Three.js: Is sharing webgl context not supported?

Created on 15 Feb 2016  Â·  8Comments  Â·  Source: mrdoob/three.js

Here is a demo of pixi spinning bunny + creating three.js renderer. If you uncomment a single line of three.js code, the bunny dies.

Most helpful comment

Yeah 🎉Leaving working combo link in case someone will end up reading here.

All 8 comments

Additionally, passing 3js context to pixi instead leaves it in good shape, as it seems, so the problem must be on 3js side?

The problem seems to be in WebGLRenderer's setDefaultGLState() that I can't opt out of... If I disable WebGLState init, the bunny lives.

Ok, so it looks like the best workaround is to manually set proper context state before each lib's render call. However, this is not all there is to the story, I will be spamming this issue with uniform location errors soon, stay tuned :wink:

Here goes:

https://jsfiddle.net/psgvteg0/5/

As you see, pixi's bunny rotation actually mangles 3D cube, and you have a bunch of errors in the console:
screen shot 2016-02-16 at 0 11 22

Ok, after rtfm-ing in #5278 I have used this advice:

Calling renderer.resetGLState() before - or after - your custom rendering function should be sufficient to reset the state predictably

https://jsfiddle.net/psgvteg0/6/

there is now only one invalid location: WebGL: INVALID_OPERATION: uniformMatrix3fv: location is not from current program

Oh wait, this one is in pixi, I guess three.js is cleared.

✌

Yeah 🎉Leaving working combo link in case someone will end up reading here.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

fuzihaofzh picture fuzihaofzh  Â·  3Comments

clawconduce picture clawconduce  Â·  3Comments

makc picture makc  Â·  3Comments

ghost picture ghost  Â·  3Comments

jlaquinte picture jlaquinte  Â·  3Comments