|
| 1 | +/************************************************************************* |
| 2 | + * GLFW 3.0 - www.glfw.org |
| 3 | + * A library for OpenGL, window and input |
| 4 | + *------------------------------------------------------------------------ |
| 5 | + * Copyright (c) 2002-2006 Marcus Geelnard |
| 6 | + * Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.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 | + |
| 41 | +/*! @defgroup native Native access |
| 42 | + * |
| 43 | + * **By using the native API, you assert that you know what you're doing and |
| 44 | + * how to fix problems caused by using it. If you don't, you shouldn't be |
| 45 | + * using it.** |
| 46 | + * |
| 47 | + * Before the inclusion of @ref glfw3native.h, you must define exactly one |
| 48 | + * window API macro and exactly one context API macro. Failure to do this |
| 49 | + * will cause a compile-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 | + * |
| 56 | + * The available context API macros are: |
| 57 | + * * `GLFW_EXPOSE_NATIVE_WGL` |
| 58 | + * * `GLFW_EXPOSE_NATIVE_NSGL` |
| 59 | + * * `GLFW_EXPOSE_NATIVE_GLX` |
| 60 | + * * `GLFW_EXPOSE_NATIVE_EGL` |
| 61 | + * |
| 62 | + * These macros select which of the native access functions that are declared |
| 63 | + * and which platform-specific headers to include. It is then up your (by |
| 64 | + * definition platform-specific) code to handle which of these should be |
| 65 | + * defined. |
| 66 | + */ |
| 67 | + |
| 68 | + |
| 69 | +/************************************************************************* |
| 70 | + * System headers and types |
| 71 | + *************************************************************************/ |
| 72 | + |
| 73 | +#if defined(GLFW_EXPOSE_NATIVE_WIN32) |
| 74 | + #include <windows.h> |
| 75 | +#elif defined(GLFW_EXPOSE_NATIVE_COCOA) |
| 76 | + #if defined(__OBJC__) |
| 77 | + #import <Cocoa/Cocoa.h> |
| 78 | + #else |
| 79 | + typedef void* id; |
| 80 | + #endif |
| 81 | +#elif defined(GLFW_EXPOSE_NATIVE_X11) |
| 82 | + #include <X11/Xlib.h> |
| 83 | +#else |
| 84 | + #error "No window API specified" |
| 85 | +#endif |
| 86 | + |
| 87 | +#if defined(GLFW_EXPOSE_NATIVE_WGL) |
| 88 | + /* WGL is declared by windows.h */ |
| 89 | +#elif defined(GLFW_EXPOSE_NATIVE_NSGL) |
| 90 | + /* NSGL is declared by Cocoa.h */ |
| 91 | +#elif defined(GLFW_EXPOSE_NATIVE_GLX) |
| 92 | + #include <GL/glx.h> |
| 93 | +#elif defined(GLFW_EXPOSE_NATIVE_EGL) |
| 94 | + #include <EGL/egl.h> |
| 95 | +#else |
| 96 | + #error "No context API specified" |
| 97 | +#endif |
| 98 | + |
| 99 | + |
| 100 | +/************************************************************************* |
| 101 | + * Functions |
| 102 | + *************************************************************************/ |
| 103 | + |
| 104 | +#if defined(GLFW_EXPOSE_NATIVE_WIN32) |
| 105 | +/*! @brief Returns the `HWND` of the specified window. |
| 106 | + * @return The `HWND` of the specified window. |
| 107 | + * @ingroup native |
| 108 | + */ |
| 109 | +GLFWAPI HWND glfwGetWin32Window(GLFWwindow* window); |
| 110 | +#endif |
| 111 | + |
| 112 | +#if defined(GLFW_EXPOSE_NATIVE_WGL) |
| 113 | +/*! @brief Returns the `HGLRC` of the specified window. |
| 114 | + * @return The `HGLRC` of the specified window. |
| 115 | + * @ingroup native |
| 116 | + */ |
| 117 | +GLFWAPI HGLRC glfwGetWGLContext(GLFWwindow* window); |
| 118 | +#endif |
| 119 | + |
| 120 | +#if defined(GLFW_EXPOSE_NATIVE_COCOA) |
| 121 | +/*! @brief Returns the `NSWindow` of the specified window. |
| 122 | + * @return The `NSWindow` of the specified window. |
| 123 | + * @ingroup native |
| 124 | + */ |
| 125 | +GLFWAPI id glfwGetCocoaWindow(GLFWwindow* window); |
| 126 | +#endif |
| 127 | + |
| 128 | +#if defined(GLFW_EXPOSE_NATIVE_NSGL) |
| 129 | +/*! @brief Returns the `NSOpenGLContext` of the specified window. |
| 130 | + * @return The `NSOpenGLContext` of the specified window. |
| 131 | + * @ingroup native |
| 132 | + */ |
| 133 | +GLFWAPI id glfwGetNSGLContext(GLFWwindow* window); |
| 134 | +#endif |
| 135 | + |
| 136 | +#if defined(GLFW_EXPOSE_NATIVE_X11) |
| 137 | +/*! @brief Returns the `Display` used by GLFW. |
| 138 | + * @return The `Display` used by GLFW. |
| 139 | + * @ingroup native |
| 140 | + */ |
| 141 | +GLFWAPI Display* glfwGetX11Display(void); |
| 142 | +/*! @brief Returns the `Window` of the specified window. |
| 143 | + * @return The `Window` of the specified window. |
| 144 | + * @ingroup native |
| 145 | + */ |
| 146 | +GLFWAPI Window glfwGetX11Window(GLFWwindow* window); |
| 147 | +#endif |
| 148 | + |
| 149 | +#if defined(GLFW_EXPOSE_NATIVE_GLX) |
| 150 | +/*! @brief Returns the `GLXContext` of the specified window. |
| 151 | + * @return The `GLXContext` of the specified window. |
| 152 | + * @ingroup native |
| 153 | + */ |
| 154 | +GLFWAPI GLXContext glfwGetGLXContext(GLFWwindow* window); |
| 155 | +#endif |
| 156 | + |
| 157 | +#if defined(GLFW_EXPOSE_NATIVE_EGL) |
| 158 | +/*! @brief Returns the `EGLDisplay` used by GLFW. |
| 159 | + * @return The `EGLDisplay` used by GLFW. |
| 160 | + * @ingroup native |
| 161 | + */ |
| 162 | +GLFWAPI EGLDisplay glfwGetEGLDisplay(void); |
| 163 | +/*! @brief Returns the `EGLContext` of the specified window. |
| 164 | + * @return The `EGLContext` of the specified window. |
| 165 | + * @ingroup native |
| 166 | + */ |
| 167 | +GLFWAPI EGLContext glfwGetEGLContext(GLFWwindow* window); |
| 168 | +/*! @brief Returns the `EGLSurface` of the specified window. |
| 169 | + * @return The `EGLSurface` of the specified window. |
| 170 | + * @ingroup native |
| 171 | + */ |
| 172 | +GLFWAPI EGLSurface glfwGetEGLSurface(GLFWwindow* window); |
| 173 | +#endif |
| 174 | + |
| 175 | +#ifdef __cplusplus |
| 176 | +} |
| 177 | +#endif |
| 178 | + |
| 179 | +#endif /* _glfw3_native_h_ */ |
| 180 | + |
0 commit comments