SDL - Process terminated with status 3 (0 minutes, 0 seconds)



  • Warum geht der Code hier nicht?
    Er wird zwar ausgeführt, aber das Fenster blitzt nur ganz kurz auf, und dann steht in meiner IDE "SDL - Process terminated with status 3 (0 minutes, 0 seconds)"...???

    #include <SDL/SDL.h>
    #include <string>
    using namespace std;
    
    const long screen_WIDTH  = 640;
    const long screen_HEIGHT = 480;
    const long screen_BPP   = 32;
    
    SDL_Surface *background  = NULL;
    SDL_Surface *message     = NULL;
    SDL_Surface *screen      = NULL;
    
    SDL_Surface *load_image(std::string filename);
    void apply_surface(int x, int y, SDL_Surface *source, SDL_Surface *destination);
    
    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(screen = NULL)
        {
            return 1;
        }
    
        SDL_WM_SetCaption("Hello World", NULL);
    
        message    = load_image("hello_world.bmp");
        background = load_image("background.bmp");
        apply_surface(0,0,background,screen);
    
        if(SDL_Flip(screen) == -1)
        {
            return 1;
        }
        SDL_Delay(2000);
    
        SDL_FreeSurface(message);
        SDL_FreeSurface(background);
    
        SDL_Quit();
    
        return 0;
    }
    
    SDL_Surface *load_image(std::string filename)
    {
        SDL_Surface *LoadedImage    = NULL;
        SDL_Surface *OptimizedImage = NULL;
    
        LoadedImage = SDL_LoadBMP(filename.c_str());
    
        if(LoadedImage != NULL)
        {
            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);
    }
    

    Kann mir jemand helfen?
    Die beiden Bilder sind 100% im Verzeichnis, also daran kanns nicht liegen.

    MfG
    Stromberg



  • if(screen = NULL)
    {
        return 1;
    }
    

  • Mod

    com'on, wieso benutzt du nicht einfach einen debugger, das ist wirklich nichts was ein forum loesen muesste. ohne debugger wirst du eh nichts ordentliches zustande bringen koennen --> widerstand ist zwecklos.


Anmelden zum Antworten