-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathglUtil.cpp
30 lines (27 loc) · 817 Bytes
/
glUtil.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
#include "glUtil.h"
#include <sstream>
#include <stdexcept>
GlErrorVerifier::~GlErrorVerifier()
{
GLenum err = glGetError();
if (err != GL_NO_ERROR)
{
std::ostringstream stream;
stream << "OGL error " << glErrorToString(err);
throw std::runtime_error(stream.str());
}
}
const char* glErrorToString(GLenum err)
{
switch (err)
{
case GL_INVALID_ENUM: return "GL_INVALID_ENUM";
case GL_INVALID_VALUE: return "GL_INVALID_VALUE";
case GL_INVALID_OPERATION: return "GL_INVALID_OPERATION";
case GL_STACK_OVERFLOW: return "GL_STACK_OVERFLOW";
case GL_STACK_UNDERFLOW: return "GL_STACK_UNDERFLOW";
case GL_OUT_OF_MEMORY: return "GL_OUT_OF_MEMORY";
case GL_INVALID_FRAMEBUFFER_OPERATION: return "GL_INVALID_FRAMEBUFFER_OPERATION";
default: throw std::runtime_error("Invalid GL error code");
}
}