I run a triple-monitor setup and I am working on a graphics demo in MonoGame that I decided (heck why not? let's give it the ability to maximize across all displays!) so I used this code:
graphics.IsFullScreen = false;
graphics.ApplyChanges();
//get dimensions of box that will cover all displays and set window to it.
int xPos = System.Windows.Forms.Screen.AllScreens.OrderBy(x => x.Bounds.X).Select(x => x.Bounds.X).First();
int yPos = System.Windows.Forms.Screen.AllScreens.OrderBy(y => y.Bounds.Y).Select(y => y.Bounds.Y).First();
form.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
form.Location = new System.Drawing.Point(xPos, yPos);
int xWidth = System.Windows.Forms.Screen.AllScreens.OrderByDescending(x => x.Bounds.X).Select(x => x.Bounds.X + x.Bounds.Width).First() - xPos;
int yHeight = System.Windows.Forms.Screen.AllScreens.OrderByDescending(y => y.Bounds.Y).Select(y => y.Bounds.Y + y.Bounds.Height).First() - yPos;
form.MaximumSize = new System.Drawing.Size(0, 0);
form.Width = xWidth;
form.Height = yHeight;
// graphics.PreferredBackBufferWidth = xWidth;
// graphics.PreferredBackBufferHeight = yHeight;
graphics.ApplyChanges();
Properties.Settings.Default.FakeFullScreen = true;
}
and of course a 2nd function to undo it.
This worked fine when I had one of my monitors set above the others for testing, but when I set windows layout to place them all side-by-side (giving a resolution of 5760x1080) I was throwing an invalid parameter error on the graphics.ApplyChanges(). So I commented out the graphics code and set the form width manually and discovered that evidently I am not allowed to have a form wider than 4096 pixels.
Is there a way around this? I am open to all suggestions, including having more than one window side-by-side to draw to, but I would need some code to show me how to target a 2nd form.
Please and thank you.
This is a DirectX 9/Windows Phone 7 limitation of texture sizes limited to 4096 x 4096 by the use of the "Reach Graphics Profile".
The final displayed image is a single texture of the composite of all spritebatches, the size cannot exceed the maximum texture size.
To correct the issue:
To enable "Hidef", modify your Game1.cs
constructor use this code:
public Game1()
{
graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
graphics.GraphicsProfile = GraphicsProfile.HiDef;
graphics.ApplyChanges();
// any additional code goes here
}
The alternative is to use OpenGL, which ignores the graphics profile and uses the optimal version for your video card.