diff options
author | Jukka Jylänki <jujjyl@gmail.com> | 2014-02-21 00:41:33 +0200 |
---|---|---|
committer | Jukka Jylänki <jujjyl@gmail.com> | 2014-02-21 00:42:49 +0200 |
commit | 50851c70efe445da8b56af1f59b5094845007bf1 (patch) | |
tree | f1fe79b691bbf5dc71ea53f90eff9e10f292cf11 /src | |
parent | 7a4a695ee8bf825ad9cffd04eece1b5d6feb75c5 (diff) |
When LEGACY_GL_EMULATION is enabled, we cannot use WebGL VAO extension effectively, since we need to maintain the VAO state in the emulation layer to be able to programmatically construct the appropriate VBOs for rendering. Therefore only use WebGL VAO extension only when LEGACY_GL_EMULATION is not set. (An alternative could be to glGet() the VAO state when bound, or to maintain a shadow cache alongside the VAOs in the emulation layer, but that wholly defeats the performance purposes of VAOs, so it's the same to just never use the VAO extension when emulating). This fixes the browser GL emulation VAO tests.
Diffstat (limited to 'src')
-rw-r--r-- | src/library_gl.js | 44 |
1 files changed, 16 insertions, 28 deletions
diff --git a/src/library_gl.js b/src/library_gl.js index 10c8cec9..7e4c5a97 100644 --- a/src/library_gl.js +++ b/src/library_gl.js @@ -1806,14 +1806,10 @@ var LibraryGL = { glGenVertexArrays__sig: 'vii', glGenVertexArrays: function (n, arrays) { #if LEGACY_GL_EMULATION - if (GL.vaoExt == null) { - _emulGlGenVertexArrays(n, arrays); - return; - } -#else -#if GL_ASSERTIONS + _emulGlGenVertexArrays(n, arrays); +#else +#if GL_ASSERTIONS assert(GL.vaoExt, 'Must have OES_vertex_array_object to use vao'); -#endif #endif for(var i = 0; i < n; i++) { @@ -1823,6 +1819,7 @@ var LibraryGL = { GL.vaos[id] = vao; {{{ makeSetValue('arrays', 'i*4', 'id', 'i32') }}}; } +#endif }, #if LEGACY_GL_EMULATION @@ -1831,21 +1828,17 @@ var LibraryGL = { glDeleteVertexArrays__sig: 'vii', glDeleteVertexArrays: function(n, vaos) { #if LEGACY_GL_EMULATION - if (GL.vaoExt == null) { - _emulGlDeleteVertexArrays(n, vaos); - return; - } -#else -#if GL_ASSERTIONS + _emulGlDeleteVertexArrays(n, vaos); +#else +#if GL_ASSERTIONS assert(GL.vaoExt, 'Must have OES_vertex_array_object to use vao'); -#endif #endif - for(var i = 0; i < n; i++) { var id = {{{ makeGetValue('vaos', 'i*4', 'i32') }}}; GL.vaoExt.deleteVertexArrayOES(GL.vaos[id]); GL.vaos[id] = null; } +#endif }, #if LEGACY_GL_EMULATION @@ -1854,17 +1847,14 @@ var LibraryGL = { glBindVertexArray__sig: 'vi', glBindVertexArray: function(vao) { #if LEGACY_GL_EMULATION - if (GL.vaoExt == null) { - _emulGlBindVertexArray(vao); - return; - } -#else + _emulGlBindVertexArray(vao); +#else #if GL_ASSERTIONS - assert(GL.vaoExt, 'Must have OES_vertex_array_object to use vao'); -#endif + assert(GL.vaoExt, 'Must have OES_vertex_array_object to use vao'); #endif GL.vaoExt.bindVertexArrayOES(GL.vaos[vao]); +#endif }, #if LEGACY_GL_EMULATION @@ -1873,18 +1863,16 @@ var LibraryGL = { glIsVertexArray__sig: 'ii', glIsVertexArray: function(array) { #if LEGACY_GL_EMULATION - if (GL.vaoExt == null) { - return _emulGlIsVertexArray(array); - } -#else + return _emulGlIsVertexArray(array); +#else #if GL_ASSERTIONS - assert(GL.vaoExt, 'Must have OES_vertex_array_object to use vao'); + assert(GL.vaoExt, 'Must have OES_vertex_array_object to use vao'); #endif -#endif var vao = GL.vaos[array]; if (!vao) return 0; return GL.vaoExt.isVertexArrayOES(vao); +#endif }, #if LEGACY_GL_EMULATION |