Well, a few things jump out at me...
"lasttime" seems to be a global variable, but then you''re returning a float from your GetTimePassed function that is never used. Which do you intend to use?
It''s unclear whether you''re drawing with DEPTH_TEST enabled or not. If so, you need to draw your textured quad BEHIND (in Z) the black one. Right now they''re at the same Z coordinate. But a better way would be to simply glDisable(DEPTH_TEST) before drawing your black quad and simply draw it last.
since you don''t really need your source colors, you might find that glBlendFunc(GL_ZERO, GL_ONE_MINUS_SRC_ALPHA) is faster, but I dunno. Might not be worth switching modes, I suppose.
As for the timing logic:
total_time = 0.0;
while (total_time < FADE_UP_TIME)
{
draw_textured_quad();
draw_black_quad(total_time/FADE_UP_TIME);
total_time += GetTimePassed();
}
FADE_UP_TIME is the number of seconds you want your fade up to last
draw_textued_quad() draws your textured quad
draw_black_quad() draws your black quad with an alpha as passed
I''ve left out the other stuff like screen clearing, swapping, mode sets, etc...
Popular Topics
Advertisement
Recommended Tutorials
Advertisement