1 /**
2  * The header of the native access functions, translated from `glfw3native.h`
3  *
4  * This is the header file of the native access functions.
5  */
6 module glfw3.apinative;
7 
8 extern(C): @nogc: nothrow: __gshared: export:
9 
10 /*************************************************************************
11  * GLFW 3.3 - www.glfw.org
12  * A library for OpenGL, window and input
13  *------------------------------------------------------------------------
14  * Copyright (c) 2002-2006 Marcus Geelnard
15  * Copyright (c) 2006-2018 Camilla Löwy <elmindreda@glfw.org>
16  *
17  * This software is provided 'as-is', without any express or implied
18  * warranty. In no event will the authors be held liable for any damages
19  * arising from the use of this software.
20  *
21  * Permission is granted to anyone to use this software for any purpose,
22  * including commercial applications, and to alter it and redistribute it
23  * freely, subject to the following restrictions:
24  *
25  * 1. The origin of this software must not be misrepresented; you must not
26  *    claim that you wrote the original software. If you use this software
27  *    in a product, an acknowledgment in the product documentation would
28  *    be appreciated but is not required.
29  *
30  * 2. Altered source versions must be plainly marked as such, and must not
31  *    be misrepresented as being the original software.
32  *
33  * 3. This notice may not be removed or altered from any source
34  *    distribution.
35  *
36  *************************************************************************/
37 
38 /** @defgroup native Native access
39  *  Functions related to accessing native handles.
40  *
41  *  **By using the native access functions you assert that you know what you're
42  *  doing and how to fix problems caused by using them.  If you don't, you
43  *  shouldn't be using them.**
44  *
45  *  Before the inclusion of @ref glfw3native.h, you may define zero or more
46  *  window system API macro and zero or more context creation API macros.
47  *
48  *  The chosen backends must match those the library was compiled for.  Failure
49  *  to do this will cause a link-time error.
50  *
51  *  The available window API macros are:
52  *  * `GLFW_EXPOSE_NATIVE_WIN32`
53  *  * `GLFW_EXPOSE_NATIVE_COCOA`
54  *  * `GLFW_EXPOSE_NATIVE_X11`
55  *  * `GLFW_EXPOSE_NATIVE_WAYLAND`
56  *
57  *  The available context API macros are:
58  *  * `GLFW_EXPOSE_NATIVE_WGL`
59  *  * `GLFW_EXPOSE_NATIVE_NSGL`
60  *  * `GLFW_EXPOSE_NATIVE_GLX`
61  *  * `GLFW_EXPOSE_NATIVE_EGL`
62  *  * `GLFW_EXPOSE_NATIVE_OSMESA`
63  *
64  *  These macros select which of the native access functions that are declared
65  *  and which platform-specific headers to include.  It is then up your (by
66  *  definition platform-specific) code to handle which of these should be
67  *  defined.
68  */
69 
70 /*************************************************************************
71  * System headers and types
72  *************************************************************************/
73 
74 // Omitted
75 
76 /*************************************************************************
77  * Functions
78  *************************************************************************/
79 
80 version (GLFW_EXPOSE_NATIVE_WIN32) {
81 /** Returns the adapter device name of the specified monitor.
82  *
83  *  Returns: The UTF-8 encoded adapter device name (for example `\\.\DISPLAY1`)
84  *  of the specified monitor, or `null` if an [error](@ref error_handling)
85  *  occurred.
86  *
87  *  Thread_Safety: This function may be called from any thread.  Access is not
88  *  synchronized.
89  *
90  *  Since: Added in version 3.1.
91  *
92  *  Ingroup: native
93  */
94 const(char)* glfwGetWin32Adapter(GLFWmonitor* monitor);
95 
96 /** Returns the display device name of the specified monitor.
97  *
98  *  Returns: The UTF-8 encoded display device name (for example
99  *  `\\.\DISPLAY1\Monitor0`) of the specified monitor, or `null` if an
100  *  [error](@ref error_handling) occurred.
101  *
102  *  Thread_Safety: This function may be called from any thread.  Access is not
103  *  synchronized.
104  *
105  *  Since: Added in version 3.1.
106  *
107  *  Ingroup: native
108  */
109 const(char)* glfwGetWin32Monitor(GLFWmonitor* monitor);
110 
111 /** Returns the `HWND` of the specified window.
112  *
113  *  Returns: The `HWND` of the specified window, or `null` if an
114  *  [error](@ref error_handling) occurred.
115  *
116  *  Thread_Safety: This function may be called from any thread.  Access is not
117  *  synchronized.
118  *
119  *  Since: Added in version 3.0.
120  *
121  *  Ingroup: native
122  */
123 HWND glfwGetWin32Window(GLFWwindow* window);
124 }
125 
126 version (GLFW_EXPOSE_NATIVE_WGL) {
127 /** Returns the `HGLRC` of the specified window.
128  *
129  *  Returns: The `HGLRC` of the specified window, or `null` if an
130  *  [error](@ref error_handling) occurred.
131  *
132  *  Thread_Safety: This function may be called from any thread.  Access is not
133  *  synchronized.
134  *
135  *  Since: Added in version 3.0.
136  *
137  *  Ingroup: native
138  */
139 HGLRC glfwGetWGLContext(GLFWwindow* window);
140 }
141 
142 version (GLFW_EXPOSE_NATIVE_COCOA) {
143 /** Returns the `CGDirectDisplayID` of the specified monitor.
144  *
145  *  Returns: The `CGDirectDisplayID` of the specified monitor, or
146  *  `kCGNullDirectDisplay` if an [error](@ref error_handling) occurred.
147  *
148  *  Thread_Safety: This function may be called from any thread.  Access is not
149  *  synchronized.
150  *
151  *  Since: Added in version 3.1.
152  *
153  *  Ingroup: native
154  */
155 CGDirectDisplayID glfwGetCocoaMonitor(GLFWmonitor* monitor);
156 
157 /** Returns the `NSWindow` of the specified window.
158  *
159  *  Returns: The `NSWindow` of the specified window, or `nil` if an
160  *  [error](@ref error_handling) occurred.
161  *
162  *  Thread_Safety: This function may be called from any thread.  Access is not
163  *  synchronized.
164  *
165  *  Since: Added in version 3.0.
166  *
167  *  Ingroup: native
168  */
169 id glfwGetCocoaWindow(GLFWwindow* window);
170 }
171 
172 version (GLFW_EXPOSE_NATIVE_NSGL) {
173 /** Returns the `NSOpenGLContext` of the specified window.
174  *
175  *  Returns: The `NSOpenGLContext` of the specified window, or `nil` if an
176  *  [error](@ref error_handling) occurred.
177  *
178  *  Thread_Safety: This function may be called from any thread.  Access is not
179  *  synchronized.
180  *
181  *  Since: Added in version 3.0.
182  *
183  *  Ingroup: native
184  */
185 id glfwGetNSGLContext(GLFWwindow* window);
186 }
187 
188 version (GLFW_EXPOSE_NATIVE_X11) {
189 /** Returns the `Display` used by GLFW.
190  *
191  *  Returns: The `Display` used by GLFW, or `null` if an
192  *  [error](@ref error_handling) occurred.
193  *
194  *  Thread_Safety: This function may be called from any thread.  Access is not
195  *  synchronized.
196  *
197  *  Since: Added in version 3.0.
198  *
199  *  Ingroup: native
200  */
201 Display* glfwGetX11Display();
202 
203 /** Returns the `RRCrtc` of the specified monitor.
204  *
205  *  Returns: The `RRCrtc` of the specified monitor, or `None` if an
206  *  [error](@ref error_handling) occurred.
207  *
208  *  Thread_Safety: This function may be called from any thread.  Access is not
209  *  synchronized.
210  *
211  *  Since: Added in version 3.1.
212  *
213  *  Ingroup: native
214  */
215 RRCrtc glfwGetX11Adapter(GLFWmonitor* monitor);
216 
217 /** Returns the `RROutput` of the specified monitor.
218  *
219  *  Returns: The `RROutput` of the specified monitor, or `None` if an
220  *  [error](@ref error_handling) occurred.
221  *
222  *  Thread_Safety: This function may be called from any thread.  Access is not
223  *  synchronized.
224  *
225  *  Since: Added in version 3.1.
226  *
227  *  Ingroup: native
228  */
229 RROutput glfwGetX11Monitor(GLFWmonitor* monitor);
230 
231 /** Returns the `Window` of the specified window.
232  *
233  *  Returns: The `Window` of the specified window, or `None` if an
234  *  [error](@ref error_handling) occurred.
235  *
236  *  Thread_Safety: This function may be called from any thread.  Access is not
237  *  synchronized.
238  *
239  *  Since: Added in version 3.0.
240  *
241  *  Ingroup: native
242  */
243 Window glfwGetX11Window(GLFWwindow* window);
244 
245 /** Sets the current primary selection to the specified string.
246  *
247  * Params:
248  *  string = A UTF-8 encoded string.
249  *
250  *  Errors: Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
251  *  GLFW_PLATFORM_ERROR.
252  *
253  *  Pointer_lifetime: The specified string is copied before this function
254  *  returns.
255  *
256  *  Thread_Safety: This function must only be called from the main thread.
257  *
258  *  @sa @ref clipboard
259  *  @sa glfwGetX11SelectionString
260  *  @sa glfwSetClipboardString
261  *
262  *  Since: Added in version 3.3.
263  *
264  *  Ingroup: native
265  */
266 void glfwSetX11SelectionString(const(char)* string_);
267 
268 /** Returns the contents of the current primary selection as a string.
269  *
270  *  If the selection is empty or if its contents cannot be converted, `null`
271  *  is returned and a @ref GLFW_FORMAT_UNAVAILABLE error is generated.
272  *
273  *  Returns: The contents of the selection as a UTF-8 encoded string, or `null`
274  *  if an [error](@ref error_handling) occurred.
275  *
276  *  Errors: Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
277  *  GLFW_PLATFORM_ERROR.
278  *
279  *  Pointer_lifetime: The returned string is allocated and freed by GLFW. You
280  *  should not free it yourself. It is valid until the next call to @ref
281  *  glfwGetX11SelectionString or @ref glfwSetX11SelectionString, or until the
282  *  library is terminated.
283  *
284  *  Thread_Safety: This function must only be called from the main thread.
285  *
286  *  @sa @ref clipboard
287  *  @sa glfwSetX11SelectionString
288  *  @sa glfwGetClipboardString
289  *
290  *  Since: Added in version 3.3.
291  *
292  *  Ingroup: native
293  */
294 const(char)* glfwGetX11SelectionString();
295 }
296 
297 version (GLFW_EXPOSE_NATIVE_GLX) {
298 /** Returns the `GLXContext` of the specified window.
299  *
300  *  Returns: The `GLXContext` of the specified window, or `null` if an
301  *  [error](@ref error_handling) occurred.
302  *
303  *  Thread_Safety: This function may be called from any thread.  Access is not
304  *  synchronized.
305  *
306  *  Since: Added in version 3.0.
307  *
308  *  Ingroup: native
309  */
310 GLXContext glfwGetGLXContext(GLFWwindow* window);
311 
312 /** Returns the `GLXWindow` of the specified window.
313  *
314  *  Returns: The `GLXWindow` of the specified window, or `None` if an
315  *  [error](@ref error_handling) occurred.
316  *
317  *  Thread_Safety: This function may be called from any thread.  Access is not
318  *  synchronized.
319  *
320  *  Since: Added in version 3.2.
321  *
322  *  Ingroup: native
323  */
324 GLXWindow glfwGetGLXWindow(GLFWwindow* window);
325 }
326 
327 version (GLFW_EXPOSE_NATIVE_WAYLAND) {
328 /** Returns the `struct wl_display*` used by GLFW.
329  *
330  *  Returns: The `struct wl_display*` used by GLFW, or `null` if an
331  *  [error](@ref error_handling) occurred.
332  *
333  *  Thread_Safety: This function may be called from any thread.  Access is not
334  *  synchronized.
335  *
336  *  Since: Added in version 3.2.
337  *
338  *  Ingroup: native
339  */
340 wl_display* glfwGetWaylandDisplay();
341 
342 /** Returns the `struct wl_output*` of the specified monitor.
343  *
344  *  Returns: The `struct wl_output*` of the specified monitor, or `null` if an
345  *  [error](@ref error_handling) occurred.
346  *
347  *  Thread_Safety: This function may be called from any thread.  Access is not
348  *  synchronized.
349  *
350  *  Since: Added in version 3.2.
351  *
352  *  Ingroup: native
353  */
354 wl_output* glfwGetWaylandMonitor(GLFWmonitor* monitor);
355 
356 /** Returns the main `struct wl_surface*` of the specified window.
357  *
358  *  Returns: The main `struct wl_surface*` of the specified window, or `null` if
359  *  an [error](@ref error_handling) occurred.
360  *
361  *  Thread_Safety: This function may be called from any thread.  Access is not
362  *  synchronized.
363  *
364  *  Since: Added in version 3.2.
365  *
366  *  Ingroup: native
367  */
368 wl_surface* glfwGetWaylandWindow(GLFWwindow* window);
369 }
370 
371 version (GLFW_EXPOSE_NATIVE_EGL) {
372 /** Returns the `EGLDisplay` used by GLFW.
373  *
374  *  Returns: The `EGLDisplay` used by GLFW, or `EGL_NO_DISPLAY` if an
375  *  [error](@ref error_handling) occurred.
376  *
377  *  Thread_Safety: This function may be called from any thread.  Access is not
378  *  synchronized.
379  *
380  *  Since: Added in version 3.0.
381  *
382  *  Ingroup: native
383  */
384 EGLDisplay glfwGetEGLDisplay();
385 
386 /** Returns the `EGLContext` of the specified window.
387  *
388  *  Returns: The `EGLContext` of the specified window, or `EGL_NO_CONTEXT` if an
389  *  [error](@ref error_handling) occurred.
390  *
391  *  Thread_Safety: This function may be called from any thread.  Access is not
392  *  synchronized.
393  *
394  *  Since: Added in version 3.0.
395  *
396  *  Ingroup: native
397  */
398 EGLContext glfwGetEGLContext(GLFWwindow* window);
399 
400 /** Returns the `EGLSurface` of the specified window.
401  *
402  *  Returns: The `EGLSurface` of the specified window, or `EGL_NO_SURFACE` if an
403  *  [error](@ref error_handling) occurred.
404  *
405  *  Thread_Safety: This function may be called from any thread.  Access is not
406  *  synchronized.
407  *
408  *  Since: Added in version 3.0.
409  *
410  *  Ingroup: native
411  */
412 EGLSurface glfwGetEGLSurface(GLFWwindow* window);
413 }
414 
415 version (GLFW_EXPOSE_NATIVE_OSMESA) {
416 /** Retrieves the color buffer associated with the specified window.
417  *
418  * Params:
419  *  window = The window whose color buffer to retrieve.
420  *  width = Where to store the width of the color buffer, or `null`.
421  *  height = Where to store the height of the color buffer, or `null`.
422  *  format = Where to store the OSMesa pixel format of the color
423  *  buffer, or `null`.
424  *  buffer = Where to store the address of the color buffer, or
425  *  `null`.
426  *  Returns: `GLFW_TRUE` if successful, or `GLFW_FALSE` if an
427  *  [error](@ref error_handling) occurred.
428  *
429  *  Thread_Safety: This function may be called from any thread.  Access is not
430  *  synchronized.
431  *
432  *  Since: Added in version 3.3.
433  *
434  *  Ingroup: native
435  */
436 int glfwGetOSMesaColorBuffer(GLFWwindow* window, int* width, int* height, int* format, void** buffer);
437 
438 /** Retrieves the depth buffer associated with the specified window.
439  *
440  * Params:
441  *  window = The window whose depth buffer to retrieve.
442  *  width = Where to store the width of the depth buffer, or `null`.
443  *  height = Where to store the height of the depth buffer, or `null`.
444  *  bytesPerValue = Where to store the number of bytes per depth
445  *  buffer element, or `null`.
446  *  buffer = Where to store the address of the depth buffer, or
447  *  `null`.
448  *  Returns: `GLFW_TRUE` if successful, or `GLFW_FALSE` if an
449  *  [error](@ref error_handling) occurred.
450  *
451  *  Thread_Safety: This function may be called from any thread.  Access is not
452  *  synchronized.
453  *
454  *  Since: Added in version 3.3.
455  *
456  *  Ingroup: native
457  */
458 int glfwGetOSMesaDepthBuffer(GLFWwindow* window, int* width, int* height, int* bytesPerValue, void** buffer);
459 
460 /** Returns the `OSMesaContext` of the specified window.
461  *
462  *  Returns: The `OSMesaContext` of the specified window, or `null` if an
463  *  [error](@ref error_handling) occurred.
464  *
465  *  Thread_Safety: This function may be called from any thread.  Access is not
466  *  synchronized.
467  *
468  *  Since: Added in version 3.3.
469  *
470  *  Ingroup: native
471  */
472 OSMesaContext glfwGetOSMesaContext(GLFWwindow* window);
473 }