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: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

* Fixed `invalid enumerant` error (1280) on call to `Viewer.show()` which occurs due to lingering OpenGL errors.

### Removed


Expand Down
10 changes: 10 additions & 0 deletions src/compas_viewer/renderer/renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,13 @@ def clear(self):
"""
GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT) # type: ignore

def _clear_opengl_errors(self):
while True:
error = GL.glGetError()
if error == GL.GL_NO_ERROR:
break
print(f"Cleared stale OpenGL error: {error}")

def initializeGL(self):
"""
Initialize the OpenGL canvas.
Expand All @@ -220,6 +227,9 @@ def initializeGL(self):
* https://doc.qt.io/qtforpython-6/PySide6/QtOpenGL/QOpenGLWindow.html#PySide6.QtOpenGL.PySide6.QtOpenGL.QOpenGLWindow.initializeGL

"""
# any stale errors caused e.g. by the windowing framework and were not cleared may trigger a crash as soon as we start issuing GL calls.
self._clear_opengl_errors()

GL.glClearColor(*self.viewer.config.renderer.backgroundcolor.rgba)
GL.glPolygonOffset(1.0, 1.0)
GL.glEnable(GL.GL_CULL_FACE)
Expand Down
Loading