From df2ebadaa3c298370fce8d6a84d45b693683503d Mon Sep 17 00:00:00 2001 From: Leith Bade Date: Thu, 11 Dec 2014 00:14:46 +1100 Subject: [PATCH] Add missing CHECK_ERROR --- include/mbgl/platform/gl.hpp | 23 +++++++++++------------ src/mbgl/renderer/prerendered_texture.cpp | 8 ++++---- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/include/mbgl/platform/gl.hpp b/include/mbgl/platform/gl.hpp index d20d3074b..140c98504 100644 --- a/include/mbgl/platform/gl.hpp +++ b/include/mbgl/platform/gl.hpp @@ -36,6 +36,13 @@ struct Error : ::std::runtime_error { const GLenum code; }; +void checkError(const char *cmd, const char *file, int line); + +#if defined(DEBUG) +#define MBGL_CHECK_ERROR(cmd) ([&]() { struct _ { inline ~_() { ::mbgl::gl::checkError(#cmd, __FILE__, __LINE__); } } _; return cmd; }()) +#else +#define MBGL_CHECK_ERROR(cmd) (cmd) +#endif // GL_KHR_debug / GL_ARB_debug_output #define GL_DEBUG_OUTPUT_SYNCHRONOUS 0x8242 @@ -162,9 +169,9 @@ extern PFNGLPROGRAMPARAMETERIPROC ProgramParameteri; // static int indent = 0; inline void start_group(const std::string &str) { if (gl::PushDebugGroup != nullptr) { - gl::PushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0, GLsizei(str.size()), str.c_str()); + MBGL_CHECK_ERROR(gl::PushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0, GLsizei(str.size()), str.c_str())); } else if (gl::PushGroupMarkerEXT != nullptr) { - gl::PushGroupMarkerEXT(GLsizei(str.size()), str.c_str()); + MBGL_CHECK_ERROR(gl::PushGroupMarkerEXT(GLsizei(str.size()), str.c_str())); } // fprintf(stderr, "%s%s\n", std::string(indent * 4, ' ').c_str(), str.c_str()); // indent++; @@ -172,9 +179,9 @@ inline void start_group(const std::string &str) { inline void end_group() { if (gl::PopDebugGroup != nullptr) { - gl::PopDebugGroup(); + MBGL_CHECK_ERROR(gl::PopDebugGroup()); } else if (gl::PopGroupMarkerEXT != nullptr) { - gl::PopGroupMarkerEXT(); + MBGL_CHECK_ERROR(gl::PopGroupMarkerEXT()); } // indent--; } @@ -188,8 +195,6 @@ struct group { ~group() { end_group(); }; }; -void checkError(const char *cmd, const char *file, int line); - } } @@ -198,10 +203,4 @@ void checkError(const char *cmd, const char *file, int line); #define glDepthRange glDepthRangef #endif -#if defined(DEBUG) -#define MBGL_CHECK_ERROR(cmd) ([&]() { struct _ { inline ~_() { ::mbgl::gl::checkError(#cmd, __FILE__, __LINE__); } } _; return cmd; }()) -#else -#define MBGL_CHECK_ERROR(cmd) (cmd) -#endif - #endif diff --git a/src/mbgl/renderer/prerendered_texture.cpp b/src/mbgl/renderer/prerendered_texture.cpp index 955f5b11b..6d8af3c3b 100644 --- a/src/mbgl/renderer/prerendered_texture.cpp +++ b/src/mbgl/renderer/prerendered_texture.cpp @@ -18,12 +18,12 @@ PrerenderedTexture::~PrerenderedTexture() { } if (fboDepth != 0) { - glDeleteRenderbuffers(1, &fboDepth); + MBGL_CHECK_ERROR(glDeleteRenderbuffers(1, &fboDepth)); fboDepth = 0; } if (fboStencil != 0) { - glDeleteRenderbuffers(1, &fboStencil); + MBGL_CHECK_ERROR(glDeleteRenderbuffers(1, &fboStencil)); fboStencil = 0; } @@ -99,8 +99,8 @@ void PrerenderedTexture::bindFramebuffer() { MBGL_CHECK_ERROR(glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, fboDepth)); #endif } else { - glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, fboDepth); - glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, fboStencil); + MBGL_CHECK_ERROR(glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, fboDepth)); + MBGL_CHECK_ERROR(glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, fboStencil)); } GLenum status = MBGL_CHECK_ERROR(glCheckFramebufferStatus(GL_FRAMEBUFFER));