简体   繁体   English

C ++ Allegro 5.0.8-al_load_bitmap()在Linux上返回NULL

[英]C++ Allegro 5.0.8 - al_load_bitmap() returning NULL on Linux

I'm developing a game in Allegro 5.0.8, and everything was going well, until i tried compiling it and running it on Linux (Mint 14)...so i did sime tests; 我正在用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;
}

this example compiles just fine, but the line 这个例子编译很好,但是行

ALLEGRO_BITMAP *img = al_load_bitmap(al_path_cstr(path, '/'));

returns NULL . 返回NULL On the other hand, the line 另一方面,线

std::cout << al_path_cstr(path, '/') << std::endl;

prints the exact absolute path of the image. 打印图像的确切绝对路径。

What am i doing wrong? 我究竟做错了什么?

i have libpng12-0 ..but not libpng12-dev...should i install that too?? 我有libpng12-0 ..但没有libpng12-dev ...我也应该安装吗?

After you install libpng12-dev, you'll need to rebuild Allegro. 安装libpng12-dev后,需要重建Allegro。 The output of cmake tells you whether or not PNG is supported. cmake的输出告诉您是否支持PNG。

Once you rebuild Allegro with PNG support, it will work assuming your PNG file is not too big to load onto your video card. 一旦重建了具有PNG支持的Allegro,它将在您的PNG文件不太大而无法加载到视频卡的情况下起作用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM