summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@theqtcompany.com>2015-02-11 12:29:23 +0100
committerLaszlo Agocs <laszlo.agocs@theqtcompany.com>2015-02-11 12:00:20 +0000
commit08dfa85052a35ab11849026b0301d61637e43413 (patch)
treec5bce9526bad118cadc7bf79ced2c187c26a61e4 /src
parent70a578be0e160ac7c5d4817f1972bc16686c344b (diff)
Fix image format for textures
We always convert to RGBA8888 so the only acceptable combination is GL_RGBA - GL_RGBA8. Previously we were checking the presence of the alpha channel in the original image. This is quite wrong since we end up with GL_RGBA - GL_RGB8 type of combinations in case the input has no alpha. That is not a valid combination. This makes images without an alpha channel, e.g. image formats that provide Format_RGB32 QImages, working. Change-Id: I2631071134c5224c52b64cff2f00ef6ae166762b Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'src')
-rw-r--r--src/render/io/texturedata.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/render/io/texturedata.cpp b/src/render/io/texturedata.cpp
index cfccefff4..745e0f54e 100644
--- a/src/render/io/texturedata.cpp
+++ b/src/render/io/texturedata.cpp
@@ -54,14 +54,14 @@ TexImageData::TexImageData()
void TexImageData::setImage(const QImage &image)
{
- QImage glImage = image.convertToFormat(QImage::Format_RGBA8888);
m_width = image.width();
m_height = image.height();
m_depth = 1;
+
+ QImage glImage = image.convertToFormat(QImage::Format_RGBA8888);
QByteArray imageBytes((const char*) glImage.constBits(), glImage.byteCount());
setData(imageBytes, QOpenGLTexture::RGBA, QOpenGLTexture::UInt8);
- m_format = image.hasAlphaChannel() ? QOpenGLTexture::RGBA8_UNorm :
- QOpenGLTexture::RGB8_UNorm;
+ m_format = QOpenGLTexture::RGBA8_UNorm;
}
void TexImageData::setData(const QByteArray &data, QOpenGLTexture::PixelFormat fmt, QOpenGLTexture::PixelType ptype)