Skip to content

Commit d0a65ed

Browse files
committed
Micro-optimize WebGL object creation
1 parent c63664a commit d0a65ed

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/library_gl.js

+5-6
Original file line numberDiff line numberDiff line change
@@ -1763,17 +1763,16 @@ var LibraryGL = {
17631763
) {
17641764
for (var i = 0; i < n; i++) {
17651765
var buffer = GLctx[createFunction]();
1766-
if (!buffer) {
1766+
var id = buffer && GL.getNewId(objectTable);
1767+
if (buffer) {
1768+
buffer.name = id;
1769+
objectTable[id] = buffer;
1770+
} else {
17671771
GL.recordError(0x0502 /* GL_INVALID_OPERATION */);
17681772
#if GL_ASSERTIONS
17691773
err('GL_INVALID_OPERATION in ' + functionName + ': GLctx.' + createFunction + ' returned null - most likely GL context is lost!');
17701774
#endif
1771-
while(i < n) {{{ makeSetValue('buffers', 'i++*4', 0, 'i32') }}};
1772-
return;
17731775
}
1774-
var id = GL.getNewId(objectTable);
1775-
buffer.name = id;
1776-
objectTable[id] = buffer;
17771776
{{{ makeSetValue('buffers', 'i*4', 'id', 'i32') }}};
17781777
}
17791778
},

0 commit comments

Comments
 (0)