   Help running Lazy Foo's SDL tutorials?
  Hey guys,I dont know if you're familiar with this, but I've been doing the Lazy Foo SDL tutorials. The first one went great, but after the second one where you get into the SDL_image stuff, none of the codes will work. A black screen just briefly flickers up and dissapears... I've followed all the steps on installing the extension libraries, but nothing will work... can anyone help?Oh, and Im using visual c++ 2008Thanks for the help, but I think the problem has to do with the extension library, becuase the tutorial the doesnt use it still works, but once I use that image file its all messed up...sure :)/*This source code copyrighted by Lazy Foo' Productions (2004-2009) and may notbe redestributed without written permission.*///The headers#include "SDL.h"#include "SDL_image.h"#include <string>//Screen attributesconst int SCREEN_WIDTH = 640;const int SCREEN_HEIGHT = 480;const int SCREEN_BPP = 32;//The surfacesSDL_Surface *image = NULL;SDL_Surface *screen = NULL;//The event structure that will be usedSDL_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 surface    SDL_FreeSurface( image );    //Quit SDL    SDL_Quit();}int main( int argc, char* args[] ){    //Make sure the program 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 event to handle   while( SDL_PollEvent( &event ) )   {  //If the user has Xed out the window  if( event.type == SDL_QUIT )  { //Quit the program quit = true;  }   }    }    //Free the surface and quit SDL    clean_up();    return 0;}well i do have to admit that I'm a beginner... so this is kinda emberassing but... where exactly is the executable?Ok, thanks for your help tho :)[Edited by - Chocolate on June 25, 2009 3:20:07 PM]
  Without seeing your code, I can't say for sure but I suspect the problem is your program does what it's suppose to and then encounters the return for main() and ends like it should. To stop it finishing so quickly I would recommend that you try adding a call to SDL_Delay() after your called to SDL_Flip(). SDL_Delay() doesn't return until a time specified in miliseconds has elapsed. For example, SDL_Flip(3000) would pause for 3 seconds. Lazyfoo's tutorial includes this so it's possible you just forgot or over looked it. :)So something like:if( SDL_Flip( screen ) == -1 ) {   return 1; } SDL_Flip(3000);If that still doesn't work, we'll need to see your code to be of more assistance.If you haven't already, you may want to download Lazyfoo's code and compare it to yours.Hope that helps.   ;Quote:Thanks for the help, but I think the problem has to do with the extension library, becuase the tutorial the doesnt use it still works, but once I use that image file its all messed up...Can you post the code please.   ;  The code you posted on first post is correct and should work. Do you have a .png file named "x" on the same folder as the executable? If it's mispelled or something, the window will open and exit almost instantly.   ;  I've looked through the code line by and could find nothing that could cause that issue. Like Litz, it compiles and runs fine for me. The only possibility that comes to mind is as Litz suggests, making sure the image is the same folder as the executable.[Edited by - prh99 on June 26, 2009 2:18:53 PM];  Did you run the program through the command line, or by just double clicking on it? Or running with Visual C++?If you ran it through the command line, were there any errors?It might be that there is no file named x.png.   