summaryrefslogtreecommitdiff
path: root/frontend/_shared/2d
diff options
context:
space:
mode:
Diffstat (limited to 'frontend/_shared/2d')
-rw-r--r--frontend/_shared/2d/shader.js18
1 files changed, 17 insertions, 1 deletions
diff --git a/frontend/_shared/2d/shader.js b/frontend/_shared/2d/shader.js
index 4deddb5..7e85a9e 100644
--- a/frontend/_shared/2d/shader.js
+++ b/frontend/_shared/2d/shader.js
@@ -28,7 +28,7 @@ function loadOrthographicShader(pGl) {
return null;
}
- return {
+ var lRetval = {
program: lShaderProgram,
attributeLocations: {
position: pGl.getAttribLocation(lShaderProgram, 'position'),
@@ -38,7 +38,23 @@ function loadOrthographicShader(pGl) {
projection: pGl.getUniformLocation(lShaderProgram, 'projection'),
model: pGl.getUniformLocation(lShaderProgram, 'model')
}
+ };
+
+ lRetval.renderShape = function(pShape) {
+ pGl.uniformMatrix4fv(lRetval.uniformLocations.model, false, pShape.model);
+ pGl.bindBuffer(pGl.ARRAY_BUFFER, pShape.buffer);
+ {
+ pGl.enableVertexAttribArray(lRetval.attributeLocations.position);
+ pGl.vertexAttribPointer(lRetval.attributeLocations.position, 2, pGl.FLOAT, false, BYTES_PER_FLOAT * 6, 0);
+
+ pGl.enableVertexAttribArray(lRetval.attributeLocations.color);
+ pGl.vertexAttribPointer(lRetval.attributeLocations.color, 4, pGl.FLOAT, false, BYTES_PER_FLOAT * 6, BYTES_PER_FLOAT * 2);
+ }
+
+ pGl.drawArrays(pGl.TRIANGLES, 0, pShape.vertexCount);
}
+
+ return lRetval;
}
return fetch('/_shared/2d/shaders/orthographic.vert').then(function(pResponse) {