Use index buffers (GL_ELEMENT_ARRAY_BUFFER) and glDrawElements as well. Example:
Construct ibo.
//gen vbo
int[] indices = new int[] { //This uses quads and depends on the order of the vertices in the vbo but you get the
0, 1, 2, 3, //Face 1 picture
4, 5, 6, 7, //Face 2
0, 1, 5, 4, //Face 3
3, 2, 6, 7, //Face 4
0, 4, 7, 3, //Face 5
1, 5, 6, 2 //Face 6
};
IntBuffer indicesData = createIntBuffer(indices);
int iboId = glGenBuffer();
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, iboId);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, indicesData, GL_STATIC_DRAW);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
Rendering the quad
bindVBO();
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, iboId);
setupPointers();
glDrawElements(GL_QUADS, 24, GL_UNSIGNED_INT, 0); //Arguments are: render mode, number indices, type of indices
// and byte offset into indices to start at.
That’s all folks.