【发布时间】:2013-11-01 00:36:58
【问题描述】:
我有一个带有 2D 摄像头的旧 XNA 3.1 游戏,我最近将其转换为 XNA 4.0。
我通过创建一个新的视口来缩放相机,将边界设置为相机的宽度/高度,然后像这样“合并”它们:
Viewport viewport = new Viewport();
viewport.X = 0;
viewport.Y = 0;
viewport.Width = camera.DisplayWidth;
viewport.Height = camera.DisplayHeight;
Viewport priorViewport = this.GraphicsDevice.Viewport;
this.GraphicsDevice.Viewport = viewport;
GraphicsDevice.Clear(Color.Black);
DrawGameLayer(gameTime, "PreContent");
this.GraphicsDevice.Viewport = priorViewport;
但是,当新视口的分辨率变得大于图形设备的视口分辨率(缩小时)时,它会在第 7 行爆炸,并显示:
视口无效。视口不能大于或超出 当前渲染目标的边界。 MinDepth 和 MaxDepth 必须是 介于 0 和 1 之间。参数名称:值
这在以前很有效,但现在显然不是正确的做法。有没有快速解决这个问题的好方法?还是我不得不完全改变放大和缩小的方式?
【问题讨论】: