i want to develope a game, and because many open souce games use the sdl graphic
libary i thougth i should do soo too. Anyway, i am still learning the basics,
and came to a problem.
So my Question:
How can i clear the Screen? or the App window?
Because i found no function or something similar ,i tried the following
unsigned long ul_pixelsize;
SDL_LockSurface(screen);
ul_pixelsize=screen->format->BytesPerPixelscreen->wscreen->h;
memset(&(screen->pixels),0,ul_pixelsize);
SDL_UnlockSurface(screen);
but this doesnt seem to work, it eaven seems to me its f****up the whole
displaying routine of Win2k, although i am running the programm as an normal
user. (I think i might have misscalculated the actuale size of the pixel array)
Which blacks the screen. Then you can draw on top of it.
-TomT64
none yet wrote:>Hullo
i want to develope a game, and because many open souce games use the sdl graphic
libary i thougth i should do soo too. Anyway, i am still learning the basics,
and came to a problem.
So my Question:
How can i clear the Screen? or the App window?
Because i found no function or something similar ,i tried the following
unsigned long ul_pixelsize;
SDL_LockSurface(screen);
ul_pixelsize=screen->format->BytesPerPixelscreen->wscreen->h;
memset(&(screen->pixels),0,ul_pixelsize);
SDL_UnlockSurface(screen);
but this doesnt seem to work, it eaven seems to me its f****up the whole
displaying routine of Win2k, although i am running the programm as an normal
user. (I think i might have misscalculated the actuale size of the pixel array)
How can i clear the Screen? or the App window?
<…>
So, is there any “nice” way to clear the screen?
very easy :
SDL_FillRect( screen, NULL, SDL_MapRGB(screen->format, 0,0,0) );
(don’t forget to call SDL_Blit if you use SDL_DOUBLEBUF)
I am drawing a bmp picture with the showBMP function in the sdl introductin
document, and than i move this picture(I draw it at another position).
But the old one is still there, althoug i did a SDL_FillRect().
How can this be?
I am drawing a bmp picture with the showBMP function in the sdl introductin
document, and than i move this picture(I draw it at another position).
But the old one is still there, althoug i did a SDL_FillRect().
How can this be?
How did you update the surface? If you called SDL_UpdateRect(), be sure
to ALSO include the FillRect()'d area that you ‘cleared’.
(This JUST came up a few days ago, didn’t it?)
-bill!
bill at newbreedsoftware.com Man, some trip this turned out to be. http://www.newbreedsoftware.com/ All we caught is a tire, a boot,
New Breed Software a tin can and this book of cliches.On Sun, Sep 05, 2004 at 11:12:51PM +0000, none yet wrote:
Thx for the Fast Answers
but it doest to work.
I am drawing a bmp picture with the showBMP function in the sdl introductin
document, and than i move this picture(I draw it at another position).
But the old one is still there, althoug i did a SDL_FillRect().
How can this be?
loading the bmp file#
(*pC_image)=SDL_LoadBMP(file);
if(!(*pC_image))
return 1;
return 0;
displaying the bmp:
SDL_Rect dest;
/* Blit onto the screen surface.
The surfaces should not be locked at this point.
*/
dest.x = pst_bmp->ui_x;
dest.y = pst_bmp->ui_y;
dest.w = pst_bmp->pC_bmp->w;
dest.h = pst_bmp->pC_bmp->h;
if(SDL_BlitSurface(pst_bmp->pC_bmp, NULL, screen, &dest)) return 1;
/* Update the changed portion of the screen */
SDL_UpdateRects(screen, 1, &dest);
return 0;