summaryrefslogtreecommitdiff
path: root/Client/Source/Graphics/OpenGL.h
blob: d93fb5a6e6c162dc0a866c2facbcde0eaaff7fc5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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