|
|
@ -3,7 +3,7 @@ |
|
|
|
* A library for OpenGL, window and input |
|
|
|
*------------------------------------------------------------------------ |
|
|
|
* Copyright (c) 2002-2006 Marcus Geelnard |
|
|
|
* Copyright (c) 2006-2016 Camilla Löwy <elmindreda@glfw.org> |
|
|
|
* Copyright (c) 2006-2018 Camilla Löwy <elmindreda@glfw.org> |
|
|
|
* |
|
|
|
* This software is provided 'as-is', without any express or implied |
|
|
|
* warranty. In no event will the authors be held liable for any damages |
|
|
@ -62,7 +62,6 @@ extern "C" { |
|
|
|
* * `GLFW_EXPOSE_NATIVE_COCOA` |
|
|
|
* * `GLFW_EXPOSE_NATIVE_X11` |
|
|
|
* * `GLFW_EXPOSE_NATIVE_WAYLAND` |
|
|
|
* * `GLFW_EXPOSE_NATIVE_MIR` |
|
|
|
* |
|
|
|
* The available context API macros are: |
|
|
|
* * `GLFW_EXPOSE_NATIVE_WGL` |
|
|
@ -75,6 +74,16 @@ extern "C" { |
|
|
|
* and which platform-specific headers to include. It is then up your (by |
|
|
|
* definition platform-specific) code to handle which of these should be |
|
|
|
* defined. |
|
|
|
* |
|
|
|
* If you do not want the platform-specific headers to be included, define |
|
|
|
* `GLFW_NATIVE_INCLUDE_NONE` before including the @ref glfw3native.h header. |
|
|
|
* |
|
|
|
* @code |
|
|
|
* #define GLFW_EXPOSE_NATIVE_WIN32 |
|
|
|
* #define GLFW_EXPOSE_NATIVE_WGL |
|
|
|
* #define GLFW_NATIVE_INCLUDE_NONE |
|
|
|
* #include <GLFW/glfw3native.h> |
|
|
|
* @endcode |
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
@ -82,46 +91,65 @@ extern "C" { |
|
|
|
* System headers and types |
|
|
|
*************************************************************************/ |
|
|
|
|
|
|
|
#if defined(GLFW_EXPOSE_NATIVE_WIN32) |
|
|
|
// This is a workaround for the fact that glfw3.h needs to export APIENTRY (for |
|
|
|
// example to allow applications to correctly declare a GL_ARB_debug_output |
|
|
|
// callback) but windows.h assumes no one will define APIENTRY before it does |
|
|
|
#if defined(GLFW_APIENTRY_DEFINED) |
|
|
|
#undef APIENTRY |
|
|
|
#undef GLFW_APIENTRY_DEFINED |
|
|
|
#if !defined(GLFW_NATIVE_INCLUDE_NONE) |
|
|
|
|
|
|
|
#if defined(GLFW_EXPOSE_NATIVE_WIN32) || defined(GLFW_EXPOSE_NATIVE_WGL) |
|
|
|
/* This is a workaround for the fact that glfw3.h needs to export APIENTRY (for |
|
|
|
* example to allow applications to correctly declare a GL_KHR_debug callback) |
|
|
|
* but windows.h assumes no one will define APIENTRY before it does |
|
|
|
*/ |
|
|
|
#if defined(GLFW_APIENTRY_DEFINED) |
|
|
|
#undef APIENTRY |
|
|
|
#undef GLFW_APIENTRY_DEFINED |
|
|
|
#endif |
|
|
|
#include <windows.h> |
|
|
|
#elif defined(GLFW_EXPOSE_NATIVE_COCOA) || defined(GLFW_EXPOSE_NATIVE_NSGL) |
|
|
|
#if defined(__OBJC__) |
|
|
|
#import <Cocoa/Cocoa.h> |
|
|
|
#else |
|
|
|
#include <ApplicationServices/ApplicationServices.h> |
|
|
|
#include <objc/objc.h> |
|
|
|
#endif |
|
|
|
#elif defined(GLFW_EXPOSE_NATIVE_X11) || defined(GLFW_EXPOSE_NATIVE_GLX) |
|
|
|
#include <X11/Xlib.h> |
|
|
|
#include <X11/extensions/Xrandr.h> |
|
|
|
#elif defined(GLFW_EXPOSE_NATIVE_WAYLAND) |
|
|
|
#include <wayland-client.h> |
|
|
|
#endif |
|
|
|
#include <windows.h> |
|
|
|
#elif defined(GLFW_EXPOSE_NATIVE_COCOA) |
|
|
|
#include <ApplicationServices/ApplicationServices.h> |
|
|
|
#if defined(__OBJC__) |
|
|
|
#import <Cocoa/Cocoa.h> |
|
|
|
#else |
|
|
|
typedef void* id; |
|
|
|
|
|
|
|
#if defined(GLFW_EXPOSE_NATIVE_WGL) |
|
|
|
/* WGL is declared by windows.h */ |
|
|
|
#endif |
|
|
|
#if defined(GLFW_EXPOSE_NATIVE_NSGL) |
|
|
|
/* NSGL is declared by Cocoa.h */ |
|
|
|
#endif |
|
|
|
#if defined(GLFW_EXPOSE_NATIVE_GLX) |
|
|
|
/* This is a workaround for the fact that glfw3.h defines GLAPIENTRY because by |
|
|
|
* default it also acts as an OpenGL header |
|
|
|
* However, glx.h will include gl.h, which will define it unconditionally |
|
|
|
*/ |
|
|
|
#if defined(GLFW_GLAPIENTRY_DEFINED) |
|
|
|
#undef GLAPIENTRY |
|
|
|
#undef GLFW_GLAPIENTRY_DEFINED |
|
|
|
#endif |
|
|
|
#include <GL/glx.h> |
|
|
|
#endif |
|
|
|
#if defined(GLFW_EXPOSE_NATIVE_EGL) |
|
|
|
#include <EGL/egl.h> |
|
|
|
#endif |
|
|
|
#if defined(GLFW_EXPOSE_NATIVE_OSMESA) |
|
|
|
/* This is a workaround for the fact that glfw3.h defines GLAPIENTRY because by |
|
|
|
* default it also acts as an OpenGL header |
|
|
|
* However, osmesa.h will include gl.h, which will define it unconditionally |
|
|
|
*/ |
|
|
|
#if defined(GLFW_GLAPIENTRY_DEFINED) |
|
|
|
#undef GLAPIENTRY |
|
|
|
#undef GLFW_GLAPIENTRY_DEFINED |
|
|
|
#endif |
|
|
|
#include <GL/osmesa.h> |
|
|
|
#endif |
|
|
|
#elif defined(GLFW_EXPOSE_NATIVE_X11) |
|
|
|
#include <X11/Xlib.h> |
|
|
|
#include <X11/extensions/Xrandr.h> |
|
|
|
#elif defined(GLFW_EXPOSE_NATIVE_WAYLAND) |
|
|
|
#include <wayland-client.h> |
|
|
|
#elif defined(GLFW_EXPOSE_NATIVE_MIR) |
|
|
|
#include <mir_toolkit/mir_client_library.h> |
|
|
|
#endif |
|
|
|
|
|
|
|
#if defined(GLFW_EXPOSE_NATIVE_WGL) |
|
|
|
/* WGL is declared by windows.h */ |
|
|
|
#endif |
|
|
|
#if defined(GLFW_EXPOSE_NATIVE_NSGL) |
|
|
|
/* NSGL is declared by Cocoa.h */ |
|
|
|
#endif |
|
|
|
#if defined(GLFW_EXPOSE_NATIVE_GLX) |
|
|
|
#include <GL/glx.h> |
|
|
|
#endif |
|
|
|
#if defined(GLFW_EXPOSE_NATIVE_EGL) |
|
|
|
#include <EGL/egl.h> |
|
|
|
#endif |
|
|
|
#if defined(GLFW_EXPOSE_NATIVE_OSMESA) |
|
|
|
#include <GL/osmesa.h> |
|
|
|
#endif |
|
|
|
#endif /*GLFW_NATIVE_INCLUDE_NONE*/ |
|
|
|
|
|
|
|
|
|
|
|
/************************************************************************* |
|
|
@ -135,6 +163,8 @@ extern "C" { |
|
|
|
* of the specified monitor, or `NULL` if an [error](@ref error_handling) |
|
|
|
* occurred. |
|
|
|
* |
|
|
|
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED. |
|
|
|
* |
|
|
|
* @thread_safety This function may be called from any thread. Access is not |
|
|
|
* synchronized. |
|
|
|
* |
|
|
@ -150,6 +180,8 @@ GLFWAPI const char* glfwGetWin32Adapter(GLFWmonitor* monitor); |
|
|
|
* `\\.\DISPLAY1\Monitor0`) of the specified monitor, or `NULL` if an |
|
|
|
* [error](@ref error_handling) occurred. |
|
|
|
* |
|
|
|
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED. |
|
|
|
* |
|
|
|
* @thread_safety This function may be called from any thread. Access is not |
|
|
|
* synchronized. |
|
|
|
* |
|
|
@ -164,6 +196,16 @@ GLFWAPI const char* glfwGetWin32Monitor(GLFWmonitor* monitor); |
|
|
|
* @return The `HWND` of the specified window, or `NULL` if an |
|
|
|
* [error](@ref error_handling) occurred. |
|
|
|
* |
|
|
|
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED. |
|
|
|
* |
|
|
|
* @remark The `HDC` associated with the window can be queried with the |
|
|
|
* [GetDC](https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getdc) |
|
|
|
* function. |
|
|
|
* @code |
|
|
|
* HDC dc = GetDC(glfwGetWin32Window(window)); |
|
|
|
* @endcode |
|
|
|
* This DC is private and does not need to be released. |
|
|
|
* |
|
|
|
* @thread_safety This function may be called from any thread. Access is not |
|
|
|
* synchronized. |
|
|
|
* |
|
|
@ -180,6 +222,17 @@ GLFWAPI HWND glfwGetWin32Window(GLFWwindow* window); |
|
|
|
* @return The `HGLRC` of the specified window, or `NULL` if an |
|
|
|
* [error](@ref error_handling) occurred. |
|
|
|
* |
|
|
|
* @errors Possible errors include @ref GLFW_NO_WINDOW_CONTEXT and @ref |
|
|
|
* GLFW_NOT_INITIALIZED. |
|
|
|
* |
|
|
|
* @remark The `HDC` associated with the window can be queried with the |
|
|
|
* [GetDC](https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getdc) |
|
|
|
* function. |
|
|
|
* @code |
|
|
|
* HDC dc = GetDC(glfwGetWin32Window(window)); |
|
|
|
* @endcode |
|
|
|
* This DC is private and does not need to be released. |
|
|
|
* |
|
|
|
* @thread_safety This function may be called from any thread. Access is not |
|
|
|
* synchronized. |
|
|
|
* |
|
|
@ -196,6 +249,8 @@ GLFWAPI HGLRC glfwGetWGLContext(GLFWwindow* window); |
|
|
|
* @return The `CGDirectDisplayID` of the specified monitor, or |
|
|
|
* `kCGNullDirectDisplay` if an [error](@ref error_handling) occurred. |
|
|
|
* |
|
|
|
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED. |
|
|
|
* |
|
|
|
* @thread_safety This function may be called from any thread. Access is not |
|
|
|
* synchronized. |
|
|
|
* |
|
|
@ -210,6 +265,8 @@ GLFWAPI CGDirectDisplayID glfwGetCocoaMonitor(GLFWmonitor* monitor); |
|
|
|
* @return The `NSWindow` of the specified window, or `nil` if an |
|
|
|
* [error](@ref error_handling) occurred. |
|
|
|
* |
|
|
|
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED. |
|
|
|
* |
|
|
|
* @thread_safety This function may be called from any thread. Access is not |
|
|
|
* synchronized. |
|
|
|
* |
|
|
@ -226,6 +283,9 @@ GLFWAPI id glfwGetCocoaWindow(GLFWwindow* window); |
|
|
|
* @return The `NSOpenGLContext` of the specified window, or `nil` if an |
|
|
|
* [error](@ref error_handling) occurred. |
|
|
|
* |
|
|
|
* @errors Possible errors include @ref GLFW_NO_WINDOW_CONTEXT and @ref |
|
|
|
* GLFW_NOT_INITIALIZED. |
|
|
|
* |
|
|
|
* @thread_safety This function may be called from any thread. Access is not |
|
|
|
* synchronized. |
|
|
|
* |
|
|
@ -242,6 +302,8 @@ GLFWAPI id glfwGetNSGLContext(GLFWwindow* window); |
|
|
|
* @return The `Display` used by GLFW, or `NULL` if an |
|
|
|
* [error](@ref error_handling) occurred. |
|
|
|
* |
|
|
|
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED. |
|
|
|
* |
|
|
|
* @thread_safety This function may be called from any thread. Access is not |
|
|
|
* synchronized. |
|
|
|
* |
|
|
@ -256,6 +318,8 @@ GLFWAPI Display* glfwGetX11Display(void); |
|
|
|
* @return The `RRCrtc` of the specified monitor, or `None` if an |
|
|
|
* [error](@ref error_handling) occurred. |
|
|
|
* |
|
|
|
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED. |
|
|
|
* |
|
|
|
* @thread_safety This function may be called from any thread. Access is not |
|
|
|
* synchronized. |
|
|
|
* |
|
|
@ -270,6 +334,8 @@ GLFWAPI RRCrtc glfwGetX11Adapter(GLFWmonitor* monitor); |
|
|
|
* @return The `RROutput` of the specified monitor, or `None` if an |
|
|
|
* [error](@ref error_handling) occurred. |
|
|
|
* |
|
|
|
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED. |
|
|
|
* |
|
|
|
* @thread_safety This function may be called from any thread. Access is not |
|
|
|
* synchronized. |
|
|
|
* |
|
|
@ -284,6 +350,8 @@ GLFWAPI RROutput glfwGetX11Monitor(GLFWmonitor* monitor); |
|
|
|
* @return The `Window` of the specified window, or `None` if an |
|
|
|
* [error](@ref error_handling) occurred. |
|
|
|
* |
|
|
|
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED. |
|
|
|
* |
|
|
|
* @thread_safety This function may be called from any thread. Access is not |
|
|
|
* synchronized. |
|
|
|
* |
|
|
@ -350,6 +418,9 @@ GLFWAPI const char* glfwGetX11SelectionString(void); |
|
|
|
* @return The `GLXContext` of the specified window, or `NULL` if an |
|
|
|
* [error](@ref error_handling) occurred. |
|
|
|
* |
|
|
|
* @errors Possible errors include @ref GLFW_NO_WINDOW_CONTEXT and @ref |
|
|
|
* GLFW_NOT_INITIALIZED. |
|
|
|
* |
|
|
|
* @thread_safety This function may be called from any thread. Access is not |
|
|
|
* synchronized. |
|
|
|
* |
|
|
@ -364,6 +435,9 @@ GLFWAPI GLXContext glfwGetGLXContext(GLFWwindow* window); |
|
|
|
* @return The `GLXWindow` of the specified window, or `None` if an |
|
|
|
* [error](@ref error_handling) occurred. |
|
|
|
* |
|
|
|
* @errors Possible errors include @ref GLFW_NO_WINDOW_CONTEXT and @ref |
|
|
|
* GLFW_NOT_INITIALIZED. |
|
|
|
* |
|
|
|
* @thread_safety This function may be called from any thread. Access is not |
|
|
|
* synchronized. |
|
|
|
* |
|
|
@ -380,6 +454,8 @@ GLFWAPI GLXWindow glfwGetGLXWindow(GLFWwindow* window); |
|
|
|
* @return The `struct wl_display*` used by GLFW, or `NULL` if an |
|
|
|
* [error](@ref error_handling) occurred. |
|
|
|
* |
|
|
|
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED. |
|
|
|
* |
|
|
|
* @thread_safety This function may be called from any thread. Access is not |
|
|
|
* synchronized. |
|
|
|
* |
|
|
@ -394,6 +470,8 @@ GLFWAPI struct wl_display* glfwGetWaylandDisplay(void); |
|
|
|
* @return The `struct wl_output*` of the specified monitor, or `NULL` if an |
|
|
|
* [error](@ref error_handling) occurred. |
|
|
|
* |
|
|
|
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED. |
|
|
|
* |
|
|
|
* @thread_safety This function may be called from any thread. Access is not |
|
|
|
* synchronized. |
|
|
|
* |
|
|
@ -408,35 +486,7 @@ GLFWAPI struct wl_output* glfwGetWaylandMonitor(GLFWmonitor* monitor); |
|
|
|
* @return The main `struct wl_surface*` of the specified window, or `NULL` if |
|
|
|
* an [error](@ref error_handling) occurred. |
|
|
|
* |
|
|
|
* @thread_safety This function may be called from any thread. Access is not |
|
|
|
* synchronized. |
|
|
|
* |
|
|
|
* @since Added in version 3.2. |
|
|
|
* |
|
|
|
* @ingroup native |
|
|
|
*/ |
|
|
|
GLFWAPI struct wl_surface* glfwGetWaylandWindow(GLFWwindow* window); |
|
|
|
#endif |
|
|
|
|
|
|
|
#if defined(GLFW_EXPOSE_NATIVE_MIR) |
|
|
|
/*! @brief Returns the `MirConnection*` used by GLFW. |
|
|
|
* |
|
|
|
* @return The `MirConnection*` used by GLFW, or `NULL` if an |
|
|
|
* [error](@ref error_handling) occurred. |
|
|
|
* |
|
|
|
* @thread_safety This function may be called from any thread. Access is not |
|
|
|
* synchronized. |
|
|
|
* |
|
|
|
* @since Added in version 3.2. |
|
|
|
* |
|
|
|
* @ingroup native |
|
|
|
*/ |
|
|
|
GLFWAPI MirConnection* glfwGetMirDisplay(void); |
|
|
|
|
|
|
|
/*! @brief Returns the Mir output ID of the specified monitor. |
|
|
|
* |
|
|
|
* @return The Mir output ID of the specified monitor, or zero if an |
|
|
|
* [error](@ref error_handling) occurred. |
|
|
|
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED. |
|
|
|
* |
|
|
|
* @thread_safety This function may be called from any thread. Access is not |
|
|
|
* synchronized. |
|
|
@ -445,21 +495,7 @@ GLFWAPI MirConnection* glfwGetMirDisplay(void); |
|
|
|
* |
|
|
|
* @ingroup native |
|
|
|
*/ |
|
|
|
GLFWAPI int glfwGetMirMonitor(GLFWmonitor* monitor); |
|
|
|
|
|
|
|
/*! @brief Returns the `MirWindow*` of the specified window. |
|
|
|
* |
|
|
|
* @return The `MirWindow*` of the specified window, or `NULL` if an |
|
|
|
* [error](@ref error_handling) occurred. |
|
|
|
* |
|
|
|
* @thread_safety This function may be called from any thread. Access is not |
|
|
|
* synchronized. |
|
|
|
* |
|
|
|
* @since Added in version 3.2. |
|
|
|
* |
|
|
|
* @ingroup native |
|
|
|
*/ |
|
|
|
GLFWAPI MirWindow* glfwGetMirWindow(GLFWwindow* window); |
|
|
|
GLFWAPI struct wl_surface* glfwGetWaylandWindow(GLFWwindow* window); |
|
|
|
#endif |
|
|
|
|
|
|
|
#if defined(GLFW_EXPOSE_NATIVE_EGL) |
|
|
@ -468,6 +504,11 @@ GLFWAPI MirWindow* glfwGetMirWindow(GLFWwindow* window); |
|
|
|
* @return The `EGLDisplay` used by GLFW, or `EGL_NO_DISPLAY` if an |
|
|
|
* [error](@ref error_handling) occurred. |
|
|
|
* |
|
|
|
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED. |
|
|
|
* |
|
|
|
* @remark Because EGL is initialized on demand, this function will return |
|
|
|
* `EGL_NO_DISPLAY` until the first context has been created via EGL. |
|
|
|
* |
|
|
|
* @thread_safety This function may be called from any thread. Access is not |
|
|
|
* synchronized. |
|
|
|
* |
|
|
@ -482,6 +523,9 @@ GLFWAPI EGLDisplay glfwGetEGLDisplay(void); |
|
|
|
* @return The `EGLContext` of the specified window, or `EGL_NO_CONTEXT` if an |
|
|
|
* [error](@ref error_handling) occurred. |
|
|
|
* |
|
|
|
* @errors Possible errors include @ref GLFW_NO_WINDOW_CONTEXT and @ref |
|
|
|
* GLFW_NOT_INITIALIZED. |
|
|
|
* |
|
|
|
* @thread_safety This function may be called from any thread. Access is not |
|
|
|
* synchronized. |
|
|
|
* |
|
|
@ -496,6 +540,9 @@ GLFWAPI EGLContext glfwGetEGLContext(GLFWwindow* window); |
|
|
|
* @return The `EGLSurface` of the specified window, or `EGL_NO_SURFACE` if an |
|
|
|
* [error](@ref error_handling) occurred. |
|
|
|
* |
|
|
|
* @errors Possible errors include @ref GLFW_NO_WINDOW_CONTEXT and @ref |
|
|
|
* GLFW_NOT_INITIALIZED. |
|
|
|
* |
|
|
|
* @thread_safety This function may be called from any thread. Access is not |
|
|
|
* synchronized. |
|
|
|
* |
|
|
@ -519,6 +566,9 @@ GLFWAPI EGLSurface glfwGetEGLSurface(GLFWwindow* window); |
|
|
|
* @return `GLFW_TRUE` if successful, or `GLFW_FALSE` if an |
|
|
|
* [error](@ref error_handling) occurred. |
|
|
|
* |
|
|
|
* @errors Possible errors include @ref GLFW_NO_WINDOW_CONTEXT and @ref |
|
|
|
* GLFW_NOT_INITIALIZED. |
|
|
|
* |
|
|
|
* @thread_safety This function may be called from any thread. Access is not |
|
|
|
* synchronized. |
|
|
|
* |
|
|
@ -540,6 +590,9 @@ GLFWAPI int glfwGetOSMesaColorBuffer(GLFWwindow* window, int* width, int* height |
|
|
|
* @return `GLFW_TRUE` if successful, or `GLFW_FALSE` if an |
|
|
|
* [error](@ref error_handling) occurred. |
|
|
|
* |
|
|
|
* @errors Possible errors include @ref GLFW_NO_WINDOW_CONTEXT and @ref |
|
|
|
* GLFW_NOT_INITIALIZED. |
|
|
|
* |
|
|
|
* @thread_safety This function may be called from any thread. Access is not |
|
|
|
* synchronized. |
|
|
|
* |
|
|
@ -554,6 +607,9 @@ GLFWAPI int glfwGetOSMesaDepthBuffer(GLFWwindow* window, int* width, int* height |
|
|
|
* @return The `OSMesaContext` of the specified window, or `NULL` if an |
|
|
|
* [error](@ref error_handling) occurred. |
|
|
|
* |
|
|
|
* @errors Possible errors include @ref GLFW_NO_WINDOW_CONTEXT and @ref |
|
|
|
* GLFW_NOT_INITIALIZED. |
|
|
|
* |
|
|
|
* @thread_safety This function may be called from any thread. Access is not |
|
|
|
* synchronized. |
|
|
|
* |
|
|
|