How to enforce a user-defined aspect ratio?
I'm trying to find a callback or something similar that occurs when the user resizes the game window (in windowed mode) so that I can force the window to stretch in a way that it maintains their originally picked Aspect Ratio from settings. So if someone had picked a 16:9 resolution and tried to stretch the side of the window, the bottom would also stretch to end up with a 16:9 window.
Also, if someone could point me towards a way to set the viewport size from code (assuming "viewport" and "window" are the same thing?) to an arbitrary value, that'd be appreciated.
asked Mar 07 '16 at 11:53 PM in C++ Programming
I found what I was looking for in WindowsApplication.cpp's handler for the wm_sizing event. It can be controlled by calling the SetFixedWindowAspectRatio function from SlateApplicationBase.h.
answered Mar 11 '16 at 10:19 PM
You can set the aspect ratio of the camera component:
But that will introduce black bars rather than force-sizing the window.
As for setting the resolution:
Where the w means windowed. Can be replaced by f for fullscreen.
answered Mar 08 '16 at 02:01 AM
If you want to add some code to viewport override this class:
and set it in project configuration. You can definitly find size from there (without overriding), not sure about keeping ratio but there GetDesiredAspectRatio() in FViewport, not sure how to override it. So try searching around there
answered Mar 08 '16 at 12:18 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here