From 08dfa85052a35ab11849026b0301d61637e43413 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Wed, 11 Feb 2015 12:29:23 +0100 Subject: 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 --- src/render/io/texturedata.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') 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) -- cgit v1.2.3