locked
Help with porting OpenGL code

    Question

  • Hi,

    I'm porting code from Android that uses OpenGL to a new store app and would like some advice on how best to tackle this.

    Currently in Android we use a GLSurfaceView and a C++ back end which makes the OpenGL calls on the renderer thread.

    Now for our store app we have gone with a Javascript UI, so it is possible to follow a similar model, i.e. javascript provides a canvas (or something else) that the back end c++ code can make then the appropriate directX equivalent calls.  Or is WebGL an option in some way.

    Thanks for the help.

    Tuesday, November 11, 2014 5:14 PM

Answers

  • WebGL is supported for HTML/JavaScript apps.

    Otherwise you probably are better off using a Xaml or full DirectX app as you can't directly host DX output in either: Xaml supports DX interop via the SwapChainPanel and SurfaceImageSource classes, and DirectX apps (obviously) draw DX directly.

    HTML apps cannot directly interop with DX: you cannot compose a DX scene into an HTML page. For static scenes you could generate an image in a Windows Runtime Component, but passing the image from the component to the HTML layer would be too slow for video.

    --Rob

    Tuesday, November 11, 2014 9:39 PM
    Moderator

All replies

  • WebGL is supported for HTML/JavaScript apps.

    Otherwise you probably are better off using a Xaml or full DirectX app as you can't directly host DX output in either: Xaml supports DX interop via the SwapChainPanel and SurfaceImageSource classes, and DirectX apps (obviously) draw DX directly.

    HTML apps cannot directly interop with DX: you cannot compose a DX scene into an HTML page. For static scenes you could generate an image in a Windows Runtime Component, but passing the image from the component to the HTML layer would be too slow for video.

    --Rob

    Tuesday, November 11, 2014 9:39 PM
    Moderator
  • Thanks Rob, that has been extremely useful.

    I suspect I can guess the answer to these but here goes:

    Is it possible to mix UI's, i.e. stick with our existing Javascript UI and switch to XAML when needed (we don't need to show both UI formats at the same time)?

    I assume the OpenGL calls within WebGL need to be made from the HTML side, i.e. they can't be made from a C++ runtime component in some way?

    Thanks

    Tuesday, November 11, 2014 10:10 PM
  • I suspect this is what you expected:

    No, you can't mix the top level HTML and Xaml UIs (other than hosting a WebView in Xaml, but I don't think that'll do what you want).

    OpenGL isn't supported directly, only via WebGL. You can't break out the underlying calls into a component.

    Tuesday, November 11, 2014 10:47 PM
    Moderator
  • That's what I expected but thanks for confirming.

    Thanks for the help.

    Wednesday, November 12, 2014 9:06 AM