diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-02-27 20:58:00 -0500 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-02-27 20:58:00 -0500 |
commit | 2b012610c54da149b480bce7ea3b75480a7b60e9 (patch) | |
tree | bfcc7ef35867afde84e90a580ff6b23e96911a71 /src | |
parent | a0a5e19ded9d2610c60c27a8cb65009365fc33c5 (diff) |
cleanups
Diffstat (limited to 'src')
-rw-r--r-- | src/library_gl.js | 41 | ||||
-rw-r--r-- | src/settings.js | 6 |
2 files changed, 24 insertions, 23 deletions
diff --git a/src/library_gl.js b/src/library_gl.js index 0d6b799b..80dc2006 100644 --- a/src/library_gl.js +++ b/src/library_gl.js @@ -19,10 +19,12 @@ var LibraryGL = { uniforms: [], shaders: [], +#if FULL_ES2 clientBuffers: [], enabledClientBuffers: [], currArrayBuffer: 0, currElementArrayBuffer: 0, +#endif uniformTable: {}, // name => uniform ID. the uID must be identical until relinking, cannot create a new uID each call to glGetUniformLocation @@ -182,34 +184,35 @@ var LibraryGL = { }, #if FULL_ES2 - calcBufLength: function (size, type, stride, cnt) { - if (stride > 0) - return cnt * stride; // XXXvlad this is not exactly correct I don't think + calcBufLength: function(size, type, stride, count) { + if (stride > 0) { + return count * stride; // XXXvlad this is not exactly correct I don't think + } - var typesz; + var typeSize; switch (type) { case Module.ctx.UNSIGNED_BYTE: case Module.ctx.BYTE: - typesz = 1; + typeSize = 1; break; case Module.ctx.UNSIGNED_SHORT: case Module.ctx.SHORT: - typesz = 2; + typeSize = 2; break; case Module.ctx.UNSIGNED_INT: case Module.ctx.INT: case Module.ctx.FLOAT: - typesz = 4; + typeSize = 4; break; case Module.ctx.DOUBLE: - typesz = 8; + typeSize = 8; break; } - return size * typesz * cnt; + return size * typeSize * count; }, - preDrawHandleClientVertexAttribBindings: function(cnt) { + preDrawHandleClientVertexAttribBindings: function(count) { GL.resetBufferBinding = false; for (var i = 0; i < GL.maxVertexAttribs; ++i) { if (!GL.enabledClientBuffers[i] || !GL.clientBuffers[i]) @@ -222,7 +225,7 @@ var LibraryGL = { var buf = Module.ctx.createBuffer(); Module.ctx.bindBuffer(Module.ctx.ARRAY_BUFFER, buf); Module.ctx.bufferData(Module.ctx.ARRAY_BUFFER, - HEAPU8.subarray(cb.ptr, cb.ptr + GL.calcBufLength(cb.size, cb.type, cb.stride, cnt)), + HEAPU8.subarray(cb.ptr, cb.ptr + GL.calcBufLength(cb.size, cb.type, cb.stride, count)), Module.ctx.DYNAMIC_DRAW); Module.ctx.vertexAttribPointer(i, cb.size, cb.type, cb.normalized, cb.stride, 0); } @@ -2898,40 +2901,40 @@ var LibraryGL = { Module.ctx.disableVertexAttribArray(index); }, - glDrawArrays: function(mode, first, cnt) { + glDrawArrays: function(mode, first, count) { #if FULL_ES2 // bind any client-side buffers - GL.preDrawHandleClientVertexAttribBindings(cnt); + GL.preDrawHandleClientVertexAttribBindings(count); #endif - Module.ctx.drawArrays(mode, first, cnt); + Module.ctx.drawArrays(mode, first, count); #if FULL_ES2 GL.postDrawHandleClientVertexAttribBindings(); #endif }, - glDrawElements: function(mode, cnt, type, indices) { + glDrawElements: function(mode, count, type, indices) { #if FULL_ES2 var buf; if (!GL.currElementArrayBuffer) { buf = Module.ctx.createBuffer(); Module.ctx.bindBuffer(Module.ctx.ELEMENT_ARRAY_BUFFER, buf); Module.ctx.bufferData(Module.ctx.ELEMENT_ARRAY_BUFFER, - HEAPU8.subarray(indices, indices + GL.calcBufLength(1, type, 0, cnt)), + HEAPU8.subarray(indices, indices + GL.calcBufLength(1, type, 0, count)), Module.ctx.DYNAMIC_DRAW); // the index is now 0 indices = 0; } // bind any client-side buffers - GL.preDrawHandleClientVertexAttribBindings(cnt); + GL.preDrawHandleClientVertexAttribBindings(count); #endif - Module.ctx.drawElements(mode, cnt, type, indices); + Module.ctx.drawElements(mode, count, type, indices); #if FULL_ES2 - GL.postDrawHandleClientVertexAttribBindings(cnt); + GL.postDrawHandleClientVertexAttribBindings(count); if (!GL.currElementArrayBuffer) { Module.ctx.bindBuffer(Module.ctx.ELEMENT_ARRAY_BUFFER, null); diff --git a/src/settings.js b/src/settings.js index dbce836d..82cbebe4 100644 --- a/src/settings.js +++ b/src/settings.js @@ -166,10 +166,8 @@ var GL_DEBUG = 0; // Print out all calls into WebGL. As with LIBRARY_DEBUG, you var GL_TESTING = 0; // When enabled, sets preserveDrawingBuffer in the context, to allow tests to work (but adds overhead) var GL_MAX_TEMP_BUFFER_SIZE = 2097152; // How large GL emulation temp buffers are var GL_UNSAFE_OPTS = 1; // Enables some potentially-unsafe optimizations in GL emulation code -var FORCE_GL_EMULATION = 0; // Forces inclusion of GL emulation code. This lets you use non-WebGL features - // like clientside data. GL commands that are not in WebGL will automatically - // include this feature, but if you just use pure GLES commands *and* need - // emualation, you will need to enable it manually with this flag. +var FULL_ES2 = 0; // Forces support for all GLES2 features, not just the WebGL-friendly subset. +var FORCE_GL_EMULATION = 0; // Forces inclusion of full GL emulation code. var DISABLE_EXCEPTION_CATCHING = 0; // Disables generating code to actually catch exceptions. If the code you // are compiling does not actually rely on catching exceptions (but the |