summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@digia.com>2014-07-08 16:40:36 +0200
committerSean Harmer <sean.harmer@kdab.com>2014-07-09 17:13:49 +0200
commit91ae8cd044d9039212a1a71ede91afd5f8cb3ac5 (patch)
treeec1733932aaa737bcc1e91226dbc6e125d6f48a7 /src/gui
parent676e5a4f37383f7b173e69e8802652e062b60f78 (diff)
Fix internalFormat in QOpenGLTexture for ES2
Task-number: QTBUG-39856 Change-Id: I005f05c26efb4c81dd017cd4b0f16f6dac3f679e Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/opengl/qopengltexture.cpp11
1 files changed, 10 insertions, 1 deletions
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();