From 65667c0f18558f0387c57b0125ec9abcbd5ad980 Mon Sep 17 00:00:00 2001 From: Alex Szpakowski Date: Sun, 16 Jan 2022 10:30:56 -0400 Subject: [PATCH] Fix sRGB texture internal formats in OpenGL ES 3. --- src/modules/graphics/opengl/OpenGL.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/modules/graphics/opengl/OpenGL.cpp b/src/modules/graphics/opengl/OpenGL.cpp index bf2e715af..7c7118be3 100644 --- a/src/modules/graphics/opengl/OpenGL.cpp +++ b/src/modules/graphics/opengl/OpenGL.cpp @@ -1701,7 +1701,14 @@ OpenGL::TextureFormat OpenGL::convertPixelFormat(PixelFormat pixelformat, bool r if (!isPixelFormatCompressed(pixelformat)) { - if (GLAD_ES_VERSION_2_0 && !(GLAD_ES_VERSION_3_0 && pixelformat == PIXELFORMAT_LA8) + // glTexImage in OpenGL ES 2 only accepts internal format enums that + // match the external format. GLES3 doesn't have that restriction - + // except for GL_LUMINANCE_ALPHA which doesn't have a sized version in + // ES3. However we always use RG8 for PIXELFORMAT_LA8 on GLES3 so it + // doesn't matter there. + // Also note that GLES2+extension sRGB format enums are different from + // desktop GL and GLES3+ (this is handled above). + if (GLAD_ES_VERSION_2_0 && !GLAD_ES_VERSION_3_0 && !renderbuffer && !isTexStorageSupported()) { f.internalformat = f.externalformat;