Hi, I’ve got a ‘little’ problem. Look at this code:
[b] glTranslatef(0,0,-12.0f);
for(int i=0; i<20;i++)
{
for(int j=0;j<20;j++)
{
glPushMatrix();
glTranslatef(i-10,j-10,-i*j*0.2);
glRotatef(aaa*40,1.0f,1.0f,0.0f);
glBegin(GL_TRIANGLES);
glColor3f(1-i*0.05f,1-j*0.05f,0.0f);
glNormal3f(0.0f,0.0f,1.0f);
glVertex3f(-1.0f,0.0f,0.0f);
glVertex3f(1.0f,0.0f,0.0f);
glVertex3f(0.0f,1.0f,0.0f);
glEnd();
glPopMatrix();
};
};
// glEnable(GL_LIGHTING);
glColorMaterial(GL_FRONT,GL_DIFFUSE);
glLoadIdentity();
… some polygons are drew later.[/b]
Is it wrote properly? I think yes, because polygons are shaded properly (before this code GL_COLOR_MATERIAL is enabled). But when I change the place where glColorMaterial() function is written to place before all this code, that means:
[b] glColorMaterial(GL_FRONT,GL_DIFFUSE);
glTranslatef(0,0,-12.0f);
for(int i=0; i<20;i++)
{
(…)
[/b]
All polygons are white. I don’t know why. It happens even when all code between old and new place for glColorMaterial() is in commentary:
[b]
glColorMaterial(GL_FRONT,GL_DIFFUSE);
/* glTranslatef(0,0,-12.0f);
for(int i=0; i<20;i++)
{
for(int j=0;j<20;j++)
{
glPushMatrix();
glTranslatef(i-10,j-10,-i*j*0.2);
glRotatef(aaa*40,1.0f,1.0f,0.0f);
glBegin(GL_TRIANGLES);
glColor3f(1-i*0.05f,1-j*0.05f,0.0f);
glNormal3f(0.0f,0.0f,1.0f);
glVertex3f(-1.0f,0.0f,0.0f);
glVertex3f(1.0f,0.0f,0.0f);
glVertex3f(0.0f,1.0f,0.0f);
glEnd();
glPopMatrix();
};
};*/
// glEnable(GL_LIGHTING);
glLoadIdentity();
[/b]
What can be wrong?