SDL - 不加载图像
这是我第一次尝试将文件分成 4 个文件夹:图像、源、声音、标题。我的问题是:我试图从源文件夹中的文件调用的图像文件夹中加载一个简单的 BMP。这是我的代码:
#include <SDL/SDL.h> int main(int argc, char *argv[]) { SDL_Surface *hello = NULL; SDL_Surface *screen = NULL; screen = SDL_SetVideoMode(640, 480, 32, SDL_SWSURFACE); hello = SDL_LoadBMP("../images/hello.bmp"); SDL_BlitSurface(hello, NULL, screen, NULL); SDL_Flip(screen); SDL_Delay(2000); SDL_FreeSurface(hello); SDL_Quit(); return 0; }
显然,调用“../images/hello.bmp”不起作用。
This is the first time I'm trying out separating my files into 4 folders: images, source, sounds, headers. My problem is: I'm trying to load a trivial BMP from the images folder that has been called on by a file in the source folder. Here is my code:
#include <SDL/SDL.h> int main(int argc, char *argv[]) { SDL_Surface *hello = NULL; SDL_Surface *screen = NULL; screen = SDL_SetVideoMode(640, 480, 32, SDL_SWSURFACE); hello = SDL_LoadBMP("../images/hello.bmp"); SDL_BlitSurface(hello, NULL, screen, NULL); SDL_Flip(screen); SDL_Delay(2000); SDL_FreeSurface(hello); SDL_Quit(); return 0; }
Apparently, the call "../images/hello.bmp" isn't working.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为您忘记调用
SDL_Init()
。I think you forgot to call
SDL_Init()
.