From 042d7652ae408cd0501e4bcb860a51fb96199a33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20=C5=81u=C5=BCy=C5=84ski?= Date: Sat, 31 Jan 2026 20:45:36 +0100 Subject: [PATCH] Replace gluErrorString with ErrorString --- cyGL.h | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/cyGL.h b/cyGL.h index c941ec7..7fac291 100644 --- a/cyGL.h +++ b/cyGL.h @@ -158,6 +158,9 @@ class GL //! Prints the OpenGL version to the given stream. static void PrintVersion(std::ostream *outStream=&std::cout); + //! Returns OpenGL error in text format. + static const char* ErrorString(GLenum error); + //! Checks all previously triggered OpenGL errors and prints them to the given output stream. static void CheckError( char const *sourcefile, int line, char const *call=nullptr, std::ostream *outStream=&std::cout ); @@ -1361,13 +1364,35 @@ inline void GL::PrintVersion(std::ostream *outStream) } } +inline const char *GL::ErrorString(GLenum error) { + switch (error) { + case GL_NO_ERROR: + return "GL_NO_ERROR: No error has been recorded"; + case GL_INVALID_ENUM: + return "GL_INVALID_ENUM: An unacceptable value is specified for an enumerated argument. The offending command is ignored and has no other side effect than to set the error flag"; + case GL_INVALID_VALUE: + return "GL_INVALID_VALUE: A numeric argument is out of range. The offending command is ignored and has no other side effect than to set the error flag"; + case GL_INVALID_OPERATION: + return "GL_INVALID_OPERATION: The specified operation is not allowed in the current state. The offending command is ignored and has no other side effect than to set the error flag"; + case GL_STACK_OVERFLOW: + return "GL_STACK_OVERFLOW: An attempt has been made to perform an operation that would cause an internal stack to overflow"; + case GL_STACK_UNDERFLOW: + return "GL_STACK_UNDERFLOW: An attempt has been made to perform an operation that would cause an internal stack to underflow"; + case GL_OUT_OF_MEMORY: + return "GL_OUT_OF_MEMORY: There is not enough memory left to execute the command. The state of the GL is undefined, except for the state of the error flags, after this error is recorded"; + default: + return "Unknown error"; + } +} + + inline void GL::CheckError( char const *sourcefile, int line, char const *call, std::ostream *outStream ) { GLenum error; while ( (error = glGetError()) != GL_NO_ERROR) { *outStream << "OpenGL ERROR: " << sourcefile << " (line " << line << "): "; if ( call ) *outStream << call << " triggered "; - *outStream << gluErrorString(error) << std::endl; + *outStream << ErrorString(error) << std::endl; } }