I'm having an issue loading/assigning interleaved vertex data in OpenGL.
I keep getting an INVALID_OPERATION when setting the second attribute.
EDIT Turns out this only happens on Mac. On Windows, I don't get an INVALID_OPERATION error. But I have modified the below with what it looks like now. Still errors out on Mac.
GL.BindBuffer(BufferTarget.ArrayBuffer, vbo);
GL.VertexAttribPointer(shader.GetAttribLocation("position"), 3, VertexAttribPointerType.Float, false, _vertexStride, 0);
REngine.CheckGLError();
GL.VertexAttribPointer(shader.GetAttribLocation("normal"), 3, VertexAttribPointerType.Float, false, _vertexStride, 12);
REngine.CheckGLError();
GL.VertexAttribPointer(shader.GetAttribLocation("texcoord"), 2, VertexAttribPointerType.Float, false, _vertexStride, 24);
REngine.CheckGLError();
GL.EnableVertexAttribArray(shader.GetAttribLocation("position"));
REngine.CheckGLError();
GL.EnableVertexAttribArray(shader.GetAttribLocation("normal"));
REngine.CheckGLError();
GL.EnableVertexAttribArray(shader.GetAttribLocation("texcoord"));
REngine.CheckGLError();
Any idea why? Others seem to do it and it works great, but I can't seem to get it to work.
Here is my GLSL for this:
layout(location=0) in vec3 position;
layout(location=1) in vec3 normal;
layout(location=2) in vec2 texcoord;
out vec4 out_position;
out vec4 out_normal;
out vec2 out_texcoord;
void main() {
out_normal = vec4(normal,1.0f);
out_position = vec4(position,1.0f);
out_texcoord = texcoord;
}
and the frag:
out vec4 color;
void main()
{
color = vec4(1.0f,1.0f,1.0f,1.0f);
}
EDIT
Turns out I had stale glErrors in the queue from earlier in the pipeline. I checked earlier and had a bum call to glEnableClientState which isn't supported on Mac using the 4.2 context. I removed it as it wasn't necessary anymore with a full shader approach. This fixed the error and my glorious white mesh was displayed.