glfw3native.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663
  1. /*************************************************************************
  2. * GLFW 3.4 - 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. #endif
  450. #if defined(GLFW_EXPOSE_NATIVE_WAYLAND)
  451. /*! @brief Returns the `struct wl_display*` used by GLFW.
  452. *
  453. * @return The `struct wl_display*` used by GLFW, or `NULL` if an
  454. * [error](@ref error_handling) occurred.
  455. *
  456. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  457. * GLFW_PLATFORM_UNAVAILABLE.
  458. *
  459. * @thread_safety This function may be called from any thread. Access is not
  460. * synchronized.
  461. *
  462. * @since Added in version 3.2.
  463. *
  464. * @ingroup native
  465. */
  466. GLFWAPI struct wl_display* glfwGetWaylandDisplay(void);
  467. /*! @brief Returns the `struct wl_output*` of the specified monitor.
  468. *
  469. * @return The `struct wl_output*` of the specified monitor, or `NULL` if an
  470. * [error](@ref error_handling) occurred.
  471. *
  472. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  473. * GLFW_PLATFORM_UNAVAILABLE.
  474. *
  475. * @thread_safety This function may be called from any thread. Access is not
  476. * synchronized.
  477. *
  478. * @since Added in version 3.2.
  479. *
  480. * @ingroup native
  481. */
  482. GLFWAPI struct wl_output* glfwGetWaylandMonitor(GLFWmonitor* monitor);
  483. /*! @brief Returns the main `struct wl_surface*` of the specified window.
  484. *
  485. * @return The main `struct wl_surface*` of the specified window, or `NULL` if
  486. * an [error](@ref error_handling) occurred.
  487. *
  488. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  489. * GLFW_PLATFORM_UNAVAILABLE.
  490. *
  491. * @thread_safety This function may be called from any thread. Access is not
  492. * synchronized.
  493. *
  494. * @since Added in version 3.2.
  495. *
  496. * @ingroup native
  497. */
  498. GLFWAPI struct wl_surface* glfwGetWaylandWindow(GLFWwindow* window);
  499. #endif
  500. #if defined(GLFW_EXPOSE_NATIVE_EGL)
  501. /*! @brief Returns the `EGLDisplay` used by GLFW.
  502. *
  503. * @return The `EGLDisplay` used by GLFW, or `EGL_NO_DISPLAY` if an
  504. * [error](@ref error_handling) occurred.
  505. *
  506. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  507. *
  508. * @remark Because EGL is initialized on demand, this function will return
  509. * `EGL_NO_DISPLAY` until the first context has been created via EGL.
  510. *
  511. * @thread_safety This function may be called from any thread. Access is not
  512. * synchronized.
  513. *
  514. * @since Added in version 3.0.
  515. *
  516. * @ingroup native
  517. */
  518. GLFWAPI EGLDisplay glfwGetEGLDisplay(void);
  519. /*! @brief Returns the `EGLContext` of the specified window.
  520. *
  521. * @return The `EGLContext` of the specified window, or `EGL_NO_CONTEXT` if an
  522. * [error](@ref error_handling) occurred.
  523. *
  524. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  525. * GLFW_NO_WINDOW_CONTEXT.
  526. *
  527. * @thread_safety This function may be called from any thread. Access is not
  528. * synchronized.
  529. *
  530. * @since Added in version 3.0.
  531. *
  532. * @ingroup native
  533. */
  534. GLFWAPI EGLContext glfwGetEGLContext(GLFWwindow* window);
  535. /*! @brief Returns the `EGLSurface` of the specified window.
  536. *
  537. * @return The `EGLSurface` of the specified window, or `EGL_NO_SURFACE` if an
  538. * [error](@ref error_handling) occurred.
  539. *
  540. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  541. * GLFW_NO_WINDOW_CONTEXT.
  542. *
  543. * @thread_safety This function may be called from any thread. Access is not
  544. * synchronized.
  545. *
  546. * @since Added in version 3.0.
  547. *
  548. * @ingroup native
  549. */
  550. GLFWAPI EGLSurface glfwGetEGLSurface(GLFWwindow* window);
  551. #endif
  552. #if defined(GLFW_EXPOSE_NATIVE_OSMESA)
  553. /*! @brief Retrieves the color buffer associated with the specified window.
  554. *
  555. * @param[in] window The window whose color buffer to retrieve.
  556. * @param[out] width Where to store the width of the color buffer, or `NULL`.
  557. * @param[out] height Where to store the height of the color buffer, or `NULL`.
  558. * @param[out] format Where to store the OSMesa pixel format of the color
  559. * buffer, or `NULL`.
  560. * @param[out] buffer Where to store the address of the color buffer, or
  561. * `NULL`.
  562. * @return `GLFW_TRUE` if successful, or `GLFW_FALSE` if an
  563. * [error](@ref error_handling) occurred.
  564. *
  565. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  566. * GLFW_NO_WINDOW_CONTEXT.
  567. *
  568. * @thread_safety This function may be called from any thread. Access is not
  569. * synchronized.
  570. *
  571. * @since Added in version 3.3.
  572. *
  573. * @ingroup native
  574. */
  575. GLFWAPI int glfwGetOSMesaColorBuffer(GLFWwindow* window, int* width, int* height, int* format, void** buffer);
  576. /*! @brief Retrieves the depth buffer associated with the specified window.
  577. *
  578. * @param[in] window The window whose depth buffer to retrieve.
  579. * @param[out] width Where to store the width of the depth buffer, or `NULL`.
  580. * @param[out] height Where to store the height of the depth buffer, or `NULL`.
  581. * @param[out] bytesPerValue Where to store the number of bytes per depth
  582. * buffer element, or `NULL`.
  583. * @param[out] buffer Where to store the address of the depth buffer, or
  584. * `NULL`.
  585. * @return `GLFW_TRUE` if successful, or `GLFW_FALSE` if an
  586. * [error](@ref error_handling) occurred.
  587. *
  588. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  589. * GLFW_NO_WINDOW_CONTEXT.
  590. *
  591. * @thread_safety This function may be called from any thread. Access is not
  592. * synchronized.
  593. *
  594. * @since Added in version 3.3.
  595. *
  596. * @ingroup native
  597. */
  598. GLFWAPI int glfwGetOSMesaDepthBuffer(GLFWwindow* window, int* width, int* height, int* bytesPerValue, void** buffer);
  599. /*! @brief Returns the `OSMesaContext` of the specified window.
  600. *
  601. * @return The `OSMesaContext` of the specified window, or `NULL` if an
  602. * [error](@ref error_handling) occurred.
  603. *
  604. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  605. * GLFW_NO_WINDOW_CONTEXT.
  606. *
  607. * @thread_safety This function may be called from any thread. Access is not
  608. * synchronized.
  609. *
  610. * @since Added in version 3.3.
  611. *
  612. * @ingroup native
  613. */
  614. GLFWAPI OSMesaContext glfwGetOSMesaContext(GLFWwindow* window);
  615. #endif
  616. #ifdef __cplusplus
  617. }
  618. #endif
  619. #endif /* _glfw3_native_h_ */