I am trying to render a basic model using lwjgl (java OpenGL binding). I am trying to do this off my own knowledge as much as possible using what I remember. I created a vbo like this:
int verticesVBO = GL15.glGenBuffers ( );
vboIDs.add ( verticesVBO );
FloatBuffer verticesData = bufferFromData ( vertices );// Custom Method
GL15.glBindBuffer ( GL15.GL_ARRAY_BUFFER , verticesVBO );
GL15.glBufferData ( GL15.GL_ARRAY_BUFFER , verticesData , GL15.GL_STATIC_DRAW );
GL20.glVertexAttribPointer(0, 3, GL11.GL_FLOAT, false, 0, 0);// Binds the vbo to the bound vao
if(( error = GL11.glGetError()) != GL11.GL_NO_ERROR) System.err.println(GLU.gluErrorString(error));
I got about this far with the index buffer object:
int indicesVBO = GL15.glGenBuffers ( );
vboIDs.add ( verticesVBO );
IntBuffer indicesData = bufferFromData ( indices );
GL15.glBindBuffer ( GL15.GL_ELEMENT_ARRAY_BUFFER , indicesVBO );
GL15.glBufferData ( GL15.GL_ELEMENT_ARRAY_BUFFER , indicesData , GL15.GL_STATIC_DRAW );
//Problem Here
if(( error = GL11.glGetError()) != GL11.GL_NO_ERROR) System.err.println(GLU.gluErrorString(error));
The probelm I am having is that I don't know the method to use to bind the index buffer to the vao. For the vbo containing the vertex data I know to use GL20.glVertexAttribPointer(0, 3, GL11.GL_FLOAT, false, 0, 0);
but I remember index buffers behaving differently. This is a learning process so please be constructive with your criticism.
All you need to do is bind the index buffer while the VAO is bound.
See https://www.opengl.org/wiki/Buffer_Object#General_use: