I'm using vertex arrays to create a cube. I've used the GL_VERTEX_ARRAY and the GL_COLOR_ARRAY to draw and color the cube. However, using these arrays only lets me set an individual color to each VERTEX.
I need to set an individual color to each FACE. Does anyone know how to do this?
Here's some of the code that I'm using so you'll have a better idea what I'm doing:
This is how I enabled the arrays:
glEnableClientState(GL_COLOR_ARRAY);
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, 0, cubeVertices);
glColorPointer(3, GL_FLOAT, 0, cubeColors);
Here are the arrays I created:
GLfloat cubeVertices[] ={-5,-5,-5, 5,-5,-5,
5,5,-5, -5,5,-5, -5,-5,5, 5,
-5,5, 5,5,5, -5,5,5};
GLfloat cubeColors[] = {0,0,0, 1,0,0, 1,1,0,
0,1,0, 0,0,1, 1,0,1, 1,1,1, 0,1,1};
GLubyte cubeIndices[]={0,3,2,1, 2,3,7,6, 0,4,7,3, 1,2,6,5, 4,5,6,7, 0,1,5,4};
Here's where I drew the cube:
[cube]
glDrawElements(GL_QUADS, 24, GL_UNSIGNED_BYTE, cubeIndices);
[/cube]
Pixel art/3D art portfolio: http://myweb.csuchico.edu/~lkester/