Windows Phone 8 - is it possible to access DX directly? |
Windows Phone 8 - is it possible to access DX directly? |
meklu
Guest
|
The SDL render equivalent of SDL_GL_SwapBuffers is SDL_RenderPresent, the rest I'm afraid I can't help you with.
-- Melker Narikka Limanima kirjoitti Mon Aug 25 2014 17:37:30 GMT+0300 (EEST):
SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||||
|
Re: Windows Phone 8 - is it possible to access DX directly? |
Limanima
|
I've already tried that, but I'm getting this: "identifier "SDL_RenderPresent_REAL" is undefined" I'm going to try to understand why is this undefined. |
|||||||||||||
|
Re: Windows Phone 8 - is it possible to access DX directly? |
Limanima
|
OK, I'm getting that error because I'm including SDL_sysrender.h.
I'm including this so I can have access to the SDL_Renderer structure and get the driverdata member. I know that what I'm doing is plane wrong, that's why I want to access DX context the correct way (if possible of course). |
|||||||||||
|
Re: Windows Phone 8 - is it possible to access DX directly? |
DLudwig
|
There currently isn't any explicit support for accessing the internals of the SDL/WinRT's Direct3D 11.x renderer (outside of SDL). It might be possible, however I haven't tried it myself. It is, however, possible to create your own, complete-set of Direct3D 11 resources (swap chain, textures, etc.), which'll get attached to the SDL-managed OS' native window (WinRT calls this a 'CoreWindow'; attached to D3D11 via IDXGIFactory::CreateSwapChainForCoreWindow, detailed at http://msdn.microsoft.com/en-us/library/windows/apps/hh404559(v=vs.85).aspx ). From there, SDL can be used for input, audio, etc., while Direct3D 11.x gets used for rendering, swap chain management and presentation, etc. To get the WinRT native window, SDL_GetWindowWMInfo can be used. A pointer to the CoreWindow will be in the SDL_SysWMinfo struct, via the field, 'info.winrt.window' (minus the quote marks). To note, SDL/WinRT does have some experimental support for rendering content via OpenGL ES 2.x, via a Microsoft Open Technologies driven port of Google's ANGLE library (which emulates OpenGL ES 2.x on top of Direct3D), to the WinRT family of platforms. The port is available at https://github.com/msopentech/angle, if you'd like to take a look. Getting it running is a matter of compiling it's various components, packaging the .dll files in your app, then using SDL to create an OpenGL content. SDL will attempt to load the appropriate DLL files, and create an OpenGL context via ANGLE (which'll issue appropriate Direct3D calls). A few notes on this though: 1. I've never tried using OpenGL ES via ANGLE on Windows Phone 8, only Windows 8 (in it's 'Metro' environment). I suspect that it would work off the bat, but haven't explicitly-tested this. 2. If you're compiling a Windows Phone 8.0 app (as opposed to a Windows Phone 8.1 app), and end up using ANGLE, you'll need to precompile your shaders, as WP 8.0 doesn't allow store-distributed apps to compile shaders at runtime. A shader compiler can be packaged into developer-only/non-store builds, however store-distributed apps must precompile the shaders. More details on this are on MS Open-Tech's ANGLE page (https://github.com/msopentech/angle).
If you're using a custom, Direct3D 11 renderer, you wouldn't use SDL to present a frame, but rather the equivalent Direct3D 11 calls (IDXGISwapChain::Present, for example). If you're only using SDL_Renderer to draw content (and avoiding a custom, Direct3D 11 renderer), you can use SDL_RenderPresent to show content. -- David L. |
|||||||||||||||
|
Re: Windows Phone 8 - is it possible to access DX directly? |
Limanima
|
Thanks for the insight. I'm trying my initial route: hack SDL to get access to the SDL_Renderer.driverData member, and then create my own shaders, viewport, rasterizer etc. It's seems to be working, but I still haven't managed to get something to be drawn on screen. At least I'm not getting DX errors, and I already have everything in place, vertex/index buffers, shaders etc. I'm trying to understand what's going on. Last DX version I've used was DX 5.0 and it was a long time ago... At least ClearRenderTargetView is working, because I can change the background color . |
|||||||||||||||||
|
Re: Windows Phone 8 - is it possible to access DX directly? |
DLudwig
|
Here's one tip: try turning on Direct3D 11's debug mode. If you're using the SDL_Renderer API to create this, use SDL_SetHint to set SDL_HINT_RENDER_DIRECT3D11_DEBUG to "1", doing so -before- creating the renderer. If, at some point, you end up creating your own D3D device (and swap chain, etc.), you can turn on debug mode by passing in the D3D11_CREATE_DEVICE_DEBUG flag to D3D11CreateDevice. Best of luck! -- David L. |
|||||||||||||
|
Re: Windows Phone 8 - is it possible to access DX directly? |
Limanima
|
Already did that. I'm still chasing the problem. It can be anything. Wrong viewport, projection matrix, shaders, buffers, etc.. I'm getting ready for a few hours chasing this. |
|||||||||||||
|
Re: Windows Phone 8 - is it possible to access DX directly? |
Limanima
|
I think I got it, took me some time, but I think I know why nothing is being rendered.
The projection matrix is wrong. Opengl uses a right handed system, and DirectX uses a left handed system! Next step: remove all the test code I have and add texture support to the shader. |
|||||||||||
|
Re: Windows Phone 8 - is it possible to access DX directly? |
Limanima
|
There's another difference in matrix math. Transformation matrices have to be transposed. |
|||||||||||||
|
Limanima
|
YEAH!
After a few hours (days actually, and a lot of headaches) I finally have the game working on WP! All sprites are filled rects for now, but it's working. All I need now is a texture shader (and to adjust a few more things). |
|||||||||||
|