Archive 17/01/2023.

Correct way to set full screen

mrchrissross

Hi everyone,

I’d just like to know the correct way to set full screen. Currently I’m using:

GetSubsystem<Graphics>()->ToggleFullscreen();

This does make the game fullscreen however the problem I’m having is the resolution is low, everything is quite pixelated. I’ve tried this on two monitors, the first does a fullscreen however the game picture remains the same size with black all around it. The second just comes out pixelated.

Am I supposed to set a resolution?

Thanks in advance,

Modanung

Graphics::ToggleFullscreen() only toggles fullscreen. To set a resolution as well you can combine it with Graphics::SetMode(int width, int height) or use Graphics::SetMode(int width, int height, bool fullscreen, bool borderless, bool resizable, bool highDPI, bool vsync, bool tripleBuffer, int multiSample, int monitor, int refreshRate) instead.

mrchrissross

Is there a quick way to get the current monitor resolution through urho?

Modanung

I think Graphics::GetDesktopResolution(int monitor) should get you that.
Graphics::GetResolutions(int monitor) will get you a PODVector<IntVector3> of available resolution/refresh-rate pairs.

mrchrissross

What is the default resolution set to, when the game is started? (the default resolution that urho sets?) Also what is “highDPI”? sorry for all the questions

Modanung

By default the engine starts in full screen at the current desktop resolution.

I’m not sure, might be for Apple retina screens.

mrchrissross

so far this is what I have:

if (input->GetKeyDown(KEY_P)) 
{ 
    IntVector2 screenRes = GetSubsystem<Graphics>()->GetSize();
    GetSubsystem<Graphics>()->ToggleFullscreen(); GetSubsystem<Graphics>()->SetMode(screenRes.x_, screenRes.y_);
}

However this still comes out quite pixelated :confused:

Modanung

Ah, yes. So setting the resolution to the current size will not change anything. :slight_smile:

mrchrissross

Took a screen cap, http://imgur.com/a/6PLQls1
It doesnt look the best. The space ship is quite pixelated. Do you know how I could solve this?

Modanung

Try replacing Graphics::GetSize() with Graphics::GetDesktopResolution(0). To set the initial resolution you can set engineParamaters_ of your Application during Setup().
Also you’ll want to use GetKeyPress instead of GetKeyDown for things that toggle.

mrchrissross

That seems to have worked, how can I set engineParamaters_ in the Setup()? I’ve only got a Start()

(So that this automatically happens from start)

Also when i press the P key it minimizes the application first and I press clicked it in the taskbar to op in again

Modanung

Here’s an example of how to use engine parameters:

I’ve gotten used to reactivating games after entering full screen. I’m not sure what causes it but I don’t think this problem is limited to or caused by Urho3D.

mrchrissross

Alight thanks a lot of this, really appreciate it. Everything seems to be working here :slight_smile:

Modanung

Glad I could help. :slight_smile: