File tree Expand file tree Collapse file tree 2 files changed +12
-0
lines changed
src/compas_viewer/renderer Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111
1212### Changed
1313
14+ * Fixed ` invalid enumerant ` error (1280) on call to ` Viewer.show() ` which occurs due to lingering OpenGL errors.
15+
1416### Removed
1517
1618
Original file line number Diff line number Diff line change @@ -205,6 +205,13 @@ def clear(self):
205205 """
206206 GL .glClear (GL .GL_COLOR_BUFFER_BIT | GL .GL_DEPTH_BUFFER_BIT ) # type: ignore
207207
208+ def _clear_opengl_errors (self ):
209+ while True :
210+ error = GL .glGetError ()
211+ if error == GL .GL_NO_ERROR :
212+ break
213+ print (f"Cleared stale OpenGL error: { error } " )
214+
208215 def initializeGL (self ):
209216 """
210217 Initialize the OpenGL canvas.
@@ -220,6 +227,9 @@ def initializeGL(self):
220227 * https://doc.qt.io/qtforpython-6/PySide6/QtOpenGL/QOpenGLWindow.html#PySide6.QtOpenGL.PySide6.QtOpenGL.QOpenGLWindow.initializeGL
221228
222229 """
230+ # 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.
231+ self ._clear_opengl_errors ()
232+
223233 GL .glClearColor (* self .viewer .config .renderer .backgroundcolor .rgba )
224234 GL .glPolygonOffset (1.0 , 1.0 )
225235 GL .glEnable (GL .GL_CULL_FACE )
You can’t perform that action at this time.
0 commit comments