Windows Phone 8.1 emulator for DirectX landscape

0

July 16, 2014 update: I have converted the SharpDX "MiniCube" sample project to a Universal 8.1 project. It is 100% self-contained. It will demonstrate this issue. There is a "READ ME.txt" file included with information. You can download it here:

Download SharpDX MiniCube Universal 8.1 project


My issue is that the Windows Phone 8.1 emulator in Visual Studio 2013 is displaying the landscape mode sideways. The image is landscape and looks correct, but it's rotated 90 degrees, sitting on one end and running off the top of the display. Here are pictures to show you what I mean:

Portrait Landscape

You can click the images to see them in full size.

As far as the app is concerned, it is in landscape mode, and all handling of touches behaves correctly, as though it is being displayed properly. It simply shows up in the emulator rotated on one end.

This is a C# project, using SharpDX (a DirectX wrapper for C#). I don't know if this issue will occur on a real device or not; I do not have one. I obviously can't even consider releasing my app without knowing if this should behave properly on a real device.

I don't do anything fancy in my code. I use the "CommonDX" source code used in the SharpDX samples, unmodified:

https://github.com/sharpdx/SharpDX-Samples/tree/master/WindowsAppStore81/CommonDX

The same source code behaves properly in the WinRT (computer/tablet) version, both in the simulator and on a real device.

If anyone knows anything about this, please tell me whatever you can. Thanks!


July 16, 2014 update: I went out and bought a Nokia Lumia 520 and updated it to Windows 8.1. This same issue occurs on a real device as well. The only difference is that it squishes the full rotated width to fit in the display, rather than running off the top.

I should also add that I am using the SharpDX 2.6.2 DLLs.

As I stated, I am using the same source code that I use for the Windows App Store 8.1 project (for computers and tablets), and it all works perfectly there. There was one small change I had to make for Windows Phone 8.1 though. In the CommonDX source code, in the file SwapChainTargetBase.cs, the call to swapChain.ResizeBuffers() generates a SharpDXException exception (HRESULT 0x887A0004 DXGI_ERROR_UNSUPPORTED).

This occurs whenever the screen dimensions change, which of course occurs when you tilt the device to change the orientation. To get around this problem, I simply dispose the current "swapChain" and let the existing code create a new one instead of resizing the old one. This change would not cause the issue that is happening here.

I checked the SharpDX samples for sample code, but as of this date, none of the samples appear to be for Windows Phone 8.1. They have "WindowsAppStore81" (PC/tablet), and "WindowsPhone8" samples, but no "WindowsPhone81", nor "WindowsUniversal81".

I'm no DirectX guru by any stretch. I'm into making apps, not fighting to make my tools work for me. And I use OpenGL on all other platforms, with no problems. But in any case, I couldn't cause the landscape view to rotate off the top of the display if I tried. You can see in the screenshot that my app knows it's in landscape view, and is rendering a landscape buffer. Whatever is causing this issue, it's outside of my own source code.

My app is fully functional, on an actual device running Windows Phone 8.1 in the palm of my hand, and I can't release it, because it won't display the landscape view properly. And there doesn't seem to be a thing I can do to change that.

Has anyone even built a successful SharpDX project for Windows Phone 8.1, one that works in portrait and landscape both?

One last note: Why the heck does Microsoft not allow support for OpenGL, and then not include support for DirectX either for the C# language? If it wasn't for SharpDX, we'd all be totally screwed.

c#
visual-studio-2013
directx
windows-phone-8.1
sharpdx
asked on Stack Overflow Jun 23, 2014 by msedore • edited Jul 16, 2014 by msedore

2 Answers

1

When using DirectX directly, it would appear that Windows Phone does not change how the framebuffer is addressed. You have to manually rotate your graphics yourself when in landscape mode.

See this article: http://www.catalinzima.com/2012/12/handling-orientation-in-a-windows-phone-8-game/

answered on Stack Overflow Sep 2, 2014 by Mike Clarke
0

I found that removing the following fixed the issue:

DX::ThrowIfFailed(
    m_swapChain->SetRotation(displayRotation)
    );

It clearly doesn't need to be set!

answered on Stack Overflow Apr 19, 2015 by Comeradealexi

User contributions licensed under CC BY-SA 3.0