🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Handling window resizing (without cycles)

Started by
0 comments, last by Jman2 4 years, 3 months ago

Hello,

My window code always seems to have a cyclic event issue which requires hacks to keep a consistent sync with Window and GraphicsDevice. Essentially when the user resizing (drags) the window you generate an event, then process it in the queue (Syphoned like SFML in my case). In one solution I had an XNA like Graphics Manager that was called to change the resolution of the device to reflect the window. However if the user changes the resolution using the GraphicsManager directly it has to trigger the window to resize if its in windowed mode. As should be easy to see… this triggers the window to push a new resize event that tells the graphics manager to resize again. I know I can easily ignore this message by doing a check (if res != currentRes) but this clearly breaks the rule “don’t generate events in the place you process them”.

I could go the route of Inheriting Window into a RenverWindow which stores the device and contains a virtual OnResize function that gets called internally to sort the device and push the resize event for the benefit of the rest of the engine (current implementation). But this convolutes the interface with all the windows code and having to try add a separate set resolution function to allow Borderless Fullscreen sizes to be any out of the list of supported sizes etc.

I have seen the suggestion that we can leave the Window and device completely in sync and use a Virtual backbuffer to render everything into essentially as a Dynamic Resolution Render target which means we can set the Borderless Fullscreen to any resolution we want. But again in windowed mode we would need to inform the window the size changed which would then re-inform us the size changed back…

A lot of games seem to get this wrong, wargroove and orcs must die for instance don’t allow resizable windows and combine everything together. Others in borderless Fullscreen max the resolution to the screen and don’t allow you to change it which means force rendering at 4k for some users (the Dynamic Render target would fix this).

Will be interesting to hear other peoples experiences with managing this.

This topic is closed to new replies.

Advertisement