Allegro 5 crashes on calling al_clear_to_color(ALLEGRO_COLOR)

不羁的心 提交于 2019-12-04 03:01:39

问题


I'm starting at Allegro 5, but soon I got stuck in the second hello-world-like program I'm coding. After some debugging, I concluded that the program crashes when it calls the function al_clear_to_color(ALLEGRO_COLOR). I've tried linking allegro statically and dynamically, but the problem still remains. I'm completely lost.

Here is the code:

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

int main() {
    ALLEGRO_DISPLAY         *display;
    ALLEGRO_KEYBOARD_STATE  kbState;

    if(!al_init())
        return 0;

    if(!al_install_keyboard())
        return 0;

    display = al_create_display(800, 600);
    if(!display)
        return 0;

    do {
        al_get_keyboard_state(&kbState);

        al_clear_to_color(al_map_rgb(255, 255, 255));

        al_flip_display();

        al_rest(0.5);
    } while(!al_key_down(&kbState, ALLEGRO_KEY_ESCAPE));

    al_destroy_display(display);

    return 0;
}

edit:

Substituting the line

al_clear_to_color(al_map_rgb(255, 255, 255));

for the line

al_clear_to_color(tempClearColor);

declaring

ALLEGRO_COLOR tempClearColor = al_map_rgb(255, 255, 255);

before the loop starts, it does work, but crashes when the function

al_destroy_display(display);

is called.

The debugger returns the messages:

Error while reading shared library symbols for C:\Program Files (x86)\CodeBlocks\MinGW\bin\libstdc++-6.dll:
Program received signal SIGSEGV, Segmentation fault.

来源:https://stackoverflow.com/questions/14901930/allegro-5-crashes-on-calling-al-clear-to-colorallegro-color

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!