@@ -1435,14 +1435,14 @@ var LibraryGL = {
14351435#if MAX_WEBGL_VERSION >= 2
14361436 if ( { { { isCurrentContextWebGL2( ) } } } ) { // WebGL 2 provides new garbage-free entry points to call to WebGL. Use those always when possible.
14371437 if ( GLctx . currentPixelUnpackBufferBinding || ! imageSize ) {
1438- GLctx [ ' compressedTexImage2D' ] ( target , level , internalFormat , width , height , border , imageSize , data ) ;
1438+ GLctx . compressedTexImage2D ( target , level , internalFormat , width , height , border , imageSize , data ) ;
14391439 } else {
1440- GLctx [ ' compressedTexImage2D' ] ( target , level , internalFormat , width , height , border , HEAPU8 , data , imageSize ) ;
1440+ GLctx . compressedTexImage2D ( target , level , internalFormat , width , height , border , HEAPU8 , data , imageSize ) ;
14411441 }
14421442 return ;
14431443 }
14441444#endif
1445- GLctx [ ' compressedTexImage2D' ] ( target , level , internalFormat , width , height , border , data ? { { { makeHEAPView ( 'U8' , 'data' , 'data+imageSize' ) } } } : null ) ;
1445+ GLctx . compressedTexImage2D ( target , level , internalFormat , width , height , border , data ? { { { makeHEAPView ( 'U8' , 'data' , 'data+imageSize' ) } } } : null ) ;
14461446 } ,
14471447
14481448
@@ -1451,14 +1451,14 @@ var LibraryGL = {
14511451#if MAX_WEBGL_VERSION >= 2
14521452 if ( { { { isCurrentContextWebGL2( ) } } } ) { // WebGL 2 provides new garbage-free entry points to call to WebGL. Use those always when possible.
14531453 if ( GLctx . currentPixelUnpackBufferBinding || ! imageSize ) {
1454- GLctx [ ' compressedTexSubImage2D' ] ( target , level , xoffset , yoffset , width , height , format , imageSize , data ) ;
1454+ GLctx . compressedTexSubImage2D ( target , level , xoffset , yoffset , width , height , format , imageSize , data ) ;
14551455 } else {
1456- GLctx [ ' compressedTexSubImage2D' ] ( target , level , xoffset , yoffset , width , height , format , HEAPU8 , data , imageSize ) ;
1456+ GLctx. compressedTexSubImage2D ( target , level , xoffset , yoffset , width , height , format , HEAPU8 , data , imageSize ) ;
14571457 }
14581458 return ;
14591459 }
14601460#endif
1461- GLctx [ ' compressedTexSubImage2D' ] ( target , level , xoffset , yoffset , width , height , format , data ? { { { makeHEAPView ( 'U8' , 'data' , 'data+imageSize' ) } } } : null ) ;
1461+ GLctx . compressedTexSubImage2D ( target , level , xoffset , yoffset , width , height , format , data ? { { { makeHEAPView ( 'U8' , 'data' , 'data+imageSize' ) } } } : null ) ;
14621462 } ,
14631463
14641464 $computeUnpackAlignedImageSize : function ( width , height , sizePerPixel , alignment ) {
@@ -1942,7 +1942,7 @@ var LibraryGL = {
19421942 }
19431943#if MAX_WEBGL_VERSION >= 2
19441944 else {
1945- param = GLctx [ ' getQueryParameter' ] ( query , pname ) ;
1945+ param = GLctx . getQueryParameter ( query , pname ) ;
19461946 }
19471947#endif
19481948 var ret ;
@@ -3643,7 +3643,7 @@ var LibraryGL = {
36433643 _emulGlGenVertexArrays ( n , arrays ) ;
36443644#else
36453645#if GL_ASSERTIONS
3646- assert ( GLctx [ ' createVertexArray' ] , 'Must have WebGL2 or OES_vertex_array_object to use vao' ) ;
3646+ assert ( GLctx . createVertexArray , 'Must have WebGL2 or OES_vertex_array_object to use vao' ) ;
36473647#endif
36483648 __glGenObject ( n , arrays , 'createVertexArray' , GL . vaos
36493649#if GL_ASSERTIONS
@@ -3662,11 +3662,11 @@ var LibraryGL = {
36623662 _emulGlDeleteVertexArrays ( n , vaos ) ;
36633663#else
36643664#if GL_ASSERTIONS
3665- assert ( GLctx [ ' deleteVertexArray' ] , 'Must have WebGL2 or OES_vertex_array_object to use vao' ) ;
3665+ assert ( GLctx . deleteVertexArray , 'Must have WebGL2 or OES_vertex_array_object to use vao' ) ;
36663666#endif
36673667 for ( var i = 0 ; i < n ; i ++ ) {
36683668 var id = { { { makeGetValue ( 'vaos' , 'i*4' , 'i32' ) } } } ;
3669- GLctx [ ' deleteVertexArray' ] ( GL . vaos [ id ] ) ;
3669+ GLctx . deleteVertexArray ( GL . vaos [ id ] ) ;
36703670 GL . vaos [ id ] = null ;
36713671 }
36723672#endif
@@ -3681,9 +3681,9 @@ var LibraryGL = {
36813681 _emulGlBindVertexArray ( vao ) ;
36823682#else
36833683#if GL_ASSERTIONS
3684- assert ( GLctx [ ' bindVertexArray' ] , 'Must have WebGL2 or OES_vertex_array_object to use vao' ) ;
3684+ assert ( GLctx . bindVertexArray , 'Must have WebGL2 or OES_vertex_array_object to use vao' ) ;
36853685#endif
3686- GLctx [ ' bindVertexArray' ] ( GL . vaos [ vao ] ) ;
3686+ GLctx . bindVertexArray ( GL . vaos [ vao ] ) ;
36873687#endif
36883688#if FULL_ES2 || LEGACY_GL_EMULATION
36893689 var ibo = GLctx . getParameter ( 0x8895 /*ELEMENT_ARRAY_BUFFER_BINDING*/ ) ;
@@ -3700,12 +3700,12 @@ var LibraryGL = {
37003700 return _emulGlIsVertexArray ( array ) ;
37013701#else
37023702#if GL_ASSERTIONS
3703- assert ( GLctx [ ' isVertexArray' ] , 'Must have WebGL2 or OES_vertex_array_object to use vao' ) ;
3703+ assert ( GLctx . isVertexArray , 'Must have WebGL2 or OES_vertex_array_object to use vao' ) ;
37043704#endif
37053705
37063706 var vao = GL . vaos [ array ] ;
37073707 if ( ! vao ) return 0 ;
3708- return GLctx [ ' isVertexArray' ] ( vao ) ;
3708+ return GLctx . isVertexArray ( vao ) ;
37093709#endif
37103710 } ,
37113711
@@ -3853,25 +3853,25 @@ var LibraryGL = {
38533853 glVertexAttribDivisor__sig : 'vii' ,
38543854 glVertexAttribDivisor : function ( index , divisor ) {
38553855#if GL_ASSERTIONS
3856- assert ( GLctx [ ' vertexAttribDivisor' ] , 'Must have ANGLE_instanced_arrays extension or WebGL 2 to use WebGL instancing' ) ;
3856+ assert ( GLctx . vertexAttribDivisor , 'Must have ANGLE_instanced_arrays extension or WebGL 2 to use WebGL instancing' ) ;
38573857#endif
3858- GLctx [ ' vertexAttribDivisor' ] ( index , divisor ) ;
3858+ GLctx . vertexAttribDivisor ( index , divisor ) ;
38593859 } ,
38603860
38613861 glDrawArraysInstanced__sig : 'viiii' ,
38623862 glDrawArraysInstanced : function ( mode , first , count , primcount ) {
38633863#if GL_ASSERTIONS
3864- assert ( GLctx [ ' drawArraysInstanced' ] , 'Must have ANGLE_instanced_arrays extension or WebGL 2 to use WebGL instancing' ) ;
3864+ assert ( GLctx . drawArraysInstanced , 'Must have ANGLE_instanced_arrays extension or WebGL 2 to use WebGL instancing' ) ;
38653865#endif
3866- GLctx [ ' drawArraysInstanced' ] ( mode , first , count , primcount ) ;
3866+ GLctx . drawArraysInstanced ( mode , first , count , primcount ) ;
38673867 } ,
38683868
38693869 glDrawElementsInstanced__sig : 'viiipi' ,
38703870 glDrawElementsInstanced : function ( mode , count , type , indices , primcount ) {
38713871#if GL_ASSERTIONS
3872- assert ( GLctx [ ' drawElementsInstanced' ] , 'Must have ANGLE_instanced_arrays extension or WebGL 2 to use WebGL instancing' ) ;
3872+ assert ( GLctx . drawElementsInstanced , 'Must have ANGLE_instanced_arrays extension or WebGL 2 to use WebGL instancing' ) ;
38733873#endif
3874- GLctx [ ' drawElementsInstanced' ] ( mode , count , type , indices , primcount ) ;
3874+ GLctx . drawElementsInstanced ( mode , count , type , indices , primcount ) ;
38753875 } ,
38763876
38773877 // OpenGL Desktop/ES 2.0 instancing extensions compatibility
@@ -3894,7 +3894,7 @@ var LibraryGL = {
38943894 glDrawBuffers__sig : 'vip' ,
38953895 glDrawBuffers : function ( n , bufs ) {
38963896#if GL_ASSERTIONS
3897- assert ( GLctx [ ' drawBuffers' ] , 'Must have WebGL2 or WEBGL_draw_buffers extension to use drawBuffers' ) ;
3897+ assert ( GLctx . drawBuffers , 'Must have WebGL2 or WEBGL_draw_buffers extension to use drawBuffers' ) ;
38983898#endif
38993899#if GL_ASSERTIONS
39003900 assert ( n < tempFixedLengthArray . length , 'Invalid count of numBuffers=' + n + ' passed to glDrawBuffers (that many draw buffer points do not exist in GL)' ) ;
@@ -3905,7 +3905,7 @@ var LibraryGL = {
39053905 bufArray [ i ] = { { { makeGetValue ( 'bufs' , 'i*4' , 'i32' ) } } } ;
39063906 }
39073907
3908- GLctx [ ' drawBuffers' ] ( bufArray ) ;
3908+ GLctx . drawBuffers ( bufArray ) ;
39093909 } ,
39103910
39113911 // OpenGL ES 2.0 draw buffer extensions compatibility
@@ -4172,33 +4172,32 @@ var LibraryGL = {
41724172 glFrontFace__sig : 'vi' ,
41734173} ;
41744174
4175- // Simple pass-through functions. Starred ones have return values. [X] ones have X in the C name but not in the JS name
4176- var glFuncs = [ [ 0 , 'finish flush' ] ,
4177- [ 1 , 'clearDepth clearDepth[f] depthFunc enable disable frontFace cullFace clear lineWidth clearStencil stencilMask checkFramebufferStatus* generateMipmap activeTexture blendEquation isEnabled*' ] ,
4178- [ 2 , 'blendFunc blendEquationSeparate depthRange depthRange[f] stencilMaskSeparate hint polygonOffset vertexAttrib1f' ] ,
4179- [ 3 , 'texParameteri texParameterf vertexAttrib2f stencilFunc stencilOp ' ] ,
4180- [ 4 , 'viewport clearColor scissor vertexAttrib3f renderbufferStorage blendFuncSeparate blendColor stencilFuncSeparate stencilOpSeparate ' ] ,
4181- [ 5 , 'vertexAttrib4f ' ] ,
4182- [ 6 , '' ] ,
4183- [ 7 , '' ] ,
4184- [ 8 , 'copyTexImage2D copyTexSubImage2D ' ] ,
4185- [ 9 , '' ] ,
4186- [ 10 , '' ] ] ;
4175+ // Simple pass-through functions.
4176+ // - Starred ones have return values.
4177+ // - [X] ones have X in the C name but not in the JS name
4178+ var glPassthroughFuncs = [
4179+ [ 0 , 'finish flush ' ] ,
4180+ [ 1 , 'clearDepth clearDepth[f] depthFunc enable disable frontFace cullFace clear lineWidth clearStencil stencilMask checkFramebufferStatus* generateMipmap activeTexture blendEquation isEnabled* ' ] ,
4181+ [ 2 , 'blendFunc blendEquationSeparate depthRange depthRange[f] stencilMaskSeparate hint polygonOffset vertexAttrib1f ' ] ,
4182+ [ 3 , 'texParameteri texParameterf vertexAttrib2f stencilFunc stencilOp ' ] ,
4183+ [ 4 , 'viewport clearColor scissor vertexAttrib3f renderbufferStorage blendFuncSeparate blendColor stencilFuncSeparate stencilOpSeparate ' ] ,
4184+ [ 5 , 'vertexAttrib4f ' ] ,
4185+ [ 8 , 'copyTexImage2D copyTexSubImage2D ' ] ,
4186+ ] ;
41874187
41884188function createGLPassthroughFunctions ( lib , funcs ) {
41894189 funcs . forEach ( ( data ) => {
41904190 const num = data [ 0 ] ;
41914191 const names = data [ 1 ] ;
41924192 const args = range ( num ) . map ( ( i ) => 'x' + i ) . join ( ', ' ) ;
4193- const plainStub = '(function(' + args + ') { GLctx[\' NAME\'] (' + args + ') })' ;
4194- const returnStub = '(function(' + args + ') { return GLctx[\' NAME\'] (' + args + ') })' ;
4193+ const plainStub = '(function(' + args + ') { GLctx. NAME(' + args + ') })' ;
4194+ const returnStub = '(function(' + args + ') { return GLctx. NAME(' + args + ') })' ;
41954195 const sigEnd = range ( num ) . map ( ( ) => 'i' ) . join ( '' ) ;
41964196 names . split ( ' ' ) . forEach ( ( name ) => {
4197- if ( name . length == 0 ) return ;
41984197 let stub = plainStub ;
41994198 let sig ;
4200- if ( name [ name . length - 1 ] == '*' ) {
4201- name = name . substr ( 0 , name . length - 1 ) ;
4199+ if ( name . endsWith ( '*' ) ) {
4200+ name = name . slice ( 0 , - 1 )
42024201 stub = returnStub ;
42034202 sig = 'i' + sigEnd ;
42044203 } else {
@@ -4207,7 +4206,7 @@ function createGLPassthroughFunctions(lib, funcs) {
42074206 let cName = name ;
42084207 if ( name . includes ( '[' ) ) {
42094208 cName = name . replace ( '[' , '' ) . replace ( ']' , '' ) ;
4210- name = cName . substr ( 0 , cName . length - 1 ) ;
4209+ name = cName . slice ( 0 , - 1 )
42114210 }
42124211 cName = 'gl' + cName [ 0 ] . toUpperCase ( ) + cName . substr ( 1 ) ;
42134212 assert ( ! ( cName in lib ) , "Cannot reimplement the existing function " + cName ) ;
@@ -4217,7 +4216,7 @@ function createGLPassthroughFunctions(lib, funcs) {
42174216 } ) ;
42184217}
42194218
4220- createGLPassthroughFunctions ( LibraryGL , glFuncs ) ;
4219+ createGLPassthroughFunctions ( LibraryGL , glPassthroughFuncs ) ;
42214220
42224221autoAddDeps ( LibraryGL , '$GL' ) ;
42234222
0 commit comments