Strange lighting problem

Started by
4 comments, last by TomasH 18 years, 4 months ago
I have a quite strange problem with my opengl program. The lighting is affected by how my camera is rotated. If I look on a cube and look around the cube goes colored (by the color of the ligth) but if i look straight into it it has normal texture. Any ideas what it could be?
Advertisement
Set you light position after you call gluLookAT() and before you do anything else every frame...
Yes, but I am already doing that.
Are you providing correct face/vertex normals when rendering?
Richard 'ViLiO' Thomasv.net | Twitter | YouTube
first off - whenever you do any rotations or anything with the camera make sure you change the matrix mode to GL_PROJECTION, then switch back to GL_MODELVIEW to move lights around ,etc...

next off, are you doing directional or positional?
AfroFire | Brin"The only thing that interferes with my learning is my education."-Albert Einstein
Quote:Original post by AfroFire
first off - whenever you do any rotations or anything with the camera make sure you change the matrix mode to GL_PROJECTION, then switch back to GL_MODELVIEW to move lights around ,etc...

Mmmm... no.

The projection matrix should only define the type of projection (so to speak), meaning glFrustum, glPerspective, glOrtho etc. Think of it as the matrix stack that is used to choose the lens for your camera (but not the position/orientation of it).

The modelview matrix is used for all rotations and translations, whether you consider them moving the camera, an object or a light source.

Perhaps posting some code would help?

This topic is closed to new replies.

Advertisement