Cannot exit fullscreen with ALLEGRO_OPENGL flag

I'm toggling full-screen for a display using the ALLEGRO_FULLSCREEN_WINDOW flag (using the F11 key, as seen in the example below). The display was created with the ALLEGRO_OPENGL flag. I'm running Windows 8.1.

Setting the flag to true works as expected; the display is expanded to fill the entire screen. However, when setting it to false, the display still appears to fill the screen.

What's strange about it is that if I move the cursor around, it appears that the window really has gone back to its original size, and is located in the lower left corner of the screen (I can see the cursor change to the resize icon as I hover over the edges of where the window would be). It's just invisible, because the content of the display is still taking up the entire screen. (I hope that makes sense.)

The only way to get out of it is to Press Ctrl+Alt+Del. When returning to Windows, the contents of the display no longer take up the entire screen and window is now visible.

I managed to narrow it down to these things:

  • If I use a Direct3D display (i.e., don't use the ALLEGRO_OPENGL flag), it's fine.

  • If I don't use al_clear_to_color, it's fine.

Here's an example to demonstrate:

1#include <allegro5/allegro.h> 2 3int main() { 4 5 al_init(); 6 al_install_keyboard(); 7 8 // Set display flags and create the display. 9 al_set_new_display_flags(ALLEGRO_OPENGL | ALLEGRO_RESIZABLE); 10 ALLEGRO_DISPLAY* display = al_create_display(640, 480); 11 12 // Create event queue and register event sources. 13 ALLEGRO_EVENT_QUEUE* event_queue = al_create_event_queue(); 14 al_register_event_source(event_queue, al_get_display_event_source(display)); 15 ALLEGRO_TIMER* timer = al_create_timer(1.0f / 60.0f); 16 al_register_event_source(event_queue, al_get_timer_event_source(timer)); 17 al_start_timer(timer); 18 al_register_event_source(event_queue, al_get_keyboard_event_source()); 19 20 bool fs = false; 21 while (true) { 22 23 ALLEGRO_EVENT ev; 24 al_wait_for_event(event_queue, &ev); 25 26 switch (ev.type) { 27 28 case ALLEGRO_EVENT_KEY_DOWN: 29 if (ev.keyboard.keycode == ALLEGRO_KEY_F11) { 30 fs = !fs; 31 al_toggle_display_flag(display, ALLEGRO_FULLSCREEN_WINDOW, fs); 32 } 33 break; 34 35 case ALLEGRO_EVENT_DISPLAY_RESIZE: 36 al_acknowledge_resize(display); 37 break; 38 39 case ALLEGRO_EVENT_TIMER: 40 break; 41 42 } 43 44 if (al_is_event_queue_empty(event_queue)) { 45 al_clear_to_color(al_map_rgb(0, 0, 0)); 46 al_flip_display(); 47 } 48 49 } 50 51}


What Allegro version is this?


Thanks for the response!

It's version 5.2.2.


Can't reproduce this in Win7, but I'll try it in Win 8 and 10 tomorrow. Not sure what's up yet.


Thank you.

I tested it out on a separate Windows 8.1 machine, and the behavior is slightly different this time. Instead of going full-screen, the window instead goes borderless and then jumps to the top-left corner of the screen. Pressing F11 again will put it into full-screen mode, and pressing it again will take it back out, except the window remains at the same size as the monitor (it just adds a border). From thereon out it will switch in between the two without jumping to the top-left like it does on the first key-press.

Maybe my development environment across both machines is acting up for some reason. I'm using VS2015 on both, with Visual C++ 14.0. I haven't tested other compilers just yet.

Another thing I tried was using the same executable, compiled on one machine, across multiple different machines. Regardless of which one it was compiled on, the same respective problem occurs for each Windows 8.1 machine (that is, they all exhibit the problematic behavior with their own consistent quirks). So, this leads me to believe it's not a compiler issue.

Also, I tested that same executable on a Windows 10 machine. The problem did not occur this time, so it seems restricted to Windows 8.1.


This could be related to, where Intel GPUs were blamed. What GPUs do you have?

EDIT: I definitely had some trouble exiting the fullscreen mode in Win 8, although I couldn't reproduce the issue exactly. Moreover, after I did the Ctrl-Alt-Delete once, it started functioning fine.


The first machine uses an Intel CPU with integrated graphics (i5-4210U), so that could definitely be related.

The second uses an Intel CPU (i7-4770), but with a dedicated Nvidia graphics card (GeForce GTX 760).

The third, on which the problem oddly didn't occur, is also using an Intel CPU (i5-6200U) with a dedicated Nvidia graphics card (GeForce 940MX).

Maybe it's an issue with Intel CPUs on Windows 8 specifically? Not sure.

Thread #616750. Printed from