Ok, i’m trying to rendering a cube using vertex arrays, but for some reason the glDrawElements(…) isn’t working for me.
Here is the code that I have:
// These are the variables that are defined
static float fvVertexData = {-0.5f,-0.5f,0.5f, // Vertex 0
-0.5f,0.5f,0.5f, // Vertex 1
0.5f,-0.5f,0.5f, // Vertex 2
0.5f,0.5f,0.5f, // Vertex 3
0.5f,-0.5f,-0.5f, // Vertex 4
0.5f,0.5f,-0.5f, // Vertex 5
-0.5f,-0.5f,-0.5f, // Vertex 6
-0.5f,0.5f,-0.5f}; // Vertex 7
static float fvColorData = {1.0f,0.0f,0.0f, // Color for Vertex 0
0.0f,0.0f,1.0f, // Color for Vertex 1
1.0f,0.0f,0.0f, // Color for Vertex 2
0.0f,0.0f,1.0f, // Color for Vertex 3
1.0f,0.0f,0.0f, // Color for Vertex 4
0.0f,0.0f,1.0f, // Color for Vertex 5
1.0f,0.0f,0.0f, // Color for Vertex 6
0.0f,0.0f,1.0f}; // Color for Vertex 7
static int ivIndexDataTop = {1,7,3,5};
static int ivIndexDataBottom = {0,2,4,6};
static int ivIndexDataSides = {0,1,2,3,4,5,6,7,8,9};
// This is the code in my render procedure
glClear(GL_COLOR_BUFFER_BIT);
glLoadIdentity();glEnableClientState(GL_COLOR_ARRAY);
glEnableClientState(GL_VERTEX_ARRAY);
glColorPointer(3,GL_FLOAT,0,fvColorData);glVertexPointer(3,GL_FLOAT,0,fvVertexData);
glTranslatef(0.0f,0.0f,-5.0f);
// Draw the top face of the cube.
glDrawElements(GL_TRIANGLE_STRIP,4,GL_INT,ivIndexDataTop);
// Draw the sides of the cube
glDrawElements(GL_TRIANGLE_STRIP,10,GL_INT,ivIndexDataSides);
// Draw the bottom of the cube
glDrawElements(GL_TRIANGLE_STRIP,4,GL_INT,ivIndexDataBottom);
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_COLOR_ARRAY);
glFlush();
SwapBuffers(this->m_hDC);
Thanks for any help!
- Halcyon
[This message has been edited by Halcyon (edited 01-10-2003).]