Bru*_*cia 9 c c++ runtime-error allegro allegro5
我是从Allegro 5开始的,但很快我就陷入了第二个类似hello-world的程序中.经过一些调试后,我得出结论,程序在调用函数时崩溃了al_clear_to_color(ALLEGRO_COLOR).我已尝试静态和动态地链接allegro,但问题仍然存在.我完全迷失了.
这是代码:
#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;
}
Run Code Online (Sandbox Code Playgroud)
编辑:
替换线
al_clear_to_color(al_map_rgb(255, 255, 255));
Run Code Online (Sandbox Code Playgroud)
为线
al_clear_to_color(tempClearColor);
Run Code Online (Sandbox Code Playgroud)
声明
ALLEGRO_COLOR tempClearColor = al_map_rgb(255, 255, 255);
Run Code Online (Sandbox Code Playgroud)
在循环开始之前,它确实有效,但在函数崩溃时
al_destroy_display(display);
Run Code Online (Sandbox Code Playgroud)
叫做.
调试器返回消息:
读取C:\ Program Files(x86)\ CodeBlocks\MinGW\bin\libstdc ++ - 6.dll的共享库符号时出错:
编程接收信号SIGSEGV,分段错误.
| 归档时间: |
|
| 查看次数: |
1249 次 |
| 最近记录: |