blob: 34d64271f4d56bb8940798b2e1b79db7c8a14ce4 (
plain)
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
46
47
48
49
|
#define AL_LOG_SECTION "gl"
#include <al/log.h>
#include <al/lib.h>
#include "gl_common.h"
// https://stackoverflow.com/a/49236965
#define ERROR_CASE_STR(value) case value: return #value;
static const char *glGetErrorString(GLenum error)
{
switch (error) {
ERROR_CASE_STR(GL_INVALID_ENUM)
ERROR_CASE_STR(GL_INVALID_VALUE)
ERROR_CASE_STR(GL_INVALID_OPERATION)
ERROR_CASE_STR(GL_OUT_OF_MEMORY)
default: return "Unknown";
}
}
#undef ERROR_CASE_STR
bool stl_gl_check_error()
{
GLenum error;
bool any_error = false;
while ((error = glGetError()) != GL_NO_ERROR) {
log_error("GL error %s, %d.", glGetErrorString(error), error);
any_error = true;
}
return any_error;
}
bool stl_gl_loader_load(void (*(*get_proc_address)(const char *))(void))
{
#ifdef STELA_USE_GLAD
al_assert(get_proc_address);
#ifdef STELA_USE_GLES
if (!gladLoadGLES2((GLADloadfunc)get_proc_address)) {
return false;
}
#else
if (!gladLoadGL((GLADloadfunc)get_proc_address)) {
return false;
}
#endif
#else
(void)get_proc_address;
#endif
return true;
}
|