Hi guys i am trying to learn SDL and im following Tutorials. But i can never get the sample code to compile. Now i dont know if its something to do with the way i compile the file... I cant seem to find anything on that using google. Im using MinGW via the command line. Here is the sample code:
#include "SDL.h"
int main( int argc, char* argv[] )
{
/* initialize sdl*/
SDL_Init(SDL_INIT_VIDEO);
/*set the title bar*/
SDL_WM_SetCaption("SDL Test" , "SDL Test");
/*create window*/
SDL_Surface* screen = SDL_SetVideoMode(640, 480, 0, 0);
/* load bitmap to temp surface*/
SDL_Surface* temp = SDL_LoadBMP("Logo.bmp");
/*convert bitmap to display format*/
SDL_Surface* bg = SDL_DisplayFormat(temp);
/*free the temp surface*/
SDL_FreeSurface(temp);
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)
{
/*colse 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;
}
}
/*draw the background*/
SDL_BitSurface(bg, NULL, screen, NULL);
/*update the screen*/
SDL_UpdateRect(screen, 0, 0, 0, 0);
/*free background surface*/
SDL_FreeSurface(bg);
/*cleanup SDL*/
SDL_Quit();
return 0;
}
}
Along with the compilers output:
c:\docs\SDL>g++ sdltest.cpp
sdltest.cpp: In function 'int SDL_main(int, char***)';
sdltest.cpp: 66:40: error: 'SDL_BitSurface' was not declared in this scope
c:\docs\SDL