Rendering with native OpenGL

I am writing an application which will need to render graphics with native OpenGL. The reason that it needs to do this is that I need to integrate with a native library that expects to have access to the OpenGL context and associated resources. This library cannot be ported to JS using emscripten or something similar, because it relies on a lot of native system calls/dlls/magic/etc.

I think that I can create a Node.js addon which will be C library that does all of my rendering with native OpenGL.

However, there are two things that I don’t know how to do:

  1. I’ll need to send rendered images of the DOM to the node.js addon. Is there a way to render the contents, or part of the contents, of the DOM to a RGBA buffer, so I can send it to my addon?

  2. I’ll need to send rendered images from the node.js addon back to electron for display. I know that I can render to a buffer and return the bytes to V8, but I’m wondering if there’s a faster way to share this data.

Has anyone ever done this? Are there any mechanisms to share buffers on the GPU between electron land and native land?

1 Like

As far as #1 goes, I just stumbled across this StackOverflow answer that might be helpful:

Hi @rodarmor! Were you able to make any progress on answering some of those questions? I’m in the same boat!

Hi @slnovak! Unfortunately not, although I wound up not needing to do it, so I also can’t conclusively say that it’s not possible, either.

1 Like

i’m searching about this just for a future project and i got an idea (purely theorical) what about a glfw window with embeded nodejs part of the ui and a smaller surface for your opengl part like it’s 2 apps merged in one

I have this problem too.any progress now?
BrowserView can show webside over the content,is it possible to modify the source code ,and make it render with opengl?
I know maybe modify the chromium’s code can do it ,but it just too hard…