[A5] Changing window flags
Matias Persson

Hey, how would I go by changing the window flags while the program is running?
Right now, the program is operating in fullscreen mode, but I want the user to be able to push F1 to switch between Windowed || Fullscreen mode.

I tried this, but it didn't seem to work;
al_set_new_display_flags(ALLEGRO_WINDOWED || ALLEGRO_FULLSCREEN);

1if(ev.type == ALLEGRO_EVENT_KEY_DOWN) 2{ 3 //handle key presses 4 switch(ev.keyboard.keycode) 5 { 6 case ALLEGRO_KEY_F1: 7 { 8 al_set_new_display_flags(ALLEGRO_WINDOWED); 9 } 10 break; 11 } 12}

Edgar Reynaldo

You need al_toggle_display_flag(display , ALLEGRO_FULLSCREEN_WINDOW , fullscreen = !fullscreen); Or you can destroy and recreate the display. But that means converting bitmaps to be compatible with the new display or reloading everything.

Matias Persson



Allegro 5.1 is supposed to do the bitmap conversion automatically for you, but with 5.0 you have to do it manually, using al_clone_bitmap. You don't need to do this when using the "fullscreen window" mode, though.

Thread #614575. Printed from Allegro.cc