@@ -132,12 +132,36 @@ def _extract_gl_errors() -> Iterator[int]:
132132 yield err
133133
134134
135+ def _gl_error_str (code : int ) -> str :
136+ match code :
137+ case GL .GL_NO_ERROR :
138+ return "GL_NO_ERROR"
139+ case GL .GL_INVALID_ENUM :
140+ return "GL_INVALID_ENUM"
141+ case GL .GL_INVALID_VALUE :
142+ return "GL_INVALID_VALUE"
143+ case GL .GL_INVALID_OPERATION :
144+ return "GL_INVALID_OPERATION"
145+ case GL .GL_STACK_OVERFLOW :
146+ return "GL_STACK_OVERFLOW"
147+ case GL .GL_STACK_UNDERFLOW :
148+ return "GL_STACK_UNDERFLOW"
149+ case GL .GL_OUT_OF_MEMORY :
150+ return "GL_OUT_OF_MEMORY"
151+ case GL .GL_INVALID_FRAMEBUFFER_OPERATION :
152+ return "GL_INVALID_FRAMEBUFFER_OPERATION"
153+ case GL .GL_CONTEXT_LOST :
154+ return "GL_CONTEXT_LOST"
155+ case _:
156+ return f"0x{ code :X} "
157+
158+
135159def _warn_unhandled_gl_errors ():
136160 # Should be called as soon as possible after entering Python from the core;
137161 # unhandled OpenGL errors from the core must not hamper the frontend.
138162 unhandled_errors = tuple (_extract_gl_errors ())
139163 if unhandled_errors :
140- error_string = ", " .join (f"0x { e :X } " for e in unhandled_errors )
164+ error_string = ", " .join (_gl_error_str ( e ) for e in unhandled_errors )
141165 warnings .warn (f"Core did not handle the following OpenGL errors: { error_string } " )
142166
143167
0 commit comments