PDA

View Full Version : Vertex-Color & Lighting?



AleaIactaEst
12-28-2009, 05:38 PM
I am currently working with interleaved arrays, especially the format GL_T2F_C4F_N3F_V3F.

So far i've drawn a cube with the following array and indices:

//Format: GL_T2F_C4F_N3F_V3F
// Texture Color Normals Vertices
GLfloat Cube[] = {0.0,0.0, 1.0,1.0,1.0,1.0, -1.07735,-1.07735,-1.07735, -0.5,-0.5,-0.5,
1.0,0.0, 1.0,1.0,0.0,1.0, 1.07735,-1.07735,-1.07735, 0.5,-0.5,-0.5,
1.0,1.0, 1.0,0.0,1.0,1.0, 1.07735, 1.07735,-1.07735, 0.5, 0.5,-0.5,
0.0,1.0, 0.0,1.0,1.0,1.0, -1.07735, 1.07735,-1.07735, -0.5, 0.5,-0.5,
1.0,0.0, 1.0,0.0,0.0,1.0, -1.07735,-1.07735, 1.07735, -0.5,-0.5, 0.5,
0.0,0.0, 0.0,1.0,0.0,1.0, 1.07735,-1.07735, 1.07735, 0.5,-0.5, 0.5,
0.0,1.0, 0.0,0.0,1.0,1.0, 1.07735, 1.07735, 1.07735, 0.5, 0.5, 0.5,
1.0,1.0, 0.0,0.0,0.0,1.0, -1.07735, 1.07735, 1.07735, -0.5, 0.5, 0.5};
//faces: front right left bottom top back
GLubyte indices[] = {0,1,2,3, 1,5,6,2, 4,0,3,7, 5,1,0,4, 3,2,6,7, 6,5,4,7};

That's the cube with neither lighting nor textures enabled:
http://img197.imageshack.us/img197/3641/nolighting.png









And this is the one with lighting enabled and textures disabled:
http://img192.imageshack.us/img192/130/lightingenabled.png

Obviously the colors from the vertices disappeared and the cube is drawn with the white color of the light.

So what do I need the color at the vertices for if they disappear anyway as soon as I enable lighting? Is it possible to draw the cube with the color which was previously assigned to every vertex with lighting enabled?

ZbuffeR
12-28-2009, 07:15 PM
Try doing glEnable(GL_COLOR_MATERIAL);