Hi
I have an object which is derived from a subdivided icosahedron, where each vertex is replaced by a small hexagon (or pentagon).
Each of the hexagons (drawn as TRIANGLE_FAN) may have a different color.
When i put a
glMaterialfv(GL_FRONT, GL_EMISSION, fCol);
before i draw a TRIANGLE_FAN, this works,
and i get the desired result.
Now i want to introduce some lighting and shading to give my object a more threedimensional appearance.
But all I get is my object with much brighter (i.e. washed out) colors, and no noticeable shades - it looks really flat…
Here’s the relevant part (strongly simplified):
float fCol[4];
glCullFace(GL_BACK);
float afLightPos[] = {1.0, 1.0, 1.0, 0.0};
float afLightAmb[] = {0.75, 0.75, 0.75, 1.0};
float afLightDiff[] = {0.0, 0.0, 0.0, 1.0};
float afLightSpec[] = {1.0, 1.0, 1.0, 1.0};
glLightfv(GL_LIGHT0, GL_POSITION, afLightPos);
glLightfv(GL_LIGHT0, GL_DIFFUSE, afLightDiff);
glLightfv(GL_LIGHT0, GL_AMBIENT, afLightAmb);
glLightfv(GL_LIGHT0, GL_SPECULAR, afLightSpec);
glEnable(GL_LIGHT0);
glEnable(GL_COLOR_MATERIAL);
glEnable(GL_LIGHTING);
glShadeModel(GL_SMOOTH);
for (iHex = 0; iHex < iNumHex; iHex++) {
Vec3D *vNode = getVertex(iHex, 0);
colGet(iHex, fCol);
glMaterialfv(GL_FRONT, GL_AMBIENT, fCol);
glBegin(GL_TRIANGLE_FAN);
glVertex3f(vNode->m_fX,vNode->m_fY,vNode->m_fZ);
for (iVert = 0; iVert < NumVert(iHex); iVert++) {
Vec3D *vC = getVertex(iHex, iVert);
glVertex3f(vC->m_fX,vC->m_fY,vC->m_fZ);
}
glEnd();
}
glDisable(GL_LIGHTING);
I don’t know if this is important, but this code is called inside a “glNewList(IDX_BIGOBJECT);… glEndList();”
Can anybody see what i might be doing wrong?
Thank You
Jody