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.bindstatic; 8 9 version(BindBC_Static) version = BindGLFW_Static; 10 version(BindGLFW_Static): 11 12 import bindbc.glfw.types; 13 14 extern(C) @nogc nothrow { 15 int glfwInit(); 16 void glfwTerminate(); 17 void glfwGetVersion(int* major, int* minor, int* rev); 18 const(char)* glfwGetVersionString(); 19 GLFWerrorfun glfwSetErrorCallback(GLFWerrorfun callback); 20 GLFWmonitor** glfwGetMonitors(int* count); 21 GLFWmonitor* glfwGetPrimaryMonitor(); 22 void glfwGetMonitorPos(GLFWmonitor* monitor, int* xpos, int* ypos); 23 void glfwGetMonitorPhysicalSize(GLFWmonitor* monitor, int* widthMM, int* heightMM); 24 const(char)* glfwGetMonitorName(GLFWmonitor* monitor); 25 GLFWmonitorfun glfwSetMonitorCallback(GLFWmonitorfun callback); 26 const(GLFWvidmode)* glfwGetVideoModes(GLFWmonitor* monitor, int* count); 27 const(GLFWvidmode)* glfwGetVideoMode(GLFWmonitor* monitor); 28 void glfwSetGamma(GLFWmonitor* monitor, float gamma); 29 const(GLFWgammaramp*) glfwGetGammaRamp(GLFWmonitor* monitor); 30 void glfwSetGammaRamp(GLFWmonitor* monitor, const(GLFWgammaramp)* ramp); 31 void glfwDefaultWindowHints(); 32 void glfwWindowHint(int hint, int value); 33 GLFWwindow* glfwCreateWindow(int width, int height, const(char)* title, GLFWmonitor* monitor, GLFWwindow* share); 34 void glfwDestroyWindow(GLFWwindow* window); 35 int glfwWindowShouldClose(GLFWwindow* window); 36 void glfwSetWindowShouldClose(GLFWwindow* window, int value); 37 void glfwSetWindowTitle(GLFWwindow* window, const(char)* title); 38 void glfwGetWindowPos(GLFWwindow* window, int* xpos, int* ypos); 39 void glfwSetWindowPos(GLFWwindow* window, int xpos, int ypos); 40 void glfwGetWindowSize(GLFWwindow* window, int* width, int* height); 41 void glfwSetWindowSize(GLFWwindow* window, int width, int height); 42 void glfwGetFramebufferSize(GLFWwindow* window, int* width, int* height); 43 void glfwIconifyWindow(GLFWwindow* window); 44 void glfwRestoreWindow(GLFWwindow* window); 45 void glfwShowWindow(GLFWwindow* window); 46 void glfwHideWindow(GLFWwindow* window); 47 GLFWmonitor* glfwGetWindowMonitor(GLFWwindow* window); 48 int glfwGetWindowAttrib(GLFWwindow* window, int attrib); 49 void glfwSetWindowUserPointer(GLFWwindow* window, void* pointer); 50 void* glfwGetWindowUserPointer(GLFWwindow* window); 51 GLFWwindowposfun glfwSetWindowPosCallback(GLFWwindow* window, GLFWwindowposfun callback); 52 GLFWwindowsizefun glfwSetWindowSizeCallback(GLFWwindow* window, GLFWwindowsizefun callback); 53 GLFWwindowclosefun glfwSetWindowCloseCallback(GLFWwindow* window, GLFWwindowclosefun callback); 54 GLFWwindowrefreshfun glfwSetWindowRefreshCallback(GLFWwindow* window, GLFWwindowrefreshfun callback); 55 GLFWwindowfocusfun glfwSetWindowFocusCallback(GLFWwindow* window, GLFWwindowfocusfun callback); 56 GLFWwindowiconifyfun glfwSetWindowIconifyCallback(GLFWwindow* window, GLFWwindowiconifyfun callback); 57 GLFWframebuffersizefun glfwSetFramebufferSizeCallback(GLFWwindow* window, GLFWframebuffersizefun callback); 58 void glfwPollEvents(); 59 void glfwWaitEvents(); 60 int glfwGetInputMode(GLFWwindow* window, int mode); 61 void glfwSetInputMode(GLFWwindow* window, int mode, int value); 62 int glfwGetKey(GLFWwindow* window, int key); 63 int glfwGetMouseButton(GLFWwindow* window, int button); 64 void glfwGetCursorPos(GLFWwindow* window, double* xpos, double* ypos); 65 void glfwSetCursorPos(GLFWwindow* window, double xpos, double ypos); 66 GLFWkeyfun glfwSetKeyCallback(GLFWwindow* window, GLFWkeyfun callback); 67 GLFWcharfun glfwSetCharCallback(GLFWwindow* window, GLFWcharfun callback); 68 GLFWmousebuttonfun glfwSetMouseButtonCallback(GLFWwindow* window, GLFWmousebuttonfun callback); 69 GLFWcursorposfun glfwSetCursorPosCallback(GLFWwindow* window, GLFWcursorposfun callback); 70 GLFWcursorenterfun glfwSetCursorEnterCallback(GLFWwindow* window, GLFWcursorenterfun callback); 71 GLFWscrollfun glfwSetScrollCallback(GLFWwindow* window, GLFWscrollfun callback); 72 int glfwJoystickPresent(int jid); 73 float* glfwGetJoystickAxes(int jid, int* count); 74 ubyte* glfwGetJoystickButtons(int jid, int* count); 75 const(char)* glfwGetJoystickName(int jid); 76 void glfwSetClipboardString(GLFWwindow* window, const(char)* string_); 77 const(char)* glfwGetClipboardString(GLFWwindow* window); 78 double glfwGetTime(); 79 void glfwSetTime(double time); 80 void glfwMakeContextCurrent(GLFWwindow* window); 81 GLFWwindow* glfwGetCurrentContext(); 82 void glfwSwapBuffers(GLFWwindow* window); 83 void glfwSwapInterval(int interval); 84 int glfwExtensionSupported(const(char)* extension); 85 GLFWglproc glfwGetProcAddress(const(char)* procname); 86 87 static if(glfwSupport >= GLFWSupport.glfw31) { 88 void glfwGetWindowFrameSize(GLFWwindow* window, int* left, int* top, int* right, int* bottom); 89 void glfwPostEmptyEvent(); 90 GLFWcursor* glfwCreateCursor(const(GLFWimage)* image, int xhot, int yhot); 91 GLFWcursor* glfwCreateStandardCursor(int shape); 92 void glfwDestroyCursor(GLFWcursor* cursor); 93 void glfwSetCursor(GLFWwindow* window, GLFWcursor* cursor); 94 GLFWcharmodsfun glfwSetCharModsCallback(GLFWwindow* window, GLFWcharmodsfun callback); 95 GLFWdropfun glfwSetDropCallback(GLFWwindow* window, GLFWdropfun callback); 96 } 97 98 static if(glfwSupport >= GLFWSupport.glfw32) { 99 void glfwSetWindowIcon(GLFWwindow* window, int count, const(GLFWimage)* images); 100 void glfwSetWindowSizeLimits(GLFWwindow* window, int minwidth, int minheight, int maxwidth, int maxheight); 101 void glfwSetWindowAspectRatio(GLFWwindow* window, int numer, int denom); 102 void glfwMaximizeWindow(GLFWwindow* window); 103 void glfwFocusWindow(GLFWwindow* window); 104 void glfwSetWindowMonitor(GLFWwindow* window, GLFWmonitor* monitor, int xpos, int ypos, int width, int height, int refreshRate); 105 void glfwWaitEventsTimeout(double timeout); 106 const(char)* glfwGetKeyName(int key, int scancode); 107 long glfwGetTimerValue(); 108 long glfwGetTimerFrequency(); 109 int glfwVulkanSupported(); 110 GLFWjoystickfun glfwSetJoystickCallback(GLFWjoystickfun callback); 111 } 112 113 static if(glfwSupport >= GLFWSupport.glfw33) { 114 void glfwInitHint(int,int); 115 int glfwGetError(const(char)** description); 116 void glfwGetMonitorWorkarea(GLFWmonitor* monitor, int* xpos, int* ypos, int* width, int* height); 117 void glfwGetMonitorContentScale(GLFWmonitor* monitor, float* xscale, float* yscale); 118 void glfwSetMonitorUserPointer(GLFWmonitor* monitor, void* pointer); 119 void* glfwGetMonitorUserPointer(GLFWmonitor* monitor); 120 void glfwWindowHintString(int hint,const(char)* value); 121 void glfwGetWindowContentScale(GLFWwindow* window, float* xscale, float* yscale); 122 float glfwGetWindowOpacity(GLFWwindow* window); 123 void glfwSetWindowOpacity(GLFWwindow* window, float opacity); 124 void glfwRequestWindowAttention(GLFWwindow* window); 125 void glfwSetWindowAttrib(GLFWwindow* window, int attrib, int value); 126 GLFWwindowmaximizefun glfwSetWindowMaximizeCallback(GLFWwindow* window, GLFWwindowmaximizefun callback); 127 GLFWwindowcontentscalefun glfwSetWindowContentScaleCallback(GLFWwindow* window, GLFWwindowcontentscalefun callback); 128 int glfwGetKeyScancode(int key); 129 const(ubyte)* glfwGetJoystickHats(int jid, int* count); 130 const(char)* glfwGetJoystickGUID(int jid); 131 void glfwSetJoystickUserPointer(int jid, void* pointer); 132 void* glfwGetJoystickUserPointer(int jid); 133 int glfwJoystickIsGamepad(int jid); 134 int glfwUpdateGamepadMappings(const(char)* string_); 135 const(char)* glfwGetGamepadName(int jid); 136 int glfwGetGamepadState(int jid, GLFWgamepadstate* state); 137 } 138 } 139 140 /* 141 The following allow binding to Vulkan and native system functions using 142 types declared in any Vulkan or system binding, e.g.: 143 144 ```d 145 module myglfw; 146 public import bindbc.glfw; 147 mixin(bindGLFW_Vulkan); 148 ``` 149 */ 150 151 // Vulkan 152 static if(glfwSupport >= GLFWSupport.glfw32) { 153 enum bindGLFW_Vulkan = q{ 154 extern(C) @nogc nothrow { 155 const(char)** glfwGetRequiredInstanceExtensions(uint* count); 156 GLFWvkproc glfwGetInstanceProcAddress(VkInstance instance, const(char)* procname); 157 int glfwGetPhysicalDevicePresentationSupport(VkInstance instance, VkPhysicalDevice device, uint queuefamily); 158 VkResult glfwCreateWindowSurface(VkInstance instance, GLFWwindow* window, const(VkAllocationCallbacks)* allocator, VkSurfaceKHR* surface); 159 } 160 }; 161 } 162 163 // EGL 164 enum bindGLFW_EGL = q{ 165 extern(C) @nogc nothrow { 166 EGLDisplay glfwGetEGLDisplay(); 167 EGLContext glfwGetEGLContext(GLFWwindow* window); 168 EGLSurface glfwGetEGLSurface(GLFWwindow* window); 169 } 170 }; 171 172 version(Windows) { 173 enum bindGLFW_WGL = q{ 174 extern(C) @nogc nothrow HGLRC glfwGetWGLContext(GLFWwindow* window); 175 }; 176 177 static if(glfwSupport >= GLFWSupport.glfw31) { 178 enum bindGLFW_Windows = q{ 179 extern(C) @nogc nothrow { 180 HWND glfwGetWin32Window(GLFWwindow* window); 181 const(char)* glfwGetWin32Adapter(GLFWmonitor* monitor); 182 const(char)* glfwGetWin32Monitor(GLFWmonitor* monitor); 183 } 184 }; 185 } 186 else enum bindGLFW_Windows= q{ 187 extern(C) @nogc nothrow HWND glfwGetWin32Window(GLFWwindow* window); 188 }; 189 } 190 191 version(OSX) { 192 enum bindGLFW_NSGL = q{ 193 extern(C) @nogc nothrow id glfwGetNSGLContext(GLFWwindow* window); 194 }; 195 196 static if(glfwSupport >= GLFWSupport.glfw31) { 197 enum bindGLFW_Cocoa = q{ 198 extern(C) @nogc nothrow { 199 CGDirectDisplayID glfwGetCocoaMonitor(GLFWmonitor* monitor); 200 id glfwGetCocoaWindow(GLFWwindow* window); 201 } 202 }; 203 } 204 else enum bindGLFW_Cocoa = q{ 205 extern(C) @nogc nothrow id glfwGetCocoaWindow(GLFWwindow* window); 206 }; 207 } 208 else version(Android) {} 209 else version(Posix) { 210 // X11 211 static if(glfwSupport >= GLFWSupport.glfw32) { 212 enum bindGLFW_GLX = q{ 213 extern(C) @nogc nothrow { 214 GLXContext glfwGetGLXContext(GLFWwindow* window); 215 GLXwindow glfwGetGLXWindow(GLFWwindow* window); 216 } 217 }; 218 } 219 else enum bindGLFW_GLX = q{ 220 extern(C) @nogc nothrow GLXContext glfwGetGLXContext(GLFWwindow* window); 221 }; 222 static if(glfwSupport >= GLFWSupport.glfw33) { 223 enum bindGLFW_X11 = q{ 224 extern(C) @nogc nothrow { 225 Display* glfwGetX11Display(); 226 Window glfwGetX11Window(GLFWwindow* window); 227 RRCrtc glfwGetX11Adapter(GLFWmonitor* monitor); 228 RROutput glfwGetX11Monitor(GLFWmonitor* monitor); 229 void glfwSetX11SelectionString(const(char)* string_); 230 const(char)* glfwGetX11SelectionString(); 231 } 232 }; 233 } 234 else static if(glfwSupport >= GLFWSupport.glfw31) { 235 enum bindGLFW_X11 = q{ 236 extern(C) @nogc nothrow { 237 Display* glfwGetX11Display(); 238 Window glfwGetX11Window(GLFWwindow* window); 239 RRCrtc glfwGetX11Adapter(GLFWmonitor* monitor); 240 RROutput glfwGetX11Monitor(GLFWmonitor* monitor); 241 } 242 }; 243 } 244 else enum bindGLFW_X11 = q{ 245 extern(C) @nogc nothrow { 246 Display* glfwGetX11Display(); 247 Window glfwGetX11Window(GLFWwindow* window); 248 } 249 }; 250 251 // Wayland 252 static if(glfwSupport >= GLFWSupport.glfw32) { 253 enum bindGLFW_Wayland = q{ 254 extern(C) @nogc nothrow { 255 wl_display* glfwGetWaylandDisplay(); 256 wl_output* glfwGetWaylandMonitor(GLFWmonitor* monitor); 257 wl_surface* glfwGetWaylandWindow(GLFWwindow* window); 258 } 259 }; 260 } 261 262 // Mir 263 // Removed in GLFW 3.3 264 static if(glfwSupport == GLFWSupport.glfw32) { 265 enum bindGLFW_Mir = q{ 266 extern(C) @nogc nothrow { 267 MirConnection* glfwGetMirDisplay(); 268 int glfwGetMirMonitor(GLFWmonitor* monitor); 269 MirSurface* glfwGetMirWindow(GLFWwindow* window); 270 } 271 }; 272 } 273 }