• Content count

  • Joined

  • Last visited

Community Reputation

108 Neutral

About Luffi45

  • Rank
  1. SDL Error Help

    I have fixed my problem, my compiler settings were incorrect. Now, I have anoher problem. Here is my code: #include <sdl.h> #include <string.h> const int SCREEN_WIDTH = 640; const int SCREEN_HEIGHT = 480; const int SCREEN_BPP = 32; SDL_Surface *message = NULL; SDL_Surface *background = NULL; SDL_Surface *screen = NULL; SDL_Surface *load_image( std::string filename){ //Temporary storage for the image that's loaded SDL_Surface* loadedImage = NULL; //The optimized image that will be used SDL_Surface* optimizedImage = NULL; //Load the image loadedImage = SDL_LoadBMP( filename.c_str() ); //If nothing went wrong in loading the image if( loadedImage != NULL ) { //Create an optimized image optimizedImage = SDL_DisplayFormat( loadedImage ); //Free the old image SDL_FreeSurface( loadedImage ); } //Return the optimized image return optimizedImage; } void apply_surface( int x, int y, SDL_Surface* source, SDL_Surface* destination ) { //Make a temporary rectangle to hold the offsets SDL_Rect offset; //Give the offsets to the rectangle offset.x = x; offset.y = y; SDL_BlitSurface( source, NULL, destination, &offset ); } int main( int argc, char* args[] ) { if( SDL_Init( SDL_INIT_EVERYTHING ) == -1 ) { return 1; } screen = SDL_SetVideoMode( SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP, SDL_SWSURFACE ); //If there was an error in setting up the screen if( screen == NULL ) { return 1; } SDL_WM_SetCaption( "Riku!", NULL ); message = load_image( "riku.bmp" ); background = load_image( "abc.bmp" ); //Apply the background to the screen apply_surface( 0, 0, background, screen ); apply_surface( 320, 0, background, screen ); apply_surface( 0, 240, background, screen ); apply_surface( 320, 240, background, screen ); apply_surface( 180, 140, message, screen ); if( SDL_Flip( screen ) == -1 ) { return 1; } SDL_Delay( 2000 ); } With this code, rather than applying 5 images to the screen, it simply places one of the riku.bmp images in the top corner. Can someone please help me with this?
  2. I have been trying to get started with SDL, I have set up my code and can't seem to find out what's wrong. Here is my source code: #include <stdlib.h> #include <sdl.h> #include <sdl_video.h> int main( int argc, char* args[] ) { //The images SDL_Surface* hello = NULL; SDL_Surface* screen = NULL; SDL_Init(SDL_INIT_VIDEO); screen = SDL_SetVideoMode(640,480,16, SDL_HWSURFACE|SDL_DOUBLEBUF); hello= SDL_LoadBMP("riku.bmp"); SDL_BlitSurface(hello,NULL,screen,NULL); SDL_Flip(screen); SDL_Delay(2000); SDL_FreeSurface(hello); SDL_Quit(); return 0; } The errors I get are: \mingw\lib\libSDLmain.a(SDL_win32_main.o):SDL_win32_main.c|| undefined reference to `SDL_strlcpy'| \mingw\lib\libSDLmain.a(SDL_win32_main.o):SDL_win32_main.c|| undefined reference to `SDL_strlcat'| \mingw\lib\libSDLmain.a(SDL_win32_main.o):SDL_win32_main.c|| undefined reference to `SDL_strlcpy'| \mingw\lib\libSDLmain.a(SDL_win32_main.o):SDL_win32_main.c|| undefined reference to `SDL_strlcat'| \mingw\lib\libSDLmain.a(SDL_win32_main.o):SDL_win32_main.c|| undefined reference to `SDL_strlcpy'| \mingw\lib\libSDLmain.a(SDL_win32_main.o):SDL_win32_main.c|| undefined reference to `SDL_GetError'| \mingw\lib\libSDLmain.a(SDL_win32_main.o):SDL_win32_main.c|| undefined reference to `SDL_SetModuleHandle'| \mingw\lib\libSDLmain.a(SDL_win32_main.o):SDL_win32_main.c|| undefined reference to `SDL_getenv'| \mingw\lib\libSDLmain.a(SDL_win32_main.o):SDL_win32_main.c|| undefined reference to `SDL_strlcpy'| ||=== Build finished: 9 errors, 0 warnings ===| I don't know what is wrong with the code, could someone please help me? I am using the latest versions of SDL and mingw, I have mingw32, SDL, and SDLmain libraries linked, and I am using the code::blocks IDE.