From e9274b6cb9bbc71cf9aa7614190e0d3a242fef29 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Fri, 28 Aug 2009 09:35:53 +1000 Subject: Define highp to mediump on OpenGL/ES systems that don't have highp Reviewed-by: Tom Cooksey --- src/opengl/qglshaderprogram.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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); -- cgit v0.12