diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2024-06-25 09:20:01 +0200 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2024-06-25 09:20:01 +0200 |
commit | 1a0190270fb6c658fe0842fa424f9e87d7d2bb42 (patch) | |
tree | 6f817b8335aceffb3734ab0a3ec953cac13189fc /drivers/gles3 | |
parent | fb8a1f143a52a08ded3a3f86a8be444cf09f4633 (diff) | |
parent | 51f9df0ec8f0eb8b65c551a3edf4d8abe7e9b663 (diff) | |
download | redot-engine-1a0190270fb6c658fe0842fa424f9e87d7d2bb42.tar.gz |
Merge pull request #93560 from dsnopek/webxr-emscripten-3151
[Web] Fix checking for OpenGL extensions with Emscripten 3.1.51 and later
Diffstat (limited to 'drivers/gles3')
-rw-r--r-- | drivers/gles3/storage/config.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/drivers/gles3/storage/config.cpp b/drivers/gles3/storage/config.cpp index 1a14902c7c..a28b050bf8 100644 --- a/drivers/gles3/storage/config.cpp +++ b/drivers/gles3/storage/config.cpp @@ -35,6 +35,10 @@ #include "../rasterizer_gles3.h" #include "texture_storage.h" +#ifdef WEB_ENABLED +#include <emscripten/html5_webgl.h> +#endif + using namespace GLES3; #define _GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF @@ -44,6 +48,23 @@ Config *Config::singleton = nullptr; Config::Config() { singleton = this; +#ifdef WEB_ENABLED + // Starting with Emscripten 3.1.51, glGetStringi(GL_EXTENSIONS, i) will only ever return + // a fixed list of extensions, regardless of what additional extensions are enabled. This + // isn't very useful for us in determining which extensions we can rely on here. So, instead + // we use emscripten_webgl_get_supported_extensions() to get all supported extensions, which + // is what Emscripten 3.1.50 and earlier do. + { + char *extension_array_string = emscripten_webgl_get_supported_extensions(); + PackedStringArray extension_array = String((const char *)extension_array_string).split(" "); + extensions.reserve(extension_array.size() * 2); + for (const String &s : extension_array) { + extensions.insert(s); + extensions.insert("GL_" + s); + } + free(extension_array_string); + } +#else { GLint max_extensions = 0; glGetIntegerv(GL_NUM_EXTENSIONS, &max_extensions); @@ -55,6 +76,7 @@ Config::Config() { extensions.insert((const char *)s); } } +#endif bptc_supported = extensions.has("GL_ARB_texture_compression_bptc") || extensions.has("EXT_texture_compression_bptc"); astc_supported = extensions.has("GL_KHR_texture_compression_astc") || extensions.has("GL_OES_texture_compression_astc") || extensions.has("GL_KHR_texture_compression_astc_ldr") || extensions.has("GL_KHR_texture_compression_astc_hdr"); |