OpenGL Image Fade-In / Out Routines?

Started by
10 comments, last by aphidtwix 22 years, 7 months ago
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...


Advertisement
Thanks for all the replies guys!

I re-wrote my whole timing code a couple days ago
and now everything works flawlessly.



at
at

This topic is closed to new replies.

Advertisement