summaryrefslogtreecommitdiff
path: root/Client/Source/Graphics/OpenGL.h
diff options
context:
space:
mode:
Diffstat (limited to 'Client/Source/Graphics/OpenGL.h')
-rw-r--r--Client/Source/Graphics/OpenGL.h41
1 files changed, 41 insertions, 0 deletions
diff --git a/Client/Source/Graphics/OpenGL.h b/Client/Source/Graphics/OpenGL.h
new file mode 100644
index 0000000..d93fb5a
--- /dev/null
+++ b/Client/Source/Graphics/OpenGL.h
@@ -0,0 +1,41 @@
+#ifndef OPENGL_H
+#define OPENGL_H
+
+#include "glad/glad.h"
+#include <string>
+#include <exception>
+
+//http://docs.gl/gl3/glClear
+
+#define CheckGLError(action)\
+if(true){ \
+ GLenum error; \
+ while ((error = glGetError()) != GL_NO_ERROR) { \
+ action \
+ } \
+}
+
+#define WipeGLError() \
+if(true){\
+ GLenum error; \
+ while ((error = glGetError()) != GL_NO_ERROR) { \
+ throw GLException(error); \
+ } \
+}
+
+extern std::string g_sharedGLErrorMsg;
+
+class GLException : public std::exception
+{
+public:
+ GLException(const char* what)
+ : std::exception(what)
+ {}
+ GLException(int glError)
+ {
+ g_sharedGLErrorMsg = std::to_string(glError);
+ std::exception(g_sharedGLErrorMsg.c_str());
+ }
+};
+
+#endif \ No newline at end of file