From 4373c03823b6348bc4539b6e1515fff967a4ab63 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Sun, 8 Nov 2020 11:48:36 +0100 Subject: [PATCH] GLWRAP for debugging GL errors --- glhr.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/glhr.cpp b/glhr.cpp index bf757455..354da23b 100644 --- a/glhr.cpp +++ b/glhr.cpp @@ -59,6 +59,24 @@ EX void glError(const char* GLcall, const char* file, const int line) { } } +#if HDR +struct glwrap { + const char* msg; + int line; + void act(const char *when); + glwrap(const char *m, int l) : msg(m), line(l) { act("before"); } + ~glwrap() { act("after"); } + }; +#define GLWRAP glwrap w##__line(__FILE__, __LINE__) +#endif + +void glwrap::act(const char *when) { + GLenum errCode = glGetError(); + if(errCode!=GL_NO_ERROR) { + println(hlog, format("GL error %i %s: %s:%i", errCode, when, msg, line)); + } + } + #if HDR #if CAP_SHADER && CAP_NOSHADER #define WITHSHADER(x, y) if(glhr::noshaders) y else x