-
Notifications
You must be signed in to change notification settings - Fork 0
/
util.cpp
38 lines (33 loc) · 995 Bytes
/
util.cpp
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
#include "util.h"
#define GLFW_INCLUDE_GLCOREARB
#define GL_GLEXT_PROTOTYPES
#include <GLFW/glfw3.h>
#include <sstream>
bool CheckGLErrors()
{
bool error = false;
std::ostringstream err;
err << "OpenGL error: ";
for (GLenum flag = glGetError(); flag != GL_NO_ERROR; flag = glGetError())
{
switch (flag) {
case GL_INVALID_ENUM:
err << "GL_INVALID_ENUM" << endl; break;
case GL_INVALID_VALUE:
err << "GL_INVALID_VALUE" << endl; break;
case GL_INVALID_OPERATION:
err << "GL_INVALID_OPERATION" << endl; break;
case GL_INVALID_FRAMEBUFFER_OPERATION:
err << "GL_INVALID_FRAMEBUFFER_OPERATION" << endl; break;
case GL_OUT_OF_MEMORY:
err << "GL_OUT_OF_MEMORY" << endl; break;
default:
err << "[unknown error code]" << endl;
}
error = true;
}
if (error) {
throw std::runtime_error(err.str());
}
return false;
}