Skip to main content
gamedev.net
🔒 Locked

GL_LIGHTING

Started by ADumbledore 1 reply 1.2k views
Original Post
ADumbledore
ADumbledore
Hello, I don't understand why the following code:

   GL::Render()
{
   GLfloat lightDir[] = {0, 1.0, 1.0, 0}; 
   GLfloat blue[] = {0.0, 0.0, 1.0, 1.0};
	// clear screen and depth buffer
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	// load the identity matrix (clear to default position and orientation)
	glLoadIdentity();

   glLightfv(GL_LIGHT0, GL_DIFFUSE, blue);

   // cut out some code here that causes the object drawn to rotate
   DrawObject();
}
would result in the object being lit with a blue color as it rotates for about 45 degrees, and then the entire object dims (no lighting) for the next say 215 degrees. I would have thought that the light source is constant, so as the object rotates the portion facing the light would be lit blue. Thanks for any help!
CableGuy
CableGuy
When you set a light's position or direction it gets transformed by the current modelview matrix, so that might be your problem.

Hope this helps.
MARS_999
MARS_999
Do you have normals for this object?

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.