From d1b528b01796601c2bfea7b1a9813e5907e1c728 Mon Sep 17 00:00:00 2001 From: Matthew Kosarek Date: Sat, 27 Feb 2021 17:32:32 -0500 Subject: 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 --- frontend/_shared/2d/shader.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'frontend/_shared/2d') 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) { -- cgit v1.2.1