glfw3native.h
Go to the documentation of this file.
1 /*************************************************************************
2  * GLFW 3.3 - www.glfw.org
3  * A library for OpenGL, window and input
4  *------------------------------------------------------------------------
5  * Copyright (c) 2002-2006 Marcus Geelnard
6  * Copyright (c) 2006-2018 Camilla Löwy <elmindreda@glfw.org>
7  *
8  * This software is provided 'as-is', without any express or implied
9  * warranty. In no event will the authors be held liable for any damages
10  * arising from the use of this software.
11  *
12  * Permission is granted to anyone to use this software for any purpose,
13  * including commercial applications, and to alter it and redistribute it
14  * freely, subject to the following restrictions:
15  *
16  * 1. The origin of this software must not be misrepresented; you must not
17  * claim that you wrote the original software. If you use this software
18  * in a product, an acknowledgment in the product documentation would
19  * be appreciated but is not required.
20  *
21  * 2. Altered source versions must be plainly marked as such, and must not
22  * be misrepresented as being the original software.
23  *
24  * 3. This notice may not be removed or altered from any source
25  * distribution.
26  *
27  *************************************************************************/
28 
29 #ifndef _glfw3_native_h_
30 #define _glfw3_native_h_
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 
37 /*************************************************************************
38  * Doxygen documentation
39  *************************************************************************/
40 
90 /*************************************************************************
91  * System headers and types
92  *************************************************************************/
93 
94 #if !defined(GLFW_NATIVE_INCLUDE_NONE)
95 
96  #if defined(GLFW_EXPOSE_NATIVE_WIN32) || defined(GLFW_EXPOSE_NATIVE_WGL)
97  /* This is a workaround for the fact that glfw3.h needs to export APIENTRY (for
98  * example to allow applications to correctly declare a GL_KHR_debug callback)
99  * but windows.h assumes no one will define APIENTRY before it does
100  */
101  #if defined(GLFW_APIENTRY_DEFINED)
102  #undef APIENTRY
103  #undef GLFW_APIENTRY_DEFINED
104  #endif
105  #include <windows.h>
106  #elif defined(GLFW_EXPOSE_NATIVE_COCOA) || defined(GLFW_EXPOSE_NATIVE_NSGL)
107  #if defined(__OBJC__)
108  #import <Cocoa/Cocoa.h>
109  #else
110  #include <ApplicationServices/ApplicationServices.h>
111  #include <objc/objc.h>
112  #endif
113  #elif defined(GLFW_EXPOSE_NATIVE_X11) || defined(GLFW_EXPOSE_NATIVE_GLX)
114  #include <X11/Xlib.h>
115  #include <X11/extensions/Xrandr.h>
116  #elif defined(GLFW_EXPOSE_NATIVE_WAYLAND)
117  #include <wayland-client.h>
118  #endif
119 
120  #if defined(GLFW_EXPOSE_NATIVE_WGL)
121  /* WGL is declared by windows.h */
122  #endif
123  #if defined(GLFW_EXPOSE_NATIVE_NSGL)
124  /* NSGL is declared by Cocoa.h */
125  #endif
126  #if defined(GLFW_EXPOSE_NATIVE_GLX)
127  /* This is a workaround for the fact that glfw3.h defines GLAPIENTRY because by
128  * default it also acts as an OpenGL header
129  * However, glx.h will include gl.h, which will define it unconditionally
130  */
131  #if defined(GLFW_GLAPIENTRY_DEFINED)
132  #undef GLAPIENTRY
133  #undef GLFW_GLAPIENTRY_DEFINED
134  #endif
135  #include <GL/glx.h>
136  #endif
137  #if defined(GLFW_EXPOSE_NATIVE_EGL)
138  #include <EGL/egl.h>
139  #endif
140  #if defined(GLFW_EXPOSE_NATIVE_OSMESA)
141  /* This is a workaround for the fact that glfw3.h defines GLAPIENTRY because by
142  * default it also acts as an OpenGL header
143  * However, osmesa.h will include gl.h, which will define it unconditionally
144  */
145  #if defined(GLFW_GLAPIENTRY_DEFINED)
146  #undef GLAPIENTRY
147  #undef GLFW_GLAPIENTRY_DEFINED
148  #endif
149  #include <GL/osmesa.h>
150  #endif
151 
152 #endif /*GLFW_NATIVE_INCLUDE_NONE*/
153 
154 
155 /*************************************************************************
156  * Functions
157  *************************************************************************/
158 
159 #if defined(GLFW_EXPOSE_NATIVE_WIN32)
160 
175 GLFWAPI const char* glfwGetWin32Adapter(GLFWmonitor* monitor);
176 
192 GLFWAPI const char* glfwGetWin32Monitor(GLFWmonitor* monitor);
193 
216 GLFWAPI HWND glfwGetWin32Window(GLFWwindow* window);
217 #endif
218 
219 #if defined(GLFW_EXPOSE_NATIVE_WGL)
220 
243 GLFWAPI HGLRC glfwGetWGLContext(GLFWwindow* window);
244 #endif
245 
246 #if defined(GLFW_EXPOSE_NATIVE_COCOA)
247 
261 GLFWAPI CGDirectDisplayID glfwGetCocoaMonitor(GLFWmonitor* monitor);
262 
277 GLFWAPI id glfwGetCocoaWindow(GLFWwindow* window);
278 #endif
279 
280 #if defined(GLFW_EXPOSE_NATIVE_NSGL)
281 
296 GLFWAPI id glfwGetNSGLContext(GLFWwindow* window);
297 #endif
298 
299 #if defined(GLFW_EXPOSE_NATIVE_X11)
300 
314 GLFWAPI Display* glfwGetX11Display(void);
315 
330 GLFWAPI RRCrtc glfwGetX11Adapter(GLFWmonitor* monitor);
331 
346 GLFWAPI RROutput glfwGetX11Monitor(GLFWmonitor* monitor);
347 
362 GLFWAPI Window glfwGetX11Window(GLFWwindow* window);
363 
384 GLFWAPI void glfwSetX11SelectionString(const char* string);
385 
412 GLFWAPI const char* glfwGetX11SelectionString(void);
413 #endif
414 
415 #if defined(GLFW_EXPOSE_NATIVE_GLX)
416 
431 GLFWAPI GLXContext glfwGetGLXContext(GLFWwindow* window);
432 
448 GLFWAPI GLXWindow glfwGetGLXWindow(GLFWwindow* window);
449 #endif
450 
451 #if defined(GLFW_EXPOSE_NATIVE_WAYLAND)
452 
466 GLFWAPI struct wl_display* glfwGetWaylandDisplay(void);
467 
482 GLFWAPI struct wl_output* glfwGetWaylandMonitor(GLFWmonitor* monitor);
483 
498 GLFWAPI struct wl_surface* glfwGetWaylandWindow(GLFWwindow* window);
499 #endif
500 
501 #if defined(GLFW_EXPOSE_NATIVE_EGL)
502 
519 GLFWAPI EGLDisplay glfwGetEGLDisplay(void);
520 
536 GLFWAPI EGLContext glfwGetEGLContext(GLFWwindow* window);
537 
553 GLFWAPI EGLSurface glfwGetEGLSurface(GLFWwindow* window);
554 #endif
555 
556 #if defined(GLFW_EXPOSE_NATIVE_OSMESA)
557 
579 GLFWAPI int glfwGetOSMesaColorBuffer(GLFWwindow* window, int* width, int* height, int* format, void** buffer);
580 
603 GLFWAPI int glfwGetOSMesaDepthBuffer(GLFWwindow* window, int* width, int* height, int* bytesPerValue, void** buffer);
604 
620 GLFWAPI OSMesaContext glfwGetOSMesaContext(GLFWwindow* window);
621 #endif
622 
623 #ifdef __cplusplus
624 }
625 #endif
626 
627 #endif /* _glfw3_native_h_ */
628 
HGLRC glfwGetWGLContext(GLFWwindow *window)
Returns the HGLRC of the specified window.
id glfwGetCocoaWindow(GLFWwindow *window)
Returns the NSWindow of the specified window.
EGLSurface glfwGetEGLSurface(GLFWwindow *window)
Returns the EGLSurface of the specified window.
OSMesaContext glfwGetOSMesaContext(GLFWwindow *window)
Returns the OSMesaContext of the specified window.
int glfwGetOSMesaDepthBuffer(GLFWwindow *window, int *width, int *height, int *bytesPerValue, void **buffer)
Retrieves the depth buffer associated with the specified window.
int glfwGetOSMesaColorBuffer(GLFWwindow *window, int *width, int *height, int *format, void **buffer)
Retrieves the color buffer associated with the specified window.
const char * glfwGetWin32Monitor(GLFWmonitor *monitor)
Returns the display device name of the specified monitor.
CGDirectDisplayID glfwGetCocoaMonitor(GLFWmonitor *monitor)
Returns the CGDirectDisplayID of the specified monitor.
RRCrtc glfwGetX11Adapter(GLFWmonitor *monitor)
Returns the RRCrtc of the specified monitor.
HWND glfwGetWin32Window(GLFWwindow *window)
Returns the HWND of the specified window.
id glfwGetNSGLContext(GLFWwindow *window)
Returns the NSOpenGLContext of the specified window.
EGLDisplay glfwGetEGLDisplay(void)
Returns the EGLDisplay used by GLFW.
Window glfwGetX11Window(GLFWwindow *window)
Returns the Window of the specified window.
struct GLFWmonitor GLFWmonitor
Opaque monitor object.
Definition: glfw3.h:1173
struct GLFWwindow GLFWwindow
Opaque window object.
Definition: glfw3.h:1185
Display * glfwGetX11Display(void)
Returns the Display used by GLFW.
const char * glfwGetX11SelectionString(void)
Returns the contents of the current primary selection as a string.
GLXContext glfwGetGLXContext(GLFWwindow *window)
Returns the GLXContext of the specified window.
EGLContext glfwGetEGLContext(GLFWwindow *window)
Returns the EGLContext of the specified window.
void glfwSetX11SelectionString(const char *string)
Sets the current primary selection to the specified string.
const char * glfwGetWin32Adapter(GLFWmonitor *monitor)
Returns the adapter device name of the specified monitor.
GLXWindow glfwGetGLXWindow(GLFWwindow *window)
Returns the GLXWindow of the specified window.
struct wl_output * glfwGetWaylandMonitor(GLFWmonitor *monitor)
Returns the struct wl_output* of the specified monitor.
struct wl_display * glfwGetWaylandDisplay(void)
Returns the struct wl_display* used by GLFW.
RROutput glfwGetX11Monitor(GLFWmonitor *monitor)
Returns the RROutput of the specified monitor.
struct wl_surface * glfwGetWaylandWindow(GLFWwindow *window)
Returns the main struct wl_surface* of the specified window.