mono/MonoGame — pull request #1336 by Nezz (2013-02-09 15:22:56+00:00)
Title: DisplayOrientation revision

We are working on unifying WP8 with the other platforms of MonoGame. The straightforward solution is to have a device orientation and a desired orientation and if they don't match, we apply a rotation to our game. This is working fine, but we have noticed that the DisplayOrientation is implemented in a confusing and hard to use way.

Let's take a look at the MonoGame code of DisplayOrientation:
```C#
[Flags]
public enum DisplayOrientation
{
///

/// In Xna, this value is Default = 0. The effect of setting
/// GraphicsDeviceManager.SupportedOrientations = Default is the same as setting
/// GraphicsDeviceManager.SupportedOrientations = LandscapeLeft | LandscapeRight.
///

Default = 1,
LandscapeLeft = 2,
LandscapeRight = 4,
Portrait = 8,
// iPhone specific Orientations
FaceDown = 16,
FaceUp = 32,
// Android can also use this orientation
PortraitUpsideDown = 64,
Unknown = 128,
}
```

The same in XNA (Click go to definition):
```C#
[Flags]
public enum DisplayOrientation
{
Default = 0,
LandscapeLeft = 1,
LandscapeRight = 2,
Portrait = 4,
}
```

I have spent plenty of time working with iOS orientations (implementing iOS 6 orientation model for example). FaceDown and FaceUp are never used. As for PortraitUpsideDown I would recommend renaming it to PortraitDown (see http://msdn.microsoft.com/en-US/library/windowsphone/develop/microsoft.phone.controls.pageorientation%28v=vs.105%29.aspx).

## My recommendation for DisplayOrientation##
```C#
[Flags]
public enum DisplayOrientation
{
Default = 0,
LandscapeLeft = 1,
LandscapeRight = 2,
Portrait = 4,
PortraitDown = 8,
Unknown = 16
}
```

Default can mean LandscapeLeft | LandscapeRight or Portrait depending on the requested resolution (the comment in MonoGame is wrong), so it should stay 0.

What do you guys think? Any input is welcome.

Further reading:
http://blogs.msdn.com/b/shawnhar/archive/2010/07/12/orientation-and-rotation-on-windows-phone.aspx

Orientations need some additional work on WP8, as it isn't implemented at the moment.
## My recommendation for WP8 ##
GraphicsDevice.PresentationParameters.DisplayOrientation should be set to Portrait, as the swap chain is always in portrait.

The GamePage.xaml should have all orientations enabled (Portrait+LandscapeLeft+LandscapeRight). The XAML should notify the WPGameWindow every time the device orientation changes (display orientation remains portrait!). If the new orientation is part of SupportedOrientations, we set the CurrentOrientation to our new rotation and notify the game if needed.

This way, the game will see what orientation it should be in and what orientation the GraphicsDevice has.