gluLookAt + lighting

Started by
3 comments, last by ISOPimp 20 years, 4 months ago
I am making a simple app right now that has 1 light (all default values) a normalized cube, and I am moving about the scene with gluLookAt. The problem is that the light seems to move along with my gluLookAt command similar to a flashlight, so no matter what part of the cube I look at it is always most bright when it is in the center of my view. What I want to be able to do is move behind the cube, and see the dark side of it. Has anyone had this problem before? I dont have the code with me right now but here is the basic procedure I use: 1. Init OpenGL + Window 2. Init OpenGL Options (culling, depth test, lighting) Then in my render loop 1. Clear (Color + Depth) 2. LoadIdentity 3. Position and rotate the camera 4. Call gluLookAt 5. Draw Cube Thank you. PS. I started with the Java Port of Nehe''s First Tutorial.
Advertisement
this happened to me too, and i still havent solved it (been working with opengl for a while now). it even does it with fog.
--FirekingOwner/LeaderFiregames Development &Blackdragon Studios
I think it''s because when you do your glTranslates and glRotates and whatever, it''s actually moving where it draws the objects, not where the camera is. So, the camera is staying still and everything (your cube) is moving around it. So, what you probably would have to do is move your light whenever you move your scene. Otherwise the light is just staying in the same spot.

It could be that I have no clue what I''m talking about, but I think that''s what''s happening...
hi guys. I''ve seen this problem too. Here''s how I fixed it.

In your drawing method, do this *after* applying camera rotation and translation:

glLightfv(GL_LIGHT0, GL_POSITION, light_position);

the key is to do it after the camera has been positioned.
That sounds like it would work. I''ll test it when I get home.... Thanks

This topic is closed to new replies.

Advertisement