Jump to content
  • Advertisement
Sign in to follow this  
TigerSam

OpenGL Flashing Lights

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

How in OpenGL using GL_LIGHTING would you go about creating a flashing light? Would the best way be to set up a count variable which after x amount of times round the game loop turns the light from either on to off, or off to on depending on its current state? Any input apprechiated Cheers

Share this post


Link to post
Share on other sites
Advertisement
Not that I have ever even touched OpenGL lighting, but I would thing that for random flashes, you would just set a timer , and after a random amount of time, destroy the light.

FlyingIsFun1217

Share this post


Link to post
Share on other sites
In pseudocode :

// In the initialization
timeLeftBeforeLightStateChange = random(0.5 seconds, 3 seconds)

// At each update
timeLeftBeforeLightStateChange -= timeDelta
if timeLeftBeforeLightStateChange <= 0
timeLeftBeforeLightStateChange = random(0.5 seconds, 3 seconds)
if lightIsOn
turnLightOff()
else
turnLightOn()

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!