Utilities.h
Go to the documentation of this file.
1 
2 #pragma once
3 
4 #include <ionCore.h>
5 #include <ionMath.h>
6 #include <ionGraphics.h>
7 
8 
9 namespace ion
10 {
11  namespace Graphics
12  {
13  namespace GL
14  {
15 
16  int GetValueTypeOpenGLEnum(EValueType const ValueType);
17  int GetAttributeTypeOpenGLEnum(EAttributeType const AttributeType);
18 
19  bool OpenGLError();
20  void IgnoreOpenGLError();
21  string GetOpenGLError();
22  void PrintOpenGLErrors(char const * const Before = nullptr);
23  void PrintOpenGLErrors(char const * const Function, char const * const File, int const Line);
24  bool CheckGLFunctionPointer(void * Ptr, char const * const FunctionName);
25 
26 #ifdef _DEBUG
27  #define CheckedGLCall(x) do { ion::Graphics::GL::PrintOpenGLErrors(">>BEFORE<< "#x, __FILE__, __LINE__); (x); ion::Graphics::GL::PrintOpenGLErrors(#x, __FILE__, __LINE__); } while (0)
28  #define CheckExistingErrors(x) ion::Graphics::GL::PrintOpenGLErrors(">>BEFORE<< "#x, __FILE__, __LINE__);
29  #define SafeGLCall(FUNCTION, PARAMS)\
30  do {\
31  ion::Graphics::GL::PrintOpenGLErrors("(somewhere before) "#FUNCTION, __FILE__, __LINE__);\
32  if (ion::Graphics::GL::CheckGLFunctionPointer((FUNCTION), #FUNCTION))\
33  {\
34  FUNCTION PARAMS;\
35  ion::Graphics::GL::PrintOpenGLErrors(#FUNCTION, __FILE__, __LINE__);\
36  }\
37  } while (0);
38  #define SafeGLAssignment(LHS, FUNCTION, PARAMS)\
39  do {\
40  ion::Graphics::GL::PrintOpenGLErrors("(somewhere before) "#FUNCTION, __FILE__, __LINE__);\
41  if (ion::Graphics::GL::CheckGLFunctionPointer((FUNCTION), #FUNCTION))\
42  {\
43  LHS = FUNCTION PARAMS;\
44  ion::Graphics::GL::PrintOpenGLErrors(#FUNCTION, __FILE__, __LINE__);\
45  }\
46  } while (0);
47 #else
48  #define CheckedGLCall(x) (x)
49  #define CheckExistingErrors(x)
50  #define SafeGLCall(FUNCTION, PARAMS) FUNCTION PARAMS
51  #define SafeGLAssignment(LHS, FUNCTION, PARAMS) LHS = FUNCTION PARAMS
52 #endif
53 
54  class Util
55  {
56  public:
57 
58  static uint const ScalarTypeMatrix[9];
59  static string const ScalarTypeStringMatrix[9];
60 
61  };
62  }
63  }
64 }
static uint const ScalarTypeMatrix[9]
Definition: Utilities.h:58
EValueType
Standard type enum used through module.
Definition: Enums.h:14
int GetValueTypeOpenGLEnum(EValueType const ValueType)
Definition: Utilities.cpp:13
Definition: CCatmullRomAdvancedSplineInterpolator.h:7
EAttributeType
Possible types for attributes i.e. vertex buffer contents.
Definition: Enums.h:48
unsigned int uint
Definition: ionTypes.h:42
bool CheckGLFunctionPointer(void *Ptr, char const *const FunctionName)
Definition: Utilities.cpp:136
void IgnoreOpenGLError()
Definition: Utilities.cpp:62
string GetOpenGLError()
Definition: Utilities.cpp:92
int GetAttributeTypeOpenGLEnum(EAttributeType const AttributeType)
Definition: Utilities.cpp:38
static string const ScalarTypeStringMatrix[9]
Definition: Utilities.h:59
Definition: Utilities.h:54
void PrintOpenGLErrors(char const *const Before)
Definition: Utilities.cpp:99
bool OpenGLError()
Definition: Utilities.cpp:57