Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is sharing webgl context not supported? #8147

Closed
makc opened this issue Feb 15, 2016 · 8 comments
Closed

Is sharing webgl context not supported? #8147

makc opened this issue Feb 15, 2016 · 8 comments

Comments

@makc
Copy link
Contributor

makc commented Feb 15, 2016

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.

@makc makc changed the title Is sharing webgl context is not supported? Is sharing webgl context not supported? Feb 15, 2016
@makc
Copy link
Contributor Author

makc commented Feb 15, 2016

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

@makc
Copy link
Contributor Author

makc commented Feb 15, 2016

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

@makc
Copy link
Contributor Author

makc commented Feb 15, 2016

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 😉

@makc
Copy link
Contributor Author

makc commented Feb 15, 2016

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

@makc
Copy link
Contributor Author

makc commented Feb 16, 2016

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

@makc
Copy link
Contributor Author

makc commented Feb 16, 2016

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

@makc makc closed this as completed Feb 16, 2016
@mrdoob
Copy link
Owner

mrdoob commented Feb 16, 2016

@makc
Copy link
Contributor Author

makc commented Feb 16, 2016

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants