No ALLEGRO_EVENT_DISPLAY_RESIZE on fullscreen switch?
roger levy

In my event handler I respond to ALLEGRO_EVENT_DISPLAY_RESIZE events, but it seems that they don't fire when I call al_toggle_display_flag to toggle fullscreen via ALLEGRO_FULLSCREEN_WINDOW. Seems that that should event should be generated on fs toggle. Is this a bug?

In any case how should I get the current display dimensions on fullscreen toggle?


The way I do it is:

My Display class does this:

1 bool Display::toggleFullscreen( bool fullscreen ) 2 { 3 bool result = al_toggle_display_flag(context,ALLEGRO_FULLSCREEN_WINDOW,fullscreen); 4 if(result) 5 { 6 resizeSceneForFullscreen(getResolution().getX(),getResolution().getY()); 7 if(fullscreen) 8 Log::write("Display","Window is now Fullscreen"); 9 else 10 Log::write("Display","Window is now Windowed"); 11 } 12 //initContext(context); 13 return result; 14 15 } 16 17 void Display::resizeSceneForFullscreen(int w, int h) 18 { 19 if(m_sceneMessenger) 20 { 21 m_sceneMessenger->sendResizeMessage(w,h); 22 } 23 } 24 25 Vec2 Display::getResolution() const 26 { 27 return Vec2( 28 (float)al_get_display_width(context), 29 (float)al_get_display_height(context)); 30 }

So quite simply, I pump my own resize message in this case to the scene manager.

If you want more detail let me know.


But that makes sense, I woudl expect a display resize regardless on an actual change of resolution if toggling between window and fullscreen mode.

Is this not fired by design?

William Labbett

Fullscreen as oppose to windowed mode is a tricky business. My project went on hold for a year due to needing to handle it all properly.

Gideon Weems

Bah, it's not tricky. See the FAQ.


How do I switch between full-screen and windowed modes?

For full-screen, use ALLEGRO_FULLSCREEN_WINDOWED and scale the buffer with a transformation.[5] For windowed, use ALLEGRO_WINDOWED.

Thread #615037. Printed from