colouring triangles

im trying to learn how to light up a triangle strip on a polygon mesh, and i cant seem to get it to work. im using the following…

void faceStrip (CGPolyMesh *m, int faceIndex, int edgeIndex)
{

int i;
CGFaceVertex *f;
RGBAColor *cptr;

// setup vertex array
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, 0, m->V);

glBegin(GL_TRIANGLES);

for (f=m->Fv, i=0 ; i<m->noofFaces ; i++, f++)cptr = m->C + i; // i’th face colour in colour array
glColor3f(cptr->r, cptr->g, cptr->b);

		glArrayElement(f-&gt;v1);
		glColor3f(1.0, 1.0, 0.0);
		glArrayElement(f-&gt;v2);
		glColor3f(1.0, 1.0, 0.0);
		glArrayElement(f-&gt;v3);
		glColor3f(1.0, 1.0, 0.0);
		
		 	

	

	}

glEnd();

glEnableClientState(GL_VERTEX_ARRAY);

does any one know where im going wrong?

thanx

jofoxy

where i say light i mean colour in red for example

If you’ve got lighting enabled, glColor does nothing, you must manipulate the colour of the object by changing its material properties.
However, you can still use glColor by using colormaterial:-

glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
glEnable(GL_COLOR_MATERIAL);

This will make OpenGL change the ambient and diffuse attributes of the current material whenever you use glColor or equivalent.

i dont mean light up i mean colour in red a triangle stip polygon

Why do you call glColor3f(1.0, 1.0, 0.0) between your vertices? You would get only yellow polygons this way, because AFAIK with flat shading the color of the last vertex determines the color of the whole polygon. Or you might get color interpolation between your color and yellow if you activate smooth shading.

You need to post your question as an OpenGL question ONCE and you should stick to the beginners forum for now.

If you don’t get a reply in one thread don’t post another two.

Moving thread to beginners forum.