-
Notifications
You must be signed in to change notification settings - Fork 1
/
utility.cpp
44 lines (38 loc) · 1.14 KB
/
utility.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
39
40
41
42
43
44
#include "utility.hpp"
#include <fstream>
bool file_exists(const string &filename)
{
std::ifstream ifile(filename.c_str());
return ifile;
}
string read_file(const string &filename)
{
std::ifstream ifile(filename.c_str());
return string(std::istreambuf_iterator<char>(ifile),
std::istreambuf_iterator<char>());
}
void get_errors(void)
{
GLenum error = glGetError();
if (error != GL_NO_ERROR) {
switch (error) {
case GL_INVALID_ENUM:
cerr << "GL: enum argument out of range." << endl;
break;
case GL_INVALID_VALUE:
cerr << "GL: Numeric argument out of range." << endl;
break;
case GL_INVALID_OPERATION:
cerr << "GL: Operation illegal in current state." << endl;
break;
case GL_INVALID_FRAMEBUFFER_OPERATION:
cerr << "GL: Framebuffer object is not complete." << endl;
break;
case GL_OUT_OF_MEMORY:
cerr << "GL: Not enough memory left to execute command." << endl;
break;
default:
cerr << "GL: Unknown error." << endl;
}
}
}