13 #ifndef OGLPLUS_ERROR_BASIC_1107121317_HPP
14 #define OGLPLUS_ERROR_BASIC_1107121317_HPP
16 #include <oglplus/config/error.hpp>
44 :
public std::runtime_error
48 #if !OGLPLUS_ERROR_NO_FILE
51 #if !OGLPLUS_ERROR_NO_FUNC
54 #if !OGLPLUS_ERROR_NO_LINE
58 #if !OGLPLUS_ERROR_NO_GL_LIB
59 const char* _gllib_name;
62 #if !OGLPLUS_ERROR_NO_GL_FUNC
63 const char* _glfunc_name;
66 #if !OGLPLUS_ERROR_NO_GL_SYMBOL
67 const char* _enumpar_name;
73 static const char* Message(GLenum);
75 Error(
const char* message);
77 ~
Error(
void)
throw() { }
79 Error& NoInfo(
void) {
return *
this; }
92 #if !OGLPLUS_ERROR_NO_FILE
110 #if !OGLPLUS_ERROR_NO_FUNC
128 #if !OGLPLUS_ERROR_NO_LINE
144 Error& GLLib(
const char* lib_name)
146 #if !OGLPLUS_ERROR_NO_GL_LIB
147 _gllib_name = lib_name;
153 const char* GLLib(
void)
const;
155 Error&
GLFunc(
const char* func_name)
157 #if !OGLPLUS_ERROR_NO_GL_FUNC
158 _glfunc_name = func_name;
173 const char*
GLFunc(
void)
const;
175 template <
typename Enum_>
178 #if !OGLPLUS_ERROR_NO_GL_SYMBOL
179 _enumpar = GLenum(param);
186 Error&
EnumParam(GLenum param,
const char* param_name)
188 #if !OGLPLUS_ERROR_NO_GL_SYMBOL
190 _enumpar_name = param_name;
219 Error&
Index(GLuint index)
221 #if !OGLPLUS_ERROR_NO_GL_SYMBOL
222 _index = GLint(index);
239 GLint
Index(
void)
const;
242 virtual GLfloat
Value(
void)
const {
return GLfloat(0); }
245 virtual GLfloat
Limit(
void)
const {
return GLfloat(0); }
251 virtual const char*
TargetName(
void)
const {
return nullptr; }
280 return EmptyStdString();
311 return EmptyStdString();
320 virtual const char*
Identifier(
void)
const {
return nullptr; }
328 virtual const String&
Log(
void)
const {
return EmptyString(); }
332 template <
typename ErrorType>
338 #define OGLPLUS_ERROR_CONTEXT(GLFUNC, CLASS) \
339 static const char* _errinf_glfn(void) \
343 static const char* _errinf_cls(void) \
348 #define OGLPLUS_ERROR_REUSE_CONTEXT(SOURCE) \
349 using SOURCE::_errinf_glfn; \
350 using SOURCE::_errinf_cls;
353 #define OGLPLUS_HANDLE_ERROR_IF(\
361 GLenum error_code = ERROR_CODE;\
364 ERROR error(MESSAGE);\
367 .SourceFile(__FILE__)\
368 .SourceFunc(__FUNCTION__)\
369 .SourceLine(__LINE__)\
375 #define OGLPLUS_GLFUNC_CHECK(FUNC_NAME, ERROR, ERROR_INFO)\
376 OGLPLUS_HANDLE_ERROR_IF(\
377 error_code != GL_NO_ERROR,\
379 ERROR::Message(error_code),\
381 ERROR_INFO.GLFunc(FUNC_NAME)\
384 #define OGLPLUS_CHECK(GLFUNC, ERROR, ERROR_INFO) \
385 OGLPLUS_GLFUNC_CHECK(#GLFUNC, ERROR, ERROR_INFO)
387 #define OGLPLUS_CHECK_CTXT(ERROR, ERROR_INFO) \
388 OGLPLUS_GLFUNC_CHECK(_errinf_glfn(), ERROR, ERROR_INFO)
390 #define OGLPLUS_CHECK_SIMPLE(GLFUNC) \
391 OGLPLUS_CHECK(GLFUNC, Error, NoInfo())
393 #if !OGLPLUS_LOW_PROFILE
394 #define OGLPLUS_VERIFY(GLFUNC, ERROR, ERROR_INFO) \
395 OGLPLUS_CHECK(GLFUNC, ERROR, ERROR_INFO)
397 #define OGLPLUS_VERIFY(GLFUNC, ERROR, ERROR_INFO)
400 #define OGLPLUS_VERIFY_SIMPLE(GLFUNC) \
401 OGLPLUS_CHECK(GLFUNC, Error, NoInfo())
403 #define OGLPLUS_IGNORE(PARAM) ::glGetError();
407 #if !OGLPLUS_LINK_LIBRARY || defined(OGLPLUS_IMPLEMENTING_LIBRARY)
408 #include <oglplus/error/basic.ipp>
411 #endif // include guard
virtual const char * TargetName(void) const
Returns the bind target name.
Definition: basic.hpp:251
const Char * c_str(void) const
Returns the null-terminated c-string.
Definition: ref_tpl.hpp:200
unsigned SourceLine(void) const
Returns the line of the source file where the error occured.
virtual GLenum SubjectType(void) const
Returns the subject type.
Definition: basic.hpp:288
virtual GLfloat Limit(void) const
Returns the limit value related to the error.
Definition: basic.hpp:245
virtual GLfloat Value(void) const
Returns the value parameter related to the error.
Definition: basic.hpp:242
StrCRef EnumValueName(Enum enum_value)
Returns the name of the GL enumerated value for an OGLplus enum value.
GLint Index(void) const
Returns the index parameter related to the error.
virtual const char * Identifier(void) const
Returns the identifier of a GPU program variable.
Definition: basic.hpp:320
virtual const char * SubjectTypeName(void) const
Returns the subject class name.
Definition: basic.hpp:295
void HandleError(ErrorType &error)
Generic error handling function.
Definition: basic.hpp:333
String type definition and related functions.
GLenum EnumParam(void) const
Returns the value of the enumeration parameter related to the error.
virtual const char * ObjectTypeName(void) const
Returns the object type name.
Definition: basic.hpp:264
const char * GLFunc(void) const
Returns the name of the GL function related to the error.
const char * SourceFile(void) const
Returns the name of the source file where the error occured.
virtual const std::string & SubjectDesc(void) const
Returns the subject textual description.
Definition: basic.hpp:309
virtual GLenum BindTarget(void) const
Returns the bind target.
Definition: basic.hpp:248
virtual GLint SubjectName(void) const
Returns the subject GL name.
Definition: basic.hpp:302
const char * SourceFunc(void) const
Returns the name of the function where the error occured.
::std::basic_string< GLchar > String
String class.
Definition: def.hpp:36
virtual const String & Log(void) const
Returns a log string associated with the error.
Definition: basic.hpp:328
virtual const std::string & ObjectDesc(void) const
Returns the object instance description.
Definition: basic.hpp:278
ErrorCode Code(void) const
Returns the GL error code related to the error.
Definition: basic.hpp:88
Exception class for general OpenGL errors.
Definition: basic.hpp:43
Enumeration of error-codes.
ErrorCode
Error code enumeration.
Definition: code.hpp:27
virtual GLint ObjectName(void) const
Returns the object instance GL name.
Definition: basic.hpp:271
const char * EnumParamName(void) const
Returns the name of the enumeration parameter related to the error.
virtual GLenum ObjectType(void) const
Returns the object type.
Definition: basic.hpp:257