DaShwimp

Member
  • Content count

    8
  • Joined

  • Last visited

Community Reputation

108 Neutral

About DaShwimp

  • Rank
    Newbie
  1. TTF Problem

    Wow Im sorry xD I cant believe I didnt think of it before. Thank you! I downloaded your media and source for that tutorial and right there was the .ttf to put in xP Thanks again. Hopefully I wont need to post super often xP
  2. TTF Problem

    The SDL_ttf.dll and libfreetype-6.dll are in the same directory as the .exe., if those are the ones you're talking about. There is another zlib1.dll that came with ttf but Im using the one that came with SDL_image, if that matters. Thanks for the reply I love your tutorial so far!
  3. TTF Problem

    Hello again I now have another problem xP with my C++ and SDL. Im now learning to use the ttf library and Ive linked all the libraries together, and theirs no issues with the compiler trying to find the functions or anything, but when I try to load a font, the ttf_openfont command cant find "lazy.ttf" and returns null, so I end up with the message that the program returned 4, meaning the font failed to load. Any help as to why the program cant find the font? [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img] Thanks! Heres the source for it: [source lang="cpp"]//The headers #include "SDL/SDL.h" #include "SDL/SDL_image.h" #include "SDL/SDL_ttf.h" #include <string> //Screen settings const int SCREEN_WIDTH = 640; const int SCREEN_HEIGHT = 480; const int SCREEN_BPP = 32; //The surfaces SDL_Surface *background = NULL; SDL_Surface *message = NULL; SDL_Surface *screen = NULL; //The event structure SDL_Event event; //The font that's going to be used TTF_Font *font = NULL; //The color of the font SDL_Color textColor = { 255, 255, 255 }; SDL_Surface *load_image( std::string filename ) { //The image that's loaded SDL_Surface* loadedImage = NULL; //The optimized image that will be used SDL_Surface* optimizedImage = NULL; //Load the image loadedImage = IMG_Load( filename.c_str() ); //If the image loaded if( loadedImage != NULL ) { //Create an optimized image optimizedImage = SDL_DisplayFormat( loadedImage ); //Free the old image SDL_FreeSurface( loadedImage ); } return optimizedImage; } bool init() { //Initialize all SDL subsystems if( SDL_Init( SDL_INIT_EVERYTHING ) == -1 ) { return false; } //Set up the screen 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 false; } //Initialize SDL_ttf if( TTF_Init() == -1 ) { return false; } //Set the window caption SDL_WM_SetCaption( "TTF Test", NULL ); //If everything initialized fine return true; } bool load_files() { //Load the background image background = load_image( "background.png" ); //Open the font font = TTF_OpenFont( "lazy.ttf", 28 ); return true; } bool backgroundLoad() { //If there was a problem in loading the background if( background == NULL ) { return false; } else { return true; } } bool fontLoad() { //If there was an error in loading the font if( font == NULL ) { return false; } else { return true; } } void clean_up() { //Free the surfaces SDL_FreeSurface( background ); SDL_FreeSurface( message ); //Close the font that was used TTF_CloseFont( font ); //Quit SDL_ttf TTF_Quit(); //Quit SDL SDL_Quit(); } void apply_surface( int x, int y, SDL_Surface* source, SDL_Surface* destination ) { //Temporary rectangle to hold the offsets SDL_Rect offset; //Get the offsets offset.x = x; offset.y = y; //Blit the surface SDL_BlitSurface( source, NULL, destination, &offset ); } int main( int argc, char* args[] ) { bool quit = false; if( init() == false ) { return 1; } if( load_files() == false ) { return 2; } if( backgroundLoad() == false ) { return 3; } if( fontLoad() == false ) { return 4; } //Render the text message = TTF_RenderText_Solid( font, "The quick brown fox jumps over the lazy dog", textColor ); //If there was an error in rendering the text if( message == NULL ) { return 5; } //Apply the images to the screen apply_surface( 0, 0, background, screen ); apply_surface( 0, 150, message, screen ); //Update the screen if( SDL_Flip( screen ) == -1 ) { return 6; } while( quit == false ) { while( SDL_PollEvent ( &event ) ) { if( event.type == SDL_QUIT ) { quit == true; } } } //Clean up clean_up(); return 0; } [/source]
  4. Problem with SDL (Undefined Reference)

    Thanks so much for all the help [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img] Would you recommend any in particular? Like which one is easier for someone to pickup and go with? Im not too concerned with mobile though [img]http://public.gamedev.net//public/style_emoticons/default/tongue.png[/img] Edit: Toying around a bit, I found that the build error is coming in the load_files function, namely it is returning false no matter what. I had this before in another load_image instance and I just had to remake the file, but it isn't working here. Any tips? lolz xP Edit: Nevermind! Got it, I had the x.png in the debug folder, when it needed to be in the project folder! Thank you SO much!! You have no idea how awesome it is to have this working xD
  5. Problem with SDL (Undefined Reference)

    I know its not a capital i lolz xD bluehailex your solution seemed to work! Except now it just closes instantly with the message: "Process terminated with status 1 (0 minutes, 0 seconds)" So now I need to like look around and try to find out that problem! Thanks so much! If you can maybe offer some advice for the current problem or using SDL in general, thatd be great
  6. Problem with SDL (Undefined Reference)

    I downloaded the 3rd download under Windows Binary, SDL_image-devel-1.2.12-VC.zip as the tutorial instructed me to. Im using a 32bit compiler and made sure to use the x86. Thanks so much for the replies so far
  7. Problem with SDL (Undefined Reference)

    Thanks for the replies, here is the source code [source lang="cpp"]//The headers #include "SDL/SDL.h" #include "SDL/SDL_image.h" #include <string> //Screen attributes const int SCREEN_WIDTH = 640; const int SCREEN_HEIGHT = 480; const int SCREEN_BPP = 32; //The surfaces SDL_Surface *image = NULL; SDL_Surface *screen = NULL; //The even structure that will be used SDL_Event event; SDL_Surface *load_image( std::string filename ) { //The image that's loaded SDL_Surface* loadedImage = NULL; //The optimized image that will be used SDL_Surface* optimizedImage = NULL; //Load the image loadedImage = IMG_Load( filename.c_str() ); //If the image loaded 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 ) { //Temporary rectangle to hold the offsets SDL_Rect offset; //Get the offsets offset.x = x; offset.y = y; //Blit the surface SDL_BlitSurface( source, NULL, destination, &offset ); } bool init() { //Initialize all SDL subsystems if( SDL_Init( SDL_INIT_EVERYTHING ) == -1 ) { return false; } //Set up the screen 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 false; } //set the window caption SDL_WM_SetCaption( "Event test", NULL ); //If everything initialized fine return true; } bool load_files() { //Load the image image = load_image( "x.png" ); //If there was an error in loading the image if( image == NULL ) { return false; } //If everything loaded fine return true; } void clean_up() { //Free the image SDL_FreeSurface( image ); //Quit SDL SDL_Quit(); } int main( int argc, char* args[] ) { //Make sure the programs waits for a quit bool quit = false; //Initialize if( init() == false ) { return 1; } //Load the files if( load_files() == false ) { return 1; } //Apply the surface to the screen apply_surface( 0, 0, image, screen ); //Update the screen if( SDL_Flip( screen ) == -1 ) { return 1; } //While the user hasn't quit while( quit == false ) { //While there's an even to handle while( SDL_PollEvent( &event ) ) { //If the user has X'd out the window if( event.type == SDL_QUIT ) { //Quit the program quit = true; } } } //Free the surface and quit SDL clean_up(); return 0; } [/source] I tried putting -lSDL_image at the top and it didnt change anything :\
  8. Hi, Im relatively new to programming. I know quite a bit about C++ and want to try to make a game so I started doing Lazy Foo's SDL tutorial. Im using CodeBlocks 10.05 with GNU GCC compiler. I got to Tutorial 4 and now Im completely stuck. All that ever happens is I get the error "Undefined Reference to IMG_Load" obj\Debug\source3.o||In function `Z10load_imageSs':| C:\Users\Da Shwimpster\Documents\C++\Platformer\Platformer\source3.cpp|27|undefined reference to `IMG_Load'| ||=== Build finished: 1 errors, 0 warnings ===| My linker options are set up as: -lmingw32 -lSDLmain -lSDL_image -lSDL I have the SDL.dll with the project folder In the projects bin/Debug folder I have 6 .dll's and a .lib libjpeg-8.dll libpng15-15.dll libtiff-5.dll libwebp-2.dll SDL_image.dll zlib1.dll SDL_image.lib In the source files properties, I have Compile File, Link File, Debug, and Release all enabled, the SDL headers are included, and all the directories to SDL files and folders are all correct. I can attach the source file if it helps at all. Any help is really appreciated. I have been searching for days, hours on end for a solution and most posted solutions are changing the settings to something I already have set up. Thanks in advanced! [img]http://public.gamedev.net//public/style_emoticons/default/biggrin.png[/img]