I was testing it with more complicated object also but for purpose of this post i added QUAD and removed some trash.
My problem is. I have got light just before my “eyes” (i can se it’s position becouse i have drawn cross in this point) and there is a quad after the light pos “eyepos”>>“light_pos”>>“object”
Normals points from the object toward eye cordinates. But the object is not enlightened until i move it toward eye and pass the light_pos so it looks like that eye>>object>>light. But when i change Normal’s xyz to negative (-x,-y,-z) i can see the object properly shading.Why do i have to flip the normals direction (toward object) to make it correct ??
///////////////////////THE codE////////////
void TestRendering()
{
int IndV;
int IndN;
float px,py,pz;
float LPos[]={0.0f,0.0f,0.0f};
float LDif[]={0.6f,0.6f,0.6f};
float LSpc[]={0.4f,0.4f,0.4f};
float Amb[]={0.5f,0.5f,0.5f};
float MAmbDif[]={0.75f,0.75f,0.75f};
float MSpc[]={1.0f,1.0f,1.0f};
//-----------------Test Rendering
glClearColor(0.0f, 0.0f, 0.0f, 0.0f );
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glEnable(GL_DEPTH_TEST);
glEnable(GL_LIGHTING);
glEnable(GL_COLOR_MATERIAL);
glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);
glFrontFace(GL_CCW);
glShadeModel(GL_SMOOTH);
glColorMaterial(GL_FRONT,GL_AMBIENT_AND_DIFFUSE);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(60,1,0.01,100);
gluLookAt(0,0,3.5,0,0,0,0,1,0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
//Turning and positioning Light
glLightfv(GL_LIGHT0,GL_DIFFUSE,LDif);
glLightfv(GL_LIGHT0,GL_POSITION,LPos);
glEnable(GL_LIGHT0);
#define DCROSS //drawing cross where light is
#if defined (DCROSS)
glDisable(GL_LIGHTING);
glColor3f(1.0f,1.0f,1.0f);
glBegin(GL_LINES);
glVertex3f(LPos[0]+0.3,LPos[1],LPos[2]); glVertex3f(LPos[0]-0.3,LPos[1],LPos[2]); glVertex3f(LPos[0],LPos[1]+0.3,LPos[2]); glVertex3f(LPos[0],LPos[1]-0.3,LPos[2]); glVertex3f(LPos[0],LPos[1],LPos[2]+0.3); glVertex3f(LPos[0],LPos[1],LPos[2]-0.3);
glEnd();
glEnable(GL_LIGHTING);
#endif
//rotating object and setting distance
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0,0,Dist-1.5);
glRotatef(CamRotX,0,1,0);
glRotatef(CamRotY,1,0,0);
//End Turning and drawing Light
//--------------- //one dimensional quad to lighten//
glBegin( GL_QUADS );
glNormal3f( 0.0f, 0.0f, 1.0f);// Normal Pointing Towards Viewer
glVertex3f(-1.0f, -1.0f, 0.0f); // Point 1 (Front)
glVertex3f( 1.0f, -1.0f, 0.0f); // Point 2 (Front)
glVertex3f( 1.0f, 1.0f, 0.0f); // Point 3 (Front)
glVertex3f(-1.0f, 1.0f, 0.0f);
glEnd();
//---------------
//DRAWING TEXT
glPushMatrix();
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
gluOrtho2D(-1,1,-1,1);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glDisable(GL_DEPTH_TEST);
glDisable(GL_LIGHTING);
glColor3f(1.0f,1.0f,1.0f);
GLScreen->Write2DText("Ilosc Wierzcholkow: ",(int)VectVertex3f.size(),-1.0f,0.9f);
GLScreen->Write2DText("Ilosc Trojkatow: ",(int)VectFace.size()/3,-1.0f,0.8f);
glEnable(GL_LIGHTING);
glEnable(GL_DEPTH_TEST);
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
//DRAWING TExt
//----------------ENDOF IT
}