From 8efcae424319b1e093d2819c2a8b18744564fc15 Mon Sep 17 00:00:00 2001 From: Jonny Hopper Date: Tue, 18 Aug 2015 11:57:15 +0100 Subject: [PATCH] Fix crash on some OpenGLES devices On some older OpenGLES devices, attempting to bind textures to unsupported compressed formats can crash. So explicitly disable the unsupported formats so this never happens. --- src/renderer_gl.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/renderer_gl.cpp b/src/renderer_gl.cpp index b7552b5b..592133ee 100644 --- a/src/renderer_gl.cpp +++ b/src/renderer_gl.cpp @@ -1451,7 +1451,21 @@ namespace bgfx { namespace gl setTextureFormat(TextureFormat::BGRA8, GL_RGBA, GL_BGRA, GL_UNSIGNED_BYTE); } } + +#ifdef BGFX_CONFIG_RENDERER_OPENGLES + // on some older devices attempting glTexImage2D or glCompressedTexImage2D with unsupported compressed formats can crash + // so disable the format by setting to GL_ZERO + for (uint32_t ii = 0; ii < TextureFormat::Unknown; ++ii) + { + if ( !s_textureFormat[ ii ].m_supported ) + { + s_textureFormat[ ii ].m_internalFmt = GL_ZERO; + s_textureFormat[ ii ].m_internalFmtSrgb = GL_ZERO; + } + } +#endif + if (BX_ENABLED(BX_PLATFORM_EMSCRIPTEN) || !isTextureFormatValid(TextureFormat::R8) ) {