summaryrefslogtreecommitdiffstats
path: root/src/opengl/qopengltexture.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/opengl/qopengltexture.cpp')
-rw-r--r--src/opengl/qopengltexture.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/opengl/qopengltexture.cpp b/src/opengl/qopengltexture.cpp
index 6700f0e383..3b8e14490b 100644
--- a/src/opengl/qopengltexture.cpp
+++ b/src/opengl/qopengltexture.cpp
@@ -2456,6 +2456,9 @@ QOpenGLTexture::QOpenGLTexture(Target target)
This does create the underlying OpenGL texture object. Therefore,
construction using this constructor does require a valid current
OpenGL context.
+
+ \note \a image is automatically converted to QImage::Format_RGBA8888 which
+ may have performance implications for large images with a different format.
*/
QOpenGLTexture::QOpenGLTexture(const QImage& image, MipMapGeneration genMipMaps)
: QOpenGLTexture(QOpenGLTexture::Target2D)
@@ -3610,6 +3613,9 @@ void QOpenGLTexture::setData(int xOffset, int yOffset, int zOffset,
The pixel data is contained in \a image. Mipmaps are generated by default.
Set \a genMipMaps to \l DontGenerateMipMaps to turn off mipmap generation.
+ \note \a image is automatically converted to QImage::Format_RGBA8888 which
+ may have performance implications for large images with a different format.
+
\overload
*/
void QOpenGLTexture::setData(const QImage& image, MipMapGeneration genMipMaps)
@@ -3625,6 +3631,12 @@ void QOpenGLTexture::setData(const QImage& image, MipMapGeneration genMipMaps)
return;
}
+ QImage glImage = image.convertToFormat(QImage::Format_RGBA8888);
+ if (glImage.isNull()) {
+ qWarning("QOpenGLTexture::setData() failed to convert image");
+ return;
+ }
+
if (context->isOpenGLES() && context->format().majorVersion() < 3)
setFormat(QOpenGLTexture::RGBAFormat);
else
@@ -3635,7 +3647,6 @@ void QOpenGLTexture::setData(const QImage& image, MipMapGeneration genMipMaps)
allocateStorage(QOpenGLTexture::RGBA, QOpenGLTexture::UInt8);
// Upload pixel data and generate mipmaps
- QImage glImage = image.convertToFormat(QImage::Format_RGBA8888);
QOpenGLPixelTransferOptions uploadOptions;
uploadOptions.setAlignment(1);
setData(0, QOpenGLTexture::RGBA, QOpenGLTexture::UInt8, glImage.constBits(), &uploadOptions);