Sat, 09 Aug 2025 14:36:39 +0200
fix incorrect file/line information when catching GL errors
src/ascension/error.h | file | annotate | diff | comparison | revisions | |
src/error.c | file | annotate | diff | comparison | revisions |
--- a/src/ascension/error.h Fri Aug 08 20:51:19 2025 +0200 +++ b/src/ascension/error.h Sat Aug 09 14:36:39 2025 +0200 @@ -32,7 +32,11 @@ #define asc_error(...) asc_error_(__FILE__, __LINE__, __VA_ARGS__) -void asc_error_gl(unsigned code, const char *message); +void asc_error_gl_(const char *file, unsigned line, unsigned code, const char *message); + +#define asc_error_gl(code, message) asc_error_gl_(__FILE__, __LINE__, code, message) + +int asc_error_catch_gl_(const char *file, unsigned line, const char *message); /** * Catches all OpenGL errors. @@ -42,7 +46,7 @@ * @param message the text to include in the error messages * @returns non-zero if any error was caught and zero when no error exists */ -int asc_error_catch_gl(const char *message); +#define asc_error_catch_gl(message) asc_error_catch_gl_(__FILE__, __LINE__, message) bool asc_has_error(void);
--- a/src/error.c Fri Aug 08 20:51:19 2025 +0200 +++ b/src/error.c Sat Aug 09 14:36:39 2025 +0200 @@ -78,7 +78,7 @@ asc_clear_flag(asc_context.flags, ASC_FLAG_HAS_ERROR); } -void asc_error_gl(unsigned code, const char *message) { +void asc_error_gl_(const char *file, unsigned line, unsigned code, const char *message) { const char *glerr; switch(code) { case GL_NO_ERROR: @@ -107,15 +107,15 @@ default: glerr = "unknown GL error"; } - asc_error("%s - GL Error: %s", message, glerr); + asc_error_(file, line, "%s - GL Error: %s", message, glerr); } -int asc_error_catch_gl(const char *message) { +int asc_error_catch_gl_(const char *file, unsigned line, const char *message) { // TODO: a printf-like signature does not hurt GLenum error; int ret = 0; while ((error = glGetError()) != GL_NO_ERROR) { - asc_error_gl(error, message); + asc_error_gl_(file, line, error, message); ret = 1; } return ret;