Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion genesis/ext/pyrender/primitive.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ def _remove_from_context(self):
glDeleteVertexArrays(1, [self._vaid])
glDeleteBuffers(len(self._buffers), list(self._buffers.values()))
self._vaid = None
self._buffers = {}
self._buffers.clear()

def _in_context(self):
return self._vaid is not None
Expand Down
24 changes: 13 additions & 11 deletions genesis/ext/pyrender/renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -609,24 +609,26 @@ def _bind_and_draw_primitive(self, primitive, pose, program, flags, env_idx):
###########################################################################

def _update_context(self, scene, flags):
# Update meshes
scene_meshes = scene.meshes
# Get existing and new meshes
scene_meshes_new = scene.meshes.copy()
scene_meshes_old = self._meshes

# Add new meshes to context
for mesh in scene_meshes - self._meshes:
for p in mesh.primitives:
p._add_to_context()

# Remove old meshes from context
for mesh in self._meshes - scene_meshes:
# Remove from context old meshes that are now irrelevant
for mesh in scene_meshes_old - scene_meshes_new:
for p in mesh.primitives:
p.delete()

self._meshes = scene_meshes.copy()
# Update set of meshes right away, so that the context can be cleaned up correctly in case of failure
self._meshes = scene_meshes_new

# Add new meshes to context
for mesh in scene_meshes_new - scene_meshes_old:
for p in mesh.primitives:
p._add_to_context()

# Update mesh textures
mesh_textures = set()
for m in scene_meshes:
for m in scene_meshes_new:
for p in m.primitives:
mesh_textures |= p.material.textures

Expand Down
2 changes: 1 addition & 1 deletion genesis/ext/pyrender/viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1237,7 +1237,7 @@ def start(self, auto_refresh=True):
except OpenGL.error.Error:
# Invalid OpenGL context. Closing before raising.
self.close()
return
raise

# At this point, we are all set to display the graphical window, finally!
self.set_visible(True)
Expand Down