Kobra's picture

Changing resolution and fullscreen state while running.

I have been adding graphics settings to my project. But I cannot figure out how to correctly change the resolution or go in or out of fullscreen mode while the the project is running.

Using WindowState = WindowState.Fullscreen; and WindowState = WindowState.Fullscreen; work, but they modify the viewing area and setting GL.Viewport doesn't fix it.

I am currently changing the monitor resolution with DisplayDevice.GetDisplay(DisplayIndex.Default).ChangeResolution

Can someone please explain the correct procedure to changing the resolution and/or fullscreen state in while the game is running.


Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
the Fiddler's picture

To change the resolution use DisplayDevice.ChangeResolution(). To move the application window to/from fullscreen, use WindowState = WindowState.Fullscreen and call GL.Viewport to update the viewport.

These will work even when the game is running. Do note that you will need to recreate any window-sized FBO textures/renderbuffers you are using.

There's nothing more to it - this should work fine. Can you describe the problem you are encountering in a little more detail?

Kobra's picture

Success! I have managed to get it working. I was having a problem where the view area was incorrect after I set the viewport and GameWindow Height/Width. But I fixed that recreating my camera.

Yesterday I was also having problems with the monitor resolution not changing when calling DisplayDevice.ChangeResolution() in some cases, but today, it seems to have been magically fixed.

The only problem I am currently having is restoring the monitor to the desktop resolution (not necessarily the native resolution) for when I swap from fullscreen to windowed. DisplayDevice.RestoreResolution() appears to have no effect.

the Fiddler's picture

Which OS and opentk version are you using?

Kobra's picture

Windows 7 64bit, the version of OpenTK.dll is 1.1.399.52617