diff --git a/lib/kwinglutils.cpp b/lib/kwinglutils.cpp index cdbaa3eecc..8db291397d 100644 --- a/lib/kwinglutils.cpp +++ b/lib/kwinglutils.cpp @@ -1252,6 +1252,7 @@ class GLVertexBufferPrivate , dimension( 2 ) , useShader( false ) , useColor( false ) + , useTexCoords( true ) , color( 0, 0, 0, 255 ) { if( GLVertexBufferPrivate::supported ) @@ -1275,6 +1276,7 @@ class GLVertexBufferPrivate QVector legacyVertices; QVector legacyTexCoords; bool useColor; + bool useTexCoords; QColor color; void legacyPainting( QRegion region, GLenum primitiveMode ); @@ -1316,7 +1318,9 @@ void GLVertexBufferPrivate::legacyPainting( QRegion region, GLenum primitiveMode void GLVertexBufferPrivate::corePainting( const QRegion& region, GLenum primitiveMode ) { glEnableVertexAttribArray( 0 ); - glEnableVertexAttribArray( 1 ); + if (useTexCoords) { + glEnableVertexAttribArray( 1 ); + } // TODO: have this information available somewhere useable GLint currentProgram; @@ -1324,19 +1328,21 @@ void GLVertexBufferPrivate::corePainting( const QRegion& region, GLenum primitiv GLint vertexAttrib = glGetAttribLocation( currentProgram, "vertex" ); GLint texAttrib = glGetAttribLocation( currentProgram, "texCoord" ); - glBindBuffer( GL_ARRAY_BUFFER, buffers[ 0 ] ); - glVertexAttribPointer( vertexAttrib, dimension, GL_FLOAT, GL_FALSE, 0, 0 ); - - glBindBuffer( GL_ARRAY_BUFFER, buffers[ 1 ] ); - glVertexAttribPointer( texAttrib, 2, GL_FLOAT, GL_FALSE, 0, 0 ); - if (useColor) { GLint colorLocation = glGetUniformLocation(currentProgram, "geometryColor"); if (colorLocation != 0) { - glUniform4f(currentProgram, color.redF(), color.greenF(), color.blueF(), color.alphaF()); + glUniform4f(colorLocation, color.redF(), color.greenF(), color.blueF(), color.alphaF()); } } + glBindBuffer( GL_ARRAY_BUFFER, buffers[ 0 ] ); + glVertexAttribPointer( vertexAttrib, dimension, GL_FLOAT, GL_FALSE, 0, 0 ); + + if (texAttrib != -1 && useTexCoords) { + glBindBuffer( GL_ARRAY_BUFFER, buffers[ 1 ] ); + glVertexAttribPointer( texAttrib, 2, GL_FLOAT, GL_FALSE, 0, 0 ); + } + // TODO: reenable paint clipper // Clip using scissoring PaintClipper pc( region ); @@ -1349,7 +1355,9 @@ void GLVertexBufferPrivate::corePainting( const QRegion& region, GLenum primitiv glBindBuffer( GL_ARRAY_BUFFER, 0 ); - glDisableVertexAttribArray( 1 ); + if (useTexCoords) { + glDisableVertexAttribArray( 1 ); + } glDisableVertexAttribArray( 0 ); } @@ -1370,6 +1378,7 @@ void GLVertexBuffer::setData( int numberVertices, int dim, const float* vertices { d->numberVertices = numberVertices; d->dimension = dim; + d->useTexCoords = (texcoords != NULL); if( !GLVertexBufferPrivate::supported ) { // legacy data @@ -1380,7 +1389,7 @@ void GLVertexBuffer::setData( int numberVertices, int dim, const float* vertices d->legacyVertices << vertices[i]; } d->legacyTexCoords.clear(); - if (texcoords != NULL) { + if (d->useTexCoords) { d->legacyTexCoords.reserve( numberVertices * 2 ); for (int i=0; ilegacyTexCoords << texcoords[i]; @@ -1408,7 +1417,7 @@ void GLVertexBuffer::setData( int numberVertices, int dim, const float* vertices glBindBuffer( GL_ARRAY_BUFFER, d->buffers[ 0 ] ); glBufferData( GL_ARRAY_BUFFER, sizeof(GLfloat)*numberVertices*d->dimension, vertices, hint ); - if (texcoords != NULL) { + if (d->useTexCoords) { glBindBuffer( GL_ARRAY_BUFFER, d->buffers[ 1 ] ); glBufferData( GL_ARRAY_BUFFER, sizeof(GLfloat)*numberVertices*2, texcoords, hint ); } diff --git a/scene-color-fragment.glsl b/scene-color-fragment.glsl index d2b425053b..748707163a 100644 --- a/scene-color-fragment.glsl +++ b/scene-color-fragment.glsl @@ -3,9 +3,6 @@ precision highp float; #endif uniform vec4 geometryColor; -// not used -varying vec2 varyingTexCoords; - void main() { gl_FragColor = geometryColor; }