From d4e75aa1dac6e535cc16e4f1fd44d4a9a2c844e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Sat, 20 Nov 2010 09:16:53 +0100 Subject: [PATCH] RenderGLGeometry and texture coord normalization are noops in ES --- lib/kwinglutils.cpp | 107 +++++--------------------------------------- lib/kwinglutils.h | 14 +++++- 2 files changed, 25 insertions(+), 96 deletions(-) diff --git a/lib/kwinglutils.cpp b/lib/kwinglutils.cpp index d903d17490..81f53770d4 100644 --- a/lib/kwinglutils.cpp +++ b/lib/kwinglutils.cpp @@ -153,92 +153,7 @@ void renderGLGeometry( const QRegion& region, int count, const float* vertices, const float* texture, const float* color, int dim, int stride ) { -#ifdef KWIN_HAVE_OPENGLES - int triangleCount = count * 6; - float* triangleVertices = new float[ dim * triangleCount ]; - float* triangleTexCoords = NULL; - float* triangleColors = NULL; - if( texture != NULL ) - { - triangleTexCoords = new float[ 2 * triangleCount ]; - } - if( color != NULL ) - { - triangleColors = new float[ 4 * triangleCount ]; - } - for( int i=0; i 5); @@ -295,15 +210,7 @@ void renderGLGeometry( const QRegion& region, int count, void renderGLGeometryImmediate( int count, const float* vertices, const float* texture, const float* color, int dim, int stride ) { -#ifdef KWIN_HAVE_OPENGLES - Q_UNUSED( count ) - Q_UNUSED( vertices ) - Q_UNUSED( texture ) - Q_UNUSED( color ) - Q_UNUSED( dim ) - Q_UNUSED( stride ) - // TODO: OpenGL ES should use a VBO -#else +#ifndef KWIN_HAVE_OPENGLES // Find out correct glVertex*fv function according to dim parameter. void ( *glVertexFunc )( const float* ) = glVertex2fv; if( dim == 3 ) @@ -582,6 +489,7 @@ void GLTexture::render( QRegion region, const QRect& rect, bool useShader ) void GLTexture::enableUnnormalizedTexCoords() { +#ifndef KWIN_HAVE_OPENGLES assert( mNormalizeActive == 0 ); if( mUnnormalizeActive++ != 0 ) return; @@ -598,20 +506,24 @@ void GLTexture::enableUnnormalizedTexCoords() glTranslatef( 0, -mSize.height(), 0 ); } glMatrixMode( GL_MODELVIEW ); +#endif } void GLTexture::disableUnnormalizedTexCoords() { +#ifndef KWIN_HAVE_OPENGLES if( --mUnnormalizeActive != 0 ) return; // Restore texture matrix glMatrixMode( GL_TEXTURE ); glPopMatrix(); glMatrixMode( GL_MODELVIEW ); +#endif } void GLTexture::enableNormalizedTexCoords() { +#ifndef KWIN_HAVE_OPENGLES assert( mUnnormalizeActive == 0 ); if( mNormalizeActive++ != 0 ) return; @@ -628,16 +540,19 @@ void GLTexture::enableNormalizedTexCoords() glTranslatef( 0, -1, 0 ); } glMatrixMode( GL_MODELVIEW ); +#endif } void GLTexture::disableNormalizedTexCoords() { +#ifndef KWIN_HAVE_OPENGLES if( --mNormalizeActive != 0 ) return; // Restore texture matrix glMatrixMode( GL_TEXTURE ); glPopMatrix(); glMatrixMode( GL_MODELVIEW ); +#endif } GLuint GLTexture::texture() const @@ -1254,6 +1169,7 @@ bool GLVertexBufferPrivate::supported = false; void GLVertexBufferPrivate::legacyPainting( QRegion region, GLenum primitiveMode ) { +#ifndef KWIN_HAVE_OPENGLES // Enable arrays glEnableClientState( GL_VERTEX_ARRAY ); glVertexPointer( dimension, GL_FLOAT, 0, legacyVertices.constData() ); @@ -1271,6 +1187,7 @@ void GLVertexBufferPrivate::legacyPainting( QRegion region, GLenum primitiveMode glDisableClientState( GL_VERTEX_ARRAY ); glDisableClientState( GL_TEXTURE_COORD_ARRAY ); +#endif } void GLVertexBufferPrivate::corePainting( const QRegion& region, GLenum primitiveMode ) diff --git a/lib/kwinglutils.h b/lib/kwinglutils.h index f05898d4c6..2b11ac1433 100644 --- a/lib/kwinglutils.h +++ b/lib/kwinglutils.h @@ -85,7 +85,7 @@ int KWIN_EXPORT nearestPowerOfTwo( int x ); * Note that texture coordinates must match texture type (normalized/unnormalized * for GL_TEXTURE_2D/GL_TEXTURE_ARB). * - * For OpenGL ES each quad is split into two triangles. + * In OpenGL ES this method is a no-op. * * @param count number of vertices to use. * @param dim number of components per vertex coordinate in vertices array. @@ -163,10 +163,16 @@ class KWIN_EXPORT GLTexture * types. This can be done only for one texture at a time, repeated * calls for the same texture are allowed though, requiring the same * amount of calls to disableUnnormalizedTexCoords(). + * + * In OpenGL ES this method is a no-op. In core profile a shader should be used + * @deprecated */ void enableUnnormalizedTexCoords(); /** * Disables transformation set up using enableUnnormalizedTexCoords(). + * + * In OpenGL ES this method is a no-op. In core profile a shader should be used + * @deprecated */ void disableUnnormalizedTexCoords(); /** @@ -176,10 +182,16 @@ class KWIN_EXPORT GLTexture * types. This can be done only for one texture at a time, repeated * calls for the same texture are allowed though, requiring the same * amount of calls to disableNormalizedTexCoords(). + * + * In OpenGL ES this method is a no-op. In core profile a shader should be used + * @deprecated */ void enableNormalizedTexCoords(); /** * Disables transformation set up using enableNormalizedTexCoords(). + * + * In OpenGL ES this method is a no-op. In core profile a shader should be used + * @deprecated */ void disableNormalizedTexCoords();