summaryrefslogtreecommitdiffstats
path: root/src/opengl
diff options
context:
space:
mode:
authorRhys Weatherley <rhys.weatherley@nokia.com>2009-09-11 06:50:24 (GMT)
committerRhys Weatherley <rhys.weatherley@nokia.com>2009-09-11 06:50:24 (GMT)
commit02df785c9d95cdafe47a087d29a25f08bfb9e387 (patch)
tree8bba0634be2e679b7cea0980cc77cbf7015dd038 /src/opengl
parent4b1a48f212c7624e9c1976c9e7c92a08b4fb307d (diff)
downloadQt-02df785c9d95cdafe47a087d29a25f08bfb9e387.zip
Qt-02df785c9d95cdafe47a087d29a25f08bfb9e387.tar.gz
Qt-02df785c9d95cdafe47a087d29a25f08bfb9e387.tar.bz2
Make mipmaps work on OpenGL/ES 2.0
Reviewed-by: Gunnar
Diffstat (limited to 'src/opengl')
-rw-r--r--src/opengl/qgl.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp
index 0e05b10..9148456 100644
--- a/src/opengl/qgl.cpp
+++ b/src/opengl/qgl.cpp
@@ -2070,6 +2070,9 @@ QGLTexture* QGLContextPrivate::bindTexture(const QImage &image, GLenum target, G
glBindTexture(target, tx_id);
glTexParameterf(target, GL_TEXTURE_MAG_FILTER, filtering);
+#if defined(QT_OPENGL_ES_2)
+ bool genMipmap = false;
+#endif
if (glFormat.directRendering()
&& QGLExtensions::glExtensions & QGLExtensions::GenerateMipmap
&& target == GL_TEXTURE_2D
@@ -2078,12 +2081,17 @@ QGLTexture* QGLContextPrivate::bindTexture(const QImage &image, GLenum target, G
#ifdef QGL_BIND_TEXTURE_DEBUG
printf(" - generating mipmaps\n");
#endif
+#if !defined(QT_OPENGL_ES_2)
glHint(GL_GENERATE_MIPMAP_HINT_SGIS, GL_NICEST);
#ifndef QT_OPENGL_ES
glTexParameteri(target, GL_GENERATE_MIPMAP_SGIS, GL_TRUE);
#else
glTexParameterf(target, GL_GENERATE_MIPMAP_SGIS, GL_TRUE);
#endif
+#else
+ glHint(GL_GENERATE_MIPMAP_HINT, GL_NICEST);
+ genMipmap = true;
+#endif
glTexParameterf(target, GL_TEXTURE_MIN_FILTER, options & QGLContext::LinearFilteringBindOption
? GL_LINEAR_MIPMAP_LINEAR : GL_NEAREST_MIPMAP_NEAREST);
} else {
@@ -2190,6 +2198,10 @@ QGLTexture* QGLContextPrivate::bindTexture(const QImage &image, GLenum target, G
const QImage &constRef = img; // to avoid detach in bits()...
glTexImage2D(target, 0, internalFormat, img.width(), img.height(), 0, externalFormat,
pixel_type, constRef.bits());
+#if defined(QT_OPENGL_ES_2)
+ if (genMipmap)
+ glGenerateMipmap(target);
+#endif
#ifndef QT_NO_DEBUG
GLenum error = glGetError();
if (error != GL_NO_ERROR) {