diff options
Diffstat (limited to 'blockgame/mesh.js')
-rw-r--r-- | blockgame/mesh.js | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/blockgame/mesh.js b/blockgame/mesh.js new file mode 100644 index 0000000..0e39fd0 --- /dev/null +++ b/blockgame/mesh.js @@ -0,0 +1,24 @@ + +export class Mesh { + constructor(gl, dims) { + this.posbuffer = gl.createBuffer(); + this.dimensions = dims; + } + + add_positions(gl, positions) { + gl.bindBuffer(gl.ARRAY_BUFFER, this.posbuffer); + gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(positions), gl.STATIC_DRAW); + } + + addattrib(gl, shader, buffer, components, type, normalized, stride, offset) { + gl.bindBuffer(gl.ARRAY_BUFFER, buffer); + gl.vertexAttribPointer( + shader.attribs.position, + components, + type, + normalized, + stride, + offset); + gl.enableVertexAttribArray(shader.attribs.position); + } +} |