summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--changelog4
-rw-r--r--examples/events/main.lua22
-rw-r--r--include/GLFW/glfw3.h (renamed from include/glfw3.h)559
-rw-r--r--include/GLFW/glfw3native.h (renamed from include/glfw3native.h)93
-rw-r--r--include/main.h4
-rw-r--r--include/platforms/core_desktop.h10
-rw-r--r--include/state.h4
-rw-r--r--src/platforms/core_desktop.c95
8 files changed, 717 insertions, 74 deletions
diff --git a/changelog b/changelog
index 8a90a95..3b07f59 100644
--- a/changelog
+++ b/changelog
@@ -13,6 +13,7 @@ KEY CHANGES:
- ADDED: Platform desktop SDL.
- CHANGE: Renamed event enums. Events are now platform specific.
- ADDED: SDL Events.
+ - ADDED: Experimental GLFW Pen Touch events. Needs glfw PR https://github.com/glfw/glfw/pull/1445.
DETAILED CHANGES:
- REMOVED: DrawLineBezierQuad, DrawLineBezierCubic.
@@ -25,7 +26,8 @@ DETAILED CHANGES:
- ADDED: GetApplicationDirectory.
- FIXED: Snake example after Vector2Angle change.
- FIXED: Raygui edit mode selection.
-
+ - CHANGE: Moved glfw headers to GLFW folder.
+
------------------------------------------------------------------------
Release: ReiLua version 0.6.0 Using Raylib 4.5
------------------------------------------------------------------------
diff --git a/examples/events/main.lua b/examples/events/main.lua
index f8f615d..28d63a3 100644
--- a/examples/events/main.lua
+++ b/examples/events/main.lua
@@ -64,6 +64,9 @@ local function keyName( key )
return "Unknown"
end
+local mousePos = { 0, 0 }
+local cursorMode = 1
+
function RL.event( event )
text = "Event: "..getEventType( event ).."\n"
@@ -126,6 +129,25 @@ function RL.event( event )
-- elseif event.type == RL.SDL_JOYBUTTONDOWN or event.type == RL.SDL_JOYBUTTONUP then
-- text = text.."which "..event.which.." Button: "..event.button.." State: "..event.state
-- end
+
+ -- Experimental GLFW pen tablet events.
+
+ -- if event.type == RL.GLFW_MOUSE_CURSOR_POS_EVENT then
+ -- mousePos = { event.x, event.y }
+ -- elseif event.type == RL.GLFW_PEN_TABLET_DATA_EVENT then
+ -- text = "x: "..event.x.." y: "..event.y.." pressure: "..event.pressure
+ -- text = text.."\nMouse Pos: "..mousePos[1]..", "..mousePos[2]
+
+ -- if cursorMode == 1 then
+ -- text = text.."\nMode: Pen"
+ -- elseif cursorMode == 2 then
+ -- text = text.."\nMode: Eraser"
+ -- end
+ -- elseif event.type == RL.GLFW_PEN_TABLET_CURSOR_EVENT then
+ -- cursorMode = event.identifier
+ -- elseif event.type == RL.GLFW_PEN_TABLET_PROXIMITY_EVENT then
+ -- print( event.state )
+ -- end
end
function RL.draw()
diff --git a/include/glfw3.h b/include/GLFW/glfw3.h
index 7728dad..de9d07b 100644
--- a/include/glfw3.h
+++ b/include/GLFW/glfw3.h
@@ -190,6 +190,9 @@ extern "C" {
#else /*__APPLE__*/
#include <GL/glcorearb.h>
+ #if defined(GLFW_INCLUDE_GLEXT)
+ #include <GL/glext.h>
+ #endif
#endif /*__APPLE__*/
@@ -372,7 +375,7 @@ extern "C" {
*
* The naming of the key codes follow these rules:
* - The US keyboard layout is used
- * - Names of printable alpha-numeric characters are used (e.g. "A", "R",
+ * - Names of printable alphanumeric characters are used (e.g. "A", "R",
* "3", etc.)
* - For non-alphanumeric characters, Unicode:ish names are used (e.g.
* "COMMA", "LEFT_SQUARE_BRACKET", etc.). Note that some names do not
@@ -717,7 +720,7 @@ extern "C" {
* GLFW could not find support for the requested API on the system.
*
* @analysis The installed graphics driver does not support the requested
- * API, or does not support it via the chosen context creation backend.
+ * API, or does not support it via the chosen context creation API.
* Below are a few examples.
*
* @par
@@ -786,7 +789,7 @@ extern "C" {
/*! @brief The specified cursor shape is not available.
*
* The specified standard cursor shape is not available, either because the
- * current system cursor theme does not provide it or because it is not
+ * current platform cursor theme does not provide it or because it is not
* available on the platform.
*
* @analysis Platform or system settings limitation. Pick another
@@ -821,6 +824,28 @@ extern "C" {
* updating any existing out parameters.
*/
#define GLFW_FEATURE_UNIMPLEMENTED 0x0001000D
+/*! @brief Platform unavailable or no matching platform was found.
+ *
+ * If emitted during initialization, no matching platform was found. If @ref
+ * GLFW_PLATFORM is set to `GLFW_ANY_PLATFORM`, GLFW could not detect any of the
+ * platforms supported by this library binary, except for the Null platform. If set to
+ * a specific platform, it is either not supported by this library binary or GLFW was not
+ * able to detect it.
+ *
+ * If emitted by a native access function, GLFW was initialized for a different platform
+ * than the function is for.
+ *
+ * @analysis Failure to detect any platform usually only happens on non-macOS Unix
+ * systems, either when no window system is running or the program was run from
+ * a terminal that does not have the necessary environment variables. Fall back to
+ * a different platform if possible or notify the user that no usable platform was
+ * detected.
+ *
+ * Failure to detect a specific platform may have the same cause as above or be because
+ * support for that platform was not compiled in. Call @ref glfwPlatformSupported to
+ * check whether a specific platform is supported by a library binary.
+ */
+#define GLFW_PLATFORM_UNAVAILABLE 0x0001000E
/*! @} */
/*! @addtogroup window
@@ -1003,7 +1028,7 @@ extern "C" {
* and [attribute](@ref GLFW_CONTEXT_VERSION_MINOR_attrib).
*/
#define GLFW_CONTEXT_VERSION_MINOR 0x00022003
-/*! @brief Context client API revision number hint and attribute.
+/*! @brief Context client API revision number attribute.
*
* Context client API revision number
* [attribute](@ref GLFW_CONTEXT_REVISION_attrib).
@@ -1125,7 +1150,7 @@ extern "C" {
* @brief Standard system cursor shapes.
*
* These are the [standard cursor shapes](@ref cursor_standard) that can be
- * requested from the window system.
+ * requested from the platform (window system).
*
* @ingroup input
* @{ */
@@ -1242,6 +1267,11 @@ extern "C" {
* ANGLE rendering backend [init hint](@ref GLFW_ANGLE_PLATFORM_TYPE_hint).
*/
#define GLFW_ANGLE_PLATFORM_TYPE 0x00050002
+/*! @brief Platform selection init hint.
+ *
+ * Platform selection [init hint](@ref GLFW_PLATFORM).
+ */
+#define GLFW_PLATFORM 0x00050003
/*! @brief macOS specific init hint.
*
* macOS specific [init hint](@ref GLFW_COCOA_CHDIR_RESOURCES_hint).
@@ -1259,6 +1289,20 @@ extern "C" {
#define GLFW_X11_XCB_VULKAN_SURFACE 0x00052001
/*! @} */
+/*! @addtogroup init
+ * @{ */
+/*! @brief Hint value that enables automatic platform selection.
+ *
+ * Hint value for @ref GLFW_PLATFORM that enables automatic platform selection.
+ */
+#define GLFW_ANY_PLATFORM 0x00060000
+#define GLFW_PLATFORM_WIN32 0x00060001
+#define GLFW_PLATFORM_COCOA 0x00060002
+#define GLFW_PLATFORM_WAYLAND 0x00060003
+#define GLFW_PLATFORM_X11 0x00060004
+#define GLFW_PLATFORM_NULL 0x00060005
+/*! @} */
+
#define GLFW_DONT_CARE -1
@@ -1330,6 +1374,131 @@ typedef struct GLFWwindow GLFWwindow;
*/
typedef struct GLFWcursor GLFWcursor;
+/*! @brief The function pointer type for memory allocation callbacks.
+ *
+ * This is the function pointer type for memory allocation callbacks. A memory
+ * allocation callback function has the following signature:
+ * @code
+ * void* function_name(size_t size, void* user)
+ * @endcode
+ *
+ * This function must return either a memory block at least `size` bytes long,
+ * or `NULL` if allocation failed. Note that not all parts of GLFW handle allocation
+ * failures gracefully yet.
+ *
+ * This function may be called during @ref glfwInit but before the library is
+ * flagged as initialized, as well as during @ref glfwTerminate after the
+ * library is no longer flagged as initialized.
+ *
+ * Any memory allocated by this function will be deallocated during library
+ * termination or earlier.
+ *
+ * The size will always be greater than zero. Allocations of size zero are filtered out
+ * before reaching the custom allocator.
+ *
+ * @param[in] size The minimum size, in bytes, of the memory block.
+ * @param[in] user The user-defined pointer from the allocator.
+ * @return The address of the newly allocated memory block, or `NULL` if an
+ * error occurred.
+ *
+ * @pointer_lifetime The returned memory block must be valid at least until it
+ * is deallocated.
+ *
+ * @reentrancy This function should not call any GLFW function.
+ *
+ * @thread_safety This function may be called from any thread that calls GLFW functions.
+ *
+ * @sa @ref init_allocator
+ * @sa @ref GLFWallocator
+ *
+ * @since Added in version 3.4.
+ *
+ * @ingroup init
+ */
+typedef void* (* GLFWallocatefun)(size_t size, void* user);
+
+/*! @brief The function pointer type for memory reallocation callbacks.
+ *
+ * This is the function pointer type for memory reallocation callbacks.
+ * A memory reallocation callback function has the following signature:
+ * @code
+ * void* function_name(void* block, size_t size, void* user)
+ * @endcode
+ *
+ * This function must return a memory block at least `size` bytes long, or
+ * `NULL` if allocation failed. Note that not all parts of GLFW handle allocation
+ * failures gracefully yet.
+ *
+ * This function may be called during @ref glfwInit but before the library is
+ * flagged as initialized, as well as during @ref glfwTerminate after the
+ * library is no longer flagged as initialized.
+ *
+ * Any memory allocated by this function will be deallocated during library
+ * termination or earlier.
+ *
+ * The block address will never be `NULL` and the size will always be greater than zero.
+ * Reallocations of a block to size zero are converted into deallocations. Reallocations
+ * of `NULL` to a non-zero size are converted into regular allocations.
+ *
+ * @param[in] block The address of the memory block to reallocate.
+ * @param[in] size The new minimum size, in bytes, of the memory block.
+ * @param[in] user The user-defined pointer from the allocator.
+ * @return The address of the newly allocated or resized memory block, or
+ * `NULL` if an error occurred.
+ *
+ * @pointer_lifetime The returned memory block must be valid at least until it
+ * is deallocated.
+ *
+ * @reentrancy This function should not call any GLFW function.
+ *
+ * @thread_safety This function may be called from any thread that calls GLFW functions.
+ *
+ * @sa @ref init_allocator
+ * @sa @ref GLFWallocator
+ *
+ * @since Added in version 3.4.
+ *
+ * @ingroup init
+ */
+typedef void* (* GLFWreallocatefun)(void* block, size_t size, void* user);
+
+/*! @brief The function pointer type for memory deallocation callbacks.
+ *
+ * This is the function pointer type for memory deallocation callbacks.
+ * A memory deallocation callback function has the following signature:
+ * @code
+ * void function_name(void* block, void* user)
+ * @endcode
+ *
+ * This function may deallocate the specified memory block. This memory block
+ * will have been allocated with the same allocator.
+ *
+ * This function may be called during @ref glfwInit but before the library is
+ * flagged as initialized, as well as during @ref glfwTerminate after the
+ * library is no longer flagged as initialized.
+ *
+ * The block address will never be `NULL`. Deallocations of `NULL` are filtered out
+ * before reaching the custom allocator.
+ *
+ * @param[in] block The address of the memory block to deallocate.
+ * @param[in] user The user-defined pointer from the allocator.
+ *
+ * @pointer_lifetime The specified memory block will not be accessed by GLFW
+ * after this function is called.
+ *
+ * @reentrancy This function should not call any GLFW function.
+ *
+ * @thread_safety This function may be called from any thread that calls GLFW functions.
+ *
+ * @sa @ref init_allocator
+ * @sa @ref GLFWallocator
+ *
+ * @since Added in version 3.4.
+ *
+ * @ingroup init
+ */
+typedef void (* GLFWdeallocatefun)(void* block, void* user);
+
/*! @brief The function pointer type for error callbacks.
*
* This is the function pointer type for error callbacks. An error callback
@@ -1352,7 +1521,7 @@ typedef struct GLFWcursor GLFWcursor;
*
* @ingroup init
*/
-typedef void (* GLFWerrorfun)(int,const char*);
+typedef void (* GLFWerrorfun)(int error_code, const char* description);
/*! @brief The function pointer type for window position callbacks.
*
@@ -1375,7 +1544,7 @@ typedef void (* GLFWerrorfun)(int,const char*);
*
* @ingroup window
*/
-typedef void (* GLFWwindowposfun)(GLFWwindow*,int,int);
+typedef void (* GLFWwindowposfun)(GLFWwindow* window, int xpos, int ypos);
/*! @brief The function pointer type for window size callbacks.
*
@@ -1397,7 +1566,7 @@ typedef void (* GLFWwindowposfun)(GLFWwindow*,int,int);
*
* @ingroup window
*/
-typedef void (* GLFWwindowsizefun)(GLFWwindow*,int,int);
+typedef void (* GLFWwindowsizefun)(GLFWwindow* window, int width, int height);
/*! @brief The function pointer type for window close callbacks.
*
@@ -1417,7 +1586,7 @@ typedef void (* GLFWwindowsizefun)(GLFWwindow*,int,int);
*
* @ingroup window
*/
-typedef void (* GLFWwindowclosefun)(GLFWwindow*);
+typedef void (* GLFWwindowclosefun)(GLFWwindow* window);
/*! @brief The function pointer type for window content refresh callbacks.
*
@@ -1437,7 +1606,7 @@ typedef void (* GLFWwindowclosefun)(GLFWwindow*);
*
* @ingroup window
*/
-typedef void (* GLFWwindowrefreshfun)(GLFWwindow*);
+typedef void (* GLFWwindowrefreshfun)(GLFWwindow* window);
/*! @brief The function pointer type for window focus callbacks.
*
@@ -1458,7 +1627,7 @@ typedef void (* GLFWwindowrefreshfun)(GLFWwindow*);
*
* @ingroup window
*/
-typedef void (* GLFWwindowfocusfun)(GLFWwindow*,int);
+typedef void (* GLFWwindowfocusfun)(GLFWwindow* window, int focused);
/*! @brief The function pointer type for window iconify callbacks.
*
@@ -1479,7 +1648,7 @@ typedef void (* GLFWwindowfocusfun)(GLFWwindow*,int);
*
* @ingroup window
*/
-typedef void (* GLFWwindowiconifyfun)(GLFWwindow*,int);
+typedef void (* GLFWwindowiconifyfun)(GLFWwindow* window, int iconified);
/*! @brief The function pointer type for window maximize callbacks.
*
@@ -1500,7 +1669,7 @@ typedef void (* GLFWwindowiconifyfun)(GLFWwindow*,int);
*
* @ingroup window
*/
-typedef void (* GLFWwindowmaximizefun)(GLFWwindow*,int);
+typedef void (* GLFWwindowmaximizefun)(GLFWwindow* window, int maximized);
/*! @brief The function pointer type for framebuffer size callbacks.
*
@@ -1521,7 +1690,7 @@ typedef void (* GLFWwindowmaximizefun)(GLFWwindow*,int);
*
* @ingroup window
*/
-typedef void (* GLFWframebuffersizefun)(GLFWwindow*,int,int);
+typedef void (* GLFWframebuffersizefun)(GLFWwindow* window, int width, int height);
/*! @brief The function pointer type for window content scale callbacks.
*
@@ -1542,7 +1711,7 @@ typedef void (* GLFWframebuffersizefun)(GLFWwindow*,int,int);
*
* @ingroup window
*/
-typedef void (* GLFWwindowcontentscalefun)(GLFWwindow*,float,float);
+typedef void (* GLFWwindowcontentscalefun)(GLFWwindow* window, float xscale, float yscale);
/*! @brief The function pointer type for mouse button callbacks.
*
@@ -1568,7 +1737,7 @@ typedef void (* GLFWwindowcontentscalefun)(GLFWwindow*,float,float);
*
* @ingroup input
*/
-typedef void (* GLFWmousebuttonfun)(GLFWwindow*,int,int,int);
+typedef void (* GLFWmousebuttonfun)(GLFWwindow* window, int button, int action, int mods);
/*! @brief The function pointer type for cursor position callbacks.
*
@@ -1591,7 +1760,7 @@ typedef void (* GLFWmousebuttonfun)(GLFWwindow*,int,int,int);
*
* @ingroup input
*/
-typedef void (* GLFWcursorposfun)(GLFWwindow*,double,double);
+typedef void (* GLFWcursorposfun)(GLFWwindow* window, double xpos, double ypos);
/*! @brief The function pointer type for cursor enter/leave callbacks.
*
@@ -1612,7 +1781,7 @@ typedef void (* GLFWcursorposfun)(GLFWwindow*,double,double);
*
* @ingroup input
*/
-typedef void (* GLFWcursorenterfun)(GLFWwindow*,int);
+typedef void (* GLFWcursorenterfun)(GLFWwindow* window, int entered);
/*! @brief The function pointer type for scroll callbacks.
*
@@ -1633,7 +1802,7 @@ typedef void (* GLFWcursorenterfun)(GLFWwindow*,int);
*
* @ingroup input
*/
-typedef void (* GLFWscrollfun)(GLFWwindow*,double,double);
+typedef void (* GLFWscrollfun)(GLFWwindow* window, double xoffset, double yoffset);
/*! @brief The function pointer type for keyboard key callbacks.
*
@@ -1645,7 +1814,7 @@ typedef void (* GLFWscrollfun)(GLFWwindow*,double,double);
*
* @param[in] window The window that received the event.
* @param[in] key The [keyboard key](@ref keys) that was pressed or released.
- * @param[in] scancode The system-specific scancode of the key.
+ * @param[in] scancode The platform-specific scancode of the key.
* @param[in] action `GLFW_PRESS`, `GLFW_RELEASE` or `GLFW_REPEAT`. Future
* releases may add more actions.
* @param[in] mods Bit field describing which [modifier keys](@ref mods) were
@@ -1659,7 +1828,7 @@ typedef void (* GLFWscrollfun)(GLFWwindow*,double,double);
*
* @ingroup input
*/
-typedef void (* GLFWkeyfun)(GLFWwindow*,int,int,int,int);
+typedef void (* GLFWkeyfun)(GLFWwindow* window, int key, int scancode, int action, int mods);
/*! @brief The function pointer type for Unicode character callbacks.
*
@@ -1680,7 +1849,7 @@ typedef void (* GLFWkeyfun)(GLFWwindow*,int,int,int,int);
*
* @ingroup input
*/
-typedef void (* GLFWcharfun)(GLFWwindow*,unsigned int);
+typedef void (* GLFWcharfun)(GLFWwindow* window, unsigned int codepoint);
/*! @brief The function pointer type for Unicode character with modifiers
* callbacks.
@@ -1707,7 +1876,7 @@ typedef void (* GLFWcharfun)(GLFWwindow*,unsigned int);
*
* @ingroup input
*/
-typedef void (* GLFWcharmodsfun)(GLFWwindow*,unsigned int,int);
+typedef void (* GLFWcharmodsfun)(GLFWwindow* window, unsigned int codepoint, int mods);
/*! @brief The function pointer type for path drop callbacks.
*
@@ -1731,7 +1900,7 @@ typedef void (* GLFWcharmodsfun)(GLFWwindow*,unsigned int,int);
*
* @ingroup input
*/
-typedef void (* GLFWdropfun)(GLFWwindow*,int,const char*[]);
+typedef void (* GLFWdropfun)(GLFWwindow* window, int path_count, const char* paths[]);
/*! @brief The function pointer type for monitor configuration callbacks.
*
@@ -1752,7 +1921,7 @@ typedef void (* GLFWdropfun)(GLFWwindow*,int,const char*[]);
*
* @ingroup monitor
*/
-typedef void (* GLFWmonitorfun)(GLFWmonitor*,int);
+typedef void (* GLFWmonitorfun)(GLFWmonitor* monitor, int event);
/*! @brief The function pointer type for joystick configuration callbacks.
*
@@ -1773,7 +1942,60 @@ typedef void (* GLFWmonitorfun)(GLFWmonitor*,int);
*
* @ingroup input
*/
-typedef void (* GLFWjoystickfun)(int,int);
+typedef void (* GLFWjoystickfun)(int jid, int event);
+
+/*! @brief The function signature for pen tablet data callbacks.
+ *
+ * This is the function signature for pen tablet data callback functions.
+ *
+ * @param[in] x pen position relative to the screen.
+ * @param[in] y pen position relative to the screen.
+ * @param[in] z pen position relative to the tablet.
+ * @param[in] pen pressure from 0.0 to 1.0.
+ * @param[in] pen pitch in radian.
+ * @param[in] pen yaw in radian.
+ * @param[in] pen roll in radian.
+ *
+ * @sa @ref pen_tablet_data
+ * @sa @ref glfwSetPenTabletDataCallback
+ *
+ * @since Added in version 3.3.
+ *
+ * @ingroup input
+ */
+typedef void (* GLFWpentabletdatafun)(double,double,double,double,double,double,double);
+
+/*! @brief The function signature for pen tablet cursor callbacks.
+ *
+ * This is the function signature for pen tablet cursor callback functions.
+ * It is called when the tablet cursor is changed, from stylus to eraser for example.
+ *
+ * @param[in] pen cursor identifier. 1 is usually a stylus, 2 and 3 an eraser.
+ *
+ * @sa @ref pen_tablet_cursor
+ * @sa @ref glfwSetPenTabletCursorCallback
+ *
+ * @since Added in version 3.3.
+ *
+ * @ingroup input
+ */
+typedef void (* GLFWpentabletcursorfun)(unsigned int);
+
+/*! @brief The function signature for pen tablet proximity callbacks.
+ *
+ * This is the function signature for pen tablet proximity callback functions.
+ * It is called when a tablet device (pen etc) entering or is exiting tablet proximity.
+ *
+ * @param[in] pen proximity state. 1 = entering, 0 = exiting.
+ *
+ * @sa @ref pen_tablet_proximity
+ * @sa @ref glfwSetPenTabletProximityCallback
+ *
+ * @since Added in version 3.3.
+ *
+ * @ingroup input
+ */
+typedef void (* GLFWpentabletproximityfun)(int);
/*! @brief Video mode type.
*
@@ -1887,6 +2109,23 @@ typedef struct GLFWgamepadstate
float axes[6];
} GLFWgamepadstate;
+/*! @brief
+ *
+ * @sa @ref init_allocator
+ * @sa @ref glfwInitAllocator
+ *
+ * @since Added in version 3.4.
+ *
+ * @ingroup init
+ */
+typedef struct GLFWallocator
+{
+ GLFWallocatefun allocate;
+ GLFWreallocatefun reallocate;
+ GLFWdeallocatefun deallocate;
+ void* user;
+} GLFWallocator;
+
/*************************************************************************
* GLFW API functions
@@ -1905,10 +2144,15 @@ typedef struct GLFWgamepadstate
* Additional calls to this function after successful initialization but before
* termination will return `GLFW_TRUE` immediately.
*
+ * The @ref GLFW_PLATFORM init hint controls which platforms are considered during
+ * initialization. This also depends on which platforms the library was compiled to
+ * support.
+ *
* @return `GLFW_TRUE` if successful, or `GLFW_FALSE` if an
* [error](@ref error_handling) occurred.
*
- * @errors Possible errors include @ref GLFW_PLATFORM_ERROR.
+ * @errors Possible errors include @ref GLFW_PLATFORM_UNAVAILABLE and @ref
+ * GLFW_PLATFORM_ERROR.
*
* @remark @macos This function will change the current directory of the
* application to the `Contents/Resources` subdirectory of the application's
@@ -1930,6 +2174,8 @@ typedef struct GLFWgamepadstate
* @thread_safety This function must only be called from the main thread.
*
* @sa @ref intro_init
+ * @sa @ref glfwInitHint
+ * @sa @ref glfwInitAllocator
* @sa @ref glfwTerminate
*
* @since Added in version 1.0.
@@ -2004,6 +2250,81 @@ GLFWAPI void glfwTerminate(void);
*/
GLFWAPI void glfwInitHint(int hint, int value);
+/*! @brief Sets the init allocator to the desired value.
+ *
+ * To use the default allocator, call this function with a `NULL` argument.
+ *
+ * If you specify an allocator struct, every member must be a valid function
+ * pointer. If any member is `NULL`, this function emits @ref
+ * GLFW_INVALID_VALUE and the init allocator is unchanged.
+ *
+ * @param[in] allocator The allocator to use at the next initialization, or
+ * `NULL` to use the default one.
+ *
+ * @errors Possible errors include @ref GLFW_INVALID_VALUE.
+ *
+ * @pointer_lifetime The specified allocator is copied before this function
+ * returns.
+ *
+ * @thread_safety This function must only be called from the main thread.
+ *
+ * @sa @ref init_allocator
+ * @sa @ref glfwInit
+ *
+ * @since Added in version 3.4.
+ *
+ * @ingroup init
+ */
+GLFWAPI void glfwInitAllocator(const GLFWallocator* allocator);
+
+#if defined(VK_VERSION_1_0)
+
+/*! @brief Sets the desired Vulkan `vkGetInstanceProcAddr` function.
+ *
+ * This function sets the `vkGetInstanceProcAddr` function that GLFW will use for all
+ * Vulkan related entry point queries.
+ *
+ * This feature is mostly useful on macOS, if your copy of the Vulkan loader is in
+ * a location where GLFW cannot find it through dynamic loading, or if you are still
+ * using the static library version of the loader.
+ *
+ * If set to `NULL`, GLFW will try to load the Vulkan loader dynamically by its standard
+ * name and get this function from there. This is the default behavior.
+ *
+ * The standard name of the loader is `vulkan-1.dll` on Windows, `libvulkan.so.1` on
+ * Linux and other Unix-like systems and `libvulkan.1.dylib` on macOS. If your code is
+ * also loading it via these names then you probably don't need to use this function.
+ *
+ * The function address you set is never reset by GLFW, but it only takes effect during
+ * initialization. Once GLFW has been initialized, any updates will be ignored until the
+ * library is terminated and initialized again.
+ *
+ * @param[in] loader The address of the function to use, or `NULL`.
+ *
+ * @par Loader function signature
+ * @code
+ * PFN_vkVoidFunction vkGetInstanceProcAddr(VkInstance instance, const char* name)
+ * @endcode
+ * For more information about this function, see the
+ * [Vulkan Registry](https://www.khronos.org/registry/vulkan/).
+ *
+ * @errors None.
+ *
+ * @remark This function may be called before @ref glfwInit.
+ *
+ * @thread_safety This function must only be called from the main thread.
+ *
+ * @sa @ref vulkan_loader
+ * @sa @ref glfwInit
+ *
+ * @since Added in version 3.4.
+ *
+ * @ingroup init
+ */
+GLFWAPI void glfwInitVulkanLoader(PFN_vkGetInstanceProcAddr loader);
+
+#endif /*VK_VERSION_1_0*/
+
/*! @brief Retrieves the version of the GLFW library.
*
* This function retrieves the major, minor and revision numbers of the GLFW
@@ -2034,15 +2355,18 @@ GLFWAPI void glfwGetVersion(int* major, int* minor, int* rev);
/*! @brief Returns a string describing the compile-time configuration.
*
* This function returns the compile-time generated
- * [version string](@ref intro_version_string) of the GLFW library binary. It
- * describes the version, platform, compiler and any platform-specific
- * compile-time options. It should not be confused with the OpenGL or OpenGL
- * ES version string, queried with `glGetString`.
+ * [version string](@ref intro_version_string) of the GLFW library binary. It describes
+ * the version, platforms, compiler and any platform or operating system specific
+ * compile-time options. It should not be confused with the OpenGL or OpenGL ES version
+ * string, queried with `glGetString`.
*
* __Do not use the version string__ to parse the GLFW library version. The
* @ref glfwGetVersion function provides the version of the running library
* binary in numerical format.
*
+ * __Do not use the version string__ to parse what platforms are supported. The @ref
+ * glfwPlatformSupported function lets you query platform support.
+ *
* @return The ASCII encoded GLFW version string.
*
* @errors None.
@@ -2139,6 +2463,51 @@ GLFWAPI int glfwGetError(const char** description);
*/
GLFWAPI GLFWerrorfun glfwSetErrorCallback(GLFWerrorfun callback);
+/*! @brief Returns the currently selected platform.
+ *
+ * This function returns the platform that was selected during initialization. The
+ * returned value will be one of `GLFW_PLATFORM_WIN32`, `GLFW_PLATFORM_COCOA`,
+ * `GLFW_PLATFORM_WAYLAND`, `GLFW_PLATFORM_X11` or `GLFW_PLATFORM_NULL`.
+ *
+ * @return The currently selected platform, or zero if an error occurred.
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
+ *
+ * @thread_safety This function may be called from any thread.
+ *
+ * @sa @ref platform
+ * @sa @ref glfwPlatformSupported
+ *
+ * @since Added in version 3.4.
+ *
+ * @ingroup init
+ */
+GLFWAPI int glfwGetPlatform(void);
+
+/*! @brief Returns whether the library includes support for the specified platform.
+ *
+ * This function returns whether the library was compiled with support for the specified
+ * platform. The platform must be one of `GLFW_PLATFORM_WIN32`, `GLFW_PLATFORM_COCOA`,
+ * `GLFW_PLATFORM_WAYLAND`, `GLFW_PLATFORM_X11` or `GLFW_PLATFORM_NULL`.
+ *
+ * @param[in] platform The platform to query.
+ * @return `GLFW_TRUE` if the platform is supported, or `GLFW_FALSE` otherwise.
+ *
+ * @errors Possible errors include @ref GLFW_INVALID_ENUM.
+ *
+ * @remark This function may be called before @ref glfwInit.
+ *
+ * @thread_safety This function may be called from any thread.
+ *
+ * @sa @ref platform
+ * @sa @ref glfwGetPlatform
+ *
+ * @since Added in version 3.4.
+ *
+ * @ingroup init
+ */
+GLFWAPI int glfwPlatformSupported(int platform);
+
/*! @brief Returns the currently connected monitors.
*
* This function returns an array of handles for all currently connected
@@ -2222,7 +2591,7 @@ GLFWAPI void glfwGetMonitorPos(GLFWmonitor* monitor, int* xpos, int* ypos);
* This function returns the position, in screen coordinates, of the upper-left
* corner of the work area of the specified monitor along with the work area
* size in screen coordinates. The work area is defined as the area of the
- * monitor not occluded by the operating system task bar where present. If no
+ * monitor not occluded by the window system task bar where present. If no
* task bar exists then the work area is the monitor resolution in screen
* coordinates.
*
@@ -2253,7 +2622,7 @@ GLFWAPI void glfwGetMonitorWorkarea(GLFWmonitor* monitor, int* xpos, int* ypos,
* This function returns the size, in millimetres, of the display area of the
* specified monitor.
*
- * Some systems do not provide accurate monitor size information, either
+ * Some platforms do not provide accurate monitor size information, either
* because the monitor
* [EDID](https://en.wikipedia.org/wiki/Extended_display_identification_data)
* data is incorrect or because the driver does not report it accurately.
@@ -2269,8 +2638,8 @@ GLFWAPI void glfwGetMonitorWorkarea(GLFWmonitor* monitor, int* xpos, int* ypos,
*
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
*
- * @remark @win32 calculates the returned physical size from the
- * current resolution and system DPI instead of querying the monitor EDID data.
+ * @remark @win32 On Windows 8 and earlier the physical size is calculated from
+ * the current resolution and system DPI instead of querying the monitor EDID data.
*
* @thread_safety This function must only be called from the main thread.
*
@@ -2942,7 +3311,8 @@ GLFWAPI void glfwSetWindowTitle(GLFWwindow* window, const char* title);
* count is zero.
*
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
- * GLFW_PLATFORM_ERROR and @ref GLFW_FEATURE_UNAVAILABLE (see remarks).
+ * GLFW_INVALID_VALUE, @ref GLFW_PLATFORM_ERROR and @ref
+ * GLFW_FEATURE_UNAVAILABLE (see remarks).
*
* @pointer_lifetime The specified image data is copied before this function
* returns.
@@ -3267,7 +3637,7 @@ GLFWAPI void glfwGetWindowFrameSize(GLFWwindow* window, int* left, int* top, int
* regardless of their DPI and scaling settings. This relies on the system DPI
* and scaling settings being somewhat correct.
*
- * On systems where each monitors can have its own content scale, the window
+ * On platforms where each monitors can have its own content scale, the window
* content scale will depend on which monitor the system considers the window
* to be on.
*
@@ -3448,6 +3818,11 @@ GLFWAPI void glfwMaximizeWindow(GLFWwindow* window);
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
* GLFW_PLATFORM_ERROR.
*
+ * @remark @wayland Because Wayland wants every frame of the desktop to be
+ * complete, this function does not immediately make the window visible.
+ * Instead it will become visible the next time the window framebuffer is
+ * updated after this call.
+ *
* @thread_safety This function must only be called from the main thread.
*
* @sa @ref window_hide
@@ -4571,8 +4946,8 @@ GLFWAPI void glfwSetCursorPos(GLFWwindow* window, double xpos, double ypos);
* @return The handle of the created cursor, or `NULL` if an
* [error](@ref error_handling) occurred.
*
- * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
- * GLFW_PLATFORM_ERROR.
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
+ * GLFW_INVALID_VALUE and @ref GLFW_PLATFORM_ERROR.
*
* @pointer_lifetime The specified image data is copied before this function
* returns.
@@ -5387,6 +5762,8 @@ GLFWAPI int glfwUpdateGamepadMappings(const char* string);
* joystick is not present, does not have a mapping or an
* [error](@ref error_handling) occurred.
*
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref GLFW_INVALID_ENUM.
+ *
* @pointer_lifetime The returned string is allocated and freed by GLFW. You
* should not free it yourself. It is valid until the specified joystick is
* disconnected, the gamepad mappings are updated or the library is terminated.
@@ -5440,6 +5817,72 @@ GLFWAPI const char* glfwGetGamepadName(int jid);
*/
GLFWAPI int glfwGetGamepadState(int jid, GLFWgamepadstate* state);
+/*! @brief Sets the pen tablet data callback.
+ *
+ * This function sets the pen tablet data callback, or removes the
+ * currently set callback. This is called when the pen tablet data is updated.
+ *
+ * @param[in] cbfun The new callback, or `NULL` to remove the currently set
+ * callback.
+ * @return The previously set callback, or `NULL` if no callback was set or the
+ * library had not been [initialized](@ref intro_init).
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
+ *
+ * @thread_safety This function must only be called from the main thread.
+ *
+ * @sa @ref pen_tablet_event
+ *
+ * @since Added in version 3.3.
+ *
+ * @ingroup input
+ */
+GLFWAPI GLFWpentabletdatafun glfwSetPenTabletDataCallback(GLFWpentabletdatafun cbfun);
+
+/*! @brief Sets the pen tablet cursor callback.
+ *
+ * This function sets the pen tablet cursor callback, or removes the
+ * currently set callback. This is called when the pen tablet cursor has changed.
+ *
+ * @param[in] cbfun The new callback, or `NULL` to remove the currently set
+ * callback.
+ * @return The previously set callback, or `NULL` if no callback was set or the
+ * library had not been [initialized](@ref intro_init).
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
+ *
+ * @thread_safety This function must only be called from the main thread.
+ *
+ * @sa @ref pen_tablet_event
+ *
+ * @since Added in version 3.3.
+ *
+ * @ingroup input
+ */
+GLFWAPI GLFWpentabletcursorfun glfwSetPenTabletCursorCallback(GLFWpentabletcursorfun cbfun);
+
+/*! @brief Sets the pen tablet proximity callback.
+ *
+ * This function sets the pen tablet proximity callback, or removes the
+ * currently set callback. This is called when the pen tablet proximity has changed.
+ *
+ * @param[in] cbfun The new callback, or `NULL` to remove the currently set
+ * callback.
+ * @return The previously set callback, or `NULL` if no callback was set or the
+ * library had not been [initialized](@ref intro_init).
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
+ *
+ * @thread_safety This function must only be called from the main thread.
+ *
+ * @sa @ref pen_tablet_event
+ *
+ * @since Added in version 3.3.
+ *
+ * @ingroup input
+ */
+GLFWAPI GLFWpentabletproximityfun glfwSetPenTabletProximityCallback(GLFWpentabletproximityfun cbfun);
+
/*! @brief Sets the clipboard to the specified string.
*
* This function sets the system clipboard to the specified, UTF-8 encoded
@@ -5476,8 +5919,8 @@ GLFWAPI void glfwSetClipboardString(GLFWwindow* window, const char* string);
* @return The contents of the clipboard as a UTF-8 encoded string, or `NULL`
* if an [error](@ref error_handling) occurred.
*
- * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
- * GLFW_PLATFORM_ERROR.
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
+ * GLFW_FORMAT_UNAVAILABLE and @ref GLFW_PLATFORM_ERROR.
*
* @pointer_lifetime The returned string is allocated and freed by GLFW. You
* should not free it yourself. It is valid until the next call to @ref
@@ -5506,7 +5949,7 @@ GLFWAPI const char* glfwGetClipboardString(GLFWwindow* window);
*
* The resolution of the timer is system dependent, but is usually on the order
* of a few micro- or nanoseconds. It uses the highest-resolution monotonic
- * time source on each supported platform.
+ * time source on each operating system.
*
* @return The current time, in seconds, or zero if an
* [error](@ref error_handling) occurred.
@@ -5717,7 +6160,7 @@ GLFWAPI void glfwSwapBuffers(GLFWwindow* window);
* GLFW_NO_CURRENT_CONTEXT and @ref GLFW_PLATFORM_ERROR.
*
* @remark This function is not called during context creation, leaving the
- * swap interval set to whatever is the default on that platform. This is done
+ * swap interval set to whatever is the default for that API. This is done
* because some swap interval extensions used by GLFW do not allow the swap
* interval to be reset to zero once it has been set to a non-zero value.
*
@@ -5821,13 +6264,11 @@ GLFWAPI GLFWglproc glfwGetProcAddress(const char* procname);
* This function returns whether the Vulkan loader and any minimally functional
* ICD have been found.
*
- * The availability of a Vulkan loader and even an ICD does not by itself
- * guarantee that surface creation or even instance creation is possible.
- * For example, on Fermi systems Nvidia will install an ICD that provides no
- * actual Vulkan support. Call @ref glfwGetRequiredInstanceExtensions to check
- * whether the extensions necessary for Vulkan surface creation are available
- * and @ref glfwGetPhysicalDevicePresentationSupport to check whether a queue
- * family of a physical device supports image presentation.
+ * The availability of a Vulkan loader and even an ICD does not by itself guarantee that
+ * surface creation or even instance creation is possible. Call @ref
+ * glfwGetRequiredInstanceExtensions to check whether the extensions necessary for Vulkan
+ * surface creation are available and @ref glfwGetPhysicalDevicePresentationSupport to
+ * check whether a queue family of a physical device supports image presentation.
*
* @return `GLFW_TRUE` if Vulkan is minimally available, or `GLFW_FALSE`
* otherwise.
@@ -5873,9 +6314,6 @@ GLFWAPI int glfwVulkanSupported(void);
* returned array, as it is an error to specify an extension more than once in
* the `VkInstanceCreateInfo` struct.
*
- * @remark @macos GLFW currently supports both the `VK_MVK_macos_surface` and
- * the newer `VK_EXT_metal_surface` extensions.
- *
* @pointer_lifetime The returned array is allocated and freed by GLFW. You
* should not free it yourself. It is guaranteed to be valid only until the
* library is terminated.
@@ -6014,17 +6452,20 @@ GLFWAPI int glfwGetPhysicalDevicePresentationSupport(VkInstance instance, VkPhys
* @ref glfwVulkanSupported and @ref glfwGetRequiredInstanceExtensions should
* eliminate almost all occurrences of these errors.
*
- * @remark @macos This function currently only supports the
- * `VK_MVK_macos_surface` extension from MoltenVK.
+ * @remark @macos GLFW prefers the `VK_EXT_metal_surface` extension, with the
+ * `VK_MVK_macos_surface` extension as a fallback. The name of the selected
+ * extension, if any, is included in the array returned by @ref
+ * glfwGetRequiredInstanceExtensions.
*
* @remark @macos This function creates and sets a `CAMetalLayer` instance for
* the window content view, which is required for MoltenVK to function.
*
- * @remark @x11 GLFW by default attempts to use the `VK_KHR_xcb_surface`
- * extension, if available. You can make it prefer the `VK_KHR_xlib_surface`
- * extension by setting the
+ * @remark @x11 By default GLFW prefers the `VK_KHR_xcb_surface` extension,
+ * with the `VK_KHR_xlib_surface` extension as a fallback. You can make
+ * `VK_KHR_xlib_surface` the preferred extension by setting the
* [GLFW_X11_XCB_VULKAN_SURFACE](@ref GLFW_X11_XCB_VULKAN_SURFACE_hint) init
- * hint.
+ * hint. The name of the selected extension, if any, is included in the array
+ * returned by @ref glfwGetRequiredInstanceExtensions.
*
* @thread_safety This function may be called from any thread. For
* synchronization details of Vulkan objects, see the Vulkan specification.
diff --git a/include/glfw3native.h b/include/GLFW/glfw3native.h
index f67f540..11fee09 100644
--- a/include/glfw3native.h
+++ b/include/GLFW/glfw3native.h
@@ -82,19 +82,15 @@ extern "C" {
*************************************************************************/
#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
+ /* 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
-// @raysan5: Actually, only HWND handler needs to be defined
-// Including windows.h could suppose symbols re-definition issues (i.e Rectangle type)
-//#include <windows.h>
- typedef void *PVOID;
- typedef PVOID HANDLE;
- typedef HANDLE HWND;
+ #include <windows.h>
#elif defined(GLFW_EXPOSE_NATIVE_COCOA) || defined(GLFW_EXPOSE_NATIVE_NSGL)
#if defined(__OBJC__)
#import <Cocoa/Cocoa.h>
@@ -116,12 +112,22 @@ extern "C" {
/* 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
+ */
+ #undef GLAPIENTRY
#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
+ */
+ #undef GLAPIENTRY
#include <GL/osmesa.h>
#endif
@@ -137,6 +143,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.
*
@@ -152,6 +160,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.
*
@@ -166,6 +176,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.
*
@@ -182,6 +202,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.
*
@@ -198,6 +229,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.
*
@@ -212,6 +245,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.
*
@@ -228,6 +263,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.
*
@@ -244,6 +282,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.
*
@@ -258,6 +298,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.
*
@@ -272,6 +314,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.
*
@@ -286,6 +330,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.
*
@@ -352,6 +398,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.
*
@@ -366,6 +415,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.
*
@@ -382,6 +434,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.
*
@@ -396,6 +450,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.
*
@@ -410,6 +466,8 @@ 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.
*
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
+ *
* @thread_safety This function may be called from any thread. Access is not
* synchronized.
*
@@ -426,6 +484,8 @@ GLFWAPI struct wl_surface* glfwGetWaylandWindow(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.
+ *
* @thread_safety This function may be called from any thread. Access is not
* synchronized.
*
@@ -440,6 +500,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.
*
@@ -454,6 +517,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.
*
@@ -477,6 +543,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.
*
@@ -498,6 +567,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.
*
@@ -512,6 +584,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.
*
diff --git a/include/main.h b/include/main.h
index fc711b8..dddea73 100644
--- a/include/main.h
+++ b/include/main.h
@@ -15,8 +15,8 @@
#include "glad.h"
#ifdef PLATFORM_DESKTOP
- #include "glfw3.h"
- #include "glfw3native.h"
+ #include "GLFW/glfw3.h"
+ #include "GLFW/glfw3native.h"
#elif PLATFORM_DESKTOP_SDL
#include <SDL.h>
#endif
diff --git a/include/platforms/core_desktop.h b/include/platforms/core_desktop.h
index 2dc64e0..8782819 100644
--- a/include/platforms/core_desktop.h
+++ b/include/platforms/core_desktop.h
@@ -1,7 +1,7 @@
#pragma once
-#include "glfw3.h"
-#include "glfw3native.h"
+#include "GLFW/glfw3.h"
+#include "GLFW/glfw3native.h"
enum EventType {
GLFW_WINDOW_SIZE_EVENT,
@@ -15,5 +15,9 @@ enum EventType {
GLFW_MOUSE_CURSOR_POS_EVENT,
GLFW_MOUSE_SCROLL_EVENT,
GLFW_CURSOR_ENTER_EVENT,
- GLFW_JOYSTICK_EVENT
+ GLFW_JOYSTICK_EVENT,
+ /* NOTE! Experimental. Needs glfw PR https://github.com/glfw/glfw/pull/1445 */
+ GLFW_PEN_TABLET_DATA_EVENT,
+ GLFW_PEN_TABLET_CURSOR_EVENT,
+ GLFW_PEN_TABLET_PROXIMITY_EVENT
};
diff --git a/include/state.h b/include/state.h
index 40963f5..0ebd828 100644
--- a/include/state.h
+++ b/include/state.h
@@ -31,6 +31,10 @@ typedef struct {
GLFWscrollfun raylibMouseScrollCallback;
GLFWcursorenterfun raylibCursorEnterCallback;
GLFWjoystickfun raylibJoystickCallback;
+ /* NOTE! Experimental. Needs glfw PR https://github.com/glfw/glfw/pull/1445 */
+ GLFWpentabletdatafun glfwtabletDataCallback;
+ GLFWpentabletcursorfun glfwtabletCursorCallback;
+ GLFWpentabletproximityfun glfwtabletProximityCallback;
#elif PLATFORM_DESKTOP_SDL
int SDL_eventQueueLen;
SDL_Event *SDL_eventQueue;
diff --git a/src/platforms/core_desktop.c b/src/platforms/core_desktop.c
index 1f22f32..4ea871a 100644
--- a/src/platforms/core_desktop.c
+++ b/src/platforms/core_desktop.c
@@ -30,6 +30,10 @@ static void platformDefineGlobals() {
assignGlobalInt( GLFW_MOUSE_SCROLL_EVENT, "GLFW_MOUSE_SCROLL_EVENT" ); // GLFW event mouse scroll
assignGlobalInt( GLFW_CURSOR_ENTER_EVENT, "GLFW_CURSOR_ENTER_EVENT" ); // GLFW event cursor enter/leave
assignGlobalInt( GLFW_JOYSTICK_EVENT, "GLFW_JOYSTICK_EVENT" ); // GLFW event joystick
+ /* Pen Tablet Events. NOTE! Experimental. Needs glfw PR https://github.com/glfw/glfw/pull/1445. */
+ // assignGlobalInt( GLFW_PEN_TABLET_DATA_EVENT, "GLFW_PEN_TABLET_DATA_EVENT" ); // GLFW event pen tablet data
+ // assignGlobalInt( GLFW_PEN_TABLET_CURSOR_EVENT, "GLFW_PEN_TABLET_CURSOR_EVENT" ); // GLFW event pen tablet cursor
+ // assignGlobalInt( GLFW_PEN_TABLET_PROXIMITY_EVENT, "GLFW_PEN_TABLET_PROXIMITY_EVENT" ); // GLFW event pen tablet proximity
lua_pop( L, -1 );
}
@@ -463,6 +467,93 @@ static void joystickInputEvent( int jid, int event ) {
lua_pop( L, -1 );
}
+// /* NOTE! Experimental. Needs glfw PR https://github.com/glfw/glfw/pull/1445 */
+// static void penTabletDataEvent( double x, double y, double z, double pressure, double pitch, double yaw, double roll ) {
+// lua_State *L = state->luaState;
+
+// lua_pushcfunction( L, luaTraceback );
+// int tracebackidx = lua_gettop( L );
+
+// lua_getglobal( L, "RL" );
+// lua_getfield( L, -1, "event" );
+
+// if ( lua_isfunction( L, -1 ) ) {
+// lua_createtable( L, 8, 0 );
+// lua_pushinteger( L, GLFW_PEN_TABLET_DATA_EVENT );
+// lua_setfield( L, -2, "type" );
+// lua_pushnumber( L, x );
+// lua_setfield( L, -2, "x" );
+// lua_pushnumber( L, y );
+// lua_setfield( L, -2, "y" );
+// lua_pushnumber( L, z );
+// lua_setfield( L, -2, "z" );
+// lua_pushnumber( L, pressure );
+// lua_setfield( L, -2, "pressure" );
+// lua_pushnumber( L, pitch );
+// lua_setfield( L, -2, "pitch" );
+// lua_pushnumber( L, yaw );
+// lua_setfield( L, -2, "yaw" );
+// lua_pushnumber( L, roll );
+// lua_setfield( L, -2, "roll" );
+
+// if ( lua_pcall( L, 1, 0, tracebackidx ) != 0 ) {
+// TraceLog( LOG_ERROR, "Lua error: %s", lua_tostring( L, -1 ) );
+// state->run = false;
+// }
+// }
+// lua_pop( L, -1 );
+// }
+
+// /* NOTE! Experimental. Needs glfw PR https://github.com/glfw/glfw/pull/1445 */
+// static void penTabletCursorEvent( unsigned int identifier ) {
+// lua_State *L = state->luaState;
+
+// lua_pushcfunction( L, luaTraceback );
+// int tracebackidx = lua_gettop( L );
+
+// lua_getglobal( L, "RL" );
+// lua_getfield( L, -1, "event" );
+
+// if ( lua_isfunction( L, -1 ) ) {
+// lua_createtable( L, 2, 0 );
+// lua_pushinteger( L, GLFW_PEN_TABLET_CURSOR_EVENT );
+// lua_setfield( L, -2, "type" );
+// lua_pushinteger( L, identifier );
+// lua_setfield( L, -2, "identifier" );
+
+// if ( lua_pcall( L, 1, 0, tracebackidx ) != 0 ) {
+// TraceLog( LOG_ERROR, "Lua error: %s", lua_tostring( L, -1 ) );
+// state->run = false;
+// }
+// }
+// lua_pop( L, -1 );
+// }
+
+// /* NOTE! Experimental. Needs glfw PR https://github.com/glfw/glfw/pull/1445 */
+// static void penTabletProximityEvent( int proxState ) {
+// lua_State *L = state->luaState;
+
+// lua_pushcfunction( L, luaTraceback );
+// int tracebackidx = lua_gettop( L );
+
+// lua_getglobal( L, "RL" );
+// lua_getfield( L, -1, "event" );
+
+// if ( lua_isfunction( L, -1 ) ) {
+// lua_createtable( L, 2, 0 );
+// lua_pushinteger( L, GLFW_PEN_TABLET_PROXIMITY_EVENT );
+// lua_setfield( L, -2, "type" );
+// lua_pushinteger( L, proxState );
+// lua_setfield( L, -2, "state" );
+
+// if ( lua_pcall( L, 1, 0, tracebackidx ) != 0 ) {
+// TraceLog( LOG_ERROR, "Lua error: %s", lua_tostring( L, -1 ) );
+// state->run = false;
+// }
+// }
+// lua_pop( L, -1 );
+// }
+
static void platformRegisterEvents() {
/* Window events. */
state->raylibWindowSizeCallback = glfwSetWindowSizeCallback( GetWindowHandle(), windowSizeEvent );
@@ -481,4 +572,8 @@ static void platformRegisterEvents() {
state->raylibMouseScrollCallback = glfwSetScrollCallback( GetWindowHandle(), mouseScrollInputEvent );
state->raylibCursorEnterCallback = glfwSetCursorEnterCallback( GetWindowHandle(), cursorEnterInputEvent );
state->raylibJoystickCallback = glfwSetJoystickCallback( joystickInputEvent );
+ /* NOTE! Experimental. Needs glfw PR https://github.com/glfw/glfw/pull/1445 */
+ // state->glfwtabletDataCallback = glfwSetPenTabletDataCallback( penTabletDataEvent );
+ // state->glfwtabletCursorCallback = glfwSetPenTabletCursorCallback( penTabletCursorEvent );
+ // state->glfwtabletProximityCallback = glfwSetPenTabletProximityCallback( penTabletProximityEvent );
}