这是Allegro5 教程中的一个示例:(要查看原始示例,请点击链接,出于说明目的,我对其进行了一些简化。
#include <allegro5/allegro.h>
int main(int argc, char **argv)
{
ALLEGRO_DISPLAY *display = NULL;
ALLEGRO_EVENT_QUEUE *event_queue = NULL;
al_init()
display = al_create_display(640, 480);
event_queue = al_create_event_queue();
al_register_event_source(event_queue, al_get_display_event_source(display));
al_clear_to_color(al_map_rgb(0,0,0));
al_flip_display();
while(1)
{
ALLEGRO_EVENT ev;
ALLEGRO_TIMEOUT timeout;
al_init_timeout(&timeout, 0.06);
bool get_event = al_wait_for_event_until(event_queue, &ev, &timeout);
//-->// if(get_event && ev.type == ALLEGRO_EVENT_DISPLAY_CLOSE) {
//-->// break;
//-->// }
al_clear_to_color(al_map_rgb(0,0,0));
al_flip_display();
}
al_destroy_display(display);
al_destroy_event_queue(event_queue);
return 0;
}
如果我不手动检查ALLEGRO_EVENT_DISPLAY_CLOSE
,则无法关闭窗口或终止程序(无需通过任务管理器终止进程)。我明白这一点。但在这种情况下,如果没有我手动处理,我不明白最小化按钮是如何工作的。有人可以解释一下吗?