-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutilities.cpp
More file actions
27 lines (23 loc) · 747 Bytes
/
utilities.cpp
File metadata and controls
27 lines (23 loc) · 747 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
#include "utilities.hpp"
#include <cstdlib>
void SDL_Log(SDL_LogPriority priority, const char* fmt, ...) {
va_list ap;
va_start(ap, fmt);
SDL_LogMessageV(SDL_LOG_CATEGORY_APPLICATION, priority, fmt, ap);
va_end(ap);
}
void logAndCrashSDL(const char* error) {
const char* msg = SDL_GetError();
SDL_Log(SDL_LOG_PRIORITY_CRITICAL, "%s: %s", error, msg);
if (SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, error, msg, NULL))
SDL_Log(SDL_LOG_PRIORITY_CRITICAL, "Error presenting error");
SDL_Quit();
std::exit(-1);
}
void checkGLError() {
GLenum error = glGetError();
if (error != GL_NO_ERROR) {
SDL_SetError("GL Error 0x%04X", error);
logAndCrashSDL("OpenGL Error");
}
}