From dfbb3c32409af2b3e82ea6be106a8ca631a0c27a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Mon, 4 Aug 2008 15:22:21 +0000 Subject: [PATCH] New algorithm for rendering the cube caps. The caps are now made up of many small triangles. This is needed so that we can have caps on the upcoming sphere effect. Also this way it is possible to paint textured cap in one step and not in two. So the opacity of the textured caps is now correct. The texture has got a border of one pixel in cap color so that the texture can be used to paint the whole cap and transparent areas of the texture are manually blended with the cap color. svn path=/trunk/KDE/kdebase/workspace/; revision=842034 --- effects/cube.cpp | 163 ++++++++++++++++++++++++++++++++++++++--------- effects/cube.h | 1 + 2 files changed, 135 insertions(+), 29 deletions(-) diff --git a/effects/cube.cpp b/effects/cube.cpp index 99c49e9389..79c53213f3 100644 --- a/effects/cube.cpp +++ b/effects/cube.cpp @@ -103,7 +103,24 @@ CubeEffect::CubeEffect() for( int y=0; ynumberOfDesktops(); i++ ) - { - glPushMatrix(); - glRotatef( i*angle, 0.0, 1.0, 0.0 ); - glBegin( GL_POLYGON ); - glVertex3f( -rect.width()/2, 0.0, z ); - glVertex3f( rect.width()/2, 0.0, z ); - glVertex3f( 0.0, 0.0, 0.0 ); - glEnd(); - glPopMatrix(); - } + glRotatef( (1-frontDesktop)*angle, 0.0, 1.0, 0.0 ); - // textured caps - // only works for more than three desktops + bool texture = false; if( texturedCaps && effects->numberOfDesktops() > 3 && capTexture ) { - glPushMatrix(); - glRotatef( (1-frontDesktop)*angle, 0.0, 1.0, 0.0 ); - capTexture->bind(); - glBegin( GL_QUADS ); - glTexCoord2f( 0.0, 0.0 ); - glVertex3f( -rect.width()/2, 0.0, zTexture ); - glTexCoord2f( 1.0, 0.0 ); - glVertex3f( rect.width()/2, 0.0, zTexture ); - glTexCoord2f( 1.0, 1.0 ); - glVertex3f( rect.width()/2, 0.0, -zTexture ); - glTexCoord2f( 0.0, 1.0 ); - glVertex3f( -rect.width()/2, 0.0, -zTexture ); - glEnd( ); - capTexture->unbind(); - glPopMatrix(); + texture = true; + paintCapStep( z, zTexture, true ); } + else + paintCapStep( z, zTexture, false ); glPopMatrix(); } +void CubeEffect::paintCapStep( float z, float zTexture, bool texture ) + { + QRect rect = effects->clientArea( FullArea, activeScreen, effects->currentDesktop()); + float angle = 360.0f/effects->numberOfDesktops(); + if( texture ) + capTexture->bind(); + for( int i=0; inumberOfDesktops(); i++ ) + { + int triangleRows = effects->numberOfDesktops()*5; + float zTriangleDistance = z/(float)triangleRows; + float widthTriangle = tan( angle*0.5 * M_PI/180.0 ) * zTriangleDistance; + float currentWidth = 0.0; + glBegin( GL_TRIANGLES ); + float cosValue = cos( i*angle * M_PI/180.0 ); + float sinValue = sin( i*angle * M_PI/180.0 ); + for( int j=0; junbind(); + } + } + void CubeEffect::postPaintScreen() { effects->postPaintScreen(); diff --git a/effects/cube.h b/effects/cube.h index 7323bda425..630c255afe 100644 --- a/effects/cube.h +++ b/effects/cube.h @@ -64,6 +64,7 @@ class CubeEffect }; virtual void paintScene( int mask, QRegion region, ScreenPaintData& data ); virtual void paintCap( float z, float zTexture ); + virtual void paintCapStep( float z, float zTexture, bool texture ); void rotateToDesktop( int desktop ); void setActive( bool active ); bool activated;