在 XNA 中处理调整窗口大小和 RenderTargets
我正在为我的 XNA 游戏设计一个 GUI 系统。窗口可以在运行时动态调整大小,并且“桌面”可以很好地调整大小。
然而,我的渲染现在使用渲染目标来渲染窗口和效果。如果窗口或任何组件调整大小,我如何处理渲染目标?无法动态调整大小,并且每次循环创建新的都会非常低效。
I am designing a gui system for my XNA game. The window can be dynamically resized at runtime and the 'desktop' resizes to it fine.
However my rendering now uses render targets to render the windows and effects. If the window or any of the components resize how do I handle the render targets? The cant be resized dynamically and creating new ones every loop would be incredibly inefficient.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
调整窗口大小时,您可以创建新的渲染目标。无需每一帧都重新创建它们。
另一种选择是创建一个大于所需的渲染目标,并仅使用您需要的部分。这意味着您必须以某种方式重新映射后期效果 UV。这可能有助于解决内存碎片问题,但就我个人而言,我对第一种在需要时重新创建渲染目标的方法从来没有任何问题。
You can create new render targets when the window is resized. No need to recreate them every frame.
Another option is to create a render target bigger than needed and only use the part you need. That means you will have to remap your post effects UVs in some way. This might help with memory fragmentation, but personnaly, I never had any problem with the first method of just recreating the render targets when needed.