Archived

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

branhield

color fading

Recommended Posts

branhield    122
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
Ready4Dis    180

  

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