glfw3native.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  1. /*************************************************************************
  2. * GLFW 3.1 - 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. #ifndef _glfw3_native_h_
  29. #define _glfw3_native_h_
  30. #ifdef __cplusplus
  31. extern "C" {
  32. #endif
  33. /*************************************************************************
  34. * Doxygen documentation
  35. *************************************************************************/
  36. /*! @defgroup native Native access
  37. *
  38. * **By using the native access functions you assert that you know what you're
  39. * doing and how to fix problems caused by using them. If you don't, you
  40. * shouldn't be using them.**
  41. *
  42. * Before the inclusion of @ref glfw3native.h, you must define exactly one
  43. * window system API macro and exactly one context creation API macro. Failure
  44. * to do this will cause a compile-time error.
  45. *
  46. * The available window API macros are:
  47. * * `GLFW_EXPOSE_NATIVE_WIN32`
  48. * * `GLFW_EXPOSE_NATIVE_COCOA`
  49. * * `GLFW_EXPOSE_NATIVE_X11`
  50. *
  51. * The available context API macros are:
  52. * * `GLFW_EXPOSE_NATIVE_WGL`
  53. * * `GLFW_EXPOSE_NATIVE_NSGL`
  54. * * `GLFW_EXPOSE_NATIVE_GLX`
  55. * * `GLFW_EXPOSE_NATIVE_EGL`
  56. *
  57. * These macros select which of the native access functions that are declared
  58. * and which platform-specific headers to include. It is then up your (by
  59. * definition platform-specific) code to handle which of these should be
  60. * defined.
  61. */
  62. /*************************************************************************
  63. * System headers and types
  64. *************************************************************************/
  65. #if defined(GLFW_EXPOSE_NATIVE_WIN32)
  66. // This is a workaround for the fact that glfw3.h needs to export APIENTRY (for
  67. // example to allow applications to correctly declare a GL_ARB_debug_output
  68. // callback) but windows.h assumes no one will define APIENTRY before it does
  69. #undef APIENTRY
  70. #include <windows.h>
  71. #elif defined(GLFW_EXPOSE_NATIVE_COCOA)
  72. #include <ApplicationServices/ApplicationServices.h>
  73. #if defined(__OBJC__)
  74. #import <Cocoa/Cocoa.h>
  75. #else
  76. typedef void* id;
  77. #endif
  78. #elif defined(GLFW_EXPOSE_NATIVE_X11)
  79. #include <X11/Xlib.h>
  80. #include <X11/extensions/Xrandr.h>
  81. #else
  82. #error "No window API selected"
  83. #endif
  84. #if defined(GLFW_EXPOSE_NATIVE_WGL)
  85. /* WGL is declared by windows.h */
  86. #elif defined(GLFW_EXPOSE_NATIVE_NSGL)
  87. /* NSGL is declared by Cocoa.h */
  88. #elif defined(GLFW_EXPOSE_NATIVE_GLX)
  89. #include <GL/glx.h>
  90. #elif defined(GLFW_EXPOSE_NATIVE_EGL)
  91. #include <EGL/egl.h>
  92. #else
  93. #error "No context API selected"
  94. #endif
  95. /*************************************************************************
  96. * Functions
  97. *************************************************************************/
  98. #if defined(GLFW_EXPOSE_NATIVE_WIN32)
  99. /*! @brief Returns the adapter device name of the specified monitor.
  100. *
  101. * @return The UTF-8 encoded adapter device name (for example `\\.\DISPLAY1`)
  102. * of the specified monitor, or `NULL` if an [error](@ref error_handling)
  103. * occurred.
  104. *
  105. * @par Thread Safety
  106. * This function may be called from any thread. Access is not synchronized.
  107. *
  108. * @par History
  109. * Added in GLFW 3.1.
  110. *
  111. * @ingroup native
  112. */
  113. GLFWAPI const char* glfwGetWin32Adapter(GLFWmonitor* monitor);
  114. /*! @brief Returns the display device name of the specified monitor.
  115. *
  116. * @return The UTF-8 encoded display device name (for example
  117. * `\\.\DISPLAY1\Monitor0`) of the specified monitor, or `NULL` if an
  118. * [error](@ref error_handling) occurred.
  119. *
  120. * @par Thread Safety
  121. * This function may be called from any thread. Access is not synchronized.
  122. *
  123. * @par History
  124. * Added in GLFW 3.1.
  125. *
  126. * @ingroup native
  127. */
  128. GLFWAPI const char* glfwGetWin32Monitor(GLFWmonitor* monitor);
  129. /*! @brief Returns the `HWND` of the specified window.
  130. *
  131. * @return The `HWND` of the specified window, or `NULL` if an
  132. * [error](@ref error_handling) occurred.
  133. *
  134. * @par Thread Safety
  135. * This function may be called from any thread. Access is not synchronized.
  136. *
  137. * @par History
  138. * Added in GLFW 3.0.
  139. *
  140. * @ingroup native
  141. */
  142. GLFWAPI HWND glfwGetWin32Window(GLFWwindow* window);
  143. #endif
  144. #if defined(GLFW_EXPOSE_NATIVE_WGL)
  145. /*! @brief Returns the `HGLRC` of the specified window.
  146. *
  147. * @return The `HGLRC` of the specified window, or `NULL` if an
  148. * [error](@ref error_handling) occurred.
  149. *
  150. * @par Thread Safety
  151. * This function may be called from any thread. Access is not synchronized.
  152. *
  153. * @par History
  154. * Added in GLFW 3.0.
  155. *
  156. * @ingroup native
  157. */
  158. GLFWAPI HGLRC glfwGetWGLContext(GLFWwindow* window);
  159. #endif
  160. #if defined(GLFW_EXPOSE_NATIVE_COCOA)
  161. /*! @brief Returns the `CGDirectDisplayID` of the specified monitor.
  162. *
  163. * @return The `CGDirectDisplayID` of the specified monitor, or
  164. * `kCGNullDirectDisplay` if an [error](@ref error_handling) occurred.
  165. *
  166. * @par Thread Safety
  167. * This function may be called from any thread. Access is not synchronized.
  168. *
  169. * @par History
  170. * Added in GLFW 3.1.
  171. *
  172. * @ingroup native
  173. */
  174. GLFWAPI CGDirectDisplayID glfwGetCocoaMonitor(GLFWmonitor* monitor);
  175. /*! @brief Returns the `NSWindow` of the specified window.
  176. *
  177. * @return The `NSWindow` of the specified window, or `nil` if an
  178. * [error](@ref error_handling) occurred.
  179. *
  180. * @par Thread Safety
  181. * This function may be called from any thread. Access is not synchronized.
  182. *
  183. * @par History
  184. * Added in GLFW 3.0.
  185. *
  186. * @ingroup native
  187. */
  188. GLFWAPI id glfwGetCocoaWindow(GLFWwindow* window);
  189. #endif
  190. #if defined(GLFW_EXPOSE_NATIVE_NSGL)
  191. /*! @brief Returns the `NSOpenGLContext` of the specified window.
  192. *
  193. * @return The `NSOpenGLContext` of the specified window, or `nil` if an
  194. * [error](@ref error_handling) occurred.
  195. *
  196. * @par Thread Safety
  197. * This function may be called from any thread. Access is not synchronized.
  198. *
  199. * @par History
  200. * Added in GLFW 3.0.
  201. *
  202. * @ingroup native
  203. */
  204. GLFWAPI id glfwGetNSGLContext(GLFWwindow* window);
  205. #endif
  206. #if defined(GLFW_EXPOSE_NATIVE_X11)
  207. /*! @brief Returns the `Display` used by GLFW.
  208. *
  209. * @return The `Display` used by GLFW, or `NULL` if an
  210. * [error](@ref error_handling) occurred.
  211. *
  212. * @par Thread Safety
  213. * This function may be called from any thread. Access is not synchronized.
  214. *
  215. * @par History
  216. * Added in GLFW 3.0.
  217. *
  218. * @ingroup native
  219. */
  220. GLFWAPI Display* glfwGetX11Display(void);
  221. /*! @brief Returns the `RRCrtc` of the specified monitor.
  222. *
  223. * @return The `RRCrtc` of the specified monitor, or `None` if an
  224. * [error](@ref error_handling) occurred.
  225. *
  226. * @par Thread Safety
  227. * This function may be called from any thread. Access is not synchronized.
  228. *
  229. * @par History
  230. * Added in GLFW 3.1.
  231. *
  232. * @ingroup native
  233. */
  234. GLFWAPI RRCrtc glfwGetX11Adapter(GLFWmonitor* monitor);
  235. /*! @brief Returns the `RROutput` of the specified monitor.
  236. *
  237. * @return The `RROutput` of the specified monitor, or `None` if an
  238. * [error](@ref error_handling) occurred.
  239. *
  240. * @par Thread Safety
  241. * This function may be called from any thread. Access is not synchronized.
  242. *
  243. * @par History
  244. * Added in GLFW 3.1.
  245. *
  246. * @ingroup native
  247. */
  248. GLFWAPI RROutput glfwGetX11Monitor(GLFWmonitor* monitor);
  249. /*! @brief Returns the `Window` of the specified window.
  250. *
  251. * @return The `Window` of the specified window, or `None` if an
  252. * [error](@ref error_handling) occurred.
  253. *
  254. * @par Thread Safety
  255. * This function may be called from any thread. Access is not synchronized.
  256. *
  257. * @par History
  258. * Added in GLFW 3.0.
  259. *
  260. * @ingroup native
  261. */
  262. GLFWAPI Window glfwGetX11Window(GLFWwindow* window);
  263. #endif
  264. #if defined(GLFW_EXPOSE_NATIVE_GLX)
  265. /*! @brief Returns the `GLXContext` of the specified window.
  266. *
  267. * @return The `GLXContext` of the specified window, or `NULL` if an
  268. * [error](@ref error_handling) occurred.
  269. *
  270. * @par Thread Safety
  271. * This function may be called from any thread. Access is not synchronized.
  272. *
  273. * @par History
  274. * Added in GLFW 3.0.
  275. *
  276. * @ingroup native
  277. */
  278. GLFWAPI GLXContext glfwGetGLXContext(GLFWwindow* window);
  279. #endif
  280. #if defined(GLFW_EXPOSE_NATIVE_EGL)
  281. /*! @brief Returns the `EGLDisplay` used by GLFW.
  282. *
  283. * @return The `EGLDisplay` used by GLFW, or `EGL_NO_DISPLAY` if an
  284. * [error](@ref error_handling) occurred.
  285. *
  286. * @par Thread Safety
  287. * This function may be called from any thread. Access is not synchronized.
  288. *
  289. * @par History
  290. * Added in GLFW 3.0.
  291. *
  292. * @ingroup native
  293. */
  294. GLFWAPI EGLDisplay glfwGetEGLDisplay(void);
  295. /*! @brief Returns the `EGLContext` of the specified window.
  296. *
  297. * @return The `EGLContext` of the specified window, or `EGL_NO_CONTEXT` if an
  298. * [error](@ref error_handling) occurred.
  299. *
  300. * @par Thread Safety
  301. * This function may be called from any thread. Access is not synchronized.
  302. *
  303. * @par History
  304. * Added in GLFW 3.0.
  305. *
  306. * @ingroup native
  307. */
  308. GLFWAPI EGLContext glfwGetEGLContext(GLFWwindow* window);
  309. /*! @brief Returns the `EGLSurface` of the specified window.
  310. *
  311. * @return The `EGLSurface` of the specified window, or `EGL_NO_SURFACE` if an
  312. * [error](@ref error_handling) occurred.
  313. *
  314. * @par Thread Safety
  315. * This function may be called from any thread. Access is not synchronized.
  316. *
  317. * @par History
  318. * Added in GLFW 3.0.
  319. *
  320. * @ingroup native
  321. */
  322. GLFWAPI EGLSurface glfwGetEGLSurface(GLFWwindow* window);
  323. #endif
  324. #ifdef __cplusplus
  325. }
  326. #endif
  327. #endif /* _glfw3_native_h_ */