From 4f3f5ea02d8ccab6fb2b72ca11050b24787391cf Mon Sep 17 00:00:00 2001 From: Bearborg Date: Wed, 25 Dec 2019 11:34:28 -0500 Subject: [PATCH] Replace deprecated GL_LUMINANCE and GL_LUMINANCE_ALPHA texture formats --- src/Core/Resource/CTexture.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Core/Resource/CTexture.cpp b/src/Core/Resource/CTexture.cpp index d7104613..4dd956ee 100644 --- a/src/Core/Resource/CTexture.cpp +++ b/src/Core/Resource/CTexture.cpp @@ -49,11 +49,11 @@ bool CTexture::BufferGL() switch (mTexelFormat) { case ETexelFormat::Luminance: - GLFormat = GL_LUMINANCE; + GLFormat = GL_R; GLType = GL_UNSIGNED_BYTE; break; case ETexelFormat::LuminanceAlpha: - GLFormat = GL_LUMINANCE_ALPHA; + GLFormat = GL_RG; GLType = GL_UNSIGNED_BYTE; break; case ETexelFormat::RGB565: @@ -104,6 +104,13 @@ bool CTexture::BufferGL() glTexParameteri(BindTarget, GL_TEXTURE_BASE_LEVEL, 0); glTexParameteri(BindTarget, GL_TEXTURE_MAX_LEVEL, mNumMipMaps - 1); + // Swizzling for luminance textures: + if (mTexelFormat == ETexelFormat::Luminance || mTexelFormat == ETexelFormat::LuminanceAlpha) + { + GLint SwizzleMask[] = {GL_RED, GL_RED, GL_RED, GLFormat == GL_RG ? GL_GREEN : GL_ONE}; + glTexParameteriv(BindTarget, GL_TEXTURE_SWIZZLE_RGBA, SwizzleMask); + } + // Linear filtering on mipmaps: glTexParameteri(BindTarget, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(BindTarget, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);