I have a VBO and an IBO in OpenGL, but am unable to draw them properly. Could you please let me know what I could have forgotten in the frame display function ? - struct Point3D is a struct with 3 floats inside (x,y,z). - nbVertex is the amount of vertexes in the glVertex array. - nbVBOInd is the amount of indices in the VBOInd array.
glGenBuffers(1, &VertexVBOID);
glBindBuffer(GL_ARRAY_BUFFER, VertexVBOID);
glBufferData(GL_ARRAY_BUFFER, sizeof(struct Point3D)*nbVertex, glVertex, GL_STATIC_DRAW);
glGenBuffers(1, &IndexVBOID);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, IndexVBOID);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(int)*nbVBOInd, VBOInd, GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, VertexVBOID);
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, sizeof(glVertex), BUFFER_OFFSET(0)); //The starting point of the VBO, for the vertices
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, IndexVBOID);
glDrawElements(GL_TRIANGLES, 3, GL_UNSIGNED_SHORT, BUFFER_OFFSET(0)); //The starting point of the IBO
Thanks !