提问者:小点点

我一直在尝试将Png图片加载到SDL[已关闭]


我一直在尝试加载png图片,但在使用SDL_ConvertSurface(loadedSurface,gScreenSurface->format,0)时,它往往会给我exec_bad_access我做错了什么?

Tures

完整代码:https://gist.github.com/mosh98/113f9d4706e5936c5f1fc14b3e458234


共1个答案

匿名用户

看起来您没有初始化SDL_IMAGE。 您需要调用IMG_Init()并向它传递标志,使SDL_Image知道您正在使用PNG文件。

Lazy Foo Productions有很好的SDL2教程。。。 请在此处参考用于PNG图像加载的文件:https://lazyfoo.net/tutorials/sdl/06_extension_libraries_and_loading_other_image_formats/index2.php