Advertisement

Screen fading

Started by August 15, 2001 01:40 PM
5 comments, last by Sqwiddly 23 years, 6 months ago
I was kinda thinking about 2D games and screen fades lately and I am wondering, what would be a nice way to do it? I mean using glClearColor almost every frame probably wouldn''t be good.. thanks in advance
Odd idea, but I don''t know how good an idea it is...

You''re most likely using the glColor*(...) function somewhere... The ideal way to do it (most likely) is to make all of your colour functions glColor4f(r, g, b, alpha), where alpha is some global constant. Every time through the draw, you can decrement it by some value to fade it out.

Or...

Let''s say {rb, gb, bb} is your background colour and {ro, go, bo} is the object''s colour. Make your colour commands...

  glColor*(ro + (rb - ro) * (step / numSteps),         go + (gb - go) * (step / numSteps),         bo + (bb - bo) * (step / numSteps));  


NumSteps is the number of transitional states between the scene and the blank screen, while step is the current step on your way to that point.

Step = 0 if you want the scene to appear normally. Step = numSteps if you want a blank screen.

Possible answer to your problem?

~ Dragonus
Advertisement
or draw a alpha blended polygon over the whole screen, increasing the alpha with time
Dragonus and zedzeek: thanks!

Here''s what I think i''ll try.. first I''m going to make a function that sets an objects color (the alpha value being a global). This alpha value stays at 1.0f until the app calls on a screen fade, and for each of the objects I could decrease the value until it hits 0.0f right? Seems like it would work.. correct me if im wrong here.. thanks again
Hey Sqwiddly thats the way I think i''d do it. Just use alpha blending to make the objects fade.

I would appreciate it if you could inform me to how cool it looks because I''m thinking of using it with font''s in OpenGL

~Steve~
Ust draw a polygon that fills the screen and add the alpha, you can evan make it fade to red/white/any cholor you want.

If filling the screen is hard, then you can use ortho coordinates for drawing the poly. I''ve tried that and it looked Great.
Help me with my Isometric OpenGL engine.
Advertisement
I forgot to tell you that using the global glColor will give some trouble. Because all sprites will look blended (like your characters going semi transpatent before fading completely).

Use the polygon, easy and doesn''t cost you much preformance trouble (I think having all your sprites blended in transculency will be slower than having ONE transcument polygon).

ope it helps
Help me with my Isometric OpenGL engine.

This topic is closed to new replies.

Advertisement