From b99c616c236c9b4130a0855b09d79df9511483a3 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Fri, 5 Feb 2016 08:36:54 +0100 Subject: [PATCH] Re-implementation of opengl_check_errors --- GraphicsView/include/CGAL/Qt/debug.h | 5 ++++ GraphicsView/include/CGAL/Qt/debug_impl.h | 26 +++++++++++++++++-- Mesh_3/demo/Mesh_3/Volume_plane.h | 20 ++------------ .../Plugins/Mesh_3_plugin/Volume_plane.h | 21 ++------------- Surface_mesher/demo/Surface_mesher/volume.cpp | 21 ++------------- 5 files changed, 35 insertions(+), 58 deletions(-) diff --git a/GraphicsView/include/CGAL/Qt/debug.h b/GraphicsView/include/CGAL/Qt/debug.h index 8ff5f1d44f6..e5ee8699473 100644 --- a/GraphicsView/include/CGAL/Qt/debug.h +++ b/GraphicsView/include/CGAL/Qt/debug.h @@ -41,6 +41,11 @@ CGAL_QT_EXPORT void traverse_resources(const QString& name, const QString& dirname = QString(), int indent = 0); +/** + * Call this in the end of an OpenGL implementation to check if it returns errors. + */ +CGAL_QT_EXPORT void opengl_check_errors(unsigned int line); + } // namespace Qt } // namespace CGAL diff --git a/GraphicsView/include/CGAL/Qt/debug_impl.h b/GraphicsView/include/CGAL/Qt/debug_impl.h index e7bf2904420..21a9ee8fc4e 100644 --- a/GraphicsView/include/CGAL/Qt/debug_impl.h +++ b/GraphicsView/include/CGAL/Qt/debug_impl.h @@ -27,9 +27,8 @@ #include #include - #include - +#include namespace CGAL { namespace Qt { @@ -56,5 +55,28 @@ void traverse_resources(const QString& name, const QString& dirname, int indent) } } +CGAL_INLINE_FUNCTION +void opengl_check_errors(unsigned int line) +{ + GLenum error = ::glGetError(); + while (error != GL_NO_ERROR) + { + if(error == GL_INVALID_ENUM) + std::cerr << "An unacceptable value is specified for an enumerated argument." << "@" << line << std::endl; + if(error == GL_INVALID_VALUE) + std::cerr << "A numeric argument is out of range." << "@" << line << std::endl; + if(error == GL_INVALID_OPERATION) + std::cerr << "The specified operation is not allowed in the current state." << "@" << line << std::endl; + if(error == GL_INVALID_FRAMEBUFFER_OPERATION) + std::cerr << "The framebuffer object is not complete." << "@" << line << std::endl; + if(error == GL_OUT_OF_MEMORY) + std::cerr << "There is not enough memory left to execute the command." << "@" << line << std::endl; + if(error == GL_STACK_UNDERFLOW) + std::cerr << "An attempt has been made to perform an operation that would cause an internal stack to underflow." << "@" << line << std::endl; + if(error == GL_STACK_OVERFLOW) + std::cerr << "An attempt has been made to perform an operation that would cause an internal stack to overflow." << "@" << line << std::endl; + error = ::glGetError(); + } +} } // namesapce Qt } // namespace CGAL diff --git a/Mesh_3/demo/Mesh_3/Volume_plane.h b/Mesh_3/demo/Mesh_3/Volume_plane.h index 9ef4e9df065..2f7e89a56c3 100644 --- a/Mesh_3/demo/Mesh_3/Volume_plane.h +++ b/Mesh_3/demo/Mesh_3/Volume_plane.h @@ -13,28 +13,12 @@ #include #include #include +#include #if !defined(NDEBUG) inline void printGlError(unsigned int line) { - GLenum error = glGetError(); - if(error != GL_NO_ERROR) - { - if(error == GL_INVALID_ENUM) - std::cerr << "An unacceptable value is specified for an enumerated argument." << "@" << line << std::endl; - if(error == GL_INVALID_VALUE) - std::cerr << "A numeric argument is out of range." << "@" << line << std::endl; - if(error == GL_INVALID_OPERATION) - std::cerr << "The specified operation is not allowed in the current state." << "@" << line << std::endl; - if(error == GL_INVALID_FRAMEBUFFER_OPERATION) - std::cerr << "The framebuffer object is not complete." << "@" << line << std::endl; - if(error == GL_OUT_OF_MEMORY) - std::cerr << "There is not enough memory left to execute the command." << "@" << line << std::endl; - if(error == GL_STACK_UNDERFLOW) - std::cerr << "An attempt has been made to perform an operation that would cause an internal stack to underflow." << "@" << line << std::endl; - if(error == GL_STACK_OVERFLOW) - std::cerr << "An attempt has been made to perform an operation that would cause an internal stack to overflow." << "@" << line << std::endl; - } + CGAL::Qt::opengl_check_errors(line); } #else inline diff --git a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3_plugin/Volume_plane.h b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3_plugin/Volume_plane.h index 8ce7d545a56..d01b02bb6b8 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3_plugin/Volume_plane.h +++ b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3_plugin/Volume_plane.h @@ -14,31 +14,14 @@ #include #include #include +#include using namespace CGAL::Three; #if !defined(NDEBUG) inline void printGlError(unsigned int line) { - GLenum error = glGetError(); - if(error != GL_NO_ERROR) - { - if(error == GL_INVALID_ENUM) - std::cerr << "An unacceptable value is specified for an enumerated argument." << "@" << line << std::endl; - if(error == GL_INVALID_VALUE) - std::cerr << "A numeric argument is out of range." << "@" << line << std::endl; - if(error == GL_INVALID_OPERATION) - std::cerr << "The specified operation is not allowed in the current state." << "@" << line << std::endl; - if(error == GL_INVALID_FRAMEBUFFER_OPERATION) - std::cerr << "The framebuffer object is not complete." << "@" << line << std::endl; - if(error == GL_OUT_OF_MEMORY) - std::cerr << "There is not enough memory left to execute the command." << "@" << line << std::endl; - if(error == GL_STACK_UNDERFLOW) - std::cerr << "An attempt has been made to perform an operation that would cause an internal stack to underflow." << "@" << line << std::endl; - if(error == GL_STACK_OVERFLOW) - std::cerr << "An attempt has been made to perform an operation that would cause an internal stack to overflow." << "@" << line << std::endl; - } - + CGAL::Qt::opengl_check_errors(line); } #else inline diff --git a/Surface_mesher/demo/Surface_mesher/volume.cpp b/Surface_mesher/demo/Surface_mesher/volume.cpp index 67f08ae7864..244d8768279 100644 --- a/Surface_mesher/demo/Surface_mesher/volume.cpp +++ b/Surface_mesher/demo/Surface_mesher/volume.cpp @@ -33,8 +33,8 @@ #include #include #include - #include +#include struct Threshold : public std::unary_function { double isovalue; @@ -1516,24 +1516,7 @@ void Volume::gl_draw_marchingcube() } if(!list_draw_marching_cube_is_valid) { - GLenum error = ::glGetError(); - if(error != GL_NO_ERROR) - { - if(error == GL_INVALID_ENUM) - std::cerr << "An unacceptable value is specified for an enumerated argument." << "@" << line << std::endl; - if(error == GL_INVALID_VALUE) - std::cerr << "A numeric argument is out of range." << "@" << line << std::endl; - if(error == GL_INVALID_OPERATION) - std::cerr << "The specified operation is not allowed in the current state." << "@" << line << std::endl; - if(error == GL_INVALID_FRAMEBUFFER_OPERATION) - std::cerr << "The framebuffer object is not complete." << "@" << line << std::endl; - if(error == GL_OUT_OF_MEMORY) - std::cerr << "There is not enough memory left to execute the command." << "@" << line << std::endl; - if(error == GL_STACK_UNDERFLOW) - std::cerr << "An attempt has been made to perform an operation that would cause an internal stack to underflow." << "@" << line << std::endl; - if(error == GL_STACK_OVERFLOW) - std::cerr << "An attempt has been made to perform an operation that would cause an internal stack to overflow." << "@" << line << std::endl; - } + CGAL::Qt::opengl_check_errors(); } } }