From b15d727e0bacec5084aad11822f8cd0c955e0878 Mon Sep 17 00:00:00 2001 From: John Breaux Date: Thu, 28 Jul 2022 08:15:12 -0500 Subject: [PATCH] Upgrade to webgl2 --- BivariateFunction/BivariateFunction.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/BivariateFunction/BivariateFunction.js b/BivariateFunction/BivariateFunction.js index b789c3d..c8b9d53 100644 --- a/BivariateFunction/BivariateFunction.js +++ b/BivariateFunction/BivariateFunction.js @@ -3,7 +3,6 @@ // k: number of subdivisions per edge -// On my machine, k = [1, 256) // I prefer 96 var k = 64 // f(x, y): function to graph @@ -69,8 +68,9 @@ function main() { // Retrieve element var canvas = document.getElementById('webgl'); - // Get the rendering context for WebGL - var gl = getWebGLContext(canvas); + // Get the rendering context for WebGL *2* + var gl = canvas.getContext('webgl2'); + if (!gl) { console.log('Failed to get the rendering context for WebGL'); return; @@ -151,7 +151,7 @@ function main() { gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT); // Draw the cube - gl.drawElements(gl.TRIANGLES, n, gl.UNSIGNED_SHORT, 0); + gl.drawElements(gl.TRIANGLES, n, gl.UNSIGNED_INT, 0); } @@ -237,7 +237,7 @@ function initVertexBuffers(gl) { var vertices = new Float32Array(bf.vertices); var colors = new Float32Array(bf.vertex_colors); var normals = new Float32Array(bf.vertex_normals); - var indices = new Uint16Array(bf.indices); + var indices = new Uint32Array(bf.indices); // Write the vertex property to buffers (coordinates, colors and normals) if (!initArrayBuffer(gl, 'a_Position', vertices, 3)) return -1;