diff --git a/src/modules/graphics/opengl/Font.cpp b/src/modules/graphics/opengl/Font.cpp index 40854601c..0b090536b 100644 --- a/src/modules/graphics/opengl/Font.cpp +++ b/src/modules/graphics/opengl/Font.cpp @@ -85,6 +85,14 @@ void Font::createTexture() bool sRGB = isGammaCorrect(); OpenGL::TextureFormat fmt = gl.convertPixelFormat(pixelFormat, false, sRGB); + if (fmt.swizzled) + { + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_R, fmt.swizzle[0]); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_G, fmt.swizzle[1]); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_B, fmt.swizzle[2]); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_A, fmt.swizzle[3]); + } + // Initialize the texture with transparent black. std::vector emptydata(size.width * size.height * bpp, 0); diff --git a/src/modules/graphics/opengl/OpenGL.cpp b/src/modules/graphics/opengl/OpenGL.cpp index 38f3c0b86..38c301f6e 100644 --- a/src/modules/graphics/opengl/OpenGL.cpp +++ b/src/modules/graphics/opengl/OpenGL.cpp @@ -868,9 +868,21 @@ OpenGL::TextureFormat OpenGL::convertPixelFormat(PixelFormat pixelformat, bool r break; case PIXELFORMAT_LA8: - f.internalformat = GL_LUMINANCE8_ALPHA8; - f.externalformat = GL_LUMINANCE_ALPHA; - f.type = GL_UNSIGNED_BYTE; + if (gl.isCoreProfile() || GLAD_ES_VERSION_3_0) + { + f.internalformat = GL_RG8; + f.externalformat = GL_RG; + f.type = GL_UNSIGNED_BYTE; + f.swizzled = true; + f.swizzle[0] = f.swizzle[1] = f.swizzle[2] = GL_RED; + f.swizzle[3] = GL_GREEN; + } + else + { + f.internalformat = GL_LUMINANCE8_ALPHA8; + f.externalformat = GL_LUMINANCE_ALPHA; + f.type = GL_UNSIGNED_BYTE; + } break; case PIXELFORMAT_RGBA4: diff --git a/src/modules/graphics/opengl/OpenGL.h b/src/modules/graphics/opengl/OpenGL.h index 9ee4a303d..51f2ba9ce 100644 --- a/src/modules/graphics/opengl/OpenGL.h +++ b/src/modules/graphics/opengl/OpenGL.h @@ -92,6 +92,9 @@ public: GLenum internalformat = 0; GLenum externalformat = 0; GLenum type = 0; + + bool swizzled = false; + GLint swizzle[4]; }; class TempDebugGroup