@@ -472,6 +472,18 @@ var LibraryGL = {
472
472
webGLContextAttributes [ 'preserveDrawingBuffer' ] = true ;
473
473
#endif
474
474
475
+ #if USE_WEBGL2 && OLDEST_SUPPORTED_CHROME_VERSION <= 57
476
+ // BUG: Workaround Chrome WebGL 2 issue: the first shipped versions of WebGL 2 in Chrome did not actually implement the new WebGL 2 functions.
477
+ // Those are supported only in Chrome 58 and newer. For Chrome 57 (and older), disable WebGL 2 support altogether.
478
+ function getChromeVersion ( ) {
479
+ var raw = navigator . userAgent . match ( / C h r o m ( e | i u m ) \/ ( [ 0 - 9 ] + ) \. / ) ;
480
+ return raw ? parseInt ( raw [ 2 ] , 10 ) : false ;
481
+ }
482
+ if ( getChromeVersion ( ) <= 57 ) {
483
+ WebGL2RenderingContext = undefined ;
484
+ }
485
+ #endif
486
+
475
487
#if GL_DEBUG
476
488
var errorInfo = '?';
477
489
function onContextCreationError ( event ) {
@@ -814,16 +826,6 @@ var LibraryGL = {
814
826
GLctx : ctx
815
827
} ;
816
828
817
- #if USE_WEBGL2
818
- // BUG: Workaround Chrome WebGL 2 issue: the first shipped versions of WebGL 2 in Chrome did not actually implement the new WebGL 2 functions.
819
- // Those are supported only in Chrome 58 and newer.
820
- function getChromeVersion ( ) {
821
- var raw = navigator . userAgent . match ( / C h r o m ( e | i u m ) \/ ( [ 0 - 9 ] + ) \. / ) ;
822
- return raw ? parseInt ( raw [ 2 ] , 10 ) : false ;
823
- }
824
- context . supportsWebGL2EntryPoints = ( context . version >= 2 ) && ( getChromeVersion ( ) === false || getChromeVersion ( ) >= 58 ) ;
825
- #endif
826
-
827
829
#if WORKAROUND_OLD_WEBGL_UNIFORM_UPLOAD_IGNORED_OFFSET_BUG
828
830
context . cannotHandleOffsetsInUniformArrayViews = ( function ( g ) {
829
831
function b ( c , t ) {
@@ -1323,7 +1325,7 @@ var LibraryGL = {
1323
1325
glCompressedTexImage2D__sig : 'viiiiiiii' ,
1324
1326
glCompressedTexImage2D : function ( target , level , internalFormat , width , height , border , imageSize , data ) {
1325
1327
#if USE_WEBGL2
1326
- if ( GL . currentContext . supportsWebGL2EntryPoints ) { // WebGL 2 provides new garbage-free entry points to call to WebGL. Use those always when possible.
1328
+ if ( GL . currentContext . version >= 2 ) { // WebGL 2 provides new garbage-free entry points to call to WebGL. Use those always when possible.
1327
1329
if ( GLctx . currentPixelUnpackBufferBinding ) {
1328
1330
GLctx [ 'compressedTexImage2D' ] ( target , level , internalFormat , width , height , border , imageSize , data ) ;
1329
1331
} else {
@@ -1339,7 +1341,7 @@ var LibraryGL = {
1339
1341
glCompressedTexSubImage2D__sig : 'viiiiiiiii ',
1340
1342
glCompressedTexSubImage2D : function ( target , level , xoffset , yoffset , width , height , format , imageSize , data ) {
1341
1343
#if USE_WEBGL2
1342
- if ( GL . currentContext . supportsWebGL2EntryPoints ) { // WebGL 2 provides new garbage-free entry points to call to WebGL. Use those always when possible.
1344
+ if ( GL . currentContext . version >= 2 ) { // WebGL 2 provides new garbage-free entry points to call to WebGL. Use those always when possible.
1343
1345
if ( GLctx . currentPixelUnpackBufferBinding ) {
1344
1346
GLctx [ 'compressedTexSubImage2D' ] ( target , level , xoffset , yoffset , width , height , format , imageSize , data ) ;
1345
1347
} else {
@@ -1497,7 +1499,7 @@ var LibraryGL = {
1497
1499
}
1498
1500
}
1499
1501
#endif
1500
- if ( GL . currentContext . supportsWebGL2EntryPoints ) {
1502
+ if ( GL . currentContext . version >= 2 ) {
1501
1503
// WebGL 2 provides new garbage-free entry points to call to WebGL. Use those always when possible.
1502
1504
if ( GLctx . currentPixelUnpackBufferBinding ) {
1503
1505
GLctx . texImage2D ( target , level , internalFormat , width , height , border , format , type , pixels ) ;
@@ -1528,7 +1530,7 @@ var LibraryGL = {
1528
1530
if ( type == 0x8d61 /*GL_HALF_FLOAT_OES*/ ) type = 0x140B /*GL_HALF_FLOAT*/ ;
1529
1531
}
1530
1532
#endif
1531
- if ( GL . currentContext . supportsWebGL2EntryPoints ) {
1533
+ if ( GL . currentContext . version >= 2 ) {
1532
1534
// WebGL 2 provides new garbage-free entry points to call to WebGL. Use those always when possible.
1533
1535
if ( GLctx . currentPixelUnpackBufferBinding ) {
1534
1536
GLctx . texSubImage2D ( target , level , xoffset , yoffset , width , height , format , type , pixels ) ;
@@ -1553,7 +1555,7 @@ var LibraryGL = {
1553
1555
] ,
1554
1556
glReadPixels : function ( x , y , width , height , format , type , pixels ) {
1555
1557
#if USE_WEBGL2
1556
- if ( GL . currentContext . supportsWebGL2EntryPoints ) { // WebGL 2 provides new garbage-free entry points to call to WebGL. Use those always when possible.
1558
+ if ( GL . currentContext . version >= 2 ) { // WebGL 2 provides new garbage-free entry points to call to WebGL. Use those always when possible.
1557
1559
if ( GLctx . currentPixelPackBufferBinding ) {
1558
1560
GLctx . readPixels ( x , y , width , height , format , type , pixels ) ;
1559
1561
} else {
@@ -1730,7 +1732,7 @@ var LibraryGL = {
1730
1732
}
1731
1733
#endif
1732
1734
#if USE_WEBGL2
1733
- if ( GL . currentContext . supportsWebGL2EntryPoints ) { // WebGL 2 provides new garbage-free entry points to call to WebGL. Use those always when possible.
1735
+ if ( GL . currentContext . version >= 2 ) { // WebGL 2 provides new garbage-free entry points to call to WebGL. Use those always when possible.
1734
1736
if ( data ) {
1735
1737
GLctx . bufferData ( target , HEAPU8 , usage , data , size ) ;
1736
1738
} else {
@@ -1749,7 +1751,7 @@ var LibraryGL = {
1749
1751
glBufferSubData__sig : 'viiii ',
1750
1752
glBufferSubData : function ( target , offset , size , data ) {
1751
1753
#if USE_WEBGL2
1752
- if ( GL . currentContext . supportsWebGL2EntryPoints ) { // WebGL 2 provides new garbage-free entry points to call to WebGL. Use those always when possible.
1754
+ if ( GL . currentContext . version >= 2 ) { // WebGL 2 provides new garbage-free entry points to call to WebGL. Use those always when possible.
1753
1755
GLctx . bufferSubData ( target , offset , HEAPU8 , data , size ) ;
1754
1756
return ;
1755
1757
}
@@ -2166,7 +2168,7 @@ var LibraryGL = {
2166
2168
#endif
2167
2169
2168
2170
#if USE_WEBGL2
2169
- if ( GL . currentContext . supportsWebGL2EntryPoints ) { // WebGL 2 provides new garbage-free entry points to call to WebGL. Use those always when possible.
2171
+ if ( GL . currentContext . version >= 2 ) { // WebGL 2 provides new garbage-free entry points to call to WebGL. Use those always when possible.
2170
2172
GLctx . uniform1iv ( GL . uniforms [ location ] , HEAP32 , value >> 2 , count ) ;
2171
2173
return ;
2172
2174
}
@@ -2183,7 +2185,7 @@ var LibraryGL = {
2183
2185
#endif
2184
2186
2185
2187
#if USE_WEBGL2
2186
- if ( GL . currentContext . supportsWebGL2EntryPoints ) { // WebGL 2 provides new garbage-free entry points to call to WebGL. Use those always when possible.
2188
+ if ( GL . currentContext . version >= 2 ) { // WebGL 2 provides new garbage-free entry points to call to WebGL. Use those always when possible.
2187
2189
GLctx . uniform2iv ( GL . uniforms [ location ] , HEAP32 , value >> 2 , count * 2 ) ;
2188
2190
return ;
2189
2191
}
@@ -2200,7 +2202,7 @@ var LibraryGL = {
2200
2202
#endif
2201
2203
2202
2204
#if USE_WEBGL2
2203
- if ( GL . currentContext . supportsWebGL2EntryPoints ) { // WebGL 2 provides new garbage-free entry points to call to WebGL. Use those always when possible.
2205
+ if ( GL . currentContext . version >= 2 ) { // WebGL 2 provides new garbage-free entry points to call to WebGL. Use those always when possible.
2204
2206
GLctx . uniform3iv ( GL . uniforms [ location ] , HEAP32 , value >> 2 , count * 3 ) ;
2205
2207
return ;
2206
2208
}
@@ -2217,7 +2219,7 @@ var LibraryGL = {
2217
2219
#endif
2218
2220
2219
2221
#if USE_WEBGL2
2220
- if ( GL . currentContext . supportsWebGL2EntryPoints ) { // WebGL 2 provides new garbage-free entry points to call to WebGL. Use those always when possible.
2222
+ if ( GL . currentContext . version >= 2 ) { // WebGL 2 provides new garbage-free entry points to call to WebGL. Use those always when possible.
2221
2223
GLctx . uniform4iv ( GL . uniforms [ location ] , HEAP32 , value >> 2 , count * 4 ) ;
2222
2224
return ;
2223
2225
}
@@ -2234,7 +2236,7 @@ var LibraryGL = {
2234
2236
#endif
2235
2237
2236
2238
#if USE_WEBGL2
2237
- if ( GL . currentContext . supportsWebGL2EntryPoints ) { // WebGL 2 provides new garbage-free entry points to call to WebGL. Use those always when possible.
2239
+ if ( GL . currentContext . version >= 2 ) { // WebGL 2 provides new garbage-free entry points to call to WebGL. Use those always when possible.
2238
2240
GLctx . uniform1fv ( GL . uniforms [ location ] , HEAPF32 , value >> 2 , count ) ;
2239
2241
return ;
2240
2242
}
@@ -2266,7 +2268,7 @@ var LibraryGL = {
2266
2268
#endif
2267
2269
2268
2270
#if USE_WEBGL2
2269
- if ( GL . currentContext . supportsWebGL2EntryPoints ) { // WebGL 2 provides new garbage-free entry points to call to WebGL. Use those always when possible.
2271
+ if ( GL . currentContext . version >= 2 ) { // WebGL 2 provides new garbage-free entry points to call to WebGL. Use those always when possible.
2270
2272
GLctx . uniform2fv ( GL . uniforms [ location ] , HEAPF32 , value >> 2 , count * 2 ) ;
2271
2273
return ;
2272
2274
}
@@ -2299,7 +2301,7 @@ var LibraryGL = {
2299
2301
#endif
2300
2302
2301
2303
#if USE_WEBGL2
2302
- if ( GL . currentContext . supportsWebGL2EntryPoints ) { // WebGL 2 provides new garbage-free entry points to call to WebGL. Use those always when possible.
2304
+ if ( GL . currentContext . version >= 2 ) { // WebGL 2 provides new garbage-free entry points to call to WebGL. Use those always when possible.
2303
2305
GLctx . uniform3fv ( GL . uniforms [ location ] , HEAPF32 , value >> 2 , count * 3 ) ;
2304
2306
return ;
2305
2307
}
@@ -2333,7 +2335,7 @@ var LibraryGL = {
2333
2335
#endif
2334
2336
2335
2337
#if USE_WEBGL2
2336
- if ( GL . currentContext . supportsWebGL2EntryPoints ) { // WebGL 2 provides new garbage-free entry points to call to WebGL. Use those always when possible.
2338
+ if ( GL . currentContext . version >= 2 ) { // WebGL 2 provides new garbage-free entry points to call to WebGL. Use those always when possible.
2337
2339
GLctx . uniform4fv ( GL . uniforms [ location ] , HEAPF32 , value >> 2 , count * 4 ) ;
2338
2340
return ;
2339
2341
}
@@ -2368,7 +2370,7 @@ var LibraryGL = {
2368
2370
#endif
2369
2371
2370
2372
#if USE_WEBGL2
2371
- if ( GL . currentContext . supportsWebGL2EntryPoints ) { // WebGL 2 provides new garbage-free entry points to call to WebGL. Use those always when possible.
2373
+ if ( GL . currentContext . version >= 2 ) { // WebGL 2 provides new garbage-free entry points to call to WebGL. Use those always when possible.
2372
2374
GLctx . uniformMatrix2fv ( GL . uniforms [ location ] , ! ! transpose , HEAPF32 , value >> 2 , count * 4 ) ;
2373
2375
return ;
2374
2376
}
@@ -2403,7 +2405,7 @@ var LibraryGL = {
2403
2405
#endif
2404
2406
2405
2407
#if USE_WEBGL2
2406
- if ( GL . currentContext . supportsWebGL2EntryPoints ) { // WebGL 2 provides new garbage-free entry points to call to WebGL. Use those always when possible.
2408
+ if ( GL . currentContext . version >= 2 ) { // WebGL 2 provides new garbage-free entry points to call to WebGL. Use those always when possible.
2407
2409
GLctx . uniformMatrix3fv ( GL . uniforms [ location ] , ! ! transpose , HEAPF32 , value >> 2 , count * 9 ) ;
2408
2410
return ;
2409
2411
}
@@ -2443,7 +2445,7 @@ var LibraryGL = {
2443
2445
#endif
2444
2446
2445
2447
#if USE_WEBGL2
2446
- if ( GL . currentContext . supportsWebGL2EntryPoints ) { // WebGL 2 provides new garbage-free entry points to call to WebGL. Use those always when possible.
2448
+ if ( GL . currentContext . version >= 2 ) { // WebGL 2 provides new garbage-free entry points to call to WebGL. Use those always when possible.
2447
2449
GLctx . uniformMatrix4fv ( GL . uniforms [ location ] , ! ! transpose , HEAPF32 , value >> 2 , count * 16 ) ;
2448
2450
return ;
2449
2451
}
@@ -3486,7 +3488,7 @@ var LibraryGL = {
3486
3488
GL . mappedBuffers [ buffer ] = null ;
3487
3489
3488
3490
if ( ! ( mapping . access & 0x10 ) ) /* GL_MAP_FLUSH_EXPLICIT_BIT */
3489
- if ( GL . currentContext . supportsWebGL2EntryPoints ) { // WebGL 2 provides new garbage-free entry points to call to WebGL. Use those always when possible.
3491
+ if ( GL . currentContext . version >= 2 ) { // WebGL 2 provides new garbage-free entry points to call to WebGL. Use those always when possible.
3490
3492
GLctx . bufferSubData ( target , mapping . offset , HEAPU8 , mapping . mem , mapping . length ) ;
3491
3493
} else {
3492
3494
GLctx . bufferSubData ( target , mapping . offset , HEAPU8 . subarray ( mapping . mem , mapping . mem + mapping . length ) ) ;
0 commit comments