XNA调整窗口,而无需增加分辨率 [英] XNA resize window without increasing resolution

查看:115
本文介绍了XNA调整窗口,而无需增加分辨率的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在更大的窗口中创建一个低分辨率的游戏。 (96x54 RES上960×540大小的窗口为例)。



我怎么会去呢?有没有一种方法可单独调整的首选后台缓冲区的宽度和高度的窗口?或者我应该保持一个较低的分辨率渲染目标我借鉴,只是画它作为我的窗户全屏幕的四,当我做了调整最近纹理采样?



<提前p>谢谢,



xoorath


解决方案

使用RenderToTexture你谈论的方法可能是一个好主意(若你想要做的后期处理着色器将是您更容易)。
或者,您也可以设置窗口的大小,但您的代码将只在桌面上工作。



您必须添加在你的项目中的2引用:

 使用System.Drawing中;使用System.Windows.Forms的
;



然后在你的游戏类(即在初始化方法)

  GraphicsDeviceManager.PreferredBackBufferWidth = 96; 
GraphicsDeviceManager.PreferredBackBufferHeight = 54;
IntPtr的PTR = this.Window.Handle;
Form表单=(表格)Control.FromHandle(PTR);
form.Size =新的大小(960,540);


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

解决方案

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:

using System.Drawing;
using System.Windows.Forms;

And then in your Game class (i.e. in the Initialize method)

GraphicsDeviceManager.PreferredBackBufferWidth = 96;
GraphicsDeviceManager.PreferredBackBufferHeight = 54;
IntPtr ptr = this.Window.Handle;
Form form = (Form) Control.FromHandle(ptr);
form.Size = new Size(960, 540);

这篇关于XNA调整窗口,而无需增加分辨率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆