set viewport resolution using gl.canvas.{width, height}

This commit is contained in:
Emile Clark-Boman 2026-01-31 13:17:03 +10:00
parent c452a0761d
commit 7e59de380f

View file

@ -1,4 +1,7 @@
function drawScene(gl, programInfo, buffers, time) {
// Tell WebGL how to convert from clip space to pixels
gl.viewport(0, 0, gl.canvas.width, gl.canvas.height);
gl.clearColor(0.0, 0.0, 0.0, 1.0); // Clear to black, fully opaque
gl.clearDepth(1.0); // Clear everything
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
@ -21,8 +24,8 @@ function drawScene(gl, programInfo, buffers, time) {
// Viewport resolution in pixels
gl.uniform2f(
programInfo.uniformLocations.resolution,
gl.drawingBufferWidth,
gl.drawingBufferHeight,
gl.canvas.width,
gl.canvas.height,
);
{