-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathopenglcontext.h
47 lines (35 loc) · 1.64 KB
/
openglcontext.h
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
#ifndef __GETIMAGE_OPENGLCONTEXT__
#define __GETIMAGE_OPENGLCONTEXT__
#define CONTEXT_EGL 1
#define CONTEXT_GLFW 2
#if (GETIMAGE_CONTEXT == CONTEXT_EGL)
#include "context_egl.h"
#elif (GETIMAGE_CONTEXT == CONTEXT_GLFW)
#include "context_glfw.h"
#else
#error Must define an OpenGL context preprocessor macro!
#endif
/*---------------------------------------------------------------------------*/
// Primitives all context should define
void contextInitAndGetAPI(Params& params, Context& ctx);
bool contextKeepLooping(Context &ctx);
void contextSwap(Context& ctx);
void contextSetKeyCallback(Context& ctx);
void contextTerminate(Context& ctx);
/*---------------------------------------------------------------------------*/
// This one is defined is main.cpp, but used in the macro belows
const char *openglErrorString(GLenum err);
/*---------------------------------------------------------------------------*/
#define GL_CHECKERR(strfunc) do { \
GLenum __err = glGetError(); \
if (__err != GL_NO_ERROR) { \
crash("OpenGL error: %s(): %s" , strfunc, openglErrorString(__err)); \
} \
} while (0)
/*---------------------------------------------------------------------------*/
#define GL_SAFECALL(func, ...) do { \
func(__VA_ARGS__); \
GL_CHECKERR(#func); \
} while (0)
/*---------------------------------------------------------------------------*/
#endif