views:

455

answers:

2

It's my first time trying to make anything really interesting in C# and I was trying to make a simple form or game screen where the user could define a custom resolution/screen ratio etc. or to automatically detect the max screen size/ratio and output? its my first game, so I was wondering if it was possible or if there would be any major issues with such, rather than just setting it to 1366x768 (the resolution of all of my computers). Thanks in advance for any assistance.

A: 

Just set the PreferredBackBuffer to 1366x768 and if the graphics device can handle that resolution you'll get it. otherwise you'll get something scaled down. the xbox will automatically scale if nescessary to support the television being used as well.

Joel Martinez
I was looking at having it changeable so my friends can play/test as well, on different systems. which was the query about making a configuration form or menu within the game itself.
PCAddict
I believe you can just change the preferred back buffer at any time. So you can easily make a menu item which changes this :-)
Joel Martinez
+2  A: 

You could enumerate through the default GraphicAdapter's DisplayModeCollection property to find the DisplayMode with the max width/height/aspect ratio.

Something like:

GraphicsAdapter defaultAdapter = GraphicsAdapter.DefaultAdapter;
DisplayMode maxMode = defaultAdapter.DisplayModeCollection[0];
foreach (DisplayMode enumeratedDisplay in defaultAdapter.DisplayModeCollection)
{
    //Test enumeratedDisplay against maxMode, setting maxMode to enumeratedDisplay if enumeratedDisplay is better
}

Maybe there's a better way, but that's certainly one way you could find the max.

Or, you could take the same DisplayModeCollection and populate a comboBox of sorts or a list, letting the user choose for themselves.

My apologies if the above code doesn't work in that exact form. I can't test it where I am currently

Bob
This is Great thanks, I was wondering if i could attatch a Windows for so the user could select the Screen Resolution and Aspect ratio, wether to run in a window or full screen etc. but I am unsure as to how I would save the settings and load them in the game if the form was a seperate App, I would like to look at alternative solutions, due to using several times, I think this might be easier, as I could make other games to read the same settings data from the form or file it creates in this way.
PCAddict
You can, technically, attach WinForms...but it's complicated. I'd recommend creating your own in-game UI and just saving the choice to a file
Bob