From 91ae8cd044d9039212a1a71ede91afd5f8cb3ac5 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Tue, 8 Jul 2014 16:40:36 +0200 Subject: [PATCH] Fix internalFormat in QOpenGLTexture for ES2 Task-number: QTBUG-39856 Change-Id: I005f05c26efb4c81dd017cd4b0f16f6dac3f679e Reviewed-by: Giuseppe D'Angelo --- src/gui/opengl/qopengltexture.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/gui/opengl/qopengltexture.cpp b/src/gui/opengl/qopengltexture.cpp index 06a71af552..0b9732d278 100644 --- a/src/gui/opengl/qopengltexture.cpp +++ b/src/gui/opengl/qopengltexture.cpp @@ -2664,7 +2664,16 @@ void QOpenGLTexture::setData(PixelFormat sourceFormat, PixelType sourceType, */ void QOpenGLTexture::setData(const QImage& image, MipMapGeneration genMipMaps) { - setFormat(QOpenGLTexture::RGBA8_UNorm); + QOpenGLContext *context = QOpenGLContext::currentContext(); + if (!context) { + qWarning("QOpenGLTexture::setData() requires a valid current context"); + return; + } + if (context->isOpenGLES() && context->format().majorVersion() < 3) + setFormat(QOpenGLTexture::RGBAFormat); + else + setFormat(QOpenGLTexture::RGBA8_UNorm); + setSize(image.width(), image.height()); setMipLevels(genMipMaps == GenerateMipMaps ? maximumMipLevels() : 1); allocateStorage();