我正在尝试与 SDL 一起起步。SDL 本身工作正常,我得到了基本的 Hello World 设置。但是,尝试使用 SDL_image 让我非常头疼。我当前的代码(如下)在第 17 行给出了错误“Img_Load”未在此范围内声明。
- 我在 Code::Blocks 中的链接器设置如下所示:“-lmingw32 -lSDLmain -lSDL -lSDL_image”
- 搜索目录已正确设置
所需的 DLL 位于带有 EXE 的文件夹中。
include iostream include fstream include "SDL/SDL.h" include "SDL_image.h" using namespace std; const int SCREEN_WIDTH = 600; const int SCREEN_HEIGHT = 600; int main(int argc, char *argv[]){ SDL_Init(SDL_INIT_EVERYTHING); SDL_Surface* hello = NULL; SDL_Surface* screen = NULL; screen = SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, 32, SDL_SWSURFACE); hello = Img_Load("img\\hello world.png"); if(!hello) //check that the load worked cout<<"error"; SDL_BlitSurface(hello, NULL, screen, NULL); //draw image SDL_Flip(screen); SDL_Delay(2000); SDL_FreeSurface(hello); //closing down SDL_Quit(); return 0; }
任何和所有的帮助将不胜感激!