|
CGVIS Utils
|
Minimal OpenGL error utilities, exception type, and a debug GL() wrapper macro. More...
#include <iostream>#include <exception>Go to the source code of this file.
Classes | |
| class | GLException |
| Exception used for OpenGL-related failures. More... | |
| struct | Dimensions |
| Simple pixel/viewport dimensions with an aspect ratio helper. More... | |
Functions | |
| std::string | errorString (GLenum glerr) |
| Convert a GL error enum to a short string (e.g., "GL_INVALID_VALUE"). | |
| void | checkAndThrow () |
| Throw a GLException if glGetError() reports an error. | |
| void | checkAndThrowShader (GLuint shader) |
| Check a shader object's compile status and throw with its log on error. | |
| void | checkAndThrowProgram (GLuint program) |
| Check a program object's link status and throw with its log on error. | |
Debug-only error reporting support | |
| #define | MAX_GL_ERROR_COUNT 10 |
| Maximum number of consecutive glGetError() iterations before bailing. | |
| #define | GL(stmt) |
| Debug wrapper that flushes and reports GL errors around a statement. | |
| void | errorOut (const std::string &statement, const std::string &location, uint32_t line, const std::string &file, uint32_t errnum) |
| Internal printer used by the GL() macro to emit formatted errors. | |
Minimal OpenGL error utilities, exception type, and a debug GL() wrapper macro.
Declares a lightweight OpenGL error reporting facility:
GLException used to surface GL errors and shader/program log messages.Dimensions struct with a convenience aspect() getter.GL(stmt) macro that wraps GL calls to flush and report error codes before and after executing stmt.NDEBUG is defined, GL(stmt) compiles down to a plain stmt without extra error checks. | #define GL | ( | stmt | ) |
Debug wrapper that flushes and reports GL errors around a statement.
Usage:
In debug builds, existing GL errors are drained and reported ("before"), the statement is executed, then new errors are drained and reported ("in"). In release builds (NDEBUG defined), this expands to the bare statement.
| #define MAX_GL_ERROR_COUNT 10 |
Maximum number of consecutive glGetError() iterations before bailing.
Protects against pathological drivers/contexts where querying the error state itself may produce errors or never clears.
| void checkAndThrow | ( | ) |
Throw a GLException if glGetError() reports an error.
| void checkAndThrowProgram | ( | GLuint | program | ) |
Check a program object's link status and throw with its log on error.
| program | Program object name returned by glCreateProgram(). |
| void checkAndThrowShader | ( | GLuint | shader | ) |
Check a shader object's compile status and throw with its log on error.
| shader | Shader object name returned by glCreateShader(). |
| void errorOut | ( | const std::string & | statement, |
| const std::string & | location, | ||
| uint32_t | line, | ||
| const std::string & | file, | ||
| uint32_t | errnum ) |
Internal printer used by the GL() macro to emit formatted errors.
| statement | The stringified GL statement being executed. |
| location | One of "before" or "in" indicating when the error occurred. |
| line | Source line number. |
| file | Source file name. |
| errnum | Numeric GL error code. |
| std::string errorString | ( | GLenum | glerr | ) |
Convert a GL error enum to a short string (e.g., "GL_INVALID_VALUE").
| glerr | Error code returned by glGetError(). |