mirror of https://github.com/CGAL/cgal
Re-implementation of opengl_check_errors
This commit is contained in:
parent
ca841c9623
commit
b99c616c23
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -27,9 +27,8 @@
|
|||
|
||||
#include <CGAL/Qt/debug.h>
|
||||
#include <QDir>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <GL/gl.h>
|
||||
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
|
||||
|
|
|
|||
|
|
@ -13,28 +13,12 @@
|
|||
#include <QOpenGLVertexArrayObject>
|
||||
#include <QOpenGLBuffer>
|
||||
#include <QOpenGLShaderProgram>
|
||||
#include <CGAL/Qt/debug.h>
|
||||
|
||||
#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
|
||||
|
|
|
|||
|
|
@ -14,31 +14,14 @@
|
|||
#include <QOpenGLBuffer>
|
||||
#include <QOpenGLShaderProgram>
|
||||
#include <CGAL/Three/Viewer_interface.h>
|
||||
#include <CGAL/Qt/debug.h>
|
||||
|
||||
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
|
||||
|
|
|
|||
|
|
@ -33,8 +33,8 @@
|
|||
#include <CGAL/Surface_mesher/Implicit_surface_oracle_3.h>
|
||||
#include <CGAL/Surface_mesher/Vertices_on_the_same_psc_element_criterion.h>
|
||||
#include <CGAL/IO/Complex_2_in_triangulation_3_file_writer.h>
|
||||
|
||||
#include <CGAL/make_surface_mesh.h>
|
||||
#include <CGAL/Qt/debug.h>
|
||||
|
||||
struct Threshold : public std::unary_function<FT, unsigned char> {
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue