Jump to content
  • Advertisement
Sign in to follow this  
badkeeper3410

OpenGL Need help in Opengl Lighting

This topic is 4870 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

hello all. Here I need some help in Opengl lightPosition. I read the readbook 1.4,and found something maybe wrong. In the book, it set a light like follow: init() { ..... GLfloat light_position = {0.0,0.0,0.0,1.0}; glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glLightfv(GL_LIGHT0,GL_POSITION,light_position); } display() { ..... gluLookAt(...); //here change the view matrix,the center is (0,0,0) glutSolodTorus(); //or other geometric } and it said,when the camera move,the light will move with it. and this way can simulate flashlight or candle in hand.Is that right? If the light's position was treated like anyother vertex, It should be multi the modelview Matrix. but if the position moved like the eye,it should be multi the modelview's Invert matrix? please help me

Share this post


Link to post
Share on other sites
Advertisement
Ok,I found some information on www.opengl.org,and understand.Opengl first transform lightposition from world coordinate to eye coordinate,and keep it; the
light operations(computer color) are all in eye coordinate.so if set the light position on (0,0,0) with identity modelview matrix, the light will aways use this coordinate like eye coordinate until set lightposition again.
Is that right? If i am wrong ,please tell me. thanks:)

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!