【发布时间】:2014-06-25 22:43:59
【问题描述】:
我在探测后将其范围缩小到 SDL_DisplayFormat。我在 Windows 机器上使用 msys 编译 g++ -o test.exe test.cpp -lmingw32 -lSDLmain -lSDL -lSDL2_image,然后运行可执行文件;然后echo $? 返回 3...
int main( int argc, char **args ) {
int status = SDL_Init( SDL_INIT_EVERYTHING );
if ( status == -1 ) return 4;
screen = SDL_SetVideoMode( W_WIDTH, W_HEIGHT, BPP, SDL_SWSURFACE );
if ( screen == NULL ) return 44;
SDL_Surface *loaded_surface = IMG_Load( "./res/figure.png" );
if ( loaded_surface == NULL ) return 444;
SDL_Surface *background = SDL_DisplayFormat( loaded_surface );
return 5;
if ( background == NULL ) return 4444;
SDL_FreeSurface( loaded_surface );
SDL_BlitSurface( background, NULL, screen, NULL );
SDL_Flip( screen );
SDL_Delay( 2000 );
return 0;
}
【问题讨论】:
-
当提供给
IMG_Load()的文件存在时,它在我的系统上运行良好。检查文件./res/figure.png是否存在。 -
是的,确实如此。可执行文件所在的目录包含一个名为 res/ 的目录,其中存在 figure.png...