Download

Viewport resolution vs Screen Resolution

I noticed an issue with positioning widgets in windowed mode when using the SCanvas widget. I want to place a widget in the center of the screen, but it’s appearing left of center. after some experimentation, it seems the reported viewport size is not what’s being used to render the window. (Problem occurs only in windowed mode. It works fine in fullscreen mode.) The widget is being positioned as if the window resolution has the same resolution as the desktop. For example, if the game window is 1280x800 and the desktop is 1920x1080, the window acts as if it too were 1920x1080. But GetViewportSize reports the window as 1280x1080. This makes centering stuff a bit tricky in windowed mode. So the question is how do I get the virtual resolution being used by Slate to position widgets?

Maybe related? This is done in the code for determining when the viewport and window are not the same size:



        // If the user has configured a resolution quality we need to multiply
        // the pixels by the resolution quality to arrive at the true position in
        // the viewport, as the rendered image will be stretched to fill whatever
        // size the viewport is at.
        Scalability::FQualityLevels ScalabilityQuality = Scalability::GetQualityLevels();
        float QualityScale = ( ScalabilityQuality.ResolutionQuality / 100.0f );
        player_pos = player_pos / QualityScale;