1 module wayland.egl;
2 
3 import wayland.client;
4 import wayland.native.egl;
5 import wayland.util;
6 
7 class WlEglWindow : Native!wl_egl_window
8 {
9     mixin nativeImpl!(wl_egl_window);
10 
11     this(WlSurface surf, int width, int height)
12     {
13         _native = wl_egl_window_create(surf.proxy, width, height);
14     }
15 
16     void destroy()
17     {
18         wl_egl_window_destroy(_native);
19         _native = null;
20     }
21 
22     void resize(int width, int height, int dx, int dy)
23     {
24         wl_egl_window_resize(_native, width, height, dx, dy);
25     }
26 
27     @property int[2] attachedSize()
28     {
29         int[2] wh = -1;
30         wl_egl_window_get_attached_size(_native, &wh[0], &wh[1]);
31         return wh;
32     }
33 }
34 
35 version(WlDynamic)
36 {
37     import derelict.util.loader : SharedLibLoader;
38 
39     private class WlEglLoader : SharedLibLoader
40     {
41         this()
42         {
43             super("libwayland-egl.so");
44         }
45 
46         protected override void loadSymbols()
47         {
48             bindFunc( cast( void** )&wl_egl_window_create, "wl_egl_window_create" );
49             bindFunc( cast( void** )&wl_egl_window_destroy, "wl_egl_window_destroy" );
50             bindFunc( cast( void** )&wl_egl_window_resize, "wl_egl_window_resize" );
51             bindFunc( cast( void** )&wl_egl_window_get_attached_size, "wl_egl_window_get_attached_size" );
52         }
53     }
54 
55     private __gshared WlEglLoader _loader;
56 
57     shared static this()
58     {
59         _loader = new WlEglLoader;
60     }
61 
62     public @property SharedLibLoader wlEglDynLib()
63     {
64         return _loader;
65     }
66 }