-
Notifications
You must be signed in to change notification settings - Fork 0
/
glCheck.h
51 lines (45 loc) · 1.22 KB
/
glCheck.h
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
42
43
44
45
46
47
48
49
50
51
/* Created on: Jan 29, 2015
* Author: T.Delame (tdelame@gmail.com)
*/
# ifndef PROJECT_GL_HELPER_H_
# define PROJECT_GL_HELPER_H_
# include <iostream>
# ifndef __APPLE__
# include <GL/glew.h>
# else
# include <OpenGL/GL.h>
# endif
# define GLCHECK( call ) \
call; \
check_gl_error( #call, __FILE__, __LINE__ );
inline void check_gl_error( const char* call, const char* file, const int line )
{
unsigned int gle = glGetError();
if( gle != GL_NO_ERROR )
{
std::cerr<<"[error][GL] GL Error discovered when calling " << call << " at " << file << "(l " << line << "): ";
switch (gle)
{
case GL_INVALID_ENUM:
std::cerr << "Invalid enum.\n";
break;
case GL_INVALID_VALUE:
std::cerr << "Invalid value.\n";
break;
case GL_INVALID_OPERATION:
std::cerr <<"Invalid Operation.\n";
break;
case GL_STACK_OVERFLOW:
std::cerr << "Stack overflow.\n";
break;
case GL_STACK_UNDERFLOW:
std::cerr << "Stack underflow.\n";
break;
case GL_OUT_OF_MEMORY:
std::cerr << "Out of memory.\n";
break;
}
return;
}
}
# endif /* PROJECT_GL_HELPER_H_ */