
GameWindow - fullscreen + setting the resolution
Posted Sunday, 2 August, 2009 - 18:31 by james_lohr inAt present, if I create a new GameWindow, with a resolution of say 800x600, and then set the WindowState to fullscreen, instead of changing my monitor resolution to 800x600 (as I would expect), it just overrwrites the resolution with my current desktop resolution.
So, how do I change my monitor resolution? I've spent a good 25 minutes googling, and I found:
OpenTK.Graphics.DisplayDevice and OpenTK.Graphics.DisplayResolution help enumerate available displays and resolutions (yes, the code is multi-monitor aware ;) ), and provide methods to change the settings of any display.
...but the I can't for the life of me find these elusive methods. Are they perhaps private? - if so, how do I get at them?


Comments
Re: GameWindow - fullscreen + setting the resolution
At present, if I create a new GameWindow, with a resolution of say 800x600, and then set the WindowState to fullscreen, instead of changing my monitor resolution to 800x600 (as I would expect), it just overrwrites the resolution with my current desktop resolution.
This was discussed in the forums. I'm not sure what is the current state of this part of the API. If I might, I certainly wouldn't expect GameWindow to change the screen resolution :)
Re: GameWindow - fullscreen + setting the resolution
OpenTK.Graphics.DisplayDevice.ChangeResolution()andOpenTK.Graphics.DisplayDevice.RestoreResolution()are the methods you are looking for.Edit: I made a mistake in my orginal post, it's DisplayDevice, not DisplayResolution. Sorry!
Re: GameWindow - fullscreen + setting the resolution
Woah woah woah, there seriously needs to be some documentation up on how to use this part of the library because it's very confusing if you're used to how the majority of games libs do it (i.e. they only support a single monitor).
This is how I expected it to work - (for anyone referring to this thread, this is wrong) :
For anyone referring to this thread, this is how it actually works:
In hindsight it's extremely simple, and works exactly as it should. The problem was that I wasn't expecting the support for multiple monitors, and that was where the confusion arose from. - also, no amount of googling showed up any snippet of code (like the one above) for simply setting the resolution on a single monitor.
Perhaps it was just me being slow, or the fact that I recall using a previous games library where "availableDisplayModes" was used to mean the available resolutions (which is rather similar to "availableDisplays"). Anyway, at least this thread now exists, so noone else will have the same problem as myself.
Probably half the problem is that C# comes with such good development tools that people don't even bother documenting stuff because they just assume that other programmers will have enough common sense to explore the available methods themselves throught the IDE. :P
Re: GameWindow - fullscreen + setting the resolution
As part of the ongoing documentation effort, I've added a new chapter describing the DisplayDevice class.
If you are using OpenTK 0.9.9+, you can optionally pass a DisplayDevice to the GameWindow constructor. This will ensure the GameWindow is instantiated on that specific device (OpenTK 0.9.8 and older would always instantiate GameWindows on the primary display).
Finally, you can query the actual bounds of the device using the Bounds property. This can be useful in some obscure cases, where you might like to know the actual position of each device relative to the rest.
Re: GameWindow - fullscreen + setting the resolution
Excellent! :)
Re: GameWindow - fullscreen + setting the resolution
Great work in supporting multiple display devices - as james said - it is quite unique among the graphics libraries out there. Eg. I'm not sure even the widely used SimpleDirectmedia Library (SDL) supports this.