XNA 调整窗口大小而不增加分辨率
我想在较大的窗口上创建低分辨率游戏。 (例如,960x540 尺寸窗口上的 96x54 分辨率)。
我该怎么办呢?有没有办法独立于首选后台缓冲区宽度和高度来调整窗口大小?或者我应该只保留我绘制的低分辨率渲染目标,并在完成最近纹理采样的调整后将其绘制为窗口上的全屏四边形?
预先感谢,
xoorath
I want to create a low resolution game on a larger window. (96x54 res on 960x540 size window for example).
How would I go about this? Is there a way to resize a window independently of the preferred back buffer width and height? Or should I just keep a low resolution render target I draw on, and just draw it as a full screen quad on my window when I'm done adjusting for nearest texture sampling?
Thanks in advance,
xoorath
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我倾向于选择“渲染到纹理”解决方案,这样我就可以允许全屏显示而不会失真。
我用来实现这一点的类通常看起来像这样:
然后在我的游戏中,初始化往往看起来像这样:
随着所有重要的更新调用:
然后是绘制本身的行为:
有了这个,我基本上可以停止根本不关心分辨率,只专注于游戏。
I tend to opt for the "render to texture" solution so that I can allow for things like full screen without distortions.
The class I use to achieve this usually looks something like:
And then in my game, the initialisation tends look something like:
With the all important call to Update:
And then the act of drawing itself:
With this in place, I can basically stop caring about resolution at all and just focus on the game.
使用您正在讨论的 RenderToTexture 方法可能是一个好主意(而且如果您想做后期处理着色器,它对您来说会更容易)。
或者,您可以设置窗口的大小,但您的代码只能在桌面上运行。
您必须在您的项目中添加这两个引用:
然后在您的 Game 类中(即在 Initialize 方法中)
Using the RenderToTexture method you're talking about might be a good idea (plus it will be easier for you if you want to do post-process shaders).
Alternatively, you can set the Window's size, but your code will only work on a desktop.
You must add those 2 references in your project:
And then in your Game class (i.e. in the Initialize method)