diff options
author | chai <chaifix@163.com> | 2021-12-13 00:07:19 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2021-12-13 00:07:19 +0800 |
commit | 60cbbdec07ab7a5636eac5b3c024ae44e937f4d4 (patch) | |
tree | b2c7b0a868f18159dbc43d8954e1bd7668549a88 /Client/Source/Graphics/OpenGL.h |
+init
Diffstat (limited to 'Client/Source/Graphics/OpenGL.h')
-rw-r--r-- | Client/Source/Graphics/OpenGL.h | 41 |
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 |