XNA: get screen's width and height

后端 未结 3 810
逝去的感伤
逝去的感伤 2020-12-29 01:34

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

相关标签:
3条回答
  • 2020-12-29 01:43

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

    GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height
    GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width
    
    0 讨论(0)
  • 2020-12-29 01:51

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

    0 讨论(0)
  • 2020-12-29 01:59

    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.

    0 讨论(0)
提交回复
热议问题