Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UWP + WebGL + Chakra request #86

Closed
JimSEOW opened this issue Sep 2, 2016 · 8 comments
Closed

UWP + WebGL + Chakra request #86

JimSEOW opened this issue Sep 2, 2016 · 8 comments

Comments

@JimSEOW
Copy link

JimSEOW commented Sep 2, 2016

Currently, in ChakraBridge or JsBridge for .NET, for 2D graphic context, Microsoft.Graphics.Canvas is used for Win2D.
Is it possible eventually to use Angle to provide the 3D graphic context in UWP to support for e.g. JsBridge, allowing c# to call WebGL js script?

What we are missing is to map WebGLRenderingContext to Angle, is that correct?

Embedding ChakraHost (c#) for WebGL example
How to add 3d context works in JsBridge by adding WebGLRenderingContext?

@austinkinross
Copy link
Member

Hi there, Internet Explorer and Microsoft Edge use their own WebGL->D3D11 translation layer for WebGL content. Creating a WebGLRenderingContext in your Javascript (or C#) UWP application will therefore use the Edge team's translation layer rather than ANGLE.

It may be possible for you to write your own wrapper for ANGLE in Javascript or C# but that would be a lot of effort.

@lwansbrough
Copy link

FYI this is what I'm working on @JimSEOW - if you'd like to work on it with me I could certainly use some help. The WebGL translation layer still needs to be written in C#. There's a good example of a WebGL implementation here (though it's in Objective C): https://github.com/phoboslab/Ejecta/tree/master/Source/Ejecta/EJCanvas/WebGL

Are you interested in contributing to this project?

@JimSEOW
Copy link
Author

JimSEOW commented Sep 2, 2016

@austinkinross

Taken from ChakraBridge:

Why not use a Webview?
This is a valid question that you may ask. Using only Chakra provides some great advantages:

Memory footprint: No need to embed HTML and CSS engines as we already have XAML.
Performance: We can directly control JavaScript context and, for instance, call JavaScript function without having to go through a complex process like with the webview.
Simplicity: The webview needs to navigate to a page to execute JavaScript. There is no straightforward way to just execute JavaScript code.
Control: By providing our own tools (like XHR or setTimeout), we have a high level of granularity to control what JavaScript can do.

@lwansbrough I have not reached a good overview of the different pieces of making OpenGL works in UWP for c#, coming from Chakra, calling directly c++ dll or as suggested before, having a managed c++ layer, and how OpenTK would solve the issue. At this stage, I am still learning, deciding this path or using hybrid Webview or just everything javascript. However, it is great to have you taken this challenge persistently.

@lwansbrough
Copy link

The solution I'm working on uses a C# backend to interface with OpenGL (via OpenGL.Net) and ChakraCore. That means your Javascript bridge will be written in C# which I think is a huge bonus. Getting OpenGL to play with C# isn't the easiest thing to do, but the OpenGL.Net implementation is nice because it's all automated. I'm working on a readme right now for this project, I'll try to get it on GitHub today.

@lwansbrough
Copy link

Worth noting though that my implementation is HoloLens specific, but the code is almost entirely the same save for a few classes that manage holographics.

@lwansbrough
Copy link

If anyone is interested: https://github.com/lwansbrough/HolographicJS -- still very much a WIP. Doesn't work yet.

@JimSEOW
Copy link
Author

JimSEOW commented Sep 9, 2016

I think these are good starting points for creating c# wrappers for
https://github.com/koush/OpenGLES/blob/master/gl.cs [LibGLESv2.dll]
https://github.com/koush/OpenGLES/blob/master/egl.cs [libEGL.dll]

@JimSEOW
Copy link
Author

JimSEOW commented Sep 14, 2016

The question here requires multiple steps
(a) Getting Angle UWP XAML c# to work --> Done
(b) Getting WebGL4Net to work with XAML --> WIP
(c) Connect ChakraBridge to WebGL4Net through WebGLRenderingContext.cs--> WIP

@JimSEOW JimSEOW closed this as completed Sep 15, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants