Hey, im in need of a little help...

im trying to have my .exe show an image with sdl, wait 2500 milliseconds, close the image and then return to the black console screen with my cout statments and whatnot appearing.

But instead when i exit sdl, the whole program exits. is there any way to correct this?

Here's my source code:

//including files here...

int main(int argc, char* argv[]) 
{   

	SDL_Surface *screen;
	SDL_Surface *picture;
	SDL_Event event;
	SDL_Rect pictureLocation;
	const SDL_VideoInfo* videoinfo; 

	atexit(SDL_Quit);

	/* Initialize the SDL library */
	if( SDL_Init(SDL_INIT_VIDEO) < 0 ) {
		fprintf(stderr,"Couldn't initialize SDL: %s\n", SDL_GetError());
		exit(1);
	} 

	screen = SDL_SetVideoMode(640, 480, 32, SDL_DOUBLEBUF | SDL_HWSURFACE);
	if ( screen == NULL ) {
		fprintf(stderr, "Couldn't set 640x480x8 video mode: %s\n",
			SDL_GetError());
		exit(1);
	} 

	videoinfo = SDL_GetVideoInfo();

	printf("%i", videoinfo->blit_hw);

	// Load Picture
	picture = IMG_Load("image.bmp");

	if (picture == NULL) {
		fprintf(stderr, "Couldn't load %s: %s\n", "image.bmp", SDL_GetError());
		return 0;
	} 

	pictureLocation.x = 0;
	pictureLocation.y = 0; 

	SDL_FillRect(screen, NULL, 1000);
		SDL_BlitSurface(picture, NULL, screen, &pictureLocation);
		SDL_Flip(screen); 

		SDL_Delay(2500); 

		exit(0);

//more code that isnt used below, i.e the "cout" statements.

Very few, if any, members here know what those SDL functions are. Is that a library of some kind? If it is, post the link to it.

You will have to work with the graphical window, because once you exit
the sdl window, it automatically closes the console window as well. You
might be able to get around this by using win32 but thats another
language you will have to learn.

Very few, if any, members here know what those SDL functions are. Is that a library of some kind? If it is, post the link to it.

Do you mean is SDL a library of some kind? Yes it is, and the link is:

www.libsdl.org

I don't know much about SDL programs' behaviour and possibilities, but I noticed that you do a exit(0); there (line #50). In practice, no code that you have below that line will get executed, see exit().

Perhaps you should find a SDL forum for SDL-specific questions.

I don't know much about SDL programs' behaviour and possibilities, but I noticed that you do a exit(0); there (line #50). In practice, no code that you have below that line will get executed, see exit().

Perhaps you should find a SDL forum for SDL-specific questions.

Oh yeah! In my mind i was thinking SDL_quit(); which exits sdl.

swapping my exit with the sdl_quit statment fixes the problem. my image loads, holds for a number of seconds, and then the console screen is loaded.

Thanks for the help!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.