@@ -766,7 +766,7 @@ var LibraryGL = {
766766
767767 registerContext : function ( ctx , webGLContextAttributes ) {
768768 var handle = _malloc ( 8 ) ; // Make space on the heap to store GL context attributes that need to be accessible as shared between threads.
769- #if ASSERTIONS
769+ #if GL_ASSERTIONS
770770 assert ( handle , 'malloc() failed in GL.registerContext!' ) ;
771771#endif
772772#if GL_SUPPORT_EXPLICIT_SWAP_CONTROL
@@ -1431,7 +1431,10 @@ var LibraryGL = {
14311431
14321432 _computeUnpackAlignedImageSize : function ( width , height , sizePerPixel , alignment ) {
14331433 function roundedToNextMultipleOf ( x , y ) {
1434- return Math . ceil ( x / y ) * y ;
1434+ #if GL_ASSERTIONS
1435+ assert ( ( y & ( y - 1 ) ) === 0 , 'Unpack alignment must be a power of 2! (Allowed values per WebGL spec are 1, 2, 4 or 8)' ) ;
1436+ #endif
1437+ return ( x + y - 1 ) & - y ;
14351438 }
14361439 var plainRowSize = width * sizePerPixel ;
14371440 var alignedRowSize = roundedToNextMultipleOf ( plainRowSize , alignment ) ;
@@ -1635,10 +1638,7 @@ var LibraryGL = {
16351638 return ;
16361639 }
16371640#endif
1638-
1639- var pixelData = null ;
1640- if ( pixels ) pixelData = emscriptenWebGLGetTexPixelData ( type , format , width , height , pixels , internalFormat ) ;
1641- GLctx . texImage2D ( target , level , internalFormat , width , height , border , format , type , pixelData ) ;
1641+ GLctx . texImage2D ( target , level , internalFormat , width , height , border , format , type , pixels ? emscriptenWebGLGetTexPixelData ( type , format , width , height , pixels , internalFormat ) : null ) ;
16421642 } ,
16431643
16441644 glTexSubImage2D__sig : 'viiiiiiiii' ,
@@ -3779,7 +3779,7 @@ var LibraryGL = {
37793779 { { { makeSetValue ( 'count' , '0' , 'len' , 'i32' ) } } } ;
37803780 for ( var i = 0 ; i < len ; ++ i ) {
37813781 var id = GL . shaders . indexOf ( result [ i ] ) ;
3782- #if ASSERTIONS
3782+ #if GL_ASSERTIONS
37833783 assert ( id !== - 1 , 'shader not bound to local id' ) ;
37843784#endif
37853785 { { { makeSetValue ( 'shaders' , 'i*4' , 'id' , 'i32' ) } } } ;
@@ -4368,7 +4368,7 @@ var LibraryGL = {
43684368 glVertexAttribPointer : function ( index , size , type , normalized , stride , ptr ) {
43694369#if FULL_ES2
43704370 var cb = GL . currentContext . clientBuffers [ index ] ;
4371- #if ASSERTIONS
4371+ #if GL_ASSERTIONS
43724372 assert ( cb , index ) ;
43734373#endif
43744374 if ( ! GL . currArrayBuffer ) {
@@ -4396,7 +4396,7 @@ var LibraryGL = {
43964396 glVertexAttribIPointer : function ( index , size , type , stride , ptr ) {
43974397#if FULL_ES3
43984398 var cb = GL . currentContext . clientBuffers [ index ] ;
4399- #if ASSERTIONS
4399+ #if GL_ASSERTIONS
44004400 assert ( cb , index ) ;
44014401#endif
44024402 if ( ! GL . currArrayBuffer ) {
@@ -4425,7 +4425,7 @@ var LibraryGL = {
44254425 glEnableVertexAttribArray : function ( index ) {
44264426#if FULL_ES2
44274427 var cb = GL . currentContext . clientBuffers [ index ] ;
4428- #if ASSERTIONS
4428+ #if GL_ASSERTIONS
44294429 assert ( cb , index ) ;
44304430#endif
44314431 cb . enabled = true ;
@@ -4437,7 +4437,7 @@ var LibraryGL = {
44374437 glDisableVertexAttribArray : function ( index ) {
44384438#if FULL_ES2
44394439 var cb = GL . currentContext . clientBuffers [ index ] ;
4440- #if ASSERTIONS
4440+ #if GL_ASSERTIONS
44414441 assert ( cb , index ) ;
44424442#endif
44434443 cb . enabled = false ;
0 commit comments