From 199ef040b29953a1f0ca694b1430564571e744fe Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Thu, 10 Sep 2009 11:44:28 +0200 Subject: Upload texturedata in matching internal format.. Reviewed-by: Tom --- src/opengl/qgl.cpp | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 65d6f99..8a9ea1c 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -2036,14 +2036,14 @@ QGLTexture *QGLContextPrivate::bindTexture(const QImage &image, GLenum target, G // #define QGL_BIND_TEXTURE_DEBUG -QGLTexture* QGLContextPrivate::bindTexture(const QImage &image, GLenum target, GLint format, +QGLTexture* QGLContextPrivate::bindTexture(const QImage &image, GLenum target, GLint internalFormat, const qint64 key, QGLContext::BindOptions options) { Q_Q(QGLContext); #ifdef QGL_BIND_TEXTURE_DEBUG - printf("QGLContextPrivate::bindTexture(), imageSize=(%d,%d), format=%x, options=%x\n", - image.width(), image.height(), format, int(options)); + printf("QGLContextPrivate::bindTexture(), imageSize=(%d,%d), internalFormat =0x%x, options=%x\n", + image.width(), image.height(), internalFormat, int(options)); #endif // Scale the pixmap if needed. GL textures needs to have the @@ -2092,13 +2092,13 @@ QGLTexture* QGLContextPrivate::bindTexture(const QImage &image, GLenum target, G QImage::Format target_format = img.format(); bool premul = options & QGLContext::PremultipliedAlphaBindOption; - GLenum texture_format; + GLenum externalFormat; GLuint pixel_type; if (QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_Version_1_2) { - texture_format = GL_BGRA; + externalFormat = GL_BGRA; pixel_type = GL_UNSIGNED_INT_8_8_8_8_REV; } else { - texture_format = GL_RGBA; + externalFormat = GL_RGBA; pixel_type = GL_UNSIGNED_BYTE; } @@ -2121,12 +2121,10 @@ QGLTexture* QGLContextPrivate::bindTexture(const QImage &image, GLenum target, G break; case QImage::Format_RGB16: pixel_type = GL_UNSIGNED_SHORT_5_6_5; - texture_format = GL_RGB; - format = GL_RGB; + externalFormat = GL_RGB; + internalFormat = GL_RGB; break; case QImage::Format_RGB32: - if (format == GL_RGBA) - format = GL_RGB; break; default: if (img.hasAlphaChannel()) { @@ -2145,6 +2143,9 @@ QGLTexture* QGLContextPrivate::bindTexture(const QImage &image, GLenum target, G } if (options & QGLContext::InvertedYBindOption) { +#ifdef QGL_BIND_TEXTURE_DEBUG + printf(" - flipping bits over y\n"); +#endif int ipl = img.bytesPerLine() / 4; int h = img.height(); for (int y=0; y