#include <stdlib.h>
#include "SDL.h"

int main( int argc, char* argv[] )
{	
	SDL_Surface *screen, *image; /*speicher reservieren 
	/* initialize SDL */
	
	if(SDL_Init(SDL_INIT_VIDEO) == -1)
    	{
        printf("Can't init SDL:  %s\n", SDL_GetError());
        exit(1);
    	}
	
	atexit(SDL_Quit); 
	
	

	/* set the title bar */
	SDL_WM_SetCaption("SDL Test", "SDL Test");

	/* create window */
	
	screen = SDL_SetVideoMode(640, 480, 16, SDL_HWSURFACE);
    if(screen == NULL)
    {
        printf("Can't set video mode: %s\n", SDL_GetError());
        exit(1);
    }
	
	
	
	
	
	/* load bitmap to temp surface */
	
	image = SDL_LoadBMP("hello.bmp");
    if(image == NULL)
    {
        printf("Can't load image of tux: %s\n", SDL_GetError());
        exit(1);
    }
	
	
	
	

	/* convert bitmap to display format */
	/* SDL_Surface* bg = SDL_DisplayFormat(temp);

	/* free the temp surface */
	
	
	 SDL_BlitSurface(image, NULL, screen, NULL);
    	SDL_FreeSurface(image);
   	 SDL_UpdateRect(screen, 0, 0, 0, 0);
	
	
	
	SDL_Event event;
	int gameover = 0;

	/* message pump */
	while (!gameover)
	{
		/* look for an event */
		if (SDL_PollEvent(&event)) {
			/* an event was found */
			switch (event.type) {
				/* close button clicked */
				case SDL_QUIT:
					gameover = 1;
					break;

				/* handle the keyboard */
				case SDL_KEYDOWN:
					switch (event.key.keysym.sym) {
						case SDLK_ESCAPE:
						case SDLK_q:
							gameover = 1;
							break;
					}
					break;
			}
		}

		
	}

	/* free the background surface */
	SDL_FreeSurface(image);

	/* cleanup SDL */
	SDL_Quit();

	return 0;
}


