aboutsummaryrefslogtreecommitdiff
path: root/src/library_gl.js
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2012-06-16 09:26:58 -0700
committerAlon Zakai <alonzakai@gmail.com>2012-06-16 09:26:58 -0700
commitca9c2d70f9480b50f8838944fa5a54eebc0da302 (patch)
tree5fe2310e0f5cf5f7fd85ff8cc406c0310a0f90ca /src/library_gl.js
parent0d4e93976815ea7edab89b8dbe4907bab9d39bd7 (diff)
GL_QUAD non-0 start rendering fix
Diffstat (limited to 'src/library_gl.js')
-rw-r--r--src/library_gl.js9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/library_gl.js b/src/library_gl.js
index 87c47421..21d71878 100644
--- a/src/library_gl.js
+++ b/src/library_gl.js
@@ -1891,9 +1891,14 @@ var LibraryGL = {
}
} else if (GL.immediate.mode > 6) { // above GL_TRIANGLE_FAN are the non-GL ES modes
if (GL.immediate.mode != 7) throw 'unsupported immediate mode ' + GL.immediate.mode; // GL_QUADS
+ // GL.immediate.firstVertex is the first vertex we want. Quad indexes are in the pattern
+ // 0 1 2, 0 2 3, 4 5 6, 4 6 7, so we need to look at index firstVertex * 1.5 to see it.
+ // Then since indexes are 2 bytes each, that means 3
+ assert(GL.immediate.firstVertex % 4 == 0);
+ ptr = GL.immediate.firstVertex*3;
var numQuads = numVertexes / 4;
- var numIndexes = numQuads * 6; // 0 1 2, 0 2 3 pattern
- assert(numIndexes << 1 <= GL.immediate.MAX_TEMP_BUFFER_SIZE, 'too many immediate mode indexes (b)');
+ numIndexes = numQuads * 6; // 0 1 2, 0 2 3 pattern
+ assert(ptr + (numIndexes << 1) <= GL.immediate.MAX_TEMP_BUFFER_SIZE, 'too many immediate mode indexes (b)');
Module.ctx.bindBuffer(Module.ctx.ELEMENT_ARRAY_BUFFER, this.tempQuadIndexBuffer);
emulatedElementArrayBuffer = true;
}