diff --git a/src/common.h b/src/common.h index 8338bcd8..39124dcb 100644 --- a/src/common.h +++ b/src/common.h @@ -238,7 +238,8 @@ static const char *log_end = "\n"; } \ } // -#define GL_ERRLOG(...) \ +// GL_MAYBELOG() only logs if an OpenGL error occurred +#define GL_MAYBELOG(...) \ if (do_logging) { \ GLenum _glerr = 0; \ while ( (_glerr = safeGLGetError()) ) { \ @@ -256,24 +257,29 @@ static const char *log_end = "\n"; QUIT_FUNCTION(1); \ } while (0) +// GL_ERRQUIT() only logs/quits if an OpenGL error occurred #define GL_ERRQUIT(...) \ do { \ GLenum _glerr = 0; \ + GLenum _last_glerr = 0; \ while ( (_glerr = safeGLGetError()) ) { \ + _last_glerr = _glerr; \ _LOG(__VA_ARGS__); \ - QUIT_FUNCTION(_glerr); \ + } \ + if (_last_glerr) { \ + QUIT_FUNCTION(_last_glerr); \ } \ } while (0) #else // NDEBUG -#define ERRQUIT(...) \ - do { } while (0) - #define LOG(...) \ do { } while (0) -#define GL_ERRLOG(...) \ +#define GL_MAYBELOG(...) \ + do { } while (0) + +#define ERRQUIT(...) \ do { } while (0) #define GL_ERRQUIT(...) \ diff --git a/src/video/glhudmodel.c b/src/video/glhudmodel.c index ed96ff2e..0b7dbdb9 100644 --- a/src/video/glhudmodel.c +++ b/src/video/glhudmodel.c @@ -274,7 +274,7 @@ void glhud_renderDefault(GLModel *parent) { // Draw the object _HACKAROUND_GLDRAW_PRE(); glDrawElements(parent->primType, parent->numElements, parent->elementType, 0); - GL_ERRLOG("glhudparent render"); + GL_MAYBELOG("glhudparent render"); } void glhud_destroyDefault(GLModel *parent) { diff --git a/src/video/gltouchjoy.c b/src/video/gltouchjoy.c index f1307b4e..acaaf4a5 100644 --- a/src/video/gltouchjoy.c +++ b/src/video/gltouchjoy.c @@ -168,7 +168,7 @@ static void *_azimuth_create_model(GLModel *parent) { err = false; } while (0); - GL_ERRLOG("build Aziumth joystick"); + GL_MAYBELOG("build Aziumth joystick"); if (vtxSource) { glshader_destroySource(vtxSource); @@ -228,7 +228,7 @@ static void _azimuth_render(void) { // back to main framebuffer/quad program glUseProgram(mainShaderProgram); - GL_ERRLOG("Azimuth render"); + GL_MAYBELOG("Azimuth render"); } // ---------------------------------------------------------------------------- diff --git a/src/video/gltouchmenu.c b/src/video/gltouchmenu.c index af033826..9a20beca 100644 --- a/src/video/gltouchmenu.c +++ b/src/video/gltouchmenu.c @@ -444,7 +444,7 @@ static void gltouchmenu_setup(void) { isAvailable = true; - GL_ERRLOG("gltouchmenu_setup"); + GL_MAYBELOG("gltouchmenu_setup"); } static void gltouchmenu_render(void) { @@ -481,7 +481,7 @@ static void gltouchmenu_render(void) { glUniform1i(texSamplerLoc, TEXTURE_ID_TOUCHMENU); glhud_renderDefault(menu.model); - GL_ERRLOG("gltouchmenu_render"); + GL_MAYBELOG("gltouchmenu_render"); } static void gltouchmenu_reshape(int w, int h, bool landscape) { diff --git a/src/video/glvideo.c b/src/video/glvideo.c index 5eb591d1..0d0423ee 100644 --- a/src/video/glvideo.c +++ b/src/video/glvideo.c @@ -218,7 +218,7 @@ static void glvideo_init(void) { LOG("OOPS, no texture selector in shader : %d", alphaValue); } - GL_ERRLOG("build program"); + GL_MAYBELOG("build program"); // ---------------------------- // setup static OpenGL state @@ -240,7 +240,7 @@ static void glvideo_init(void) { video_render(); // Check for errors to make sure all of our setup went ok - GL_ERRLOG("finished initialization"); + GL_MAYBELOG("finished initialization"); if (glCheckFramebufferStatus != NULL) { GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER); @@ -393,7 +393,7 @@ static void glvideo_render(void) { _HACKAROUND_GLDRAW_PRE(); glDrawElements(GL_TRIANGLES, crtModel->numElements, crtModel->elementType, 0); - GL_ERRLOG("glvideo_render"); + GL_MAYBELOG("glvideo_render"); } static void glvideo_reshape(int w, int h, bool landscape) { diff --git a/src/video_util/modelUtil.c b/src/video_util/modelUtil.c index 9410a5c0..0c6f9c33 100644 --- a/src/video_util/modelUtil.c +++ b/src/video_util/modelUtil.c @@ -388,7 +388,7 @@ static void _quadCreateVAOAndVBOs(GLModel *model) { FREE(model->texCoords); #endif - GL_ERRLOG("quad creation of VAO/VBOs"); + GL_MAYBELOG("quad creation of VAO/VBOs"); } static GLuint _quadCreateTexture(GLModel *model) { @@ -412,7 +412,7 @@ static GLuint _quadCreateTexture(GLModel *model) { // register texture with OpenGL glTexImage2D(GL_TEXTURE_2D, /*level*/0, /*internal format*/TEX_FORMAT_INTERNAL, model->texWidth, model->texHeight, /*border*/0, TEX_FORMAT, TEX_TYPE, NULL); - GL_ERRLOG("quad texture creation"); + GL_MAYBELOG("quad texture creation"); return texName; } @@ -546,7 +546,7 @@ GLModel *mdlCreateQuad(GLModelParams_s parms, GLCustom clazz) { model->custom->destroy = clazz.destroy; } - GL_ERRLOG("quad creation"); + GL_MAYBELOG("quad creation"); return model; } while (0); diff --git a/src/video_util/sourceUtil.c b/src/video_util/sourceUtil.c index ab676f19..8be3ff95 100644 --- a/src/video_util/sourceUtil.c +++ b/src/video_util/sourceUtil.c @@ -100,7 +100,7 @@ GLuint glshader_buildProgram(demoSource *vertexSource, demoSource *fragmentSourc char *shaderLangVersion = (char *)glGetString(GL_SHADING_LANGUAGE_VERSION); if (shaderLangVersion == NULL) { - ERRQUIT("shader toolchain unavailable"); + GL_ERRQUIT("shader toolchain unavailable"); } #if TARGET_OS_IPHONE sscanf(shaderLangVersion, "OpenGL ES GLSL ES %f", &glLanguageVersion); @@ -247,7 +247,7 @@ GLuint glshader_buildProgram(demoSource *vertexSource, demoSource *fragmentSourc return 0; } - GL_ERRLOG("build program"); + GL_MAYBELOG("build program"); return prgName; }