What am I doing wrong?
#include "SDL/SDL.h"
#include <string>
#define SCREEN_WIDTH 640
#define SCREEN_HEIGHT 480
#define SCREEN_BPP 32
SDL_Surface * screen = NULL;
SDL_Surface * image = NULL;
SDL_Event event;
bool init()
{
if (SDL_Init(SDL_INIT_EVERYTHING) < 0)
return false;
if ((screen = SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP, SDL_SWSURFACE)) == NULL)
return false;
SDL_WM_SetCaption("LOL", NULL);
return true;
}
SDL_Surface * load_image ( std::string filename )
{
SDL_Surface * loadedImage = NULL;
SDL_Surface * optimizedImage = NULL;
loadedImage = SDL_LoadBMP(filename.c_str());
if (loadedImage)
{
optimizedImage = SDL_DisplayFormat(loadedImage);
SDL_FreeSurface(loadedImage);
}
return optimizedImage;
}
void apply_surface (int x, int y, SDL_Surface * source, SDL_Surface * destination)
{
SDL_Rect offset;
offset.x = x;
offset.y = y;
SDL_BlitSurface(source, NULL, destination, &offset);
}
void clean_up (SDL_Surface * image)
{
SDL_FreeSurface(image);
SDL_Quit;
}
int main (int argc, char * argv[])
{
bool quit = false;
if (!init)
return 1;
image = load_image("background.bmp");
apply_surface(0, 0, image, screen);
SDL_Flip(screen);
while (!quit)
while (SDL_PollEvent(&event))
if (event.type == SDL_QUIT)
quit = true;
clean_up(image);
return 0;
}
Thanks!






