@@ -135,6 +135,54 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
135135 emscripten_webgl_enable_WEBGL_multi_draw__deps : [ '$webgl_enable_WEBGL_multi_draw' ] ,
136136 emscripten_webgl_enable_WEBGL_multi_draw : ( ctx ) => webgl_enable_WEBGL_multi_draw ( GL . contexts [ ctx ] . GLctx ) ,
137137
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+
138186 $GL__postset : 'var GLctx;' ,
139187#if GL_SUPPORT_AUTOMATIC_ENABLE_EXTENSIONS
140188 // 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 }}};
739787 disableHalfFloatExtensionIfBroken ( ctx ) ;
740788#endif
741789
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-
794790 return handle ;
795791 } ,
796792
@@ -1219,14 +1215,16 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
12191215 } ,
12201216#endif
12211217
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 ) ;
12251224#if GL_EXTENSIONS_IN_PREFIXED_FORMAT
1226- exts = exts . concat ( exts . map ( ( e ) => "GL_" + e ) ) ;
1225+ exts = exts . concat ( exts . map ( ( e ) => "GL_" + e ) ) ;
12271226#endif
1228- return exts ;
1229- } ,
1227+ return exts ;
12301228 } ,
12311229
12321230 glPixelStorei : ( pname , param ) => {
@@ -1236,13 +1234,13 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
12361234 GLctx . pixelStorei ( pname , param ) ;
12371235 } ,
12381236
1239- glGetString__deps : [ '$stringToNewUTF8' ] ,
1237+ glGetString__deps : [ '$stringToNewUTF8' , '$glGetExtensions' ] ,
12401238 glGetString : ( name_ ) => {
12411239 var ret = GL . stringCache [ name_ ] ;
12421240 if ( ! ret ) {
12431241 switch ( name_ ) {
12441242 case 0x1F03 /* GL_EXTENSIONS */ :
1245- ret = stringToNewUTF8 ( GL . getExtensions ( ) . join ( ' ' ) ) ;
1243+ ret = stringToNewUTF8 ( glGetExtensions ( ) . join ( ' ' ) ) ;
12461244 break ;
12471245 case 0x1F00 /* GL_VENDOR */ :
12481246 case 0x1F01 /* GL_RENDERER */ :
@@ -1304,7 +1302,11 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
13041302 return ret ;
13051303 } ,
13061304
1307- $emscriptenWebGLGet__deps : [ '$writeI53ToI64' ] ,
1305+ $emscriptenWebGLGet__deps : [ '$writeI53ToI64' ,
1306+ #if MAX_WEBGL_VERSION >= 2
1307+ '$getEmscriptenSupportedExtensions'
1308+ #endif
1309+ ] ,
13081310 $emscriptenWebGLGet : ( name_ , p , type ) = > {
13091311 // Guard against user passing a null pointer.
13101312 // 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 }}};
13671369 return ;
13681370 }
13691371#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 ) ;
13721373#if GL_EXTENSIONS_IN_PREFIXED_FORMAT
13731374 // each extension is duplicated, first in unprefixed WebGL form, and
13741375 // then a second time with "GL_" prefix.
0 commit comments