From 69044f10c591907bf1cf496119ded0bdf8ce17ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Sun, 12 Dec 2010 09:56:19 +0100 Subject: [PATCH] GLShader appends the ES specific commands to the shaders --- lib/kwinglutils.cpp | 12 ++++++++++-- scene-color-fragment.glsl | 3 --- scene-color-vertex.glsl | 3 --- scene-fragment.glsl | 3 --- scene-generic-vertex.glsl | 3 --- scene-vertex.glsl | 3 --- 6 files changed, 10 insertions(+), 17 deletions(-) diff --git a/lib/kwinglutils.cpp b/lib/kwinglutils.cpp index ae0ed72453..21fa7aa319 100644 --- a/lib/kwinglutils.cpp +++ b/lib/kwinglutils.cpp @@ -873,7 +873,11 @@ bool GLShader::load(const QString& vertexsource, const QString& fragmentsource) // Create shader object vertexshader = glCreateShader(GL_VERTEX_SHADER); // Load it - const QByteArray& srcba = vertexsource.toLatin1(); + QByteArray srcba; +#ifdef KWIN_HAVE_OPENGLES + srcba.append("#ifdef GL_ES\nprecision highp float;\n#endif\n"); +#endif + srcba.append(vertexsource.toLatin1()); const char* src = srcba.data(); glShaderSource(vertexshader, 1, &src, NULL); // Compile the shader @@ -905,7 +909,11 @@ bool GLShader::load(const QString& vertexsource, const QString& fragmentsource) { fragmentshader = glCreateShader(GL_FRAGMENT_SHADER); // Load it - const QByteArray& srcba = fragmentsource.toLatin1(); + QByteArray srcba; +#ifdef KWIN_HAVE_OPENGLES + srcba.append("#ifdef GL_ES\nprecision highp float;\n#endif\n"); +#endif + srcba.append(fragmentsource.toLatin1()); const char* src = srcba.data(); glShaderSource(fragmentshader, 1, &src, NULL); //glShaderSource(fragmentshader, 1, &fragmentsrc.latin1(), NULL); diff --git a/scene-color-fragment.glsl b/scene-color-fragment.glsl index 748707163a..db3473eae2 100644 --- a/scene-color-fragment.glsl +++ b/scene-color-fragment.glsl @@ -1,6 +1,3 @@ -#ifdef GL_ES -precision highp float; -#endif uniform vec4 geometryColor; void main() { diff --git a/scene-color-vertex.glsl b/scene-color-vertex.glsl index 12a4672228..09759c5395 100644 --- a/scene-color-vertex.glsl +++ b/scene-color-vertex.glsl @@ -1,6 +1,3 @@ -#ifdef GL_ES -precision highp float; -#endif // size of the complete display in pixels, x==width, y==height uniform vec2 displaySize; // geometry of the window/texture to be rendered: x, y, width, height in display geometry diff --git a/scene-fragment.glsl b/scene-fragment.glsl index 7d9724100d..c754871c13 100644 --- a/scene-fragment.glsl +++ b/scene-fragment.glsl @@ -1,6 +1,3 @@ -#ifdef GL_ES -precision highp float; -#endif uniform sampler2D sample; uniform float textureWidth; uniform float textureHeight; diff --git a/scene-generic-vertex.glsl b/scene-generic-vertex.glsl index a270a7d5ff..b40f4d381e 100644 --- a/scene-generic-vertex.glsl +++ b/scene-generic-vertex.glsl @@ -1,6 +1,3 @@ -#ifdef GL_ES -precision highp float; -#endif uniform mat4 projection; uniform mat4 modelview; uniform mat4 screenTransformation; diff --git a/scene-vertex.glsl b/scene-vertex.glsl index cd259449f3..766609f286 100644 --- a/scene-vertex.glsl +++ b/scene-vertex.glsl @@ -1,6 +1,3 @@ -#ifdef GL_ES -precision highp float; -#endif // size of the complete display in pixels, x==width, y==height uniform vec2 displaySize; // geometry of the window/texture to be rendered: x, y, width, height in display geometry