Jump to content
  • Advertisement
Sign in to follow this  
JWhetstone02

A Fixed Light Position??

This topic is 4232 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I have a quick question on how to get my light position to stay at a fixed point. For instance, I have a room(4walls and ceiling) i want my light source to come from on wall(where a window could be) I have a light position, but it stays from the position i set it at... GLfloat position[] = {1.0, 1.0, 1.0, 0.0}; i would like to know if anyone could help me position this light, so that when i rotate the room around it will only come from one wall. I also looked at a couple of NeHe tutorials, but none seem to get me where i want to be. Lesson27 on shading had a similar thing where u can rotate the light, but i didnot see how the light was moved. If anyone could helps thanks!

Share this post


Link to post
Share on other sites
Advertisement
i think the w value for position ( position[3] )
should be any-value except 0 tho.

if u want ur light be static in its old position
then u need to update the light position when u move/rotate
ur camera.

Share this post


Link to post
Share on other sites
Thanks .. Imma give it a try. I am fairly new to this, so ill give it a try to update my lighting position when I move.

But any other suggestions could be nice..

Thanks again

Share this post


Link to post
Share on other sites
lights are defined when glLight is called with GL_POSITION or GL_DIRECTION. they are affected by the modelview matrix at this point. so:

float position[] = {1.0f, 1.0f, 1.0f, 0.0f}
glLoadIdentity();
glLightfv(GL_LIGHT0, GL_POSITION, position);

would put a directional light at {1, 1, 1}.

Now load identity and draw your scene.

Share this post


Link to post
Share on other sites
this is in the faq
spend 5 minutes reading it (it will save u hours)
u need to position lights each time u change the mv matrix ie the camera

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!