XNA: get screen's width and height

流过昼夜 提交于 2019-11-29 02:06:53

问题


how do i get the width and height of the entire screen in XNA?


回答1:


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

GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height
GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width



回答2:


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.




回答3:


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



来源:https://stackoverflow.com/questions/1377524/xna-get-screens-width-and-height

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