3

My aim is to share resources (texture) between WebGL (in browser, canvas.getContext()) and glX extention (glXCreateContext [1]) for c++ (arch linux) in order to share a texture between WebGL and X.

i.e. load a window from X (using the backing pixmap) into a WebGL texture, without using the XGetImage/XGetSubImage/XShmGetImage/XShmGetSubImage to directly access the backing pixmap.

  1. Can that be done at all, considering that WebGL is OpenGL ES 2.0?
  2. If so, how do I get the handle for the context?
  3. Can I make the WebGL context the current context, and then use glXGetCurrentContext?
  4. Is there any other way to share texture between WebGL and c++ glX?

To further clarify, the idea is, CreateContext(webgl) in browser -> Share handle with C++ app -> Create new glXContext in c++ -> share texture between them.

Finally, since I am new to OpenGL in general, I keep wondering, is the texture object shared between all OpenGL/OpenGL ES/WebGL Contexts? Can it be if we knew how to bind it?

[1] glX Create context function, note the share list.

GLXContext glXCreateContext(    Display *   dpy,
    XVisualInfo *   vis,
    GLXContext      shareList,
    Bool    direct);
WhyMe
  • 535
  • 2
  • 13
  • 1
    I don't think this is possible without massive changes in the Canvas/WebGL code of the underlying browser. For security reasons a lot of effort has been put into place to tighten the boundary between browser environment and the rest of the OS. What you're calling for is essentially punching a whole through the security infrastructure that has been put in place to protect the system from malicious websites trying to siphon data from the host system. But I could be wrong. Either way, it's not a good idea, for security reasons. – datenwolf Nov 17 '16 at 10:11
  • Hi, thanks firstly for the informed comment. If I am running in a node-webkit app this is still not a good idea? I don't understand why. – WhyMe Nov 18 '16 at 07:38
  • 1
    If this is for a purely locally executed program, with full access to the file system, then it's no longer that much of a problem. However I'd still assume, that you'll have to make a few modifications to the Webkit component to enable what you want to do (essentially knock out all the code in Webkit that's responsible for the so called "GL robustness" and also somehow give you access to the GLX context handle). – datenwolf Nov 18 '16 at 08:04
  • I see, thank you. I think I might go the way of NaCl as an internal app, and try a bit there. It seems to be simpler then recompiling node-webkit. – WhyMe Nov 18 '16 at 08:09

0 Answers0