Is there a way to perfectly center a windowed app to the user's resolution?

I can't seem to find any way to find the center of the screen width and height through the config.
I'd imagine it looks something like this, where "Center?" is the correct way to get the width/2 and height/2 of the screen's reported resolution.

[Display]
ScreenPosition = (Center?, Center?)

If it can't be done through the config, then how would it be done through my source file, in c++?

Tagged:

Comments

  • Hi GaryM, welcome to the forum. I was going to direct you to the display config section on the wiki but it's currently down. Dreadful timing. You can find all the settings here: https://github.com/orx/orx/blob/master/code/bin/SettingsTemplate.ini

    Or in the SettingTemplate.ini in your repo.

    I think you are right that your game will display in the top left if using full window borderless mode.

    Change your settings to use proper full screen mode first to get your going. I'll be interested to solve your issue and I'll put an example in the wiki once it's back up.

  • The wiki is back up :)

    The thing is that fullscreen and borderless fullscreen work fine, but let's say the resolution of my game is something like 1280 x 720, just for example. You would have the windowed mode, but you could maximize it to fullscreen as well. In windowed mode, it just spawns the window at the very top left unless you use magic numbers to position it.

    I tried looking through the api documentation and examples, and searching forum posts, but I wasn't able to find the specific thing I'm looking for.

    Thanks!

  • I was playing around with this. And yep in window mode, it displays my small window to the top left, but not to the extreme top left.

    I would think the only way to do this would be to move the window to the (screen width position / 2) - window width / 2.

    But I can't see anything in the Commands or API to move the position of the current window.

    @iarwain should be able to help though.

  • edited August 24

    When you say screen size, I believe you mean the monitor's current resolution, is that correct?

    If so, this information isn't exposed in config at the moment, however I can add it if you need it.

    For the time being, you'd need to call orxDisplay_GetVideoMode with orxU32_UNDEFINED an the index parameter. You'll then get the actual video mode/resolution of the current monitor (aka desktop mode):

    /** Gets an available video mode
     * @param[in]   _u32Index                             Video mode index, pass _u32Index < orxDisplay_GetVideoModeCount() for an available listed mode, orxU32_UNDEFINED for the the default (desktop) mode and any other value for current mode
     * @param[out]  _pstVideoMode                         Storage for the video mode
     * @return orxDISPLAY_VIDEO_MODE / orxNULL if invalid
     */
    extern orxDLLAPI orxDISPLAY_VIDEO_MODE *orxFASTCALL   orxDisplay_GetVideoMode(orxU32 _u32Index, orxDISPLAY_VIDEO_MODE *_pstVideoMode);
    
Sign In or Register to comment.