Jump to content
  • Advertisement
Sign in to follow this  
razvani_844

OpenGL opengl lights

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

Hy i need some help please. I have created a car that has to move on a 3D circuit. The problem i have is that i have to put lights on the car (i.e stoplights and headlughts). My car is moving on the circuit and i know 2 coordinates (x and z). How can i put lights to be red to move with the car and to be rectangular shape (the stoplights) and the headlights to light in front of the car. Can u please help me and if u know i have to make the scene look like night. Thank you for your help.

Share this post


Link to post
Share on other sites
Advertisement
Well, you don't assign a shape to light. So, for rectangular shape (the stoplights) - you just have to draw red rectangular shape. Then, on some position between stoplights you put red openGL light. You turn light on and draw light red shape/off and draw dark red shape and the effect will be there. Same for headlights.

For lights, you should use spot lights:

glLight(GLLightHandle,GL_DIFFUSE, ltDiffuse); // color of the direct illumination
glLight(GLLightHandle,GL_SPECULAR, ltSpecular); // color of the highlight
glLight(GLLightHandle,GL_AMBIENT, ltAmbient); // color of the reflected light
glLight(GLLightHandle,GL_POSITION, ltPosition);
glLightf(GLLightHandle,GL_SPOT_CUTOFF, cutoffAngle); // width of the beam
glLight(GLLightHandle,GL_SPOT_DIRECTION, ltDirection); // which way it points

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!