From 3987296b62933d30d4c5ff8b32b61b66adb60959 Mon Sep 17 00:00:00 2001 From: bubnikv Date: Wed, 27 Mar 2019 10:26:55 +0100 Subject: [PATCH] Improved glsafe macro to print out file name, line number and function name on OpenGL assert. --- src/slic3r/GUI/3DScene.cpp | 4 ++-- src/slic3r/GUI/3DScene.hpp | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/slic3r/GUI/3DScene.cpp b/src/slic3r/GUI/3DScene.cpp index 419f1baae7..58011730b6 100644 --- a/src/slic3r/GUI/3DScene.cpp +++ b/src/slic3r/GUI/3DScene.cpp @@ -32,7 +32,7 @@ #include "GUI.hpp" #ifdef HAS_GLSAFE -void glAssertRecentCallImpl() +void glAssertRecentCallImpl(const char *file_name, unsigned int line, const char *function_name) { GLenum err = glGetError(); if (err == GL_NO_ERROR) @@ -47,7 +47,7 @@ void glAssertRecentCallImpl() case GL_OUT_OF_MEMORY: sErr = "Out Of Memory"; break; default: sErr = "Unknown"; break; } - BOOST_LOG_TRIVIAL(error) << "OpenGL error " << (int)err << ": " << sErr; + BOOST_LOG_TRIVIAL(error) << "OpenGL error in " << file_name << ":" << line << ", function " << function_name << "() : " << (int)err << " - " << sErr; assert(false); } #endif diff --git a/src/slic3r/GUI/3DScene.hpp b/src/slic3r/GUI/3DScene.hpp index d571f862f2..e421997e5d 100644 --- a/src/slic3r/GUI/3DScene.hpp +++ b/src/slic3r/GUI/3DScene.hpp @@ -16,9 +16,9 @@ #endif #ifdef HAS_GLSAFE -extern void glAssertRecentCallImpl(); -inline void glAssertRecentCall() { glAssertRecentCallImpl(); } -#define glsafe(cmd) do { cmd; glAssertRecentCallImpl(); } while (false) +extern void glAssertRecentCallImpl(const char *file_name, unsigned int line, const char *function_name); +inline void glAssertRecentCall() { glAssertRecentCallImpl(__FILE__, __LINE__, __FUNCTION__); } +#define glsafe(cmd) do { cmd; glAssertRecentCallImpl(__FILE__, __LINE__, __FUNCTION__); } while (false) #else inline void glAssertRecentCall() { } #define glsafe(cmd) cmd