Passing Colour from program to vertex shader New to opengl! I am having issues with passing colours from the program to vertex shader.

I am creating a grid where I want to control the color of each cell.Thus I am generating each cell and having two vbo's, one for the vertices, and another for the colour. I want my grid to look like this: 

 

But I end up with:



I have confirmed if I generate the colour data in the vertex shader and then pass it to the fragment, I get the first case. It is only when I grab the colour data from the program that I get the second case.

Code for creating each vbo(written in go):

var vbo [2]uint32
gl.GenBuffers(2, &amp;vbo[0])
gl.BindBuffer(gl.ARRAY_BUFFER, vbo[0])
gl.BufferData(gl.ARRAY_BUFFER, 4*len(points), gl.Ptr(points), gl.STATIC_DRAW)
gl.BindBuffer(gl.ARRAY_BUFFER, vbo[1])
gl.BufferData(gl.ARRAY_BUFFER, 4*3, gl.Ptr([]float32{0.5,0.5,0.0}), gl.STATIC_DRAW)
var vao uint32
gl.GenVertexArrays(1, &amp;vao)
gl.BindVertexArray(vao)
gl.EnableVertexAttribArray(0)
gl.BindBuffer(gl.ARRAY_BUFFER, vbo[0])
gl.VertexAttribPointer(0, 3, gl.FLOAT, false, 0, nil)

gl.EnableVertexAttribArray(1)
gl.BindBuffer(gl.ARRAY_BUFFER, vbo[1])
gl.VertexAttribPointer(1, 3, gl.FLOAT, false, 0, nil)


Vertex Shader:

#version 410
/*layout (location=0) */in vec3 vp;
/*layout (location=1)*/ in vec3 colour;
/*layout (location=2)*/  out vec3 outcolour;
void main(){
    gl_Position = vec4(vp,1.0);
    //outcolour = vec3(0.5,0.5,0.0);
    outcolour = vec3(colour);
}


Fragment Shader

#version 410
in vec3 outcolour;
out vec4 frag_colour;
void main(){
    frag_colour = vec4(outcolour,1.0);
}
I don't know what language that is, but I'm going to hazard a guess that the arrays points and gl.Ptr([]float32{0.5,0.5,0.0}) are not the same size. If you intend to provide per-vertex colors, then you must provide one color for every vertex. If you want to provide a single color that all vertices share, then that would be a uniform, not a vertex shader input.

Also, commenting out your layout declarations isn't helping. Though if you are going to declare a location for the VS output variable, then the matching FS input needs to have the same location declared.