Image won't show up

Hi guys! I'm trying to make a game on c++ and I'm starting on setting an image but that image just won't show and the screen just flashes for a second and goes away~ Any help is appreciated. Thank you all.

btw, I'm using codeblocks and using SDL.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include "SDL.h"
int main( int argc, char* args[] )
{
     //The images
     SDL_Surface* hello = NULL;
     SDL_Surface* screen = NULL;
      //Start SDL
     SDL_Init( SDL_INIT_EVERYTHING );
     //Set up screen
     screen = SDL_SetVideoMode( 640, 480, 32, SDL_SWSURFACE );
     //Load image
     hello = SDL_LoadBMP( "hello.bmp" );
      //Apply image to screen
      SDL_BlitSurface( hello, NULL, screen, NULL );
      //Update Screen
      SDL_Flip( screen );
      //Pause
      SDL_Delay( 2000 );
      //Free the loaded image
      SDL_FreeSurface( hello );
      //Quit SDL
      SDL_Quit();
      return 0; }



try and add an getch or system("PAUSE") before SDL_FreeSurface(hello);
I think that the program closes because there is nothing preventing it to reach SDL_Quit;
It worked! thanks!
Strange if SDL_Delay( 2000 ); does not make the window show for at least 2 seconds. What happens if you increase this number?
Topic archived. No new replies allowed.