@@ -309,6 +309,34 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
309
309
return ret ;
310
310
} ,
311
311
312
+ // The code path for creating textures, buffers, framebuffers and other
313
+ // objects the same (and not in fast path), so we merge the functions
314
+ // together.
315
+ // 'createFunction' refers to the WebGL context function name to do the actual
316
+ // creation, 'objectTable' points to the GL object table where to populate the
317
+ // created objects, and 'functionName' carries the name of the caller for
318
+ // debug information.
319
+ genObject : ( n , buffers , createFunction , objectTable
320
+ #if GL_ASSERTIONS
321
+ , functionName
322
+ #endif
323
+ ) => {
324
+ for ( var i = 0 ; i < n ; i ++ ) {
325
+ var buffer = GLctx [ createFunction ] ( ) ;
326
+ var id = buffer && GL . getNewId ( objectTable ) ;
327
+ if ( buffer ) {
328
+ buffer . name = id ;
329
+ objectTable [ id ] = buffer ;
330
+ } else {
331
+ GL . recordError ( 0x502 /* GL_INVALID_OPERATION */ ) ;
332
+ #if GL_ASSERTIONS
333
+ err ( `GL_INVALID_OPERATION in ${ functionName } : GLctx.${ createFunction } returned null - most likely GL context is lost!` ) ;
334
+ #endif
335
+ }
336
+ { { { makeSetValue ( 'buffers' , 'i*4' , 'id' , 'i32' ) } } } ;
337
+ }
338
+ } ,
339
+
312
340
#if FULL_ES2 || LEGACY_GL_EMULATION
313
341
// When user GL code wants to render from client-side memory, we need to
314
342
// upload the vertex data to a temp VBO for rendering. Maintain a set of
@@ -1770,46 +1798,16 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
1770
1798
return GLctx . isTexture ( texture ) ;
1771
1799
} ,
1772
1800
1773
- // The code path for creating textures, buffers, framebuffers and other
1774
- // objects is so identical to each other (and not in fast path), that merge
1775
- // the functions together to only have one generated copy of this.
1776
- // 'createFunction' refers to the WebGL context function name to do the actual
1777
- // creation, 'objectTable' points to the GL object table where to populate the
1778
- // created objects, and 'functionName' carries the name of the caller for
1779
- // debug information.
1780
- $__glGenObject : ( n , buffers , createFunction , objectTable
1781
- #if GL_ASSERTIONS
1782
- , functionName
1783
- #endif
1784
- ) = > {
1785
- for ( var i = 0 ; i < n ; i ++ ) {
1786
- var buffer = GLctx [ createFunction ] ( ) ;
1787
- var id = buffer && GL . getNewId ( objectTable ) ;
1788
- if ( buffer ) {
1789
- buffer . name = id ;
1790
- objectTable [ id ] = buffer ;
1791
- } else {
1792
- GL . recordError ( 0x502 /* GL_INVALID_OPERATION */ ) ;
1793
- #if GL_ASSERTIONS
1794
- err ( `GL_INVALID_OPERATION in ${ functionName } : GLctx.${ createFunction } returned null - most likely GL context is lost!` ) ;
1795
- #endif
1796
- }
1797
- { { { makeSetValue ( 'buffers' , 'i*4' , 'id' , 'i32' ) } } } ;
1798
- }
1799
- } ,
1800
-
1801
- glGenBuffers__deps : [ '$__glGenObject' ] ,
1802
1801
glGenBuffers : ( n , buffers ) => {
1803
- __glGenObject ( n , buffers , 'createBuffer' , GL . buffers
1802
+ GL . genObject ( n , buffers , 'createBuffer' , GL . buffers
1804
1803
#if GL_ASSERTIONS
1805
1804
, 'glGenBuffers'
1806
1805
#endif
1807
1806
) ;
1808
1807
} ,
1809
1808
1810
- glGenTextures__deps : [ '$__glGenObject' ] ,
1811
1809
glGenTextures : ( n , textures ) = > {
1812
- __glGenObject ( n , textures , 'createTexture' , GL . textures
1810
+ GL . genObject ( n , textures , 'createTexture' , GL . textures
1813
1811
#if GL_ASSERTIONS
1814
1812
, 'glGenTextures'
1815
1813
#endif
@@ -2055,9 +2053,8 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
2055
2053
return GLctx . isBuffer ( b ) ;
2056
2054
} ,
2057
2055
2058
- glGenRenderbuffers__deps : [ '$__glGenObject' ] ,
2059
2056
glGenRenderbuffers : ( n , renderbuffers ) => {
2060
- __glGenObject ( n , renderbuffers , 'createRenderbuffer' , GL . renderbuffers
2057
+ GL . genObject ( n , renderbuffers , 'createRenderbuffer' , GL . renderbuffers
2061
2058
#if GL_ASSERTIONS
2062
2059
, 'glGenRenderbuffers'
2063
2060
#endif
@@ -3627,9 +3624,8 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
3627
3624
3628
3625
} ,
3629
3626
3630
- glGenFramebuffers__deps : [ '$__glGenObject' ] ,
3631
3627
glGenFramebuffers : ( n , ids ) => {
3632
- __glGenObject ( n , ids , 'createFramebuffer' , GL . framebuffers
3628
+ GL . genObject ( n , ids , 'createFramebuffer' , GL . framebuffers
3633
3629
#if GL_ASSERTIONS
3634
3630
, 'glGenFramebuffers'
3635
3631
#endif
@@ -3678,19 +3674,17 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
3678
3674
return GLctx . isFramebuffer ( fb ) ;
3679
3675
} ,
3680
3676
3681
- glGenVertexArrays__deps : [ '$__glGenObject'
3682
3677
#if LEGACY_GL_EMULATION
3683
- , '$emulGlGenVertexArrays'
3678
+ glGenVertexArrays__deps : [ '$emulGlGenVertexArrays' ] ,
3684
3679
#endif
3685
- ] ,
3686
3680
glGenVertexArrays : ( n , arrays ) => {
3687
3681
#if LEGACY_GL_EMULATION
3688
3682
emulGlGenVertexArrays ( n , arrays ) ;
3689
3683
#else
3690
3684
#if GL_ASSERTIONS
3691
3685
assert ( GLctx . createVertexArray , 'Must have WebGL2 or OES_vertex_array_object to use vao' ) ;
3692
3686
#endif
3693
- __glGenObject ( n , arrays , 'createVertexArray' , GL . vaos
3687
+ GL . genObject ( n , arrays , 'createVertexArray' , GL . vaos
3694
3688
#if GL_ASSERTIONS
3695
3689
, 'glGenVertexArrays'
3696
3690
#endif
0 commit comments