html head head body canvas id canvas width 640 height 480 canvas script use strict const canvas document querySelector canvas const gl canvas getContext webgl abc A const vs vertex shader void main gl Position vec4 0 0 0 1 center gl PointSize 120 0 compile the shaders const vertShader gl createShader gl VERTEX SHADER gl shaderSource vertShader vs gl compileShader vertShader error checking for the vertex shader if gl getShaderParameter vertShader gl COMPILE STATUS alert vs shader error gl getShaderInfoLog vertShader abc B const fs fragment shader precision highp float void main gl FragColor vec4 1 0 0 1 red const fragShader gl createShader gl FRAGMENT SHADER gl shaderSource fragShader fs gl compileShader fragShader error checking for the vertex shader if gl getShaderParameter fragShader gl COMPILE STATUS alert fs shader error gl getShaderInfoLog fragShader setup GLSL program abc C const program gl createProgram gl attachShader program vertShader gl attachShader program fragShader gl linkProgram program gl useProgram program const offset 0 const count 1 abc D gl drawArrays gl POINTS offset count script body html
precision highp float void main gl FragColor vec4 1 0 0 1 red const fragShader gl createShader gl FRAGMENT SHADER gl shaderSource fragShader fs gl compileShader fragShader error checking for the vertex shader if gl getShaderParameter fragShader gl COMPILE STATUS alert fs shader error gl getShaderInfoLog fragShader setup GLSL program abc C const program gl createProgram gl attachShader program vertShader gl attachShader program fragShader gl linkProgram program gl useProgram program const offset 0 const count 1 abc D gl drawArrays gl POINTS offset count script body html