Hello there,
I’m a bloody beginner in OpenGL (and I’m not very good in C++) and tried to draw a cube with VertexArrays. I know that there is another thread concerning VertexArrays but it didn’t help.
I work with the fabled “red book” and, so I thouhgt, wrote my code right. This is it:
void cube(void){
glEnableClientState(GL_VERTEX_ARRAY);
static GLfloat vertices[] = {0.25, 0.25, 1.00, 3.25, 1.75, 0.25, 1.75, 3.25, 2.50, 0.25, 3.25, 3.25};
glVertexPointer(2, GL_FLOAT, 0, vertices);
//Nummerierung der Punkte des Wuerfels
static GLubyte frontIndices[] = {4, 5, 6, 7};
static GLubyte rightIndices[] = {1, 2, 6, 5};
static GLubyte bottomIndices[] = {0, 1, 5, 4};
static GLubyte backIndices[] = {0, 3, 2, 1};
static GLubyte leftIndices[] = {0, 4, 7, 3};
static GLubyte topIndices[] = {2, 3, 7, 6};
glDrawElements(GL_QUADS, 4, GL_UNSIGNED_BYTE, frontIndices);
glDrawElements(GL_QUADS, 4, GL_UNSIGNED_BYTE, rightIndices);
glDrawElements(GL_QUADS, 4, GL_UNSIGNED_BYTE, bottomIndices);
glDrawElements(GL_QUADS, 4, GL_UNSIGNED_BYTE, backIndices);
glDrawElements(GL_QUADS, 4, GL_UNSIGNED_BYTE, leftIndices);
glDrawElements(GL_QUADS, 4, GL_UNSIGNED_BYTE, topIndices);
glDisableClientState(GL_VERTEX_ARRAY);
}
The only thing I see is an edge of something that doesn’t look like a cube.
What is wrong?