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?


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