Hello, I want to make a pyramid and light it properly. I use this code for the pyramid:
void drawUnitPyramid()
{
glBegin(GL_POLYGON);
glNormal3f(0,0,-1);
glVertex3f(-0.5, -0.5,0);
glVertex3f(-0.5, 0.5,0);
glVertex3f( 0.5, 0.5,0);
glVertex3f( 0.5, -0.5,0);
glEnd();glBegin(GL_POLYGON); glNormal3f(2,0,-1); glVertex3f(-0.5, -0.5,0); glVertex3f(-0.5, 0.5,0); glVertex3f( 0, 0, 1); glEnd(); glBegin(GL_POLYGON); glNormal3f(-2, 0, -1); glVertex3f( 0.5, 0.5,0); glVertex3f( 0.5, -0.5,0); glVertex3f( 0, 0, 1); glEnd(); glBegin(GL_POLYGON); glNormal3f(0,-2,-1); glVertex3f(-0.5, 0.5,0); glVertex3f( 0.5, 0.5,0); glVertex3f( 0, 0, 1); glEnd(); glBegin(GL_POLYGON); glNormal3f(0,2,-1); glVertex3f( 0.5, -0.5,0); glVertex3f( -0.5, -0.5,0); glVertex3f( 0, 0, 1); glEnd();
}
I use glEnable( GL_LIGHTING );
glEnable( GL_COLOR_MATERIAL );
glEnable( GL_LIGHT0 ); to enable the light but I doesn’t light it good. I guess I have problem with the normal vectors but I made the math like 100 times and I think they are right. With other object like a cube it works properly. Could you help me please ?