diff --git a/www/js/webgl-demo.js b/www/js/webgl-demo.js index 8b376b2..10deb74 100644 --- a/www/js/webgl-demo.js +++ b/www/js/webgl-demo.js @@ -3,10 +3,6 @@ import { drawScene } from "./draw-scene.js"; main(); -/* XXX: TODO: Avoid using alerts! Check return values instead, - * XXX: TODO: or create/use a Result like object. - */ - // Initialize a shader program, so WebGL knows how to draw our data function initShaderProgram(gl, vsSource, fsSource) { const vertexShader = loadShader(gl, gl.VERTEX_SHADER, vsSource); @@ -86,6 +82,9 @@ function renderShader(gl, vsSource, fsSource) { requestAnimationFrame(render); } requestAnimationFrame(render); + + // XXX: TODO: read this guide it's great! https://stackoverflow.com/questions/56998225/why-is-rendering-blurred-in-webgl + // window.addEventListener('resize', render); } function fetchShader(name) { @@ -102,6 +101,10 @@ function main() { // Initialize the GL context const gl = canvas.getContext("webgl"); + // XXX: TODO: use `window.addEventListener('resize', ...);` + canvas.setAttribute('width', window.innerWidth); + canvas.setAttribute('height', window.innerHeight); + // Only continue if WebGL is available and working if (gl === null) { throw new Error("Unable to initialize WebGL. Your browser or machine may not support it.");