-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgl_dynapi.c
More file actions
36 lines (32 loc) · 901 Bytes
/
gl_dynapi.c
File metadata and controls
36 lines (32 loc) · 901 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
28
29
30
31
32
33
34
35
36
#define _COSMO_SOURCE
#include <cosmo.h>
#include "libc/log/log.h"
#include <SDL.h>
#define GL_GLEXT_PROTOTYPES
#include <GL/glcorearb.h>
#define PROC(rt,name,params,args,return) \
rt name##_DEFAULT params; \
void* dynapi_raw_##name; \
rt (* dynapi_##name) params = name##_DEFAULT; \
rt name##_WIN params { \
rt (* __attribute__((__ms_abi__)) fn) params = dynapi_raw_##name; \
return fn args; \
} \
inline rt name params { \
return dynapi_##name args; \
} \
rt name##_DEFAULT params { \
FLOGF(stderr, "loading opengl symbol: %s", #name); \
dynapi_raw_##name = SDL_GL_GetProcAddress(#name); \
if(!dynapi_raw_##name) exit(1); \
if(IsWindows()) { \
dynapi_##name = name##_WIN; \
} \
else { \
dynapi_##name = dynapi_raw_##name; \
} \
FLOGF(stderr, "loaded opengl symbol: %s", #name); \
return dynapi_##name args; \
}
#include "o/gl/glcorearb.procs.h"
#undef PROC