Skip to main content
GameDev.net gamedev.net
🔒 Locked

Simple lighting issue

Started by VanKurt Oct 14, 2005 at 11:34 AM 1 replies 550+ views
Original Post
VanKurt
VanKurt
I'm drawing a simple 2 sided quad. the one side has the normal (0,1,0) while the other one has (0,-1,0). The drawing code than looks like this:

glTranslatef( 0, 70, 0 );
glRotatef( 90, 0.0f, 0.0f, 1.0f );

glDisable(GL_TEXTURE_2D);
glEnable(GL_LIGHTING);
DrawFlatBoxThing();
glDisable(GL_LIGHTING);
glEnable(GL_TEXTURE_2D);

glRotatef(  -90, 0.0f, 0.0f, 1.0f );
glTranslatef( 0, -70, 0 );

Now one side of the quad is black, the other one white. So far so good. But when I move the camera around (using gluLookAt(...)) the lighting of the quad changes! Although the light's position and the quad's position remain fixed! Is there a problem with using gluLookAt together with lighting? What else could cause the problem? (BTW: I'm only using diffuse and ambient lighting) Thanks a lot!
Kalidor
Kalidor
Quote:
Original post by VanKurt
Is there a problem with using gluLookAt together with lighting?
What else could cause the problem?
You are probably setting the light's position before the viewing transformation (gluLookAt). The light position is transformed just like a vertex when you send it to OpenGL with glLight so you need to set the light's position after you call gluLookAt. Read the Lighting chapter of the Red Book for more information, specifically the Controlling a Light's Position and Direction section.
VanKurt
VanKurt
Oh, that sounds great ;-) Im sure that'll do...Thanks!

Topic Locked

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

Sign in to reply to this topic.