-
Notifications
You must be signed in to change notification settings - Fork 0
/
wldl-egl.h
89 lines (72 loc) · 2.39 KB
/
wldl-egl.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#ifndef WLDL_EGL_H
#define WLDL_EGL_H
#include <wayland-util.h>
#include <wayland-egl-backend.h>
#define WL_EGL_PLATFORM 1
struct wayland_egl_lib {
void* handle;
struct wl_egl_window* (*window_create)(
struct wl_surface*,
int,
int);
void (*window_destroy)(struct wl_egl_window*);
void (*window_resize)(
struct wl_egl_window*,
int,
int,
int,
int);
void (*window_get_attached_size)(
struct wl_egl_window*,
int*,
int*);
};
extern struct wayland_egl_lib _wldl_egl;
#define wl_egl_window_create(s, w, h) \
_wldl_egl.window_create(s, w, h)
#define wl_egl_window_destroy(wnd) \
_wldl_egl.window_destroy(wnd)
#define wl_egl_window_resize(wnd, w, h, dx, dy) \
_wldl_egl.window_resize(wnd, w, h, dx, dy)
#define wl_egl_window_get_attached_size(wnd, w, h) \
_wldl_egl.window_get_attached_size(wnd, w, h)
int wldl_egl_load(const char* libpath);
char* wldl_egl_get_error(void);
void wldl_egl_unload(void);
#ifdef WLDL_EGL_IMPL
#include <dlfcn.h>
struct wayland_egl_lib _wldl_egl;
#define DLOPEN(file) \
do { \
_wldl_client.handle = dlopen((file), RTLD_NOW | RTLD_GLOBAL); \
if (_wldl_client.handle == NULL) \
return -1; \
} while (0)
#define DLSYM(symb) \
do { \
_wldl_client.symb = dlsym(_wldl_client.handle, "wl_" #symb); \
if (_wldl_client.symb == NULL) \
return -1; \
} while (0)
#define DLCLOSE() \
do { \
if (_wldl_client.handle != NULL) \
dlclose(_wldl_client.handle); \
} while (0)
int wldl_egl_load(const char* libpath) {
libpath = (libpath == NULL) ? "libwayland-egl.so" : libpath;
DLOPEN(libpath);
DLSYM(window_create);
DLSYM(window_destroy);
DLSYM(window_resize);
DLSYM(window_get_attached_size);
return 0;
}
char* wldl_egl_get_error(void) {
return dlerror();
}
void wldl_egl_unload(void) {
DLCLOSE();
}
#endif // WLDL_EGL_IMPL
#endif // WLDL_EGL_H