View Full Version : Light and Translate

05-13-2011, 09:40 PM
hello everyone,
when I draw a solidsphere at (1,0,0) and shading it as below

GLfloat lightIntensity[]={0.7f, 0.7f, 0.7f, 1.0f};
GLfloat light_position[]={0.1, 0, 0.0f, 0.0f};
glLightfv(GL_LIGHT0, GL_POSITION, light_position);
glLightfv(GL_LIGHT0, GL_DIFFUSE, lightIntensity);
glTranslated(1,0, 0.0); // sphere at (1, 0, 0.0)
glutSolidSphere(0.3, 10, 8);

in this case we have:

origin --> light source(0.1,0,0) --> solidsphere (1,0,0)

i think the left side of solidsphere is lighted, but when i run the program , the right side of solidsphere is lighted

)I think this problem because OpenGL draw solidsphere at (0,0,0) and tranlate in to (1,0,0))
can I solve this problem??

05-14-2011, 12:29 AM
ok!. I have just solved this problem. very simple!^^