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.