[.net] Changing Resolution in .NET

Started by
3 comments, last by joanusdmentia 19 years, 5 months ago
How can I change the screen resolution in .NET for my fullscreen window?
Advertisement
You'll need to use the API and some DllImport work. You can read more about that here.

Frankly, though, you're better off using DirectX or OpenGL rather than doing it directly. In general, you shouldn't change the user's screen resolution without letting them know first. It's up to you to adapt to the user's environment, not force it to be the other way around.
- k2"Choose a job you love, and you'll never have to work a day in your life." — Confucius"Logic will get you from A to B. Imagination will get you everywhere." — Albert Einstein"Money is the most egalitarian force in society. It confers power on whoever holds it." — Roger Starr{General Programming Forum FAQ} | {Blog/Journal} | {[email=kkaitan at gmail dot com]e-mail me[/email]} | {excellent webhosting}
I'm using Tao OpenGL. Correct me if I'm wrong, but I am under the impression that glViewport sets the control's resolution rather than the screen resolution.

AKA with 1024x1280 screen resolution a call such as glViewport(0, 0, 1200, 1600) will still display at 1024x1280.

And therefore the only way to change the screen resolution would be through API stuff, right?
Quote:Original post by Lithic
I'm using Tao OpenGL. Correct me if I'm wrong, but I am under the impression that glViewport sets the control's resolution rather than the screen resolution.

AKA with 1024x1280 screen resolution a call such as glViewport(0, 0, 1200, 1600) will still display at 1024x1280.


glViewport() changes the resolution *inside* the control of the screen that is being rendered. For an easy way to change the fullscreen resolution, I suggest using glutFullscreen() function, which is included with Tao as well (under Tao.Glut, I believe).
Quote:Original post by kSquared
Frankly, though, you're better off using DirectX or OpenGL rather than doing it directly.

OpenGL can't change your video mode, you still use the Win32 API's ChangeDisplaySettings() to set the resolution when you use OpenGL.

Quote:Original post by Lithic
I'm using Tao OpenGL. Correct me if I'm wrong, but I am under the impression that glViewport sets the control's resolution rather than the screen resolution.

AKA with 1024x1280 screen resolution a call such as glViewport(0, 0, 1200, 1600) will still display at 1024x1280.

And therefore the only way to change the screen resolution would be through API stuff, right?

No and yes :)

glViewport sets the area into which projections are performed by the GL (but it doesn't clip to that area, for details on the difference check out the specs at www.opengl.org). This doesn't adjust the control or window in any way (in fact, OpenGL can't modify anything Windows-specific), it just affects where on the control you do your rendering.

But like I said, you're right in that OpenGL can't change the display resolution. Since you're already using Tao.OpenGL then take a look at Tao.SDL. It handles changing resolution and creating a window, amongst a lot of other stuff.
"Voilà! In view, a humble vaudevillian veteran, cast vicariously as both victim and villain by the vicissitudes of Fate. This visage, no mere veneer of vanity, is a vestige of the vox populi, now vacant, vanished. However, this valorous visitation of a bygone vexation stands vivified, and has vowed to vanquish these venal and virulent vermin vanguarding vice and vouchsafing the violently vicious and voracious violation of volition. The only verdict is vengeance; a vendetta held as a votive, not in vain, for the value and veracity of such shall one day vindicate the vigilant and the virtuous. Verily, this vichyssoise of verbiage veers most verbose, so let me simply add that it's my very good honor to meet you and you may call me V.".....V

This topic is closed to new replies.

Advertisement