Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » No ALLEGRO_EVENT_DISPLAY_RESIZE on fullscreen switch?

This thread is locked; no one can reply to it. rss feed Print
No ALLEGRO_EVENT_DISPLAY_RESIZE on fullscreen switch?
roger levy
Member #2,513
July 2002

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?

jmasterx
Member #11,410
October 2009

The way I do it is:

My Display class does this:

#SelectExpand
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.

pkrcel
Member #14,001
February 2012

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?

It is unlikely that Google shares your distaste for capitalism. - Derezo
If one had the eternity of time, one would do things later. - Johan Halmén

William Labbett
Member #4,486
March 2004
avatar

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
Member #3,925
October 2003
avatar

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

Quote:

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.

Go to: