@@ -135,6 +135,54 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
135
135
emscripten_webgl_enable_WEBGL_multi_draw__deps : [ '$webgl_enable_WEBGL_multi_draw' ] ,
136
136
emscripten_webgl_enable_WEBGL_multi_draw : ( ctx ) => webgl_enable_WEBGL_multi_draw ( GL . contexts [ ctx ] . GLctx ) ,
137
137
138
+ $getEmscriptenSupportedExtensions__internal : true ,
139
+ $getEmscriptenSupportedExtensions : function ( ctx ) {
140
+ var supportedExtensionsForGetProcAddress = [
141
+ #if MIN_WEBGL_VERSION == 1
142
+ // WebGL 1 extensions
143
+ 'ANGLE_instanced_arrays' ,
144
+ 'EXT_blend_minmax' ,
145
+ 'EXT_disjoint_timer_query' ,
146
+ 'EXT_frag_depth' ,
147
+ 'EXT_shader_texture_lod' ,
148
+ 'EXT_sRGB' ,
149
+ 'OES_element_index_uint' ,
150
+ 'OES_fbo_render_mipmap' ,
151
+ 'OES_standard_derivatives' ,
152
+ 'OES_texture_float' ,
153
+ 'OES_texture_half_float' ,
154
+ 'OES_texture_half_float_linear' ,
155
+ 'OES_vertex_array_object' ,
156
+ 'WEBGL_color_buffer_float' ,
157
+ 'WEBGL_depth_texture' ,
158
+ 'WEBGL_draw_buffers' ,
159
+ #endif
160
+ #if MAX_WEBGL_VERSION >= 2
161
+ // WebGL 2 extensions
162
+ 'EXT_color_buffer_float' ,
163
+ 'EXT_disjoint_timer_query_webgl2' ,
164
+ 'EXT_texture_norm16' ,
165
+ 'WEBGL_clip_cull_distance' ,
166
+ #endif
167
+ // WebGL 1 and WebGL 2 extensions
168
+ 'EXT_color_buffer_half_float' ,
169
+ 'EXT_float_blend' ,
170
+ 'EXT_texture_compression_bptc' ,
171
+ 'EXT_texture_compression_rgtc' ,
172
+ 'EXT_texture_filter_anisotropic' ,
173
+ 'KHR_parallel_shader_compile' ,
174
+ 'OES_texture_float_linear' ,
175
+ 'WEBGL_compressed_texture_s3tc' ,
176
+ 'WEBGL_compressed_texture_s3tc_srgb' ,
177
+ 'WEBGL_debug_renderer_info' ,
178
+ 'WEBGL_debug_shaders' ,
179
+ 'WEBGL_lose_context' ,
180
+ 'WEBGL_multi_draw' ,
181
+ ] ;
182
+ // .getSupportedExtensions() can return null if context is lost, so coerce to empty array.
183
+ return ( ctx . getSupportedExtensions ( ) || [ ] ) . filter ( ext => supportedExtensionsForGetProcAddress . includes ( ext ) ) ; ;
184
+ } ,
185
+
138
186
$GL__postset : 'var GLctx;' ,
139
187
#if GL_SUPPORT_AUTOMATIC_ENABLE_EXTENSIONS
140
188
// If GL_SUPPORT_AUTOMATIC_ENABLE_EXTENSIONS is enabled, GL.initExtensions() will call to initialize these.
@@ -739,58 +787,6 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
739
787
disableHalfFloatExtensionIfBroken ( ctx ) ;
740
788
#endif
741
789
742
- // If end user enables *glGetProcAddress() functionality, then we must filter out
743
- // all future WebGL extensions from being passed to the user, and only restrict to advertising
744
- // extensions that the *glGetProcAddress() function knows to handle.
745
- #if GL_ENABLE_GET_PROC_ADDRESS
746
- var _allSupportedExtensions = ctx . getSupportedExtensions ;
747
- var supportedExtensionsForGetProcAddress = [
748
- #if MIN_WEBGL_VERSION == 1
749
- // WebGL 1 extensions
750
- 'ANGLE_instanced_arrays' ,
751
- 'EXT_blend_minmax' ,
752
- 'EXT_disjoint_timer_query' ,
753
- 'EXT_frag_depth' ,
754
- 'EXT_shader_texture_lod' ,
755
- 'EXT_sRGB' ,
756
- 'OES_element_index_uint' ,
757
- 'OES_fbo_render_mipmap' ,
758
- 'OES_standard_derivatives' ,
759
- 'OES_texture_float' ,
760
- 'OES_texture_half_float' ,
761
- 'OES_texture_half_float_linear' ,
762
- 'OES_vertex_array_object' ,
763
- 'WEBGL_color_buffer_float' ,
764
- 'WEBGL_depth_texture' ,
765
- 'WEBGL_draw_buffers' ,
766
- #endif
767
- #if MAX_WEBGL_VERSION >= 2
768
- // WebGL 2 extensions
769
- 'EXT_color_buffer_float' ,
770
- 'EXT_disjoint_timer_query_webgl2' ,
771
- 'EXT_texture_norm16' ,
772
- 'WEBGL_clip_cull_distance' ,
773
- #endif
774
- // WebGL 1 and WebGL 2 extensions
775
- 'EXT_color_buffer_half_float' ,
776
- 'EXT_float_blend' ,
777
- 'EXT_texture_compression_bptc' ,
778
- 'EXT_texture_compression_rgtc' ,
779
- 'EXT_texture_filter_anisotropic' ,
780
- 'KHR_parallel_shader_compile' ,
781
- 'OES_texture_float_linear' ,
782
- 'WEBGL_compressed_texture_s3tc' ,
783
- 'WEBGL_compressed_texture_s3tc_srgb' ,
784
- 'WEBGL_debug_renderer_info' ,
785
- 'WEBGL_debug_shaders' ,
786
- 'WEBGL_lose_context' ,
787
- 'WEBGL_multi_draw' ,
788
- ] ;
789
- ctx . getSupportedExtensions = function ( ) {
790
- return ( _allSupportedExtensions . apply ( this ) || [ ] ) . filter ( ext => supportedExtensionsForGetProcAddress . includes ( ext ) ) ;
791
- }
792
- #endif
793
-
794
790
return handle ;
795
791
} ,
796
792
@@ -1219,14 +1215,16 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
1219
1215
} ,
1220
1216
#endif
1221
1217
1222
- getExtensions ( ) {
1223
- // .getSupportedExtensions() can return null if context is lost, so coerce to empty array.
1224
- var exts = GLctx . getSupportedExtensions ( ) || [ ] ;
1218
+ } ,
1219
+
1220
+ $glGetExtensions__internal : true ,
1221
+ $glGetExtensions__deps : [ '$getEmscriptenSupportedExtensions' ] ,
1222
+ $glGetExtensions ( ctx ) {
1223
+ var exts = getEmscriptenSupportedExtensions ( ctx ) ;
1225
1224
#if GL_EXTENSIONS_IN_PREFIXED_FORMAT
1226
- exts = exts . concat ( exts . map ( ( e ) => "GL_" + e ) ) ;
1225
+ exts = exts . concat ( exts . map ( ( e ) => "GL_" + e ) ) ;
1227
1226
#endif
1228
- return exts ;
1229
- } ,
1227
+ return exts ;
1230
1228
} ,
1231
1229
1232
1230
glPixelStorei : ( pname , param ) => {
@@ -1236,13 +1234,13 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
1236
1234
GLctx . pixelStorei ( pname , param ) ;
1237
1235
} ,
1238
1236
1239
- glGetString__deps : [ '$stringToNewUTF8' ] ,
1237
+ glGetString__deps : [ '$stringToNewUTF8' , '$glGetExtensions' ] ,
1240
1238
glGetString : ( name_ ) => {
1241
1239
var ret = GL . stringCache [ name_ ] ;
1242
1240
if ( ! ret ) {
1243
1241
switch ( name_ ) {
1244
1242
case 0x1F03 /* GL_EXTENSIONS */ :
1245
- ret = stringToNewUTF8 ( GL . getExtensions ( ) . join ( ' ' ) ) ;
1243
+ ret = stringToNewUTF8 ( glGetExtensions ( ) . join ( ' ' ) ) ;
1246
1244
break ;
1247
1245
case 0x1F00 /* GL_VENDOR */ :
1248
1246
case 0x1F01 /* GL_RENDERER */ :
@@ -1304,7 +1302,11 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
1304
1302
return ret ;
1305
1303
} ,
1306
1304
1307
- $emscriptenWebGLGet__deps : [ '$writeI53ToI64' ] ,
1305
+ $emscriptenWebGLGet__deps : [ '$writeI53ToI64' ,
1306
+ #if MAX_WEBGL_VERSION >= 2
1307
+ '$getEmscriptenSupportedExtensions'
1308
+ #endif
1309
+ ] ,
1308
1310
$emscriptenWebGLGet : ( name_ , p , type ) = > {
1309
1311
// Guard against user passing a null pointer.
1310
1312
// Note that GLES2 spec does not say anything about how passing a null
@@ -1367,8 +1369,7 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
1367
1369
return ;
1368
1370
}
1369
1371
#endif
1370
- // .getSupportedExtensions() can return null if context is lost, so coerce to empty array.
1371
- var exts = GLctx . getSupportedExtensions ( ) || [ ] ;
1372
+ var exts = getEmscriptenSupportedExtensions ( GLctx ) ;
1372
1373
#if GL_EXTENSIONS_IN_PREFIXED_FORMAT
1373
1374
// each extension is duplicated, first in unprefixed WebGL form, and
1374
1375
// then a second time with "GL_" prefix.
0 commit comments