glfw3native.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709
  1. /*************************************************************************
  2. * GLFW 3.5 - 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 <[email protected]>
  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. /*! @file glfw3native.h
  37. * @brief The header of the native access functions.
  38. *
  39. * This is the header file of the native access functions. See @ref native for
  40. * more information.
  41. */
  42. /*! @defgroup native Native access
  43. * @brief Functions related to accessing native handles.
  44. *
  45. * **By using the native access functions you assert that you know what you're
  46. * doing and how to fix problems caused by using them. If you don't, you
  47. * shouldn't be using them.**
  48. *
  49. * Before the inclusion of @ref glfw3native.h, you may define zero or more
  50. * window system API macro and zero or more context creation API macros.
  51. *
  52. * The chosen backends must match those the library was compiled for. Failure
  53. * to do this will cause a link-time error.
  54. *
  55. * The available window API macros are:
  56. * * `GLFW_EXPOSE_NATIVE_WIN32`
  57. * * `GLFW_EXPOSE_NATIVE_COCOA`
  58. * * `GLFW_EXPOSE_NATIVE_X11`
  59. * * `GLFW_EXPOSE_NATIVE_WAYLAND`
  60. *
  61. * The available context API macros are:
  62. * * `GLFW_EXPOSE_NATIVE_WGL`
  63. * * `GLFW_EXPOSE_NATIVE_NSGL`
  64. * * `GLFW_EXPOSE_NATIVE_GLX`
  65. * * `GLFW_EXPOSE_NATIVE_EGL`
  66. * * `GLFW_EXPOSE_NATIVE_OSMESA`
  67. *
  68. * These macros select which of the native access functions that are declared
  69. * and which platform-specific headers to include. It is then up your (by
  70. * definition platform-specific) code to handle which of these should be
  71. * defined.
  72. *
  73. * If you do not want the platform-specific headers to be included, define
  74. * `GLFW_NATIVE_INCLUDE_NONE` before including the @ref glfw3native.h header.
  75. *
  76. * @code
  77. * #define GLFW_EXPOSE_NATIVE_WIN32
  78. * #define GLFW_EXPOSE_NATIVE_WGL
  79. * #define GLFW_NATIVE_INCLUDE_NONE
  80. * #include <GLFW/glfw3native.h>
  81. * @endcode
  82. */
  83. /*************************************************************************
  84. * System headers and types
  85. *************************************************************************/
  86. #if !defined(GLFW_NATIVE_INCLUDE_NONE)
  87. #if defined(GLFW_EXPOSE_NATIVE_WIN32) || defined(GLFW_EXPOSE_NATIVE_WGL)
  88. /* This is a workaround for the fact that glfw3.h needs to export APIENTRY (for
  89. * example to allow applications to correctly declare a GL_KHR_debug callback)
  90. * but windows.h assumes no one will define APIENTRY before it does
  91. */
  92. #if defined(GLFW_APIENTRY_DEFINED)
  93. #undef APIENTRY
  94. #undef GLFW_APIENTRY_DEFINED
  95. #endif
  96. #include <windows.h>
  97. #endif
  98. #if defined(GLFW_EXPOSE_NATIVE_COCOA) || defined(GLFW_EXPOSE_NATIVE_NSGL)
  99. #if defined(__OBJC__)
  100. #import <Cocoa/Cocoa.h>
  101. #else
  102. #include <ApplicationServices/ApplicationServices.h>
  103. #include <objc/objc.h>
  104. #endif
  105. #endif
  106. #if defined(GLFW_EXPOSE_NATIVE_X11) || defined(GLFW_EXPOSE_NATIVE_GLX)
  107. #include <X11/Xlib.h>
  108. #include <X11/extensions/Xrandr.h>
  109. #endif
  110. #if defined(GLFW_EXPOSE_NATIVE_WAYLAND)
  111. #include <wayland-client.h>
  112. #endif
  113. #if defined(GLFW_EXPOSE_NATIVE_WGL)
  114. /* WGL is declared by windows.h */
  115. #endif
  116. #if defined(GLFW_EXPOSE_NATIVE_NSGL)
  117. /* NSGL is declared by Cocoa.h */
  118. #endif
  119. #if defined(GLFW_EXPOSE_NATIVE_GLX)
  120. /* This is a workaround for the fact that glfw3.h defines GLAPIENTRY because by
  121. * default it also acts as an OpenGL header
  122. * However, glx.h will include gl.h, which will define it unconditionally
  123. */
  124. #if defined(GLFW_GLAPIENTRY_DEFINED)
  125. #undef GLAPIENTRY
  126. #undef GLFW_GLAPIENTRY_DEFINED
  127. #endif
  128. #include <GL/glx.h>
  129. #endif
  130. #if defined(GLFW_EXPOSE_NATIVE_EGL)
  131. #include <EGL/egl.h>
  132. #endif
  133. #if defined(GLFW_EXPOSE_NATIVE_OSMESA)
  134. /* This is a workaround for the fact that glfw3.h defines GLAPIENTRY because by
  135. * default it also acts as an OpenGL header
  136. * However, osmesa.h will include gl.h, which will define it unconditionally
  137. */
  138. #if defined(GLFW_GLAPIENTRY_DEFINED)
  139. #undef GLAPIENTRY
  140. #undef GLFW_GLAPIENTRY_DEFINED
  141. #endif
  142. #include <GL/osmesa.h>
  143. #endif
  144. #endif /*GLFW_NATIVE_INCLUDE_NONE*/
  145. /*************************************************************************
  146. * Functions
  147. *************************************************************************/
  148. #if defined(GLFW_EXPOSE_NATIVE_WIN32)
  149. /*! @brief Returns the adapter device name of the specified monitor.
  150. *
  151. * @return The UTF-8 encoded adapter device name (for example `\\.\DISPLAY1`)
  152. * of the specified monitor, or `NULL` if an [error](@ref error_handling)
  153. * occurred.
  154. *
  155. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  156. * GLFW_PLATFORM_UNAVAILABLE.
  157. *
  158. * @thread_safety This function may be called from any thread. Access is not
  159. * synchronized.
  160. *
  161. * @since Added in version 3.1.
  162. *
  163. * @ingroup native
  164. */
  165. GLFWAPI const char* glfwGetWin32Adapter(GLFWmonitor* monitor);
  166. /*! @brief Returns the display device name of the specified monitor.
  167. *
  168. * @return The UTF-8 encoded display device name (for example
  169. * `\\.\DISPLAY1\Monitor0`) of the specified monitor, or `NULL` if an
  170. * [error](@ref error_handling) occurred.
  171. *
  172. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  173. * GLFW_PLATFORM_UNAVAILABLE.
  174. *
  175. * @thread_safety This function may be called from any thread. Access is not
  176. * synchronized.
  177. *
  178. * @since Added in version 3.1.
  179. *
  180. * @ingroup native
  181. */
  182. GLFWAPI const char* glfwGetWin32Monitor(GLFWmonitor* monitor);
  183. /*! @brief Returns the `HWND` of the specified window.
  184. *
  185. * @return The `HWND` of the specified window, or `NULL` if an
  186. * [error](@ref error_handling) occurred.
  187. *
  188. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  189. * GLFW_PLATFORM_UNAVAILABLE.
  190. *
  191. * @remark The `HDC` associated with the window can be queried with the
  192. * [GetDC](https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getdc)
  193. * function.
  194. * @code
  195. * HDC dc = GetDC(glfwGetWin32Window(window));
  196. * @endcode
  197. * This DC is private and does not need to be released.
  198. *
  199. * @thread_safety This function may be called from any thread. Access is not
  200. * synchronized.
  201. *
  202. * @since Added in version 3.0.
  203. *
  204. * @ingroup native
  205. */
  206. GLFWAPI HWND glfwGetWin32Window(GLFWwindow* window);
  207. #endif
  208. #if defined(GLFW_EXPOSE_NATIVE_WGL)
  209. /*! @brief Returns the `HGLRC` of the specified window.
  210. *
  211. * @return The `HGLRC` of the specified window, or `NULL` if an
  212. * [error](@ref error_handling) occurred.
  213. *
  214. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  215. * GLFW_PLATFORM_UNAVAILABLE and @ref GLFW_NO_WINDOW_CONTEXT.
  216. *
  217. * @remark The `HDC` associated with the window can be queried with the
  218. * [GetDC](https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getdc)
  219. * function.
  220. * @code
  221. * HDC dc = GetDC(glfwGetWin32Window(window));
  222. * @endcode
  223. * This DC is private and does not need to be released.
  224. *
  225. * @thread_safety This function may be called from any thread. Access is not
  226. * synchronized.
  227. *
  228. * @since Added in version 3.0.
  229. *
  230. * @ingroup native
  231. */
  232. GLFWAPI HGLRC glfwGetWGLContext(GLFWwindow* window);
  233. #endif
  234. #if defined(GLFW_EXPOSE_NATIVE_COCOA)
  235. /*! @brief Returns the `CGDirectDisplayID` of the specified monitor.
  236. *
  237. * @return The `CGDirectDisplayID` of the specified monitor, or
  238. * `kCGNullDirectDisplay` if an [error](@ref error_handling) occurred.
  239. *
  240. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  241. * GLFW_PLATFORM_UNAVAILABLE.
  242. *
  243. * @thread_safety This function may be called from any thread. Access is not
  244. * synchronized.
  245. *
  246. * @since Added in version 3.1.
  247. *
  248. * @ingroup native
  249. */
  250. GLFWAPI CGDirectDisplayID glfwGetCocoaMonitor(GLFWmonitor* monitor);
  251. /*! @brief Returns the `NSWindow` of the specified window.
  252. *
  253. * @return The `NSWindow` of the specified window, or `nil` if an
  254. * [error](@ref error_handling) occurred.
  255. *
  256. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  257. * GLFW_PLATFORM_UNAVAILABLE.
  258. *
  259. * @thread_safety This function may be called from any thread. Access is not
  260. * synchronized.
  261. *
  262. * @since Added in version 3.0.
  263. *
  264. * @ingroup native
  265. */
  266. GLFWAPI id glfwGetCocoaWindow(GLFWwindow* window);
  267. /*! @brief Returns the `NSView` of the specified window.
  268. *
  269. * @return The `NSView` of the specified window, or `nil` if an
  270. * [error](@ref error_handling) occurred.
  271. *
  272. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  273. * GLFW_PLATFORM_UNAVAILABLE.
  274. *
  275. * @thread_safety This function may be called from any thread. Access is not
  276. * synchronized.
  277. *
  278. * @since Added in version 3.4.
  279. *
  280. * @ingroup native
  281. */
  282. GLFWAPI id glfwGetCocoaView(GLFWwindow* window);
  283. #endif
  284. #if defined(GLFW_EXPOSE_NATIVE_NSGL)
  285. /*! @brief Returns the `NSOpenGLContext` of the specified window.
  286. *
  287. * @return The `NSOpenGLContext` of the specified window, or `nil` if an
  288. * [error](@ref error_handling) occurred.
  289. *
  290. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  291. * GLFW_PLATFORM_UNAVAILABLE and @ref GLFW_NO_WINDOW_CONTEXT.
  292. *
  293. * @thread_safety This function may be called from any thread. Access is not
  294. * synchronized.
  295. *
  296. * @since Added in version 3.0.
  297. *
  298. * @ingroup native
  299. */
  300. GLFWAPI id glfwGetNSGLContext(GLFWwindow* window);
  301. #endif
  302. #if defined(GLFW_EXPOSE_NATIVE_X11)
  303. /*! @brief Returns the `Display` used by GLFW.
  304. *
  305. * @return The `Display` used by GLFW, or `NULL` if an
  306. * [error](@ref error_handling) occurred.
  307. *
  308. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  309. * GLFW_PLATFORM_UNAVAILABLE.
  310. *
  311. * @thread_safety This function may be called from any thread. Access is not
  312. * synchronized.
  313. *
  314. * @since Added in version 3.0.
  315. *
  316. * @ingroup native
  317. */
  318. GLFWAPI Display* glfwGetX11Display(void);
  319. /*! @brief Returns the `RRCrtc` of the specified monitor.
  320. *
  321. * @return The `RRCrtc` of the specified monitor, or `None` if an
  322. * [error](@ref error_handling) occurred.
  323. *
  324. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  325. * GLFW_PLATFORM_UNAVAILABLE.
  326. *
  327. * @thread_safety This function may be called from any thread. Access is not
  328. * synchronized.
  329. *
  330. * @since Added in version 3.1.
  331. *
  332. * @ingroup native
  333. */
  334. GLFWAPI RRCrtc glfwGetX11Adapter(GLFWmonitor* monitor);
  335. /*! @brief Returns the `RROutput` of the specified monitor.
  336. *
  337. * @return The `RROutput` of the specified monitor, or `None` if an
  338. * [error](@ref error_handling) occurred.
  339. *
  340. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  341. * GLFW_PLATFORM_UNAVAILABLE.
  342. *
  343. * @thread_safety This function may be called from any thread. Access is not
  344. * synchronized.
  345. *
  346. * @since Added in version 3.1.
  347. *
  348. * @ingroup native
  349. */
  350. GLFWAPI RROutput glfwGetX11Monitor(GLFWmonitor* monitor);
  351. /*! @brief Returns the `Window` of the specified window.
  352. *
  353. * @return The `Window` of the specified window, or `None` if an
  354. * [error](@ref error_handling) occurred.
  355. *
  356. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  357. * GLFW_PLATFORM_UNAVAILABLE.
  358. *
  359. * @thread_safety This function may be called from any thread. Access is not
  360. * synchronized.
  361. *
  362. * @since Added in version 3.0.
  363. *
  364. * @ingroup native
  365. */
  366. GLFWAPI Window glfwGetX11Window(GLFWwindow* window);
  367. /*! @brief Sets the current primary selection to the specified string.
  368. *
  369. * @param[in] string A UTF-8 encoded string.
  370. *
  371. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  372. * GLFW_PLATFORM_UNAVAILABLE and @ref GLFW_PLATFORM_ERROR.
  373. *
  374. * @pointer_lifetime The specified string is copied before this function
  375. * returns.
  376. *
  377. * @thread_safety This function must only be called from the main thread.
  378. *
  379. * @sa @ref clipboard
  380. * @sa glfwGetX11SelectionString
  381. * @sa glfwSetClipboardString
  382. *
  383. * @since Added in version 3.3.
  384. *
  385. * @ingroup native
  386. */
  387. GLFWAPI void glfwSetX11SelectionString(const char* string);
  388. /*! @brief Returns the contents of the current primary selection as a string.
  389. *
  390. * If the selection is empty or if its contents cannot be converted, `NULL`
  391. * is returned and a @ref GLFW_FORMAT_UNAVAILABLE error is generated.
  392. *
  393. * @return The contents of the selection as a UTF-8 encoded string, or `NULL`
  394. * if an [error](@ref error_handling) occurred.
  395. *
  396. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  397. * GLFW_PLATFORM_UNAVAILABLE and @ref GLFW_PLATFORM_ERROR.
  398. *
  399. * @pointer_lifetime The returned string is allocated and freed by GLFW. You
  400. * should not free it yourself. It is valid until the next call to @ref
  401. * glfwGetX11SelectionString or @ref glfwSetX11SelectionString, or until the
  402. * library is terminated.
  403. *
  404. * @thread_safety This function must only be called from the main thread.
  405. *
  406. * @sa @ref clipboard
  407. * @sa glfwSetX11SelectionString
  408. * @sa glfwGetClipboardString
  409. *
  410. * @since Added in version 3.3.
  411. *
  412. * @ingroup native
  413. */
  414. GLFWAPI const char* glfwGetX11SelectionString(void);
  415. #endif
  416. #if defined(GLFW_EXPOSE_NATIVE_GLX)
  417. /*! @brief Returns the `GLXContext` of the specified window.
  418. *
  419. * @return The `GLXContext` of the specified window, or `NULL` if an
  420. * [error](@ref error_handling) occurred.
  421. *
  422. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  423. * GLFW_NO_WINDOW_CONTEXT and @ref GLFW_PLATFORM_UNAVAILABLE.
  424. *
  425. * @thread_safety This function may be called from any thread. Access is not
  426. * synchronized.
  427. *
  428. * @since Added in version 3.0.
  429. *
  430. * @ingroup native
  431. */
  432. GLFWAPI GLXContext glfwGetGLXContext(GLFWwindow* window);
  433. /*! @brief Returns the `GLXWindow` of the specified window.
  434. *
  435. * @return The `GLXWindow` of the specified window, or `None` if an
  436. * [error](@ref error_handling) occurred.
  437. *
  438. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  439. * GLFW_NO_WINDOW_CONTEXT and @ref GLFW_PLATFORM_UNAVAILABLE.
  440. *
  441. * @thread_safety This function may be called from any thread. Access is not
  442. * synchronized.
  443. *
  444. * @since Added in version 3.2.
  445. *
  446. * @ingroup native
  447. */
  448. GLFWAPI GLXWindow glfwGetGLXWindow(GLFWwindow* window);
  449. /*! @brief Retrieves the `GLXFBConfig` of the specified window's `GLXWindow`.
  450. *
  451. * @param[in] window The window whose `GLXWindow` to query.
  452. * @param[out] config The `GLXFBConfig` of the window `GLXWindow`, if available.
  453. * @return `GLFW_TRUE` if successful, or `GLFW_FALSE` if an
  454. * [error](@ref error_handling) occurred.
  455. *
  456. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  457. * GLFW_NO_WINDOW_CONTEXT and @ref GLFW_PLATFORM_UNAVAILABLE.
  458. *
  459. * @remark `GLXFBConfig` is an opaque type. Unlike other GLFW functions, the
  460. * @p config out parameter is not cleared on error, as core GLX does not define
  461. * any invalid value.
  462. *
  463. * @thread_safety This function may be called from any thread. Access is not
  464. * synchronized.
  465. *
  466. * @since Added in version 3.5
  467. *
  468. * @ingroup native
  469. */
  470. GLFWAPI int glfwGetGLXFBConfig(GLFWwindow* window, GLXFBConfig* config);
  471. #endif
  472. #if defined(GLFW_EXPOSE_NATIVE_WAYLAND)
  473. /*! @brief Returns the `struct wl_display*` used by GLFW.
  474. *
  475. * @return The `struct wl_display*` used by GLFW, or `NULL` if an
  476. * [error](@ref error_handling) occurred.
  477. *
  478. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  479. * GLFW_PLATFORM_UNAVAILABLE.
  480. *
  481. * @thread_safety This function may be called from any thread. Access is not
  482. * synchronized.
  483. *
  484. * @since Added in version 3.2.
  485. *
  486. * @ingroup native
  487. */
  488. GLFWAPI struct wl_display* glfwGetWaylandDisplay(void);
  489. /*! @brief Returns the `struct wl_output*` of the specified monitor.
  490. *
  491. * @return The `struct wl_output*` of the specified monitor, or `NULL` if an
  492. * [error](@ref error_handling) occurred.
  493. *
  494. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  495. * GLFW_PLATFORM_UNAVAILABLE.
  496. *
  497. * @thread_safety This function may be called from any thread. Access is not
  498. * synchronized.
  499. *
  500. * @since Added in version 3.2.
  501. *
  502. * @ingroup native
  503. */
  504. GLFWAPI struct wl_output* glfwGetWaylandMonitor(GLFWmonitor* monitor);
  505. /*! @brief Returns the main `struct wl_surface*` of the specified window.
  506. *
  507. * @return The main `struct wl_surface*` of the specified window, or `NULL` if
  508. * an [error](@ref error_handling) occurred.
  509. *
  510. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  511. * GLFW_PLATFORM_UNAVAILABLE.
  512. *
  513. * @thread_safety This function may be called from any thread. Access is not
  514. * synchronized.
  515. *
  516. * @since Added in version 3.2.
  517. *
  518. * @ingroup native
  519. */
  520. GLFWAPI struct wl_surface* glfwGetWaylandWindow(GLFWwindow* window);
  521. #endif
  522. #if defined(GLFW_EXPOSE_NATIVE_EGL)
  523. /*! @brief Returns the `EGLDisplay` used by GLFW.
  524. *
  525. * @return The `EGLDisplay` used by GLFW, or `EGL_NO_DISPLAY` if an
  526. * [error](@ref error_handling) occurred.
  527. *
  528. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  529. *
  530. * @remark Because EGL is initialized on demand, this function will return
  531. * `EGL_NO_DISPLAY` until the first context has been created via EGL.
  532. *
  533. * @thread_safety This function may be called from any thread. Access is not
  534. * synchronized.
  535. *
  536. * @since Added in version 3.0.
  537. *
  538. * @ingroup native
  539. */
  540. GLFWAPI EGLDisplay glfwGetEGLDisplay(void);
  541. /*! @brief Returns the `EGLContext` of the specified window.
  542. *
  543. * @return The `EGLContext` of the specified window, or `EGL_NO_CONTEXT` if an
  544. * [error](@ref error_handling) occurred.
  545. *
  546. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  547. * GLFW_NO_WINDOW_CONTEXT.
  548. *
  549. * @thread_safety This function may be called from any thread. Access is not
  550. * synchronized.
  551. *
  552. * @since Added in version 3.0.
  553. *
  554. * @ingroup native
  555. */
  556. GLFWAPI EGLContext glfwGetEGLContext(GLFWwindow* window);
  557. /*! @brief Returns the `EGLSurface` of the specified window.
  558. *
  559. * @return The `EGLSurface` of the specified window, or `EGL_NO_SURFACE` if an
  560. * [error](@ref error_handling) occurred.
  561. *
  562. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  563. * GLFW_NO_WINDOW_CONTEXT.
  564. *
  565. * @thread_safety This function may be called from any thread. Access is not
  566. * synchronized.
  567. *
  568. * @since Added in version 3.0.
  569. *
  570. * @ingroup native
  571. */
  572. GLFWAPI EGLSurface glfwGetEGLSurface(GLFWwindow* window);
  573. /*! @brief Retrieves the `EGLConfig` of the specified window's `EGLSurface`.
  574. *
  575. * @param[in] window The window whose `EGLSurface` to query.
  576. * @param[out] config The `EGLConfig` of the window `EGLSurface`, if available.
  577. * @return `GLFW_TRUE` if successful, or `GLFW_FALSE` if an
  578. * [error](@ref error_handling) occurred.
  579. *
  580. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  581. * GLFW_NO_WINDOW_CONTEXT.
  582. *
  583. * @remark `EGLConfig` is an opaque type. Unlike other GLFW functions, the @p
  584. * config out parameter is not cleared on error, as core EGL does not define
  585. * any invalid value.
  586. *
  587. * @thread_safety This function may be called from any thread. Access is not
  588. * synchronized.
  589. *
  590. * @since Added in version 3.5.
  591. *
  592. * @ingroup native
  593. */
  594. GLFWAPI int glfwGetEGLConfig(GLFWwindow* window, EGLConfig* config);
  595. #endif
  596. #if defined(GLFW_EXPOSE_NATIVE_OSMESA)
  597. /*! @brief Retrieves the color buffer associated with the specified window.
  598. *
  599. * @param[in] window The window whose color buffer to retrieve.
  600. * @param[out] width Where to store the width of the color buffer, or `NULL`.
  601. * @param[out] height Where to store the height of the color buffer, or `NULL`.
  602. * @param[out] format Where to store the OSMesa pixel format of the color
  603. * buffer, or `NULL`.
  604. * @param[out] buffer Where to store the address of the color buffer, or
  605. * `NULL`.
  606. * @return `GLFW_TRUE` if successful, or `GLFW_FALSE` if an
  607. * [error](@ref error_handling) occurred.
  608. *
  609. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  610. * GLFW_NO_WINDOW_CONTEXT.
  611. *
  612. * @thread_safety This function may be called from any thread. Access is not
  613. * synchronized.
  614. *
  615. * @since Added in version 3.3.
  616. *
  617. * @ingroup native
  618. */
  619. GLFWAPI int glfwGetOSMesaColorBuffer(GLFWwindow* window, int* width, int* height, int* format, void** buffer);
  620. /*! @brief Retrieves the depth buffer associated with the specified window.
  621. *
  622. * @param[in] window The window whose depth buffer to retrieve.
  623. * @param[out] width Where to store the width of the depth buffer, or `NULL`.
  624. * @param[out] height Where to store the height of the depth buffer, or `NULL`.
  625. * @param[out] bytesPerValue Where to store the number of bytes per depth
  626. * buffer element, or `NULL`.
  627. * @param[out] buffer Where to store the address of the depth buffer, or
  628. * `NULL`.
  629. * @return `GLFW_TRUE` if successful, or `GLFW_FALSE` if an
  630. * [error](@ref error_handling) occurred.
  631. *
  632. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  633. * GLFW_NO_WINDOW_CONTEXT.
  634. *
  635. * @thread_safety This function may be called from any thread. Access is not
  636. * synchronized.
  637. *
  638. * @since Added in version 3.3.
  639. *
  640. * @ingroup native
  641. */
  642. GLFWAPI int glfwGetOSMesaDepthBuffer(GLFWwindow* window, int* width, int* height, int* bytesPerValue, void** buffer);
  643. /*! @brief Returns the `OSMesaContext` of the specified window.
  644. *
  645. * @return The `OSMesaContext` of the specified window, or `NULL` if an
  646. * [error](@ref error_handling) occurred.
  647. *
  648. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  649. * GLFW_NO_WINDOW_CONTEXT.
  650. *
  651. * @thread_safety This function may be called from any thread. Access is not
  652. * synchronized.
  653. *
  654. * @since Added in version 3.3.
  655. *
  656. * @ingroup native
  657. */
  658. GLFWAPI OSMesaContext glfwGetOSMesaContext(GLFWwindow* window);
  659. #endif
  660. #ifdef __cplusplus
  661. }
  662. #endif
  663. #endif /* _glfw3_native_h_ */