forked from ixchow/15-466-f18-base0
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgl_errors.hpp
More file actions
32 lines (27 loc) · 738 Bytes
/
gl_errors.hpp
File metadata and controls
32 lines (27 loc) · 738 Bytes
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
#pragma once
#include "GL.hpp"
#include <iostream>
#include <string>
#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 )
CHECK( GL_STACK_UNDERFLOW )
CHECK( GL_STACK_OVERFLOW )
{
std::cerr << "WARNING: gl error '" << err << "'" << std::endl;
}
#undef CHECK
}
}
#define GL_ERRORS() gl_errors(__FILE__ ":" STR(__LINE__) )