From 5001f79c4f98e22d9a301ae6519a67d1135f7312 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Sat, 28 Sep 2019 21:31:19 -0500 Subject: Support DXT1/3/5 in compressed texture atlas Change-Id: I791adbfce96481aea71bb285e48b89cb5db08e1c Reviewed-by: Eirik Aavitsland --- .../compressedtexture/qsgcompressedatlastexture.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/quick/scenegraph/compressedtexture') diff --git a/src/quick/scenegraph/compressedtexture/qsgcompressedatlastexture.cpp b/src/quick/scenegraph/compressedtexture/qsgcompressedatlastexture.cpp index d3dc4978f2..46b2c6386c 100644 --- a/src/quick/scenegraph/compressedtexture/qsgcompressedatlastexture.cpp +++ b/src/quick/scenegraph/compressedtexture/qsgcompressedatlastexture.cpp @@ -88,10 +88,20 @@ Texture *Atlas::create(const QByteArray &data, int dataLength, int dataOffset, c void Atlas::generateTexture() { + int bytesPerBlock = 8; + switch (m_format) { + case QOpenGLTexture::RGBA8_ETC2_EAC: + case QOpenGLTexture::RGBA_DXT3: + case QOpenGLTexture::RGBA_DXT5: + bytesPerBlock = 16; + default: + break; + } + QOpenGLFunctions *funcs = QOpenGLContext::currentContext()->functions(); funcs->glCompressedTexImage2D(GL_TEXTURE_2D, 0, m_format, m_size.width(), m_size.height(), 0, - (m_size.width() * m_size.height()) / 2, + (m_size.width() / 4 * m_size.height() / 4) * bytesPerBlock, nullptr); } -- cgit v1.2.3