You need a VertexAttribPointer
call after each of the BindBuffer
calls in your drawing code. VertexAttribPointer
applies to the currently bound buffer. Your current code has only one VertexAttribPointer
call in the init code, which happened while Buffers[1]
was called. So all your draw calls will use vertex data from that buffer.
EDIT: I also just notice that you use BindVertexArray
in your draw code. Vertex array objects (VAO) are different kinds of objects from vertex buffers (VBO), and you can't just use the id of a VBO for a BindVertexArray
call. To get this all working without VAOs for now, you can remove the VertexAttribPointer
call from the init code. Then add two VertexAttribPointer
calls to your draw code, and replace the BindVertexArray
with BindBuffer
, to structure it like this:
gl.BindBuffer(OpenGL.GL_ARRAY_BUFFER, Buffers[0]);
gl.VertexAttribPointer((uint)Attrib_IDs.vPosition, 3, OpenGL.GL_FLOAT, false, 0, new IntPtr(0));
for (int i = 0; i < 34; i++)
{
gl.DrawArrays(OpenGL.GL_QUAD_STRIP, i * 52, 52);
}
gl.BindBuffer(OpenGL.GL_ARRAY_BUFFER, Buffers[1]);
gl.VertexAttribPointer((uint)Attrib_IDs.vPosition, 3, OpenGL.GL_FLOAT, false, 0, new IntPtr(0));
shaderProgram.SetUniform3(gl, "color", 0, 0.4f, 1);
for (int i = 0; i < 48; i++)
{
gl.DrawArrays(OpenGL.GL_QUAD_STRIP, i * 26, 26);
}
The other option is that you really use Vertex Array Objects (VAO) all the way. For that to work, you have to create those objects in the init code (glGenVertexArrays
), and bind them while setting up the state for each buffer. They allow you to set up all your state during setup, and then only make a single bind call when you get ready to draw. You should be able to find code examples for that with some searching.