From 60cbbdec07ab7a5636eac5b3c024ae44e937f4d4 Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 13 Dec 2021 00:07:19 +0800 Subject: +init --- Client/Source/Graphics/OpenGL.h | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 Client/Source/Graphics/OpenGL.h (limited to 'Client/Source/Graphics/OpenGL.h') 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 +#include + +//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 -- cgit v1.1-26-g67d0