0
我在Allegro 5.0.8中开发一款游戏,并且一切进展顺利,直到我尝试编译它并在Linux(Mint 14)上运行它。所以我做了测验;C++ Allegro 5.0.8 - 在Linux上返回NULL的al_load_bitmap()
#include <allegro5/allegro.h>
#include <allegro5/allegro_image.h>
#include <iostream>
int main(void)
{
al_init();
ALLEGRO_DISPLAY *screen = al_create_display(800, 600);
al_init_image_addon();
ALLEGRO_PATH *path = al_get_standard_path(ALLEGRO_RESOURCES_PATH);
al_set_path_filename(path, "players.png");
ALLEGRO_BITMAP *img = al_load_bitmap(al_path_cstr(path, '/'));
if (img == NULL)
std::cout << al_path_cstr(path, '/') << std::endl;
al_draw_bitmap(img, 0, 0, 0);
al_flip_display();
while (true){}
return 0;
}
这个例子编译就好了,但行
ALLEGRO_BITMAP *img = al_load_bitmap(al_path_cstr(path, '/'));
回报NULL。另一方面,行
std::cout << al_path_cstr(path, '/') << std::endl;
打印图像的确切绝对路径。
我在做什么错了?
通过外部库支持PNG文件,例如, 'libpng'安装? –
我有libpng12-0 ..但不是libpng12-dev ...我应该安装吗? – Sylar
是的,你可能也需要这个,并且用'libpng'(即'-lpng')连接。 –