Skip to content

Commit a8d9039

Browse files
committed
Consistently use normal object access notation for GLctx
We were already using the normal notation in most cases anyway: ``` $ git grep "GLctx\[" | wc -l 74 $ git grep "GLctx\." | wc -l 505 ``` IIUC we have tests that verify this doesn't break with --closure=1.
1 parent 1db2a1e commit a8d9039

File tree

2 files changed

+72
-72
lines changed

2 files changed

+72
-72
lines changed

src/library_webgl.js

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -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
@@ -4190,8 +4190,8 @@ function createGLPassthroughFunctions(lib, funcs) {
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) => {
41974197
if (name.length == 0) return;

0 commit comments

Comments
 (0)