Context
39
glc2 = canvas.getContext('webgl2', options);
One option that I use is {antialias: false}. It is not enough alone, canvas CSS should include "image-rendering: pixelated;"
Text (GLSL) to shader
51
52
53
54
55
56
57
58
59
60
61
62
63
64
let compile_shader = function (gl, str, type)
{
let shader = gl.createShader(type);
gl.shaderSource(shader, str);
gl.compileShader(shader);
if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS))
{
console.error('Error while compiling shader: ' + gl.getShaderInfoLog(shader));
window.alert('Error while compiling shader:\n' + gl.getShaderInfoLog(shader));
return null;
}
return shader;
};
Linking shaders
70
71
72
73
74
75
76
let vsc = compile_shader(gl, vs_str, gl.VERTEX_SHADER);
gl.attachShader(glp.bin, vsc);
let fsc = compile_shader(gl, fs_str, gl.FRAGMENT_SHADER);
gl.attachShader(glp.bin, fsc);
gl.linkProgram(glp.bin);