summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/opengl/qglshaderprogram.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/opengl/qglshaderprogram.cpp b/src/opengl/qglshaderprogram.cpp
index 8ce50cf..b07fb3b 100644
--- a/src/opengl/qglshaderprogram.cpp
+++ b/src/opengl/qglshaderprogram.cpp
@@ -441,6 +441,16 @@ static const char qualifierDefines[] =
"#define highp\n";
#endif
+// The "highp" qualifier doesn't exist in fragment shaders
+// on all ES platforms. When it doesn't exist, use "mediump".
+#ifdef QT_OPENGL_ES
+#define QGL_REDEFINE_HIGHP 1
+static const char redefineHighp[] =
+ "#ifndef GL_FRAGMENT_PRECISION_HIGH\n"
+ "#define highp mediump\n"
+ "#endif\n";
+#endif
+
/*!
Sets the \a source code for this shader and compiles it.
Returns true if the source was successfully compiled, false otherwise.
@@ -463,6 +473,11 @@ bool QGLShader::compile(const char *source)
#ifdef QGL_DEFINE_QUALIFIERS
src.append(qualifierDefines);
#endif
+#ifdef QGL_REDEFINE_HIGHP
+ if (d->shaderType == FragmentShader ||
+ d->shaderType == PartialFragmentShader)
+ src.append(redefineHighp);
+#endif
src.append(source);
glShaderSource(d->shader, src.size(), src.data(), 0);
return d->compile(this);