Limanima wrote:
Is there a way I can access DX similar to OpenGL?
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:
-
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.
-
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).
Another question: SDL uses a swap chain for rendering, what’s the API call to swap the render targets? I’m looking for the SDL_GL_SwapWindow equivalent.
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.