glfw3native.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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 <[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. /*! @defgroup native Native access
  37. *
  38. * **By using the native API, you assert that you know what you're doing and
  39. * how to fix problems caused by using it. If you don't, you shouldn't be
  40. * using it.**
  41. *
  42. * Before the inclusion of @ref glfw3native.h, you must define exactly one
  43. * window API macro and exactly one context API macro. Failure to do this
  44. * 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. #include <windows.h>
  67. #elif defined(GLFW_EXPOSE_NATIVE_COCOA)
  68. #if defined(__OBJC__)
  69. #import <Cocoa/Cocoa.h>
  70. #else
  71. typedef void* id;
  72. #endif
  73. #elif defined(GLFW_EXPOSE_NATIVE_X11)
  74. #include <X11/Xlib.h>
  75. #else
  76. #error "No window API specified"
  77. #endif
  78. #if defined(GLFW_EXPOSE_NATIVE_WGL)
  79. /* WGL is declared by windows.h */
  80. #elif defined(GLFW_EXPOSE_NATIVE_NSGL)
  81. /* NSGL is declared by Cocoa.h */
  82. #elif defined(GLFW_EXPOSE_NATIVE_GLX)
  83. #include <GL/glx.h>
  84. #elif defined(GLFW_EXPOSE_NATIVE_EGL)
  85. #include <EGL/egl.h>
  86. #else
  87. #error "No context API specified"
  88. #endif
  89. /*************************************************************************
  90. * Functions
  91. *************************************************************************/
  92. #if defined(GLFW_EXPOSE_NATIVE_WIN32)
  93. /*! @brief Returns the `HWND` of the specified window.
  94. * @return The `HWND` of the specified window.
  95. * @ingroup native
  96. */
  97. GLFWAPI HWND glfwGetWin32Window(GLFWwindow* window);
  98. #endif
  99. #if defined(GLFW_EXPOSE_NATIVE_WGL)
  100. /*! @brief Returns the `HGLRC` of the specified window.
  101. * @return The `HGLRC` of the specified window.
  102. * @ingroup native
  103. */
  104. GLFWAPI HGLRC glfwGetWGLContext(GLFWwindow* window);
  105. #endif
  106. #if defined(GLFW_EXPOSE_NATIVE_COCOA)
  107. /*! @brief Returns the `NSWindow` of the specified window.
  108. * @return The `NSWindow` of the specified window.
  109. * @ingroup native
  110. */
  111. GLFWAPI id glfwGetCocoaWindow(GLFWwindow* window);
  112. #endif
  113. #if defined(GLFW_EXPOSE_NATIVE_NSGL)
  114. /*! @brief Returns the `NSOpenGLContext` of the specified window.
  115. * @return The `NSOpenGLContext` of the specified window.
  116. * @ingroup native
  117. */
  118. GLFWAPI id glfwGetNSGLContext(GLFWwindow* window);
  119. #endif
  120. #if defined(GLFW_EXPOSE_NATIVE_X11)
  121. /*! @brief Returns the `Display` used by GLFW.
  122. * @return The `Display` used by GLFW.
  123. * @ingroup native
  124. */
  125. GLFWAPI Display* glfwGetX11Display(void);
  126. /*! @brief Returns the `Window` of the specified window.
  127. * @return The `Window` of the specified window.
  128. * @ingroup native
  129. */
  130. GLFWAPI Window glfwGetX11Window(GLFWwindow* window);
  131. #endif
  132. #if defined(GLFW_EXPOSE_NATIVE_GLX)
  133. /*! @brief Returns the `GLXContext` of the specified window.
  134. * @return The `GLXContext` of the specified window.
  135. * @ingroup native
  136. */
  137. GLFWAPI GLXContext glfwGetGLXContext(GLFWwindow* window);
  138. #endif
  139. #if defined(GLFW_EXPOSE_NATIVE_EGL)
  140. /*! @brief Returns the `EGLDisplay` used by GLFW.
  141. * @return The `EGLDisplay` used by GLFW.
  142. * @ingroup native
  143. */
  144. GLFWAPI EGLDisplay glfwGetEGLDisplay(void);
  145. /*! @brief Returns the `EGLContext` of the specified window.
  146. * @return The `EGLContext` of the specified window.
  147. * @ingroup native
  148. */
  149. GLFWAPI EGLContext glfwGetEGLContext(GLFWwindow* window);
  150. /*! @brief Returns the `EGLSurface` of the specified window.
  151. * @return The `EGLSurface` of the specified window.
  152. * @ingroup native
  153. */
  154. GLFWAPI EGLSurface glfwGetEGLSurface(GLFWwindow* window);
  155. #endif
  156. #ifdef __cplusplus
  157. }
  158. #endif
  159. #endif /* _glfw3_native_h_ */