diff options
author | Rhys Weatherley <rhys.weatherley@nokia.com> | 2009-08-27 23:35:53 (GMT) |
---|---|---|
committer | Rhys Weatherley <rhys.weatherley@nokia.com> | 2009-08-27 23:35:53 (GMT) |
commit | e9274b6cb9bbc71cf9aa7614190e0d3a242fef29 (patch) | |
tree | 4a1ea5a83dfaa90580430e3f7b02e43a756f67ab /src/opengl | |
parent | d4973f096ebbaada144ea1d6d0c44c5274d5279c (diff) | |
download | Qt-e9274b6cb9bbc71cf9aa7614190e0d3a242fef29.zip Qt-e9274b6cb9bbc71cf9aa7614190e0d3a242fef29.tar.gz Qt-e9274b6cb9bbc71cf9aa7614190e0d3a242fef29.tar.bz2 |
Define highp to mediump on OpenGL/ES systems that don't have highp
Reviewed-by: Tom Cooksey
Diffstat (limited to 'src/opengl')
-rw-r--r-- | src/opengl/qglshaderprogram.cpp | 15 |
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); |