Errors with SDL

I have a problem. My SDL program isn't working right, so I want to debugged it. Unfortunately, the program crashes when it has an error. That means I can't look at the error messages when there's an error, so I can't do any debugging. I've tried using printf and cout and SYSTEM("PAUSE") and cin to stop pause it before it crashes. How do I fix this?

Best Regards,
CodeKing

Comments

  • post the source code


    ------
    nugent



  • Here's my code.
    image.cpp

    bool image::loadImage(char* filename) {
    SDL_Surface *temp;

    temp =IMG_Load(filename);
    if (temp == NULL) {
    printf("Unable to load bitmap: %s
    ", SDL_GetError());
    return false;
    }

    bitmap = SDL_DisplayFormat(temp);
    SDL_FreeSurface(temp);
    return true;
    }

    sprite.cpp

    bool sprite::loadFrame(short frame,char* filename) {
    if(!spriteFrames[frame].loadImage(filename)) //Load image
    return false; //Oops, something went wrong
    return true;
    }

    main.cpp

    if (!mario.loadFrame(0,"mario0.jpg"))
    printf("Could not load mario0.jpg");


    When I load the frame, the program crashes. I don't know why. Is there some setting I can turn off? My system is windows vista, if that helps.

    Best Regards,
    CodeKing

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories