Skip to content

Commit 51f9df0

Browse files
committed
[Web] Fix checking for OpenGL extensions with Emscripten 3.1.51 and later
1 parent e78dc83 commit 51f9df0

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

drivers/gles3/storage/config.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@
3535
#include "../rasterizer_gles3.h"
3636
#include "texture_storage.h"
3737

38+
#ifdef WEB_ENABLED
39+
#include <emscripten/html5_webgl.h>
40+
#endif
41+
3842
using namespace GLES3;
3943

4044
#define _GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF
@@ -44,6 +48,23 @@ Config *Config::singleton = nullptr;
4448
Config::Config() {
4549
singleton = this;
4650

51+
#ifdef WEB_ENABLED
52+
// Starting with Emscripten 3.1.51, glGetStringi(GL_EXTENSIONS, i) will only ever return
53+
// a fixed list of extensions, regardless of what additional extensions are enabled. This
54+
// isn't very useful for us in determining which extensions we can rely on here. So, instead
55+
// we use emscripten_webgl_get_supported_extensions() to get all supported extensions, which
56+
// is what Emscripten 3.1.50 and earlier do.
57+
{
58+
char *extension_array_string = emscripten_webgl_get_supported_extensions();
59+
PackedStringArray extension_array = String((const char *)extension_array_string).split(" ");
60+
extensions.reserve(extension_array.size() * 2);
61+
for (const String &s : extension_array) {
62+
extensions.insert(s);
63+
extensions.insert("GL_" + s);
64+
}
65+
free(extension_array_string);
66+
}
67+
#else
4768
{
4869
GLint max_extensions = 0;
4970
glGetIntegerv(GL_NUM_EXTENSIONS, &max_extensions);
@@ -55,6 +76,7 @@ Config::Config() {
5576
extensions.insert((const char *)s);
5677
}
5778
}
79+
#endif
5880

5981
bptc_supported = extensions.has("GL_ARB_texture_compression_bptc") || extensions.has("EXT_texture_compression_bptc");
6082
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");

0 commit comments

Comments
 (0)