From: bones_was_here Date: Thu, 21 Jul 2022 23:49:16 +0000 (+1000) Subject: Improve DEBUGGL X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=545554989bf17036e78d7b5ea2379b70269d4b30;p=xonotic%2Fdarkplaces.git Improve DEBUGGL glGetError() must be called in a loop to retrieve and reset multiple error flags. Signed-off-by: bones_was_here --- diff --git a/gl_backend.c b/gl_backend.c index ad4a0cdc..3b511704 100644 --- a/gl_backend.c +++ b/gl_backend.c @@ -27,9 +27,7 @@ float gl_modelviewprojection16f[16]; qbool gl_modelmatrixchanged; #ifdef DEBUGGL -int gl_errornumber = 0; - -void GL_PrintError(int errornumber, const char *filename, int linenumber) +void GL_PrintError(GLenum errornumber, const char *filename, unsigned int linenumber) { switch(errornumber) { diff --git a/glquake.h b/glquake.h index 21da68bc..e3f8f6d0 100644 --- a/glquake.h +++ b/glquake.h @@ -29,20 +29,6 @@ //==================================================== -//#define DEBUGGL - -#ifdef DEBUGGL -#ifdef USE_GLES2 -#define CHECKGLERROR {if (gl_paranoid.integer){if (gl_printcheckerror.integer) Con_Printf("CHECKGLERROR at %s:%d\n", __FILE__, __LINE__);gl_errornumber = glGetError();if (gl_errornumber) GL_PrintError(gl_errornumber, __FILE__, __LINE__);}} -#else -#define CHECKGLERROR {if (gl_paranoid.integer){if (gl_printcheckerror.integer) Con_Printf("CHECKGLERROR at %s:%d\n", __FILE__, __LINE__);gl_errornumber = qglGetError ? qglGetError() : 0;if (gl_errornumber) GL_PrintError(gl_errornumber, __FILE__, __LINE__);}} -#endif //USE_GLES2 -extern int gl_errornumber; -void GL_PrintError(int errornumber, const char *filename, int linenumber); -#else -#define CHECKGLERROR -#endif //DEBUGGL - #ifndef USE_GLES2 // this is defined if the SDL_opengl.h is included #ifndef GL_ZERO @@ -1050,4 +1036,25 @@ extern void (GLAPIENTRY *qglViewport)(GLint x, GLint y, GLsizei width, GLsizei h #define GL_HALF_FLOAT 0x140B #define GL_NUM_EXTENSIONS 0x821D + +//==================================================== + +//#define DEBUGGL + +#ifdef DEBUGGL +void GL_PrintError(GLenum errornumber, const char *filename, unsigned int linenumber); +#define CHECKGLERROR { \ + if (gl_paranoid.integer) { \ + GLenum gl_errornumber; \ + if (gl_printcheckerror.integer) \ + Con_Printf("CHECKGLERROR at %s:%d\n", __FILE__, __LINE__); \ + if (qglGetError) /* bones_was_here: is this pointer check still necessary? */ \ + while ((gl_errornumber = qglGetError())) \ + GL_PrintError(gl_errornumber, __FILE__, __LINE__); \ + }} +#else +#define CHECKGLERROR +#endif //DEBUGGL + + #endif //GLQUAKE_H