Added tech ENABLE_OPENGL_ERROR_LOGGING -> log opengl errors when SLIC3R_LOGLEVEL=5
This commit is contained in:
parent
6f4d24ab95
commit
ad7e7ae1cd
@ -48,5 +48,8 @@
|
||||
// Enable smoothing of objects normals
|
||||
#define ENABLE_SMOOTH_NORMALS (0 && ENABLE_2_3_0_ALPHA1)
|
||||
|
||||
// Enable error logging for OpenGL calls when SLIC3R_LOGLEVEL >= 5
|
||||
#define ENABLE_OPENGL_ERROR_LOGGING (1 && ENABLE_2_3_0_ALPHA1)
|
||||
|
||||
|
||||
#endif // _prusaslicer_technologies_h_
|
||||
|
@ -39,6 +39,32 @@
|
||||
|
||||
#include <Eigen/Dense>
|
||||
|
||||
#if ENABLE_OPENGL_ERROR_LOGGING
|
||||
void glAssertRecentCallImpl(const char* file_name, unsigned int line, const char* function_name)
|
||||
{
|
||||
#if NDEBUG
|
||||
if (Slic3r::get_logging_level() < 5)
|
||||
return;
|
||||
#endif // NDEBUG
|
||||
|
||||
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);
|
||||
}
|
||||
#else
|
||||
#ifdef HAS_GLSAFE
|
||||
void glAssertRecentCallImpl(const char *file_name, unsigned int line, const char *function_name)
|
||||
{
|
||||
@ -60,6 +86,7 @@ void glAssertRecentCallImpl(const char *file_name, unsigned int line, const char
|
||||
assert(false);
|
||||
}
|
||||
#endif
|
||||
#endif // ENABLE_OPENGL_ERROR_LOGGING
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
|
@ -10,6 +10,12 @@
|
||||
|
||||
#include <functional>
|
||||
|
||||
#if ENABLE_OPENGL_ERROR_LOGGING
|
||||
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)
|
||||
#define glcheck() do { glAssertRecentCallImpl(__FILE__, __LINE__, __FUNCTION__); } while (false)
|
||||
#else
|
||||
#ifndef NDEBUG
|
||||
#define HAS_GLSAFE
|
||||
#endif
|
||||
@ -24,6 +30,7 @@ inline void glAssertRecentCall() { }
|
||||
#define glsafe(cmd) cmd
|
||||
#define glcheck()
|
||||
#endif
|
||||
#endif // ENABLE_OPENGL_ERROR_LOGGING
|
||||
|
||||
namespace Slic3r {
|
||||
namespace GUI {
|
||||
|
Loading…
Reference in New Issue
Block a user