Fix internalFormat in QOpenGLTexture for ES2

Task-number: QTBUG-39856
Change-Id: I005f05c26efb4c81dd017cd4b0f16f6dac3f679e
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
This commit is contained in:
Laszlo Agocs 2014-07-08 16:40:36 +02:00 committed by Sean Harmer
parent 676e5a4f37
commit 91ae8cd044

View File

@ -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();