From 3a7090684ad1dede403b174b514794c90c330f36 Mon Sep 17 00:00:00 2001 From: bkaradzic Date: Wed, 23 Jan 2013 23:42:38 -0800 Subject: [PATCH] Fixed bug caused by mixing GLES and GL texture extensions. --- src/bgfx_p.h | 2 +- src/renderer_gl.cpp | 22 ++++++++++++++++++++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/bgfx_p.h b/src/bgfx_p.h index a530754b..df98727d 100755 --- a/src/bgfx_p.h +++ b/src/bgfx_p.h @@ -18,7 +18,7 @@ extern void dbgPrintf(const char* _format, ...); extern void dbgPrintfData(const void* _data, uint32_t _size, const char* _format, ...); #ifndef BGFX_CONFIG_DEBUG -# define BGFX_CONFIG_DEBUG 0 +# define BGFX_CONFIG_DEBUG 1 #endif // BGFX_CONFIG_DEBUG #if BGFX_CONFIG_DEBUG diff --git a/src/renderer_gl.cpp b/src/renderer_gl.cpp index cc4bd3ab..77020e6d 100644 --- a/src/renderer_gl.cpp +++ b/src/renderer_gl.cpp @@ -18,6 +18,7 @@ namespace bgfx { EXT_texture_filter_anisotropic, EXT_texture_format_BGRA8888, + EXT_bgra, EXT_texture_compression_s3tc, EXT_texture_compression_dxt1, CHROMIUM_texture_compression_dxt3, @@ -68,6 +69,7 @@ namespace bgfx { { "GL_EXT_texture_filter_anisotropic", false, true }, { "GL_EXT_texture_format_BGRA8888", false, true }, + { "GL_EXT_bgra", false, true }, { "GL_EXT_texture_compression_s3tc", false, true }, { "GL_EXT_texture_compression_dxt1", false, true }, { "GL_CHROMIUM_texture_compression_dxt3", false, true }, @@ -1819,7 +1821,8 @@ namespace bgfx s_textureFormat[TextureFormat::BC3].m_supported = bc123Supported || s_extension[Extension::CHROMIUM_texture_compression_dxt5].m_supported; bool bc45Supported = s_extension[Extension::EXT_texture_compression_latc].m_supported - || s_extension[Extension::EXT_texture_compression_rgtc].m_supported; + || s_extension[Extension::EXT_texture_compression_rgtc].m_supported + ; s_textureFormat[TextureFormat::BC4].m_supported = bc45Supported; s_textureFormat[TextureFormat::BC5].m_supported = bc45Supported; @@ -1843,10 +1846,25 @@ namespace bgfx glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &s_renderCtx.m_maxAnisotropy); } - if (s_extension[Extension::EXT_texture_format_BGRA8888].m_supported) + if (s_extension[Extension::EXT_texture_format_BGRA8888].m_supported + || s_extension[Extension::EXT_bgra].m_supported) { s_textureFormat[TextureFormat::BGRX8].m_fmt = GL_BGRA_EXT; s_textureFormat[TextureFormat::BGRA8].m_fmt = GL_BGRA_EXT; + + // Mixing GLES and GL extensions here. OpenGL EXT_bgra wants + // format to be BGRA but internal format to stay RGBA, but + // EXT_texture_format_BGRA8888 wants both format and internal + // format to be BGRA. + // + // Reference: + // https://www.khronos.org/registry/gles/extensions/EXT/EXT_texture_format_BGRA8888.txt + // https://www.opengl.org/registry/specs/EXT/bgra.txt + if (!s_extension[Extension::EXT_bgra].m_supported) + { + s_textureFormat[TextureFormat::BGRX8].m_internalFmt = GL_BGRA_EXT; + s_textureFormat[TextureFormat::BGRA8].m_internalFmt = GL_BGRA_EXT; + } } #if !BGFX_CONFIG_RENDERER_OPENGLES3