I need to break a while loop when the use clicks the close button on the window, but I don't know what to check for. I'm using allegro to run the GUI.
            Asked
            
        
        
            Active
            
        
            Viewed 1,446 times
        
    6
            
            
        - 
                    9What platform/GUI library are you talking about? – Oliver Charlesworth Jun 16 '11 at 00:26
- 
                    It's very important to give more information or the question will be closed as 'Not a real question' – Preet Sangha Jun 16 '11 at 00:28
- 
                    @Oli: I'm using allegro. – John Stimac Jun 16 '11 at 00:30
- 
                    Do you use such: http://wiki.allegro.cc/index.php?title=Allegro_-_A_Game_Programming_Library ? – George Gaál Jun 16 '11 at 00:40
1 Answers
1
            If using Allegro 4: set_close_button_callback()
volatile int hit_closed = 0;
void close_button_proc()
{
  hit_closed = 1;
}
// later after creating the display:
set_close_button_callback(close_button_proc);
while (!hit_closed)
{
}
With Allegro 5, it's more like:
al_register_event_source(queue, al_get_display_event_source(display));
// in your event loop:
if (event.type == ALLEGRO_EVENT_DISPLAY_CLOSE) {
}
See the manual for all the details.
 
    
    
        Matthew
        
- 47,584
- 11
- 86
- 98
 
    