It doesn’t really matter. Truthfully for whole frame redraws (such as new
backgrounds) the way you are doing it is one of the most straightforward and
simple ways to handle it. I mean, once you wipe the old background with a new
one, it’s not like the old background stays on the surface just under the new
one.
But if you /really/ do want to wipe the old background, use SDL_FillRect(…) [
http://sdldoc.csn.ul.ie/sdlfillrect.html ], to fill the entire screen with a
solid color (eg, black). Eg.:
SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 0, 0, 0))
where SDL_MapRGB(screen->format…) ensures that the black you use is the same
as the screen format’s black.On Tue, 20 Mar 2001, you wrote:
Hi, I’m a bit of a newbie to SDL and have
simple question to ask, I have a game that uses
a main function to run, RunGame() which draws a
background right at the start, using the folowing code;
SDL_Rect dst;
dst.x = 0;
dst.y = 0;
dst.w = background->w;
dst.h = backgroung->h;
SDL_BlitSurface (background, NULL, screen, &dst);
when the game finishes the next function is an Intro’
screen intro(); so I want to have a dfferent background drawn to
SDL_Surface *screen. I have achieved this by using the code
above to simply draw a different background to screen.
What I would like to know is how to completely remove the original
background before I draw a new one to the SDL_surfae *screen, at the
moment it seems as if I’m forever blitting a new background on top
of the old on without first removing it, or does this not matter.
–
Sam “Criswell” Hart <@Sam_Hart> AIM, Yahoo!:
Homepage: < http://www.geekcomix.com/snh/ >
PGP Info: < http://www.geekcomix.com/snh/contact/ >
Advogato: < http://advogato.org/person/criswell/ >