public bool SetGraphicsMode(int Width, int Height, bool isFullScreen)
{
// If we aren't using a full screen mode, the height and width of the window can
// be set to anything equal to or smaller than the actual screen size.
if (isFullScreen == false)
{
if ((Width <= GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width)
&& (Height <= GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height))
{
_GraphicsDeviceManager.PreferredBackBufferWidth = Width;
_GraphicsDeviceManager.PreferredBackBufferHeight = Height;
_GraphicsDeviceManager.IsFullScreen = isFullScreen;
_GraphicsDeviceManager.ApplyChanges();
return true;
}
}
else
{
// If we are using full screen mode, we should check to make sure that the display
// adapter can handle the video mode we are trying to set. To do this, we will
// iterate thorugh the display modes supported by the adapter and check them against
// the mode we want to set.
foreach (DisplayMode dm in GraphicsAdapter.DefaultAdapter.SupportedDisplayModes)
{
// Check the width and height of each mode against the passed values
if ((dm.Width == Width) && (dm.Height == Height))
{
// The mode is supported, so set the buffer formats, apply changes and return
_GraphicsDeviceManager.PreferredBackBufferWidth = Width;
_GraphicsDeviceManager.PreferredBackBufferHeight = Height;
_GraphicsDeviceManager.IsFullScreen = isFullScreen;
_GraphicsDeviceManager.ApplyChanges();
return true;
}
}
}
return false;
}
I have experience working with C++ and DirectX. I prefer working with C# and WPF. In my spare time I work with HTML, JS, CSS.
Showing posts with label Graphics Mode. Show all posts
Showing posts with label Graphics Mode. Show all posts
Saturday, May 15, 2010
XNA Set Graphics Mode
Subscribe to:
Posts (Atom)