mmatl / pyrender

Easy-to-use glTF 2.0-compliant OpenGL renderer for visualization of 3D scenes.
http://pyrender.readthedocs.io/
MIT License
1.27k stars 219 forks source link

pyrender pybullet.GUI rendering issue on MacOS #187

Open shivanimall opened 3 years ago

shivanimall commented 3 years ago

Hello,

I am on MacOS. I am using pybullet.GUI to connect to physics client as follows: self.physicsClient = pb.connect(pb.GUI) In addition, I am using pyrender to render some other images in parallel. following pyrender code is called and results in the shown error:

    color, depth = self.r.render(self.scene)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pyrender/offscreen.py", line 102, in render
    retval = self._renderer.render(scene, flags, seg_node_map)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pyrender/renderer.py", line 125, in render
    self._update_context(scene, flags)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pyrender/renderer.py", line 738, in _update_context
    p._add_to_context()
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pyrender/primitive.py", line 324, in _add_to_context
    self._vaid = glGenVertexArrays(1)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/OpenGL/latebind.py", line 41, in __call__
    return self._finalCall( *args, **named )
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/OpenGL/wrapper.py", line 674, in wrapperCall
    raise err
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/OpenGL/wrapper.py", line 667, in wrapperCall
    result = wrappedOperation( *cArguments )
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/OpenGL/error.py", line 228, in glCheckError
    raise GLError(
OpenGL.error.GLError: GLError(
    err = 1282,
    description = b'invalid operation',
    baseOperation = glGenVertexArrays,
    pyArgs = (1, <object object at 0x11c16d200>),
    cArgs = (1, array([3], dtype=uint32)),
    cArguments = (1, array([3], dtype=uint32))
)

This results from conflicting flags between the two libraries. Can you please suggest a fix? Really hoping to resolve this since I have to run my code at scale. Thank you, please let me know if you need more details or if anything is unclear.

shivanimall commented 3 years ago

https://github.com/bulletphysics/bullet3/discussions/3844 in case you have support for this already, please let me know!

shivanimall commented 3 years ago

Hi @mmatl - I saw that viewer.py has option to run_in_thread I am wondering if there is a similar option for renderer.py

otherwise, where would you recommend adding the threading code to start renderer in a different thread to avoid running into any other issues I may be unaware of?