快板5窗口无法关闭
Allegro5 window won't close
我在allegro中有一个窗口,当点击顶部的X按钮时,它应该会关闭。我有它工作所需的所有代码,但它不会。
要初始化显示器,我有这个:
display = al_create_display(dwidth, dheight);
if (!display){
error.message("Fatal Error", "ERROR:", "DISPLAY HAS FAILED TO BE CREATED");
}
要初始化事件队列,我有这样的:
ALLEGRO_EVENT_QUEUE *event_queue = NULL;
event_queue = al_create_event_queue();
if (!event_queue){
error.message("Fatal Error", "ERROR:", "EVENT QUEUE HAS FAILED TO BE CREATED");
}
al_register_event_source(event_queue, al_get_display_event_source(display));
为了响应输入并使用或关闭窗口进行渲染,我有这样的:
al_start_timer(tick);
while (true)
{
//handle input and timer
ALLEGRO_EVENT ev;
al_wait_for_event(event_queue, &ev);
if (ev.type = ALLEGRO_EVENT_TIMER){
redraw = true;
//put all fps dependant function here
}
else if (ev.type == ALLEGRO_EVENT_DISPLAY_CLOSE){
break;
}
if (redraw && al_is_event_queue_empty(event_queue)) {
//FPS independant functions go here
al_flip_display();
al_clear_to_color(al_map_rgb(255, 255, 255));
redraw = false;
}
}
我认为您需要更改行:
else if (ev.type == ALLEGRO_EVENT_KEY_DOWN){
至
else if (ev.type == ALLEGRO_EVENT_DISPLAY_CLOSE){
相关文章:
- 如何在Qt窗口小部件中使用QStringView(或QStringRef)
- 问:如何使用C++中的按钮从窗口打开窗口
- SDL 窗口不会弹出
- 在createdialog创建的窗口中捕获用于编辑控件的OnMouseMove消息
- 如何在cpp文件之间切换窗口?在Qt中
- QuadTree只在窗口的右上角绘制
- VS Code "command":"make"与终端窗口中的命令行"make"不同
- 如何在C++中找到active directory中禁用和锁定的窗口帐户
- 处理闪烁窗口事件
- 如何通过按下第三个窗口中的按钮,将QString从一个窗口获取到另一个窗口
- C++win32 API创建多个类似视口的窗口
- SFML RenderWindow打开窗口需要很长时间
- 如何将不同的可执行文件合并到一个窗口框架中进行编码?像浏览器一样
- 获取 SFML 窗口的 HWND 和高可用性?
- 如何获取 GLFW 窗口 ID?
- GLEW/GLUT:调用init并创建一个窗口后,取消初始化并重新初始化?
- 用于窗口的 HID 终端
- 快板获取当前窗口大小
- 快板5窗口无法关闭
- 快板浏览窗口