From df2ebadaa3c298370fce8d6a84d45b693683503d Mon Sep 17 00:00:00 2001 From: Leith Bade Date: Thu, 11 Dec 2014 00:14:46 +1100 Subject: Add missing CHECK_ERROR --- include/mbgl/platform/gl.hpp | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'include/mbgl/platform') diff --git a/include/mbgl/platform/gl.hpp b/include/mbgl/platform/gl.hpp index d20d3074b7..140c985042 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 -- cgit v1.2.1