Reduced ugly copy / paste for ENABLE_OPENGL_ERROR_LOGGING
This commit is contained in:
parent
3e0e537b7a
commit
1e3290fee1
2 changed files with 17 additions and 44 deletions
|
@ -39,13 +39,15 @@
|
||||||
|
|
||||||
#include <Eigen/Dense>
|
#include <Eigen/Dense>
|
||||||
|
|
||||||
#if ENABLE_OPENGL_ERROR_LOGGING
|
#ifdef HAS_GLSAFE
|
||||||
void glAssertRecentCallImpl(const char* file_name, unsigned int line, const char* function_name)
|
void glAssertRecentCallImpl(const char* file_name, unsigned int line, const char* function_name)
|
||||||
{
|
{
|
||||||
#if NDEBUG
|
#if defined(NDEBUG) && ENABLE_OPENGL_ERROR_LOGGING
|
||||||
|
// In release mode, if OpenGL debugging was forced by ENABLE_OPENGL_ERROR_LOGGING, only show
|
||||||
|
// OpenGL errors if sufficiently high loglevel.
|
||||||
if (Slic3r::get_logging_level() < 5)
|
if (Slic3r::get_logging_level() < 5)
|
||||||
return;
|
return;
|
||||||
#endif // NDEBUG
|
#endif // ENABLE_OPENGL_ERROR_LOGGING
|
||||||
|
|
||||||
GLenum err = glGetError();
|
GLenum err = glGetError();
|
||||||
if (err == GL_NO_ERROR)
|
if (err == GL_NO_ERROR)
|
||||||
|
@ -64,29 +66,7 @@ void glAssertRecentCallImpl(const char* file_name, unsigned int line, const char
|
||||||
BOOST_LOG_TRIVIAL(error) << "OpenGL error in " << file_name << ":" << line << ", function " << function_name << "() : " << (int)err << " - " << sErr;
|
BOOST_LOG_TRIVIAL(error) << "OpenGL error in " << file_name << ":" << line << ", function " << function_name << "() : " << (int)err << " - " << sErr;
|
||||||
assert(false);
|
assert(false);
|
||||||
}
|
}
|
||||||
#else
|
#endif // HAS_GLSAFE
|
||||||
#ifdef HAS_GLSAFE
|
|
||||||
void glAssertRecentCallImpl(const char *file_name, unsigned int line, const char *function_name)
|
|
||||||
{
|
|
||||||
GLenum err = glGetError();
|
|
||||||
if (err == GL_NO_ERROR)
|
|
||||||
return;
|
|
||||||
const char *sErr = 0;
|
|
||||||
switch (err) {
|
|
||||||
case GL_INVALID_ENUM: sErr = "Invalid Enum"; break;
|
|
||||||
case GL_INVALID_VALUE: sErr = "Invalid Value"; break;
|
|
||||||
// be aware that GL_INVALID_OPERATION is generated if glGetError is executed between the execution of glBegin and the corresponding execution of glEnd
|
|
||||||
case GL_INVALID_OPERATION: sErr = "Invalid Operation"; break;
|
|
||||||
case GL_STACK_OVERFLOW: sErr = "Stack Overflow"; break;
|
|
||||||
case GL_STACK_UNDERFLOW: sErr = "Stack Underflow"; break;
|
|
||||||
case GL_OUT_OF_MEMORY: sErr = "Out Of Memory"; break;
|
|
||||||
default: sErr = "Unknown"; break;
|
|
||||||
}
|
|
||||||
BOOST_LOG_TRIVIAL(error) << "OpenGL error in " << file_name << ":" << line << ", function " << function_name << "() : " << (int)err << " - " << sErr;
|
|
||||||
assert(false);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#endif // ENABLE_OPENGL_ERROR_LOGGING
|
|
||||||
|
|
||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
|
|
||||||
|
|
|
@ -10,27 +10,20 @@
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
#if ENABLE_OPENGL_ERROR_LOGGING
|
#if ENABLE_OPENGL_ERROR_LOGGING || ! defined(NDEBUG)
|
||||||
extern void glAssertRecentCallImpl(const char* file_name, unsigned int line, const char* function_name);
|
#define HAS_GLSAFE
|
||||||
inline void glAssertRecentCall() { glAssertRecentCallImpl(__FILE__, __LINE__, __FUNCTION__); }
|
|
||||||
#define glsafe(cmd) do { cmd; glAssertRecentCallImpl(__FILE__, __LINE__, __FUNCTION__); } while (false)
|
|
||||||
#define glcheck() do { glAssertRecentCallImpl(__FILE__, __LINE__, __FUNCTION__); } while (false)
|
|
||||||
#else
|
|
||||||
#ifndef NDEBUG
|
|
||||||
#define HAS_GLSAFE
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAS_GLSAFE
|
#ifdef HAS_GLSAFE
|
||||||
extern void glAssertRecentCallImpl(const char *file_name, unsigned int line, const char *function_name);
|
extern void glAssertRecentCallImpl(const char *file_name, unsigned int line, const char *function_name);
|
||||||
inline void glAssertRecentCall() { glAssertRecentCallImpl(__FILE__, __LINE__, __FUNCTION__); }
|
inline void glAssertRecentCall() { glAssertRecentCallImpl(__FILE__, __LINE__, __FUNCTION__); }
|
||||||
#define glsafe(cmd) do { cmd; glAssertRecentCallImpl(__FILE__, __LINE__, __FUNCTION__); } while (false)
|
#define glsafe(cmd) do { cmd; glAssertRecentCallImpl(__FILE__, __LINE__, __FUNCTION__); } while (false)
|
||||||
#define glcheck() do { glAssertRecentCallImpl(__FILE__, __LINE__, __FUNCTION__); } while (false)
|
#define glcheck() do { glAssertRecentCallImpl(__FILE__, __LINE__, __FUNCTION__); } while (false)
|
||||||
#else
|
#else // HAS_GLSAFE
|
||||||
inline void glAssertRecentCall() { }
|
inline void glAssertRecentCall() { }
|
||||||
#define glsafe(cmd) cmd
|
#define glsafe(cmd) cmd
|
||||||
#define glcheck()
|
#define glcheck()
|
||||||
#endif
|
#endif // HAS_GLSAFE
|
||||||
#endif // ENABLE_OPENGL_ERROR_LOGGING
|
|
||||||
|
|
||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
namespace GUI {
|
namespace GUI {
|
||||||
|
|
Loading…
Reference in a new issue