diff options
author | Jukka Jylänki <jujjyl@gmail.com> | 2013-11-07 17:23:25 +0200 |
---|---|---|
committer | Jukka Jylänki <jujjyl@gmail.com> | 2013-11-07 17:23:25 +0200 |
commit | df185bf8d4b44903ec454158c07ad7ca3231cf26 (patch) | |
tree | 3148f322eb8649516da34914186b24ea2560d3a1 | |
parent | 7f870cf9c357f6a1138ba612ace7d7249f85e250 (diff) |
Implement GLES2 glShaderBinary and glReleaseShaderCompiler functions as no-op stubs. Add a machinery for glGetError() to report errors generated by the library_gl.js interop layer.
-rw-r--r-- | src/library_gl.js | 43 |
1 files changed, 33 insertions, 10 deletions
diff --git a/src/library_gl.js b/src/library_gl.js index 7074f844..15eb0d52 100644 --- a/src/library_gl.js +++ b/src/library_gl.js @@ -11,6 +11,7 @@ var LibraryGL = { #endif counter: 1, // 0 is reserved as 'null' in gl + lastError: 0, buffers: [], programs: [], framebuffers: [], @@ -51,6 +52,13 @@ var LibraryGL = { Browser.moduleContextCreatedCallbacks.push(GL.initExtensions); }, + // Records a GL error condition that occurred, stored until user calls glGetError() to fetch it. As per GLES2 spec, only the first error + // is remembered, and subsequent errors are discarded until the user has cleared the stored error by a call to glGetError(). + recordError: function recordError(errorCode) { + if (!GL.lastError) { + GL.lastError = errorCode; + } + }, // Get a new ID for a texture/buffer/etc., while keeping the table dense and fast. Creation is farely rare so it is worth optimizing lookups later. getNewId: function(table) { var ret = GL.counter++; @@ -2123,9 +2131,6 @@ var LibraryGL = { glGetShaderPrecisionFormat__sig: 'v', glGetShaderPrecisionFormat: function() { throw 'glGetShaderPrecisionFormat: TODO' }, - glShaderBinary__sig: 'v', - glShaderBinary: function() { throw 'glShaderBinary: TODO' }, - glDeleteObject__sig: 'vi', glDeleteObject: function(id) { if (GL.programs[id]) { @@ -2137,11 +2142,6 @@ var LibraryGL = { } }, - glReleaseShaderCompiler__sig: 'v', - glReleaseShaderCompiler: function() { - // NOP (as allowed by GLES 2.0 spec) - }, - glGetObjectParameteriv__sig: 'viii', glGetObjectParameteriv: function(id, type, result) { if (GL.programs[id]) { @@ -4618,6 +4618,30 @@ var LibraryGL = { #endif }, + glShaderBinary__sig: 'v', + glShaderBinary: function() { + GL.recordError(0x0500/*GL_INVALID_ENUM*/); +#if GL_ASSERTIONS + Module.printErr("GL_INVALID_ENUM in glShaderBinary: WebGL does not support binary shader formats! Calls to glShaderBinary always fail."); +#endif + }, + + glReleaseShaderCompiler__sig: 'v', + glReleaseShaderCompiler: function() { + // NOP (as allowed by GLES 2.0 spec) + }, + + glGetError__sig: 'i', + glGetError: function() { + // First return any GL error generated by the emscripten library_gl.js interop layer. + if (GL.lastError) { + var error = GL.lastError; + GL.lastError = 0/*GL_NO_ERROR*/; + return error; + } else { // If there were none, return the GL error from the browser GL context. + return Module.ctx.getError(); + } + }, // signatures of simple pass-through functions, see later glActiveTexture__sig: 'vi', @@ -4651,14 +4675,13 @@ var LibraryGL = { glFlush__sig: 'v', glClearColor__sig: 'viiii', glIsEnabled__sig: 'ii', - glGetError__sig: 'i', glFrontFace__sig: 'vi', glSampleCoverage__sig: 'vi', }; // Simple pass-through functions. Starred ones have return values. [X] ones have X in the C name but not in the JS name -[[0, 'getError* finish flush'], +[[0, 'finish flush'], [1, 'clearDepth clearDepth[f] depthFunc enable disable frontFace cullFace clear lineWidth clearStencil depthMask stencilMask checkFramebufferStatus* generateMipmap activeTexture blendEquation sampleCoverage isEnabled*'], [2, 'blendFunc blendEquationSeparate depthRange depthRange[f] stencilMaskSeparate hint polygonOffset vertexAttrib1f'], [3, 'texParameteri texParameterf vertexAttrib2f stencilFunc stencilOp'], |