summaryrefslogtreecommitdiff
path: root/frontend/_shared/2d
diff options
context:
space:
mode:
authorMatthew Kosarek <matthew.kosarek@vention.cc>2021-02-27 17:32:32 -0500
committerMatthew Kosarek <matthew.kosarek@vention.cc>2021-02-27 17:32:32 -0500
commitd1b528b01796601c2bfea7b1a9813e5907e1c728 (patch)
tree77e2200e930fcad2166edf1e3d31d4cd1211db56 /frontend/_shared/2d
parent026abdb98ad30209df0e88795f25b1f74556585e (diff)
Close to being done on line-circle collisions, but it appears we're running into a rotation problem. Going to work on square-line collisions in the meantime
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) {