我使用IMG_Load()来加载PNG文件,但它根本无法正常工作.loadedImage = IMG_Load(filename.c_str()); 在这句话之后,loadedImage仍为NULL,没有发生错误.PS:我使用的是VS C++ 2008,png文件位于develop文件夹中.这是我的代码:(这正是Lazy Foo的样子)
//The headers
#include "SDL.h"
#include "SDL_image.h"
#include <string>
#pragma comment( linker, "/subsystem:\"windows\" /entry:\"mainCRTStartup\"" )
//Screen attributes
const int SCREEN_WIDTH = 640;
const int SCREEN_HEIGHT = 480;
const int SCREEN_BPP = 32;
//The surfaces
SDL_Surface *image = NULL;
SDL_Surface *screen = NULL;
SDL_Surface *load_image( std::string filename )
{
//The image that's loaded
SDL_Surface* loadedImage = NULL;
//The optimized image that will be used
SDL_Surface* optimizedImage = NULL;
//Load the image using SDL_image
loadedImage = …Run Code Online (Sandbox Code Playgroud) sdl-image ×1