开发者

SDL - not loading an image

开发者 https://www.devze.com 2023-03-12 08:15 出处:网络
This is the first time I\'m trying out separating my files into 4 folders: images, source, sounds, headers. My problem is: I\'m trying to load a trivial BMP from the images folder that has been called

This is the first time I'm trying out separating my files into 4 folders: images, source, sounds, headers. My problem is: I'm trying to load a trivial BMP from the images folder that has been called on by a file in the source folder. Here is my code:

#include <SDL/SDL.h>

int main(int argc, char *argv[])
{
    SDL_Surface *hello = NULL;
    SDL_Surface *screen = NULL;

    screen = SDL_SetVideoMode(640, 480, 32, SDL_SWSURFACE);
    hello = SDL_LoadBMP("../images/hello.bmp");

    SDL_BlitSurface(hello, NULL, screen, NULL);

    SDL_Flip(screen);

    SDL_Delay(2000);

    SDL_FreeSurface(hello);

    SDL_Quit();

    return 0;   

}

Apparently, the c开发者_高级运维all "../images/hello.bmp" isn't working.


I think you forgot to call SDL_Init().

0

精彩评论

暂无评论...
验证码 换一张
取 消