[英]Fake multi-monitor fullscreen in monogame: form can't be big enough
我运行了一个三显示器设置,我正在做我决定的 MonoGame 中的图形演示(为什么不呢?让它能够在所有显示器上最大化!)所以我使用了以下代码:
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;
}
当然还有第二个功能来撤消它。
当我将我的一个显示器设置在其他显示器之上进行测试时,这很好用,但是当我设置 Windows 布局以将它们全部并排放置(提供 5760x1080 的分辨率)时,我在图形上抛出了无效的参数错误。应用更改()。 所以我注释掉了图形代码并手动设置了表单宽度,发现显然我不允许表单宽度超过4096像素。
有没有解决的办法? 我愿意接受所有建议,包括并排绘制多个窗口,但我需要一些代码来向我展示如何定位第二个表单。
谢谢,麻烦您了。
这是 DirectX 9/Windows Phone 7 对纹理大小的限制,通过使用“Reach Graphics Profile”将其限制为 4096 x 4096。
最终显示的图像是所有 spritebatches 合成的单个纹理,大小不能超过最大纹理大小。
要更正问题:
要启用“隐藏”,请使用以下代码修改您的Game1.cs
构造函数:
public Game1()
{
graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
graphics.GraphicsProfile = GraphicsProfile.HiDef;
graphics.ApplyChanges();
// any additional code goes here
}
另一种方法是使用 OpenGL,它会忽略图形配置文件并使用适合您显卡的最佳版本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.