Passing color to fragment shader from javascript
I am currently learning webgl and have a question. I am trying to make a triangle and passing the color info into fragment shader from js file. The following is my js code. var VSHADER_SOURCE = 'attribute vec4 a_Position;\n'+ 'attribute vec4 a_Color;\n'+ 'varying vec4 v_Color;\n'+ 'void main(){\n'+ 'gl_Position = a_Position;\n'+ 'v_Color = a_Color;\n'+ '}\n'; var FSHADER_SOURCE = 'precision highp float;\n'+ 'varying vec4 v_Color;\n'+ 'void main() {\n'+ 'gl_FragColor = v_Color;\n'+ '}\n'; function main(){ var canvas = document.getElementById('webgl'); var gl = getWebGLContext(canvas); if(!gl){