【问题标题】:Why is SDL_DisplayFormat crashing?为什么 SDL_DisplayFormat 会崩溃?
【发布时间】: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...

标签: windows crash mingw sdl


【解决方案1】:

如此处所述:can i use SDL-1.2.15 with SDL2-image extension?

SDL2_ImageSDL 1.x不兼容,您应该升级到SDL 2

【讨论】:

    猜你喜欢
    • 2012-04-20
    • 1970-01-01
    • 2013-01-31
    • 2014-05-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-06-11
    • 2011-04-17
    相关资源
    最近更新 更多