Platformer in OpenGL
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

456 строки
13 KiB

5 лет назад
  1. /*************************************************************************
  2. * GLFW 3.2 - www.glfw.org
  3. * A library for OpenGL, window and input
  4. *------------------------------------------------------------------------
  5. * Copyright (c) 2002-2006 Marcus Geelnard
  6. * Copyright (c) 2006-2016 Camilla Berglund <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. #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. *
  44. * **By using the native access functions you assert that you know what you're
  45. * doing and how to fix problems caused by using them. If you don't, you
  46. * shouldn't be using them.**
  47. *
  48. * Before the inclusion of @ref glfw3native.h, you may define exactly one
  49. * window system API macro and zero or more context creation API macros.
  50. *
  51. * The chosen backends must match those the library was compiled for. Failure
  52. * to do this will cause a link-time error.
  53. *
  54. * The available window API macros are:
  55. * * `GLFW_EXPOSE_NATIVE_WIN32`
  56. * * `GLFW_EXPOSE_NATIVE_COCOA`
  57. * * `GLFW_EXPOSE_NATIVE_X11`
  58. * * `GLFW_EXPOSE_NATIVE_WAYLAND`
  59. * * `GLFW_EXPOSE_NATIVE_MIR`
  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. *
  67. * These macros select which of the native access functions that are declared
  68. * and which platform-specific headers to include. It is then up your (by
  69. * definition platform-specific) code to handle which of these should be
  70. * defined.
  71. */
  72. /*************************************************************************
  73. * System headers and types
  74. *************************************************************************/
  75. #if defined(GLFW_EXPOSE_NATIVE_WIN32)
  76. // This is a workaround for the fact that glfw3.h needs to export APIENTRY (for
  77. // example to allow applications to correctly declare a GL_ARB_debug_output
  78. // callback) but windows.h assumes no one will define APIENTRY before it does
  79. #undef APIENTRY
  80. #include <windows.h>
  81. #elif defined(GLFW_EXPOSE_NATIVE_COCOA)
  82. #include <ApplicationServices/ApplicationServices.h>
  83. #if defined(__OBJC__)
  84. #import <Cocoa/Cocoa.h>
  85. #else
  86. typedef void* id;
  87. #endif
  88. #elif defined(GLFW_EXPOSE_NATIVE_X11)
  89. #include <X11/Xlib.h>
  90. #include <X11/extensions/Xrandr.h>
  91. #elif defined(GLFW_EXPOSE_NATIVE_WAYLAND)
  92. #include <wayland-client.h>
  93. #elif defined(GLFW_EXPOSE_NATIVE_MIR)
  94. #include <mir_toolkit/mir_client_library.h>
  95. #endif
  96. #if defined(GLFW_EXPOSE_NATIVE_WGL)
  97. /* WGL is declared by windows.h */
  98. #endif
  99. #if defined(GLFW_EXPOSE_NATIVE_NSGL)
  100. /* NSGL is declared by Cocoa.h */
  101. #endif
  102. #if defined(GLFW_EXPOSE_NATIVE_GLX)
  103. #include <GL/glx.h>
  104. #endif
  105. #if defined(GLFW_EXPOSE_NATIVE_EGL)
  106. #include <EGL/egl.h>
  107. #endif
  108. /*************************************************************************
  109. * Functions
  110. *************************************************************************/
  111. #if defined(GLFW_EXPOSE_NATIVE_WIN32)
  112. /*! @brief Returns the adapter device name of the specified monitor.
  113. *
  114. * @return The UTF-8 encoded adapter device name (for example `\\.\DISPLAY1`)
  115. * of the specified monitor, or `NULL` if an [error](@ref error_handling)
  116. * occurred.
  117. *
  118. * @thread_safety This function may be called from any thread. Access is not
  119. * synchronized.
  120. *
  121. * @since Added in version 3.1.
  122. *
  123. * @ingroup native
  124. */
  125. GLFWAPI const char* glfwGetWin32Adapter(GLFWmonitor* monitor);
  126. /*! @brief Returns the display device name of the specified monitor.
  127. *
  128. * @return The UTF-8 encoded display device name (for example
  129. * `\\.\DISPLAY1\Monitor0`) of the specified monitor, or `NULL` if an
  130. * [error](@ref error_handling) occurred.
  131. *
  132. * @thread_safety This function may be called from any thread. Access is not
  133. * synchronized.
  134. *
  135. * @since Added in version 3.1.
  136. *
  137. * @ingroup native
  138. */
  139. GLFWAPI const char* glfwGetWin32Monitor(GLFWmonitor* monitor);
  140. /*! @brief Returns the `HWND` of the specified window.
  141. *
  142. * @return The `HWND` of the specified window, or `NULL` if an
  143. * [error](@ref error_handling) occurred.
  144. *
  145. * @thread_safety This function may be called from any thread. Access is not
  146. * synchronized.
  147. *
  148. * @since Added in version 3.0.
  149. *
  150. * @ingroup native
  151. */
  152. GLFWAPI HWND glfwGetWin32Window(GLFWwindow* window);
  153. #endif
  154. #if defined(GLFW_EXPOSE_NATIVE_WGL)
  155. /*! @brief Returns the `HGLRC` of the specified window.
  156. *
  157. * @return The `HGLRC` of the specified window, or `NULL` if an
  158. * [error](@ref error_handling) occurred.
  159. *
  160. * @thread_safety This function may be called from any thread. Access is not
  161. * synchronized.
  162. *
  163. * @since Added in version 3.0.
  164. *
  165. * @ingroup native
  166. */
  167. GLFWAPI HGLRC glfwGetWGLContext(GLFWwindow* window);
  168. #endif
  169. #if defined(GLFW_EXPOSE_NATIVE_COCOA)
  170. /*! @brief Returns the `CGDirectDisplayID` of the specified monitor.
  171. *
  172. * @return The `CGDirectDisplayID` of the specified monitor, or
  173. * `kCGNullDirectDisplay` if an [error](@ref error_handling) occurred.
  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 CGDirectDisplayID glfwGetCocoaMonitor(GLFWmonitor* monitor);
  183. /*! @brief Returns the `NSWindow` of the specified window.
  184. *
  185. * @return The `NSWindow` of the specified window, or `nil` if an
  186. * [error](@ref error_handling) occurred.
  187. *
  188. * @thread_safety This function may be called from any thread. Access is not
  189. * synchronized.
  190. *
  191. * @since Added in version 3.0.
  192. *
  193. * @ingroup native
  194. */
  195. GLFWAPI id glfwGetCocoaWindow(GLFWwindow* window);
  196. #endif
  197. #if defined(GLFW_EXPOSE_NATIVE_NSGL)
  198. /*! @brief Returns the `NSOpenGLContext` of the specified window.
  199. *
  200. * @return The `NSOpenGLContext` of the specified window, or `nil` if an
  201. * [error](@ref error_handling) occurred.
  202. *
  203. * @thread_safety This function may be called from any thread. Access is not
  204. * synchronized.
  205. *
  206. * @since Added in version 3.0.
  207. *
  208. * @ingroup native
  209. */
  210. GLFWAPI id glfwGetNSGLContext(GLFWwindow* window);
  211. #endif
  212. #if defined(GLFW_EXPOSE_NATIVE_X11)
  213. /*! @brief Returns the `Display` used by GLFW.
  214. *
  215. * @return The `Display` used by GLFW, or `NULL` if an
  216. * [error](@ref error_handling) occurred.
  217. *
  218. * @thread_safety This function may be called from any thread. Access is not
  219. * synchronized.
  220. *
  221. * @since Added in version 3.0.
  222. *
  223. * @ingroup native
  224. */
  225. GLFWAPI Display* glfwGetX11Display(void);
  226. /*! @brief Returns the `RRCrtc` of the specified monitor.
  227. *
  228. * @return The `RRCrtc` of the specified monitor, or `None` if an
  229. * [error](@ref error_handling) occurred.
  230. *
  231. * @thread_safety This function may be called from any thread. Access is not
  232. * synchronized.
  233. *
  234. * @since Added in version 3.1.
  235. *
  236. * @ingroup native
  237. */
  238. GLFWAPI RRCrtc glfwGetX11Adapter(GLFWmonitor* monitor);
  239. /*! @brief Returns the `RROutput` of the specified monitor.
  240. *
  241. * @return The `RROutput` of the specified monitor, or `None` if an
  242. * [error](@ref error_handling) occurred.
  243. *
  244. * @thread_safety This function may be called from any thread. Access is not
  245. * synchronized.
  246. *
  247. * @since Added in version 3.1.
  248. *
  249. * @ingroup native
  250. */
  251. GLFWAPI RROutput glfwGetX11Monitor(GLFWmonitor* monitor);
  252. /*! @brief Returns the `Window` of the specified window.
  253. *
  254. * @return The `Window` of the specified window, or `None` if an
  255. * [error](@ref error_handling) occurred.
  256. *
  257. * @thread_safety This function may be called from any thread. Access is not
  258. * synchronized.
  259. *
  260. * @since Added in version 3.0.
  261. *
  262. * @ingroup native
  263. */
  264. GLFWAPI Window glfwGetX11Window(GLFWwindow* window);
  265. #endif
  266. #if defined(GLFW_EXPOSE_NATIVE_GLX)
  267. /*! @brief Returns the `GLXContext` of the specified window.
  268. *
  269. * @return The `GLXContext` of the specified window, or `NULL` if an
  270. * [error](@ref error_handling) occurred.
  271. *
  272. * @thread_safety This function may be called from any thread. Access is not
  273. * synchronized.
  274. *
  275. * @since Added in version 3.0.
  276. *
  277. * @ingroup native
  278. */
  279. GLFWAPI GLXContext glfwGetGLXContext(GLFWwindow* window);
  280. /*! @brief Returns the `GLXWindow` of the specified window.
  281. *
  282. * @return The `GLXWindow` of the specified window, or `None` if an
  283. * [error](@ref error_handling) occurred.
  284. *
  285. * @thread_safety This function may be called from any thread. Access is not
  286. * synchronized.
  287. *
  288. * @since Added in version 3.2.
  289. *
  290. * @ingroup native
  291. */
  292. GLFWAPI GLXWindow glfwGetGLXWindow(GLFWwindow* window);
  293. #endif
  294. #if defined(GLFW_EXPOSE_NATIVE_WAYLAND)
  295. /*! @brief Returns the `struct wl_display*` used by GLFW.
  296. *
  297. * @return The `struct wl_display*` used by GLFW, or `NULL` if an
  298. * [error](@ref error_handling) occurred.
  299. *
  300. * @thread_safety This function may be called from any thread. Access is not
  301. * synchronized.
  302. *
  303. * @since Added in version 3.2.
  304. *
  305. * @ingroup native
  306. */
  307. GLFWAPI struct wl_display* glfwGetWaylandDisplay(void);
  308. /*! @brief Returns the `struct wl_output*` of the specified monitor.
  309. *
  310. * @return The `struct wl_output*` of the specified monitor, or `NULL` if an
  311. * [error](@ref error_handling) occurred.
  312. *
  313. * @thread_safety This function may be called from any thread. Access is not
  314. * synchronized.
  315. *
  316. * @since Added in version 3.2.
  317. *
  318. * @ingroup native
  319. */
  320. GLFWAPI struct wl_output* glfwGetWaylandMonitor(GLFWmonitor* monitor);
  321. /*! @brief Returns the main `struct wl_surface*` of the specified window.
  322. *
  323. * @return The main `struct wl_surface*` of the specified window, or `NULL` if
  324. * an [error](@ref error_handling) occurred.
  325. *
  326. * @thread_safety This function may be called from any thread. Access is not
  327. * synchronized.
  328. *
  329. * @since Added in version 3.2.
  330. *
  331. * @ingroup native
  332. */
  333. GLFWAPI struct wl_surface* glfwGetWaylandWindow(GLFWwindow* window);
  334. #endif
  335. #if defined(GLFW_EXPOSE_NATIVE_MIR)
  336. /*! @brief Returns the `MirConnection*` used by GLFW.
  337. *
  338. * @return The `MirConnection*` used by GLFW, or `NULL` if an
  339. * [error](@ref error_handling) occurred.
  340. *
  341. * @thread_safety This function may be called from any thread. Access is not
  342. * synchronized.
  343. *
  344. * @since Added in version 3.2.
  345. *
  346. * @ingroup native
  347. */
  348. GLFWAPI MirConnection* glfwGetMirDisplay(void);
  349. /*! @brief Returns the Mir output ID of the specified monitor.
  350. *
  351. * @return The Mir output ID of the specified monitor, or zero if an
  352. * [error](@ref error_handling) occurred.
  353. *
  354. * @thread_safety This function may be called from any thread. Access is not
  355. * synchronized.
  356. *
  357. * @since Added in version 3.2.
  358. *
  359. * @ingroup native
  360. */
  361. GLFWAPI int glfwGetMirMonitor(GLFWmonitor* monitor);
  362. /*! @brief Returns the `MirSurface*` of the specified window.
  363. *
  364. * @return The `MirSurface*` of the specified window, or `NULL` if an
  365. * [error](@ref error_handling) occurred.
  366. *
  367. * @thread_safety This function may be called from any thread. Access is not
  368. * synchronized.
  369. *
  370. * @since Added in version 3.2.
  371. *
  372. * @ingroup native
  373. */
  374. GLFWAPI MirSurface* glfwGetMirWindow(GLFWwindow* window);
  375. #endif
  376. #if defined(GLFW_EXPOSE_NATIVE_EGL)
  377. /*! @brief Returns the `EGLDisplay` used by GLFW.
  378. *
  379. * @return The `EGLDisplay` used by GLFW, or `EGL_NO_DISPLAY` if an
  380. * [error](@ref error_handling) occurred.
  381. *
  382. * @thread_safety This function may be called from any thread. Access is not
  383. * synchronized.
  384. *
  385. * @since Added in version 3.0.
  386. *
  387. * @ingroup native
  388. */
  389. GLFWAPI EGLDisplay glfwGetEGLDisplay(void);
  390. /*! @brief Returns the `EGLContext` of the specified window.
  391. *
  392. * @return The `EGLContext` of the specified window, or `EGL_NO_CONTEXT` if an
  393. * [error](@ref error_handling) occurred.
  394. *
  395. * @thread_safety This function may be called from any thread. Access is not
  396. * synchronized.
  397. *
  398. * @since Added in version 3.0.
  399. *
  400. * @ingroup native
  401. */
  402. GLFWAPI EGLContext glfwGetEGLContext(GLFWwindow* window);
  403. /*! @brief Returns the `EGLSurface` of the specified window.
  404. *
  405. * @return The `EGLSurface` of the specified window, or `EGL_NO_SURFACE` if an
  406. * [error](@ref error_handling) occurred.
  407. *
  408. * @thread_safety This function may be called from any thread. Access is not
  409. * synchronized.
  410. *
  411. * @since Added in version 3.0.
  412. *
  413. * @ingroup native
  414. */
  415. GLFWAPI EGLSurface glfwGetEGLSurface(GLFWwindow* window);
  416. #endif
  417. #ifdef __cplusplus
  418. }
  419. #endif
  420. #endif /* _glfw3_native_h_ */