diff options
author | Ehsan Akhgari <ehsan.akhgari@gmail.com> | 2012-04-13 15:12:31 -0400 |
---|---|---|
committer | Ehsan Akhgari <ehsan.akhgari@gmail.com> | 2012-04-13 15:12:31 -0400 |
commit | aad93045cb07080ee142cbe7340ea1a296e3a935 (patch) | |
tree | 4cc95e6c7264fb4ff8bbe8d70c0a36c8d89de69d /src | |
parent | 3c1261839fecc8922efc30e48c4cad8523154379 (diff) |
Hook up the modelview and projection matrices to the rendering
Diffstat (limited to 'src')
-rw-r--r-- | src/library_gl.js | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/library_gl.js b/src/library_gl.js index 574ffc0a..813d3907 100644 --- a/src/library_gl.js +++ b/src/library_gl.js @@ -1049,9 +1049,11 @@ var LibraryGL = { Module.ctx.shaderSource(this.vertexShader, 'attribute vec4 a_position; \n\ attribute vec2 a_texCoord; \n\ varying vec2 v_texCoord; \n\ + uniform mat4 u_modelView; \n\ + uniform mat4 u_projection; \n\ void main() \n\ { \n\ - gl_Position = a_position; \n\ + gl_Position = u_projection * (u_modelView * a_position); \n\ v_texCoord = a_texCoord; \n\ } \n'); Module.ctx.compileShader(this.vertexShader); @@ -1074,6 +1076,8 @@ var LibraryGL = { this.positionLocation = Module.ctx.getAttribLocation(this.program, 'a_position'); this.texCoordLocation = Module.ctx.getAttribLocation(this.program, 'a_texCoord'); this.textureLocation = Module.ctx.getUniformLocation(this.program, 's_texture'); + this.modelViewLocation = Module.ctx.getUniformLocation(this.program, 'u_modelView'); + this.projectionLocation = Module.ctx.getUniformLocation(this.program, 'u_projection'); // Buffer for data this.vertexData = new Float32Array(5 * this.maxElements); @@ -1111,6 +1115,9 @@ var LibraryGL = { Module.ctx.uniform1i(this.textureLocation, 0); + Module.ctx.uniform4fv(this.modelViewLocation, GL.matrix["m"]); + Module.ctx.uniform4fv(this.projectionLocation, GL.matrix["p"]); + Module.ctx.bindBuffer(Module.ctx.ELEMENT_ARRAY_BUFFER, this.indexObject); Module.ctx.drawElements(Module.ctx.TRIANGLES, this.indexCounter, Module.ctx.UNSIGNED_SHORT, 0); |