Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

branhield

color fading

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

im trying to get my background fading from 0.0f to 1.0f. but when i try to execute this, it will only fade in to 1.0f, and for some reason it wont fade out. It stays at 1.0f. why is that? bool increase = true; ... if(increase) { bgBlue += 0.1f; } else { bgBlue -= 0.1f; } if(bgBlue < 1.0f) { increase = true; } if(bgBlue >= 1.0f) { increase = false; } glClearColor(0.0f, 0.0f, bgBlue, 0.0f);

Share this post


Link to post
Share on other sites
Advertisement

  

bool increase=true;

...

if(increase)
{
bgBlue += 0.1f;
}
else
{
bgBlue -= 0.1f;
}

//Changed this line!!!

if(bgBlue <= 0.0f)
{
increase = true;
}
if(bgBlue >= 1.0f)
{
increase = false;
}


The way you had it, any-time the background was less than 1.0 it would increase (so, it would decrease for only ONE frame (0.1f), then it would be < 1.0f and increase again. Hope this helps.

Billy - BillyB@mrsnj.com
(Hey, I''''m no longer anonymous!)

Share this post


Link to post
Share on other sites

  • 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!