|
rendering a fading background |
Frank Drebin
Member #2,987
December 2002
|
is there a way to create a background (every game cycle) that fades from one color to an other? |
Trent Gamblin
Member #261
April 2000
|
If you use 8 bit color you can cycle a palette.
|
HardTranceFan
Member #7,317
June 2006
|
Are blender functions of help here? Not sure on this as I haven't used them myself as yet. -- |
Frank Drebin
Member #2,987
December 2002
|
i'm not usgin 8bit mode but perhaps the blender-functions are what i'm looking for... |
Archon
Member #4,195
January 2004
|
Quote: is there a way to create a background (every game cycle) that fades from one color to an other? I'd have to suggest OpenGL as you can easily glColor the corners of your background to whatever you like - and it's fast. Otherwise, look into software blending. |
Audric
Member #907
January 2001
|
I guess you mean a rainbow effect like: The speed of hline() is probably driver-dependant. If the result is not fast enough, pre-compute the rainbow on a BITMAP and blit it, hoping for a fast memory copy. |
Frank Drebin
Member #2,987
December 2002
|
ok i'm not using opengl. so what about software blending? [edit] |
GullRaDriel
Member #3,861
September 2003
|
Quote: yes but no rainbow
With this there will be no rainbow. "Code is like shit - it only smells if it is not yours" |
Audric
Member #907
January 2001
|
smooth? As long as you compute a different (theoric) color for each line, smoothness will ultimately depend on the screen's color depth. OpenGL will display exactly as many colors as software drawing, no more, no less. edit: Yep, I meant mathematical interpolation between two colors, like Gullradriel shows for #000000 to #FF0000. The Turrican screenshot I linked is a 256 color GIF, but the actual ingame rainbow has 12bit color depth. |
Fladimir da Gorf
Member #1,565
October 2001
|
Quote: but with maps of 1280*960 pixel (or even bigger) this would be a lot of memory... Is 4.5 MB a lot of memory? Not these days. Though just using hline to render the background over and over could possibly be even faster, as it's more cache-efficient. OpenLayer has reached a random SVN version number ;) | Online manual | Installation video!| MSVC projects now possible with cmake | Now alvailable as a Dev-C++ Devpack! (Thanks to Kotori) |
Frank Drebin
Member #2,987
December 2002
|
ok i think a nice way would be to have a "precomputed" bitmap that is 10*MAP_HEIGHT and blit this for MAP_WIDTH/10 times. |
Audric
Member #907
January 2001
|
You can even try to store it as a single line, 1x960, and stretch_blit() it across the whole screen's width. |
ImLeftFooted
Member #3,935
October 2003
|
int col1, col2; int steps = 60 * 5; // about 5 seconds long for(int i = 0; i < steps; i++) { int col = makecol((getr(col1) * (steps - i) + getr(col2) * i) * 255 / steps, (getg(col1) * (steps - i) + getg(col2) * i) * 255 / steps, (getb(col1) * (steps - i) + getb(col2) * i) * 255 / steps); vsync(); rect(screen, 0, 0, SCREEN_W, SCREEN_H, col); }
|
Frank Drebin
Member #2,987
December 2002
|
ok i'll try that... |
|