1 
2 //          Copyright 2018 - 2021 Michael D. Parker
3 // Distributed under the Boost Software License, Version 1.0.
4 //    (See accompanying file LICENSE_1_0.txt or copy at
5 //          http://www.boost.org/LICENSE_1_0.txt)
6 
7 module bindbc.glfw.binddynamic;
8 
9 version(BindBC_Static) {}
10 else version(BindGLFW_Static) {}
11 else version = BindGLFW_Dynamic;
12 
13 version(BindGLFW_Dynamic):
14 
15 import bindbc.loader;
16 import bindbc.glfw.types;
17 
18 extern(C) @nogc nothrow {
19     alias pglfwInit = int function();
20     alias pglfwTerminate = void function();
21     alias pglfwGetVersion = void function(int* major, int* minor, int* rev);
22     alias pglfwGetVersionString = const(char)* function();
23     alias pglfwSetErrorCallback = GLFWerrorfun function(GLFWerrorfun callback);
24     alias pglfwGetMonitors = GLFWmonitor** function(int* count);
25     alias pglfwGetPrimaryMonitor = GLFWmonitor* function();
26     alias pglfwGetMonitorPos = void function(GLFWmonitor* monitor, int* xpos, int* ypos);
27     alias pglfwGetMonitorPhysicalSize = void function(GLFWmonitor* monitor, int* widthMM, int* heightMM);
28     alias pglfwGetMonitorName = const(char)* function(GLFWmonitor* monitor);
29     alias pglfwSetMonitorCallback = GLFWmonitorfun function(GLFWmonitorfun callback);
30     alias pglfwGetVideoModes = const(GLFWvidmode)* function(GLFWmonitor* monitor, int* count);
31     alias pglfwGetVideoMode = const(GLFWvidmode)* function(GLFWmonitor* monitor);
32     alias pglfwSetGamma = void function(GLFWmonitor* monitor, float gamma);
33     alias pglfwGetGammaRamp = const(GLFWgammaramp*) function(GLFWmonitor* monitor);
34     alias pglfwSetGammaRamp = void function(GLFWmonitor* monitor, const(GLFWgammaramp)* ramp);
35     alias pglfwDefaultWindowHints = void function();
36     alias pglfwWindowHint = void function(int hint, int value);
37     alias pglfwCreateWindow = GLFWwindow* function(int width, int height, const(char)* title, GLFWmonitor* monitor, GLFWwindow* share);
38     alias pglfwDestroyWindow = void function(GLFWwindow* window);
39     alias pglfwWindowShouldClose = int function(GLFWwindow* window);
40     alias pglfwSetWindowShouldClose = void function(GLFWwindow* window, int value);
41     alias pglfwSetWindowTitle = void function(GLFWwindow* window, const(char)* title);
42     alias pglfwGetWindowPos = void function(GLFWwindow* window, int* xpos, int* ypos);
43     alias pglfwSetWindowPos = void function(GLFWwindow* window, int xpos, int ypos);
44     alias pglfwGetWindowSize = void function(GLFWwindow* window, int* width, int* height);
45     alias pglfwSetWindowSize = void function(GLFWwindow* window, int width, int height);
46     alias pglfwGetFramebufferSize = void function(GLFWwindow* window, int* width, int* height);
47     alias pglfwIconifyWindow = void function(GLFWwindow* window);
48     alias pglfwRestoreWindow = void function(GLFWwindow* window);
49     alias pglfwShowWindow = void function(GLFWwindow* window);
50     alias pglfwHideWindow = void function(GLFWwindow* window);
51     alias pglfwGetWindowMonitor = GLFWmonitor* function(GLFWwindow* window);
52     alias pglfwGetWindowAttrib = int function(GLFWwindow* window, int attrib);
53     alias pglfwSetWindowUserPointer = void function(GLFWwindow* window, void* pointer);
54     alias pglfwGetWindowUserPointer = void* function(GLFWwindow* window);
55     alias pglfwSetWindowPosCallback = GLFWwindowposfun function(GLFWwindow* window, GLFWwindowposfun callback);
56     alias pglfwSetWindowSizeCallback = GLFWwindowsizefun function(GLFWwindow* window, GLFWwindowsizefun callback);
57     alias pglfwSetWindowCloseCallback = GLFWwindowclosefun function(GLFWwindow* window, GLFWwindowclosefun callback);
58     alias pglfwSetWindowRefreshCallback = GLFWwindowrefreshfun function(GLFWwindow* window, GLFWwindowrefreshfun callback);
59     alias pglfwSetWindowFocusCallback = GLFWwindowfocusfun function(GLFWwindow* window, GLFWwindowfocusfun callback);
60     alias pglfwSetWindowIconifyCallback = GLFWwindowiconifyfun function(GLFWwindow* window, GLFWwindowiconifyfun callback);
61     alias pglfwSetFramebufferSizeCallback = GLFWframebuffersizefun function(GLFWwindow* window, GLFWframebuffersizefun callback);
62     alias pglfwPollEvents = void function();
63     alias pglfwWaitEvents = void function();
64     alias pglfwGetInputMode = int function(GLFWwindow* window, int mode);
65     alias pglfwSetInputMode = void function(GLFWwindow* window, int mode, int value);
66     alias pglfwGetKey = int function(GLFWwindow* window, int key);
67     alias pglfwGetMouseButton = int function(GLFWwindow* window, int button);
68     alias pglfwGetCursorPos = void function(GLFWwindow* window, double* xpos, double* ypos);
69     alias pglfwSetCursorPos = void function(GLFWwindow* window, double xpos, double ypos);
70     alias pglfwSetKeyCallback = GLFWkeyfun function(GLFWwindow* window, GLFWkeyfun callback);
71     alias pglfwSetCharCallback = GLFWcharfun function(GLFWwindow* window, GLFWcharfun callback);
72     alias pglfwSetMouseButtonCallback = GLFWmousebuttonfun function(GLFWwindow* window, GLFWmousebuttonfun callback);
73     alias pglfwSetCursorPosCallback = GLFWcursorposfun function(GLFWwindow* window, GLFWcursorposfun callback);
74     alias pglfwSetCursorEnterCallback = GLFWcursorenterfun function(GLFWwindow* window, GLFWcursorenterfun callback);
75     alias pglfwSetScrollCallback = GLFWscrollfun function(GLFWwindow* window, GLFWscrollfun callback);
76     alias pglfwJoystickPresent = int function(int jid);
77     alias pglfwGetJoystickAxes = float* function(int jid, int* count);
78     alias pglfwGetJoystickButtons = ubyte* function(int jid, int* count);
79     alias pglfwGetJoystickName = const(char)* function(int jid);
80     alias pglfwSetClipboardString = void function(GLFWwindow*  window, const(char)* string_);
81     alias pglfwGetClipboardString = const(char)* function(GLFWwindow* window);
82     alias pglfwGetTime = double function();
83     alias pglfwSetTime = void function(double time);
84     alias pglfwMakeContextCurrent = void function(GLFWwindow* window);
85     alias pglfwGetCurrentContext = GLFWwindow* function();
86     alias pglfwSwapBuffers = void function(GLFWwindow* window);
87     alias pglfwSwapInterval = void function(int interval);
88     alias pglfwExtensionSupported = int function(const(char)* extension);
89     alias pglfwGetProcAddress = GLFWglproc function(const(char)* procname);
90 
91     static if(glfwSupport >= GLFWSupport.glfw31) {
92         alias pglfwGetWindowFrameSize = void function(GLFWwindow* window, int* left, int* top, int* right, int* bottom);
93         alias pglfwPostEmptyEvent = void function();
94         alias pglfwCreateCursor = GLFWcursor* function(const(GLFWimage)* image, int xhot, int yhot);
95         alias pglfwCreateStandardCursor = GLFWcursor* function(int shape);
96         alias pglfwDestroyCursor = void function(GLFWcursor* cursor);
97         alias pglfwSetCursor = void function(GLFWwindow* window, GLFWcursor* cursor);
98         alias pglfwSetCharModsCallback = GLFWcharmodsfun function(GLFWwindow* window, GLFWcharmodsfun callback);
99         alias pglfwSetDropCallback = GLFWdropfun function(GLFWwindow* window, GLFWdropfun callback);
100     }
101 
102     static if(glfwSupport >= GLFWSupport.glfw32) {
103         alias pglfwSetWindowIcon = void function(GLFWwindow* window, int count, const(GLFWimage)* images);
104         alias pglfwSetWindowSizeLimits = void function(GLFWwindow* window, int minwidth, int minheight, int maxwidth, int maxheight);
105         alias pglfwSetWindowAspectRatio = void function(GLFWwindow* window, int numer, int denom);
106         alias pglfwMaximizeWindow = void function(GLFWwindow* window);
107         alias pglfwFocusWindow = void function(GLFWwindow* window);
108         alias pglfwSetWindowMonitor = void function(GLFWwindow* window, GLFWmonitor* monitor, int xpos, int ypos, int width, int height, int refreshRate);
109         alias pglfwWaitEventsTimeout = void function(double timeout);
110         alias pglfwGetKeyName = const(char)* function(int key, int scancode);
111         alias pglfwGetTimerValue = long function();
112         alias pglfwGetTimerFrequency = long function();
113         alias pglfwVulkanSupported = int function();
114         alias pglfwSetJoystickCallback = GLFWjoystickfun function(GLFWjoystickfun callback);
115     }
116 
117     static if(glfwSupport >= GLFWSupport.glfw33) {
118         alias pglfwInitHint = void function(int,int);
119         alias pglfwGetError = int function(const(char)** description);
120         alias pglfwGetMonitorWorkarea = void function(GLFWmonitor* monitor, int* xpos, int* ypos, int* width, int* height);
121         alias pglfwGetMonitorContentScale = void function(GLFWmonitor* monitor, float* xscale, float* yscale);
122         alias pglfwSetMonitorUserPointer = void function(GLFWmonitor* monitor, void* pointer);
123         alias pglfwGetMonitorUserPointer = void* function(GLFWmonitor* monitor);
124         alias pglfwWindowHintString = void function(int hint,const(char)* value);
125         alias pglfwGetWindowContentScale = void function(GLFWwindow* window, float* xscale, float* yscale);
126         alias pglfwGetWindowOpacity = float function(GLFWwindow* window);
127         alias pglfwSetWindowOpacity = void function(GLFWwindow* window, float opacity);
128         alias pglfwRequestWindowAttention = void function(GLFWwindow* window);
129         alias pglfwSetWindowAttrib = void function(GLFWwindow* window, int attrib, int value);
130         alias pglfwSetWindowMaximizeCallback = GLFWwindowmaximizefun function(GLFWwindow* window, GLFWwindowmaximizefun callback);
131         alias pglfwSetWindowContentScaleCallback = GLFWwindowcontentscalefun function(GLFWwindow* window, GLFWwindowcontentscalefun callback);
132         alias pglfwGetKeyScancode = int function(int key);
133         alias pglfwGetJoystickHats = const(ubyte)* function(int jid, int* count);
134         alias pglfwGetJoystickGUID = const(char)* function(int jid);
135         alias pglfwSetJoystickUserPointer = void function(int jid, void* pointer);
136         alias pglfwGetJoystickUserPointer = void* function(int jid);
137         alias pglfwJoystickIsGamepad = int function(int jid);
138         alias pglfwUpdateGamepadMappings = int function(const(char)* string_);
139         alias pglfwGetGamepadName = const(char)* function(int jid);
140         alias pglfwGetGamepadState = int function(int jid, GLFWgamepadstate* state);
141     }
142 }
143 
144  __gshared {
145     pglfwInit glfwInit;
146     pglfwTerminate glfwTerminate;
147     pglfwGetVersion glfwGetVersion;
148     pglfwGetVersionString glfwGetVersionString;
149     pglfwSetErrorCallback glfwSetErrorCallback;
150     pglfwGetMonitors glfwGetMonitors;
151     pglfwGetPrimaryMonitor glfwGetPrimaryMonitor;
152     pglfwGetMonitorPos glfwGetMonitorPos;
153     pglfwGetMonitorPhysicalSize glfwGetMonitorPhysicalSize;
154     pglfwGetMonitorName glfwGetMonitorName;
155     pglfwSetMonitorCallback glfwSetMonitorCallback;
156     pglfwGetVideoModes glfwGetVideoModes;
157     pglfwGetVideoMode glfwGetVideoMode;
158     pglfwSetGamma glfwSetGamma;
159     pglfwGetGammaRamp glfwGetGammaRamp;
160     pglfwSetGammaRamp glfwSetGammaRamp;
161     pglfwDefaultWindowHints glfwDefaultWindowHints;
162     pglfwWindowHint glfwWindowHint;
163     pglfwCreateWindow glfwCreateWindow;
164     pglfwDestroyWindow glfwDestroyWindow;
165     pglfwWindowShouldClose glfwWindowShouldClose;
166     pglfwSetWindowShouldClose glfwSetWindowShouldClose;
167     pglfwSetWindowTitle glfwSetWindowTitle;
168     pglfwGetWindowPos glfwGetWindowPos;
169     pglfwSetWindowPos glfwSetWindowPos;
170     pglfwGetWindowSize glfwGetWindowSize;
171     pglfwSetWindowSize glfwSetWindowSize;
172     pglfwGetFramebufferSize glfwGetFramebufferSize;
173     pglfwIconifyWindow glfwIconifyWindow;
174     pglfwRestoreWindow glfwRestoreWindow;
175     pglfwShowWindow glfwShowWindow;
176     pglfwHideWindow glfwHideWindow;
177     pglfwGetWindowMonitor glfwGetWindowMonitor;
178     pglfwGetWindowAttrib glfwGetWindowAttrib;
179     pglfwSetWindowUserPointer glfwSetWindowUserPointer;
180     pglfwGetWindowUserPointer glfwGetWindowUserPointer;
181     pglfwSetWindowPosCallback glfwSetWindowPosCallback;
182     pglfwSetWindowSizeCallback glfwSetWindowSizeCallback;
183     pglfwSetWindowCloseCallback glfwSetWindowCloseCallback;
184     pglfwSetWindowRefreshCallback glfwSetWindowRefreshCallback;
185     pglfwSetWindowFocusCallback glfwSetWindowFocusCallback;
186     pglfwSetWindowIconifyCallback glfwSetWindowIconifyCallback;
187     pglfwSetFramebufferSizeCallback glfwSetFramebufferSizeCallback;
188     pglfwPollEvents glfwPollEvents;
189     pglfwWaitEvents glfwWaitEvents;
190     pglfwGetInputMode glfwGetInputMode;
191     pglfwSetInputMode glfwSetInputMode;
192     pglfwGetKey glfwGetKey;
193     pglfwGetMouseButton glfwGetMouseButton;
194     pglfwGetCursorPos glfwGetCursorPos;
195     pglfwSetCursorPos glfwSetCursorPos;
196     pglfwSetKeyCallback glfwSetKeyCallback;
197     pglfwSetCharCallback glfwSetCharCallback;
198     pglfwSetMouseButtonCallback glfwSetMouseButtonCallback;
199     pglfwSetCursorPosCallback glfwSetCursorPosCallback;
200     pglfwSetCursorEnterCallback glfwSetCursorEnterCallback;
201     pglfwSetScrollCallback glfwSetScrollCallback;
202     pglfwJoystickPresent glfwJoystickPresent;
203     pglfwGetJoystickAxes glfwGetJoystickAxes;
204     pglfwGetJoystickButtons glfwGetJoystickButtons;
205     pglfwGetJoystickName glfwGetJoystickName;
206     pglfwSetClipboardString glfwSetClipboardString;
207     pglfwGetClipboardString glfwGetClipboardString;
208     pglfwGetTime glfwGetTime;
209     pglfwSetTime glfwSetTime;
210     pglfwMakeContextCurrent glfwMakeContextCurrent;
211     pglfwGetCurrentContext glfwGetCurrentContext;
212     pglfwSwapBuffers glfwSwapBuffers;
213     pglfwSwapInterval glfwSwapInterval;
214     pglfwExtensionSupported glfwExtensionSupported;
215     pglfwGetProcAddress glfwGetProcAddress;
216 
217     static if(glfwSupport >= GLFWSupport.glfw31) {
218         pglfwGetWindowFrameSize glfwGetWindowFrameSize;
219         pglfwPostEmptyEvent glfwPostEmptyEvent;
220         pglfwCreateCursor glfwCreateCursor;
221         pglfwCreateStandardCursor glfwCreateStandardCursor;
222         pglfwDestroyCursor glfwDestroyCursor;
223         pglfwSetCursor glfwSetCursor;
224         pglfwSetCharModsCallback glfwSetCharModsCallback;
225         pglfwSetDropCallback glfwSetDropCallback;
226     }
227 
228     static if(glfwSupport >= GLFWSupport.glfw32) {
229         pglfwSetWindowIcon glfwSetWindowIcon;
230         pglfwSetWindowSizeLimits glfwSetWindowSizeLimits;
231         pglfwSetWindowAspectRatio glfwSetWindowAspectRatio;
232         pglfwMaximizeWindow glfwMaximizeWindow;
233         pglfwFocusWindow glfwFocusWindow;
234         pglfwSetWindowMonitor glfwSetWindowMonitor;
235         pglfwWaitEventsTimeout glfwWaitEventsTimeout;
236         pglfwGetKeyName glfwGetKeyName;
237         pglfwGetTimerValue glfwGetTimerValue;
238         pglfwGetTimerFrequency glfwGetTimerFrequency;
239         pglfwVulkanSupported glfwVulkanSupported;
240         pglfwSetJoystickCallback glfwSetJoystickCallback;
241     }
242 
243     static if(glfwSupport >= GLFWSupport.glfw33) {
244         pglfwInitHint glfwInitHint;
245         pglfwGetError glfwGetError;
246         pglfwGetMonitorWorkarea glfwGetMonitorWorkarea;
247         pglfwGetMonitorContentScale glfwGetMonitorContentScale;
248         pglfwSetMonitorUserPointer glfwSetMonitorUserPointer;
249         pglfwGetMonitorUserPointer glfwGetMonitorUserPointer;
250         pglfwWindowHintString glfwWindowHintString;
251         pglfwGetWindowContentScale glfwGetWindowContentScale;
252         pglfwGetWindowOpacity glfwGetWindowOpacity;
253         pglfwSetWindowOpacity glfwSetWindowOpacity;
254         pglfwRequestWindowAttention glfwRequestWindowAttention;
255         pglfwSetWindowAttrib glfwSetWindowAttrib;
256         pglfwSetWindowMaximizeCallback glfwSetWindowMaximizeCallback;
257         pglfwSetWindowContentScaleCallback glfwSetWindowContentScaleCallback;
258         pglfwGetKeyScancode glfwGetKeyScancode;
259         pglfwGetJoystickHats glfwGetJoystickHats;
260         pglfwGetJoystickGUID glfwGetJoystickGUID;
261         pglfwSetJoystickUserPointer glfwSetJoystickUserPointer;
262         pglfwGetJoystickUserPointer glfwGetJoystickUserPointer;
263         pglfwJoystickIsGamepad glfwJoystickIsGamepad;
264         pglfwUpdateGamepadMappings glfwUpdateGamepadMappings;
265         pglfwGetGamepadName glfwGetGamepadName;
266         pglfwGetGamepadState glfwGetGamepadState;
267     }
268 }
269 
270 private {
271     SharedLib lib;
272     GLFWSupport loadedVersion;
273 }
274 
275 @nogc nothrow:
276 
277 void unloadGLFW()
278 {
279     if(lib != invalidHandle) {
280         lib.unload();
281     }
282 }
283 
284 GLFWSupport loadedGLFWVersion() @safe
285 {
286     return loadedVersion;
287 }
288 
289 bool isGLFWLoaded() @safe
290 {
291     return lib != invalidHandle;
292 }
293 
294 /* This is exposed solely to support the optional loader mixins
295  at the bottom of the module. */
296 void bindGLFWSymbol(void** ptr, const(char)* symbolName)
297 {
298     assert(lib != invalidHandle, "GLFW must be loaded before attempting to bind optional functions.");
299     lib.bindSymbol(ptr, symbolName);
300 }
301 
302 
303 GLFWSupport loadGLFW()
304 {
305     version(Windows) {
306         const(char)[][1] libNames = ["glfw3.dll"];
307     }
308     else version(OSX) {
309         const(char)[][2] libNames = [
310             "libglfw3.dylib",
311             "libglfw.3.dylib"
312         ];
313     }
314     else version(Posix) {
315         const(char)[][4] libNames = [
316             "libglfw3.so",
317             "libglfw.so.3",
318             "/usr/local/lib/libglfw3.so",
319             "/usr/local/lib/libglfw.so.3"
320         ];
321     }
322     else static assert(0, "bindbc-glfw is not yet supported on this platform.");
323 
324     GLFWSupport ret;
325     foreach(name; libNames) {
326         ret = loadGLFW(name.ptr);
327         if(ret != GLFWSupport.noLibrary) break;
328     }
329     return ret;
330 }
331 
332 GLFWSupport loadGLFW(const(char)* libName)
333 {
334     lib = load(libName);
335     if(lib == invalidHandle) {
336         return GLFWSupport.noLibrary;
337     }
338 
339     auto errCount = errorCount();
340     loadedVersion = GLFWSupport.badLibrary;
341 
342     lib.bindSymbol(cast(void**)&glfwInit,"glfwInit");
343     lib.bindSymbol(cast(void**)&glfwTerminate,"glfwTerminate");
344     lib.bindSymbol(cast(void**)&glfwGetVersion,"glfwGetVersion");
345     lib.bindSymbol(cast(void**)&glfwGetVersionString,"glfwGetVersionString");
346     lib.bindSymbol(cast(void**)&glfwSetErrorCallback,"glfwSetErrorCallback");
347     lib.bindSymbol(cast(void**)&glfwGetMonitors,"glfwGetMonitors");
348     lib.bindSymbol(cast(void**)&glfwGetPrimaryMonitor,"glfwGetPrimaryMonitor");
349     lib.bindSymbol(cast(void**)&glfwGetMonitorPos,"glfwGetMonitorPos");
350     lib.bindSymbol(cast(void**)&glfwGetMonitorPhysicalSize,"glfwGetMonitorPhysicalSize");
351     lib.bindSymbol(cast(void**)&glfwGetMonitorName,"glfwGetMonitorName");
352     lib.bindSymbol(cast(void**)&glfwSetMonitorCallback,"glfwSetMonitorCallback");
353     lib.bindSymbol(cast(void**)&glfwGetVideoModes,"glfwGetVideoModes");
354     lib.bindSymbol(cast(void**)&glfwGetVideoMode,"glfwGetVideoMode");
355     lib.bindSymbol(cast(void**)&glfwSetGamma,"glfwSetGamma");
356     lib.bindSymbol(cast(void**)&glfwGetGammaRamp,"glfwGetGammaRamp");
357     lib.bindSymbol(cast(void**)&glfwSetGammaRamp,"glfwSetGammaRamp");
358     lib.bindSymbol(cast(void**)&glfwDefaultWindowHints,"glfwDefaultWindowHints");
359     lib.bindSymbol(cast(void**)&glfwWindowHint,"glfwWindowHint");
360     lib.bindSymbol(cast(void**)&glfwCreateWindow,"glfwCreateWindow");
361     lib.bindSymbol(cast(void**)&glfwDestroyWindow,"glfwDestroyWindow");
362     lib.bindSymbol(cast(void**)&glfwWindowShouldClose,"glfwWindowShouldClose");
363     lib.bindSymbol(cast(void**)&glfwSetWindowShouldClose,"glfwSetWindowShouldClose");
364     lib.bindSymbol(cast(void**)&glfwSetWindowTitle,"glfwSetWindowTitle");
365     lib.bindSymbol(cast(void**)&glfwGetWindowPos,"glfwGetWindowPos");
366     lib.bindSymbol(cast(void**)&glfwSetWindowPos,"glfwSetWindowPos");
367     lib.bindSymbol(cast(void**)&glfwGetWindowSize,"glfwGetWindowSize");
368     lib.bindSymbol(cast(void**)&glfwSetWindowSize,"glfwSetWindowSize");
369     lib.bindSymbol(cast(void**)&glfwGetFramebufferSize,"glfwGetFramebufferSize");
370     lib.bindSymbol(cast(void**)&glfwIconifyWindow,"glfwIconifyWindow");
371     lib.bindSymbol(cast(void**)&glfwRestoreWindow,"glfwRestoreWindow");
372     lib.bindSymbol(cast(void**)&glfwShowWindow,"glfwShowWindow");
373     lib.bindSymbol(cast(void**)&glfwHideWindow,"glfwHideWindow");
374     lib.bindSymbol(cast(void**)&glfwGetWindowMonitor,"glfwGetWindowMonitor");
375     lib.bindSymbol(cast(void**)&glfwGetWindowAttrib,"glfwGetWindowAttrib");
376     lib.bindSymbol(cast(void**)&glfwSetWindowUserPointer,"glfwSetWindowUserPointer");
377     lib.bindSymbol(cast(void**)&glfwGetWindowUserPointer,"glfwGetWindowUserPointer");
378     lib.bindSymbol(cast(void**)&glfwSetWindowPosCallback,"glfwSetWindowPosCallback");
379     lib.bindSymbol(cast(void**)&glfwSetWindowSizeCallback,"glfwSetWindowSizeCallback");
380     lib.bindSymbol(cast(void**)&glfwSetWindowCloseCallback,"glfwSetWindowCloseCallback");
381     lib.bindSymbol(cast(void**)&glfwSetWindowRefreshCallback,"glfwSetWindowRefreshCallback");
382     lib.bindSymbol(cast(void**)&glfwSetWindowFocusCallback,"glfwSetWindowFocusCallback");
383     lib.bindSymbol(cast(void**)&glfwSetWindowIconifyCallback,"glfwSetWindowIconifyCallback");
384     lib.bindSymbol(cast(void**)&glfwSetFramebufferSizeCallback,"glfwSetFramebufferSizeCallback");
385     lib.bindSymbol(cast(void**)&glfwPollEvents,"glfwPollEvents");
386     lib.bindSymbol(cast(void**)&glfwWaitEvents,"glfwWaitEvents");
387     lib.bindSymbol(cast(void**)&glfwGetInputMode,"glfwGetInputMode");
388     lib.bindSymbol(cast(void**)&glfwSetInputMode,"glfwSetInputMode");
389     lib.bindSymbol(cast(void**)&glfwGetKey,"glfwGetKey");
390     lib.bindSymbol(cast(void**)&glfwGetMouseButton,"glfwGetMouseButton");
391     lib.bindSymbol(cast(void**)&glfwGetCursorPos,"glfwGetCursorPos");
392     lib.bindSymbol(cast(void**)&glfwSetCursorPos,"glfwSetCursorPos");
393     lib.bindSymbol(cast(void**)&glfwSetKeyCallback,"glfwSetKeyCallback");
394     lib.bindSymbol(cast(void**)&glfwSetCharCallback,"glfwSetCharCallback");
395     lib.bindSymbol(cast(void**)&glfwSetMouseButtonCallback,"glfwSetMouseButtonCallback");
396     lib.bindSymbol(cast(void**)&glfwSetCursorPosCallback,"glfwSetCursorPosCallback");
397     lib.bindSymbol(cast(void**)&glfwSetScrollCallback,"glfwSetScrollCallback");
398     lib.bindSymbol(cast(void**)&glfwSetCursorEnterCallback,"glfwSetCursorEnterCallback");
399     lib.bindSymbol(cast(void**)&glfwJoystickPresent,"glfwJoystickPresent");
400     lib.bindSymbol(cast(void**)&glfwGetJoystickAxes,"glfwGetJoystickAxes");
401     lib.bindSymbol(cast(void**)&glfwGetJoystickButtons,"glfwGetJoystickButtons");
402     lib.bindSymbol(cast(void**)&glfwGetJoystickName,"glfwGetJoystickName");
403     lib.bindSymbol(cast(void**)&glfwSetClipboardString,"glfwSetClipboardString");
404     lib.bindSymbol(cast(void**)&glfwGetClipboardString,"glfwGetClipboardString");
405     lib.bindSymbol(cast(void**)&glfwGetTime,"glfwGetTime");
406     lib.bindSymbol(cast(void**)&glfwSetTime,"glfwSetTime");
407     lib.bindSymbol(cast(void**)&glfwMakeContextCurrent,"glfwMakeContextCurrent");
408     lib.bindSymbol(cast(void**)&glfwGetCurrentContext,"glfwGetCurrentContext");
409     lib.bindSymbol(cast(void**)&glfwSwapBuffers,"glfwSwapBuffers");
410     lib.bindSymbol(cast(void**)&glfwSwapInterval,"glfwSwapInterval");
411     lib.bindSymbol(cast(void**)&glfwExtensionSupported,"glfwExtensionSupported");
412     lib.bindSymbol(cast(void**)&glfwGetProcAddress,"glfwGetProcAddress");
413 
414     if(errorCount() != errCount) return GLFWSupport.badLibrary;
415     else loadedVersion = GLFWSupport.glfw30;
416 
417     static if(glfwSupport >= GLFWSupport.glfw31) {
418         lib.bindSymbol(cast(void**)&glfwGetWindowFrameSize,"glfwGetWindowFrameSize");
419         lib.bindSymbol(cast(void**)&glfwPostEmptyEvent,"glfwPostEmptyEvent");
420         lib.bindSymbol(cast(void**)&glfwCreateCursor,"glfwCreateCursor");
421         lib.bindSymbol(cast(void**)&glfwCreateStandardCursor,"glfwCreateStandardCursor");
422         lib.bindSymbol(cast(void**)&glfwDestroyCursor,"glfwDestroyCursor");
423         lib.bindSymbol(cast(void**)&glfwSetCursor,"glfwSetCursor");
424         lib.bindSymbol(cast(void**)&glfwSetCharModsCallback,"glfwSetCharModsCallback");
425         lib.bindSymbol(cast(void**)&glfwSetDropCallback,"glfwSetDropCallback");
426 
427         if(errorCount() != errCount) return GLFWSupport.badLibrary;
428         else loadedVersion = GLFWSupport.glfw31;
429     }
430 
431     static if(glfwSupport >= GLFWSupport.glfw32) {
432         lib.bindSymbol(cast(void**)&glfwSetWindowIcon, "glfwSetWindowIcon");
433         lib.bindSymbol(cast(void**)&glfwSetWindowSizeLimits, "glfwSetWindowSizeLimits");
434         lib.bindSymbol(cast(void**)&glfwSetWindowAspectRatio, "glfwSetWindowAspectRatio");
435         lib.bindSymbol(cast(void**)&glfwMaximizeWindow, "glfwMaximizeWindow");
436         lib.bindSymbol(cast(void**)&glfwFocusWindow, "glfwFocusWindow");
437         lib.bindSymbol(cast(void**)&glfwSetWindowMonitor, "glfwSetWindowMonitor");
438         lib.bindSymbol(cast(void**)&glfwWaitEventsTimeout, "glfwWaitEventsTimeout");
439         lib.bindSymbol(cast(void**)&glfwGetKeyName, "glfwGetKeyName");
440         lib.bindSymbol(cast(void**)&glfwGetTimerValue, "glfwGetTimerValue");
441         lib.bindSymbol(cast(void**)&glfwGetTimerFrequency, "glfwGetTimerFrequency");
442         lib.bindSymbol(cast(void**)&glfwVulkanSupported, "glfwVulkanSupported");
443         lib.bindSymbol(cast(void**)&glfwSetJoystickCallback, "glfwSetJoystickCallback");
444 
445         if(errorCount() != errCount) return GLFWSupport.badLibrary;
446         else loadedVersion = GLFWSupport.glfw32;
447     }
448 
449     static if(glfwSupport == GLFWSupport.glfw33) {
450         lib.bindSymbol(cast(void**)&glfwInitHint, "glfwInitHint");
451         lib.bindSymbol(cast(void**)&glfwGetError, "glfwGetError");
452         lib.bindSymbol(cast(void**)&glfwGetMonitorWorkarea, "glfwGetMonitorWorkarea");
453         lib.bindSymbol(cast(void**)&glfwGetMonitorContentScale, "glfwGetMonitorContentScale");
454         lib.bindSymbol(cast(void**)&glfwSetMonitorUserPointer, "glfwSetMonitorUserPointer");
455         lib.bindSymbol(cast(void**)&glfwGetMonitorUserPointer, "glfwGetMonitorUserPointer");
456         lib.bindSymbol(cast(void**)&glfwWindowHintString, "glfwWindowHintString");
457         lib.bindSymbol(cast(void**)&glfwGetWindowContentScale, "glfwGetWindowContentScale");
458         lib.bindSymbol(cast(void**)&glfwGetWindowOpacity, "glfwGetWindowOpacity");
459         lib.bindSymbol(cast(void**)&glfwSetWindowOpacity, "glfwSetWindowOpacity");
460         lib.bindSymbol(cast(void**)&glfwRequestWindowAttention, "glfwRequestWindowAttention");
461         lib.bindSymbol(cast(void**)&glfwSetWindowAttrib, "glfwSetWindowAttrib");
462         lib.bindSymbol(cast(void**)&glfwSetWindowMaximizeCallback, "glfwSetWindowMaximizeCallback");
463         lib.bindSymbol(cast(void**)&glfwSetWindowContentScaleCallback, "glfwSetWindowContentScaleCallback");
464         lib.bindSymbol(cast(void**)&glfwGetKeyScancode, "glfwGetKeyScancode");
465         lib.bindSymbol(cast(void**)&glfwGetJoystickHats, "glfwGetJoystickHats");
466         lib.bindSymbol(cast(void**)&glfwGetJoystickGUID, "glfwGetJoystickGUID");
467         lib.bindSymbol(cast(void**)&glfwSetJoystickUserPointer, "glfwSetJoystickUserPointer");
468         lib.bindSymbol(cast(void**)&glfwGetJoystickUserPointer, "glfwGetJoystickUserPointer");
469         lib.bindSymbol(cast(void**)&glfwJoystickIsGamepad, "glfwJoystickIsGamepad");
470         lib.bindSymbol(cast(void**)&glfwUpdateGamepadMappings, "glfwUpdateGamepadMappings");
471         lib.bindSymbol(cast(void**)&glfwGetGamepadName, "glfwGetGamepadName");
472         lib.bindSymbol(cast(void**)&glfwGetGamepadState, "glfwGetGamepadState");
473 
474         if(errorCount() != errCount) return GLFWSupport.badLibrary;
475         else loadedVersion = GLFWSupport.glfw33;
476     }
477 
478     return loadedVersion;
479 }
480 
481 /*
482     The following allow binding to Vulkan and native system functions using
483     types declared in any Vulkan or system binding, e.g.:
484 
485     ```d
486     module myglfw;
487     public import bindbc.glfw;
488     mixin(glfwVulkanBind);
489     ===============
490     module myapp;
491     import myglfw;
492     void load() {
493         if(!loadGLFW()) {
494             throw new Exception("Failed to load GLFW");
495         }
496         loadGLFW_Vulkan();
497     }
498    ```
499 */
500 static if(glfwSupport >= GLFWSupport.glfw32) {
501     enum bindGLFW_Vulkan = q{
502         extern(C) @nogc nothrow {
503             alias pglfwGetRequiredInstanceExtensions = const(char)** function(uint* count);
504             alias pglfwGetInstanceProcAddress = GLFWvkproc function(VkInstance instance, const(char)* procname);
505             alias pglfwGetPhysicalDevicePresentationSupport = int function(VkInstance instance, VkPhysicalDevice device, uint queuefamily);
506             alias pglfwCreateWindowSurface = VkResult function(VkInstance instance, GLFWwindow* window, const(VkAllocationCallbacks)* allocator, VkSurfaceKHR* surface);
507         }
508 
509         __gshared {
510             pglfwGetRequiredInstanceExtensions glfwGetRequiredInstanceExtensions;
511             pglfwGetInstanceProcAddress glfwGetInstanceProcAddress;
512             pglfwGetPhysicalDevicePresentationSupport glfwGetPhysicalDevicePresentationSupport;
513             pglfwCreateWindowSurface glfwCreateWindowSurface;
514         }
515 
516         @nogc nothrow bool loadGLFW_Vulkan()
517         {
518             import bindbc.loader.sharedlib : errorCount;
519             if(!isGLFWLoaded) return false;
520 
521             auto errCount = errorCount();
522             bindGLFWSymbol(cast(void**)&glfwGetRequiredInstanceExtensions, "glfwGetRequiredInstanceExtensions");
523             bindGLFWSymbol(cast(void**)&glfwGetInstanceProcAddress, "glfwGetInstanceProcAddress");
524             bindGLFWSymbol(cast(void**)&glfwGetPhysicalDevicePresentationSupport, "glfwGetPhysicalDevicePresentationSupport");
525             bindGLFWSymbol(cast(void**)&glfwCreateWindowSurface, "glfwCreateWindowSurface");
526             return errorCount() == errCount;
527         }
528     };
529 }
530 
531 enum bindGLFW_EGL= q{
532     extern(C) @nogc nothrow {
533         alias pglfwGetEGLDisplay = EGLDisplay function();
534         alias pglfwGetEGLContext = EGLContext function(GLFWwindow* window);
535         alias pglfwGetEGLSurface = EGLSurface function(GLFWwindow* window);
536     }
537 
538     __gshared {
539         pglfwGetEGLDisplay glfwGetEGLDisplay;
540         pglfwGetEGLContext glfwGetEGLContext;
541         pglfwGetEGLSurface glfwGetEGLSurface;
542     }
543 
544     @nogc nothrow bool loadGLFW_EGL()
545     {
546         import bindbc.loader.sharedlib : errorCount;
547         if(!isGLFWLoaded) return false;
548 
549         auto errCount = errorCount();
550         bindGLFWSymbol(cast(void**)&glfwGetEGLDisplay, "glfwGetEGLDisplay");
551         bindGLFWSymbol(cast(void**)&glfwGetEGLContext, "glfwGetEGLContext");
552         bindGLFWSymbol(cast(void**)&glfwGetEGLSurface,"glfwGetEGLSurface");
553         return errorCount() == errCount;
554     }
555 };
556 
557 static if(bindWindows) {
558     enum bindGLFW_WGL = q{
559         extern(C) @nogc nothrow alias pglfwGetWGLContext = HGLRC function(GLFWwindow* window);
560         __gshared pglfwGetWGLContext glfwGetWGLContext;
561         void loadGLFW_NSGL() {
562             import bindbc.loader.sharedlib : errorCount;
563             if(!isGLFWLoaded) return false;
564             bindGLFWSymbol(cast(void**)&glfwGetWGLContext,"glfwGetWGLContext");
565         }
566     };
567     static if(glfwSupport >= GLFWSupport.glfw31) {
568         enum bindGLFW_Windows = q{
569             extern(C) @nogc nothrow {
570                 alias pglfwGetWin32Adapter = const(char)* function(GLFWmonitor* monitor);
571                 alias pglfwGetWin32Monitor = const(char)* function(GLFWmonitor* monitor);
572                 alias pglfwGetWin32Window = HWND function(GLFWwindow* window);
573             }
574 
575             __gshared {
576                 pglfwGetWin32Adapter glfwGetWin32Adapter;
577                 pglfwGetWin32Monitor glfwGetWin32Monitor;
578                 pglfwGetWin32Window glfwGetWin32Window;
579             }
580 
581             @nogc nothrow bool loadGLFW_Windows()
582             {
583                 import bindbc.loader.sharedlib : errorCount;
584                 if(!isGLFWLoaded) return false;
585 
586                 auto errCount = errorCount();
587                 bindGLFWSymbol(cast(void**)&glfwGetWin32Adapter, "glfwGetWin32Adapter");
588                 bindGLFWSymbol(cast(void**)&glfwGetWin32Monitor, "glfwGetWin32Monitor");
589                 bindGLFWSymbol(cast(void**)&glfwGetWin32Window,"glfwGetWin32Window");
590                 return errorCount() == errCount;
591             }
592         };
593     }
594     else {
595         enum bindGLFW_Windows = q{
596             extern(C) @nogc nothrow alias pglfwGetWin32Window = HWND function(GLFWwindow* window);
597              __gshared pglfwGetWin32Window glfwGetWin32Window;
598             bool loadGLFW_Windows() {
599                 import bindbc.loader.sharedlib : errorCount;
600                 if(!isGLFWLoaded) return false;
601 
602                 auto errCount = errorCount();
603                 bindGLFWSymbol(cast(void**)&glfwGetWin32Window,"glfwGetWin32Window");
604                 return errorCount() == errCount;
605             }
606         };
607     }
608 }
609 
610 else static if(bindMac) {
611     enum bindGLFW_NSGL = q{
612         extern(C) @nogc nothrow alias pglfwGetNSGLContext = id function(GLFWwindow* window);
613         __gshared pglfwGetNSGLContext glfwGetNSGLContext;
614 
615         @nogc nothrow bool loadGLFW_NSGL() {
616             import bindbc.loader.sharedlib : errorCount;
617             if(!isGLFWLoaded) return false;
618 
619             auto errCount = errorCount();
620             bindGLFWSymbol(cast(void**)&glfwGetNSGLContext, "glfwGetNSGLContext");
621             return errorCount() == errCount;
622         }
623     };
624 
625     static if(glfwSupport >= GLFWSupport.glfw31) {
626         enum glfwCocoaBind = q{
627             extern(C) @nogc nothrow {
628                 alias pglfwGetCocoaMonitor = CGDirectDisplayID function(GLFWmonitor* monitor);
629                 alias pglfwGetCocoaWindow = id function(GLFWwindow* window);
630             }
631 
632             __gshared {
633                 pglfwGetCocoaMonitor glfwGetCocoaMonitor;
634                 pglfwGetCocoaWindow glfwGetCocoaWindow;
635             }
636 
637             @nogc nothrow bool loadGLFW_Cocoa() {
638                 import bindbc.loader.sharedlib : errorCount;
639                 if(!isGLFWLoaded) return false;
640 
641                 auto errCount = errorCount();
642                 bindGLFWSymbol(cast(void**)&glfwGetCocoaMonitor, "glfwGetCocoaMonitor");
643                 bindGLFWSymbol(cast(void**)&glfwGetCocoaWindow,"glfwGetCocoaWindow");
644                 return errorCount() == errCount;
645             }
646         };
647     }
648     else {
649         enum bindGLFW_Cocoa = q{
650             extern(C) @nogc nothrow alias pglfwGetCocoaWindow = id function(GLFWwindow* window);
651             __gshared pglfwGetCocoaWindow glfwGetCocoaWindow;
652 
653             @nogc nothrow bool loadGLFW_Cocoa() {
654                 import bindbc.loader.sharedlib : errorCount;
655                 if(!isGLFWLoaded) return false;
656 
657                 auto errCount = errorCount();
658                 bindGLFWSymbol(cast(void**)&glfwGetCocoaWindow,"glfwGetCocoaWindow");
659                 return errorCount() == errCount;
660             }
661         };
662     }
663 }
664 else static if(bindPosix && !bindAndroid) {
665     static if(glfwSupport >= GLFWSupport.glfw32) {
666         enum bindGLFW_GLX = q{
667             extern(C) @nogc nothrow {
668                 alias pglfwGetGLXContext = GLXContext function(GLFWwindow* window);
669                 alias pglfwGetGLXWindow = GLXWindow function(GLFWwindow* window);
670             }
671 
672             __gshared {
673                 pglfwGetGLXContext glfwGetGLXContext;
674                 pglfwGetGLXWindow glfwGetGLXWindow;
675             }
676 
677             @nogc nothrow bool loadGLFW_GLX() {
678                 import bindbc.loader.sharedlib : errorCount;
679                 if(!isGLFWLoaded) return false;
680 
681                 auto errCount = errorCount();
682                 bindGLFWSymbol(cast(void**)&glfwGetGLXContext, "glfwGetGLXContext");
683                 bindGLFWSymbol(cast(void**)&glfwGetGLXWindow, "glfwGetGLXWindow");
684                 return errorCount() == errCount;
685             }
686         };
687     }
688     else {
689         enum bindGLFW_GLX = q{
690             extern(C) @nogc nothrow alias pglfwGetGLXContext = GLXContext function(GLFWwindow* window);
691             __gshared pglfwGetGLXContext glfwGetGLXContext;
692 
693             @nogc nothrow bool loadGLFW_GLX() {
694                 import bindbc.loader.sharedlib : errorCount;
695                 if(!isGLFWLoaded) return false;
696 
697                 auto errCount = errorCount();
698                 bindGLFWSymbol(cast(void**)&glfwGetGLXContext, "glfwGetGLXContext");
699                 return errorCount() == errCount;
700             }
701         };
702     }
703     static if(glfwSupport >= GLFWSupport.glfw33) {
704         enum bindGLFW_X11= q{
705             extern(C) @nogc nothrow {
706                 alias pglfwGetX11Display = Display* function();
707                 alias pglfwGetX11Window = Window function(GLFWwindow* window);
708                 alias pglfwGetX11Adapter = RRCrtc function(GLFWmonitor* monitor);
709                 alias pglfwGetX11Monitor = RROutput function(GLFWmonitor* monitor);
710                 alias pglfwSetX11SelectionString = void function(const(char)* string_);
711                 alias pglfwGetX11SelectionString = const(char)* function();
712             }
713 
714             __gshared {
715                 pglfwGetX11Display glfwGetX11Display;
716                 pglfwGetX11Window glfwGetX11Window;
717                 pglfwGetX11Adapter glfwGetX11Adapter;
718                 pglfwGetX11Monitor glfwGetX11Monitor;
719                 pglfwSetX11SelectionString glfwSetX11SelectionString;
720                 pglfwGetX11SelectionString glfwGetX11SelectionString;
721             }
722 
723             @nogc nothrow bool loadGLFW_X11() {
724                 import bindbc.loader.sharedlib : errorCount;
725                 if(!isGLFWLoaded) return false;
726 
727                 auto errCount = errorCount();
728                 bindGLFWSymbol(cast(void**)&glfwGetX11Display, "glfwGetX11Display");
729                 bindGLFWSymbol(cast(void**)&glfwGetX11Window,"glfwGetX11Window");
730                 bindGLFWSymbol(cast(void**)&glfwGetX11Adapter, "glfwGetX11Adapter");
731                 bindGLFWSymbol(cast(void**)&glfwGetX11Monitor,"glfwGetX11Monitor");
732                 bindGLFWSymbol(cast(void**)&glfwSetX11SelectionString,"glfwSetX11SelectionString");
733                 bindGLFWSymbol(cast(void**)&glfwGetX11SelectionString,"glfwGetX11SelectionString");
734                 return errorCount() == errCount;
735             }
736         };
737     }
738     else static if(glfwSupport >= GLFWSupport.glfw31) {
739         enum bindGLFW_X11= q{
740             extern(C) @nogc nothrow {
741                 alias pglfwGetX11Display = Display* function();
742                 alias pglfwGetX11Window = Window function(GLFWwindow* window);
743                 alias pglfwGetX11Adapter = RRCrtc function(GLFWmonitor* monitor);
744                 alias pglfwGetX11Monitor = RROutput function(GLFWmonitor* monitor);
745             }
746 
747             __gshared {
748                 pglfwGetX11Display glfwGetX11Display;
749                 pglfwGetX11Window glfwGetX11Window;
750                 pglfwGetX11Adapter glfwGetX11Adapter;
751                 pglfwGetX11Monitor glfwGetX11Monitor;
752             }
753 
754             @nogc nothrow bool loadGLFW_X11() {
755                 import bindbc.loader.sharedlib : errorCount;
756                 if(!isGLFWLoaded) return false;
757 
758                 auto errCount = errorCount();
759                 bindGLFWSymbol(cast(void**)&glfwGetX11Display, "glfwGetX11Display");
760                 bindGLFWSymbol(cast(void**)&glfwGetX11Window,"glfwGetX11Window");
761                 bindGLFWSymbol(cast(void**)&glfwGetX11Adapter, "glfwGetX11Adapter");
762                 bindGLFWSymbol(cast(void**)&glfwGetX11Monitor,"glfwGetX11Monitor");
763                 return errorCount() == errCount;
764             }
765         };
766     }
767     else {
768         enum bindGLFW_X11 = q{
769             extern(C) @nogc nothrow {
770                 alias pglfwGetX11Display = Display* function();
771                 alias pglfwGetX11Window = Window function(GLFWwindow* window);
772             }
773 
774             __gshared {
775                 pglfwGetX11Display glfwGetX11Display;
776                 pglfwGetX11Window glfwGetX11Window;
777             }
778 
779             @nogc nothrow bool loadGLFW_X11() {
780                 import bindbc.loader.sharedlib : errorCount;
781                 if(!isGLFWLoaded) return false;
782 
783                 auto errCount = errorCount();
784                 bindGLFWSymbol(cast(void**)&glfwGetX11Display, "glfwGetX11Display");
785                 bindGLFWSymbol(cast(void**)&glfwGetX11Window,"glfwGetX11Window");
786                 return errorCount() == errCount;
787             }
788         };
789     }
790 
791     static if(glfwSupport >= GLFWSupport.glfw32) {
792         enum gbindGLFW_Wayland = q{
793             extern(C) @nogc nothrow {
794                 alias pglfwGetWaylandDisplay = wl_display* function();
795                 alias pglfwGetWaylandMonitor = wl_output* function(GLFWmonitor* monitor);
796                 alias pglfwGetWaylandWindow = wl_surface* function(GLFWwindow* window);
797             }
798             __gshared {
799                 pglfwGetWaylandDisplay glfwGetWaylandDisplay;
800                 pglfwGetWaylandMonitor glfwGetWaylandMonitor;
801                 pglfwGetWaylandWindow glfwGetWaylandWindow;
802             }
803 
804             @nogc nothrow bool loadGLFW_Wayland() {
805                 import bindbc.loader.sharedlib : errorCount;
806                 if(!isGLFWLoaded) return false;
807 
808                 auto errCount = errorCount();
809                 bindGLFWSymbol(cast(void**)&glfwGetWaylandDisplay, "glfwGetWaylandDisplay");
810                 bindGLFWSymbol(cast(void**)&glfwGetWaylandMonitor, "glfwGetWaylandMonitor");
811                 bindGLFWSymbol(cast(void**)&glfwGetWaylandWindow,"glfwGetWaylandWindow");
812                 return errorCount() == errCount;
813             }
814         };
815     }
816 
817     // Support for Mir was removed in GLFW 3.3
818     static if(glfwSupport == GLFWSupport.glfw32) {
819         enum bindGLFW_Mir = q{
820             extern(C) @nogc nothrow {
821                 alias pglfwGetMirDisplay = MirConnection* function();
822                 alias pglfwGetMirMonitor = int function(GLFWmonitor* monitor);
823                 alias pglfwGetMirWindow = MirSurface* function(GLFWwindow* window);
824             }
825 
826             __gshared {
827                 pglfwGetMirDisplay glfwGetMirDisplay;
828                 pglfwGetMirMonitor glfwGetMirMonitor;
829                 pglfwGetMirWindow glfwGetMirWindow;
830             }
831 
832             @nogc nothrow bool loadGLFW_Mir() {
833                 import bindbc.loader.sharedlib : errorCount;
834                 if(!isGLFWLoaded) return false;
835 
836                 auto errCount = errorCount();
837                 bindGLFWSymbol(cast(void**)&glfwGetMirDisplay, "glfwGetMirDisplay");
838                 bindGLFWSymbol(cast(void**)&glfwGetMirMonitor, "glfwGetMirMonitor");
839                 bindGLFWSymbol(cast(void**)&glfwGetMirWindow,"glfwGetMirWindow");
840                 return errorCount() == errCount;
841             }
842         };
843     }
844 }