Stuff not showing up

Hi all,

I have some code like this:

screen = SDL_SetVideoMode(640, 480, 16, SDL_HWSURFACE | SDL_ANYFORMAT |
SDL_DOUBLEBUF);

/* … then I call a function with this code: */

SDL_Surface *image;
SDL_Rect dest;

/* draw white background */
SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 0xFF, 
	     0xFF, 0xFF));

/* load_image() is wrapper around SDL_LoadBMP() */
if (!(image = load_image("logo.bmp")))
	exit(1);

/* center image */
dest.x = (screen->w - image->w)/2;
dest.y = (screen->h - image->h)/2;
dest.w = image->w;
dest.h = image->h;

SDL_BlitSurface(image, NULL, screen, &dest);
SDL_Flip(screen);

SDL_FreeSurface(image);

/* after calling that function i call: */

SDL_Delay(3000);

Sometimes the image shows up but sometimes it doesn’t. (I could not find
a pattern for this behaviour but it usually doesn’t show up when run it
just after compiling)

Am I doing anything wrong?

TIA–
Luis Oliveira
luismbo at netcabo.pt

i had the same problem. i found out that there must be a timing probelm when
initializing the screen of the window. this rarly happens in fullscreen mode
and
never in hardware mode. although you use SDL_HWSURFACE it is software surface
if you run it under x.

you can bypass the problem if you wait a little bit after the video-mode
initializing. it seems that 500ms do well:

screen = SDL_SetVideoMode(640, 480, 16, SDL_HWSURFACE | SDL_ANYFORMAT |
SDL_DOUBLEBUF);
SDL_Delay(500);

now it schould work fine.

ciao, stefan

Am Montag, 31. Dezember 2001 01:33 schrieben Sie:> Hi all,

I have some code like this:

screen = SDL_SetVideoMode(640, 480, 16, SDL_HWSURFACE | SDL_ANYFORMAT |
SDL_DOUBLEBUF);

/* … then I call a function with this code: */

SDL_Surface *image;
SDL_Rect dest;

/* draw white background */
SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 0xFF,
0xFF, 0xFF));

/* load_image() is wrapper around SDL_LoadBMP() */
if (!(image = load_image(“logo.bmp”)))
exit(1);

/* center image */
dest.x = (screen->w - image->w)/2;
dest.y = (screen->h - image->h)/2;
dest.w = image->w;
dest.h = image->h;

SDL_BlitSurface(image, NULL, screen, &dest);
SDL_Flip(screen);

SDL_FreeSurface(image);

/* after calling that function i call: */

SDL_Delay(3000);

Sometimes the image shows up but sometimes it doesn’t. (I could not find
a pattern for this behaviour but it usually doesn’t show up when run it
just after compiling)

Am I doing anything wrong?

TIA