A slightly richer vertex shader that passes the color on to the fragment shader.
134 var vertexShaderSource = "attribute vec3 position;" 135 + "attribute vec4 color;" 136 + "" 137 + "varying vec4 vColor;" 138 + "" 139 + "void main()" 140 + "{" 141 + " gl_Position = vec4(position, 1);" 142 + " vColor = color;" 143 + "}";
The position attribute is again copied into gl_Position.
The new code defines a vec4 color attribute to hold r, g, b, α color values. The color attribute is assigned to the identically typed varying vColor. Varying variables are passed from the vertex shader to the fragment shader.