Inconsistent behaviour from SDL_BlitSurface

Posted by bardes on Stack Overflow See other posts from Stack Overflow or by bardes
Published on 2012-05-07T00:41:40Z Indexed on 2012/07/03 3:16 UTC
Read the original article Hit count: 101

Filed under:
|
|

Here is an example code:

#include <SDL/SDL.h>
#include <SDL/SDL_image.h>
#include <stdio.h>

int main()
{
    if(SDL_Init(SDL_INIT_EVERYTHING) == -1)
    {
        printf("SDL ERROR: %s", SDL_GetError());
        return 1;
    }

    SDL_Surface *screen;
    screen = SDL_SetVideoMode(128, 128, 32, SDL_SWSURFACE);

    SDL_Surface *img;
    img = IMG_Load("./debug.png");

    SDL_BlitSurface(img, NULL, screen, NULL);
    SDL_Flip(screen);

    SDL_Delay(1000);

    SDL_FreeSurface(img);
    SDL_Quit();
    return 0;
}

It compiles fine, but when I run it sometimes it works and most times only part of the image is displayed. I really can't imagine what's causing that...

EDIT: This is the image I'm using to test the program: http://img140.imageshack.us/img140/3858/debugi.png

© Stack Overflow or respective owner

Related posts about c

    Related posts about sdl