aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-12-29 12:05:05 -0800
committerAlon Zakai <alonzakai@gmail.com>2013-12-29 12:05:05 -0800
commite2edef3cb2ee8e696b82775e75671f5c9141868c (patch)
tree2dbb51113e7181542bf190af909963136ae72664
parent7a288fffe8960c4b4f211671eb32581c1df93d04 (diff)
parent8865ddefbf65642d6fe289a14c13d76b7eb85cd5 (diff)
Merge pull request #1928 from anlambert/webgl_ANGLE_instanced_arrays
Add support for WebGL hardware instancing through extension ANGLE_instanced_arrays
-rw-r--r--src/library_gl.js42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/library_gl.js b/src/library_gl.js
index 29f78c8a..efe3b868 100644
--- a/src/library_gl.js
+++ b/src/library_gl.js
@@ -547,6 +547,9 @@ var LibraryGL = {
Module.ctx.getExtension('WEBKIT_EXT_texture_filter_anisotropic');
GL.floatExt = Module.ctx.getExtension('OES_texture_float');
+
+ // Extension available from Firefox 26 and Google Chrome 30
+ GL.instancedArraysExt = Module.ctx.getExtension('ANGLE_instanced_arrays');
// These are the 'safe' feature-enabling extensions that don't add any performance impact related to e.g. debugging, and
// should be enabled by default so that client GLES2/GL code will not need to go through extra hoops to get its stuff working.
@@ -4959,6 +4962,45 @@ var LibraryGL = {
return Module.ctx.getError();
}
},
+
+ // ANGLE_instanced_arrays WebGL extension related functions
+
+ glVertexAttribDivisor__sig: 'vii',
+ glVertexAttribDivisor: function(index, divisor) {
+#if GL_ASSERTIONS
+ assert(GL.instancedArraysExt, 'Must have ANGLE_instanced_arrays extension to use WebGL instancing');
+#endif
+ GL.instancedArraysExt.vertexAttribDivisorANGLE(index, divisor);
+ },
+
+ glDrawArraysInstanced_sig: 'viiii',
+ glDrawArraysInstanced: function(mode, first, count, primcount) {
+#if GL_ASSERTIONS
+ assert(GL.instancedArraysExt, 'Must have ANGLE_instanced_arrays extension to use WebGL instancing');
+#endif
+ GL.instancedArraysExt.drawArraysInstancedANGLE(mode, first, count, primcount);
+ },
+
+ glDrawElementsInstanced_sig: 'viiiii',
+ glDrawElementsInstanced: function(mode, count, type, indices, primcount) {
+#if GL_ASSERTIONS
+ assert(GL.instancedArraysExt, 'Must have ANGLE_instanced_arrays extension to use WebGL instancing');
+#endif
+ GL.instancedArraysExt.drawElementsInstancedANGLE(mode, count, type, indices, primcount);
+ },
+
+ // OpenGL Desktop/ES 2.0 instancing extensions compatibility
+
+ glVertexAttribDivisorNV: 'glVertexAttribDivisor',
+ glDrawArraysInstancedNV: 'glDrawArraysInstanced',
+ glDrawElementsInstancedNV: 'glDrawElementsInstanced',
+ glVertexAttribDivisorEXT: 'glVertexAttribDivisor',
+ glDrawArraysInstancedEXT: 'glDrawArraysInstanced',
+ glDrawElementsInstancedEXT: 'glDrawElementsInstanced',
+ glVertexAttribDivisorARB: 'glVertexAttribDivisor',
+ glDrawArraysInstancedARB: 'glDrawArraysInstanced',
+ glDrawElementsInstancedARB: 'glDrawElementsInstanced',
+
// signatures of simple pass-through functions, see later
glActiveTexture__sig: 'vi',