summaryrefslogblamecommitdiffstats
path: root/blockgame/mesh.js
blob: 0e39fd033fe524386440726e1353e9a8709da792 (plain) (tree)























                                                                                            

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);
	}
}