我正在 Allegro 5.0.8 中开发游戏,一切进展顺利,直到我尝试在 Linux(Mint 14)上编译并运行它……所以我做了 sime 测试;
#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;
打印图像的确切绝对路径。
我究竟做错了什么?