-1

I have a WebGLRenderingContext (XR-compatible) that is being drawn on by regular WebGL calls, and I also want to render on it using a Three.js WebGLRender. For some reason, creating a THREE.WebGLRenderer using the existing context (even if render is never called) makes the canvas go blank, and no drawing shows up after that.

1 Answer 1

-1

If you check HTML5 spec you’ll see you cannot share the context for 2D and webgl. A workaround could be to get a new context from a hidden canvas, that’s what some websites do.

5
  • Uh, but @programmer didn't say they were using the canvas for 2D, but that it would be used for WebGL by both THREE.js and directly?
    – mystery
    Jan 11, 2021 at 11:20
  • AFAIK just instancing that requires to define if it’s 2D or webgl cannot be used for other purpose
    – jscastro
    Jan 11, 2021 at 11:22
  • The canvas is only used for WebGL, and the WebGLRenderer is created using an existing context, so there should only be one context from the canvas.
    – programmer
    Jan 12, 2021 at 0:02
  • If you add some code it’ll be clearer I think
    – jscastro
    Jan 12, 2021 at 0:06
  • Are you setting renderer.autoClear = false;??
    – jscastro
    Jan 12, 2021 at 0:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.