Save a few more webgl calls
This commit is contained in:
parent
7bc7b64c8b
commit
4fdb59596f
16
index.js
16
index.js
@ -339,6 +339,12 @@ async function initWorldGl(gl) {
|
||||
// doing this here because it's the same for all world stuff
|
||||
gl.uniformMatrix4fv(modelLoc, false, new Float32Array(se3.identity()));
|
||||
gl.uniform1i(samplerLoc, 0);
|
||||
|
||||
gl.enableVertexAttribArray(positionLoc);
|
||||
gl.enableVertexAttribArray(normalLoc);
|
||||
gl.enableVertexAttribArray(textureLoc);
|
||||
gl.activeTexture(gl.TEXTURE0);
|
||||
gl.bindTexture(gl.TEXTURE_2D, texture);
|
||||
};
|
||||
|
||||
const drawObject = (objectParams) => {
|
||||
@ -350,16 +356,8 @@ async function initWorldGl(gl) {
|
||||
gl.bindBuffer(gl.ARRAY_BUFFER, glBuffer);
|
||||
|
||||
gl.vertexAttribPointer(positionLoc, 3, gl.FLOAT, false, 20, 0);
|
||||
gl.enableVertexAttribArray(positionLoc);
|
||||
|
||||
gl.vertexAttribPointer(normalLoc, 3, gl.BYTE, true, 20, 12);
|
||||
gl.enableVertexAttribArray(normalLoc);
|
||||
|
||||
gl.vertexAttribPointer(textureLoc, 2, gl.UNSIGNED_SHORT, true, 20, 16);
|
||||
gl.enableVertexAttribArray(textureLoc);
|
||||
|
||||
gl.activeTexture(gl.TEXTURE0);
|
||||
gl.bindTexture(gl.TEXTURE_2D, texture);
|
||||
|
||||
gl.drawArrays(gl.TRIANGLES, 0, numVertices);
|
||||
};
|
||||
@ -389,11 +387,11 @@ async function main() {
|
||||
velocity: [0, 0, 0],
|
||||
},
|
||||
keys: new Set(),
|
||||
world: makeWorld(),
|
||||
lightDirection: [-0.2, -0.5, 0.4],
|
||||
ambiantLight: 0.7,
|
||||
flying: false,
|
||||
isOnGround: false,
|
||||
world: makeWorld(),
|
||||
worldGl,
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user