Jump to content
  • Advertisement
Sign in to follow this  
gcmonk

OpenGL moving lights

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

I am currently learning OpenGL and I am starting on lighting. I made a scene with a heightfield terrain and can move around it with directional keys. I also placed a light using these commands in my initilization section and then render the map. When I move around though, it seems like the lighting changes, as if it's moving with me. I read somewhere that the lights are moved when you do translation and such. Is there a way I can make sure the lights are moved or am I doing this wrong?
  // this is in my init section of code
  GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 };
  GLfloat mat_shininess[] = { 50.0 };
  GLfloat light_position[] = { 0.0, 1.0, 1.0, 1.0 };

  glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
  glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess);
  glLightfv(GL_LIGHT0, GL_POSITION, light_position);

  glEnable(GL_LIGHTING);
  glEnable(GL_LIGHT0);

// this is in my main loop
  glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);  
  glLoadIdentity();
  glRotatef(mAngleZ, 0.0f, 1.0f, 0.0f);
  glTranslatef(mX, mY, mZ);
  // renders the heightfield terrain
  mMap->Render();

Share this post


Link to post
Share on other sites
Advertisement
I've done a search using the terms, "opengl light moving" and "opengl lighting move" and can't seem to find it. Do you happen to have this thread handly so I can learn from it?

Share this post


Link to post
Share on other sites
Found the relevant thread after going through each page of thread in the OpenGl forum. ^_^ Here it is for anyone else who may encounter the problem.

http://www.gamedev.net/community/forums/topic.asp?topic_id=329426

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!