8#include <glbinding/gl/gl.h>
9#include <glbinding/gl45core/gl.h>
10#include <glbinding/gl45ext/gl.h>
15using namespace gl45core;
16using namespace gl45ext;
21#include <glbinding-aux/types_to_string.h>
26#define GL_SCALAR GL_FLOAT
27#define GL_SCALAR_PLAIN float
30inline bool checkOpenGLContext() {
31 return gl::glGetString( gl::GL_VERSION ) !=
nullptr;
35inline const char* glErrorString( gl::GLenum err ) {
36 using namespace gl45core;
37 using namespace gl45ext;
41 return " Invalid enum : An unacceptable value is specified for an enumerated argument. The "
42 "offending command is ignored and has no other side effect than to set the error "
44 case GL_INVALID_VALUE:
45 return " Invalid value : A numeric argument is out of range. The offending command is "
46 "ignored and has no other side effect than to set the error flag.\n";
47 case GL_INVALID_OPERATION:
48 return " Invalid operation : The specified operation is not allowed in the current state. "
49 "The offending command is ignored and has no other side effect than to set the "
51 case GL_INVALID_FRAMEBUFFER_OPERATION:
52 return " Invalid framebuffer operation : The framebuffer object is not complete. The "
53 "offending command is ignored and has no other side effect than to set the error "
55 case GL_OUT_OF_MEMORY:
56 return " Out of memory : There is not enough memory left to execute the command. The state "
57 "of the GL is undefined, except for the state of the error flags, after this error "
68 return " Unknown GL error\n";
73# include <Core/Utils/Log.hpp>
74# include <Core/Utils/StackTrace.hpp>
75# define GL_ASSERT( x ) \
78 gl::GLenum err = gl::glGetError(); \
79 if ( err != gl::GL_NO_ERROR ) { \
80 const char* errBuf = glErrorString( err ); \
81 LOG( Ra::Core::Utils::logERROR ) \
82 << "OpenGL error (" << __FILE__ << ":" << __LINE__ << ", " << STRINGIFY( x ) \
83 << ") : " << errBuf << "(" << err << " : 0x" << std::hex << int( err ) \
84 << std::dec << ")."; \
90# define GL_CHECK_ERROR \
92 gl::GLenum err = gl::glGetError(); \
93 if ( err != gl::GL_NO_ERROR ) { \
94 const char* errBuf = glErrorString( err ); \
95 LOG( Ra::Core::Utils::logERROR ) \
96 << "OpenGL error (" << __FILE__ << ":" << __LINE__ \
97 << ", glCheckError()) : " << errBuf << "(" << err << " : 0x" << std::hex \
98 << err << std::dec << ")." << '\n' \
99 << Ra::Core::Utils::StackTrace(); \
105# define glFlushError() glGetError()
108# define GL_ASSERT( x ) x
109# define GL_CHECK_ERROR \
111# define glFlushError() \
hepler function to manage enum as underlying types in VariableSet