3
\$\begingroup\$

Just to be clear this is not for Windows Phone 7. =)

I've got some interesting requirements for a project and I'm having trouble trying to find the information I need.

I have two monitors. The default monitor is landscape. The second monitor is portrait.

Right now I save the width and height and then change Graphics.PreferredBackBufferWidth and Graphics.PreferredBackBufferHeight to the values returned from GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width (1920) and GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height (1080) right before toggling to full screen. This works fine on the monitor in landscape mode. The monitor in portrait however scales 1920x1080 to fit onto the 1080x1920 screen.

I'm looking for either a way to determine that the monitor is in portrait mode or have the CurrentDisplayMode.Width and CurrentDisplayMode.Height return the portrait appropriate values.

I've been rifling through the XNA Framework documentation and googling like mad and not finding anything helpful.

\$\endgroup\$

1 Answer 1

3
\$\begingroup\$

You can just check if the width of the screen is less than the height - if this is the case, then you definitely have a monitor in portrait mode.

\$\endgroup\$
3
  • 1
    \$\begingroup\$ The issue is that regardless of the screens orientation Width and Height are reported as 1920 and 1080 respectively. \$\endgroup\$ Oct 2, 2013 at 14:17
  • \$\begingroup\$ @lose_the_grimm If width < height, then that means you swap it, no? So if width < height, then width must equal height now in your case. I think you've answered your own question. :) \$\endgroup\$ Oct 3, 2013 at 0:28
  • \$\begingroup\$ And that would make sense if the Width and Height switched in portrait mode. However, Width is never less than height. No matter if the screen is in portrait mode or landscape mode Width is reported as 1920 and Height is reported as 1080. Always. \$\endgroup\$ Oct 3, 2013 at 13:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .