From 3b2e7cc2347d88dbd8d7697a7cbd8354e7728fc0 Mon Sep 17 00:00:00 2001 From: Charles Date: Tue, 19 May 2020 21:41:09 +0200 Subject: Added OpenGL boilerplate --- src/error.c | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) (limited to 'src/error.c') diff --git a/src/error.c b/src/error.c index 92e3a71..1e2975f 100644 --- a/src/error.c +++ b/src/error.c @@ -7,7 +7,42 @@ void error_check_sdl(const char *code, const char *filename, int line_num) err = SDL_GetError(); if (*err == '\0') return ; - SDL_Log("[ERROR SDL] %s\n\t(%s) at %s:%d", err, code, filename, line_num); + SDL_Log("[ERROR SDL] %s\n\t(%s) at %s:%d\n", err, code, filename, line_num); SDL_Quit(); exit(EXIT_FAILURE); } + +void error_clear_gl(void) +{ + while (glGetError() != GL_NO_ERROR) + ; +} + +void error_check_gl(const char *code, const char *filename, int line_num) +{ + GLenum err; + bool occured; + char *err_str = ""; + + occured = false; + while ((err = glGetError()) != GL_NO_ERROR) + { + switch (err) + { + case GL_INVALID_OPERATION: + err_str = "GL_INVALID_OPERATION"; + break; + case GL_INVALID_VALUE: + err_str = "GL_INVALID_VALUE"; + break; + case GL_INVALID_ENUM: + err_str = "GL_INVALID_ENUM"; + break; + } + fprintf(stderr, "[ERROR OPENGL] (%d) %s\n\t(%s) at %s:%d\n", + err, err_str, code, filename, line_num); + occured = true; + } + if (occured) + exit(EXIT_FAILURE); +} -- cgit