upgraded to webgl2

This commit is contained in:
dongho
2024-09-03 16:21:56 +09:00
parent f16a721d2d
commit 7bf70c6010
6 changed files with 200 additions and 73 deletions

View File

@ -89,7 +89,7 @@ function bind2DFloat32Data(positions) {
function main() {
const canvas = document.querySelector("#glcanvas");
// Initialize the GL context
gl = canvas.getContext("webgl");
gl = canvas.getContext("webgl2");
// Only continue if WebGL is available and working
if (gl === null) {
@ -106,12 +106,12 @@ function main() {
`;
const fsSource = `
void main() {
gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0);
gl_FragColor = vec4(0, 1.0, 0, 1.0);
}
`;
const shaderProgram = compileLinkProgram(vsSource, fsSource);
const positions = [0.5, 0.5, -0.5, 0.5, 0.5, -0.5, -0.5, -0.5];
const vao = bind2DFloat32Data(positions);
// Set clear color to black, fully opaqe
gl.clearColor(0.0, 0.0, 0.0, 1.0);
// Clear the color buffer with specified clear color