简体   繁体   English

Allegro 在尝试画线时抛出错误

[英]Allegro Throws errors when trying to draw lines

For some reason allegro (C++ Game Engine), throws errors when i try to run... So first this code works fine !由于某种原因,快板(C++ 游戏引擎)在我尝试运行时抛出错误......所以首先这段代码工作正常! :

#include <allegro5/allegro.h>
#include <allegro5/allegro_primitives.h>

int main(void)
{
    int width = 640, height = 480;
       ALLEGRO_DISPLAY *display = NULL;

    if (!al_init()) 
       return -1;


       display = al_create_display(width, height);


   if (!display) 
       return -1;


        al_flip_display();

        //al_draw_line(100, 100, width - 100, 100, al_map_rgb(255, 0, 0), 1);
        al_rest(3);


           al_destroy_display(display);
       return 0;
    }

But all the sudden when i try to uncomment that line above i get this "error".但是突然之间,当我尝试取消注释上面那行时,我收到了这个“错误”。 在此处输入图片说明

More Closer Up:更近距离:

在此处输入图片说明

As you can see above this is some type of assertion failling... Im Confused?!正如你在上面看到的,这是某种类型的断言失败......我很困惑?! Help would be appreciated!帮助将不胜感激!

Before you can use the primitives add-on you need to initialize it by calling al_init_primitives_addon .在您可以使用原语插件之前,您需要通过调用al_init_primitives_addon对其进行初始化。

#include <allegro5/allegro.h>
#include <allegro5/allegro_primitives.h>

int main(void)
{
    int width = 640, height = 480;
    ALLEGRO_DISPLAY *display = NULL;

    if (!al_init())
        return -1;


    display = al_create_display(width, height);

    if (!display)
        return -1;

    al_init_primitives_addon();

    if (!al_init_primitives_addon())
        return -1;

    al_draw_line(0, 50, 300, 100, al_map_rgb(255, 0, 4), 1.0f);

    al_flip_display();


    al_rest(13);


    al_shutdown_primitives_addon();

    al_destroy_display(display);
    return 0;
}

The full documentation can be found here: https://www.allegro.cc/manual/5/al_init_primitives_addon .完整文档可以在这里找到: https : //www.allegro.cc/manual/5/al_init_primitives_addon

Don't forget to call al_shutdown_primitives_addon when you're done.完成后不要忘记调用al_shutdown_primitives_addon

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

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