-
Notifications
You must be signed in to change notification settings - Fork 0
/
gl_errors.hpp
33 lines (28 loc) · 762 Bytes
/
gl_errors.hpp
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
#pragma once
#include "GL.hpp"
#include <iostream>
#define STR2(X) # X
#define STR(X) STR2(X)
inline void gl_errors(std::string const &where) {
GLenum err = 0;
while ((err = glGetError()) != GL_NO_ERROR) {
#define CHECK( ERR ) \
if (err == ERR) { \
std::cerr << "WARNING: gl error '" #ERR "' at " << where << std::endl; \
} else
CHECK( GL_INVALID_ENUM )
CHECK( GL_INVALID_VALUE )
CHECK( GL_INVALID_OPERATION )
CHECK( GL_INVALID_FRAMEBUFFER_OPERATION )
CHECK( GL_OUT_OF_MEMORY )
#ifndef __ANDROID__
CHECK( GL_STACK_UNDERFLOW )
CHECK( GL_STACK_OVERFLOW )
#endif //!__ANDROID__
{
std::cerr << "WARNING: gl error '" << err << "'" << std::endl;
}
#undef CHECK
}
}
#define GL_ERRORS() gl_errors(__FILE__ ":" STR(__LINE__) )