Repository navigation
Expand file tree
/
Copy pathdebug.cpp
More file actions
45 lines (36 loc) · 1.41 KB
/
Copy pathdebug.cpp
File metadata and controls
45 lines (36 loc) · 1.41 KB
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
45
#include <debug.hpp>
#include <GLAD/glad.h>
#include <iostream>
void debug::queryErrors(const char* customMsg) {
GLenum errorCode;
const char* error;
while((errorCode = glGetError()) != GL_NO_ERROR) {
if(customMsg)
std::cout << customMsg << "\n";
switch (errorCode)
{
case GL_INVALID_ENUM: error = "INVALID_ENUM"; break;
case GL_INVALID_VALUE: error = "INVALID_VALUE"; break;
case GL_INVALID_OPERATION: error = "INVALID_OPERATION"; break;
case GL_STACK_OVERFLOW: error = "STACK_OVERFLOW"; break;
case GL_STACK_UNDERFLOW: error = "STACK_UNDERFLOW"; break;
case GL_OUT_OF_MEMORY: error = "OUT_OF_MEMORY"; break;
case GL_INVALID_FRAMEBUFFER_OPERATION: error = "INVALID_FRAMEBUFFER_OPERATION"; break;
}
std::cout << "ERROR HAPPENED! NAME: " << error << "; CODE: " << errorCode << "\n";
throwError();
}
}
void debug::throwError(const char* customMsg) {
if(customMsg)
std::cout << customMsg << "\n";
std::cout << "Press any key to continue." << std::endl;
std::cin.get();
exit(-1);
}
void debug::warn(const char* customMsg) {
std::cout << customMsg << "\n";
}
void debug::log(const char* customMsg) {
std::cout << customMsg << "\n";
}