XNA: get screen's width and height

本小妞迷上赌 提交于 2019-11-30 04:39:52
Adrian Grigore

This seems to be it (just googled for "xna screen width height" myself):

GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height
GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width
Eddie Parker

Empirically I've found that in XNA 4.0 I need to use

GraphicsDevice.Viewport.Width
GraphicsDevice.Viewport.Height

when running windowed mode, as I find

GraphicsDevice.DisplayMode.Width
GraphicsDevice.DisplayMode.Height 

gives me the resolution of the entire screen.

Hopefully this helps someone else out.

GraphicsDevice.Viewport.Bounds - this returns Rectangle2D and it has parameters Width and Height.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!