SDL_Flip causing access violation

Not sure what changed (I didn’t think anything had changed) but my
SDL_Flip(screen) command now causes an access violation. Here is some of the
code:

/* Initialize SDL's video system and check for errors. */
if (SDL_Init(SDL_INIT_VIDEO) != 0) {
	printf("Unable to initialize SDL: %s\n", SDL_GetError());
	return 1;
}

/* Make sure SDL_Quit gets called when the program exits! */
atexit(SDL_Quit);

/* Attempt to set a 640x480 hicolor (16-bit) video mode. */
screen = SDL_SetVideoMode(640, 480, 16, SDL_DOUBLEBUF);
if (screen == NULL) {
	printf("Unable to set video mode: %s\n", SDL_GetError());
	return 1;
}


… draw stuff here. Right now, all it does is draw a big yellow rectangle,
nothing else.

SDL_Flip(screen);

It then bombs at the SDL_Flip. If I remove the SDL_Flip(), and change it to
this:

SDL_UpdateRect(screen, 0, 0, 0, 0);

Then it works fine. But that’s not what I want, as that defeats the
double_buffer. Any ideas?

Thanks,
-Todd
SDL_UpdateRect(screen, 0, 0, 0, 0);_________________________________________________________________
Protect your PC - get McAfee.com VirusScan Online
http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963

You should give a hardware or software service to SDL. Otherwise you get
unreliable results :

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

or

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

Not all platforms support the SDL_HWSURFACE.

I hope this helps :slight_smile:

Your sincerely,

Niels Wagenaar
http://sdlemu.ngemu.com> ----- Original Message -----

From: toddhd@hotmail.com (Todd Davis)
To:
Sent: Thursday, June 19, 2003 9:57 PM
Subject: [SDL] SDL_Flip causing access violation

Not sure what changed (I didn’t think anything had changed) but my
SDL_Flip(screen) command now causes an access violation. Here is some of
the
code:

/* Initialize SDL’s video system and check for errors. */
if (SDL_Init(SDL_INIT_VIDEO) != 0) {
printf(“Unable to initialize SDL: %s\n”, SDL_GetError());
return 1;
}

/* Make sure SDL_Quit gets called when the program exits! */
atexit(SDL_Quit);

/* Attempt to set a 640x480 hicolor (16-bit) video mode. */
screen = SDL_SetVideoMode(640, 480, 16, SDL_DOUBLEBUF);
if (screen == NULL) {
printf(“Unable to set video mode: %s\n”, SDL_GetError());
return 1;
}


… draw stuff here. Right now, all it does is draw a big yellow rectangle,
nothing else.

SDL_Flip(screen);

It then bombs at the SDL_Flip. If I remove the SDL_Flip(), and change it
to
this:

SDL_UpdateRect(screen, 0, 0, 0, 0);

Then it works fine. But that’s not what I want, as that defeats the
double_buffer. Any ideas?

Thanks,
-Todd
SDL_UpdateRect(screen, 0, 0, 0, 0);


Protect your PC - get McAfee.com VirusScan Online
http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Not sure what changed (I didn’t think anything had changed) but my
SDL_Flip(screen) command now causes an access violation. Here is some of the
code:

/* Initialize SDL’s video system and check for errors. */
if (SDL_Init(SDL_INIT_VIDEO) != 0) {
printf(“Unable to initialize SDL: %s\n”, SDL_GetError());
return 1;
}

/* Make sure SDL_Quit gets called when the program exits! */
atexit(SDL_Quit);

/* Attempt to set a 640x480 hicolor (16-bit) video mode. */
screen = SDL_SetVideoMode(640, 480, 16, SDL_DOUBLEBUF);
if (screen == NULL) {
printf(“Unable to set video mode: %s\n”, SDL_GetError());
return 1;
}


… draw stuff here. Right now, all it does is draw a big yellow rectangle,
nothing else.

SDL_Flip(screen);

It then bombs at the SDL_Flip. If I remove the SDL_Flip(), and change it to
this:

SDL_UpdateRect(screen, 0, 0, 0, 0);

Then it works fine. But that’s not what I want, as that defeats the
double_buffer. Any ideas?

How about posting the entire file so somebody can compile it and see
what’s going on?

See ya,
-Sam Lantinga, Software Engineer, Blizzard Entertainment