From dffe203c178ecea44a0c3d52a7b62c45a6615944 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 13 Jul 2021 18:12:43 +0200 Subject: [PATCH 001/208] Wayland: Make libwayland-client dynamically loaded The insight to use wayland.xml to resolve the difficult-to-redirect interface symbols was gleaned from SDL. Instead of compiling the code output of wayland-scanner separately it is made part of the wl_init compilation unit. This lets us do things like transparently rename our copies of Wayland globals. The OS version of wayland-client-protocol.h is no longer used by GLFW, but it is presumably ABI compatible with the output of wayland-scanner. Closes #1174. Closes #1338. Related to #1655. Closes #1943. --- CMakeLists.txt | 1 - README.md | 1 + src/CMakeLists.txt | 10 +++-- src/wl_init.c | 80 ++++++++++++++++++++++++++++++++++- src/wl_monitor.c | 2 + src/wl_platform.h | 102 +++++++++++++++++++++++++++++++++++++++++---- src/wl_window.c | 8 ++++ 7 files changed, 192 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 77cdc945..825fc453 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -205,7 +205,6 @@ if (_GLFW_WAYLAND) list(APPEND glfw_PKG_DEPS "wayland-client") list(APPEND glfw_INCLUDE_DIRS "${Wayland_INCLUDE_DIRS}") - list(APPEND glfw_LIBRARIES "${Wayland_LINK_LIBRARIES}") include(CheckIncludeFiles) include(CheckFunctionExists) diff --git a/README.md b/README.md index 0c1600b0..3e529076 100644 --- a/README.md +++ b/README.md @@ -226,6 +226,7 @@ information on what to include when reporting a bug. reported (#1112,#1415,#1472,#1616) - [X11] Bugfix: Some window attributes were not applied on leaving fullscreen (#1863) + - [Wayland] Added dynamic loading of all Wayland libraries - [Wayland] Removed support for `wl_shell` (#1443) - [Wayland] Bugfix: The `GLFW_HAND_CURSOR` shape used the wrong image (#1432) - [Wayland] Bugfix: `CLOCK_MONOTONIC` was not correctly enabled diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3bae781b..d15838e0 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -57,6 +57,7 @@ if (_GLFW_WAYLAND) find_program(WAYLAND_SCANNER_EXECUTABLE NAMES wayland-scanner) pkg_check_modules(WAYLAND_PROTOCOLS REQUIRED wayland-protocols>=1.15) pkg_get_variable(WAYLAND_PROTOCOLS_BASE wayland-protocols pkgdatadir) + pkg_get_variable(WAYLAND_CLIENT_PKGDATADIR wayland-client pkgdatadir) macro(wayland_generate protocol_file output_file) add_custom_command(OUTPUT "${output_file}.h" @@ -64,14 +65,17 @@ if (_GLFW_WAYLAND) DEPENDS "${protocol_file}" VERBATIM) - add_custom_command(OUTPUT "${output_file}.c" - COMMAND "${WAYLAND_SCANNER_EXECUTABLE}" private-code "${protocol_file}" "${output_file}.c" + add_custom_command(OUTPUT "${output_file}-code.h" + COMMAND "${WAYLAND_SCANNER_EXECUTABLE}" private-code "${protocol_file}" "${output_file}-code.h" DEPENDS "${protocol_file}" VERBATIM) - target_sources(glfw PRIVATE "${output_file}.h" "${output_file}.c") + target_sources(glfw PRIVATE "${output_file}.h" "${output_file}-code.h") endmacro() + wayland_generate( + "${WAYLAND_CLIENT_PKGDATADIR}/wayland.xml" + "${GLFW_BINARY_DIR}/src/wayland-client-protocol") wayland_generate( "${WAYLAND_PROTOCOLS_BASE}/stable/xdg-shell/xdg-shell.xml" "${GLFW_BINARY_DIR}/src/wayland-xdg-shell-client-protocol") diff --git a/src/wl_init.c b/src/wl_init.c index 5e20daa6..33eeef8b 100644 --- a/src/wl_init.c +++ b/src/wl_init.c @@ -39,7 +39,22 @@ #include #include #include -#include + +#include "wayland-client-protocol.h" +#include "wayland-xdg-shell-client-protocol.h" +#include "wayland-xdg-decoration-client-protocol.h" +#include "wayland-viewporter-client-protocol.h" +#include "wayland-relative-pointer-unstable-v1-client-protocol.h" +#include "wayland-pointer-constraints-unstable-v1-client-protocol.h" +#include "wayland-idle-inhibit-unstable-v1-client-protocol.h" + +#include "wayland-client-protocol-code.h" +#include "wayland-xdg-shell-client-protocol-code.h" +#include "wayland-xdg-decoration-client-protocol-code.h" +#include "wayland-viewporter-client-protocol-code.h" +#include "wayland-relative-pointer-unstable-v1-client-protocol-code.h" +#include "wayland-pointer-constraints-unstable-v1-client-protocol-code.h" +#include "wayland-idle-inhibit-unstable-v1-client-protocol-code.h" static inline int min(int n1, int n2) @@ -1037,6 +1052,69 @@ int _glfwPlatformInit(void) long cursorSizeLong; int cursorSize; + _glfw.wl.client.handle = _glfw_dlopen("libwayland-client.so.0"); + if (!_glfw.wl.client.handle) + { + _glfwInputError(GLFW_PLATFORM_ERROR, + "Wayland: Failed to open libwayland-client"); + return GLFW_FALSE; + } + + _glfw.wl.client.display_flush = (PFN_wl_display_flush) + _glfw_dlsym(_glfw.wl.client.handle, "wl_display_flush"); + _glfw.wl.client.display_cancel_read = (PFN_wl_display_cancel_read) + _glfw_dlsym(_glfw.wl.client.handle, "wl_display_cancel_read"); + _glfw.wl.client.display_dispatch_pending = (PFN_wl_display_dispatch_pending) + _glfw_dlsym(_glfw.wl.client.handle, "wl_display_dispatch_pending"); + _glfw.wl.client.display_read_events = (PFN_wl_display_read_events) + _glfw_dlsym(_glfw.wl.client.handle, "wl_display_read_events"); + _glfw.wl.client.display_connect = (PFN_wl_display_connect) + _glfw_dlsym(_glfw.wl.client.handle, "wl_display_connect"); + _glfw.wl.client.display_disconnect = (PFN_wl_display_disconnect) + _glfw_dlsym(_glfw.wl.client.handle, "wl_display_disconnect"); + _glfw.wl.client.display_roundtrip = (PFN_wl_display_roundtrip) + _glfw_dlsym(_glfw.wl.client.handle, "wl_display_roundtrip"); + _glfw.wl.client.display_get_fd = (PFN_wl_display_get_fd) + _glfw_dlsym(_glfw.wl.client.handle, "wl_display_get_fd"); + _glfw.wl.client.display_prepare_read = (PFN_wl_display_prepare_read) + _glfw_dlsym(_glfw.wl.client.handle, "wl_display_prepare_read"); + _glfw.wl.client.proxy_marshal = (PFN_wl_proxy_marshal) + _glfw_dlsym(_glfw.wl.client.handle, "wl_proxy_marshal"); + _glfw.wl.client.proxy_add_listener = (PFN_wl_proxy_add_listener) + _glfw_dlsym(_glfw.wl.client.handle, "wl_proxy_add_listener"); + _glfw.wl.client.proxy_destroy = (PFN_wl_proxy_destroy) + _glfw_dlsym(_glfw.wl.client.handle, "wl_proxy_destroy"); + _glfw.wl.client.proxy_marshal_constructor = (PFN_wl_proxy_marshal_constructor) + _glfw_dlsym(_glfw.wl.client.handle, "wl_proxy_marshal_constructor"); + _glfw.wl.client.proxy_marshal_constructor_versioned = (PFN_wl_proxy_marshal_constructor_versioned) + _glfw_dlsym(_glfw.wl.client.handle, "wl_proxy_marshal_constructor_versioned"); + _glfw.wl.client.proxy_get_user_data = (PFN_wl_proxy_get_user_data) + _glfw_dlsym(_glfw.wl.client.handle, "wl_proxy_get_user_data"); + _glfw.wl.client.proxy_set_user_data = (PFN_wl_proxy_set_user_data) + _glfw_dlsym(_glfw.wl.client.handle, "wl_proxy_set_user_data"); + + if (!_glfw.wl.client.display_flush || + !_glfw.wl.client.display_cancel_read || + !_glfw.wl.client.display_dispatch_pending || + !_glfw.wl.client.display_read_events || + !_glfw.wl.client.display_connect || + !_glfw.wl.client.display_disconnect || + !_glfw.wl.client.display_roundtrip || + !_glfw.wl.client.display_get_fd || + !_glfw.wl.client.display_prepare_read || + !_glfw.wl.client.proxy_marshal || + !_glfw.wl.client.proxy_add_listener || + !_glfw.wl.client.proxy_destroy || + !_glfw.wl.client.proxy_marshal_constructor || + !_glfw.wl.client.proxy_marshal_constructor_versioned || + !_glfw.wl.client.proxy_get_user_data || + !_glfw.wl.client.proxy_set_user_data) + { + _glfwInputError(GLFW_PLATFORM_ERROR, + "Wayland: Failed to load libwayland-client entry point"); + return GLFW_FALSE; + } + _glfw.wl.cursor.handle = _glfw_dlopen("libwayland-cursor.so.0"); if (!_glfw.wl.cursor.handle) { diff --git a/src/wl_monitor.c b/src/wl_monitor.c index 62037618..74907c79 100644 --- a/src/wl_monitor.c +++ b/src/wl_monitor.c @@ -34,6 +34,8 @@ #include #include +#include "wayland-client-protocol.h" + static void outputHandleGeometry(void* data, struct wl_output* output, diff --git a/src/wl_platform.h b/src/wl_platform.h index 966155fd..acb52685 100644 --- a/src/wl_platform.h +++ b/src/wl_platform.h @@ -24,7 +24,7 @@ // //======================================================================== -#include +#include #include #ifdef HAVE_XKBCOMMON_COMPOSE_H #include @@ -54,12 +54,80 @@ typedef VkBool32 (APIENTRY *PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR #endif #include "xkb_unicode.h" -#include "wayland-xdg-shell-client-protocol.h" -#include "wayland-xdg-decoration-client-protocol.h" -#include "wayland-viewporter-client-protocol.h" -#include "wayland-relative-pointer-unstable-v1-client-protocol.h" -#include "wayland-pointer-constraints-unstable-v1-client-protocol.h" -#include "wayland-idle-inhibit-unstable-v1-client-protocol.h" +typedef int (* PFN_wl_display_flush)(struct wl_display *display); +typedef void (* PFN_wl_display_cancel_read)(struct wl_display *display); +typedef int (* PFN_wl_display_dispatch_pending)(struct wl_display *display); +typedef int (* PFN_wl_display_read_events)(struct wl_display *display); +typedef struct wl_display* (* PFN_wl_display_connect)(const char*); +typedef void (* PFN_wl_display_disconnect)(struct wl_display*); +typedef int (* PFN_wl_display_roundtrip)(struct wl_display*); +typedef int (* PFN_wl_display_get_fd)(struct wl_display*); +typedef int (* PFN_wl_display_prepare_read)(struct wl_display*); +typedef void (* PFN_wl_proxy_marshal)(struct wl_proxy*,uint32_t,...); +typedef int (* PFN_wl_proxy_add_listener)(struct wl_proxy*,void(**)(void),void*); +typedef void (* PFN_wl_proxy_destroy)(struct wl_proxy*); +typedef struct wl_proxy* (* PFN_wl_proxy_marshal_constructor)(struct wl_proxy*,uint32_t,const struct wl_interface*,...); +typedef struct wl_proxy* (* PFN_wl_proxy_marshal_constructor_versioned)(struct wl_proxy*,uint32_t,const struct wl_interface*,uint32_t,...); +typedef void* (* PFN_wl_proxy_get_user_data)(struct wl_proxy*); +typedef void (* PFN_wl_proxy_set_user_data)(struct wl_proxy*,void*); +#define wl_display_flush _glfw.wl.client.display_flush +#define wl_display_cancel_read _glfw.wl.client.display_cancel_read +#define wl_display_dispatch_pending _glfw.wl.client.display_dispatch_pending +#define wl_display_read_events _glfw.wl.client.display_read_events +#define wl_display_connect _glfw.wl.client.display_connect +#define wl_display_disconnect _glfw.wl.client.display_disconnect +#define wl_display_roundtrip _glfw.wl.client.display_roundtrip +#define wl_display_get_fd _glfw.wl.client.display_get_fd +#define wl_display_prepare_read _glfw.wl.client.display_prepare_read +#define wl_proxy_marshal _glfw.wl.client.proxy_marshal +#define wl_proxy_add_listener _glfw.wl.client.proxy_add_listener +#define wl_proxy_destroy _glfw.wl.client.proxy_destroy +#define wl_proxy_marshal_constructor _glfw.wl.client.proxy_marshal_constructor +#define wl_proxy_marshal_constructor_versioned _glfw.wl.client.proxy_marshal_constructor_versioned +#define wl_proxy_get_user_data _glfw.wl.client.proxy_get_user_data +#define wl_proxy_set_user_data _glfw.wl.client.proxy_set_user_data + +struct wl_shm; + +#define wl_display_interface _glfw_wl_display_interface +#define wl_subcompositor_interface _glfw_wl_subcompositor_interface +#define wl_compositor_interface _glfw_wl_compositor_interface +#define wl_shm_interface _glfw_wl_shm_interface +#define wl_data_device_manager_interface _glfw_wl_data_device_manager_interface +#define wl_shell_interface _glfw_wl_shell_interface +#define wl_buffer_interface _glfw_wl_buffer_interface +#define wl_callback_interface _glfw_wl_callback_interface +#define wl_data_device_interface _glfw_wl_data_device_interface +#define wl_data_offer_interface _glfw_wl_data_offer_interface +#define wl_data_source_interface _glfw_wl_data_source_interface +#define wl_keyboard_interface _glfw_wl_keyboard_interface +#define wl_output_interface _glfw_wl_output_interface +#define wl_pointer_interface _glfw_wl_pointer_interface +#define wl_region_interface _glfw_wl_region_interface +#define wl_registry_interface _glfw_wl_registry_interface +#define wl_seat_interface _glfw_wl_seat_interface +#define wl_shell_surface_interface _glfw_wl_shell_surface_interface +#define wl_shm_pool_interface _glfw_wl_shm_pool_interface +#define wl_subsurface_interface _glfw_wl_subsurface_interface +#define wl_surface_interface _glfw_wl_surface_interface +#define wl_touch_interface _glfw_wl_touch_interface +#define zwp_idle_inhibitor_v1_interface _glfw_zwp_idle_inhibitor_v1_interface +#define zwp_idle_inhibit_manager_v1_interface _glfw_zwp_idle_inhibit_manager_v1_interface +#define zwp_confined_pointer_v1_interface _glfw_zwp_confined_pointer_v1_interface +#define zwp_locked_pointer_v1_interface _glfw_zwp_locked_pointer_v1_interface +#define zwp_pointer_constraints_v1_interface _glfw_zwp_pointer_constraints_v1_interface +#define zwp_relative_pointer_v1_interface _glfw_zwp_relative_pointer_v1_interface +#define zwp_relative_pointer_manager_v1_interface _glfw_zwp_relative_pointer_manager_v1_interface +#define wp_viewport_interface _glfw_wp_viewport_interface +#define wp_viewporter_interface _glfw_wp_viewporter_interface +#define xdg_toplevel_interface _glfw_xdg_toplevel_interface +#define zxdg_toplevel_decoration_v1_interface _glfw_zxdg_toplevel_decoration_v1_interface +#define zxdg_decoration_manager_v1_interface _glfw_zxdg_decoration_manager_v1_interface +#define xdg_popup_interface _glfw_xdg_popup_interface +#define xdg_positioner_interface _glfw_xdg_positioner_interface +#define xdg_surface_interface _glfw_xdg_surface_interface +#define xdg_toplevel_interface _glfw_xdg_toplevel_interface +#define xdg_wm_base_interface _glfw_xdg_wm_base_interface #define _glfw_dlopen(name) dlopen(name, RTLD_LAZY | RTLD_LOCAL) #define _glfw_dlclose(handle) dlclose(handle) @@ -302,6 +370,26 @@ typedef struct _GLFWlibraryWayland _GLFWwindow* pointerFocus; _GLFWwindow* keyboardFocus; + struct { + void* handle; + PFN_wl_display_flush display_flush; + PFN_wl_display_cancel_read display_cancel_read; + PFN_wl_display_dispatch_pending display_dispatch_pending; + PFN_wl_display_read_events display_read_events; + PFN_wl_display_connect display_connect; + PFN_wl_display_disconnect display_disconnect; + PFN_wl_display_roundtrip display_roundtrip; + PFN_wl_display_get_fd display_get_fd; + PFN_wl_display_prepare_read display_prepare_read; + PFN_wl_proxy_marshal proxy_marshal; + PFN_wl_proxy_add_listener proxy_add_listener; + PFN_wl_proxy_destroy proxy_destroy; + PFN_wl_proxy_marshal_constructor proxy_marshal_constructor; + PFN_wl_proxy_marshal_constructor_versioned proxy_marshal_constructor_versioned; + PFN_wl_proxy_get_user_data proxy_get_user_data; + PFN_wl_proxy_set_user_data proxy_set_user_data; + } client; + struct { void* handle; diff --git a/src/wl_window.c b/src/wl_window.c index 939f9c19..f8b50df1 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -40,6 +40,14 @@ #include #include +#include "wayland-client-protocol.h" +#include "wayland-xdg-shell-client-protocol.h" +#include "wayland-xdg-decoration-client-protocol.h" +#include "wayland-viewporter-client-protocol.h" +#include "wayland-relative-pointer-unstable-v1-client-protocol.h" +#include "wayland-pointer-constraints-unstable-v1-client-protocol.h" +#include "wayland-idle-inhibit-unstable-v1-client-protocol.h" + static int createTmpfileCloexec(char* tmpname) { From d83849792b0cf3e40c402f299c867ac6e1fd0e20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 6 Jul 2021 23:12:05 +0200 Subject: [PATCH 002/208] Add override variable for CMake library type This adds the GLFW_LIBRARY_TYPE CMake cache variable, which allows users and higher-level projects to set what type of library GLFW is built as. When not empty, this value overrides the standard BUILD_SHARED_LIBS option for GLFW while still allowing it to control the type of other libraries in a larger project. This also allows building GLFW as an object library without adding dummy source files (as required by Xcode) or producing unused library binaries. Projects using CMake 3.12 or later can link the resulting GLFW object library normally using target_link_libraries. Fixes #279. Related to #1307. Closes #1497. Closes #1574. Closes #1928. --- CMakeLists.txt | 17 +++++++++++++++-- README.md | 2 ++ docs/compile.dox | 15 ++++++++++++--- src/CMakeLists.txt | 7 ++++--- 4 files changed, 33 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 825fc453..ab3248ee 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,7 +41,20 @@ cmake_dependent_option(GLFW_USE_WAYLAND "Use Wayland for window creation" OFF cmake_dependent_option(USE_MSVC_RUNTIME_LIBRARY_DLL "Use MSVC runtime library DLL" ON "MSVC" OFF) -if (BUILD_SHARED_LIBS AND UNIX) +set(GLFW_LIBRARY_TYPE "${GLFW_LIBRARY_TYPE}" CACHE STRING + "Library type override for GLFW (SHARED, STATIC, OBJECT, or empty to follow BUILD_SHARED_LIBS)") + +if (GLFW_LIBRARY_TYPE) + if (GLFW_LIBRARY_TYPE STREQUAL "SHARED") + set(GLFW_BUILD_SHARED_LIBRARY TRUE) + else() + set(GLFW_BUILD_SHARED_LIBRARY FALSE) + endif() +else() + set(GLFW_BUILD_SHARED_LIBRARY ${BUILD_SHARED_LIBS}) +endif() + +if (UNIX AND GLFW_BUILD_SHARED_LIBRARY) # On Unix-like systems, shared libraries can use the soname system. set(GLFW_LIB_NAME glfw) else() @@ -49,7 +62,7 @@ else() endif() if (GLFW_VULKAN_STATIC) - if (BUILD_SHARED_LIBS) + if (GLFW_BUILD_SHARED_LIBRARY) # If you absolutely must do this, remove this line and add the Vulkan # loader static library via the CMAKE_SHARED_LINKER_FLAGS message(FATAL_ERROR "You are trying to link the Vulkan loader static library into the GLFW shared library") diff --git a/README.md b/README.md index 3e529076..98b49733 100644 --- a/README.md +++ b/README.md @@ -129,6 +129,8 @@ information on what to include when reporting a bug. values to select ANGLE backend (#1380) - Added `GLFW_X11_XCB_VULKAN_SURFACE` init hint for selecting X11 Vulkan surface extension (#1793) + - Added `GLFW_LIBRARY_TYPE` CMake variable for overriding the library type + (#279,#1307,#1497,#1574,#1928) - Made joystick subsystem initialize at first use (#1284,#1646) - Made `GLFW_DOUBLEBUFFER` a read-only window attribute - Updated the minimum required CMake version to 3.1 diff --git a/docs/compile.dox b/docs/compile.dox index a5367110..d5b839d6 100644 --- a/docs/compile.dox +++ b/docs/compile.dox @@ -239,9 +239,18 @@ cmake -S path/to/glfw -B path/to/build -D BUILD_SHARED_LIBS=ON @subsection compile_options_shared Shared CMake options @anchor BUILD_SHARED_LIBS -__BUILD_SHARED_LIBS__ determines whether GLFW is built as a static -library or as a DLL / shared library / dynamic library. This is disabled by -default, producing a static GLFW library. +__BUILD_SHARED_LIBS__ determines whether GLFW is built as a static library or as +a DLL / shared library / dynamic library. This is disabled by default, +producing a static GLFW library. This variable has no `GLFW_` prefix because it +is defined by CMake. If you want to change the library only for GLFW when it is +part of a larger project, see @ref GLFW_LIBRARY_TYPE. + +@anchor GLFW_LIBRARY_TYPE +__GLFW_LIBRARY_TYPE__ allows you to override @ref BUILD_SHARED_LIBS only for +GLFW, without affecting other libraries in a larger project. When set, the +value of this option must be a valid CMake library type. Set it to `STATIC` to +build GLFW as a static library, `SHARED` to build it as a shared library +/ dynamic library / DLL, or `OBJECT` to make GLFW a CMake object library. @anchor GLFW_BUILD_EXAMPLES __GLFW_BUILD_EXAMPLES__ determines whether the GLFW examples are built diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d15838e0..ea16f195 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,5 +1,6 @@ -add_library(glfw "${GLFW_SOURCE_DIR}/include/GLFW/glfw3.h" +add_library(glfw ${GLFW_LIBRARY_TYPE} + "${GLFW_SOURCE_DIR}/include/GLFW/glfw3.h" "${GLFW_SOURCE_DIR}/include/GLFW/glfw3native.h" internal.h mappings.h context.c init.c input.c monitor.c vulkan.c window.c) @@ -96,7 +97,7 @@ if (_GLFW_WAYLAND) "${GLFW_BINARY_DIR}/src/wayland-idle-inhibit-unstable-v1-client-protocol") endif() -if (WIN32 AND BUILD_SHARED_LIBS) +if (WIN32 AND GLFW_BUILD_SHARED_LIBRARY) configure_file(glfw.rc.in glfw.rc @ONLY) target_sources(glfw PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/glfw.rc") endif() @@ -201,7 +202,7 @@ if (_GLFW_X11 OR _GLFW_WAYLAND OR _GLFW_OSMESA) endif() endif() -if (BUILD_SHARED_LIBS) +if (GLFW_BUILD_SHARED_LIBRARY) if (WIN32) if (MINGW) # Remove the dependency on the shared version of libgcc From 244948e174c0b698ac492d5aa8e379d5ccbc1323 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 30 Jul 2021 13:19:46 +0200 Subject: [PATCH 003/208] Export pkg-config dependencies via the CMake cache This will be useful when building GLFW as a CMake object library and linking it into a larger library that exports pkg-config information. Partly based on #1307 by @a3f. Closes #1307. --- CMake/glfw3.pc.in | 4 ++-- CMakeLists.txt | 9 +++++++-- README.md | 3 +++ 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/CMake/glfw3.pc.in b/CMake/glfw3.pc.in index f74298d4..37f4efd9 100644 --- a/CMake/glfw3.pc.in +++ b/CMake/glfw3.pc.in @@ -7,7 +7,7 @@ Name: GLFW Description: A multi-platform library for OpenGL, window and input Version: @GLFW_VERSION@ URL: https://www.glfw.org/ -Requires.private: @GLFW_PKG_DEPS@ +Requires.private: @GLFW_PKG_CONFIG_REQUIRES_PRIVATE@ Libs: -L${libdir} -l@GLFW_LIB_NAME@ -Libs.private: @GLFW_PKG_LIBS@ +Libs.private: @GLFW_PKG_CONFIG_LIBS_PRIVATE@ Cflags: -I${includedir} diff --git a/CMakeLists.txt b/CMakeLists.txt index ab3248ee..2519b071 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -258,12 +258,17 @@ endif() # Export GLFW library dependencies #-------------------------------------------------------------------- foreach(arg ${glfw_PKG_DEPS}) - set(GLFW_PKG_DEPS "${GLFW_PKG_DEPS} ${arg}") + set(deps "${deps} ${arg}") endforeach() foreach(arg ${glfw_PKG_LIBS}) - set(GLFW_PKG_LIBS "${GLFW_PKG_LIBS} ${arg}") + set(libs "${libs} ${arg}") endforeach() +set(GLFW_PKG_CONFIG_REQUIRES_PRIVATE "${deps}" CACHE INTERNAL + "GLFW pkg-config Requires.private") +set(GLFW_PKG_CONFIG_LIBS_PRIVATE "${libs}" CACHE INTERNAL + "GLFW pkg-config Libs.private") + #-------------------------------------------------------------------- # Create generated files #-------------------------------------------------------------------- diff --git a/README.md b/README.md index 98b49733..4667347c 100644 --- a/README.md +++ b/README.md @@ -131,6 +131,8 @@ information on what to include when reporting a bug. surface extension (#1793) - Added `GLFW_LIBRARY_TYPE` CMake variable for overriding the library type (#279,#1307,#1497,#1574,#1928) + - Added `GLFW_PKG_CONFIG_REQUIRES_PRIVATE` and `GLFW_PKG_CONFIG_LIBS_PRIVATE` CMake + variables exposing pkg-config dependencies (#1307) - Made joystick subsystem initialize at first use (#1284,#1646) - Made `GLFW_DOUBLEBUFFER` a read-only window attribute - Updated the minimum required CMake version to 3.1 @@ -322,6 +324,7 @@ skills. - Fredrik Ehnbom - Robin Eklind - Siavash Eliasi + - Ahmad Fatoum - Felipe Ferreira - Michael Fogleman - Gerald Franz From 71829a0f0de23345fecc7576a0541f6fbec78b25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Sun, 15 Aug 2021 23:34:13 +0200 Subject: [PATCH 004/208] Wayland: Remove unused pkg-config dependency Related to #1934. --- CMakeLists.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2519b071..6176e16a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -215,8 +215,6 @@ if (_GLFW_WAYLAND) wayland-egl>=0.2.7 xkbcommon) - list(APPEND glfw_PKG_DEPS "wayland-client") - list(APPEND glfw_INCLUDE_DIRS "${Wayland_INCLUDE_DIRS}") include(CheckIncludeFiles) From 071d7c0f46841c884b1ac0c493e34143a01f0c04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Sun, 15 Aug 2021 14:55:13 +0200 Subject: [PATCH 005/208] X11: Fix function returning before cleanup The _glfwPlatformSetWindowFloating function would return without freeing the state array if the window was already in the requested state. --- README.md | 1 + src/x11_window.c | 32 ++++++++++++++++---------------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 4667347c..44f7e3a8 100644 --- a/README.md +++ b/README.md @@ -230,6 +230,7 @@ information on what to include when reporting a bug. reported (#1112,#1415,#1472,#1616) - [X11] Bugfix: Some window attributes were not applied on leaving fullscreen (#1863) + - [X11] Bugfix: Changing `GLFW_FLOATING` could leak memory - [Wayland] Added dynamic loading of all Wayland libraries - [Wayland] Removed support for `wl_shell` (#1443) - [Wayland] Bugfix: The `GLFW_HAND_CURSOR` shape used the wrong image (#1432) diff --git a/src/x11_window.c b/src/x11_window.c index d7b85994..a360c15c 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -2671,14 +2671,14 @@ void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled) break; } - if (i < count) - return; - - XChangeProperty(_glfw.x11.display, window->x11.handle, - _glfw.x11.NET_WM_STATE, XA_ATOM, 32, - PropModeAppend, - (unsigned char*) &_glfw.x11.NET_WM_STATE_ABOVE, - 1); + if (i == count) + { + XChangeProperty(_glfw.x11.display, window->x11.handle, + _glfw.x11.NET_WM_STATE, XA_ATOM, 32, + PropModeAppend, + (unsigned char*) &_glfw.x11.NET_WM_STATE_ABOVE, + 1); + } } else if (states) { @@ -2688,15 +2688,15 @@ void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled) break; } - if (i == count) - return; + if (i < count) + { + states[i] = states[count - 1]; + count--; - states[i] = states[count - 1]; - count--; - - XChangeProperty(_glfw.x11.display, window->x11.handle, - _glfw.x11.NET_WM_STATE, XA_ATOM, 32, - PropModeReplace, (unsigned char*) states, count); + XChangeProperty(_glfw.x11.display, window->x11.handle, + _glfw.x11.NET_WM_STATE, XA_ATOM, 32, + PropModeReplace, (unsigned char*) states, count); + } } if (states) From 85348c67cd1caf1aea83c4d23203f7a40d9dd1de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 19 Aug 2021 18:50:17 +0200 Subject: [PATCH 006/208] Wayland: Load functions for new atomic marshalling The wayland-scanner program recently changed how it generates marshalling, requiring a couple of new core functions. Fixes #1949. --- README.md | 1 + src/wl_init.c | 4 ++++ src/wl_platform.h | 6 ++++++ 3 files changed, 11 insertions(+) diff --git a/README.md b/README.md index 44f7e3a8..0f5c2b9d 100644 --- a/README.md +++ b/README.md @@ -401,6 +401,7 @@ skills. - Martins Mozeiko - Julian Møller - ndogxj + - n3rdopolis - Kristian Nielsen - Kamil Nowakowski - onox diff --git a/src/wl_init.c b/src/wl_init.c index 33eeef8b..3d0236f2 100644 --- a/src/wl_init.c +++ b/src/wl_init.c @@ -1092,6 +1092,10 @@ int _glfwPlatformInit(void) _glfw_dlsym(_glfw.wl.client.handle, "wl_proxy_get_user_data"); _glfw.wl.client.proxy_set_user_data = (PFN_wl_proxy_set_user_data) _glfw_dlsym(_glfw.wl.client.handle, "wl_proxy_set_user_data"); + _glfw.wl.client.proxy_get_version = (PFN_wl_proxy_get_version) + _glfw_dlsym(_glfw.wl.client.handle, "wl_proxy_get_version"); + _glfw.wl.client.proxy_marshal_flags = (PFN_wl_proxy_marshal_flags) + _glfw_dlsym(_glfw.wl.client.handle, "wl_proxy_marshal_flags"); if (!_glfw.wl.client.display_flush || !_glfw.wl.client.display_cancel_read || diff --git a/src/wl_platform.h b/src/wl_platform.h index acb52685..a24943c9 100644 --- a/src/wl_platform.h +++ b/src/wl_platform.h @@ -70,6 +70,8 @@ typedef struct wl_proxy* (* PFN_wl_proxy_marshal_constructor)(struct wl_proxy*,u typedef struct wl_proxy* (* PFN_wl_proxy_marshal_constructor_versioned)(struct wl_proxy*,uint32_t,const struct wl_interface*,uint32_t,...); typedef void* (* PFN_wl_proxy_get_user_data)(struct wl_proxy*); typedef void (* PFN_wl_proxy_set_user_data)(struct wl_proxy*,void*); +typedef uint32_t (* PFN_wl_proxy_get_version)(struct wl_proxy*); +typedef struct wl_proxy* (* PFN_wl_proxy_marshal_flags)(struct wl_proxy*,uint32_t,const struct wl_interface*,uint32_t,uint32_t,...); #define wl_display_flush _glfw.wl.client.display_flush #define wl_display_cancel_read _glfw.wl.client.display_cancel_read #define wl_display_dispatch_pending _glfw.wl.client.display_dispatch_pending @@ -86,6 +88,8 @@ typedef void (* PFN_wl_proxy_set_user_data)(struct wl_proxy*,void*); #define wl_proxy_marshal_constructor_versioned _glfw.wl.client.proxy_marshal_constructor_versioned #define wl_proxy_get_user_data _glfw.wl.client.proxy_get_user_data #define wl_proxy_set_user_data _glfw.wl.client.proxy_set_user_data +#define wl_proxy_get_version _glfw.wl.client.proxy_get_version +#define wl_proxy_marshal_flags _glfw.wl.client.proxy_marshal_flags struct wl_shm; @@ -388,6 +392,8 @@ typedef struct _GLFWlibraryWayland PFN_wl_proxy_marshal_constructor_versioned proxy_marshal_constructor_versioned; PFN_wl_proxy_get_user_data proxy_get_user_data; PFN_wl_proxy_set_user_data proxy_set_user_data; + PFN_wl_proxy_get_version proxy_get_version; + PFN_wl_proxy_marshal_flags proxy_marshal_flags; } client; struct { From 2ac7e20aafebcd309b33c7b696e50e42971909d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Richard=20Boldi=C5=A1?= Date: Tue, 24 Aug 2021 02:30:41 +0200 Subject: [PATCH 007/208] Win32: Fix invalid preprocessor command 'warning' The GCCism #warning had snuck into the Win32 platform code. Merges #1953. --- src/win32_init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/win32_init.c b/src/win32_init.c index cd7ea08e..549c64c7 100644 --- a/src/win32_init.c +++ b/src/win32_init.c @@ -40,7 +40,7 @@ static const GUID _glfw_GUID_DEVINTERFACE_HID = #if defined(_GLFW_USE_HYBRID_HPG) || defined(_GLFW_USE_OPTIMUS_HPG) #if defined(_GLFW_BUILD_DLL) - #warning "These symbols must be exported by the executable and have no effect in a DLL" + #pragma message("These symbols must be exported by the executable and have no effect in a DLL") #endif // Executables (but not DLLs) exporting this symbol with this value will be From 4e557437f2e97945f57a86fc6a8c659bf5346098 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 25 Aug 2021 20:47:17 +0200 Subject: [PATCH 008/208] Name parameters for callback function types Started adding these because of Doxygen warnings but it should have been done regardless. --- include/GLFW/glfw3.h | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index 7728dad1..a3ba9910 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -1352,7 +1352,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 +1375,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 +1397,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 +1417,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 +1437,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 +1458,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 +1479,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 +1500,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 +1521,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 +1542,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 +1568,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 +1591,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 +1612,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 +1633,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. * @@ -1659,7 +1659,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 +1680,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 +1707,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 +1731,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 +1752,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 +1773,7 @@ typedef void (* GLFWmonitorfun)(GLFWmonitor*,int); * * @ingroup input */ -typedef void (* GLFWjoystickfun)(int,int); +typedef void (* GLFWjoystickfun)(int jid, int event); /*! @brief Video mode type. * From 22b586b3d87c91581074cc2a47fe5eba6f10bf0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 3 Aug 2021 20:53:48 +0200 Subject: [PATCH 009/208] Add pluggable heap allocator This adds the glfwInitAllocator function for specifying a custom memory allocator to use instead of the C runtime library. The allocator is a struct of type GLFWallocator with fields corresponding to malloc, realloc and free, while the internal API corresponds to calloc, realloc and free. Heap allocation calls are filtered before reaching the user-provided functions, so deallocation of NULL and allocations of zero bytes are not passed on, reallocating NULL is transformed into an allocation and reallocating to size zero is transformed into deallocation. The clearing of a new block to zero is performed by the internal calloc-like function. Closes #544. Fixes #1628. Closes #1947. --- README.md | 3 + docs/intro.dox | 59 +++++++++++++++ docs/news.dox | 21 ++++++ include/GLFW/glfw3.h | 171 +++++++++++++++++++++++++++++++++++++++++++ src/cocoa_init.m | 2 +- src/cocoa_joystick.m | 8 +- src/cocoa_monitor.m | 22 +++--- src/cocoa_window.m | 10 +-- src/egl_context.c | 10 +-- src/glx_context.c | 4 +- src/init.c | 106 +++++++++++++++++++++++++-- src/input.c | 24 +++--- src/internal.h | 5 ++ src/monitor.c | 27 +++---- src/null_init.c | 2 +- src/null_monitor.c | 2 +- src/null_window.c | 2 +- src/osmesa_context.c | 6 +- src/vulkan.c | 6 +- src/wgl_context.c | 13 ++-- src/win32_init.c | 13 ++-- src/win32_joystick.c | 18 ++--- src/win32_monitor.c | 15 ++-- src/win32_window.c | 23 +++--- src/window.c | 4 +- src/wl_init.c | 6 +- src/wl_monitor.c | 2 +- src/wl_window.c | 24 +++--- src/x11_init.c | 4 +- src/x11_monitor.c | 8 +- src/x11_window.c | 34 ++++----- tests/CMakeLists.txt | 5 +- tests/allocator.c | 141 +++++++++++++++++++++++++++++++++++ 33 files changed, 647 insertions(+), 153 deletions(-) create mode 100644 tests/allocator.c diff --git a/README.md b/README.md index 0f5c2b9d..018561e9 100644 --- a/README.md +++ b/README.md @@ -116,6 +116,9 @@ information on what to include when reporting a bug. ## Changelog + - Added `glfwInitAllocator` for setting a custom memory allocator (#544,#1628,#1947) + - Added `GLFWallocator` struct and `GLFWallocatefun`, `GLFWreallocatefun` and + `GLFWdeallocatefun` types (#544,#1628,#1947) - Added `GLFW_RESIZE_NWSE_CURSOR`, `GLFW_RESIZE_NESW_CURSOR`, `GLFW_RESIZE_ALL_CURSOR` and `GLFW_NOT_ALLOWED_CURSOR` cursor shapes (#427) - Added `GLFW_RESIZE_EW_CURSOR` alias for `GLFW_HRESIZE_CURSOR` (#427) diff --git a/docs/intro.dox b/docs/intro.dox index 3593ab1e..4134c84d 100644 --- a/docs/intro.dox +++ b/docs/intro.dox @@ -33,6 +33,7 @@ successfully initialized, and only from the main thread. - @ref glfwGetError - @ref glfwSetErrorCallback - @ref glfwInitHint + - @ref glfwInitAllocator - @ref glfwInit - @ref glfwTerminate @@ -143,6 +144,64 @@ Initialization hint | Default value | Supported v @ref GLFW_X11_XCB_VULKAN_SURFACE | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE` +@subsection init_allocator Custom heap memory allocator + +The heap memory allocator can be customized before initialization with @ref +glfwInitAllocator. + +@code +GLFWallocator allocator; +allocator.allocate = my_malloc; +allocator.reallocate = my_realloc; +allocator.deallocate = my_free; +allocator.user = NULL; + +glfwInitAllocator(&allocator); +@endcode + +The allocator will be picked up at the beginning of initialization and will be +used until GLFW has been fully terminated. Any allocator set after +initialization will be picked up only at the next initialization. + +The allocator will only be used for allocations that would have been made with +the C standard library. Memory allocations that must be made with platform +specific APIs will still use those. + +The allocation function must have a signature matching @ref GLFWallocatefun. It receives +the desired size, in bytes, and the user pointer passed to @ref glfwInitAllocator and +returns the address to the allocated memory block. + +@code +void* my_malloc(size_t size, void* user) +{ + ... +} +@endcode + +The reallocation function must have a function signature matching @ref GLFWreallocatefun. +It receives the memory block to be reallocated, the new desired size, in bytes, and the user +pointer passed to @ref glfwInitAllocator and returns the address to the resized memory +block. + +@code +void* my_realloc(void* block, size_t size, void* user) +{ + ... +} +@endcode + +The deallocation function must have a function signature matching @ref GLFWdeallocatefun. +It receives the memory block to be deallocated and the user pointer passed to @ref +glfwInitAllocator. + +@code +void my_free(void* block, void* user) +{ + ... +} +@endcode + + @subsection intro_init_terminate Terminating GLFW Before your application exits, you should terminate the GLFW library if it has diff --git a/docs/news.dox b/docs/news.dox index d9ed0b1d..6b1367d5 100644 --- a/docs/news.dox +++ b/docs/news.dox @@ -44,6 +44,16 @@ requesting a specific rendering backend when using contexts. +@subsubsection features_34_init_allocator Support for custom memory allocator + +GLFW now supports plugging a custom memory allocator at initialization with @ref +glfwInitAllocator. The allocator is a struct of type @ref GLFWallocator with +function pointers corresponding to the standard library functions `malloc`, +`realloc` and `free`. + +For more information see @ref init_allocator. + + @subsubsection features_34_win32_keymenu Support for keyboard access to Windows window menu GLFW now provides the @@ -118,7 +128,18 @@ then GLFW will fail to initialize. @subsection symbols_34 New symbols in version 3.4 @subsubsection functions_34 New functions in version 3.4 + + - @ref glfwInitAllocator + + @subsubsection types_34 New types in version 3.4 + + - @ref GLFWallocator + - @ref GLFWallocatefun + - @ref GLFWreallocatefun + - @ref GLFWdeallocatefun + + @subsubsection constants_34 New constants in version 3.4 - @ref GLFW_POINTING_HAND_CURSOR diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index a3ba9910..95aac6d9 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -1330,6 +1330,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 @@ -1887,6 +2012,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 @@ -1930,6 +2072,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 +2148,33 @@ 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); + /*! @brief Retrieves the version of the GLFW library. * * This function retrieves the major, minor and revision numbers of the GLFW diff --git a/src/cocoa_init.m b/src/cocoa_init.m index 626d95c2..d12f3427 100644 --- a/src/cocoa_init.m +++ b/src/cocoa_init.m @@ -602,7 +602,7 @@ void _glfwPlatformTerminate(void) if (_glfw.ns.keyUpMonitor) [NSEvent removeMonitor:_glfw.ns.keyUpMonitor]; - free(_glfw.ns.clipboardString); + _glfw_free(_glfw.ns.clipboardString); _glfwTerminateNSGL(); diff --git a/src/cocoa_joystick.m b/src/cocoa_joystick.m index 4a64fb09..a8081d2c 100644 --- a/src/cocoa_joystick.m +++ b/src/cocoa_joystick.m @@ -102,15 +102,15 @@ static void closeJoystick(_GLFWjoystick* js) return; for (i = 0; i < CFArrayGetCount(js->ns.axes); i++) - free((void*) CFArrayGetValueAtIndex(js->ns.axes, i)); + _glfw_free((void*) CFArrayGetValueAtIndex(js->ns.axes, i)); CFRelease(js->ns.axes); for (i = 0; i < CFArrayGetCount(js->ns.buttons); i++) - free((void*) CFArrayGetValueAtIndex(js->ns.buttons, i)); + _glfw_free((void*) CFArrayGetValueAtIndex(js->ns.buttons, i)); CFRelease(js->ns.buttons); for (i = 0; i < CFArrayGetCount(js->ns.hats); i++) - free((void*) CFArrayGetValueAtIndex(js->ns.hats, i)); + _glfw_free((void*) CFArrayGetValueAtIndex(js->ns.hats, i)); CFRelease(js->ns.hats); _glfwFreeJoystick(js); @@ -251,7 +251,7 @@ static void matchCallback(void* context, if (target) { - _GLFWjoyelementNS* element = calloc(1, sizeof(_GLFWjoyelementNS)); + _GLFWjoyelementNS* element = _glfw_calloc(1, sizeof(_GLFWjoyelementNS)); element->native = native; element->usage = usage; element->index = (int) CFArrayGetCount(target); diff --git a/src/cocoa_monitor.m b/src/cocoa_monitor.m index 31bf0434..2462beab 100644 --- a/src/cocoa_monitor.m +++ b/src/cocoa_monitor.m @@ -120,7 +120,7 @@ static char* getMonitorName(CGDirectDisplayID displayID, NSScreen* screen) const CFIndex size = CFStringGetMaximumSizeForEncoding(CFStringGetLength(nameRef), kCFStringEncodingUTF8); - char* name = calloc(size + 1, 1); + char* name = _glfw_calloc(size + 1, 1); CFStringGetCString(nameRef, name, size, kCFStringEncodingUTF8); CFRelease(info); @@ -301,7 +301,7 @@ void _glfwPollMonitorsNS(void) { uint32_t displayCount; CGGetOnlineDisplayList(0, NULL, &displayCount); - CGDirectDisplayID* displays = calloc(displayCount, sizeof(CGDirectDisplayID)); + CGDirectDisplayID* displays = _glfw_calloc(displayCount, sizeof(CGDirectDisplayID)); CGGetOnlineDisplayList(displayCount, displays, &displayCount); for (int i = 0; i < _glfw.monitorCount; i++) @@ -311,7 +311,7 @@ void _glfwPollMonitorsNS(void) uint32_t disconnectedCount = _glfw.monitorCount; if (disconnectedCount) { - disconnected = calloc(_glfw.monitorCount, sizeof(_GLFWmonitor*)); + disconnected = _glfw_calloc(_glfw.monitorCount, sizeof(_GLFWmonitor*)); memcpy(disconnected, _glfw.monitors, _glfw.monitorCount * sizeof(_GLFWmonitor*)); @@ -363,7 +363,7 @@ void _glfwPollMonitorsNS(void) monitor->ns.unitNumber = unitNumber; monitor->ns.screen = screen; - free(name); + _glfw_free(name); CGDisplayModeRef mode = CGDisplayCopyDisplayMode(displays[i]); if (CGDisplayModeGetRefreshRate(mode) == 0.0) @@ -379,8 +379,8 @@ void _glfwPollMonitorsNS(void) _glfwInputMonitor(disconnected[i], GLFW_DISCONNECTED, 0); } - free(disconnected); - free(displays); + _glfw_free(disconnected); + _glfw_free(displays); } // Change the current video mode @@ -521,7 +521,7 @@ GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* count) CFArrayRef modes = CGDisplayCopyAllDisplayModes(monitor->ns.displayID, NULL); const CFIndex found = CFArrayGetCount(modes); - GLFWvidmode* result = calloc(found, sizeof(GLFWvidmode)); + GLFWvidmode* result = _glfw_calloc(found, sizeof(GLFWvidmode)); for (CFIndex i = 0; i < found; i++) { @@ -569,7 +569,7 @@ GLFWbool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp) @autoreleasepool { uint32_t size = CGDisplayGammaTableCapacity(monitor->ns.displayID); - CGGammaValue* values = calloc(size * 3, sizeof(CGGammaValue)); + CGGammaValue* values = _glfw_calloc(size * 3, sizeof(CGGammaValue)); CGGetDisplayTransferByTable(monitor->ns.displayID, size, @@ -587,7 +587,7 @@ GLFWbool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp) ramp->blue[i] = (unsigned short) (values[i + size * 2] * 65535); } - free(values); + _glfw_free(values); return GLFW_TRUE; } // autoreleasepool @@ -597,7 +597,7 @@ void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp) { @autoreleasepool { - CGGammaValue* values = calloc(ramp->size * 3, sizeof(CGGammaValue)); + CGGammaValue* values = _glfw_calloc(ramp->size * 3, sizeof(CGGammaValue)); for (unsigned int i = 0; i < ramp->size; i++) { @@ -612,7 +612,7 @@ void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp) values + ramp->size, values + ramp->size * 2); - free(values); + _glfw_free(values); } // autoreleasepool } diff --git a/src/cocoa_window.m b/src/cocoa_window.m index 5b8396b4..6ab0ffa6 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -646,7 +646,7 @@ static const NSRange kEmptyRange = { NSNotFound, 0 }; const NSUInteger count = [urls count]; if (count) { - char** paths = calloc(count, sizeof(char*)); + char** paths = _glfw_calloc(count, sizeof(char*)); for (NSUInteger i = 0; i < count; i++) paths[i] = _glfw_strdup([urls[i] fileSystemRepresentation]); @@ -654,8 +654,8 @@ static const NSRange kEmptyRange = { NSNotFound, 0 }; _glfwInputDrop(window, (int) count, (const char**) paths); for (NSUInteger i = 0; i < count; i++) - free(paths[i]); - free(paths); + _glfw_free(paths[i]); + _glfw_free(paths); } return YES; @@ -1747,7 +1747,7 @@ const char* _glfwPlatformGetClipboardString(void) return NULL; } - free(_glfw.ns.clipboardString); + _glfw_free(_glfw.ns.clipboardString); _glfw.ns.clipboardString = _glfw_strdup([object UTF8String]); return _glfw.ns.clipboardString; @@ -1775,7 +1775,7 @@ EGLenum _glfwPlatformGetEGLPlatform(EGLint** attribs) if (type) { - *attribs = calloc(3, sizeof(EGLint)); + *attribs = _glfw_calloc(3, sizeof(EGLint)); (*attribs)[0] = EGL_PLATFORM_ANGLE_TYPE_ANGLE; (*attribs)[1] = type; (*attribs)[2] = EGL_NONE; diff --git a/src/egl_context.c b/src/egl_context.c index 975c67be..264b233a 100644 --- a/src/egl_context.c +++ b/src/egl_context.c @@ -103,10 +103,10 @@ static GLFWbool chooseEGLConfig(const _GLFWctxconfig* ctxconfig, return GLFW_FALSE; } - nativeConfigs = calloc(nativeCount, sizeof(EGLConfig)); + nativeConfigs = _glfw_calloc(nativeCount, sizeof(EGLConfig)); eglGetConfigs(_glfw.egl.display, nativeConfigs, nativeCount, &nativeCount); - usableConfigs = calloc(nativeCount, sizeof(_GLFWfbconfig)); + usableConfigs = _glfw_calloc(nativeCount, sizeof(_GLFWfbconfig)); usableCount = 0; for (i = 0; i < nativeCount; i++) @@ -183,8 +183,8 @@ static GLFWbool chooseEGLConfig(const _GLFWctxconfig* ctxconfig, if (closest) *result = (EGLConfig) closest->handle; - free(nativeConfigs); - free(usableConfigs); + _glfw_free(nativeConfigs); + _glfw_free(usableConfigs); return closest != NULL; } @@ -440,7 +440,7 @@ GLFWbool _glfwInitEGL(void) else _glfw.egl.display = eglGetDisplay(_glfwPlatformGetEGLNativeDisplay()); - free(attribs); + _glfw_free(attribs); if (_glfw.egl.display == EGL_NO_DISPLAY) { diff --git a/src/glx_context.c b/src/glx_context.c index 374c15e0..7207cd55 100644 --- a/src/glx_context.c +++ b/src/glx_context.c @@ -73,7 +73,7 @@ static GLFWbool chooseGLXFBConfig(const _GLFWfbconfig* desired, return GLFW_FALSE; } - usableConfigs = calloc(nativeCount, sizeof(_GLFWfbconfig)); + usableConfigs = _glfw_calloc(nativeCount, sizeof(_GLFWfbconfig)); usableCount = 0; for (i = 0; i < nativeCount; i++) @@ -138,7 +138,7 @@ static GLFWbool chooseGLXFBConfig(const _GLFWfbconfig* desired, *result = (GLXFBConfig) closest->handle; XFree(nativeConfigs); - free(usableConfigs); + _glfw_free(usableConfigs); return closest != NULL; } diff --git a/src/init.c b/src/init.c index 25a6b4f3..a9f9a54d 100644 --- a/src/init.c +++ b/src/init.c @@ -49,6 +49,7 @@ _GLFWlibrary _glfw = { GLFW_FALSE }; // static _GLFWerror _glfwMainThreadError; static GLFWerrorfun _glfwErrorCallback; +static GLFWallocator _glfwInitAllocator; static _GLFWinitconfig _glfwInitHints = { GLFW_TRUE, // hat buttons @@ -62,6 +63,27 @@ static _GLFWinitconfig _glfwInitHints = }, }; +// The allocation function used when no custom allocator is set +// +static void* defaultAllocate(size_t size, void* user) +{ + return malloc(size); +} + +// The deallocation function used when no custom allocator is set +// +static void defaultDeallocate(void* block, void* user) +{ + free(block); +} + +// The reallocation function used when no custom allocator is set +// +static void* defaultReallocate(void* block, size_t size, void* user) +{ + return realloc(block, size); +} + // Terminate the library // static void terminate(void) @@ -84,11 +106,11 @@ static void terminate(void) _glfwFreeMonitor(monitor); } - free(_glfw.monitors); + _glfw_free(_glfw.monitors); _glfw.monitors = NULL; _glfw.monitorCount = 0; - free(_glfw.mappings); + _glfw_free(_glfw.mappings); _glfw.mappings = NULL; _glfw.mappingCount = 0; @@ -102,7 +124,7 @@ static void terminate(void) { _GLFWerror* error = _glfw.errorListHead; _glfw.errorListHead = error->next; - free(error); + _glfw_free(error); } _glfwPlatformDestroyTls(&_glfw.contextSlot); @@ -120,7 +142,7 @@ static void terminate(void) char* _glfw_strdup(const char* source) { const size_t length = strlen(source); - char* result = calloc(length + 1, 1); + char* result = _glfw_calloc(length + 1, 1); strcpy(result, source); return result; } @@ -149,6 +171,59 @@ float _glfw_fmaxf(float a, float b) return b; } +void* _glfw_calloc(size_t count, size_t size) +{ + if (count && size) + { + void* block; + + if (count > SIZE_MAX / size) + { + _glfwInputError(GLFW_INVALID_VALUE, "Allocation size overflow"); + return NULL; + } + + block = _glfw.allocator.allocate(count * size, _glfw.allocator.user); + if (block) + return memset(block, 0, count * size); + else + { + _glfwInputError(GLFW_OUT_OF_MEMORY, NULL); + return NULL; + } + } + else + return NULL; +} + +void* _glfw_realloc(void* block, size_t size) +{ + if (block && size) + { + void* resized = _glfw.allocator.reallocate(block, size, _glfw.allocator.user); + if (resized) + return resized; + else + { + _glfwInputError(GLFW_OUT_OF_MEMORY, NULL); + return NULL; + } + } + else if (block) + { + _glfw_free(block); + return NULL; + } + else + return _glfw_calloc(1, size); +} + +void _glfw_free(void* block) +{ + if (block) + _glfw.allocator.deallocate(block, _glfw.allocator.user); +} + ////////////////////////////////////////////////////////////////////////// ////// GLFW event API ////// @@ -208,7 +283,7 @@ void _glfwInputError(int code, const char* format, ...) error = _glfwPlatformGetTls(&_glfw.errorSlot); if (!error) { - error = calloc(1, sizeof(_GLFWerror)); + error = _glfw_calloc(1, sizeof(_GLFWerror)); _glfwPlatformSetTls(&_glfw.errorSlot, error); _glfwPlatformLockMutex(&_glfw.errorLock); error->next = _glfw.errorListHead; @@ -239,6 +314,14 @@ GLFWAPI int glfwInit(void) memset(&_glfw, 0, sizeof(_glfw)); _glfw.hints.init = _glfwInitHints; + _glfw.allocator = _glfwInitAllocator; + if (!_glfw.allocator.allocate) + { + _glfw.allocator.allocate = defaultAllocate; + _glfw.allocator.reallocate = defaultReallocate; + _glfw.allocator.deallocate = defaultDeallocate; + } + if (!_glfwPlatformInit()) { terminate(); @@ -297,6 +380,19 @@ GLFWAPI void glfwInitHint(int hint, int value) "Invalid init hint 0x%08X", hint); } +GLFWAPI void glfwInitAllocator(const GLFWallocator* allocator) +{ + if (allocator) + { + if (allocator->allocate && allocator->reallocate && allocator->deallocate) + _glfwInitAllocator = *allocator; + else + _glfwInputError(GLFW_INVALID_VALUE, "Missing function in allocator"); + } + else + memset(&_glfwInitAllocator, 0, sizeof(GLFWallocator)); +} + GLFWAPI void glfwGetVersion(int* major, int* minor, int* rev) { if (major != NULL) diff --git a/src/input.c b/src/input.c index 4f4830b5..83ef6921 100644 --- a/src/input.c +++ b/src/input.c @@ -419,7 +419,7 @@ void _glfwInitGamepadMappings(void) { size_t i; const size_t count = sizeof(_glfwDefaultMappings) / sizeof(char*); - _glfw.mappings = calloc(count, sizeof(_GLFWmapping)); + _glfw.mappings = _glfw_calloc(count, sizeof(_GLFWmapping)); for (i = 0; i < count; i++) { @@ -450,9 +450,9 @@ _GLFWjoystick* _glfwAllocJoystick(const char* name, js = _glfw.joysticks + jid; js->present = GLFW_TRUE; - js->axes = calloc(axisCount, sizeof(float)); - js->buttons = calloc(buttonCount + (size_t) hatCount * 4, 1); - js->hats = calloc(hatCount, 1); + js->axes = _glfw_calloc(axisCount, sizeof(float)); + js->buttons = _glfw_calloc(buttonCount + (size_t) hatCount * 4, 1); + js->hats = _glfw_calloc(hatCount, 1); js->axisCount = axisCount; js->buttonCount = buttonCount; js->hatCount = hatCount; @@ -468,9 +468,9 @@ _GLFWjoystick* _glfwAllocJoystick(const char* name, // void _glfwFreeJoystick(_GLFWjoystick* js) { - free(js->axes); - free(js->buttons); - free(js->hats); + _glfw_free(js->axes); + _glfw_free(js->buttons); + _glfw_free(js->hats); memset(js, 0, sizeof(_GLFWjoystick)); } @@ -754,7 +754,7 @@ GLFWAPI GLFWcursor* glfwCreateCursor(const GLFWimage* image, int xhot, int yhot) _GLFW_REQUIRE_INIT_OR_RETURN(NULL); - cursor = calloc(1, sizeof(_GLFWcursor)); + cursor = _glfw_calloc(1, sizeof(_GLFWcursor)); cursor->next = _glfw.cursorListHead; _glfw.cursorListHead = cursor; @@ -788,7 +788,7 @@ GLFWAPI GLFWcursor* glfwCreateStandardCursor(int shape) return NULL; } - cursor = calloc(1, sizeof(_GLFWcursor)); + cursor = _glfw_calloc(1, sizeof(_GLFWcursor)); cursor->next = _glfw.cursorListHead; _glfw.cursorListHead = cursor; @@ -833,7 +833,7 @@ GLFWAPI void glfwDestroyCursor(GLFWcursor* handle) *prev = cursor->next; } - free(cursor); + _glfw_free(cursor); } GLFWAPI void glfwSetCursor(GLFWwindow* windowHandle, GLFWcursor* cursorHandle) @@ -1191,8 +1191,8 @@ GLFWAPI int glfwUpdateGamepadMappings(const char* string) { _glfw.mappingCount++; _glfw.mappings = - realloc(_glfw.mappings, - sizeof(_GLFWmapping) * _glfw.mappingCount); + _glfw_realloc(_glfw.mappings, + sizeof(_GLFWmapping) * _glfw.mappingCount); _glfw.mappings[_glfw.mappingCount - 1] = mapping; } } diff --git a/src/internal.h b/src/internal.h index efa7e5b8..f41db3c3 100644 --- a/src/internal.h +++ b/src/internal.h @@ -527,6 +527,7 @@ struct _GLFWmutex struct _GLFWlibrary { GLFWbool initialized; + GLFWallocator allocator; struct { _GLFWinitconfig init; @@ -798,3 +799,7 @@ char* _glfw_strdup(const char* source); float _glfw_fminf(float a, float b); float _glfw_fmaxf(float a, float b); +void* _glfw_calloc(size_t count, size_t size); +void* _glfw_realloc(void* pointer, size_t size); +void _glfw_free(void* pointer); + diff --git a/src/monitor.c b/src/monitor.c index bde93010..938582b2 100644 --- a/src/monitor.c +++ b/src/monitor.c @@ -80,7 +80,7 @@ static GLFWbool refreshVideoModes(_GLFWmonitor* monitor) qsort(modes, modeCount, sizeof(GLFWvidmode), compareVideoModes); - free(monitor->modes); + _glfw_free(monitor->modes); monitor->modes = modes; monitor->modeCount = modeCount; @@ -100,7 +100,8 @@ void _glfwInputMonitor(_GLFWmonitor* monitor, int action, int placement) { _glfw.monitorCount++; _glfw.monitors = - realloc(_glfw.monitors, sizeof(_GLFWmonitor*) * _glfw.monitorCount); + _glfw_realloc(_glfw.monitors, + sizeof(_GLFWmonitor*) * _glfw.monitorCount); if (placement == _GLFW_INSERT_FIRST) { @@ -166,7 +167,7 @@ void _glfwInputMonitorWindow(_GLFWmonitor* monitor, _GLFWwindow* window) // _GLFWmonitor* _glfwAllocMonitor(const char* name, int widthMM, int heightMM) { - _GLFWmonitor* monitor = calloc(1, sizeof(_GLFWmonitor)); + _GLFWmonitor* monitor = _glfw_calloc(1, sizeof(_GLFWmonitor)); monitor->widthMM = widthMM; monitor->heightMM = heightMM; @@ -187,17 +188,17 @@ void _glfwFreeMonitor(_GLFWmonitor* monitor) _glfwFreeGammaArrays(&monitor->originalRamp); _glfwFreeGammaArrays(&monitor->currentRamp); - free(monitor->modes); - free(monitor); + _glfw_free(monitor->modes); + _glfw_free(monitor); } // Allocates red, green and blue value arrays of the specified size // void _glfwAllocGammaArrays(GLFWgammaramp* ramp, unsigned int size) { - ramp->red = calloc(size, sizeof(unsigned short)); - ramp->green = calloc(size, sizeof(unsigned short)); - ramp->blue = calloc(size, sizeof(unsigned short)); + ramp->red = _glfw_calloc(size, sizeof(unsigned short)); + ramp->green = _glfw_calloc(size, sizeof(unsigned short)); + ramp->blue = _glfw_calloc(size, sizeof(unsigned short)); ramp->size = size; } @@ -205,9 +206,9 @@ void _glfwAllocGammaArrays(GLFWgammaramp* ramp, unsigned int size) // void _glfwFreeGammaArrays(GLFWgammaramp* ramp) { - free(ramp->red); - free(ramp->green); - free(ramp->blue); + _glfw_free(ramp->red); + _glfw_free(ramp->green); + _glfw_free(ramp->blue); memset(ramp, 0, sizeof(GLFWgammaramp)); } @@ -472,7 +473,7 @@ GLFWAPI void glfwSetGamma(GLFWmonitor* handle, float gamma) if (!original) return; - values = calloc(original->size, sizeof(unsigned short)); + values = _glfw_calloc(original->size, sizeof(unsigned short)); for (i = 0; i < original->size; i++) { @@ -494,7 +495,7 @@ GLFWAPI void glfwSetGamma(GLFWmonitor* handle, float gamma) ramp.size = original->size; glfwSetGammaRamp(handle, &ramp); - free(values); + _glfw_free(values); } GLFWAPI const GLFWgammaramp* glfwGetGammaRamp(GLFWmonitor* handle) diff --git a/src/null_init.c b/src/null_init.c index 57aafd5d..68599d1f 100644 --- a/src/null_init.c +++ b/src/null_init.c @@ -46,7 +46,7 @@ int _glfwPlatformInit(void) void _glfwPlatformTerminate(void) { - free(_glfw.null.clipboardString); + _glfw_free(_glfw.null.clipboardString); _glfwTerminateOSMesa(); } diff --git a/src/null_monitor.c b/src/null_monitor.c index 8301eb3a..a071e0c4 100644 --- a/src/null_monitor.c +++ b/src/null_monitor.c @@ -105,7 +105,7 @@ void _glfwPlatformGetMonitorWorkarea(_GLFWmonitor* monitor, GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* found) { - GLFWvidmode* mode = calloc(1, sizeof(GLFWvidmode)); + GLFWvidmode* mode = _glfw_calloc(1, sizeof(GLFWvidmode)); *mode = getVideoMode(); *found = 1; return mode; diff --git a/src/null_window.c b/src/null_window.c index b81ab601..1f59540e 100644 --- a/src/null_window.c +++ b/src/null_window.c @@ -513,7 +513,7 @@ void _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor) void _glfwPlatformSetClipboardString(const char* string) { char* copy = _glfw_strdup(string); - free(_glfw.null.clipboardString); + _glfw_free(_glfw.null.clipboardString); _glfw.null.clipboardString = copy; } diff --git a/src/osmesa_context.c b/src/osmesa_context.c index 70e8675b..74a9291b 100644 --- a/src/osmesa_context.c +++ b/src/osmesa_context.c @@ -46,10 +46,10 @@ static void makeContextCurrentOSMesa(_GLFWwindow* window) (width != window->context.osmesa.width) || (height != window->context.osmesa.height)) { - free(window->context.osmesa.buffer); + _glfw_free(window->context.osmesa.buffer); // Allocate the new buffer (width * height * 8-bit RGBA) - window->context.osmesa.buffer = calloc(4, (size_t) width * height); + window->context.osmesa.buffer = _glfw_calloc(4, (size_t) width * height); window->context.osmesa.width = width; window->context.osmesa.height = height; } @@ -83,7 +83,7 @@ static void destroyContextOSMesa(_GLFWwindow* window) if (window->context.osmesa.buffer) { - free(window->context.osmesa.buffer); + _glfw_free(window->context.osmesa.buffer); window->context.osmesa.width = 0; window->context.osmesa.height = 0; } diff --git a/src/vulkan.c b/src/vulkan.c index b5340520..e810ca06 100644 --- a/src/vulkan.c +++ b/src/vulkan.c @@ -108,7 +108,7 @@ GLFWbool _glfwInitVulkan(int mode) return GLFW_FALSE; } - ep = calloc(count, sizeof(VkExtensionProperties)); + ep = _glfw_calloc(count, sizeof(VkExtensionProperties)); err = vkEnumerateInstanceExtensionProperties(NULL, &count, ep); if (err) @@ -117,7 +117,7 @@ GLFWbool _glfwInitVulkan(int mode) "Vulkan: Failed to query instance extensions: %s", _glfwGetVulkanResultString(err)); - free(ep); + _glfw_free(ep); _glfwTerminateVulkan(); return GLFW_FALSE; } @@ -145,7 +145,7 @@ GLFWbool _glfwInitVulkan(int mode) #endif } - free(ep); + _glfw_free(ep); _glfw.vk.available = GLFW_TRUE; diff --git a/src/wgl_context.c b/src/wgl_context.c index 5b69f8bc..62055847 100644 --- a/src/wgl_context.c +++ b/src/wgl_context.c @@ -30,7 +30,6 @@ #include "internal.h" #include -#include #include // Return the value corresponding to the specified attribute @@ -130,7 +129,7 @@ static int choosePixelFormat(_GLFWwindow* window, NULL); } - usableConfigs = calloc(nativeCount, sizeof(_GLFWfbconfig)); + usableConfigs = _glfw_calloc(nativeCount, sizeof(_GLFWfbconfig)); for (i = 0; i < nativeCount; i++) { @@ -149,7 +148,7 @@ static int choosePixelFormat(_GLFWwindow* window, _glfwInputErrorWin32(GLFW_PLATFORM_ERROR, "WGL: Failed to retrieve pixel format attributes"); - free(usableConfigs); + _glfw_free(usableConfigs); return 0; } @@ -221,7 +220,7 @@ static int choosePixelFormat(_GLFWwindow* window, _glfwInputErrorWin32(GLFW_PLATFORM_ERROR, "WGL: Failed to describe pixel format"); - free(usableConfigs); + _glfw_free(usableConfigs); return 0; } @@ -271,7 +270,7 @@ static int choosePixelFormat(_GLFWwindow* window, _glfwInputError(GLFW_API_UNAVAILABLE, "WGL: The driver does not appear to support OpenGL"); - free(usableConfigs); + _glfw_free(usableConfigs); return 0; } @@ -281,12 +280,12 @@ static int choosePixelFormat(_GLFWwindow* window, _glfwInputError(GLFW_FORMAT_UNAVAILABLE, "WGL: Failed to find a suitable pixel format"); - free(usableConfigs); + _glfw_free(usableConfigs); return 0; } pixelFormat = (int) closest->handle; - free(usableConfigs); + _glfw_free(usableConfigs); return pixelFormat; } diff --git a/src/win32_init.c b/src/win32_init.c index 549c64c7..c5370230 100644 --- a/src/win32_init.c +++ b/src/win32_init.c @@ -30,7 +30,6 @@ #include "internal.h" #include -#include static const GUID _glfw_GUID_DEVINTERFACE_HID = {0x4d1e55b2,0xf16f,0x11cf,{0x88,0xcb,0x00,0x11,0x11,0x00,0x00,0x30}}; @@ -405,13 +404,13 @@ WCHAR* _glfwCreateWideStringFromUTF8Win32(const char* source) return NULL; } - target = calloc(count, sizeof(WCHAR)); + target = _glfw_calloc(count, sizeof(WCHAR)); if (!MultiByteToWideChar(CP_UTF8, 0, source, -1, target, count)) { _glfwInputErrorWin32(GLFW_PLATFORM_ERROR, "Win32: Failed to convert string from UTF-8"); - free(target); + _glfw_free(target); return NULL; } @@ -433,13 +432,13 @@ char* _glfwCreateUTF8FromWideStringWin32(const WCHAR* source) return NULL; } - target = calloc(size, 1); + target = _glfw_calloc(size, 1); if (!WideCharToMultiByte(CP_UTF8, 0, source, -1, target, size, NULL, NULL)) { _glfwInputErrorWin32(GLFW_PLATFORM_ERROR, "Win32: Failed to convert string to UTF-8"); - free(target); + _glfw_free(target); return NULL; } @@ -593,8 +592,8 @@ void _glfwPlatformTerminate(void) _glfwUnregisterWindowClassWin32(); - free(_glfw.win32.clipboardString); - free(_glfw.win32.rawInput); + _glfw_free(_glfw.win32.clipboardString); + _glfw_free(_glfw.win32.rawInput); _glfwTerminateWGL(); _glfwTerminateEGL(); diff --git a/src/win32_joystick.c b/src/win32_joystick.c index 9c71d114..3ac29d1d 100644 --- a/src/win32_joystick.c +++ b/src/win32_joystick.c @@ -199,11 +199,11 @@ static GLFWbool supportsXInput(const GUID* guid) if (GetRawInputDeviceList(NULL, &count, sizeof(RAWINPUTDEVICELIST)) != 0) return GLFW_FALSE; - ridl = calloc(count, sizeof(RAWINPUTDEVICELIST)); + ridl = _glfw_calloc(count, sizeof(RAWINPUTDEVICELIST)); if (GetRawInputDeviceList(ridl, &count, sizeof(RAWINPUTDEVICELIST)) == (UINT) -1) { - free(ridl); + _glfw_free(ridl); return GLFW_FALSE; } @@ -248,7 +248,7 @@ static GLFWbool supportsXInput(const GUID* guid) } } - free(ridl); + _glfw_free(ridl); return result; } @@ -262,7 +262,7 @@ static void closeJoystick(_GLFWjoystick* js) IDirectInputDevice8_Release(js->win32.device); } - free(js->win32.objects); + _glfw_free(js->win32.objects); _glfwFreeJoystick(js); _glfwInputJoystick(js, GLFW_DISCONNECTED); @@ -416,8 +416,8 @@ static BOOL CALLBACK deviceCallback(const DIDEVICEINSTANCE* di, void* user) memset(&data, 0, sizeof(data)); data.device = device; - data.objects = calloc(dc.dwAxes + (size_t) dc.dwButtons + dc.dwPOVs, - sizeof(_GLFWjoyobjectWin32)); + data.objects = _glfw_calloc(dc.dwAxes + (size_t) dc.dwButtons + dc.dwPOVs, + sizeof(_GLFWjoyobjectWin32)); if (FAILED(IDirectInputDevice8_EnumObjects(device, deviceObjectCallback, @@ -428,7 +428,7 @@ static BOOL CALLBACK deviceCallback(const DIDEVICEINSTANCE* di, void* user) "Win32: Failed to enumerate device objects"); IDirectInputDevice8_Release(device); - free(data.objects); + _glfw_free(data.objects); return DIENUM_CONTINUE; } @@ -445,7 +445,7 @@ static BOOL CALLBACK deviceCallback(const DIDEVICEINSTANCE* di, void* user) "Win32: Failed to convert joystick name to UTF-8"); IDirectInputDevice8_Release(device); - free(data.objects); + _glfw_free(data.objects); return DIENUM_STOP; } @@ -473,7 +473,7 @@ static BOOL CALLBACK deviceCallback(const DIDEVICEINSTANCE* di, void* user) if (!js) { IDirectInputDevice8_Release(device); - free(data.objects); + _glfw_free(data.objects); return DIENUM_STOP; } diff --git a/src/win32_monitor.c b/src/win32_monitor.c index b4c53e4c..10e3d282 100644 --- a/src/win32_monitor.c +++ b/src/win32_monitor.c @@ -32,7 +32,6 @@ #include #include #include -#include #include @@ -96,7 +95,7 @@ static _GLFWmonitor* createMonitor(DISPLAY_DEVICEW* adapter, DeleteDC(dc); monitor = _glfwAllocMonitor(name, widthMM, heightMM); - free(name); + _glfw_free(name); if (adapter->StateFlags & DISPLAY_DEVICE_MODESPRUNED) monitor->win32.modesPruned = GLFW_TRUE; @@ -145,7 +144,7 @@ void _glfwPollMonitorsWin32(void) disconnectedCount = _glfw.monitorCount; if (disconnectedCount) { - disconnected = calloc(_glfw.monitorCount, sizeof(_GLFWmonitor*)); + disconnected = _glfw_calloc(_glfw.monitorCount, sizeof(_GLFWmonitor*)); memcpy(disconnected, _glfw.monitors, _glfw.monitorCount * sizeof(_GLFWmonitor*)); @@ -197,7 +196,7 @@ void _glfwPollMonitorsWin32(void) monitor = createMonitor(&adapter, &display); if (!monitor) { - free(disconnected); + _glfw_free(disconnected); return; } @@ -227,7 +226,7 @@ void _glfwPollMonitorsWin32(void) monitor = createMonitor(&adapter, NULL); if (!monitor) { - free(disconnected); + _glfw_free(disconnected); return; } @@ -241,7 +240,7 @@ void _glfwPollMonitorsWin32(void) _glfwInputMonitor(disconnected[i], GLFW_DISCONNECTED, 0); } - free(disconnected); + _glfw_free(disconnected); } // Change the current video mode @@ -442,7 +441,7 @@ GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* count) if (*count == size) { size += 128; - result = (GLFWvidmode*) realloc(result, size * sizeof(GLFWvidmode)); + result = (GLFWvidmode*) _glfw_realloc(result, size * sizeof(GLFWvidmode)); } (*count)++; @@ -452,7 +451,7 @@ GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* count) if (!*count) { // HACK: Report the current mode if no valid modes were found - result = calloc(1, sizeof(GLFWvidmode)); + result = _glfw_calloc(1, sizeof(GLFWvidmode)); _glfwPlatformGetVideoMode(monitor, result); *count = 1; } diff --git a/src/win32_window.c b/src/win32_window.c index 13126292..80ae7c79 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -31,7 +31,6 @@ #include #include -#include #include #include #include @@ -884,8 +883,8 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, GetRawInputData(ri, RID_INPUT, NULL, &size, sizeof(RAWINPUTHEADER)); if (size > (UINT) _glfw.win32.rawInputSize) { - free(_glfw.win32.rawInput); - _glfw.win32.rawInput = calloc(size, 1); + _glfw_free(_glfw.win32.rawInput); + _glfw.win32.rawInput = _glfw_calloc(size, 1); _glfw.win32.rawInputSize = size; } @@ -1185,7 +1184,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, int i; const int count = DragQueryFileW(drop, 0xffffffff, NULL, 0); - char** paths = calloc(count, sizeof(char*)); + char** paths = _glfw_calloc(count, sizeof(char*)); // Move the mouse to the position of the drop DragQueryPoint(drop, &pt); @@ -1194,19 +1193,19 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, for (i = 0; i < count; i++) { const UINT length = DragQueryFileW(drop, i, NULL, 0); - WCHAR* buffer = calloc((size_t) length + 1, sizeof(WCHAR)); + WCHAR* buffer = _glfw_calloc((size_t) length + 1, sizeof(WCHAR)); DragQueryFileW(drop, i, buffer, length + 1); paths[i] = _glfwCreateUTF8FromWideStringWin32(buffer); - free(buffer); + _glfw_free(buffer); } _glfwInputDrop(window, count, (const char**) paths); for (i = 0; i < count; i++) - free(paths[i]); - free(paths); + _glfw_free(paths[i]); + _glfw_free(paths); DragFinish(drop); return 0; @@ -1269,7 +1268,7 @@ static int createNativeWindow(_GLFWwindow* window, GetModuleHandleW(NULL), (LPVOID) wndconfig); - free(wideTitle); + _glfw_free(wideTitle); if (!window->win32.handle) { @@ -1469,7 +1468,7 @@ void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title) return; SetWindowTextW(window->win32.handle, wideTitle); - free(wideTitle); + _glfw_free(wideTitle); } void _glfwPlatformSetWindowIcon(_GLFWwindow* window, @@ -2270,7 +2269,7 @@ const char* _glfwPlatformGetClipboardString(void) return NULL; } - free(_glfw.win32.clipboardString); + _glfw_free(_glfw.win32.clipboardString); _glfw.win32.clipboardString = _glfwCreateUTF8FromWideStringWin32(buffer); GlobalUnlock(object); @@ -2309,7 +2308,7 @@ EGLenum _glfwPlatformGetEGLPlatform(EGLint** attribs) if (type) { - *attribs = calloc(3, sizeof(EGLint)); + *attribs = _glfw_calloc(3, sizeof(EGLint)); (*attribs)[0] = EGL_PLATFORM_ANGLE_TYPE_ANGLE; (*attribs)[1] = type; (*attribs)[2] = EGL_NONE; diff --git a/src/window.c b/src/window.c index 518b27fd..93d8a14c 100644 --- a/src/window.c +++ b/src/window.c @@ -186,7 +186,7 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height, if (!_glfwIsValidContextConfig(&ctxconfig)) return NULL; - window = calloc(1, sizeof(_GLFWwindow)); + window = _glfw_calloc(1, sizeof(_GLFWwindow)); window->next = _glfw.windowListHead; _glfw.windowListHead = window; @@ -480,7 +480,7 @@ GLFWAPI void glfwDestroyWindow(GLFWwindow* handle) *prev = window->next; } - free(window); + _glfw_free(window); } GLFWAPI int glfwWindowShouldClose(GLFWwindow* handle) diff --git a/src/wl_init.c b/src/wl_init.c index 3d0236f2..f80b4950 100644 --- a/src/wl_init.c +++ b/src/wl_init.c @@ -1273,7 +1273,7 @@ int _glfwPlatformInit(void) wl_data_device_manager_get_data_device(_glfw.wl.dataDeviceManager, _glfw.wl.seat); wl_data_device_add_listener(_glfw.wl.dataDevice, &dataDeviceListener, NULL); - _glfw.wl.clipboardString = malloc(4096); + _glfw.wl.clipboardString = _glfw_calloc(4096, 1); if (!_glfw.wl.clipboardString) { _glfwInputError(GLFW_PLATFORM_ERROR, @@ -1369,9 +1369,9 @@ void _glfwPlatformTerminate(void) close(_glfw.wl.cursorTimerfd); if (_glfw.wl.clipboardString) - free(_glfw.wl.clipboardString); + _glfw_free(_glfw.wl.clipboardString); if (_glfw.wl.clipboardSendString) - free(_glfw.wl.clipboardSendString); + _glfw_free(_glfw.wl.clipboardSendString); } const char* _glfwPlatformGetVersionString(void) diff --git a/src/wl_monitor.c b/src/wl_monitor.c index 74907c79..11f586ad 100644 --- a/src/wl_monitor.c +++ b/src/wl_monitor.c @@ -77,7 +77,7 @@ static void outputHandleMode(void* data, monitor->modeCount++; monitor->modes = - realloc(monitor->modes, monitor->modeCount * sizeof(GLFWvidmode)); + _glfw_realloc(monitor->modes, monitor->modeCount * sizeof(GLFWvidmode)); monitor->modes[monitor->modeCount - 1] = mode; if (flags & WL_OUTPUT_MODE_CURRENT) diff --git a/src/wl_window.c b/src/wl_window.c index f8b50df1..dd6f26d5 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -112,12 +112,12 @@ static int createAnonymousFile(off_t size) return -1; } - name = calloc(strlen(path) + sizeof(template), 1); + name = _glfw_calloc(strlen(path) + sizeof(template), 1); strcpy(name, path); strcat(name, template); fd = createTmpfileCloexec(name); - free(name); + _glfw_free(name); if (fd < 0) return -1; } @@ -382,8 +382,8 @@ static void surfaceHandleEnter(void *data, { ++window->wl.monitorsSize; window->wl.monitors = - realloc(window->wl.monitors, - window->wl.monitorsSize * sizeof(_GLFWmonitor*)); + _glfw_realloc(window->wl.monitors, + window->wl.monitorsSize * sizeof(_GLFWmonitor*)); } window->wl.monitors[window->wl.monitorsCount++] = monitor; @@ -837,7 +837,7 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window, window->wl.currentCursor = NULL; - window->wl.monitors = calloc(1, sizeof(_GLFWmonitor*)); + window->wl.monitors = _glfw_calloc(1, sizeof(_GLFWmonitor*)); window->wl.monitorsCount = 0; window->wl.monitorsSize = 1; @@ -882,14 +882,14 @@ void _glfwPlatformDestroyWindow(_GLFWwindow* window) if (window->wl.surface) wl_surface_destroy(window->wl.surface); - free(window->wl.title); - free(window->wl.monitors); + _glfw_free(window->wl.title); + _glfw_free(window->wl.monitors); } void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title) { if (window->wl.title) - free(window->wl.title); + _glfw_free(window->wl.title); window->wl.title = _glfw_strdup(title); if (window->wl.xdg.toplevel) xdg_toplevel_set_title(window->wl.xdg.toplevel, title); @@ -1608,11 +1608,11 @@ void _glfwPlatformSetClipboardString(const char* string) if (_glfw.wl.clipboardSendString) { - free(_glfw.wl.clipboardSendString); + _glfw_free(_glfw.wl.clipboardSendString); _glfw.wl.clipboardSendString = NULL; } - _glfw.wl.clipboardSendString = strdup(string); + _glfw.wl.clipboardSendString = _glfw_strdup(string); if (!_glfw.wl.clipboardSendString) { _glfwInputError(GLFW_PLATFORM_ERROR, @@ -1626,7 +1626,7 @@ void _glfwPlatformSetClipboardString(const char* string) { _glfwInputError(GLFW_PLATFORM_ERROR, "Wayland: Impossible to create clipboard source"); - free(_glfw.wl.clipboardSendString); + _glfw_free(_glfw.wl.clipboardSendString); return; } wl_data_source_add_listener(_glfw.wl.dataSource, @@ -1642,7 +1642,7 @@ static GLFWbool growClipboardString(void) { char* clipboard = _glfw.wl.clipboardString; - clipboard = realloc(clipboard, _glfw.wl.clipboardSize * 2); + clipboard = _glfw_realloc(clipboard, _glfw.wl.clipboardSize * 2); if (!clipboard) { _glfwInputError(GLFW_PLATFORM_ERROR, diff --git a/src/x11_init.c b/src/x11_init.c index 6287514b..5a5154cc 100644 --- a/src/x11_init.c +++ b/src/x11_init.c @@ -1407,8 +1407,8 @@ void _glfwPlatformTerminate(void) _glfw.x11.hiddenCursorHandle = (Cursor) 0; } - free(_glfw.x11.primarySelectionString); - free(_glfw.x11.clipboardString); + _glfw_free(_glfw.x11.primarySelectionString); + _glfw_free(_glfw.x11.clipboardString); XUnregisterIMInstantiateCallback(_glfw.x11.display, NULL, NULL, NULL, diff --git a/src/x11_monitor.c b/src/x11_monitor.c index 8de86596..97da48db 100644 --- a/src/x11_monitor.c +++ b/src/x11_monitor.c @@ -116,7 +116,7 @@ void _glfwPollMonitorsX11(void) disconnectedCount = _glfw.monitorCount; if (disconnectedCount) { - disconnected = calloc(_glfw.monitorCount, sizeof(_GLFWmonitor*)); + disconnected = _glfw_calloc(_glfw.monitorCount, sizeof(_GLFWmonitor*)); memcpy(disconnected, _glfw.monitors, _glfw.monitorCount * sizeof(_GLFWmonitor*)); @@ -209,7 +209,7 @@ void _glfwPollMonitorsX11(void) _glfwInputMonitor(disconnected[i], GLFW_DISCONNECTED, 0); } - free(disconnected); + _glfw_free(disconnected); } else { @@ -450,7 +450,7 @@ GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* count) XRRCrtcInfo* ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc); XRROutputInfo* oi = XRRGetOutputInfo(_glfw.x11.display, sr, monitor->x11.output); - result = calloc(oi->nmode, sizeof(GLFWvidmode)); + result = _glfw_calloc(oi->nmode, sizeof(GLFWvidmode)); for (int i = 0; i < oi->nmode; i++) { @@ -482,7 +482,7 @@ GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* count) else { *count = 1; - result = calloc(1, sizeof(GLFWvidmode)); + result = _glfw_calloc(1, sizeof(GLFWvidmode)); _glfwPlatformGetVideoMode(monitor, result); } diff --git a/src/x11_window.c b/src/x11_window.c index a360c15c..297b975d 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -406,8 +406,8 @@ static char** parseUriList(char* text, int* count) (*count)++; - char* path = calloc(strlen(line) + 1, 1); - paths = realloc(paths, *count * sizeof(char*)); + char* path = _glfw_calloc(strlen(line) + 1, 1); + paths = _glfw_realloc(paths, *count * sizeof(char*)); paths[*count - 1] = path; while (*line) @@ -493,7 +493,7 @@ static char* convertLatin1toUTF8(const char* source) for (sp = source; *sp; sp++) size += (*sp & 0x80) ? 2 : 1; - char* target = calloc(size, 1); + char* target = _glfw_calloc(size, 1); char* tp = target; for (sp = source; *sp; sp++) @@ -924,12 +924,12 @@ static void handleSelectionClear(XEvent* event) { if (event->xselectionclear.selection == _glfw.x11.PRIMARY) { - free(_glfw.x11.primarySelectionString); + _glfw_free(_glfw.x11.primarySelectionString); _glfw.x11.primarySelectionString = NULL; } else { - free(_glfw.x11.clipboardString); + _glfw_free(_glfw.x11.clipboardString); _glfw.x11.clipboardString = NULL; } } @@ -968,7 +968,7 @@ static const char* getSelectionString(Atom selection) return *selectionString; } - free(*selectionString); + _glfw_free(*selectionString); *selectionString = NULL; for (size_t i = 0; i < targetCount; i++) @@ -1047,7 +1047,7 @@ static const char* getSelectionString(Atom selection) if (itemCount) { size += itemCount; - string = realloc(string, size); + string = _glfw_realloc(string, size); string[size - itemCount - 1] = '\0'; strcat(string, data); } @@ -1057,7 +1057,7 @@ static const char* getSelectionString(Atom selection) if (targets[i] == XA_STRING) { *selectionString = convertLatin1toUTF8(string); - free(string); + _glfw_free(string); } else *selectionString = string; @@ -1293,7 +1293,7 @@ static void processEvent(XEvent *event) if (status == XBufferOverflow) { - chars = calloc(count + 1, 1); + chars = _glfw_calloc(count + 1, 1); count = Xutf8LookupString(window->x11.ic, &event->xkey, chars, count, @@ -1309,7 +1309,7 @@ static void processEvent(XEvent *event) } if (chars != buffer) - free(chars); + _glfw_free(chars); } } else @@ -1724,8 +1724,8 @@ static void processEvent(XEvent *event) _glfwInputDrop(window, count, (const char**) paths); for (i = 0; i < count; i++) - free(paths[i]); - free(paths); + _glfw_free(paths[i]); + _glfw_free(paths); } if (data) @@ -2108,7 +2108,7 @@ void _glfwPlatformSetWindowIcon(_GLFWwindow* window, for (i = 0; i < count; i++) longCount += 2 + images[i].width * images[i].height; - long* icon = calloc(longCount, sizeof(long)); + long* icon = _glfw_calloc(longCount, sizeof(long)); long* target = icon; for (i = 0; i < count; i++) @@ -2132,7 +2132,7 @@ void _glfwPlatformSetWindowIcon(_GLFWwindow* window, (unsigned char*) icon, longCount); - free(icon); + _glfw_free(icon); } else { @@ -3045,7 +3045,7 @@ void _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor) void _glfwPlatformSetClipboardString(const char* string) { char* copy = _glfw_strdup(string); - free(_glfw.x11.clipboardString); + _glfw_free(_glfw.x11.clipboardString); _glfw.x11.clipboardString = copy; XSetSelectionOwner(_glfw.x11.display, @@ -3086,7 +3086,7 @@ EGLenum _glfwPlatformGetEGLPlatform(EGLint** attribs) if (type) { - *attribs = calloc(5, sizeof(EGLint)); + *attribs = _glfw_calloc(5, sizeof(EGLint)); (*attribs)[0] = EGL_PLATFORM_ANGLE_TYPE_ANGLE; (*attribs)[1] = type; (*attribs)[2] = EGL_PLATFORM_ANGLE_NATIVE_PLATFORM_TYPE_ANGLE; @@ -3286,7 +3286,7 @@ GLFWAPI void glfwSetX11SelectionString(const char* string) { _GLFW_REQUIRE_INIT(); - free(_glfw.x11.primarySelectionString); + _glfw_free(_glfw.x11.primarySelectionString); _glfw.x11.primarySelectionString = _glfw_strdup(string); XSetSelectionOwner(_glfw.x11.display, diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index a704bc07..0cc9db44 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -21,6 +21,7 @@ set(GETOPT "${GLFW_SOURCE_DIR}/deps/getopt.h" set(TINYCTHREAD "${GLFW_SOURCE_DIR}/deps/tinycthread.h" "${GLFW_SOURCE_DIR}/deps/tinycthread.c") +add_executable(allocator allocator.c ${GLAD_GL}) add_executable(clipboard clipboard.c ${GETOPT} ${GLAD_GL}) add_executable(events events.c ${GETOPT} ${GLAD_GL}) add_executable(msaa msaa.c ${GETOPT} ${GLAD_GL}) @@ -51,8 +52,8 @@ endif() set(GUI_ONLY_BINARIES empty gamma icon inputlag joysticks tearing threads timeout title triangle-vulkan window) -set(CONSOLE_BINARIES clipboard events msaa glfwinfo iconify monitors reopen - cursor) +set(CONSOLE_BINARIES allocator clipboard events msaa glfwinfo iconify monitors + reopen cursor) set_target_properties(${GUI_ONLY_BINARIES} ${CONSOLE_BINARIES} PROPERTIES C_STANDARD 99 diff --git a/tests/allocator.c b/tests/allocator.c new file mode 100644 index 00000000..ea9b6409 --- /dev/null +++ b/tests/allocator.c @@ -0,0 +1,141 @@ +//======================================================================== +// Custom heap allocator test +// Copyright (c) Camilla Löwy +// +// This software is provided 'as-is', without any express or implied +// warranty. In no event will the authors be held liable for any damages +// arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it +// freely, subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; you must not +// claim that you wrote the original software. If you use this software +// in a product, an acknowledgment in the product documentation would +// be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, and must not +// be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source +// distribution. +// +//======================================================================== + +#include +#define GLFW_INCLUDE_NONE +#include + +#include +#include +#include + +#define CALL(x) (function_name = #x, x) +static const char* function_name = NULL; + +struct allocator_stats +{ + size_t total; + size_t current; + size_t maximum; +}; + +static void error_callback(int error, const char* description) +{ + fprintf(stderr, "Error: %s\n", description); +} + +static void* allocate(size_t size, void* user) +{ + struct allocator_stats* stats = user; + assert(size > 0); + + stats->total += size; + stats->current += size; + if (stats->current > stats->maximum) + stats->maximum = stats->current; + + printf("%s: allocate %zu bytes (current %zu maximum %zu total %zu)\n", + function_name, size, stats->current, stats->maximum, stats->total); + + size_t* real_block = malloc(size + sizeof(size_t)); + assert(real_block != NULL); + *real_block = size; + return real_block + 1; +} + +static void deallocate(void* block, void* user) +{ + struct allocator_stats* stats = user; + assert(block != NULL); + + size_t* real_block = (size_t*) block - 1; + stats->current -= *real_block; + + printf("%s: deallocate %zu bytes (current %zu maximum %zu total %zu)\n", + function_name, *real_block, stats->current, stats->maximum, stats->total); + + free(real_block); +} + +static void* reallocate(void* block, size_t size, void* user) +{ + struct allocator_stats* stats = user; + assert(block != NULL); + assert(size > 0); + + size_t* real_block = (size_t*) block - 1; + stats->total += size; + stats->current += size - *real_block; + if (stats->current > stats->maximum) + stats->maximum = stats->current; + + printf("%s: reallocate %zu bytes to %zu bytes (current %zu maximum %zu total %zu)\n", + function_name, *real_block, size, stats->current, stats->maximum, stats->total); + + real_block = realloc(real_block, size + sizeof(size_t)); + assert(real_block != NULL); + *real_block = size; + return real_block + 1; +} + +int main(void) +{ + struct allocator_stats stats = {0}; + const GLFWallocator allocator = + { + .allocate = allocate, + .deallocate = deallocate, + .reallocate = reallocate, + .user = &stats + }; + + glfwSetErrorCallback(error_callback); + glfwInitAllocator(&allocator); + + if (!CALL(glfwInit)()) + exit(EXIT_FAILURE); + + GLFWwindow* window = CALL(glfwCreateWindow)(400, 400, "Custom allocator test", NULL, NULL); + if (!window) + { + glfwTerminate(); + exit(EXIT_FAILURE); + } + + CALL(glfwMakeContextCurrent)(window); + gladLoadGL(glfwGetProcAddress); + CALL(glfwSwapInterval)(1); + + while (!CALL(glfwWindowShouldClose)(window)) + { + glClear(GL_COLOR_BUFFER_BIT); + CALL(glfwSwapBuffers)(window); + CALL(glfwWaitEvents)(); + } + + CALL(glfwTerminate)(); + exit(EXIT_SUCCESS); +} + From 518e26e16e7a0204f28ed2669fb8e178197d81e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 16 Aug 2021 22:37:24 +0200 Subject: [PATCH 010/208] Add credit Related to #544. Related to #1947. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 018561e9..2ddb647f 100644 --- a/README.md +++ b/README.md @@ -448,6 +448,7 @@ skills. - Yoshiki Shibukawa - Dmitri Shuralyov - Daniel Skorupski + - Anthony Smith - Bradley Smith - Cliff Smolinsky - Patrick Snape From 62074f3dea0f3f2c63cb2d1263ca0f275ffc418b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 25 Aug 2021 01:18:03 +0200 Subject: [PATCH 011/208] Update glad2 and switch to header-only version This updates to a newer version of glad2 and switches to the header-only variant. This also (finally) switches to the newer glad2 loader signature that allows us to pass in glfwGetInstanceProcAddress directly. --- deps/glad/gl.h | 3676 ++++++++++++++++++++++++++++-------- deps/glad/khrplatform.h | 282 --- deps/glad/vk_platform.h | 92 - deps/glad/vulkan.h | 1550 +++++++++++++-- deps/glad_gl.c | 1791 ------------------ deps/glad_vulkan.c | 593 ------ examples/CMakeLists.txt | 3 +- examples/boing.c | 1 + examples/gears.c | 1 + examples/heightmap.c | 1 + examples/offscreen.c | 1 + examples/particles.c | 1 + examples/sharing.c | 1 + examples/splitview.c | 1 + examples/triangle-opengl.c | 1 + examples/wave.c | 1 + examples/windows.c | 1 + tests/CMakeLists.txt | 6 +- tests/allocator.c | 1 + tests/clipboard.c | 1 + tests/cursor.c | 1 + tests/empty.c | 1 + tests/events.c | 1 + tests/gamma.c | 1 + tests/glfwinfo.c | 11 +- tests/icon.c | 1 + tests/iconify.c | 1 + tests/inputlag.c | 1 + tests/joysticks.c | 1 + tests/monitors.c | 1 + tests/msaa.c | 1 + tests/reopen.c | 1 + tests/tearing.c | 1 + tests/threads.c | 1 + tests/timeout.c | 1 + tests/title.c | 1 + tests/triangle-vulkan.c | 14 +- tests/window.c | 1 + 38 files changed, 4297 insertions(+), 3749 deletions(-) delete mode 100644 deps/glad/khrplatform.h delete mode 100644 deps/glad/vk_platform.h delete mode 100644 deps/glad_gl.c delete mode 100644 deps/glad_vulkan.c diff --git a/deps/glad/gl.h b/deps/glad/gl.h index 5c7879f8..b421fe08 100644 --- a/deps/glad/gl.h +++ b/deps/glad/gl.h @@ -1,5 +1,5 @@ /** - * Loader generated by glad 2.0.0-beta on Sun Apr 14 17:03:32 2019 + * Loader generated by glad 2.0.0-beta on Tue Aug 24 22:51:07 2021 * * Generator: C/C++ * Specification: gl @@ -9,31 +9,51 @@ * - gl:compatibility=3.3 * * Options: - * - MX_GLOBAL = False - * - LOADER = False * - ALIAS = False - * - HEADER_ONLY = False * - DEBUG = False + * - HEADER_ONLY = True + * - LOADER = False * - MX = False + * - MX_GLOBAL = False + * - ON_DEMAND = False * * Commandline: - * --api='gl:compatibility=3.3' --extensions='GL_ARB_multisample,GL_ARB_robustness,GL_KHR_debug' c + * --api='gl:compatibility=3.3' --extensions='GL_ARB_multisample,GL_ARB_robustness,GL_KHR_debug' c --header-only * * Online: - * http://glad.sh/#api=gl%3Acompatibility%3D3.3&extensions=GL_ARB_multisample%2CGL_ARB_robustness%2CGL_KHR_debug&generator=c&options= + * http://glad.sh/#api=gl%3Acompatibility%3D3.3&extensions=GL_ARB_multisample%2CGL_ARB_robustness%2CGL_KHR_debug&generator=c&options=HEADER_ONLY * */ #ifndef GLAD_GL_H_ #define GLAD_GL_H_ +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wreserved-id-macro" +#endif #ifdef __gl_h_ - #error OpenGL header already included (API: gl), remove previous include! + #error OpenGL (gl.h) header already included (API: gl), remove previous include! #endif #define __gl_h_ 1 - +#ifdef __gl3_h_ + #error OpenGL (gl3.h) header already included (API: gl), remove previous include! +#endif +#define __gl3_h_ 1 +#ifdef __glext_h_ + #error OpenGL (glext.h) header already included (API: gl), remove previous include! +#endif +#define __glext_h_ 1 +#ifdef __gl3ext_h_ + #error OpenGL (gl3ext.h) header already included (API: gl), remove previous include! +#endif +#define __gl3ext_h_ 1 +#ifdef __clang__ +#pragma clang diagnostic pop +#endif #define GLAD_GL +#define GLAD_OPTION_GL_HEADER_ONLY #ifdef __cplusplus extern "C" { @@ -137,15 +157,16 @@ extern "C" { #define GLAPIENTRY GLAD_API_PTR #endif - #define GLAD_MAKE_VERSION(major, minor) (major * 10000 + minor) #define GLAD_VERSION_MAJOR(version) (version / 10000) #define GLAD_VERSION_MINOR(version) (version % 10000) +#define GLAD_GENERATOR_VERSION "2.0.0-beta" + typedef void (*GLADapiproc)(void); typedef GLADapiproc (*GLADloadfunc)(const char *name); -typedef GLADapiproc (*GLADuserptrloadfunc)(const char *name, void *userptr); +typedef GLADapiproc (*GLADuserptrloadfunc)(void *userptr, const char *name); typedef void (*GLADprecallback)(const char *name, GLADapiproc apiproc, int len_args, ...); typedef void (*GLADpostcallback)(void *ret, const char *name, GLADapiproc apiproc, int len_args, ...); @@ -1458,69 +1479,401 @@ typedef void (*GLADpostcallback)(void *ret, const char *name, GLADapiproc apipro #define GL_ZOOM_Y 0x0D17 -#include +#ifndef __khrplatform_h_ +#define __khrplatform_h_ + +/* +** Copyright (c) 2008-2018 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +/* Khronos platform-specific types and definitions. + * + * The master copy of khrplatform.h is maintained in the Khronos EGL + * Registry repository at https://github.com/KhronosGroup/EGL-Registry + * The last semantic modification to khrplatform.h was at commit ID: + * 67a3e0864c2d75ea5287b9f3d2eb74a745936692 + * + * Adopters may modify this file to suit their platform. Adopters are + * encouraged to submit platform specific modifications to the Khronos + * group so that they can be included in future versions of this file. + * Please submit changes by filing pull requests or issues on + * the EGL Registry repository linked above. + * + * + * See the Implementer's Guidelines for information about where this file + * should be located on your system and for more details of its use: + * http://www.khronos.org/registry/implementers_guide.pdf + * + * This file should be included as + * #include + * by Khronos client API header files that use its types and defines. + * + * The types in khrplatform.h should only be used to define API-specific types. + * + * Types defined in khrplatform.h: + * khronos_int8_t signed 8 bit + * khronos_uint8_t unsigned 8 bit + * khronos_int16_t signed 16 bit + * khronos_uint16_t unsigned 16 bit + * khronos_int32_t signed 32 bit + * khronos_uint32_t unsigned 32 bit + * khronos_int64_t signed 64 bit + * khronos_uint64_t unsigned 64 bit + * khronos_intptr_t signed same number of bits as a pointer + * khronos_uintptr_t unsigned same number of bits as a pointer + * khronos_ssize_t signed size + * khronos_usize_t unsigned size + * khronos_float_t signed 32 bit floating point + * khronos_time_ns_t unsigned 64 bit time in nanoseconds + * khronos_utime_nanoseconds_t unsigned time interval or absolute time in + * nanoseconds + * khronos_stime_nanoseconds_t signed time interval in nanoseconds + * khronos_boolean_enum_t enumerated boolean type. This should + * only be used as a base type when a client API's boolean type is + * an enum. Client APIs which use an integer or other type for + * booleans cannot use this as the base type for their boolean. + * + * Tokens defined in khrplatform.h: + * + * KHRONOS_FALSE, KHRONOS_TRUE Enumerated boolean false/true values. + * + * KHRONOS_SUPPORT_INT64 is 1 if 64 bit integers are supported; otherwise 0. + * KHRONOS_SUPPORT_FLOAT is 1 if floats are supported; otherwise 0. + * + * Calling convention macros defined in this file: + * KHRONOS_APICALL + * KHRONOS_GLAD_API_PTR + * KHRONOS_APIATTRIBUTES + * + * These may be used in function prototypes as: + * + * KHRONOS_APICALL void KHRONOS_GLAD_API_PTR funcname( + * int arg1, + * int arg2) KHRONOS_APIATTRIBUTES; + */ + +#if defined(__SCITECH_SNAP__) && !defined(KHRONOS_STATIC) +# define KHRONOS_STATIC 1 +#endif + +/*------------------------------------------------------------------------- + * Definition of KHRONOS_APICALL + *------------------------------------------------------------------------- + * This precedes the return type of the function in the function prototype. + */ +#if defined(KHRONOS_STATIC) + /* If the preprocessor constant KHRONOS_STATIC is defined, make the + * header compatible with static linking. */ +# define KHRONOS_APICALL +#elif defined(_WIN32) +# define KHRONOS_APICALL __declspec(dllimport) +#elif defined (__SYMBIAN32__) +# define KHRONOS_APICALL IMPORT_C +#elif defined(__ANDROID__) +# define KHRONOS_APICALL __attribute__((visibility("default"))) +#else +# define KHRONOS_APICALL +#endif + +/*------------------------------------------------------------------------- + * Definition of KHRONOS_GLAD_API_PTR + *------------------------------------------------------------------------- + * This follows the return type of the function and precedes the function + * name in the function prototype. + */ +#if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(__SCITECH_SNAP__) + /* Win32 but not WinCE */ +# define KHRONOS_GLAD_API_PTR __stdcall +#else +# define KHRONOS_GLAD_API_PTR +#endif + +/*------------------------------------------------------------------------- + * Definition of KHRONOS_APIATTRIBUTES + *------------------------------------------------------------------------- + * This follows the closing parenthesis of the function prototype arguments. + */ +#if defined (__ARMCC_2__) +#define KHRONOS_APIATTRIBUTES __softfp +#else +#define KHRONOS_APIATTRIBUTES +#endif + +/*------------------------------------------------------------------------- + * basic type definitions + *-----------------------------------------------------------------------*/ +#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__GNUC__) || defined(__SCO__) || defined(__USLC__) + + +/* + * Using + */ +#include +typedef int32_t khronos_int32_t; +typedef uint32_t khronos_uint32_t; +typedef int64_t khronos_int64_t; +typedef uint64_t khronos_uint64_t; +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 + +#elif defined(__VMS ) || defined(__sgi) + +/* + * Using + */ +#include +typedef int32_t khronos_int32_t; +typedef uint32_t khronos_uint32_t; +typedef int64_t khronos_int64_t; +typedef uint64_t khronos_uint64_t; +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 + +#elif defined(_WIN32) && !defined(__SCITECH_SNAP__) + +/* + * Win32 + */ +typedef __int32 khronos_int32_t; +typedef unsigned __int32 khronos_uint32_t; +typedef __int64 khronos_int64_t; +typedef unsigned __int64 khronos_uint64_t; +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 + +#elif defined(__sun__) || defined(__digital__) + +/* + * Sun or Digital + */ +typedef int khronos_int32_t; +typedef unsigned int khronos_uint32_t; +#if defined(__arch64__) || defined(_LP64) +typedef long int khronos_int64_t; +typedef unsigned long int khronos_uint64_t; +#else +typedef long long int khronos_int64_t; +typedef unsigned long long int khronos_uint64_t; +#endif /* __arch64__ */ +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 + +#elif 0 + +/* + * Hypothetical platform with no float or int64 support + */ +typedef int khronos_int32_t; +typedef unsigned int khronos_uint32_t; +#define KHRONOS_SUPPORT_INT64 0 +#define KHRONOS_SUPPORT_FLOAT 0 + +#else + +/* + * Generic fallback + */ +#include +typedef int32_t khronos_int32_t; +typedef uint32_t khronos_uint32_t; +typedef int64_t khronos_int64_t; +typedef uint64_t khronos_uint64_t; +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 + +#endif + + +/* + * Types that are (so far) the same on all platforms + */ +typedef signed char khronos_int8_t; +typedef unsigned char khronos_uint8_t; +typedef signed short int khronos_int16_t; +typedef unsigned short int khronos_uint16_t; + +/* + * Types that differ between LLP64 and LP64 architectures - in LLP64, + * pointers are 64 bits, but 'long' is still 32 bits. Win64 appears + * to be the only LLP64 architecture in current use. + */ +#ifdef _WIN64 +typedef signed long long int khronos_intptr_t; +typedef unsigned long long int khronos_uintptr_t; +typedef signed long long int khronos_ssize_t; +typedef unsigned long long int khronos_usize_t; +#else +typedef signed long int khronos_intptr_t; +typedef unsigned long int khronos_uintptr_t; +typedef signed long int khronos_ssize_t; +typedef unsigned long int khronos_usize_t; +#endif + +#if KHRONOS_SUPPORT_FLOAT +/* + * Float type + */ +typedef float khronos_float_t; +#endif + +#if KHRONOS_SUPPORT_INT64 +/* Time types + * + * These types can be used to represent a time interval in nanoseconds or + * an absolute Unadjusted System Time. Unadjusted System Time is the number + * of nanoseconds since some arbitrary system event (e.g. since the last + * time the system booted). The Unadjusted System Time is an unsigned + * 64 bit value that wraps back to 0 every 584 years. Time intervals + * may be either signed or unsigned. + */ +typedef khronos_uint64_t khronos_utime_nanoseconds_t; +typedef khronos_int64_t khronos_stime_nanoseconds_t; +#endif + +/* + * Dummy value used to pad enum types to 32 bits. + */ +#ifndef KHRONOS_MAX_ENUM +#define KHRONOS_MAX_ENUM 0x7FFFFFFF +#endif + +/* + * Enumerated boolean type + * + * Values other than zero should be considered to be true. Therefore + * comparisons should not be made against KHRONOS_TRUE. + */ +typedef enum { + KHRONOS_FALSE = 0, + KHRONOS_TRUE = 1, + KHRONOS_BOOLEAN_ENUM_FORCE_SIZE = KHRONOS_MAX_ENUM +} khronos_boolean_enum_t; + +#endif /* __khrplatform_h_ */ + typedef unsigned int GLenum; + typedef unsigned char GLboolean; + typedef unsigned int GLbitfield; + typedef void GLvoid; + typedef khronos_int8_t GLbyte; + typedef khronos_uint8_t GLubyte; + typedef khronos_int16_t GLshort; + typedef khronos_uint16_t GLushort; + typedef int GLint; + typedef unsigned int GLuint; + typedef khronos_int32_t GLclampx; + typedef int GLsizei; + typedef khronos_float_t GLfloat; + typedef khronos_float_t GLclampf; + typedef double GLdouble; + typedef double GLclampd; + typedef void *GLeglClientBufferEXT; + typedef void *GLeglImageOES; + typedef char GLchar; + typedef char GLcharARB; + #ifdef __APPLE__ typedef void *GLhandleARB; #else typedef unsigned int GLhandleARB; #endif + typedef khronos_uint16_t GLhalf; + typedef khronos_uint16_t GLhalfARB; + typedef khronos_int32_t GLfixed; + #if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ > 1060) typedef khronos_intptr_t GLintptr; #else typedef khronos_intptr_t GLintptr; #endif + #if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ > 1060) typedef khronos_intptr_t GLintptrARB; #else typedef khronos_intptr_t GLintptrARB; #endif + #if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ > 1060) typedef khronos_ssize_t GLsizeiptr; #else typedef khronos_ssize_t GLsizeiptr; #endif + #if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ > 1060) typedef khronos_ssize_t GLsizeiptrARB; #else typedef khronos_ssize_t GLsizeiptrARB; #endif + typedef khronos_int64_t GLint64; + typedef khronos_int64_t GLint64EXT; + typedef khronos_uint64_t GLuint64; + typedef khronos_uint64_t GLuint64EXT; + typedef struct __GLsync *GLsync; + struct _cl_context; + struct _cl_event; -typedef void ( *GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam); -typedef void ( *GLDEBUGPROCARB)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam); -typedef void ( *GLDEBUGPROCKHR)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam); -typedef void ( *GLDEBUGPROCAMD)(GLuint id,GLenum category,GLenum severity,GLsizei length,const GLchar *message,void *userParam); + +typedef void (GLAD_API_PTR *GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam); + +typedef void (GLAD_API_PTR *GLDEBUGPROCARB)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam); + +typedef void (GLAD_API_PTR *GLDEBUGPROCKHR)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam); + +typedef void (GLAD_API_PTR *GLDEBUGPROCAMD)(GLuint id,GLenum category,GLenum severity,GLsizei length,const GLchar *message,void *userParam); + typedef unsigned short GLhalfNV; + typedef GLintptr GLvdpauSurfaceNV; -typedef void ( *GLVULKANPROCNV)(void); + +typedef void (GLAD_API_PTR *GLVULKANPROCNV)(void); + #define GL_VERSION_1_0 1 @@ -1555,762 +1908,761 @@ GLAD_API_CALL int GLAD_GL_ARB_robustness; GLAD_API_CALL int GLAD_GL_KHR_debug; -typedef void (GLAD_API_PTR *PFNGLACCUMPROC)(GLenum op, GLfloat value); -typedef void (GLAD_API_PTR *PFNGLACTIVETEXTUREPROC)(GLenum texture); -typedef void (GLAD_API_PTR *PFNGLALPHAFUNCPROC)(GLenum func, GLfloat ref); -typedef GLboolean (GLAD_API_PTR *PFNGLARETEXTURESRESIDENTPROC)(GLsizei n, const GLuint * textures, GLboolean * residences); -typedef void (GLAD_API_PTR *PFNGLARRAYELEMENTPROC)(GLint i); -typedef void (GLAD_API_PTR *PFNGLATTACHSHADERPROC)(GLuint program, GLuint shader); -typedef void (GLAD_API_PTR *PFNGLBEGINPROC)(GLenum mode); -typedef void (GLAD_API_PTR *PFNGLBEGINCONDITIONALRENDERPROC)(GLuint id, GLenum mode); -typedef void (GLAD_API_PTR *PFNGLBEGINQUERYPROC)(GLenum target, GLuint id); -typedef void (GLAD_API_PTR *PFNGLBEGINTRANSFORMFEEDBACKPROC)(GLenum primitiveMode); -typedef void (GLAD_API_PTR *PFNGLBINDATTRIBLOCATIONPROC)(GLuint program, GLuint index, const GLchar * name); -typedef void (GLAD_API_PTR *PFNGLBINDBUFFERPROC)(GLenum target, GLuint buffer); -typedef void (GLAD_API_PTR *PFNGLBINDBUFFERBASEPROC)(GLenum target, GLuint index, GLuint buffer); -typedef void (GLAD_API_PTR *PFNGLBINDBUFFERRANGEPROC)(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); -typedef void (GLAD_API_PTR *PFNGLBINDFRAGDATALOCATIONPROC)(GLuint program, GLuint color, const GLchar * name); -typedef void (GLAD_API_PTR *PFNGLBINDFRAGDATALOCATIONINDEXEDPROC)(GLuint program, GLuint colorNumber, GLuint index, const GLchar * name); -typedef void (GLAD_API_PTR *PFNGLBINDFRAMEBUFFERPROC)(GLenum target, GLuint framebuffer); -typedef void (GLAD_API_PTR *PFNGLBINDRENDERBUFFERPROC)(GLenum target, GLuint renderbuffer); -typedef void (GLAD_API_PTR *PFNGLBINDSAMPLERPROC)(GLuint unit, GLuint sampler); -typedef void (GLAD_API_PTR *PFNGLBINDTEXTUREPROC)(GLenum target, GLuint texture); -typedef void (GLAD_API_PTR *PFNGLBINDVERTEXARRAYPROC)(GLuint array); -typedef void (GLAD_API_PTR *PFNGLBITMAPPROC)(GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, const GLubyte * bitmap); -typedef void (GLAD_API_PTR *PFNGLBLENDCOLORPROC)(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); -typedef void (GLAD_API_PTR *PFNGLBLENDEQUATIONPROC)(GLenum mode); -typedef void (GLAD_API_PTR *PFNGLBLENDEQUATIONSEPARATEPROC)(GLenum modeRGB, GLenum modeAlpha); -typedef void (GLAD_API_PTR *PFNGLBLENDFUNCPROC)(GLenum sfactor, GLenum dfactor); -typedef void (GLAD_API_PTR *PFNGLBLENDFUNCSEPARATEPROC)(GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); -typedef void (GLAD_API_PTR *PFNGLBLITFRAMEBUFFERPROC)(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); -typedef void (GLAD_API_PTR *PFNGLBUFFERDATAPROC)(GLenum target, GLsizeiptr size, const void * data, GLenum usage); -typedef void (GLAD_API_PTR *PFNGLBUFFERSUBDATAPROC)(GLenum target, GLintptr offset, GLsizeiptr size, const void * data); -typedef void (GLAD_API_PTR *PFNGLCALLLISTPROC)(GLuint list); -typedef void (GLAD_API_PTR *PFNGLCALLLISTSPROC)(GLsizei n, GLenum type, const void * lists); -typedef GLenum (GLAD_API_PTR *PFNGLCHECKFRAMEBUFFERSTATUSPROC)(GLenum target); -typedef void (GLAD_API_PTR *PFNGLCLAMPCOLORPROC)(GLenum target, GLenum clamp); -typedef void (GLAD_API_PTR *PFNGLCLEARPROC)(GLbitfield mask); -typedef void (GLAD_API_PTR *PFNGLCLEARACCUMPROC)(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); -typedef void (GLAD_API_PTR *PFNGLCLEARBUFFERFIPROC)(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); -typedef void (GLAD_API_PTR *PFNGLCLEARBUFFERFVPROC)(GLenum buffer, GLint drawbuffer, const GLfloat * value); -typedef void (GLAD_API_PTR *PFNGLCLEARBUFFERIVPROC)(GLenum buffer, GLint drawbuffer, const GLint * value); -typedef void (GLAD_API_PTR *PFNGLCLEARBUFFERUIVPROC)(GLenum buffer, GLint drawbuffer, const GLuint * value); -typedef void (GLAD_API_PTR *PFNGLCLEARCOLORPROC)(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); -typedef void (GLAD_API_PTR *PFNGLCLEARDEPTHPROC)(GLdouble depth); -typedef void (GLAD_API_PTR *PFNGLCLEARINDEXPROC)(GLfloat c); -typedef void (GLAD_API_PTR *PFNGLCLEARSTENCILPROC)(GLint s); -typedef void (GLAD_API_PTR *PFNGLCLIENTACTIVETEXTUREPROC)(GLenum texture); -typedef GLenum (GLAD_API_PTR *PFNGLCLIENTWAITSYNCPROC)(GLsync sync, GLbitfield flags, GLuint64 timeout); -typedef void (GLAD_API_PTR *PFNGLCLIPPLANEPROC)(GLenum plane, const GLdouble * equation); -typedef void (GLAD_API_PTR *PFNGLCOLOR3BPROC)(GLbyte red, GLbyte green, GLbyte blue); -typedef void (GLAD_API_PTR *PFNGLCOLOR3BVPROC)(const GLbyte * v); -typedef void (GLAD_API_PTR *PFNGLCOLOR3DPROC)(GLdouble red, GLdouble green, GLdouble blue); -typedef void (GLAD_API_PTR *PFNGLCOLOR3DVPROC)(const GLdouble * v); -typedef void (GLAD_API_PTR *PFNGLCOLOR3FPROC)(GLfloat red, GLfloat green, GLfloat blue); -typedef void (GLAD_API_PTR *PFNGLCOLOR3FVPROC)(const GLfloat * v); -typedef void (GLAD_API_PTR *PFNGLCOLOR3IPROC)(GLint red, GLint green, GLint blue); -typedef void (GLAD_API_PTR *PFNGLCOLOR3IVPROC)(const GLint * v); -typedef void (GLAD_API_PTR *PFNGLCOLOR3SPROC)(GLshort red, GLshort green, GLshort blue); -typedef void (GLAD_API_PTR *PFNGLCOLOR3SVPROC)(const GLshort * v); -typedef void (GLAD_API_PTR *PFNGLCOLOR3UBPROC)(GLubyte red, GLubyte green, GLubyte blue); -typedef void (GLAD_API_PTR *PFNGLCOLOR3UBVPROC)(const GLubyte * v); -typedef void (GLAD_API_PTR *PFNGLCOLOR3UIPROC)(GLuint red, GLuint green, GLuint blue); -typedef void (GLAD_API_PTR *PFNGLCOLOR3UIVPROC)(const GLuint * v); -typedef void (GLAD_API_PTR *PFNGLCOLOR3USPROC)(GLushort red, GLushort green, GLushort blue); -typedef void (GLAD_API_PTR *PFNGLCOLOR3USVPROC)(const GLushort * v); -typedef void (GLAD_API_PTR *PFNGLCOLOR4BPROC)(GLbyte red, GLbyte green, GLbyte blue, GLbyte alpha); -typedef void (GLAD_API_PTR *PFNGLCOLOR4BVPROC)(const GLbyte * v); -typedef void (GLAD_API_PTR *PFNGLCOLOR4DPROC)(GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha); -typedef void (GLAD_API_PTR *PFNGLCOLOR4DVPROC)(const GLdouble * v); -typedef void (GLAD_API_PTR *PFNGLCOLOR4FPROC)(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); -typedef void (GLAD_API_PTR *PFNGLCOLOR4FVPROC)(const GLfloat * v); -typedef void (GLAD_API_PTR *PFNGLCOLOR4IPROC)(GLint red, GLint green, GLint blue, GLint alpha); -typedef void (GLAD_API_PTR *PFNGLCOLOR4IVPROC)(const GLint * v); -typedef void (GLAD_API_PTR *PFNGLCOLOR4SPROC)(GLshort red, GLshort green, GLshort blue, GLshort alpha); -typedef void (GLAD_API_PTR *PFNGLCOLOR4SVPROC)(const GLshort * v); -typedef void (GLAD_API_PTR *PFNGLCOLOR4UBPROC)(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha); -typedef void (GLAD_API_PTR *PFNGLCOLOR4UBVPROC)(const GLubyte * v); -typedef void (GLAD_API_PTR *PFNGLCOLOR4UIPROC)(GLuint red, GLuint green, GLuint blue, GLuint alpha); -typedef void (GLAD_API_PTR *PFNGLCOLOR4UIVPROC)(const GLuint * v); -typedef void (GLAD_API_PTR *PFNGLCOLOR4USPROC)(GLushort red, GLushort green, GLushort blue, GLushort alpha); -typedef void (GLAD_API_PTR *PFNGLCOLOR4USVPROC)(const GLushort * v); -typedef void (GLAD_API_PTR *PFNGLCOLORMASKPROC)(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); -typedef void (GLAD_API_PTR *PFNGLCOLORMASKIPROC)(GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); -typedef void (GLAD_API_PTR *PFNGLCOLORMATERIALPROC)(GLenum face, GLenum mode); -typedef void (GLAD_API_PTR *PFNGLCOLORP3UIPROC)(GLenum type, GLuint color); -typedef void (GLAD_API_PTR *PFNGLCOLORP3UIVPROC)(GLenum type, const GLuint * color); -typedef void (GLAD_API_PTR *PFNGLCOLORP4UIPROC)(GLenum type, GLuint color); -typedef void (GLAD_API_PTR *PFNGLCOLORP4UIVPROC)(GLenum type, const GLuint * color); -typedef void (GLAD_API_PTR *PFNGLCOLORPOINTERPROC)(GLint size, GLenum type, GLsizei stride, const void * pointer); -typedef void (GLAD_API_PTR *PFNGLCOMPILESHADERPROC)(GLuint shader); -typedef void (GLAD_API_PTR *PFNGLCOMPRESSEDTEXIMAGE1DPROC)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void * data); -typedef void (GLAD_API_PTR *PFNGLCOMPRESSEDTEXIMAGE2DPROC)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void * data); -typedef void (GLAD_API_PTR *PFNGLCOMPRESSEDTEXIMAGE3DPROC)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void * data); -typedef void (GLAD_API_PTR *PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC)(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void * data); -typedef void (GLAD_API_PTR *PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void * data); -typedef void (GLAD_API_PTR *PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void * data); -typedef void (GLAD_API_PTR *PFNGLCOPYBUFFERSUBDATAPROC)(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); -typedef void (GLAD_API_PTR *PFNGLCOPYPIXELSPROC)(GLint x, GLint y, GLsizei width, GLsizei height, GLenum type); -typedef void (GLAD_API_PTR *PFNGLCOPYTEXIMAGE1DPROC)(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); -typedef void (GLAD_API_PTR *PFNGLCOPYTEXIMAGE2DPROC)(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); -typedef void (GLAD_API_PTR *PFNGLCOPYTEXSUBIMAGE1DPROC)(GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); -typedef void (GLAD_API_PTR *PFNGLCOPYTEXSUBIMAGE2DPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (GLAD_API_PTR *PFNGLCOPYTEXSUBIMAGE3DPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (GLAD_API_PTR *PFNGLACCUMPROC)(GLenum op, GLfloat value); +typedef void (GLAD_API_PTR *PFNGLACTIVETEXTUREPROC)(GLenum texture); +typedef void (GLAD_API_PTR *PFNGLALPHAFUNCPROC)(GLenum func, GLfloat ref); +typedef GLboolean (GLAD_API_PTR *PFNGLARETEXTURESRESIDENTPROC)(GLsizei n, const GLuint * textures, GLboolean * residences); +typedef void (GLAD_API_PTR *PFNGLARRAYELEMENTPROC)(GLint i); +typedef void (GLAD_API_PTR *PFNGLATTACHSHADERPROC)(GLuint program, GLuint shader); +typedef void (GLAD_API_PTR *PFNGLBEGINPROC)(GLenum mode); +typedef void (GLAD_API_PTR *PFNGLBEGINCONDITIONALRENDERPROC)(GLuint id, GLenum mode); +typedef void (GLAD_API_PTR *PFNGLBEGINQUERYPROC)(GLenum target, GLuint id); +typedef void (GLAD_API_PTR *PFNGLBEGINTRANSFORMFEEDBACKPROC)(GLenum primitiveMode); +typedef void (GLAD_API_PTR *PFNGLBINDATTRIBLOCATIONPROC)(GLuint program, GLuint index, const GLchar * name); +typedef void (GLAD_API_PTR *PFNGLBINDBUFFERPROC)(GLenum target, GLuint buffer); +typedef void (GLAD_API_PTR *PFNGLBINDBUFFERBASEPROC)(GLenum target, GLuint index, GLuint buffer); +typedef void (GLAD_API_PTR *PFNGLBINDBUFFERRANGEPROC)(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (GLAD_API_PTR *PFNGLBINDFRAGDATALOCATIONPROC)(GLuint program, GLuint color, const GLchar * name); +typedef void (GLAD_API_PTR *PFNGLBINDFRAGDATALOCATIONINDEXEDPROC)(GLuint program, GLuint colorNumber, GLuint index, const GLchar * name); +typedef void (GLAD_API_PTR *PFNGLBINDFRAMEBUFFERPROC)(GLenum target, GLuint framebuffer); +typedef void (GLAD_API_PTR *PFNGLBINDRENDERBUFFERPROC)(GLenum target, GLuint renderbuffer); +typedef void (GLAD_API_PTR *PFNGLBINDSAMPLERPROC)(GLuint unit, GLuint sampler); +typedef void (GLAD_API_PTR *PFNGLBINDTEXTUREPROC)(GLenum target, GLuint texture); +typedef void (GLAD_API_PTR *PFNGLBINDVERTEXARRAYPROC)(GLuint array); +typedef void (GLAD_API_PTR *PFNGLBITMAPPROC)(GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, const GLubyte * bitmap); +typedef void (GLAD_API_PTR *PFNGLBLENDCOLORPROC)(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +typedef void (GLAD_API_PTR *PFNGLBLENDEQUATIONPROC)(GLenum mode); +typedef void (GLAD_API_PTR *PFNGLBLENDEQUATIONSEPARATEPROC)(GLenum modeRGB, GLenum modeAlpha); +typedef void (GLAD_API_PTR *PFNGLBLENDFUNCPROC)(GLenum sfactor, GLenum dfactor); +typedef void (GLAD_API_PTR *PFNGLBLENDFUNCSEPARATEPROC)(GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +typedef void (GLAD_API_PTR *PFNGLBLITFRAMEBUFFERPROC)(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +typedef void (GLAD_API_PTR *PFNGLBUFFERDATAPROC)(GLenum target, GLsizeiptr size, const void * data, GLenum usage); +typedef void (GLAD_API_PTR *PFNGLBUFFERSUBDATAPROC)(GLenum target, GLintptr offset, GLsizeiptr size, const void * data); +typedef void (GLAD_API_PTR *PFNGLCALLLISTPROC)(GLuint list); +typedef void (GLAD_API_PTR *PFNGLCALLLISTSPROC)(GLsizei n, GLenum type, const void * lists); +typedef GLenum (GLAD_API_PTR *PFNGLCHECKFRAMEBUFFERSTATUSPROC)(GLenum target); +typedef void (GLAD_API_PTR *PFNGLCLAMPCOLORPROC)(GLenum target, GLenum clamp); +typedef void (GLAD_API_PTR *PFNGLCLEARPROC)(GLbitfield mask); +typedef void (GLAD_API_PTR *PFNGLCLEARACCUMPROC)(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +typedef void (GLAD_API_PTR *PFNGLCLEARBUFFERFIPROC)(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); +typedef void (GLAD_API_PTR *PFNGLCLEARBUFFERFVPROC)(GLenum buffer, GLint drawbuffer, const GLfloat * value); +typedef void (GLAD_API_PTR *PFNGLCLEARBUFFERIVPROC)(GLenum buffer, GLint drawbuffer, const GLint * value); +typedef void (GLAD_API_PTR *PFNGLCLEARBUFFERUIVPROC)(GLenum buffer, GLint drawbuffer, const GLuint * value); +typedef void (GLAD_API_PTR *PFNGLCLEARCOLORPROC)(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +typedef void (GLAD_API_PTR *PFNGLCLEARDEPTHPROC)(GLdouble depth); +typedef void (GLAD_API_PTR *PFNGLCLEARINDEXPROC)(GLfloat c); +typedef void (GLAD_API_PTR *PFNGLCLEARSTENCILPROC)(GLint s); +typedef void (GLAD_API_PTR *PFNGLCLIENTACTIVETEXTUREPROC)(GLenum texture); +typedef GLenum (GLAD_API_PTR *PFNGLCLIENTWAITSYNCPROC)(GLsync sync, GLbitfield flags, GLuint64 timeout); +typedef void (GLAD_API_PTR *PFNGLCLIPPLANEPROC)(GLenum plane, const GLdouble * equation); +typedef void (GLAD_API_PTR *PFNGLCOLOR3BPROC)(GLbyte red, GLbyte green, GLbyte blue); +typedef void (GLAD_API_PTR *PFNGLCOLOR3BVPROC)(const GLbyte * v); +typedef void (GLAD_API_PTR *PFNGLCOLOR3DPROC)(GLdouble red, GLdouble green, GLdouble blue); +typedef void (GLAD_API_PTR *PFNGLCOLOR3DVPROC)(const GLdouble * v); +typedef void (GLAD_API_PTR *PFNGLCOLOR3FPROC)(GLfloat red, GLfloat green, GLfloat blue); +typedef void (GLAD_API_PTR *PFNGLCOLOR3FVPROC)(const GLfloat * v); +typedef void (GLAD_API_PTR *PFNGLCOLOR3IPROC)(GLint red, GLint green, GLint blue); +typedef void (GLAD_API_PTR *PFNGLCOLOR3IVPROC)(const GLint * v); +typedef void (GLAD_API_PTR *PFNGLCOLOR3SPROC)(GLshort red, GLshort green, GLshort blue); +typedef void (GLAD_API_PTR *PFNGLCOLOR3SVPROC)(const GLshort * v); +typedef void (GLAD_API_PTR *PFNGLCOLOR3UBPROC)(GLubyte red, GLubyte green, GLubyte blue); +typedef void (GLAD_API_PTR *PFNGLCOLOR3UBVPROC)(const GLubyte * v); +typedef void (GLAD_API_PTR *PFNGLCOLOR3UIPROC)(GLuint red, GLuint green, GLuint blue); +typedef void (GLAD_API_PTR *PFNGLCOLOR3UIVPROC)(const GLuint * v); +typedef void (GLAD_API_PTR *PFNGLCOLOR3USPROC)(GLushort red, GLushort green, GLushort blue); +typedef void (GLAD_API_PTR *PFNGLCOLOR3USVPROC)(const GLushort * v); +typedef void (GLAD_API_PTR *PFNGLCOLOR4BPROC)(GLbyte red, GLbyte green, GLbyte blue, GLbyte alpha); +typedef void (GLAD_API_PTR *PFNGLCOLOR4BVPROC)(const GLbyte * v); +typedef void (GLAD_API_PTR *PFNGLCOLOR4DPROC)(GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha); +typedef void (GLAD_API_PTR *PFNGLCOLOR4DVPROC)(const GLdouble * v); +typedef void (GLAD_API_PTR *PFNGLCOLOR4FPROC)(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +typedef void (GLAD_API_PTR *PFNGLCOLOR4FVPROC)(const GLfloat * v); +typedef void (GLAD_API_PTR *PFNGLCOLOR4IPROC)(GLint red, GLint green, GLint blue, GLint alpha); +typedef void (GLAD_API_PTR *PFNGLCOLOR4IVPROC)(const GLint * v); +typedef void (GLAD_API_PTR *PFNGLCOLOR4SPROC)(GLshort red, GLshort green, GLshort blue, GLshort alpha); +typedef void (GLAD_API_PTR *PFNGLCOLOR4SVPROC)(const GLshort * v); +typedef void (GLAD_API_PTR *PFNGLCOLOR4UBPROC)(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha); +typedef void (GLAD_API_PTR *PFNGLCOLOR4UBVPROC)(const GLubyte * v); +typedef void (GLAD_API_PTR *PFNGLCOLOR4UIPROC)(GLuint red, GLuint green, GLuint blue, GLuint alpha); +typedef void (GLAD_API_PTR *PFNGLCOLOR4UIVPROC)(const GLuint * v); +typedef void (GLAD_API_PTR *PFNGLCOLOR4USPROC)(GLushort red, GLushort green, GLushort blue, GLushort alpha); +typedef void (GLAD_API_PTR *PFNGLCOLOR4USVPROC)(const GLushort * v); +typedef void (GLAD_API_PTR *PFNGLCOLORMASKPROC)(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); +typedef void (GLAD_API_PTR *PFNGLCOLORMASKIPROC)(GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +typedef void (GLAD_API_PTR *PFNGLCOLORMATERIALPROC)(GLenum face, GLenum mode); +typedef void (GLAD_API_PTR *PFNGLCOLORP3UIPROC)(GLenum type, GLuint color); +typedef void (GLAD_API_PTR *PFNGLCOLORP3UIVPROC)(GLenum type, const GLuint * color); +typedef void (GLAD_API_PTR *PFNGLCOLORP4UIPROC)(GLenum type, GLuint color); +typedef void (GLAD_API_PTR *PFNGLCOLORP4UIVPROC)(GLenum type, const GLuint * color); +typedef void (GLAD_API_PTR *PFNGLCOLORPOINTERPROC)(GLint size, GLenum type, GLsizei stride, const void * pointer); +typedef void (GLAD_API_PTR *PFNGLCOMPILESHADERPROC)(GLuint shader); +typedef void (GLAD_API_PTR *PFNGLCOMPRESSEDTEXIMAGE1DPROC)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void * data); +typedef void (GLAD_API_PTR *PFNGLCOMPRESSEDTEXIMAGE2DPROC)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void * data); +typedef void (GLAD_API_PTR *PFNGLCOMPRESSEDTEXIMAGE3DPROC)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void * data); +typedef void (GLAD_API_PTR *PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC)(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void * data); +typedef void (GLAD_API_PTR *PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void * data); +typedef void (GLAD_API_PTR *PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void * data); +typedef void (GLAD_API_PTR *PFNGLCOPYBUFFERSUBDATAPROC)(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +typedef void (GLAD_API_PTR *PFNGLCOPYPIXELSPROC)(GLint x, GLint y, GLsizei width, GLsizei height, GLenum type); +typedef void (GLAD_API_PTR *PFNGLCOPYTEXIMAGE1DPROC)(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +typedef void (GLAD_API_PTR *PFNGLCOPYTEXIMAGE2DPROC)(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +typedef void (GLAD_API_PTR *PFNGLCOPYTEXSUBIMAGE1DPROC)(GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +typedef void (GLAD_API_PTR *PFNGLCOPYTEXSUBIMAGE2DPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (GLAD_API_PTR *PFNGLCOPYTEXSUBIMAGE3DPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); typedef GLuint (GLAD_API_PTR *PFNGLCREATEPROGRAMPROC)(void); -typedef GLuint (GLAD_API_PTR *PFNGLCREATESHADERPROC)(GLenum type); -typedef void (GLAD_API_PTR *PFNGLCULLFACEPROC)(GLenum mode); -typedef void (GLAD_API_PTR *PFNGLDEBUGMESSAGECALLBACKPROC)(GLDEBUGPROC callback, const void * userParam); -typedef void (GLAD_API_PTR *PFNGLDEBUGMESSAGECONTROLPROC)(GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint * ids, GLboolean enabled); -typedef void (GLAD_API_PTR *PFNGLDEBUGMESSAGEINSERTPROC)(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar * buf); -typedef void (GLAD_API_PTR *PFNGLDELETEBUFFERSPROC)(GLsizei n, const GLuint * buffers); -typedef void (GLAD_API_PTR *PFNGLDELETEFRAMEBUFFERSPROC)(GLsizei n, const GLuint * framebuffers); -typedef void (GLAD_API_PTR *PFNGLDELETELISTSPROC)(GLuint list, GLsizei range); -typedef void (GLAD_API_PTR *PFNGLDELETEPROGRAMPROC)(GLuint program); -typedef void (GLAD_API_PTR *PFNGLDELETEQUERIESPROC)(GLsizei n, const GLuint * ids); -typedef void (GLAD_API_PTR *PFNGLDELETERENDERBUFFERSPROC)(GLsizei n, const GLuint * renderbuffers); -typedef void (GLAD_API_PTR *PFNGLDELETESAMPLERSPROC)(GLsizei count, const GLuint * samplers); -typedef void (GLAD_API_PTR *PFNGLDELETESHADERPROC)(GLuint shader); -typedef void (GLAD_API_PTR *PFNGLDELETESYNCPROC)(GLsync sync); -typedef void (GLAD_API_PTR *PFNGLDELETETEXTURESPROC)(GLsizei n, const GLuint * textures); -typedef void (GLAD_API_PTR *PFNGLDELETEVERTEXARRAYSPROC)(GLsizei n, const GLuint * arrays); -typedef void (GLAD_API_PTR *PFNGLDEPTHFUNCPROC)(GLenum func); -typedef void (GLAD_API_PTR *PFNGLDEPTHMASKPROC)(GLboolean flag); -typedef void (GLAD_API_PTR *PFNGLDEPTHRANGEPROC)(GLdouble n, GLdouble f); -typedef void (GLAD_API_PTR *PFNGLDETACHSHADERPROC)(GLuint program, GLuint shader); -typedef void (GLAD_API_PTR *PFNGLDISABLEPROC)(GLenum cap); -typedef void (GLAD_API_PTR *PFNGLDISABLECLIENTSTATEPROC)(GLenum array); -typedef void (GLAD_API_PTR *PFNGLDISABLEVERTEXATTRIBARRAYPROC)(GLuint index); -typedef void (GLAD_API_PTR *PFNGLDISABLEIPROC)(GLenum target, GLuint index); -typedef void (GLAD_API_PTR *PFNGLDRAWARRAYSPROC)(GLenum mode, GLint first, GLsizei count); -typedef void (GLAD_API_PTR *PFNGLDRAWARRAYSINSTANCEDPROC)(GLenum mode, GLint first, GLsizei count, GLsizei instancecount); -typedef void (GLAD_API_PTR *PFNGLDRAWBUFFERPROC)(GLenum buf); -typedef void (GLAD_API_PTR *PFNGLDRAWBUFFERSPROC)(GLsizei n, const GLenum * bufs); -typedef void (GLAD_API_PTR *PFNGLDRAWELEMENTSPROC)(GLenum mode, GLsizei count, GLenum type, const void * indices); -typedef void (GLAD_API_PTR *PFNGLDRAWELEMENTSBASEVERTEXPROC)(GLenum mode, GLsizei count, GLenum type, const void * indices, GLint basevertex); -typedef void (GLAD_API_PTR *PFNGLDRAWELEMENTSINSTANCEDPROC)(GLenum mode, GLsizei count, GLenum type, const void * indices, GLsizei instancecount); -typedef void (GLAD_API_PTR *PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC)(GLenum mode, GLsizei count, GLenum type, const void * indices, GLsizei instancecount, GLint basevertex); -typedef void (GLAD_API_PTR *PFNGLDRAWPIXELSPROC)(GLsizei width, GLsizei height, GLenum format, GLenum type, const void * pixels); -typedef void (GLAD_API_PTR *PFNGLDRAWRANGEELEMENTSPROC)(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void * indices); -typedef void (GLAD_API_PTR *PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC)(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void * indices, GLint basevertex); -typedef void (GLAD_API_PTR *PFNGLEDGEFLAGPROC)(GLboolean flag); -typedef void (GLAD_API_PTR *PFNGLEDGEFLAGPOINTERPROC)(GLsizei stride, const void * pointer); -typedef void (GLAD_API_PTR *PFNGLEDGEFLAGVPROC)(const GLboolean * flag); -typedef void (GLAD_API_PTR *PFNGLENABLEPROC)(GLenum cap); -typedef void (GLAD_API_PTR *PFNGLENABLECLIENTSTATEPROC)(GLenum array); -typedef void (GLAD_API_PTR *PFNGLENABLEVERTEXATTRIBARRAYPROC)(GLuint index); -typedef void (GLAD_API_PTR *PFNGLENABLEIPROC)(GLenum target, GLuint index); +typedef GLuint (GLAD_API_PTR *PFNGLCREATESHADERPROC)(GLenum type); +typedef void (GLAD_API_PTR *PFNGLCULLFACEPROC)(GLenum mode); +typedef void (GLAD_API_PTR *PFNGLDEBUGMESSAGECALLBACKPROC)(GLDEBUGPROC callback, const void * userParam); +typedef void (GLAD_API_PTR *PFNGLDEBUGMESSAGECONTROLPROC)(GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint * ids, GLboolean enabled); +typedef void (GLAD_API_PTR *PFNGLDEBUGMESSAGEINSERTPROC)(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar * buf); +typedef void (GLAD_API_PTR *PFNGLDELETEBUFFERSPROC)(GLsizei n, const GLuint * buffers); +typedef void (GLAD_API_PTR *PFNGLDELETEFRAMEBUFFERSPROC)(GLsizei n, const GLuint * framebuffers); +typedef void (GLAD_API_PTR *PFNGLDELETELISTSPROC)(GLuint list, GLsizei range); +typedef void (GLAD_API_PTR *PFNGLDELETEPROGRAMPROC)(GLuint program); +typedef void (GLAD_API_PTR *PFNGLDELETEQUERIESPROC)(GLsizei n, const GLuint * ids); +typedef void (GLAD_API_PTR *PFNGLDELETERENDERBUFFERSPROC)(GLsizei n, const GLuint * renderbuffers); +typedef void (GLAD_API_PTR *PFNGLDELETESAMPLERSPROC)(GLsizei count, const GLuint * samplers); +typedef void (GLAD_API_PTR *PFNGLDELETESHADERPROC)(GLuint shader); +typedef void (GLAD_API_PTR *PFNGLDELETESYNCPROC)(GLsync sync); +typedef void (GLAD_API_PTR *PFNGLDELETETEXTURESPROC)(GLsizei n, const GLuint * textures); +typedef void (GLAD_API_PTR *PFNGLDELETEVERTEXARRAYSPROC)(GLsizei n, const GLuint * arrays); +typedef void (GLAD_API_PTR *PFNGLDEPTHFUNCPROC)(GLenum func); +typedef void (GLAD_API_PTR *PFNGLDEPTHMASKPROC)(GLboolean flag); +typedef void (GLAD_API_PTR *PFNGLDEPTHRANGEPROC)(GLdouble n, GLdouble f); +typedef void (GLAD_API_PTR *PFNGLDETACHSHADERPROC)(GLuint program, GLuint shader); +typedef void (GLAD_API_PTR *PFNGLDISABLEPROC)(GLenum cap); +typedef void (GLAD_API_PTR *PFNGLDISABLECLIENTSTATEPROC)(GLenum array); +typedef void (GLAD_API_PTR *PFNGLDISABLEVERTEXATTRIBARRAYPROC)(GLuint index); +typedef void (GLAD_API_PTR *PFNGLDISABLEIPROC)(GLenum target, GLuint index); +typedef void (GLAD_API_PTR *PFNGLDRAWARRAYSPROC)(GLenum mode, GLint first, GLsizei count); +typedef void (GLAD_API_PTR *PFNGLDRAWARRAYSINSTANCEDPROC)(GLenum mode, GLint first, GLsizei count, GLsizei instancecount); +typedef void (GLAD_API_PTR *PFNGLDRAWBUFFERPROC)(GLenum buf); +typedef void (GLAD_API_PTR *PFNGLDRAWBUFFERSPROC)(GLsizei n, const GLenum * bufs); +typedef void (GLAD_API_PTR *PFNGLDRAWELEMENTSPROC)(GLenum mode, GLsizei count, GLenum type, const void * indices); +typedef void (GLAD_API_PTR *PFNGLDRAWELEMENTSBASEVERTEXPROC)(GLenum mode, GLsizei count, GLenum type, const void * indices, GLint basevertex); +typedef void (GLAD_API_PTR *PFNGLDRAWELEMENTSINSTANCEDPROC)(GLenum mode, GLsizei count, GLenum type, const void * indices, GLsizei instancecount); +typedef void (GLAD_API_PTR *PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC)(GLenum mode, GLsizei count, GLenum type, const void * indices, GLsizei instancecount, GLint basevertex); +typedef void (GLAD_API_PTR *PFNGLDRAWPIXELSPROC)(GLsizei width, GLsizei height, GLenum format, GLenum type, const void * pixels); +typedef void (GLAD_API_PTR *PFNGLDRAWRANGEELEMENTSPROC)(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void * indices); +typedef void (GLAD_API_PTR *PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC)(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void * indices, GLint basevertex); +typedef void (GLAD_API_PTR *PFNGLEDGEFLAGPROC)(GLboolean flag); +typedef void (GLAD_API_PTR *PFNGLEDGEFLAGPOINTERPROC)(GLsizei stride, const void * pointer); +typedef void (GLAD_API_PTR *PFNGLEDGEFLAGVPROC)(const GLboolean * flag); +typedef void (GLAD_API_PTR *PFNGLENABLEPROC)(GLenum cap); +typedef void (GLAD_API_PTR *PFNGLENABLECLIENTSTATEPROC)(GLenum array); +typedef void (GLAD_API_PTR *PFNGLENABLEVERTEXATTRIBARRAYPROC)(GLuint index); +typedef void (GLAD_API_PTR *PFNGLENABLEIPROC)(GLenum target, GLuint index); typedef void (GLAD_API_PTR *PFNGLENDPROC)(void); typedef void (GLAD_API_PTR *PFNGLENDCONDITIONALRENDERPROC)(void); typedef void (GLAD_API_PTR *PFNGLENDLISTPROC)(void); -typedef void (GLAD_API_PTR *PFNGLENDQUERYPROC)(GLenum target); +typedef void (GLAD_API_PTR *PFNGLENDQUERYPROC)(GLenum target); typedef void (GLAD_API_PTR *PFNGLENDTRANSFORMFEEDBACKPROC)(void); -typedef void (GLAD_API_PTR *PFNGLEVALCOORD1DPROC)(GLdouble u); -typedef void (GLAD_API_PTR *PFNGLEVALCOORD1DVPROC)(const GLdouble * u); -typedef void (GLAD_API_PTR *PFNGLEVALCOORD1FPROC)(GLfloat u); -typedef void (GLAD_API_PTR *PFNGLEVALCOORD1FVPROC)(const GLfloat * u); -typedef void (GLAD_API_PTR *PFNGLEVALCOORD2DPROC)(GLdouble u, GLdouble v); -typedef void (GLAD_API_PTR *PFNGLEVALCOORD2DVPROC)(const GLdouble * u); -typedef void (GLAD_API_PTR *PFNGLEVALCOORD2FPROC)(GLfloat u, GLfloat v); -typedef void (GLAD_API_PTR *PFNGLEVALCOORD2FVPROC)(const GLfloat * u); -typedef void (GLAD_API_PTR *PFNGLEVALMESH1PROC)(GLenum mode, GLint i1, GLint i2); -typedef void (GLAD_API_PTR *PFNGLEVALMESH2PROC)(GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2); -typedef void (GLAD_API_PTR *PFNGLEVALPOINT1PROC)(GLint i); -typedef void (GLAD_API_PTR *PFNGLEVALPOINT2PROC)(GLint i, GLint j); -typedef void (GLAD_API_PTR *PFNGLFEEDBACKBUFFERPROC)(GLsizei size, GLenum type, GLfloat * buffer); -typedef GLsync (GLAD_API_PTR *PFNGLFENCESYNCPROC)(GLenum condition, GLbitfield flags); +typedef void (GLAD_API_PTR *PFNGLEVALCOORD1DPROC)(GLdouble u); +typedef void (GLAD_API_PTR *PFNGLEVALCOORD1DVPROC)(const GLdouble * u); +typedef void (GLAD_API_PTR *PFNGLEVALCOORD1FPROC)(GLfloat u); +typedef void (GLAD_API_PTR *PFNGLEVALCOORD1FVPROC)(const GLfloat * u); +typedef void (GLAD_API_PTR *PFNGLEVALCOORD2DPROC)(GLdouble u, GLdouble v); +typedef void (GLAD_API_PTR *PFNGLEVALCOORD2DVPROC)(const GLdouble * u); +typedef void (GLAD_API_PTR *PFNGLEVALCOORD2FPROC)(GLfloat u, GLfloat v); +typedef void (GLAD_API_PTR *PFNGLEVALCOORD2FVPROC)(const GLfloat * u); +typedef void (GLAD_API_PTR *PFNGLEVALMESH1PROC)(GLenum mode, GLint i1, GLint i2); +typedef void (GLAD_API_PTR *PFNGLEVALMESH2PROC)(GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2); +typedef void (GLAD_API_PTR *PFNGLEVALPOINT1PROC)(GLint i); +typedef void (GLAD_API_PTR *PFNGLEVALPOINT2PROC)(GLint i, GLint j); +typedef void (GLAD_API_PTR *PFNGLFEEDBACKBUFFERPROC)(GLsizei size, GLenum type, GLfloat * buffer); +typedef GLsync (GLAD_API_PTR *PFNGLFENCESYNCPROC)(GLenum condition, GLbitfield flags); typedef void (GLAD_API_PTR *PFNGLFINISHPROC)(void); typedef void (GLAD_API_PTR *PFNGLFLUSHPROC)(void); -typedef void (GLAD_API_PTR *PFNGLFLUSHMAPPEDBUFFERRANGEPROC)(GLenum target, GLintptr offset, GLsizeiptr length); -typedef void (GLAD_API_PTR *PFNGLFOGCOORDPOINTERPROC)(GLenum type, GLsizei stride, const void * pointer); -typedef void (GLAD_API_PTR *PFNGLFOGCOORDDPROC)(GLdouble coord); -typedef void (GLAD_API_PTR *PFNGLFOGCOORDDVPROC)(const GLdouble * coord); -typedef void (GLAD_API_PTR *PFNGLFOGCOORDFPROC)(GLfloat coord); -typedef void (GLAD_API_PTR *PFNGLFOGCOORDFVPROC)(const GLfloat * coord); -typedef void (GLAD_API_PTR *PFNGLFOGFPROC)(GLenum pname, GLfloat param); -typedef void (GLAD_API_PTR *PFNGLFOGFVPROC)(GLenum pname, const GLfloat * params); -typedef void (GLAD_API_PTR *PFNGLFOGIPROC)(GLenum pname, GLint param); -typedef void (GLAD_API_PTR *PFNGLFOGIVPROC)(GLenum pname, const GLint * params); -typedef void (GLAD_API_PTR *PFNGLFRAMEBUFFERRENDERBUFFERPROC)(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); -typedef void (GLAD_API_PTR *PFNGLFRAMEBUFFERTEXTUREPROC)(GLenum target, GLenum attachment, GLuint texture, GLint level); -typedef void (GLAD_API_PTR *PFNGLFRAMEBUFFERTEXTURE1DPROC)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (GLAD_API_PTR *PFNGLFRAMEBUFFERTEXTURE2DPROC)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (GLAD_API_PTR *PFNGLFRAMEBUFFERTEXTURE3DPROC)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); -typedef void (GLAD_API_PTR *PFNGLFRAMEBUFFERTEXTURELAYERPROC)(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); -typedef void (GLAD_API_PTR *PFNGLFRONTFACEPROC)(GLenum mode); -typedef void (GLAD_API_PTR *PFNGLFRUSTUMPROC)(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); -typedef void (GLAD_API_PTR *PFNGLGENBUFFERSPROC)(GLsizei n, GLuint * buffers); -typedef void (GLAD_API_PTR *PFNGLGENFRAMEBUFFERSPROC)(GLsizei n, GLuint * framebuffers); -typedef GLuint (GLAD_API_PTR *PFNGLGENLISTSPROC)(GLsizei range); -typedef void (GLAD_API_PTR *PFNGLGENQUERIESPROC)(GLsizei n, GLuint * ids); -typedef void (GLAD_API_PTR *PFNGLGENRENDERBUFFERSPROC)(GLsizei n, GLuint * renderbuffers); -typedef void (GLAD_API_PTR *PFNGLGENSAMPLERSPROC)(GLsizei count, GLuint * samplers); -typedef void (GLAD_API_PTR *PFNGLGENTEXTURESPROC)(GLsizei n, GLuint * textures); -typedef void (GLAD_API_PTR *PFNGLGENVERTEXARRAYSPROC)(GLsizei n, GLuint * arrays); -typedef void (GLAD_API_PTR *PFNGLGENERATEMIPMAPPROC)(GLenum target); -typedef void (GLAD_API_PTR *PFNGLGETACTIVEATTRIBPROC)(GLuint program, GLuint index, GLsizei bufSize, GLsizei * length, GLint * size, GLenum * type, GLchar * name); -typedef void (GLAD_API_PTR *PFNGLGETACTIVEUNIFORMPROC)(GLuint program, GLuint index, GLsizei bufSize, GLsizei * length, GLint * size, GLenum * type, GLchar * name); -typedef void (GLAD_API_PTR *PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC)(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei * length, GLchar * uniformBlockName); -typedef void (GLAD_API_PTR *PFNGLGETACTIVEUNIFORMBLOCKIVPROC)(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint * params); -typedef void (GLAD_API_PTR *PFNGLGETACTIVEUNIFORMNAMEPROC)(GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei * length, GLchar * uniformName); -typedef void (GLAD_API_PTR *PFNGLGETACTIVEUNIFORMSIVPROC)(GLuint program, GLsizei uniformCount, const GLuint * uniformIndices, GLenum pname, GLint * params); -typedef void (GLAD_API_PTR *PFNGLGETATTACHEDSHADERSPROC)(GLuint program, GLsizei maxCount, GLsizei * count, GLuint * shaders); -typedef GLint (GLAD_API_PTR *PFNGLGETATTRIBLOCATIONPROC)(GLuint program, const GLchar * name); -typedef void (GLAD_API_PTR *PFNGLGETBOOLEANI_VPROC)(GLenum target, GLuint index, GLboolean * data); -typedef void (GLAD_API_PTR *PFNGLGETBOOLEANVPROC)(GLenum pname, GLboolean * data); -typedef void (GLAD_API_PTR *PFNGLGETBUFFERPARAMETERI64VPROC)(GLenum target, GLenum pname, GLint64 * params); -typedef void (GLAD_API_PTR *PFNGLGETBUFFERPARAMETERIVPROC)(GLenum target, GLenum pname, GLint * params); -typedef void (GLAD_API_PTR *PFNGLGETBUFFERPOINTERVPROC)(GLenum target, GLenum pname, void ** params); -typedef void (GLAD_API_PTR *PFNGLGETBUFFERSUBDATAPROC)(GLenum target, GLintptr offset, GLsizeiptr size, void * data); -typedef void (GLAD_API_PTR *PFNGLGETCLIPPLANEPROC)(GLenum plane, GLdouble * equation); -typedef void (GLAD_API_PTR *PFNGLGETCOMPRESSEDTEXIMAGEPROC)(GLenum target, GLint level, void * img); -typedef GLuint (GLAD_API_PTR *PFNGLGETDEBUGMESSAGELOGPROC)(GLuint count, GLsizei bufSize, GLenum * sources, GLenum * types, GLuint * ids, GLenum * severities, GLsizei * lengths, GLchar * messageLog); -typedef void (GLAD_API_PTR *PFNGLGETDOUBLEVPROC)(GLenum pname, GLdouble * data); +typedef void (GLAD_API_PTR *PFNGLFLUSHMAPPEDBUFFERRANGEPROC)(GLenum target, GLintptr offset, GLsizeiptr length); +typedef void (GLAD_API_PTR *PFNGLFOGCOORDPOINTERPROC)(GLenum type, GLsizei stride, const void * pointer); +typedef void (GLAD_API_PTR *PFNGLFOGCOORDDPROC)(GLdouble coord); +typedef void (GLAD_API_PTR *PFNGLFOGCOORDDVPROC)(const GLdouble * coord); +typedef void (GLAD_API_PTR *PFNGLFOGCOORDFPROC)(GLfloat coord); +typedef void (GLAD_API_PTR *PFNGLFOGCOORDFVPROC)(const GLfloat * coord); +typedef void (GLAD_API_PTR *PFNGLFOGFPROC)(GLenum pname, GLfloat param); +typedef void (GLAD_API_PTR *PFNGLFOGFVPROC)(GLenum pname, const GLfloat * params); +typedef void (GLAD_API_PTR *PFNGLFOGIPROC)(GLenum pname, GLint param); +typedef void (GLAD_API_PTR *PFNGLFOGIVPROC)(GLenum pname, const GLint * params); +typedef void (GLAD_API_PTR *PFNGLFRAMEBUFFERRENDERBUFFERPROC)(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +typedef void (GLAD_API_PTR *PFNGLFRAMEBUFFERTEXTUREPROC)(GLenum target, GLenum attachment, GLuint texture, GLint level); +typedef void (GLAD_API_PTR *PFNGLFRAMEBUFFERTEXTURE1DPROC)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (GLAD_API_PTR *PFNGLFRAMEBUFFERTEXTURE2DPROC)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (GLAD_API_PTR *PFNGLFRAMEBUFFERTEXTURE3DPROC)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +typedef void (GLAD_API_PTR *PFNGLFRAMEBUFFERTEXTURELAYERPROC)(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +typedef void (GLAD_API_PTR *PFNGLFRONTFACEPROC)(GLenum mode); +typedef void (GLAD_API_PTR *PFNGLFRUSTUMPROC)(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +typedef void (GLAD_API_PTR *PFNGLGENBUFFERSPROC)(GLsizei n, GLuint * buffers); +typedef void (GLAD_API_PTR *PFNGLGENFRAMEBUFFERSPROC)(GLsizei n, GLuint * framebuffers); +typedef GLuint (GLAD_API_PTR *PFNGLGENLISTSPROC)(GLsizei range); +typedef void (GLAD_API_PTR *PFNGLGENQUERIESPROC)(GLsizei n, GLuint * ids); +typedef void (GLAD_API_PTR *PFNGLGENRENDERBUFFERSPROC)(GLsizei n, GLuint * renderbuffers); +typedef void (GLAD_API_PTR *PFNGLGENSAMPLERSPROC)(GLsizei count, GLuint * samplers); +typedef void (GLAD_API_PTR *PFNGLGENTEXTURESPROC)(GLsizei n, GLuint * textures); +typedef void (GLAD_API_PTR *PFNGLGENVERTEXARRAYSPROC)(GLsizei n, GLuint * arrays); +typedef void (GLAD_API_PTR *PFNGLGENERATEMIPMAPPROC)(GLenum target); +typedef void (GLAD_API_PTR *PFNGLGETACTIVEATTRIBPROC)(GLuint program, GLuint index, GLsizei bufSize, GLsizei * length, GLint * size, GLenum * type, GLchar * name); +typedef void (GLAD_API_PTR *PFNGLGETACTIVEUNIFORMPROC)(GLuint program, GLuint index, GLsizei bufSize, GLsizei * length, GLint * size, GLenum * type, GLchar * name); +typedef void (GLAD_API_PTR *PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC)(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei * length, GLchar * uniformBlockName); +typedef void (GLAD_API_PTR *PFNGLGETACTIVEUNIFORMBLOCKIVPROC)(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint * params); +typedef void (GLAD_API_PTR *PFNGLGETACTIVEUNIFORMNAMEPROC)(GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei * length, GLchar * uniformName); +typedef void (GLAD_API_PTR *PFNGLGETACTIVEUNIFORMSIVPROC)(GLuint program, GLsizei uniformCount, const GLuint * uniformIndices, GLenum pname, GLint * params); +typedef void (GLAD_API_PTR *PFNGLGETATTACHEDSHADERSPROC)(GLuint program, GLsizei maxCount, GLsizei * count, GLuint * shaders); +typedef GLint (GLAD_API_PTR *PFNGLGETATTRIBLOCATIONPROC)(GLuint program, const GLchar * name); +typedef void (GLAD_API_PTR *PFNGLGETBOOLEANI_VPROC)(GLenum target, GLuint index, GLboolean * data); +typedef void (GLAD_API_PTR *PFNGLGETBOOLEANVPROC)(GLenum pname, GLboolean * data); +typedef void (GLAD_API_PTR *PFNGLGETBUFFERPARAMETERI64VPROC)(GLenum target, GLenum pname, GLint64 * params); +typedef void (GLAD_API_PTR *PFNGLGETBUFFERPARAMETERIVPROC)(GLenum target, GLenum pname, GLint * params); +typedef void (GLAD_API_PTR *PFNGLGETBUFFERPOINTERVPROC)(GLenum target, GLenum pname, void ** params); +typedef void (GLAD_API_PTR *PFNGLGETBUFFERSUBDATAPROC)(GLenum target, GLintptr offset, GLsizeiptr size, void * data); +typedef void (GLAD_API_PTR *PFNGLGETCLIPPLANEPROC)(GLenum plane, GLdouble * equation); +typedef void (GLAD_API_PTR *PFNGLGETCOMPRESSEDTEXIMAGEPROC)(GLenum target, GLint level, void * img); +typedef GLuint (GLAD_API_PTR *PFNGLGETDEBUGMESSAGELOGPROC)(GLuint count, GLsizei bufSize, GLenum * sources, GLenum * types, GLuint * ids, GLenum * severities, GLsizei * lengths, GLchar * messageLog); +typedef void (GLAD_API_PTR *PFNGLGETDOUBLEVPROC)(GLenum pname, GLdouble * data); typedef GLenum (GLAD_API_PTR *PFNGLGETERRORPROC)(void); -typedef void (GLAD_API_PTR *PFNGLGETFLOATVPROC)(GLenum pname, GLfloat * data); -typedef GLint (GLAD_API_PTR *PFNGLGETFRAGDATAINDEXPROC)(GLuint program, const GLchar * name); -typedef GLint (GLAD_API_PTR *PFNGLGETFRAGDATALOCATIONPROC)(GLuint program, const GLchar * name); -typedef void (GLAD_API_PTR *PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC)(GLenum target, GLenum attachment, GLenum pname, GLint * params); +typedef void (GLAD_API_PTR *PFNGLGETFLOATVPROC)(GLenum pname, GLfloat * data); +typedef GLint (GLAD_API_PTR *PFNGLGETFRAGDATAINDEXPROC)(GLuint program, const GLchar * name); +typedef GLint (GLAD_API_PTR *PFNGLGETFRAGDATALOCATIONPROC)(GLuint program, const GLchar * name); +typedef void (GLAD_API_PTR *PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC)(GLenum target, GLenum attachment, GLenum pname, GLint * params); typedef GLenum (GLAD_API_PTR *PFNGLGETGRAPHICSRESETSTATUSARBPROC)(void); -typedef void (GLAD_API_PTR *PFNGLGETINTEGER64I_VPROC)(GLenum target, GLuint index, GLint64 * data); -typedef void (GLAD_API_PTR *PFNGLGETINTEGER64VPROC)(GLenum pname, GLint64 * data); -typedef void (GLAD_API_PTR *PFNGLGETINTEGERI_VPROC)(GLenum target, GLuint index, GLint * data); -typedef void (GLAD_API_PTR *PFNGLGETINTEGERVPROC)(GLenum pname, GLint * data); -typedef void (GLAD_API_PTR *PFNGLGETLIGHTFVPROC)(GLenum light, GLenum pname, GLfloat * params); -typedef void (GLAD_API_PTR *PFNGLGETLIGHTIVPROC)(GLenum light, GLenum pname, GLint * params); -typedef void (GLAD_API_PTR *PFNGLGETMAPDVPROC)(GLenum target, GLenum query, GLdouble * v); -typedef void (GLAD_API_PTR *PFNGLGETMAPFVPROC)(GLenum target, GLenum query, GLfloat * v); -typedef void (GLAD_API_PTR *PFNGLGETMAPIVPROC)(GLenum target, GLenum query, GLint * v); -typedef void (GLAD_API_PTR *PFNGLGETMATERIALFVPROC)(GLenum face, GLenum pname, GLfloat * params); -typedef void (GLAD_API_PTR *PFNGLGETMATERIALIVPROC)(GLenum face, GLenum pname, GLint * params); -typedef void (GLAD_API_PTR *PFNGLGETMULTISAMPLEFVPROC)(GLenum pname, GLuint index, GLfloat * val); -typedef void (GLAD_API_PTR *PFNGLGETOBJECTLABELPROC)(GLenum identifier, GLuint name, GLsizei bufSize, GLsizei * length, GLchar * label); -typedef void (GLAD_API_PTR *PFNGLGETOBJECTPTRLABELPROC)(const void * ptr, GLsizei bufSize, GLsizei * length, GLchar * label); -typedef void (GLAD_API_PTR *PFNGLGETPIXELMAPFVPROC)(GLenum map, GLfloat * values); -typedef void (GLAD_API_PTR *PFNGLGETPIXELMAPUIVPROC)(GLenum map, GLuint * values); -typedef void (GLAD_API_PTR *PFNGLGETPIXELMAPUSVPROC)(GLenum map, GLushort * values); -typedef void (GLAD_API_PTR *PFNGLGETPOINTERVPROC)(GLenum pname, void ** params); -typedef void (GLAD_API_PTR *PFNGLGETPOLYGONSTIPPLEPROC)(GLubyte * mask); -typedef void (GLAD_API_PTR *PFNGLGETPROGRAMINFOLOGPROC)(GLuint program, GLsizei bufSize, GLsizei * length, GLchar * infoLog); -typedef void (GLAD_API_PTR *PFNGLGETPROGRAMIVPROC)(GLuint program, GLenum pname, GLint * params); -typedef void (GLAD_API_PTR *PFNGLGETQUERYOBJECTI64VPROC)(GLuint id, GLenum pname, GLint64 * params); -typedef void (GLAD_API_PTR *PFNGLGETQUERYOBJECTIVPROC)(GLuint id, GLenum pname, GLint * params); -typedef void (GLAD_API_PTR *PFNGLGETQUERYOBJECTUI64VPROC)(GLuint id, GLenum pname, GLuint64 * params); -typedef void (GLAD_API_PTR *PFNGLGETQUERYOBJECTUIVPROC)(GLuint id, GLenum pname, GLuint * params); -typedef void (GLAD_API_PTR *PFNGLGETQUERYIVPROC)(GLenum target, GLenum pname, GLint * params); -typedef void (GLAD_API_PTR *PFNGLGETRENDERBUFFERPARAMETERIVPROC)(GLenum target, GLenum pname, GLint * params); -typedef void (GLAD_API_PTR *PFNGLGETSAMPLERPARAMETERIIVPROC)(GLuint sampler, GLenum pname, GLint * params); -typedef void (GLAD_API_PTR *PFNGLGETSAMPLERPARAMETERIUIVPROC)(GLuint sampler, GLenum pname, GLuint * params); -typedef void (GLAD_API_PTR *PFNGLGETSAMPLERPARAMETERFVPROC)(GLuint sampler, GLenum pname, GLfloat * params); -typedef void (GLAD_API_PTR *PFNGLGETSAMPLERPARAMETERIVPROC)(GLuint sampler, GLenum pname, GLint * params); -typedef void (GLAD_API_PTR *PFNGLGETSHADERINFOLOGPROC)(GLuint shader, GLsizei bufSize, GLsizei * length, GLchar * infoLog); -typedef void (GLAD_API_PTR *PFNGLGETSHADERSOURCEPROC)(GLuint shader, GLsizei bufSize, GLsizei * length, GLchar * source); -typedef void (GLAD_API_PTR *PFNGLGETSHADERIVPROC)(GLuint shader, GLenum pname, GLint * params); -typedef const GLubyte * (GLAD_API_PTR *PFNGLGETSTRINGPROC)(GLenum name); -typedef const GLubyte * (GLAD_API_PTR *PFNGLGETSTRINGIPROC)(GLenum name, GLuint index); -typedef void (GLAD_API_PTR *PFNGLGETSYNCIVPROC)(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei * length, GLint * values); -typedef void (GLAD_API_PTR *PFNGLGETTEXENVFVPROC)(GLenum target, GLenum pname, GLfloat * params); -typedef void (GLAD_API_PTR *PFNGLGETTEXENVIVPROC)(GLenum target, GLenum pname, GLint * params); -typedef void (GLAD_API_PTR *PFNGLGETTEXGENDVPROC)(GLenum coord, GLenum pname, GLdouble * params); -typedef void (GLAD_API_PTR *PFNGLGETTEXGENFVPROC)(GLenum coord, GLenum pname, GLfloat * params); -typedef void (GLAD_API_PTR *PFNGLGETTEXGENIVPROC)(GLenum coord, GLenum pname, GLint * params); -typedef void (GLAD_API_PTR *PFNGLGETTEXIMAGEPROC)(GLenum target, GLint level, GLenum format, GLenum type, void * pixels); -typedef void (GLAD_API_PTR *PFNGLGETTEXLEVELPARAMETERFVPROC)(GLenum target, GLint level, GLenum pname, GLfloat * params); -typedef void (GLAD_API_PTR *PFNGLGETTEXLEVELPARAMETERIVPROC)(GLenum target, GLint level, GLenum pname, GLint * params); -typedef void (GLAD_API_PTR *PFNGLGETTEXPARAMETERIIVPROC)(GLenum target, GLenum pname, GLint * params); -typedef void (GLAD_API_PTR *PFNGLGETTEXPARAMETERIUIVPROC)(GLenum target, GLenum pname, GLuint * params); -typedef void (GLAD_API_PTR *PFNGLGETTEXPARAMETERFVPROC)(GLenum target, GLenum pname, GLfloat * params); -typedef void (GLAD_API_PTR *PFNGLGETTEXPARAMETERIVPROC)(GLenum target, GLenum pname, GLint * params); -typedef void (GLAD_API_PTR *PFNGLGETTRANSFORMFEEDBACKVARYINGPROC)(GLuint program, GLuint index, GLsizei bufSize, GLsizei * length, GLsizei * size, GLenum * type, GLchar * name); -typedef GLuint (GLAD_API_PTR *PFNGLGETUNIFORMBLOCKINDEXPROC)(GLuint program, const GLchar * uniformBlockName); -typedef void (GLAD_API_PTR *PFNGLGETUNIFORMINDICESPROC)(GLuint program, GLsizei uniformCount, const GLchar *const* uniformNames, GLuint * uniformIndices); -typedef GLint (GLAD_API_PTR *PFNGLGETUNIFORMLOCATIONPROC)(GLuint program, const GLchar * name); -typedef void (GLAD_API_PTR *PFNGLGETUNIFORMFVPROC)(GLuint program, GLint location, GLfloat * params); -typedef void (GLAD_API_PTR *PFNGLGETUNIFORMIVPROC)(GLuint program, GLint location, GLint * params); -typedef void (GLAD_API_PTR *PFNGLGETUNIFORMUIVPROC)(GLuint program, GLint location, GLuint * params); -typedef void (GLAD_API_PTR *PFNGLGETVERTEXATTRIBIIVPROC)(GLuint index, GLenum pname, GLint * params); -typedef void (GLAD_API_PTR *PFNGLGETVERTEXATTRIBIUIVPROC)(GLuint index, GLenum pname, GLuint * params); -typedef void (GLAD_API_PTR *PFNGLGETVERTEXATTRIBPOINTERVPROC)(GLuint index, GLenum pname, void ** pointer); -typedef void (GLAD_API_PTR *PFNGLGETVERTEXATTRIBDVPROC)(GLuint index, GLenum pname, GLdouble * params); -typedef void (GLAD_API_PTR *PFNGLGETVERTEXATTRIBFVPROC)(GLuint index, GLenum pname, GLfloat * params); -typedef void (GLAD_API_PTR *PFNGLGETVERTEXATTRIBIVPROC)(GLuint index, GLenum pname, GLint * params); -typedef void (GLAD_API_PTR *PFNGLGETNCOLORTABLEARBPROC)(GLenum target, GLenum format, GLenum type, GLsizei bufSize, void * table); -typedef void (GLAD_API_PTR *PFNGLGETNCOMPRESSEDTEXIMAGEARBPROC)(GLenum target, GLint lod, GLsizei bufSize, void * img); -typedef void (GLAD_API_PTR *PFNGLGETNCONVOLUTIONFILTERARBPROC)(GLenum target, GLenum format, GLenum type, GLsizei bufSize, void * image); -typedef void (GLAD_API_PTR *PFNGLGETNHISTOGRAMARBPROC)(GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void * values); -typedef void (GLAD_API_PTR *PFNGLGETNMAPDVARBPROC)(GLenum target, GLenum query, GLsizei bufSize, GLdouble * v); -typedef void (GLAD_API_PTR *PFNGLGETNMAPFVARBPROC)(GLenum target, GLenum query, GLsizei bufSize, GLfloat * v); -typedef void (GLAD_API_PTR *PFNGLGETNMAPIVARBPROC)(GLenum target, GLenum query, GLsizei bufSize, GLint * v); -typedef void (GLAD_API_PTR *PFNGLGETNMINMAXARBPROC)(GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void * values); -typedef void (GLAD_API_PTR *PFNGLGETNPIXELMAPFVARBPROC)(GLenum map, GLsizei bufSize, GLfloat * values); -typedef void (GLAD_API_PTR *PFNGLGETNPIXELMAPUIVARBPROC)(GLenum map, GLsizei bufSize, GLuint * values); -typedef void (GLAD_API_PTR *PFNGLGETNPIXELMAPUSVARBPROC)(GLenum map, GLsizei bufSize, GLushort * values); -typedef void (GLAD_API_PTR *PFNGLGETNPOLYGONSTIPPLEARBPROC)(GLsizei bufSize, GLubyte * pattern); -typedef void (GLAD_API_PTR *PFNGLGETNSEPARABLEFILTERARBPROC)(GLenum target, GLenum format, GLenum type, GLsizei rowBufSize, void * row, GLsizei columnBufSize, void * column, void * span); -typedef void (GLAD_API_PTR *PFNGLGETNTEXIMAGEARBPROC)(GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, void * img); -typedef void (GLAD_API_PTR *PFNGLGETNUNIFORMDVARBPROC)(GLuint program, GLint location, GLsizei bufSize, GLdouble * params); -typedef void (GLAD_API_PTR *PFNGLGETNUNIFORMFVARBPROC)(GLuint program, GLint location, GLsizei bufSize, GLfloat * params); -typedef void (GLAD_API_PTR *PFNGLGETNUNIFORMIVARBPROC)(GLuint program, GLint location, GLsizei bufSize, GLint * params); -typedef void (GLAD_API_PTR *PFNGLGETNUNIFORMUIVARBPROC)(GLuint program, GLint location, GLsizei bufSize, GLuint * params); -typedef void (GLAD_API_PTR *PFNGLHINTPROC)(GLenum target, GLenum mode); -typedef void (GLAD_API_PTR *PFNGLINDEXMASKPROC)(GLuint mask); -typedef void (GLAD_API_PTR *PFNGLINDEXPOINTERPROC)(GLenum type, GLsizei stride, const void * pointer); -typedef void (GLAD_API_PTR *PFNGLINDEXDPROC)(GLdouble c); -typedef void (GLAD_API_PTR *PFNGLINDEXDVPROC)(const GLdouble * c); -typedef void (GLAD_API_PTR *PFNGLINDEXFPROC)(GLfloat c); -typedef void (GLAD_API_PTR *PFNGLINDEXFVPROC)(const GLfloat * c); -typedef void (GLAD_API_PTR *PFNGLINDEXIPROC)(GLint c); -typedef void (GLAD_API_PTR *PFNGLINDEXIVPROC)(const GLint * c); -typedef void (GLAD_API_PTR *PFNGLINDEXSPROC)(GLshort c); -typedef void (GLAD_API_PTR *PFNGLINDEXSVPROC)(const GLshort * c); -typedef void (GLAD_API_PTR *PFNGLINDEXUBPROC)(GLubyte c); -typedef void (GLAD_API_PTR *PFNGLINDEXUBVPROC)(const GLubyte * c); +typedef void (GLAD_API_PTR *PFNGLGETINTEGER64I_VPROC)(GLenum target, GLuint index, GLint64 * data); +typedef void (GLAD_API_PTR *PFNGLGETINTEGER64VPROC)(GLenum pname, GLint64 * data); +typedef void (GLAD_API_PTR *PFNGLGETINTEGERI_VPROC)(GLenum target, GLuint index, GLint * data); +typedef void (GLAD_API_PTR *PFNGLGETINTEGERVPROC)(GLenum pname, GLint * data); +typedef void (GLAD_API_PTR *PFNGLGETLIGHTFVPROC)(GLenum light, GLenum pname, GLfloat * params); +typedef void (GLAD_API_PTR *PFNGLGETLIGHTIVPROC)(GLenum light, GLenum pname, GLint * params); +typedef void (GLAD_API_PTR *PFNGLGETMAPDVPROC)(GLenum target, GLenum query, GLdouble * v); +typedef void (GLAD_API_PTR *PFNGLGETMAPFVPROC)(GLenum target, GLenum query, GLfloat * v); +typedef void (GLAD_API_PTR *PFNGLGETMAPIVPROC)(GLenum target, GLenum query, GLint * v); +typedef void (GLAD_API_PTR *PFNGLGETMATERIALFVPROC)(GLenum face, GLenum pname, GLfloat * params); +typedef void (GLAD_API_PTR *PFNGLGETMATERIALIVPROC)(GLenum face, GLenum pname, GLint * params); +typedef void (GLAD_API_PTR *PFNGLGETMULTISAMPLEFVPROC)(GLenum pname, GLuint index, GLfloat * val); +typedef void (GLAD_API_PTR *PFNGLGETOBJECTLABELPROC)(GLenum identifier, GLuint name, GLsizei bufSize, GLsizei * length, GLchar * label); +typedef void (GLAD_API_PTR *PFNGLGETOBJECTPTRLABELPROC)(const void * ptr, GLsizei bufSize, GLsizei * length, GLchar * label); +typedef void (GLAD_API_PTR *PFNGLGETPIXELMAPFVPROC)(GLenum map, GLfloat * values); +typedef void (GLAD_API_PTR *PFNGLGETPIXELMAPUIVPROC)(GLenum map, GLuint * values); +typedef void (GLAD_API_PTR *PFNGLGETPIXELMAPUSVPROC)(GLenum map, GLushort * values); +typedef void (GLAD_API_PTR *PFNGLGETPOINTERVPROC)(GLenum pname, void ** params); +typedef void (GLAD_API_PTR *PFNGLGETPOLYGONSTIPPLEPROC)(GLubyte * mask); +typedef void (GLAD_API_PTR *PFNGLGETPROGRAMINFOLOGPROC)(GLuint program, GLsizei bufSize, GLsizei * length, GLchar * infoLog); +typedef void (GLAD_API_PTR *PFNGLGETPROGRAMIVPROC)(GLuint program, GLenum pname, GLint * params); +typedef void (GLAD_API_PTR *PFNGLGETQUERYOBJECTI64VPROC)(GLuint id, GLenum pname, GLint64 * params); +typedef void (GLAD_API_PTR *PFNGLGETQUERYOBJECTIVPROC)(GLuint id, GLenum pname, GLint * params); +typedef void (GLAD_API_PTR *PFNGLGETQUERYOBJECTUI64VPROC)(GLuint id, GLenum pname, GLuint64 * params); +typedef void (GLAD_API_PTR *PFNGLGETQUERYOBJECTUIVPROC)(GLuint id, GLenum pname, GLuint * params); +typedef void (GLAD_API_PTR *PFNGLGETQUERYIVPROC)(GLenum target, GLenum pname, GLint * params); +typedef void (GLAD_API_PTR *PFNGLGETRENDERBUFFERPARAMETERIVPROC)(GLenum target, GLenum pname, GLint * params); +typedef void (GLAD_API_PTR *PFNGLGETSAMPLERPARAMETERIIVPROC)(GLuint sampler, GLenum pname, GLint * params); +typedef void (GLAD_API_PTR *PFNGLGETSAMPLERPARAMETERIUIVPROC)(GLuint sampler, GLenum pname, GLuint * params); +typedef void (GLAD_API_PTR *PFNGLGETSAMPLERPARAMETERFVPROC)(GLuint sampler, GLenum pname, GLfloat * params); +typedef void (GLAD_API_PTR *PFNGLGETSAMPLERPARAMETERIVPROC)(GLuint sampler, GLenum pname, GLint * params); +typedef void (GLAD_API_PTR *PFNGLGETSHADERINFOLOGPROC)(GLuint shader, GLsizei bufSize, GLsizei * length, GLchar * infoLog); +typedef void (GLAD_API_PTR *PFNGLGETSHADERSOURCEPROC)(GLuint shader, GLsizei bufSize, GLsizei * length, GLchar * source); +typedef void (GLAD_API_PTR *PFNGLGETSHADERIVPROC)(GLuint shader, GLenum pname, GLint * params); +typedef const GLubyte * (GLAD_API_PTR *PFNGLGETSTRINGPROC)(GLenum name); +typedef const GLubyte * (GLAD_API_PTR *PFNGLGETSTRINGIPROC)(GLenum name, GLuint index); +typedef void (GLAD_API_PTR *PFNGLGETSYNCIVPROC)(GLsync sync, GLenum pname, GLsizei count, GLsizei * length, GLint * values); +typedef void (GLAD_API_PTR *PFNGLGETTEXENVFVPROC)(GLenum target, GLenum pname, GLfloat * params); +typedef void (GLAD_API_PTR *PFNGLGETTEXENVIVPROC)(GLenum target, GLenum pname, GLint * params); +typedef void (GLAD_API_PTR *PFNGLGETTEXGENDVPROC)(GLenum coord, GLenum pname, GLdouble * params); +typedef void (GLAD_API_PTR *PFNGLGETTEXGENFVPROC)(GLenum coord, GLenum pname, GLfloat * params); +typedef void (GLAD_API_PTR *PFNGLGETTEXGENIVPROC)(GLenum coord, GLenum pname, GLint * params); +typedef void (GLAD_API_PTR *PFNGLGETTEXIMAGEPROC)(GLenum target, GLint level, GLenum format, GLenum type, void * pixels); +typedef void (GLAD_API_PTR *PFNGLGETTEXLEVELPARAMETERFVPROC)(GLenum target, GLint level, GLenum pname, GLfloat * params); +typedef void (GLAD_API_PTR *PFNGLGETTEXLEVELPARAMETERIVPROC)(GLenum target, GLint level, GLenum pname, GLint * params); +typedef void (GLAD_API_PTR *PFNGLGETTEXPARAMETERIIVPROC)(GLenum target, GLenum pname, GLint * params); +typedef void (GLAD_API_PTR *PFNGLGETTEXPARAMETERIUIVPROC)(GLenum target, GLenum pname, GLuint * params); +typedef void (GLAD_API_PTR *PFNGLGETTEXPARAMETERFVPROC)(GLenum target, GLenum pname, GLfloat * params); +typedef void (GLAD_API_PTR *PFNGLGETTEXPARAMETERIVPROC)(GLenum target, GLenum pname, GLint * params); +typedef void (GLAD_API_PTR *PFNGLGETTRANSFORMFEEDBACKVARYINGPROC)(GLuint program, GLuint index, GLsizei bufSize, GLsizei * length, GLsizei * size, GLenum * type, GLchar * name); +typedef GLuint (GLAD_API_PTR *PFNGLGETUNIFORMBLOCKINDEXPROC)(GLuint program, const GLchar * uniformBlockName); +typedef void (GLAD_API_PTR *PFNGLGETUNIFORMINDICESPROC)(GLuint program, GLsizei uniformCount, const GLchar *const* uniformNames, GLuint * uniformIndices); +typedef GLint (GLAD_API_PTR *PFNGLGETUNIFORMLOCATIONPROC)(GLuint program, const GLchar * name); +typedef void (GLAD_API_PTR *PFNGLGETUNIFORMFVPROC)(GLuint program, GLint location, GLfloat * params); +typedef void (GLAD_API_PTR *PFNGLGETUNIFORMIVPROC)(GLuint program, GLint location, GLint * params); +typedef void (GLAD_API_PTR *PFNGLGETUNIFORMUIVPROC)(GLuint program, GLint location, GLuint * params); +typedef void (GLAD_API_PTR *PFNGLGETVERTEXATTRIBIIVPROC)(GLuint index, GLenum pname, GLint * params); +typedef void (GLAD_API_PTR *PFNGLGETVERTEXATTRIBIUIVPROC)(GLuint index, GLenum pname, GLuint * params); +typedef void (GLAD_API_PTR *PFNGLGETVERTEXATTRIBPOINTERVPROC)(GLuint index, GLenum pname, void ** pointer); +typedef void (GLAD_API_PTR *PFNGLGETVERTEXATTRIBDVPROC)(GLuint index, GLenum pname, GLdouble * params); +typedef void (GLAD_API_PTR *PFNGLGETVERTEXATTRIBFVPROC)(GLuint index, GLenum pname, GLfloat * params); +typedef void (GLAD_API_PTR *PFNGLGETVERTEXATTRIBIVPROC)(GLuint index, GLenum pname, GLint * params); +typedef void (GLAD_API_PTR *PFNGLGETNCOLORTABLEARBPROC)(GLenum target, GLenum format, GLenum type, GLsizei bufSize, void * table); +typedef void (GLAD_API_PTR *PFNGLGETNCOMPRESSEDTEXIMAGEARBPROC)(GLenum target, GLint lod, GLsizei bufSize, void * img); +typedef void (GLAD_API_PTR *PFNGLGETNCONVOLUTIONFILTERARBPROC)(GLenum target, GLenum format, GLenum type, GLsizei bufSize, void * image); +typedef void (GLAD_API_PTR *PFNGLGETNHISTOGRAMARBPROC)(GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void * values); +typedef void (GLAD_API_PTR *PFNGLGETNMAPDVARBPROC)(GLenum target, GLenum query, GLsizei bufSize, GLdouble * v); +typedef void (GLAD_API_PTR *PFNGLGETNMAPFVARBPROC)(GLenum target, GLenum query, GLsizei bufSize, GLfloat * v); +typedef void (GLAD_API_PTR *PFNGLGETNMAPIVARBPROC)(GLenum target, GLenum query, GLsizei bufSize, GLint * v); +typedef void (GLAD_API_PTR *PFNGLGETNMINMAXARBPROC)(GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void * values); +typedef void (GLAD_API_PTR *PFNGLGETNPIXELMAPFVARBPROC)(GLenum map, GLsizei bufSize, GLfloat * values); +typedef void (GLAD_API_PTR *PFNGLGETNPIXELMAPUIVARBPROC)(GLenum map, GLsizei bufSize, GLuint * values); +typedef void (GLAD_API_PTR *PFNGLGETNPIXELMAPUSVARBPROC)(GLenum map, GLsizei bufSize, GLushort * values); +typedef void (GLAD_API_PTR *PFNGLGETNPOLYGONSTIPPLEARBPROC)(GLsizei bufSize, GLubyte * pattern); +typedef void (GLAD_API_PTR *PFNGLGETNSEPARABLEFILTERARBPROC)(GLenum target, GLenum format, GLenum type, GLsizei rowBufSize, void * row, GLsizei columnBufSize, void * column, void * span); +typedef void (GLAD_API_PTR *PFNGLGETNTEXIMAGEARBPROC)(GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, void * img); +typedef void (GLAD_API_PTR *PFNGLGETNUNIFORMDVARBPROC)(GLuint program, GLint location, GLsizei bufSize, GLdouble * params); +typedef void (GLAD_API_PTR *PFNGLGETNUNIFORMFVARBPROC)(GLuint program, GLint location, GLsizei bufSize, GLfloat * params); +typedef void (GLAD_API_PTR *PFNGLGETNUNIFORMIVARBPROC)(GLuint program, GLint location, GLsizei bufSize, GLint * params); +typedef void (GLAD_API_PTR *PFNGLGETNUNIFORMUIVARBPROC)(GLuint program, GLint location, GLsizei bufSize, GLuint * params); +typedef void (GLAD_API_PTR *PFNGLHINTPROC)(GLenum target, GLenum mode); +typedef void (GLAD_API_PTR *PFNGLINDEXMASKPROC)(GLuint mask); +typedef void (GLAD_API_PTR *PFNGLINDEXPOINTERPROC)(GLenum type, GLsizei stride, const void * pointer); +typedef void (GLAD_API_PTR *PFNGLINDEXDPROC)(GLdouble c); +typedef void (GLAD_API_PTR *PFNGLINDEXDVPROC)(const GLdouble * c); +typedef void (GLAD_API_PTR *PFNGLINDEXFPROC)(GLfloat c); +typedef void (GLAD_API_PTR *PFNGLINDEXFVPROC)(const GLfloat * c); +typedef void (GLAD_API_PTR *PFNGLINDEXIPROC)(GLint c); +typedef void (GLAD_API_PTR *PFNGLINDEXIVPROC)(const GLint * c); +typedef void (GLAD_API_PTR *PFNGLINDEXSPROC)(GLshort c); +typedef void (GLAD_API_PTR *PFNGLINDEXSVPROC)(const GLshort * c); +typedef void (GLAD_API_PTR *PFNGLINDEXUBPROC)(GLubyte c); +typedef void (GLAD_API_PTR *PFNGLINDEXUBVPROC)(const GLubyte * c); typedef void (GLAD_API_PTR *PFNGLINITNAMESPROC)(void); -typedef void (GLAD_API_PTR *PFNGLINTERLEAVEDARRAYSPROC)(GLenum format, GLsizei stride, const void * pointer); -typedef GLboolean (GLAD_API_PTR *PFNGLISBUFFERPROC)(GLuint buffer); -typedef GLboolean (GLAD_API_PTR *PFNGLISENABLEDPROC)(GLenum cap); -typedef GLboolean (GLAD_API_PTR *PFNGLISENABLEDIPROC)(GLenum target, GLuint index); -typedef GLboolean (GLAD_API_PTR *PFNGLISFRAMEBUFFERPROC)(GLuint framebuffer); -typedef GLboolean (GLAD_API_PTR *PFNGLISLISTPROC)(GLuint list); -typedef GLboolean (GLAD_API_PTR *PFNGLISPROGRAMPROC)(GLuint program); -typedef GLboolean (GLAD_API_PTR *PFNGLISQUERYPROC)(GLuint id); -typedef GLboolean (GLAD_API_PTR *PFNGLISRENDERBUFFERPROC)(GLuint renderbuffer); -typedef GLboolean (GLAD_API_PTR *PFNGLISSAMPLERPROC)(GLuint sampler); -typedef GLboolean (GLAD_API_PTR *PFNGLISSHADERPROC)(GLuint shader); -typedef GLboolean (GLAD_API_PTR *PFNGLISSYNCPROC)(GLsync sync); -typedef GLboolean (GLAD_API_PTR *PFNGLISTEXTUREPROC)(GLuint texture); -typedef GLboolean (GLAD_API_PTR *PFNGLISVERTEXARRAYPROC)(GLuint array); -typedef void (GLAD_API_PTR *PFNGLLIGHTMODELFPROC)(GLenum pname, GLfloat param); -typedef void (GLAD_API_PTR *PFNGLLIGHTMODELFVPROC)(GLenum pname, const GLfloat * params); -typedef void (GLAD_API_PTR *PFNGLLIGHTMODELIPROC)(GLenum pname, GLint param); -typedef void (GLAD_API_PTR *PFNGLLIGHTMODELIVPROC)(GLenum pname, const GLint * params); -typedef void (GLAD_API_PTR *PFNGLLIGHTFPROC)(GLenum light, GLenum pname, GLfloat param); -typedef void (GLAD_API_PTR *PFNGLLIGHTFVPROC)(GLenum light, GLenum pname, const GLfloat * params); -typedef void (GLAD_API_PTR *PFNGLLIGHTIPROC)(GLenum light, GLenum pname, GLint param); -typedef void (GLAD_API_PTR *PFNGLLIGHTIVPROC)(GLenum light, GLenum pname, const GLint * params); -typedef void (GLAD_API_PTR *PFNGLLINESTIPPLEPROC)(GLint factor, GLushort pattern); -typedef void (GLAD_API_PTR *PFNGLLINEWIDTHPROC)(GLfloat width); -typedef void (GLAD_API_PTR *PFNGLLINKPROGRAMPROC)(GLuint program); -typedef void (GLAD_API_PTR *PFNGLLISTBASEPROC)(GLuint base); +typedef void (GLAD_API_PTR *PFNGLINTERLEAVEDARRAYSPROC)(GLenum format, GLsizei stride, const void * pointer); +typedef GLboolean (GLAD_API_PTR *PFNGLISBUFFERPROC)(GLuint buffer); +typedef GLboolean (GLAD_API_PTR *PFNGLISENABLEDPROC)(GLenum cap); +typedef GLboolean (GLAD_API_PTR *PFNGLISENABLEDIPROC)(GLenum target, GLuint index); +typedef GLboolean (GLAD_API_PTR *PFNGLISFRAMEBUFFERPROC)(GLuint framebuffer); +typedef GLboolean (GLAD_API_PTR *PFNGLISLISTPROC)(GLuint list); +typedef GLboolean (GLAD_API_PTR *PFNGLISPROGRAMPROC)(GLuint program); +typedef GLboolean (GLAD_API_PTR *PFNGLISQUERYPROC)(GLuint id); +typedef GLboolean (GLAD_API_PTR *PFNGLISRENDERBUFFERPROC)(GLuint renderbuffer); +typedef GLboolean (GLAD_API_PTR *PFNGLISSAMPLERPROC)(GLuint sampler); +typedef GLboolean (GLAD_API_PTR *PFNGLISSHADERPROC)(GLuint shader); +typedef GLboolean (GLAD_API_PTR *PFNGLISSYNCPROC)(GLsync sync); +typedef GLboolean (GLAD_API_PTR *PFNGLISTEXTUREPROC)(GLuint texture); +typedef GLboolean (GLAD_API_PTR *PFNGLISVERTEXARRAYPROC)(GLuint array); +typedef void (GLAD_API_PTR *PFNGLLIGHTMODELFPROC)(GLenum pname, GLfloat param); +typedef void (GLAD_API_PTR *PFNGLLIGHTMODELFVPROC)(GLenum pname, const GLfloat * params); +typedef void (GLAD_API_PTR *PFNGLLIGHTMODELIPROC)(GLenum pname, GLint param); +typedef void (GLAD_API_PTR *PFNGLLIGHTMODELIVPROC)(GLenum pname, const GLint * params); +typedef void (GLAD_API_PTR *PFNGLLIGHTFPROC)(GLenum light, GLenum pname, GLfloat param); +typedef void (GLAD_API_PTR *PFNGLLIGHTFVPROC)(GLenum light, GLenum pname, const GLfloat * params); +typedef void (GLAD_API_PTR *PFNGLLIGHTIPROC)(GLenum light, GLenum pname, GLint param); +typedef void (GLAD_API_PTR *PFNGLLIGHTIVPROC)(GLenum light, GLenum pname, const GLint * params); +typedef void (GLAD_API_PTR *PFNGLLINESTIPPLEPROC)(GLint factor, GLushort pattern); +typedef void (GLAD_API_PTR *PFNGLLINEWIDTHPROC)(GLfloat width); +typedef void (GLAD_API_PTR *PFNGLLINKPROGRAMPROC)(GLuint program); +typedef void (GLAD_API_PTR *PFNGLLISTBASEPROC)(GLuint base); typedef void (GLAD_API_PTR *PFNGLLOADIDENTITYPROC)(void); -typedef void (GLAD_API_PTR *PFNGLLOADMATRIXDPROC)(const GLdouble * m); -typedef void (GLAD_API_PTR *PFNGLLOADMATRIXFPROC)(const GLfloat * m); -typedef void (GLAD_API_PTR *PFNGLLOADNAMEPROC)(GLuint name); -typedef void (GLAD_API_PTR *PFNGLLOADTRANSPOSEMATRIXDPROC)(const GLdouble * m); -typedef void (GLAD_API_PTR *PFNGLLOADTRANSPOSEMATRIXFPROC)(const GLfloat * m); -typedef void (GLAD_API_PTR *PFNGLLOGICOPPROC)(GLenum opcode); -typedef void (GLAD_API_PTR *PFNGLMAP1DPROC)(GLenum target, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble * points); -typedef void (GLAD_API_PTR *PFNGLMAP1FPROC)(GLenum target, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat * points); -typedef void (GLAD_API_PTR *PFNGLMAP2DPROC)(GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble * points); -typedef void (GLAD_API_PTR *PFNGLMAP2FPROC)(GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat * points); -typedef void * (GLAD_API_PTR *PFNGLMAPBUFFERPROC)(GLenum target, GLenum access); -typedef void * (GLAD_API_PTR *PFNGLMAPBUFFERRANGEPROC)(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); -typedef void (GLAD_API_PTR *PFNGLMAPGRID1DPROC)(GLint un, GLdouble u1, GLdouble u2); -typedef void (GLAD_API_PTR *PFNGLMAPGRID1FPROC)(GLint un, GLfloat u1, GLfloat u2); -typedef void (GLAD_API_PTR *PFNGLMAPGRID2DPROC)(GLint un, GLdouble u1, GLdouble u2, GLint vn, GLdouble v1, GLdouble v2); -typedef void (GLAD_API_PTR *PFNGLMAPGRID2FPROC)(GLint un, GLfloat u1, GLfloat u2, GLint vn, GLfloat v1, GLfloat v2); -typedef void (GLAD_API_PTR *PFNGLMATERIALFPROC)(GLenum face, GLenum pname, GLfloat param); -typedef void (GLAD_API_PTR *PFNGLMATERIALFVPROC)(GLenum face, GLenum pname, const GLfloat * params); -typedef void (GLAD_API_PTR *PFNGLMATERIALIPROC)(GLenum face, GLenum pname, GLint param); -typedef void (GLAD_API_PTR *PFNGLMATERIALIVPROC)(GLenum face, GLenum pname, const GLint * params); -typedef void (GLAD_API_PTR *PFNGLMATRIXMODEPROC)(GLenum mode); -typedef void (GLAD_API_PTR *PFNGLMULTMATRIXDPROC)(const GLdouble * m); -typedef void (GLAD_API_PTR *PFNGLMULTMATRIXFPROC)(const GLfloat * m); -typedef void (GLAD_API_PTR *PFNGLMULTTRANSPOSEMATRIXDPROC)(const GLdouble * m); -typedef void (GLAD_API_PTR *PFNGLMULTTRANSPOSEMATRIXFPROC)(const GLfloat * m); -typedef void (GLAD_API_PTR *PFNGLMULTIDRAWARRAYSPROC)(GLenum mode, const GLint * first, const GLsizei * count, GLsizei drawcount); -typedef void (GLAD_API_PTR *PFNGLMULTIDRAWELEMENTSPROC)(GLenum mode, const GLsizei * count, GLenum type, const void *const* indices, GLsizei drawcount); -typedef void (GLAD_API_PTR *PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC)(GLenum mode, const GLsizei * count, GLenum type, const void *const* indices, GLsizei drawcount, const GLint * basevertex); -typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD1DPROC)(GLenum target, GLdouble s); -typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD1DVPROC)(GLenum target, const GLdouble * v); -typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD1FPROC)(GLenum target, GLfloat s); -typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD1FVPROC)(GLenum target, const GLfloat * v); -typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD1IPROC)(GLenum target, GLint s); -typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD1IVPROC)(GLenum target, const GLint * v); -typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD1SPROC)(GLenum target, GLshort s); -typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD1SVPROC)(GLenum target, const GLshort * v); -typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD2DPROC)(GLenum target, GLdouble s, GLdouble t); -typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD2DVPROC)(GLenum target, const GLdouble * v); -typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD2FPROC)(GLenum target, GLfloat s, GLfloat t); -typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD2FVPROC)(GLenum target, const GLfloat * v); -typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD2IPROC)(GLenum target, GLint s, GLint t); -typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD2IVPROC)(GLenum target, const GLint * v); -typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD2SPROC)(GLenum target, GLshort s, GLshort t); -typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD2SVPROC)(GLenum target, const GLshort * v); -typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD3DPROC)(GLenum target, GLdouble s, GLdouble t, GLdouble r); -typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD3DVPROC)(GLenum target, const GLdouble * v); -typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD3FPROC)(GLenum target, GLfloat s, GLfloat t, GLfloat r); -typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD3FVPROC)(GLenum target, const GLfloat * v); -typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD3IPROC)(GLenum target, GLint s, GLint t, GLint r); -typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD3IVPROC)(GLenum target, const GLint * v); -typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD3SPROC)(GLenum target, GLshort s, GLshort t, GLshort r); -typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD3SVPROC)(GLenum target, const GLshort * v); -typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD4DPROC)(GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); -typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD4DVPROC)(GLenum target, const GLdouble * v); -typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD4FPROC)(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); -typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD4FVPROC)(GLenum target, const GLfloat * v); -typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD4IPROC)(GLenum target, GLint s, GLint t, GLint r, GLint q); -typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD4IVPROC)(GLenum target, const GLint * v); -typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD4SPROC)(GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); -typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD4SVPROC)(GLenum target, const GLshort * v); -typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORDP1UIPROC)(GLenum texture, GLenum type, GLuint coords); -typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORDP1UIVPROC)(GLenum texture, GLenum type, const GLuint * coords); -typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORDP2UIPROC)(GLenum texture, GLenum type, GLuint coords); -typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORDP2UIVPROC)(GLenum texture, GLenum type, const GLuint * coords); -typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORDP3UIPROC)(GLenum texture, GLenum type, GLuint coords); -typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORDP3UIVPROC)(GLenum texture, GLenum type, const GLuint * coords); -typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORDP4UIPROC)(GLenum texture, GLenum type, GLuint coords); -typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORDP4UIVPROC)(GLenum texture, GLenum type, const GLuint * coords); -typedef void (GLAD_API_PTR *PFNGLNEWLISTPROC)(GLuint list, GLenum mode); -typedef void (GLAD_API_PTR *PFNGLNORMAL3BPROC)(GLbyte nx, GLbyte ny, GLbyte nz); -typedef void (GLAD_API_PTR *PFNGLNORMAL3BVPROC)(const GLbyte * v); -typedef void (GLAD_API_PTR *PFNGLNORMAL3DPROC)(GLdouble nx, GLdouble ny, GLdouble nz); -typedef void (GLAD_API_PTR *PFNGLNORMAL3DVPROC)(const GLdouble * v); -typedef void (GLAD_API_PTR *PFNGLNORMAL3FPROC)(GLfloat nx, GLfloat ny, GLfloat nz); -typedef void (GLAD_API_PTR *PFNGLNORMAL3FVPROC)(const GLfloat * v); -typedef void (GLAD_API_PTR *PFNGLNORMAL3IPROC)(GLint nx, GLint ny, GLint nz); -typedef void (GLAD_API_PTR *PFNGLNORMAL3IVPROC)(const GLint * v); -typedef void (GLAD_API_PTR *PFNGLNORMAL3SPROC)(GLshort nx, GLshort ny, GLshort nz); -typedef void (GLAD_API_PTR *PFNGLNORMAL3SVPROC)(const GLshort * v); -typedef void (GLAD_API_PTR *PFNGLNORMALP3UIPROC)(GLenum type, GLuint coords); -typedef void (GLAD_API_PTR *PFNGLNORMALP3UIVPROC)(GLenum type, const GLuint * coords); -typedef void (GLAD_API_PTR *PFNGLNORMALPOINTERPROC)(GLenum type, GLsizei stride, const void * pointer); -typedef void (GLAD_API_PTR *PFNGLOBJECTLABELPROC)(GLenum identifier, GLuint name, GLsizei length, const GLchar * label); -typedef void (GLAD_API_PTR *PFNGLOBJECTPTRLABELPROC)(const void * ptr, GLsizei length, const GLchar * label); -typedef void (GLAD_API_PTR *PFNGLORTHOPROC)(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); -typedef void (GLAD_API_PTR *PFNGLPASSTHROUGHPROC)(GLfloat token); -typedef void (GLAD_API_PTR *PFNGLPIXELMAPFVPROC)(GLenum map, GLsizei mapsize, const GLfloat * values); -typedef void (GLAD_API_PTR *PFNGLPIXELMAPUIVPROC)(GLenum map, GLsizei mapsize, const GLuint * values); -typedef void (GLAD_API_PTR *PFNGLPIXELMAPUSVPROC)(GLenum map, GLsizei mapsize, const GLushort * values); -typedef void (GLAD_API_PTR *PFNGLPIXELSTOREFPROC)(GLenum pname, GLfloat param); -typedef void (GLAD_API_PTR *PFNGLPIXELSTOREIPROC)(GLenum pname, GLint param); -typedef void (GLAD_API_PTR *PFNGLPIXELTRANSFERFPROC)(GLenum pname, GLfloat param); -typedef void (GLAD_API_PTR *PFNGLPIXELTRANSFERIPROC)(GLenum pname, GLint param); -typedef void (GLAD_API_PTR *PFNGLPIXELZOOMPROC)(GLfloat xfactor, GLfloat yfactor); -typedef void (GLAD_API_PTR *PFNGLPOINTPARAMETERFPROC)(GLenum pname, GLfloat param); -typedef void (GLAD_API_PTR *PFNGLPOINTPARAMETERFVPROC)(GLenum pname, const GLfloat * params); -typedef void (GLAD_API_PTR *PFNGLPOINTPARAMETERIPROC)(GLenum pname, GLint param); -typedef void (GLAD_API_PTR *PFNGLPOINTPARAMETERIVPROC)(GLenum pname, const GLint * params); -typedef void (GLAD_API_PTR *PFNGLPOINTSIZEPROC)(GLfloat size); -typedef void (GLAD_API_PTR *PFNGLPOLYGONMODEPROC)(GLenum face, GLenum mode); -typedef void (GLAD_API_PTR *PFNGLPOLYGONOFFSETPROC)(GLfloat factor, GLfloat units); -typedef void (GLAD_API_PTR *PFNGLPOLYGONSTIPPLEPROC)(const GLubyte * mask); +typedef void (GLAD_API_PTR *PFNGLLOADMATRIXDPROC)(const GLdouble * m); +typedef void (GLAD_API_PTR *PFNGLLOADMATRIXFPROC)(const GLfloat * m); +typedef void (GLAD_API_PTR *PFNGLLOADNAMEPROC)(GLuint name); +typedef void (GLAD_API_PTR *PFNGLLOADTRANSPOSEMATRIXDPROC)(const GLdouble * m); +typedef void (GLAD_API_PTR *PFNGLLOADTRANSPOSEMATRIXFPROC)(const GLfloat * m); +typedef void (GLAD_API_PTR *PFNGLLOGICOPPROC)(GLenum opcode); +typedef void (GLAD_API_PTR *PFNGLMAP1DPROC)(GLenum target, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble * points); +typedef void (GLAD_API_PTR *PFNGLMAP1FPROC)(GLenum target, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat * points); +typedef void (GLAD_API_PTR *PFNGLMAP2DPROC)(GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble * points); +typedef void (GLAD_API_PTR *PFNGLMAP2FPROC)(GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat * points); +typedef void * (GLAD_API_PTR *PFNGLMAPBUFFERPROC)(GLenum target, GLenum access); +typedef void * (GLAD_API_PTR *PFNGLMAPBUFFERRANGEPROC)(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); +typedef void (GLAD_API_PTR *PFNGLMAPGRID1DPROC)(GLint un, GLdouble u1, GLdouble u2); +typedef void (GLAD_API_PTR *PFNGLMAPGRID1FPROC)(GLint un, GLfloat u1, GLfloat u2); +typedef void (GLAD_API_PTR *PFNGLMAPGRID2DPROC)(GLint un, GLdouble u1, GLdouble u2, GLint vn, GLdouble v1, GLdouble v2); +typedef void (GLAD_API_PTR *PFNGLMAPGRID2FPROC)(GLint un, GLfloat u1, GLfloat u2, GLint vn, GLfloat v1, GLfloat v2); +typedef void (GLAD_API_PTR *PFNGLMATERIALFPROC)(GLenum face, GLenum pname, GLfloat param); +typedef void (GLAD_API_PTR *PFNGLMATERIALFVPROC)(GLenum face, GLenum pname, const GLfloat * params); +typedef void (GLAD_API_PTR *PFNGLMATERIALIPROC)(GLenum face, GLenum pname, GLint param); +typedef void (GLAD_API_PTR *PFNGLMATERIALIVPROC)(GLenum face, GLenum pname, const GLint * params); +typedef void (GLAD_API_PTR *PFNGLMATRIXMODEPROC)(GLenum mode); +typedef void (GLAD_API_PTR *PFNGLMULTMATRIXDPROC)(const GLdouble * m); +typedef void (GLAD_API_PTR *PFNGLMULTMATRIXFPROC)(const GLfloat * m); +typedef void (GLAD_API_PTR *PFNGLMULTTRANSPOSEMATRIXDPROC)(const GLdouble * m); +typedef void (GLAD_API_PTR *PFNGLMULTTRANSPOSEMATRIXFPROC)(const GLfloat * m); +typedef void (GLAD_API_PTR *PFNGLMULTIDRAWARRAYSPROC)(GLenum mode, const GLint * first, const GLsizei * count, GLsizei drawcount); +typedef void (GLAD_API_PTR *PFNGLMULTIDRAWELEMENTSPROC)(GLenum mode, const GLsizei * count, GLenum type, const void *const* indices, GLsizei drawcount); +typedef void (GLAD_API_PTR *PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC)(GLenum mode, const GLsizei * count, GLenum type, const void *const* indices, GLsizei drawcount, const GLint * basevertex); +typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD1DPROC)(GLenum target, GLdouble s); +typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD1DVPROC)(GLenum target, const GLdouble * v); +typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD1FPROC)(GLenum target, GLfloat s); +typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD1FVPROC)(GLenum target, const GLfloat * v); +typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD1IPROC)(GLenum target, GLint s); +typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD1IVPROC)(GLenum target, const GLint * v); +typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD1SPROC)(GLenum target, GLshort s); +typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD1SVPROC)(GLenum target, const GLshort * v); +typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD2DPROC)(GLenum target, GLdouble s, GLdouble t); +typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD2DVPROC)(GLenum target, const GLdouble * v); +typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD2FPROC)(GLenum target, GLfloat s, GLfloat t); +typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD2FVPROC)(GLenum target, const GLfloat * v); +typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD2IPROC)(GLenum target, GLint s, GLint t); +typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD2IVPROC)(GLenum target, const GLint * v); +typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD2SPROC)(GLenum target, GLshort s, GLshort t); +typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD2SVPROC)(GLenum target, const GLshort * v); +typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD3DPROC)(GLenum target, GLdouble s, GLdouble t, GLdouble r); +typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD3DVPROC)(GLenum target, const GLdouble * v); +typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD3FPROC)(GLenum target, GLfloat s, GLfloat t, GLfloat r); +typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD3FVPROC)(GLenum target, const GLfloat * v); +typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD3IPROC)(GLenum target, GLint s, GLint t, GLint r); +typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD3IVPROC)(GLenum target, const GLint * v); +typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD3SPROC)(GLenum target, GLshort s, GLshort t, GLshort r); +typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD3SVPROC)(GLenum target, const GLshort * v); +typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD4DPROC)(GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD4DVPROC)(GLenum target, const GLdouble * v); +typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD4FPROC)(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD4FVPROC)(GLenum target, const GLfloat * v); +typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD4IPROC)(GLenum target, GLint s, GLint t, GLint r, GLint q); +typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD4IVPROC)(GLenum target, const GLint * v); +typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD4SPROC)(GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD4SVPROC)(GLenum target, const GLshort * v); +typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORDP1UIPROC)(GLenum texture, GLenum type, GLuint coords); +typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORDP1UIVPROC)(GLenum texture, GLenum type, const GLuint * coords); +typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORDP2UIPROC)(GLenum texture, GLenum type, GLuint coords); +typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORDP2UIVPROC)(GLenum texture, GLenum type, const GLuint * coords); +typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORDP3UIPROC)(GLenum texture, GLenum type, GLuint coords); +typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORDP3UIVPROC)(GLenum texture, GLenum type, const GLuint * coords); +typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORDP4UIPROC)(GLenum texture, GLenum type, GLuint coords); +typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORDP4UIVPROC)(GLenum texture, GLenum type, const GLuint * coords); +typedef void (GLAD_API_PTR *PFNGLNEWLISTPROC)(GLuint list, GLenum mode); +typedef void (GLAD_API_PTR *PFNGLNORMAL3BPROC)(GLbyte nx, GLbyte ny, GLbyte nz); +typedef void (GLAD_API_PTR *PFNGLNORMAL3BVPROC)(const GLbyte * v); +typedef void (GLAD_API_PTR *PFNGLNORMAL3DPROC)(GLdouble nx, GLdouble ny, GLdouble nz); +typedef void (GLAD_API_PTR *PFNGLNORMAL3DVPROC)(const GLdouble * v); +typedef void (GLAD_API_PTR *PFNGLNORMAL3FPROC)(GLfloat nx, GLfloat ny, GLfloat nz); +typedef void (GLAD_API_PTR *PFNGLNORMAL3FVPROC)(const GLfloat * v); +typedef void (GLAD_API_PTR *PFNGLNORMAL3IPROC)(GLint nx, GLint ny, GLint nz); +typedef void (GLAD_API_PTR *PFNGLNORMAL3IVPROC)(const GLint * v); +typedef void (GLAD_API_PTR *PFNGLNORMAL3SPROC)(GLshort nx, GLshort ny, GLshort nz); +typedef void (GLAD_API_PTR *PFNGLNORMAL3SVPROC)(const GLshort * v); +typedef void (GLAD_API_PTR *PFNGLNORMALP3UIPROC)(GLenum type, GLuint coords); +typedef void (GLAD_API_PTR *PFNGLNORMALP3UIVPROC)(GLenum type, const GLuint * coords); +typedef void (GLAD_API_PTR *PFNGLNORMALPOINTERPROC)(GLenum type, GLsizei stride, const void * pointer); +typedef void (GLAD_API_PTR *PFNGLOBJECTLABELPROC)(GLenum identifier, GLuint name, GLsizei length, const GLchar * label); +typedef void (GLAD_API_PTR *PFNGLOBJECTPTRLABELPROC)(const void * ptr, GLsizei length, const GLchar * label); +typedef void (GLAD_API_PTR *PFNGLORTHOPROC)(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +typedef void (GLAD_API_PTR *PFNGLPASSTHROUGHPROC)(GLfloat token); +typedef void (GLAD_API_PTR *PFNGLPIXELMAPFVPROC)(GLenum map, GLsizei mapsize, const GLfloat * values); +typedef void (GLAD_API_PTR *PFNGLPIXELMAPUIVPROC)(GLenum map, GLsizei mapsize, const GLuint * values); +typedef void (GLAD_API_PTR *PFNGLPIXELMAPUSVPROC)(GLenum map, GLsizei mapsize, const GLushort * values); +typedef void (GLAD_API_PTR *PFNGLPIXELSTOREFPROC)(GLenum pname, GLfloat param); +typedef void (GLAD_API_PTR *PFNGLPIXELSTOREIPROC)(GLenum pname, GLint param); +typedef void (GLAD_API_PTR *PFNGLPIXELTRANSFERFPROC)(GLenum pname, GLfloat param); +typedef void (GLAD_API_PTR *PFNGLPIXELTRANSFERIPROC)(GLenum pname, GLint param); +typedef void (GLAD_API_PTR *PFNGLPIXELZOOMPROC)(GLfloat xfactor, GLfloat yfactor); +typedef void (GLAD_API_PTR *PFNGLPOINTPARAMETERFPROC)(GLenum pname, GLfloat param); +typedef void (GLAD_API_PTR *PFNGLPOINTPARAMETERFVPROC)(GLenum pname, const GLfloat * params); +typedef void (GLAD_API_PTR *PFNGLPOINTPARAMETERIPROC)(GLenum pname, GLint param); +typedef void (GLAD_API_PTR *PFNGLPOINTPARAMETERIVPROC)(GLenum pname, const GLint * params); +typedef void (GLAD_API_PTR *PFNGLPOINTSIZEPROC)(GLfloat size); +typedef void (GLAD_API_PTR *PFNGLPOLYGONMODEPROC)(GLenum face, GLenum mode); +typedef void (GLAD_API_PTR *PFNGLPOLYGONOFFSETPROC)(GLfloat factor, GLfloat units); +typedef void (GLAD_API_PTR *PFNGLPOLYGONSTIPPLEPROC)(const GLubyte * mask); typedef void (GLAD_API_PTR *PFNGLPOPATTRIBPROC)(void); typedef void (GLAD_API_PTR *PFNGLPOPCLIENTATTRIBPROC)(void); typedef void (GLAD_API_PTR *PFNGLPOPDEBUGGROUPPROC)(void); typedef void (GLAD_API_PTR *PFNGLPOPMATRIXPROC)(void); typedef void (GLAD_API_PTR *PFNGLPOPNAMEPROC)(void); -typedef void (GLAD_API_PTR *PFNGLPRIMITIVERESTARTINDEXPROC)(GLuint index); -typedef void (GLAD_API_PTR *PFNGLPRIORITIZETEXTURESPROC)(GLsizei n, const GLuint * textures, const GLfloat * priorities); -typedef void (GLAD_API_PTR *PFNGLPROVOKINGVERTEXPROC)(GLenum mode); -typedef void (GLAD_API_PTR *PFNGLPUSHATTRIBPROC)(GLbitfield mask); -typedef void (GLAD_API_PTR *PFNGLPUSHCLIENTATTRIBPROC)(GLbitfield mask); -typedef void (GLAD_API_PTR *PFNGLPUSHDEBUGGROUPPROC)(GLenum source, GLuint id, GLsizei length, const GLchar * message); +typedef void (GLAD_API_PTR *PFNGLPRIMITIVERESTARTINDEXPROC)(GLuint index); +typedef void (GLAD_API_PTR *PFNGLPRIORITIZETEXTURESPROC)(GLsizei n, const GLuint * textures, const GLfloat * priorities); +typedef void (GLAD_API_PTR *PFNGLPROVOKINGVERTEXPROC)(GLenum mode); +typedef void (GLAD_API_PTR *PFNGLPUSHATTRIBPROC)(GLbitfield mask); +typedef void (GLAD_API_PTR *PFNGLPUSHCLIENTATTRIBPROC)(GLbitfield mask); +typedef void (GLAD_API_PTR *PFNGLPUSHDEBUGGROUPPROC)(GLenum source, GLuint id, GLsizei length, const GLchar * message); typedef void (GLAD_API_PTR *PFNGLPUSHMATRIXPROC)(void); -typedef void (GLAD_API_PTR *PFNGLPUSHNAMEPROC)(GLuint name); -typedef void (GLAD_API_PTR *PFNGLQUERYCOUNTERPROC)(GLuint id, GLenum target); -typedef void (GLAD_API_PTR *PFNGLRASTERPOS2DPROC)(GLdouble x, GLdouble y); -typedef void (GLAD_API_PTR *PFNGLRASTERPOS2DVPROC)(const GLdouble * v); -typedef void (GLAD_API_PTR *PFNGLRASTERPOS2FPROC)(GLfloat x, GLfloat y); -typedef void (GLAD_API_PTR *PFNGLRASTERPOS2FVPROC)(const GLfloat * v); -typedef void (GLAD_API_PTR *PFNGLRASTERPOS2IPROC)(GLint x, GLint y); -typedef void (GLAD_API_PTR *PFNGLRASTERPOS2IVPROC)(const GLint * v); -typedef void (GLAD_API_PTR *PFNGLRASTERPOS2SPROC)(GLshort x, GLshort y); -typedef void (GLAD_API_PTR *PFNGLRASTERPOS2SVPROC)(const GLshort * v); -typedef void (GLAD_API_PTR *PFNGLRASTERPOS3DPROC)(GLdouble x, GLdouble y, GLdouble z); -typedef void (GLAD_API_PTR *PFNGLRASTERPOS3DVPROC)(const GLdouble * v); -typedef void (GLAD_API_PTR *PFNGLRASTERPOS3FPROC)(GLfloat x, GLfloat y, GLfloat z); -typedef void (GLAD_API_PTR *PFNGLRASTERPOS3FVPROC)(const GLfloat * v); -typedef void (GLAD_API_PTR *PFNGLRASTERPOS3IPROC)(GLint x, GLint y, GLint z); -typedef void (GLAD_API_PTR *PFNGLRASTERPOS3IVPROC)(const GLint * v); -typedef void (GLAD_API_PTR *PFNGLRASTERPOS3SPROC)(GLshort x, GLshort y, GLshort z); -typedef void (GLAD_API_PTR *PFNGLRASTERPOS3SVPROC)(const GLshort * v); -typedef void (GLAD_API_PTR *PFNGLRASTERPOS4DPROC)(GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (GLAD_API_PTR *PFNGLRASTERPOS4DVPROC)(const GLdouble * v); -typedef void (GLAD_API_PTR *PFNGLRASTERPOS4FPROC)(GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (GLAD_API_PTR *PFNGLRASTERPOS4FVPROC)(const GLfloat * v); -typedef void (GLAD_API_PTR *PFNGLRASTERPOS4IPROC)(GLint x, GLint y, GLint z, GLint w); -typedef void (GLAD_API_PTR *PFNGLRASTERPOS4IVPROC)(const GLint * v); -typedef void (GLAD_API_PTR *PFNGLRASTERPOS4SPROC)(GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (GLAD_API_PTR *PFNGLRASTERPOS4SVPROC)(const GLshort * v); -typedef void (GLAD_API_PTR *PFNGLREADBUFFERPROC)(GLenum src); -typedef void (GLAD_API_PTR *PFNGLREADPIXELSPROC)(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void * pixels); -typedef void (GLAD_API_PTR *PFNGLREADNPIXELSPROC)(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void * data); -typedef void (GLAD_API_PTR *PFNGLREADNPIXELSARBPROC)(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void * data); -typedef void (GLAD_API_PTR *PFNGLRECTDPROC)(GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2); -typedef void (GLAD_API_PTR *PFNGLRECTDVPROC)(const GLdouble * v1, const GLdouble * v2); -typedef void (GLAD_API_PTR *PFNGLRECTFPROC)(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2); -typedef void (GLAD_API_PTR *PFNGLRECTFVPROC)(const GLfloat * v1, const GLfloat * v2); -typedef void (GLAD_API_PTR *PFNGLRECTIPROC)(GLint x1, GLint y1, GLint x2, GLint y2); -typedef void (GLAD_API_PTR *PFNGLRECTIVPROC)(const GLint * v1, const GLint * v2); -typedef void (GLAD_API_PTR *PFNGLRECTSPROC)(GLshort x1, GLshort y1, GLshort x2, GLshort y2); -typedef void (GLAD_API_PTR *PFNGLRECTSVPROC)(const GLshort * v1, const GLshort * v2); -typedef GLint (GLAD_API_PTR *PFNGLRENDERMODEPROC)(GLenum mode); -typedef void (GLAD_API_PTR *PFNGLRENDERBUFFERSTORAGEPROC)(GLenum target, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (GLAD_API_PTR *PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (GLAD_API_PTR *PFNGLROTATEDPROC)(GLdouble angle, GLdouble x, GLdouble y, GLdouble z); -typedef void (GLAD_API_PTR *PFNGLROTATEFPROC)(GLfloat angle, GLfloat x, GLfloat y, GLfloat z); -typedef void (GLAD_API_PTR *PFNGLSAMPLECOVERAGEPROC)(GLfloat value, GLboolean invert); -typedef void (GLAD_API_PTR *PFNGLSAMPLECOVERAGEARBPROC)(GLfloat value, GLboolean invert); -typedef void (GLAD_API_PTR *PFNGLSAMPLEMASKIPROC)(GLuint maskNumber, GLbitfield mask); -typedef void (GLAD_API_PTR *PFNGLSAMPLERPARAMETERIIVPROC)(GLuint sampler, GLenum pname, const GLint * param); -typedef void (GLAD_API_PTR *PFNGLSAMPLERPARAMETERIUIVPROC)(GLuint sampler, GLenum pname, const GLuint * param); -typedef void (GLAD_API_PTR *PFNGLSAMPLERPARAMETERFPROC)(GLuint sampler, GLenum pname, GLfloat param); -typedef void (GLAD_API_PTR *PFNGLSAMPLERPARAMETERFVPROC)(GLuint sampler, GLenum pname, const GLfloat * param); -typedef void (GLAD_API_PTR *PFNGLSAMPLERPARAMETERIPROC)(GLuint sampler, GLenum pname, GLint param); -typedef void (GLAD_API_PTR *PFNGLSAMPLERPARAMETERIVPROC)(GLuint sampler, GLenum pname, const GLint * param); -typedef void (GLAD_API_PTR *PFNGLSCALEDPROC)(GLdouble x, GLdouble y, GLdouble z); -typedef void (GLAD_API_PTR *PFNGLSCALEFPROC)(GLfloat x, GLfloat y, GLfloat z); -typedef void (GLAD_API_PTR *PFNGLSCISSORPROC)(GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLOR3BPROC)(GLbyte red, GLbyte green, GLbyte blue); -typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLOR3BVPROC)(const GLbyte * v); -typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLOR3DPROC)(GLdouble red, GLdouble green, GLdouble blue); -typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLOR3DVPROC)(const GLdouble * v); -typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLOR3FPROC)(GLfloat red, GLfloat green, GLfloat blue); -typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLOR3FVPROC)(const GLfloat * v); -typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLOR3IPROC)(GLint red, GLint green, GLint blue); -typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLOR3IVPROC)(const GLint * v); -typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLOR3SPROC)(GLshort red, GLshort green, GLshort blue); -typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLOR3SVPROC)(const GLshort * v); -typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLOR3UBPROC)(GLubyte red, GLubyte green, GLubyte blue); -typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLOR3UBVPROC)(const GLubyte * v); -typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLOR3UIPROC)(GLuint red, GLuint green, GLuint blue); -typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLOR3UIVPROC)(const GLuint * v); -typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLOR3USPROC)(GLushort red, GLushort green, GLushort blue); -typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLOR3USVPROC)(const GLushort * v); -typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLORP3UIPROC)(GLenum type, GLuint color); -typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLORP3UIVPROC)(GLenum type, const GLuint * color); -typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLORPOINTERPROC)(GLint size, GLenum type, GLsizei stride, const void * pointer); -typedef void (GLAD_API_PTR *PFNGLSELECTBUFFERPROC)(GLsizei size, GLuint * buffer); -typedef void (GLAD_API_PTR *PFNGLSHADEMODELPROC)(GLenum mode); -typedef void (GLAD_API_PTR *PFNGLSHADERSOURCEPROC)(GLuint shader, GLsizei count, const GLchar *const* string, const GLint * length); -typedef void (GLAD_API_PTR *PFNGLSTENCILFUNCPROC)(GLenum func, GLint ref, GLuint mask); -typedef void (GLAD_API_PTR *PFNGLSTENCILFUNCSEPARATEPROC)(GLenum face, GLenum func, GLint ref, GLuint mask); -typedef void (GLAD_API_PTR *PFNGLSTENCILMASKPROC)(GLuint mask); -typedef void (GLAD_API_PTR *PFNGLSTENCILMASKSEPARATEPROC)(GLenum face, GLuint mask); -typedef void (GLAD_API_PTR *PFNGLSTENCILOPPROC)(GLenum fail, GLenum zfail, GLenum zpass); -typedef void (GLAD_API_PTR *PFNGLSTENCILOPSEPARATEPROC)(GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); -typedef void (GLAD_API_PTR *PFNGLTEXBUFFERPROC)(GLenum target, GLenum internalformat, GLuint buffer); -typedef void (GLAD_API_PTR *PFNGLTEXCOORD1DPROC)(GLdouble s); -typedef void (GLAD_API_PTR *PFNGLTEXCOORD1DVPROC)(const GLdouble * v); -typedef void (GLAD_API_PTR *PFNGLTEXCOORD1FPROC)(GLfloat s); -typedef void (GLAD_API_PTR *PFNGLTEXCOORD1FVPROC)(const GLfloat * v); -typedef void (GLAD_API_PTR *PFNGLTEXCOORD1IPROC)(GLint s); -typedef void (GLAD_API_PTR *PFNGLTEXCOORD1IVPROC)(const GLint * v); -typedef void (GLAD_API_PTR *PFNGLTEXCOORD1SPROC)(GLshort s); -typedef void (GLAD_API_PTR *PFNGLTEXCOORD1SVPROC)(const GLshort * v); -typedef void (GLAD_API_PTR *PFNGLTEXCOORD2DPROC)(GLdouble s, GLdouble t); -typedef void (GLAD_API_PTR *PFNGLTEXCOORD2DVPROC)(const GLdouble * v); -typedef void (GLAD_API_PTR *PFNGLTEXCOORD2FPROC)(GLfloat s, GLfloat t); -typedef void (GLAD_API_PTR *PFNGLTEXCOORD2FVPROC)(const GLfloat * v); -typedef void (GLAD_API_PTR *PFNGLTEXCOORD2IPROC)(GLint s, GLint t); -typedef void (GLAD_API_PTR *PFNGLTEXCOORD2IVPROC)(const GLint * v); -typedef void (GLAD_API_PTR *PFNGLTEXCOORD2SPROC)(GLshort s, GLshort t); -typedef void (GLAD_API_PTR *PFNGLTEXCOORD2SVPROC)(const GLshort * v); -typedef void (GLAD_API_PTR *PFNGLTEXCOORD3DPROC)(GLdouble s, GLdouble t, GLdouble r); -typedef void (GLAD_API_PTR *PFNGLTEXCOORD3DVPROC)(const GLdouble * v); -typedef void (GLAD_API_PTR *PFNGLTEXCOORD3FPROC)(GLfloat s, GLfloat t, GLfloat r); -typedef void (GLAD_API_PTR *PFNGLTEXCOORD3FVPROC)(const GLfloat * v); -typedef void (GLAD_API_PTR *PFNGLTEXCOORD3IPROC)(GLint s, GLint t, GLint r); -typedef void (GLAD_API_PTR *PFNGLTEXCOORD3IVPROC)(const GLint * v); -typedef void (GLAD_API_PTR *PFNGLTEXCOORD3SPROC)(GLshort s, GLshort t, GLshort r); -typedef void (GLAD_API_PTR *PFNGLTEXCOORD3SVPROC)(const GLshort * v); -typedef void (GLAD_API_PTR *PFNGLTEXCOORD4DPROC)(GLdouble s, GLdouble t, GLdouble r, GLdouble q); -typedef void (GLAD_API_PTR *PFNGLTEXCOORD4DVPROC)(const GLdouble * v); -typedef void (GLAD_API_PTR *PFNGLTEXCOORD4FPROC)(GLfloat s, GLfloat t, GLfloat r, GLfloat q); -typedef void (GLAD_API_PTR *PFNGLTEXCOORD4FVPROC)(const GLfloat * v); -typedef void (GLAD_API_PTR *PFNGLTEXCOORD4IPROC)(GLint s, GLint t, GLint r, GLint q); -typedef void (GLAD_API_PTR *PFNGLTEXCOORD4IVPROC)(const GLint * v); -typedef void (GLAD_API_PTR *PFNGLTEXCOORD4SPROC)(GLshort s, GLshort t, GLshort r, GLshort q); -typedef void (GLAD_API_PTR *PFNGLTEXCOORD4SVPROC)(const GLshort * v); -typedef void (GLAD_API_PTR *PFNGLTEXCOORDP1UIPROC)(GLenum type, GLuint coords); -typedef void (GLAD_API_PTR *PFNGLTEXCOORDP1UIVPROC)(GLenum type, const GLuint * coords); -typedef void (GLAD_API_PTR *PFNGLTEXCOORDP2UIPROC)(GLenum type, GLuint coords); -typedef void (GLAD_API_PTR *PFNGLTEXCOORDP2UIVPROC)(GLenum type, const GLuint * coords); -typedef void (GLAD_API_PTR *PFNGLTEXCOORDP3UIPROC)(GLenum type, GLuint coords); -typedef void (GLAD_API_PTR *PFNGLTEXCOORDP3UIVPROC)(GLenum type, const GLuint * coords); -typedef void (GLAD_API_PTR *PFNGLTEXCOORDP4UIPROC)(GLenum type, GLuint coords); -typedef void (GLAD_API_PTR *PFNGLTEXCOORDP4UIVPROC)(GLenum type, const GLuint * coords); -typedef void (GLAD_API_PTR *PFNGLTEXCOORDPOINTERPROC)(GLint size, GLenum type, GLsizei stride, const void * pointer); -typedef void (GLAD_API_PTR *PFNGLTEXENVFPROC)(GLenum target, GLenum pname, GLfloat param); -typedef void (GLAD_API_PTR *PFNGLTEXENVFVPROC)(GLenum target, GLenum pname, const GLfloat * params); -typedef void (GLAD_API_PTR *PFNGLTEXENVIPROC)(GLenum target, GLenum pname, GLint param); -typedef void (GLAD_API_PTR *PFNGLTEXENVIVPROC)(GLenum target, GLenum pname, const GLint * params); -typedef void (GLAD_API_PTR *PFNGLTEXGENDPROC)(GLenum coord, GLenum pname, GLdouble param); -typedef void (GLAD_API_PTR *PFNGLTEXGENDVPROC)(GLenum coord, GLenum pname, const GLdouble * params); -typedef void (GLAD_API_PTR *PFNGLTEXGENFPROC)(GLenum coord, GLenum pname, GLfloat param); -typedef void (GLAD_API_PTR *PFNGLTEXGENFVPROC)(GLenum coord, GLenum pname, const GLfloat * params); -typedef void (GLAD_API_PTR *PFNGLTEXGENIPROC)(GLenum coord, GLenum pname, GLint param); -typedef void (GLAD_API_PTR *PFNGLTEXGENIVPROC)(GLenum coord, GLenum pname, const GLint * params); -typedef void (GLAD_API_PTR *PFNGLTEXIMAGE1DPROC)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void * pixels); -typedef void (GLAD_API_PTR *PFNGLTEXIMAGE2DPROC)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void * pixels); -typedef void (GLAD_API_PTR *PFNGLTEXIMAGE2DMULTISAMPLEPROC)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); -typedef void (GLAD_API_PTR *PFNGLTEXIMAGE3DPROC)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void * pixels); -typedef void (GLAD_API_PTR *PFNGLTEXIMAGE3DMULTISAMPLEPROC)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); -typedef void (GLAD_API_PTR *PFNGLTEXPARAMETERIIVPROC)(GLenum target, GLenum pname, const GLint * params); -typedef void (GLAD_API_PTR *PFNGLTEXPARAMETERIUIVPROC)(GLenum target, GLenum pname, const GLuint * params); -typedef void (GLAD_API_PTR *PFNGLTEXPARAMETERFPROC)(GLenum target, GLenum pname, GLfloat param); -typedef void (GLAD_API_PTR *PFNGLTEXPARAMETERFVPROC)(GLenum target, GLenum pname, const GLfloat * params); -typedef void (GLAD_API_PTR *PFNGLTEXPARAMETERIPROC)(GLenum target, GLenum pname, GLint param); -typedef void (GLAD_API_PTR *PFNGLTEXPARAMETERIVPROC)(GLenum target, GLenum pname, const GLint * params); -typedef void (GLAD_API_PTR *PFNGLTEXSUBIMAGE1DPROC)(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void * pixels); -typedef void (GLAD_API_PTR *PFNGLTEXSUBIMAGE2DPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void * pixels); -typedef void (GLAD_API_PTR *PFNGLTEXSUBIMAGE3DPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void * pixels); -typedef void (GLAD_API_PTR *PFNGLTRANSFORMFEEDBACKVARYINGSPROC)(GLuint program, GLsizei count, const GLchar *const* varyings, GLenum bufferMode); -typedef void (GLAD_API_PTR *PFNGLTRANSLATEDPROC)(GLdouble x, GLdouble y, GLdouble z); -typedef void (GLAD_API_PTR *PFNGLTRANSLATEFPROC)(GLfloat x, GLfloat y, GLfloat z); -typedef void (GLAD_API_PTR *PFNGLUNIFORM1FPROC)(GLint location, GLfloat v0); -typedef void (GLAD_API_PTR *PFNGLUNIFORM1FVPROC)(GLint location, GLsizei count, const GLfloat * value); -typedef void (GLAD_API_PTR *PFNGLUNIFORM1IPROC)(GLint location, GLint v0); -typedef void (GLAD_API_PTR *PFNGLUNIFORM1IVPROC)(GLint location, GLsizei count, const GLint * value); -typedef void (GLAD_API_PTR *PFNGLUNIFORM1UIPROC)(GLint location, GLuint v0); -typedef void (GLAD_API_PTR *PFNGLUNIFORM1UIVPROC)(GLint location, GLsizei count, const GLuint * value); -typedef void (GLAD_API_PTR *PFNGLUNIFORM2FPROC)(GLint location, GLfloat v0, GLfloat v1); -typedef void (GLAD_API_PTR *PFNGLUNIFORM2FVPROC)(GLint location, GLsizei count, const GLfloat * value); -typedef void (GLAD_API_PTR *PFNGLUNIFORM2IPROC)(GLint location, GLint v0, GLint v1); -typedef void (GLAD_API_PTR *PFNGLUNIFORM2IVPROC)(GLint location, GLsizei count, const GLint * value); -typedef void (GLAD_API_PTR *PFNGLUNIFORM2UIPROC)(GLint location, GLuint v0, GLuint v1); -typedef void (GLAD_API_PTR *PFNGLUNIFORM2UIVPROC)(GLint location, GLsizei count, const GLuint * value); -typedef void (GLAD_API_PTR *PFNGLUNIFORM3FPROC)(GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -typedef void (GLAD_API_PTR *PFNGLUNIFORM3FVPROC)(GLint location, GLsizei count, const GLfloat * value); -typedef void (GLAD_API_PTR *PFNGLUNIFORM3IPROC)(GLint location, GLint v0, GLint v1, GLint v2); -typedef void (GLAD_API_PTR *PFNGLUNIFORM3IVPROC)(GLint location, GLsizei count, const GLint * value); -typedef void (GLAD_API_PTR *PFNGLUNIFORM3UIPROC)(GLint location, GLuint v0, GLuint v1, GLuint v2); -typedef void (GLAD_API_PTR *PFNGLUNIFORM3UIVPROC)(GLint location, GLsizei count, const GLuint * value); -typedef void (GLAD_API_PTR *PFNGLUNIFORM4FPROC)(GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -typedef void (GLAD_API_PTR *PFNGLUNIFORM4FVPROC)(GLint location, GLsizei count, const GLfloat * value); -typedef void (GLAD_API_PTR *PFNGLUNIFORM4IPROC)(GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -typedef void (GLAD_API_PTR *PFNGLUNIFORM4IVPROC)(GLint location, GLsizei count, const GLint * value); -typedef void (GLAD_API_PTR *PFNGLUNIFORM4UIPROC)(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); -typedef void (GLAD_API_PTR *PFNGLUNIFORM4UIVPROC)(GLint location, GLsizei count, const GLuint * value); -typedef void (GLAD_API_PTR *PFNGLUNIFORMBLOCKBINDINGPROC)(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); -typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX2FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value); -typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX2X3FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value); -typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX2X4FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value); -typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX3FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value); -typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX3X2FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value); -typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX3X4FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value); -typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX4FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value); -typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX4X2FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value); -typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX4X3FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value); -typedef GLboolean (GLAD_API_PTR *PFNGLUNMAPBUFFERPROC)(GLenum target); -typedef void (GLAD_API_PTR *PFNGLUSEPROGRAMPROC)(GLuint program); -typedef void (GLAD_API_PTR *PFNGLVALIDATEPROGRAMPROC)(GLuint program); -typedef void (GLAD_API_PTR *PFNGLVERTEX2DPROC)(GLdouble x, GLdouble y); -typedef void (GLAD_API_PTR *PFNGLVERTEX2DVPROC)(const GLdouble * v); -typedef void (GLAD_API_PTR *PFNGLVERTEX2FPROC)(GLfloat x, GLfloat y); -typedef void (GLAD_API_PTR *PFNGLVERTEX2FVPROC)(const GLfloat * v); -typedef void (GLAD_API_PTR *PFNGLVERTEX2IPROC)(GLint x, GLint y); -typedef void (GLAD_API_PTR *PFNGLVERTEX2IVPROC)(const GLint * v); -typedef void (GLAD_API_PTR *PFNGLVERTEX2SPROC)(GLshort x, GLshort y); -typedef void (GLAD_API_PTR *PFNGLVERTEX2SVPROC)(const GLshort * v); -typedef void (GLAD_API_PTR *PFNGLVERTEX3DPROC)(GLdouble x, GLdouble y, GLdouble z); -typedef void (GLAD_API_PTR *PFNGLVERTEX3DVPROC)(const GLdouble * v); -typedef void (GLAD_API_PTR *PFNGLVERTEX3FPROC)(GLfloat x, GLfloat y, GLfloat z); -typedef void (GLAD_API_PTR *PFNGLVERTEX3FVPROC)(const GLfloat * v); -typedef void (GLAD_API_PTR *PFNGLVERTEX3IPROC)(GLint x, GLint y, GLint z); -typedef void (GLAD_API_PTR *PFNGLVERTEX3IVPROC)(const GLint * v); -typedef void (GLAD_API_PTR *PFNGLVERTEX3SPROC)(GLshort x, GLshort y, GLshort z); -typedef void (GLAD_API_PTR *PFNGLVERTEX3SVPROC)(const GLshort * v); -typedef void (GLAD_API_PTR *PFNGLVERTEX4DPROC)(GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (GLAD_API_PTR *PFNGLVERTEX4DVPROC)(const GLdouble * v); -typedef void (GLAD_API_PTR *PFNGLVERTEX4FPROC)(GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (GLAD_API_PTR *PFNGLVERTEX4FVPROC)(const GLfloat * v); -typedef void (GLAD_API_PTR *PFNGLVERTEX4IPROC)(GLint x, GLint y, GLint z, GLint w); -typedef void (GLAD_API_PTR *PFNGLVERTEX4IVPROC)(const GLint * v); -typedef void (GLAD_API_PTR *PFNGLVERTEX4SPROC)(GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (GLAD_API_PTR *PFNGLVERTEX4SVPROC)(const GLshort * v); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB1DPROC)(GLuint index, GLdouble x); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB1DVPROC)(GLuint index, const GLdouble * v); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB1FPROC)(GLuint index, GLfloat x); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB1FVPROC)(GLuint index, const GLfloat * v); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB1SPROC)(GLuint index, GLshort x); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB1SVPROC)(GLuint index, const GLshort * v); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB2DPROC)(GLuint index, GLdouble x, GLdouble y); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB2DVPROC)(GLuint index, const GLdouble * v); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB2FPROC)(GLuint index, GLfloat x, GLfloat y); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB2FVPROC)(GLuint index, const GLfloat * v); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB2SPROC)(GLuint index, GLshort x, GLshort y); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB2SVPROC)(GLuint index, const GLshort * v); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB3DPROC)(GLuint index, GLdouble x, GLdouble y, GLdouble z); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB3DVPROC)(GLuint index, const GLdouble * v); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB3FPROC)(GLuint index, GLfloat x, GLfloat y, GLfloat z); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB3FVPROC)(GLuint index, const GLfloat * v); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB3SPROC)(GLuint index, GLshort x, GLshort y, GLshort z); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB3SVPROC)(GLuint index, const GLshort * v); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4NBVPROC)(GLuint index, const GLbyte * v); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4NIVPROC)(GLuint index, const GLint * v); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4NSVPROC)(GLuint index, const GLshort * v); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4NUBPROC)(GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4NUBVPROC)(GLuint index, const GLubyte * v); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4NUIVPROC)(GLuint index, const GLuint * v); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4NUSVPROC)(GLuint index, const GLushort * v); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4BVPROC)(GLuint index, const GLbyte * v); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4DPROC)(GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4DVPROC)(GLuint index, const GLdouble * v); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4FPROC)(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4FVPROC)(GLuint index, const GLfloat * v); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4IVPROC)(GLuint index, const GLint * v); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4SPROC)(GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4SVPROC)(GLuint index, const GLshort * v); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4UBVPROC)(GLuint index, const GLubyte * v); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4UIVPROC)(GLuint index, const GLuint * v); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4USVPROC)(GLuint index, const GLushort * v); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBDIVISORPROC)(GLuint index, GLuint divisor); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI1IPROC)(GLuint index, GLint x); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI1IVPROC)(GLuint index, const GLint * v); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI1UIPROC)(GLuint index, GLuint x); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI1UIVPROC)(GLuint index, const GLuint * v); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI2IPROC)(GLuint index, GLint x, GLint y); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI2IVPROC)(GLuint index, const GLint * v); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI2UIPROC)(GLuint index, GLuint x, GLuint y); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI2UIVPROC)(GLuint index, const GLuint * v); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI3IPROC)(GLuint index, GLint x, GLint y, GLint z); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI3IVPROC)(GLuint index, const GLint * v); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI3UIPROC)(GLuint index, GLuint x, GLuint y, GLuint z); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI3UIVPROC)(GLuint index, const GLuint * v); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI4BVPROC)(GLuint index, const GLbyte * v); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI4IPROC)(GLuint index, GLint x, GLint y, GLint z, GLint w); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI4IVPROC)(GLuint index, const GLint * v); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI4SVPROC)(GLuint index, const GLshort * v); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI4UBVPROC)(GLuint index, const GLubyte * v); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI4UIPROC)(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI4UIVPROC)(GLuint index, const GLuint * v); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI4USVPROC)(GLuint index, const GLushort * v); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBIPOINTERPROC)(GLuint index, GLint size, GLenum type, GLsizei stride, const void * pointer); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBP1UIPROC)(GLuint index, GLenum type, GLboolean normalized, GLuint value); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBP1UIVPROC)(GLuint index, GLenum type, GLboolean normalized, const GLuint * value); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBP2UIPROC)(GLuint index, GLenum type, GLboolean normalized, GLuint value); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBP2UIVPROC)(GLuint index, GLenum type, GLboolean normalized, const GLuint * value); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBP3UIPROC)(GLuint index, GLenum type, GLboolean normalized, GLuint value); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBP3UIVPROC)(GLuint index, GLenum type, GLboolean normalized, const GLuint * value); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBP4UIPROC)(GLuint index, GLenum type, GLboolean normalized, GLuint value); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBP4UIVPROC)(GLuint index, GLenum type, GLboolean normalized, const GLuint * value); -typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBPOINTERPROC)(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void * pointer); -typedef void (GLAD_API_PTR *PFNGLVERTEXP2UIPROC)(GLenum type, GLuint value); -typedef void (GLAD_API_PTR *PFNGLVERTEXP2UIVPROC)(GLenum type, const GLuint * value); -typedef void (GLAD_API_PTR *PFNGLVERTEXP3UIPROC)(GLenum type, GLuint value); -typedef void (GLAD_API_PTR *PFNGLVERTEXP3UIVPROC)(GLenum type, const GLuint * value); -typedef void (GLAD_API_PTR *PFNGLVERTEXP4UIPROC)(GLenum type, GLuint value); -typedef void (GLAD_API_PTR *PFNGLVERTEXP4UIVPROC)(GLenum type, const GLuint * value); -typedef void (GLAD_API_PTR *PFNGLVERTEXPOINTERPROC)(GLint size, GLenum type, GLsizei stride, const void * pointer); -typedef void (GLAD_API_PTR *PFNGLVIEWPORTPROC)(GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (GLAD_API_PTR *PFNGLWAITSYNCPROC)(GLsync sync, GLbitfield flags, GLuint64 timeout); -typedef void (GLAD_API_PTR *PFNGLWINDOWPOS2DPROC)(GLdouble x, GLdouble y); -typedef void (GLAD_API_PTR *PFNGLWINDOWPOS2DVPROC)(const GLdouble * v); -typedef void (GLAD_API_PTR *PFNGLWINDOWPOS2FPROC)(GLfloat x, GLfloat y); -typedef void (GLAD_API_PTR *PFNGLWINDOWPOS2FVPROC)(const GLfloat * v); -typedef void (GLAD_API_PTR *PFNGLWINDOWPOS2IPROC)(GLint x, GLint y); -typedef void (GLAD_API_PTR *PFNGLWINDOWPOS2IVPROC)(const GLint * v); -typedef void (GLAD_API_PTR *PFNGLWINDOWPOS2SPROC)(GLshort x, GLshort y); -typedef void (GLAD_API_PTR *PFNGLWINDOWPOS2SVPROC)(const GLshort * v); -typedef void (GLAD_API_PTR *PFNGLWINDOWPOS3DPROC)(GLdouble x, GLdouble y, GLdouble z); -typedef void (GLAD_API_PTR *PFNGLWINDOWPOS3DVPROC)(const GLdouble * v); -typedef void (GLAD_API_PTR *PFNGLWINDOWPOS3FPROC)(GLfloat x, GLfloat y, GLfloat z); -typedef void (GLAD_API_PTR *PFNGLWINDOWPOS3FVPROC)(const GLfloat * v); -typedef void (GLAD_API_PTR *PFNGLWINDOWPOS3IPROC)(GLint x, GLint y, GLint z); -typedef void (GLAD_API_PTR *PFNGLWINDOWPOS3IVPROC)(const GLint * v); -typedef void (GLAD_API_PTR *PFNGLWINDOWPOS3SPROC)(GLshort x, GLshort y, GLshort z); -typedef void (GLAD_API_PTR *PFNGLWINDOWPOS3SVPROC)(const GLshort * v); +typedef void (GLAD_API_PTR *PFNGLPUSHNAMEPROC)(GLuint name); +typedef void (GLAD_API_PTR *PFNGLQUERYCOUNTERPROC)(GLuint id, GLenum target); +typedef void (GLAD_API_PTR *PFNGLRASTERPOS2DPROC)(GLdouble x, GLdouble y); +typedef void (GLAD_API_PTR *PFNGLRASTERPOS2DVPROC)(const GLdouble * v); +typedef void (GLAD_API_PTR *PFNGLRASTERPOS2FPROC)(GLfloat x, GLfloat y); +typedef void (GLAD_API_PTR *PFNGLRASTERPOS2FVPROC)(const GLfloat * v); +typedef void (GLAD_API_PTR *PFNGLRASTERPOS2IPROC)(GLint x, GLint y); +typedef void (GLAD_API_PTR *PFNGLRASTERPOS2IVPROC)(const GLint * v); +typedef void (GLAD_API_PTR *PFNGLRASTERPOS2SPROC)(GLshort x, GLshort y); +typedef void (GLAD_API_PTR *PFNGLRASTERPOS2SVPROC)(const GLshort * v); +typedef void (GLAD_API_PTR *PFNGLRASTERPOS3DPROC)(GLdouble x, GLdouble y, GLdouble z); +typedef void (GLAD_API_PTR *PFNGLRASTERPOS3DVPROC)(const GLdouble * v); +typedef void (GLAD_API_PTR *PFNGLRASTERPOS3FPROC)(GLfloat x, GLfloat y, GLfloat z); +typedef void (GLAD_API_PTR *PFNGLRASTERPOS3FVPROC)(const GLfloat * v); +typedef void (GLAD_API_PTR *PFNGLRASTERPOS3IPROC)(GLint x, GLint y, GLint z); +typedef void (GLAD_API_PTR *PFNGLRASTERPOS3IVPROC)(const GLint * v); +typedef void (GLAD_API_PTR *PFNGLRASTERPOS3SPROC)(GLshort x, GLshort y, GLshort z); +typedef void (GLAD_API_PTR *PFNGLRASTERPOS3SVPROC)(const GLshort * v); +typedef void (GLAD_API_PTR *PFNGLRASTERPOS4DPROC)(GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (GLAD_API_PTR *PFNGLRASTERPOS4DVPROC)(const GLdouble * v); +typedef void (GLAD_API_PTR *PFNGLRASTERPOS4FPROC)(GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (GLAD_API_PTR *PFNGLRASTERPOS4FVPROC)(const GLfloat * v); +typedef void (GLAD_API_PTR *PFNGLRASTERPOS4IPROC)(GLint x, GLint y, GLint z, GLint w); +typedef void (GLAD_API_PTR *PFNGLRASTERPOS4IVPROC)(const GLint * v); +typedef void (GLAD_API_PTR *PFNGLRASTERPOS4SPROC)(GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (GLAD_API_PTR *PFNGLRASTERPOS4SVPROC)(const GLshort * v); +typedef void (GLAD_API_PTR *PFNGLREADBUFFERPROC)(GLenum src); +typedef void (GLAD_API_PTR *PFNGLREADPIXELSPROC)(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void * pixels); +typedef void (GLAD_API_PTR *PFNGLREADNPIXELSARBPROC)(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void * data); +typedef void (GLAD_API_PTR *PFNGLRECTDPROC)(GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2); +typedef void (GLAD_API_PTR *PFNGLRECTDVPROC)(const GLdouble * v1, const GLdouble * v2); +typedef void (GLAD_API_PTR *PFNGLRECTFPROC)(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2); +typedef void (GLAD_API_PTR *PFNGLRECTFVPROC)(const GLfloat * v1, const GLfloat * v2); +typedef void (GLAD_API_PTR *PFNGLRECTIPROC)(GLint x1, GLint y1, GLint x2, GLint y2); +typedef void (GLAD_API_PTR *PFNGLRECTIVPROC)(const GLint * v1, const GLint * v2); +typedef void (GLAD_API_PTR *PFNGLRECTSPROC)(GLshort x1, GLshort y1, GLshort x2, GLshort y2); +typedef void (GLAD_API_PTR *PFNGLRECTSVPROC)(const GLshort * v1, const GLshort * v2); +typedef GLint (GLAD_API_PTR *PFNGLRENDERMODEPROC)(GLenum mode); +typedef void (GLAD_API_PTR *PFNGLRENDERBUFFERSTORAGEPROC)(GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (GLAD_API_PTR *PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (GLAD_API_PTR *PFNGLROTATEDPROC)(GLdouble angle, GLdouble x, GLdouble y, GLdouble z); +typedef void (GLAD_API_PTR *PFNGLROTATEFPROC)(GLfloat angle, GLfloat x, GLfloat y, GLfloat z); +typedef void (GLAD_API_PTR *PFNGLSAMPLECOVERAGEPROC)(GLfloat value, GLboolean invert); +typedef void (GLAD_API_PTR *PFNGLSAMPLECOVERAGEARBPROC)(GLfloat value, GLboolean invert); +typedef void (GLAD_API_PTR *PFNGLSAMPLEMASKIPROC)(GLuint maskNumber, GLbitfield mask); +typedef void (GLAD_API_PTR *PFNGLSAMPLERPARAMETERIIVPROC)(GLuint sampler, GLenum pname, const GLint * param); +typedef void (GLAD_API_PTR *PFNGLSAMPLERPARAMETERIUIVPROC)(GLuint sampler, GLenum pname, const GLuint * param); +typedef void (GLAD_API_PTR *PFNGLSAMPLERPARAMETERFPROC)(GLuint sampler, GLenum pname, GLfloat param); +typedef void (GLAD_API_PTR *PFNGLSAMPLERPARAMETERFVPROC)(GLuint sampler, GLenum pname, const GLfloat * param); +typedef void (GLAD_API_PTR *PFNGLSAMPLERPARAMETERIPROC)(GLuint sampler, GLenum pname, GLint param); +typedef void (GLAD_API_PTR *PFNGLSAMPLERPARAMETERIVPROC)(GLuint sampler, GLenum pname, const GLint * param); +typedef void (GLAD_API_PTR *PFNGLSCALEDPROC)(GLdouble x, GLdouble y, GLdouble z); +typedef void (GLAD_API_PTR *PFNGLSCALEFPROC)(GLfloat x, GLfloat y, GLfloat z); +typedef void (GLAD_API_PTR *PFNGLSCISSORPROC)(GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLOR3BPROC)(GLbyte red, GLbyte green, GLbyte blue); +typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLOR3BVPROC)(const GLbyte * v); +typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLOR3DPROC)(GLdouble red, GLdouble green, GLdouble blue); +typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLOR3DVPROC)(const GLdouble * v); +typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLOR3FPROC)(GLfloat red, GLfloat green, GLfloat blue); +typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLOR3FVPROC)(const GLfloat * v); +typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLOR3IPROC)(GLint red, GLint green, GLint blue); +typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLOR3IVPROC)(const GLint * v); +typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLOR3SPROC)(GLshort red, GLshort green, GLshort blue); +typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLOR3SVPROC)(const GLshort * v); +typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLOR3UBPROC)(GLubyte red, GLubyte green, GLubyte blue); +typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLOR3UBVPROC)(const GLubyte * v); +typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLOR3UIPROC)(GLuint red, GLuint green, GLuint blue); +typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLOR3UIVPROC)(const GLuint * v); +typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLOR3USPROC)(GLushort red, GLushort green, GLushort blue); +typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLOR3USVPROC)(const GLushort * v); +typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLORP3UIPROC)(GLenum type, GLuint color); +typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLORP3UIVPROC)(GLenum type, const GLuint * color); +typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLORPOINTERPROC)(GLint size, GLenum type, GLsizei stride, const void * pointer); +typedef void (GLAD_API_PTR *PFNGLSELECTBUFFERPROC)(GLsizei size, GLuint * buffer); +typedef void (GLAD_API_PTR *PFNGLSHADEMODELPROC)(GLenum mode); +typedef void (GLAD_API_PTR *PFNGLSHADERSOURCEPROC)(GLuint shader, GLsizei count, const GLchar *const* string, const GLint * length); +typedef void (GLAD_API_PTR *PFNGLSTENCILFUNCPROC)(GLenum func, GLint ref, GLuint mask); +typedef void (GLAD_API_PTR *PFNGLSTENCILFUNCSEPARATEPROC)(GLenum face, GLenum func, GLint ref, GLuint mask); +typedef void (GLAD_API_PTR *PFNGLSTENCILMASKPROC)(GLuint mask); +typedef void (GLAD_API_PTR *PFNGLSTENCILMASKSEPARATEPROC)(GLenum face, GLuint mask); +typedef void (GLAD_API_PTR *PFNGLSTENCILOPPROC)(GLenum fail, GLenum zfail, GLenum zpass); +typedef void (GLAD_API_PTR *PFNGLSTENCILOPSEPARATEPROC)(GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +typedef void (GLAD_API_PTR *PFNGLTEXBUFFERPROC)(GLenum target, GLenum internalformat, GLuint buffer); +typedef void (GLAD_API_PTR *PFNGLTEXCOORD1DPROC)(GLdouble s); +typedef void (GLAD_API_PTR *PFNGLTEXCOORD1DVPROC)(const GLdouble * v); +typedef void (GLAD_API_PTR *PFNGLTEXCOORD1FPROC)(GLfloat s); +typedef void (GLAD_API_PTR *PFNGLTEXCOORD1FVPROC)(const GLfloat * v); +typedef void (GLAD_API_PTR *PFNGLTEXCOORD1IPROC)(GLint s); +typedef void (GLAD_API_PTR *PFNGLTEXCOORD1IVPROC)(const GLint * v); +typedef void (GLAD_API_PTR *PFNGLTEXCOORD1SPROC)(GLshort s); +typedef void (GLAD_API_PTR *PFNGLTEXCOORD1SVPROC)(const GLshort * v); +typedef void (GLAD_API_PTR *PFNGLTEXCOORD2DPROC)(GLdouble s, GLdouble t); +typedef void (GLAD_API_PTR *PFNGLTEXCOORD2DVPROC)(const GLdouble * v); +typedef void (GLAD_API_PTR *PFNGLTEXCOORD2FPROC)(GLfloat s, GLfloat t); +typedef void (GLAD_API_PTR *PFNGLTEXCOORD2FVPROC)(const GLfloat * v); +typedef void (GLAD_API_PTR *PFNGLTEXCOORD2IPROC)(GLint s, GLint t); +typedef void (GLAD_API_PTR *PFNGLTEXCOORD2IVPROC)(const GLint * v); +typedef void (GLAD_API_PTR *PFNGLTEXCOORD2SPROC)(GLshort s, GLshort t); +typedef void (GLAD_API_PTR *PFNGLTEXCOORD2SVPROC)(const GLshort * v); +typedef void (GLAD_API_PTR *PFNGLTEXCOORD3DPROC)(GLdouble s, GLdouble t, GLdouble r); +typedef void (GLAD_API_PTR *PFNGLTEXCOORD3DVPROC)(const GLdouble * v); +typedef void (GLAD_API_PTR *PFNGLTEXCOORD3FPROC)(GLfloat s, GLfloat t, GLfloat r); +typedef void (GLAD_API_PTR *PFNGLTEXCOORD3FVPROC)(const GLfloat * v); +typedef void (GLAD_API_PTR *PFNGLTEXCOORD3IPROC)(GLint s, GLint t, GLint r); +typedef void (GLAD_API_PTR *PFNGLTEXCOORD3IVPROC)(const GLint * v); +typedef void (GLAD_API_PTR *PFNGLTEXCOORD3SPROC)(GLshort s, GLshort t, GLshort r); +typedef void (GLAD_API_PTR *PFNGLTEXCOORD3SVPROC)(const GLshort * v); +typedef void (GLAD_API_PTR *PFNGLTEXCOORD4DPROC)(GLdouble s, GLdouble t, GLdouble r, GLdouble q); +typedef void (GLAD_API_PTR *PFNGLTEXCOORD4DVPROC)(const GLdouble * v); +typedef void (GLAD_API_PTR *PFNGLTEXCOORD4FPROC)(GLfloat s, GLfloat t, GLfloat r, GLfloat q); +typedef void (GLAD_API_PTR *PFNGLTEXCOORD4FVPROC)(const GLfloat * v); +typedef void (GLAD_API_PTR *PFNGLTEXCOORD4IPROC)(GLint s, GLint t, GLint r, GLint q); +typedef void (GLAD_API_PTR *PFNGLTEXCOORD4IVPROC)(const GLint * v); +typedef void (GLAD_API_PTR *PFNGLTEXCOORD4SPROC)(GLshort s, GLshort t, GLshort r, GLshort q); +typedef void (GLAD_API_PTR *PFNGLTEXCOORD4SVPROC)(const GLshort * v); +typedef void (GLAD_API_PTR *PFNGLTEXCOORDP1UIPROC)(GLenum type, GLuint coords); +typedef void (GLAD_API_PTR *PFNGLTEXCOORDP1UIVPROC)(GLenum type, const GLuint * coords); +typedef void (GLAD_API_PTR *PFNGLTEXCOORDP2UIPROC)(GLenum type, GLuint coords); +typedef void (GLAD_API_PTR *PFNGLTEXCOORDP2UIVPROC)(GLenum type, const GLuint * coords); +typedef void (GLAD_API_PTR *PFNGLTEXCOORDP3UIPROC)(GLenum type, GLuint coords); +typedef void (GLAD_API_PTR *PFNGLTEXCOORDP3UIVPROC)(GLenum type, const GLuint * coords); +typedef void (GLAD_API_PTR *PFNGLTEXCOORDP4UIPROC)(GLenum type, GLuint coords); +typedef void (GLAD_API_PTR *PFNGLTEXCOORDP4UIVPROC)(GLenum type, const GLuint * coords); +typedef void (GLAD_API_PTR *PFNGLTEXCOORDPOINTERPROC)(GLint size, GLenum type, GLsizei stride, const void * pointer); +typedef void (GLAD_API_PTR *PFNGLTEXENVFPROC)(GLenum target, GLenum pname, GLfloat param); +typedef void (GLAD_API_PTR *PFNGLTEXENVFVPROC)(GLenum target, GLenum pname, const GLfloat * params); +typedef void (GLAD_API_PTR *PFNGLTEXENVIPROC)(GLenum target, GLenum pname, GLint param); +typedef void (GLAD_API_PTR *PFNGLTEXENVIVPROC)(GLenum target, GLenum pname, const GLint * params); +typedef void (GLAD_API_PTR *PFNGLTEXGENDPROC)(GLenum coord, GLenum pname, GLdouble param); +typedef void (GLAD_API_PTR *PFNGLTEXGENDVPROC)(GLenum coord, GLenum pname, const GLdouble * params); +typedef void (GLAD_API_PTR *PFNGLTEXGENFPROC)(GLenum coord, GLenum pname, GLfloat param); +typedef void (GLAD_API_PTR *PFNGLTEXGENFVPROC)(GLenum coord, GLenum pname, const GLfloat * params); +typedef void (GLAD_API_PTR *PFNGLTEXGENIPROC)(GLenum coord, GLenum pname, GLint param); +typedef void (GLAD_API_PTR *PFNGLTEXGENIVPROC)(GLenum coord, GLenum pname, const GLint * params); +typedef void (GLAD_API_PTR *PFNGLTEXIMAGE1DPROC)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void * pixels); +typedef void (GLAD_API_PTR *PFNGLTEXIMAGE2DPROC)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void * pixels); +typedef void (GLAD_API_PTR *PFNGLTEXIMAGE2DMULTISAMPLEPROC)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +typedef void (GLAD_API_PTR *PFNGLTEXIMAGE3DPROC)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void * pixels); +typedef void (GLAD_API_PTR *PFNGLTEXIMAGE3DMULTISAMPLEPROC)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +typedef void (GLAD_API_PTR *PFNGLTEXPARAMETERIIVPROC)(GLenum target, GLenum pname, const GLint * params); +typedef void (GLAD_API_PTR *PFNGLTEXPARAMETERIUIVPROC)(GLenum target, GLenum pname, const GLuint * params); +typedef void (GLAD_API_PTR *PFNGLTEXPARAMETERFPROC)(GLenum target, GLenum pname, GLfloat param); +typedef void (GLAD_API_PTR *PFNGLTEXPARAMETERFVPROC)(GLenum target, GLenum pname, const GLfloat * params); +typedef void (GLAD_API_PTR *PFNGLTEXPARAMETERIPROC)(GLenum target, GLenum pname, GLint param); +typedef void (GLAD_API_PTR *PFNGLTEXPARAMETERIVPROC)(GLenum target, GLenum pname, const GLint * params); +typedef void (GLAD_API_PTR *PFNGLTEXSUBIMAGE1DPROC)(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void * pixels); +typedef void (GLAD_API_PTR *PFNGLTEXSUBIMAGE2DPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void * pixels); +typedef void (GLAD_API_PTR *PFNGLTEXSUBIMAGE3DPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void * pixels); +typedef void (GLAD_API_PTR *PFNGLTRANSFORMFEEDBACKVARYINGSPROC)(GLuint program, GLsizei count, const GLchar *const* varyings, GLenum bufferMode); +typedef void (GLAD_API_PTR *PFNGLTRANSLATEDPROC)(GLdouble x, GLdouble y, GLdouble z); +typedef void (GLAD_API_PTR *PFNGLTRANSLATEFPROC)(GLfloat x, GLfloat y, GLfloat z); +typedef void (GLAD_API_PTR *PFNGLUNIFORM1FPROC)(GLint location, GLfloat v0); +typedef void (GLAD_API_PTR *PFNGLUNIFORM1FVPROC)(GLint location, GLsizei count, const GLfloat * value); +typedef void (GLAD_API_PTR *PFNGLUNIFORM1IPROC)(GLint location, GLint v0); +typedef void (GLAD_API_PTR *PFNGLUNIFORM1IVPROC)(GLint location, GLsizei count, const GLint * value); +typedef void (GLAD_API_PTR *PFNGLUNIFORM1UIPROC)(GLint location, GLuint v0); +typedef void (GLAD_API_PTR *PFNGLUNIFORM1UIVPROC)(GLint location, GLsizei count, const GLuint * value); +typedef void (GLAD_API_PTR *PFNGLUNIFORM2FPROC)(GLint location, GLfloat v0, GLfloat v1); +typedef void (GLAD_API_PTR *PFNGLUNIFORM2FVPROC)(GLint location, GLsizei count, const GLfloat * value); +typedef void (GLAD_API_PTR *PFNGLUNIFORM2IPROC)(GLint location, GLint v0, GLint v1); +typedef void (GLAD_API_PTR *PFNGLUNIFORM2IVPROC)(GLint location, GLsizei count, const GLint * value); +typedef void (GLAD_API_PTR *PFNGLUNIFORM2UIPROC)(GLint location, GLuint v0, GLuint v1); +typedef void (GLAD_API_PTR *PFNGLUNIFORM2UIVPROC)(GLint location, GLsizei count, const GLuint * value); +typedef void (GLAD_API_PTR *PFNGLUNIFORM3FPROC)(GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (GLAD_API_PTR *PFNGLUNIFORM3FVPROC)(GLint location, GLsizei count, const GLfloat * value); +typedef void (GLAD_API_PTR *PFNGLUNIFORM3IPROC)(GLint location, GLint v0, GLint v1, GLint v2); +typedef void (GLAD_API_PTR *PFNGLUNIFORM3IVPROC)(GLint location, GLsizei count, const GLint * value); +typedef void (GLAD_API_PTR *PFNGLUNIFORM3UIPROC)(GLint location, GLuint v0, GLuint v1, GLuint v2); +typedef void (GLAD_API_PTR *PFNGLUNIFORM3UIVPROC)(GLint location, GLsizei count, const GLuint * value); +typedef void (GLAD_API_PTR *PFNGLUNIFORM4FPROC)(GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (GLAD_API_PTR *PFNGLUNIFORM4FVPROC)(GLint location, GLsizei count, const GLfloat * value); +typedef void (GLAD_API_PTR *PFNGLUNIFORM4IPROC)(GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (GLAD_API_PTR *PFNGLUNIFORM4IVPROC)(GLint location, GLsizei count, const GLint * value); +typedef void (GLAD_API_PTR *PFNGLUNIFORM4UIPROC)(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +typedef void (GLAD_API_PTR *PFNGLUNIFORM4UIVPROC)(GLint location, GLsizei count, const GLuint * value); +typedef void (GLAD_API_PTR *PFNGLUNIFORMBLOCKBINDINGPROC)(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); +typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX2FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value); +typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX2X3FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value); +typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX2X4FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value); +typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX3FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value); +typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX3X2FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value); +typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX3X4FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value); +typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX4FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value); +typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX4X2FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value); +typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX4X3FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value); +typedef GLboolean (GLAD_API_PTR *PFNGLUNMAPBUFFERPROC)(GLenum target); +typedef void (GLAD_API_PTR *PFNGLUSEPROGRAMPROC)(GLuint program); +typedef void (GLAD_API_PTR *PFNGLVALIDATEPROGRAMPROC)(GLuint program); +typedef void (GLAD_API_PTR *PFNGLVERTEX2DPROC)(GLdouble x, GLdouble y); +typedef void (GLAD_API_PTR *PFNGLVERTEX2DVPROC)(const GLdouble * v); +typedef void (GLAD_API_PTR *PFNGLVERTEX2FPROC)(GLfloat x, GLfloat y); +typedef void (GLAD_API_PTR *PFNGLVERTEX2FVPROC)(const GLfloat * v); +typedef void (GLAD_API_PTR *PFNGLVERTEX2IPROC)(GLint x, GLint y); +typedef void (GLAD_API_PTR *PFNGLVERTEX2IVPROC)(const GLint * v); +typedef void (GLAD_API_PTR *PFNGLVERTEX2SPROC)(GLshort x, GLshort y); +typedef void (GLAD_API_PTR *PFNGLVERTEX2SVPROC)(const GLshort * v); +typedef void (GLAD_API_PTR *PFNGLVERTEX3DPROC)(GLdouble x, GLdouble y, GLdouble z); +typedef void (GLAD_API_PTR *PFNGLVERTEX3DVPROC)(const GLdouble * v); +typedef void (GLAD_API_PTR *PFNGLVERTEX3FPROC)(GLfloat x, GLfloat y, GLfloat z); +typedef void (GLAD_API_PTR *PFNGLVERTEX3FVPROC)(const GLfloat * v); +typedef void (GLAD_API_PTR *PFNGLVERTEX3IPROC)(GLint x, GLint y, GLint z); +typedef void (GLAD_API_PTR *PFNGLVERTEX3IVPROC)(const GLint * v); +typedef void (GLAD_API_PTR *PFNGLVERTEX3SPROC)(GLshort x, GLshort y, GLshort z); +typedef void (GLAD_API_PTR *PFNGLVERTEX3SVPROC)(const GLshort * v); +typedef void (GLAD_API_PTR *PFNGLVERTEX4DPROC)(GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (GLAD_API_PTR *PFNGLVERTEX4DVPROC)(const GLdouble * v); +typedef void (GLAD_API_PTR *PFNGLVERTEX4FPROC)(GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (GLAD_API_PTR *PFNGLVERTEX4FVPROC)(const GLfloat * v); +typedef void (GLAD_API_PTR *PFNGLVERTEX4IPROC)(GLint x, GLint y, GLint z, GLint w); +typedef void (GLAD_API_PTR *PFNGLVERTEX4IVPROC)(const GLint * v); +typedef void (GLAD_API_PTR *PFNGLVERTEX4SPROC)(GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (GLAD_API_PTR *PFNGLVERTEX4SVPROC)(const GLshort * v); +typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB1DPROC)(GLuint index, GLdouble x); +typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB1DVPROC)(GLuint index, const GLdouble * v); +typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB1FPROC)(GLuint index, GLfloat x); +typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB1FVPROC)(GLuint index, const GLfloat * v); +typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB1SPROC)(GLuint index, GLshort x); +typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB1SVPROC)(GLuint index, const GLshort * v); +typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB2DPROC)(GLuint index, GLdouble x, GLdouble y); +typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB2DVPROC)(GLuint index, const GLdouble * v); +typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB2FPROC)(GLuint index, GLfloat x, GLfloat y); +typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB2FVPROC)(GLuint index, const GLfloat * v); +typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB2SPROC)(GLuint index, GLshort x, GLshort y); +typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB2SVPROC)(GLuint index, const GLshort * v); +typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB3DPROC)(GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB3DVPROC)(GLuint index, const GLdouble * v); +typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB3FPROC)(GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB3FVPROC)(GLuint index, const GLfloat * v); +typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB3SPROC)(GLuint index, GLshort x, GLshort y, GLshort z); +typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB3SVPROC)(GLuint index, const GLshort * v); +typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4NBVPROC)(GLuint index, const GLbyte * v); +typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4NIVPROC)(GLuint index, const GLint * v); +typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4NSVPROC)(GLuint index, const GLshort * v); +typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4NUBPROC)(GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4NUBVPROC)(GLuint index, const GLubyte * v); +typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4NUIVPROC)(GLuint index, const GLuint * v); +typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4NUSVPROC)(GLuint index, const GLushort * v); +typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4BVPROC)(GLuint index, const GLbyte * v); +typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4DPROC)(GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4DVPROC)(GLuint index, const GLdouble * v); +typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4FPROC)(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4FVPROC)(GLuint index, const GLfloat * v); +typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4IVPROC)(GLuint index, const GLint * v); +typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4SPROC)(GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4SVPROC)(GLuint index, const GLshort * v); +typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4UBVPROC)(GLuint index, const GLubyte * v); +typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4UIVPROC)(GLuint index, const GLuint * v); +typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4USVPROC)(GLuint index, const GLushort * v); +typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBDIVISORPROC)(GLuint index, GLuint divisor); +typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI1IPROC)(GLuint index, GLint x); +typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI1IVPROC)(GLuint index, const GLint * v); +typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI1UIPROC)(GLuint index, GLuint x); +typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI1UIVPROC)(GLuint index, const GLuint * v); +typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI2IPROC)(GLuint index, GLint x, GLint y); +typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI2IVPROC)(GLuint index, const GLint * v); +typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI2UIPROC)(GLuint index, GLuint x, GLuint y); +typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI2UIVPROC)(GLuint index, const GLuint * v); +typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI3IPROC)(GLuint index, GLint x, GLint y, GLint z); +typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI3IVPROC)(GLuint index, const GLint * v); +typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI3UIPROC)(GLuint index, GLuint x, GLuint y, GLuint z); +typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI3UIVPROC)(GLuint index, const GLuint * v); +typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI4BVPROC)(GLuint index, const GLbyte * v); +typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI4IPROC)(GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI4IVPROC)(GLuint index, const GLint * v); +typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI4SVPROC)(GLuint index, const GLshort * v); +typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI4UBVPROC)(GLuint index, const GLubyte * v); +typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI4UIPROC)(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI4UIVPROC)(GLuint index, const GLuint * v); +typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI4USVPROC)(GLuint index, const GLushort * v); +typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBIPOINTERPROC)(GLuint index, GLint size, GLenum type, GLsizei stride, const void * pointer); +typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBP1UIPROC)(GLuint index, GLenum type, GLboolean normalized, GLuint value); +typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBP1UIVPROC)(GLuint index, GLenum type, GLboolean normalized, const GLuint * value); +typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBP2UIPROC)(GLuint index, GLenum type, GLboolean normalized, GLuint value); +typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBP2UIVPROC)(GLuint index, GLenum type, GLboolean normalized, const GLuint * value); +typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBP3UIPROC)(GLuint index, GLenum type, GLboolean normalized, GLuint value); +typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBP3UIVPROC)(GLuint index, GLenum type, GLboolean normalized, const GLuint * value); +typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBP4UIPROC)(GLuint index, GLenum type, GLboolean normalized, GLuint value); +typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBP4UIVPROC)(GLuint index, GLenum type, GLboolean normalized, const GLuint * value); +typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBPOINTERPROC)(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void * pointer); +typedef void (GLAD_API_PTR *PFNGLVERTEXP2UIPROC)(GLenum type, GLuint value); +typedef void (GLAD_API_PTR *PFNGLVERTEXP2UIVPROC)(GLenum type, const GLuint * value); +typedef void (GLAD_API_PTR *PFNGLVERTEXP3UIPROC)(GLenum type, GLuint value); +typedef void (GLAD_API_PTR *PFNGLVERTEXP3UIVPROC)(GLenum type, const GLuint * value); +typedef void (GLAD_API_PTR *PFNGLVERTEXP4UIPROC)(GLenum type, GLuint value); +typedef void (GLAD_API_PTR *PFNGLVERTEXP4UIVPROC)(GLenum type, const GLuint * value); +typedef void (GLAD_API_PTR *PFNGLVERTEXPOINTERPROC)(GLint size, GLenum type, GLsizei stride, const void * pointer); +typedef void (GLAD_API_PTR *PFNGLVIEWPORTPROC)(GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (GLAD_API_PTR *PFNGLWAITSYNCPROC)(GLsync sync, GLbitfield flags, GLuint64 timeout); +typedef void (GLAD_API_PTR *PFNGLWINDOWPOS2DPROC)(GLdouble x, GLdouble y); +typedef void (GLAD_API_PTR *PFNGLWINDOWPOS2DVPROC)(const GLdouble * v); +typedef void (GLAD_API_PTR *PFNGLWINDOWPOS2FPROC)(GLfloat x, GLfloat y); +typedef void (GLAD_API_PTR *PFNGLWINDOWPOS2FVPROC)(const GLfloat * v); +typedef void (GLAD_API_PTR *PFNGLWINDOWPOS2IPROC)(GLint x, GLint y); +typedef void (GLAD_API_PTR *PFNGLWINDOWPOS2IVPROC)(const GLint * v); +typedef void (GLAD_API_PTR *PFNGLWINDOWPOS2SPROC)(GLshort x, GLshort y); +typedef void (GLAD_API_PTR *PFNGLWINDOWPOS2SVPROC)(const GLshort * v); +typedef void (GLAD_API_PTR *PFNGLWINDOWPOS3DPROC)(GLdouble x, GLdouble y, GLdouble z); +typedef void (GLAD_API_PTR *PFNGLWINDOWPOS3DVPROC)(const GLdouble * v); +typedef void (GLAD_API_PTR *PFNGLWINDOWPOS3FPROC)(GLfloat x, GLfloat y, GLfloat z); +typedef void (GLAD_API_PTR *PFNGLWINDOWPOS3FVPROC)(const GLfloat * v); +typedef void (GLAD_API_PTR *PFNGLWINDOWPOS3IPROC)(GLint x, GLint y, GLint z); +typedef void (GLAD_API_PTR *PFNGLWINDOWPOS3IVPROC)(const GLint * v); +typedef void (GLAD_API_PTR *PFNGLWINDOWPOS3SPROC)(GLshort x, GLshort y, GLshort z); +typedef void (GLAD_API_PTR *PFNGLWINDOWPOS3SVPROC)(const GLshort * v); GLAD_API_CALL PFNGLACCUMPROC glad_glAccum; #define glAccum glad_glAccum @@ -3270,8 +3622,6 @@ GLAD_API_CALL PFNGLREADBUFFERPROC glad_glReadBuffer; #define glReadBuffer glad_glReadBuffer GLAD_API_CALL PFNGLREADPIXELSPROC glad_glReadPixels; #define glReadPixels glad_glReadPixels -GLAD_API_CALL PFNGLREADNPIXELSPROC glad_glReadnPixels; -#define glReadnPixels glad_glReadnPixels GLAD_API_CALL PFNGLREADNPIXELSARBPROC glad_glReadnPixelsARB; #define glReadnPixelsARB glad_glReadnPixelsARB GLAD_API_CALL PFNGLRECTDPROC glad_glRectd; @@ -3826,15 +4176,1821 @@ GLAD_API_CALL PFNGLWINDOWPOS3SVPROC glad_glWindowPos3sv; #define glWindowPos3sv glad_glWindowPos3sv + + + GLAD_API_CALL int gladLoadGLUserPtr( GLADuserptrloadfunc load, void *userptr); GLAD_API_CALL int gladLoadGL( GLADloadfunc load); - - - #ifdef __cplusplus } #endif #endif + +/* Source */ +#ifdef GLAD_GL_IMPLEMENTATION +#include +#include +#include + +#ifndef GLAD_IMPL_UTIL_C_ +#define GLAD_IMPL_UTIL_C_ + +#ifdef _MSC_VER +#define GLAD_IMPL_UTIL_SSCANF sscanf_s +#else +#define GLAD_IMPL_UTIL_SSCANF sscanf +#endif + +#endif /* GLAD_IMPL_UTIL_C_ */ + +#ifdef __cplusplus +extern "C" { +#endif + + + +int GLAD_GL_VERSION_1_0 = 0; +int GLAD_GL_VERSION_1_1 = 0; +int GLAD_GL_VERSION_1_2 = 0; +int GLAD_GL_VERSION_1_3 = 0; +int GLAD_GL_VERSION_1_4 = 0; +int GLAD_GL_VERSION_1_5 = 0; +int GLAD_GL_VERSION_2_0 = 0; +int GLAD_GL_VERSION_2_1 = 0; +int GLAD_GL_VERSION_3_0 = 0; +int GLAD_GL_VERSION_3_1 = 0; +int GLAD_GL_VERSION_3_2 = 0; +int GLAD_GL_VERSION_3_3 = 0; +int GLAD_GL_ARB_multisample = 0; +int GLAD_GL_ARB_robustness = 0; +int GLAD_GL_KHR_debug = 0; + + + +PFNGLACCUMPROC glad_glAccum = NULL; +PFNGLACTIVETEXTUREPROC glad_glActiveTexture = NULL; +PFNGLALPHAFUNCPROC glad_glAlphaFunc = NULL; +PFNGLARETEXTURESRESIDENTPROC glad_glAreTexturesResident = NULL; +PFNGLARRAYELEMENTPROC glad_glArrayElement = NULL; +PFNGLATTACHSHADERPROC glad_glAttachShader = NULL; +PFNGLBEGINPROC glad_glBegin = NULL; +PFNGLBEGINCONDITIONALRENDERPROC glad_glBeginConditionalRender = NULL; +PFNGLBEGINQUERYPROC glad_glBeginQuery = NULL; +PFNGLBEGINTRANSFORMFEEDBACKPROC glad_glBeginTransformFeedback = NULL; +PFNGLBINDATTRIBLOCATIONPROC glad_glBindAttribLocation = NULL; +PFNGLBINDBUFFERPROC glad_glBindBuffer = NULL; +PFNGLBINDBUFFERBASEPROC glad_glBindBufferBase = NULL; +PFNGLBINDBUFFERRANGEPROC glad_glBindBufferRange = NULL; +PFNGLBINDFRAGDATALOCATIONPROC glad_glBindFragDataLocation = NULL; +PFNGLBINDFRAGDATALOCATIONINDEXEDPROC glad_glBindFragDataLocationIndexed = NULL; +PFNGLBINDFRAMEBUFFERPROC glad_glBindFramebuffer = NULL; +PFNGLBINDRENDERBUFFERPROC glad_glBindRenderbuffer = NULL; +PFNGLBINDSAMPLERPROC glad_glBindSampler = NULL; +PFNGLBINDTEXTUREPROC glad_glBindTexture = NULL; +PFNGLBINDVERTEXARRAYPROC glad_glBindVertexArray = NULL; +PFNGLBITMAPPROC glad_glBitmap = NULL; +PFNGLBLENDCOLORPROC glad_glBlendColor = NULL; +PFNGLBLENDEQUATIONPROC glad_glBlendEquation = NULL; +PFNGLBLENDEQUATIONSEPARATEPROC glad_glBlendEquationSeparate = NULL; +PFNGLBLENDFUNCPROC glad_glBlendFunc = NULL; +PFNGLBLENDFUNCSEPARATEPROC glad_glBlendFuncSeparate = NULL; +PFNGLBLITFRAMEBUFFERPROC glad_glBlitFramebuffer = NULL; +PFNGLBUFFERDATAPROC glad_glBufferData = NULL; +PFNGLBUFFERSUBDATAPROC glad_glBufferSubData = NULL; +PFNGLCALLLISTPROC glad_glCallList = NULL; +PFNGLCALLLISTSPROC glad_glCallLists = NULL; +PFNGLCHECKFRAMEBUFFERSTATUSPROC glad_glCheckFramebufferStatus = NULL; +PFNGLCLAMPCOLORPROC glad_glClampColor = NULL; +PFNGLCLEARPROC glad_glClear = NULL; +PFNGLCLEARACCUMPROC glad_glClearAccum = NULL; +PFNGLCLEARBUFFERFIPROC glad_glClearBufferfi = NULL; +PFNGLCLEARBUFFERFVPROC glad_glClearBufferfv = NULL; +PFNGLCLEARBUFFERIVPROC glad_glClearBufferiv = NULL; +PFNGLCLEARBUFFERUIVPROC glad_glClearBufferuiv = NULL; +PFNGLCLEARCOLORPROC glad_glClearColor = NULL; +PFNGLCLEARDEPTHPROC glad_glClearDepth = NULL; +PFNGLCLEARINDEXPROC glad_glClearIndex = NULL; +PFNGLCLEARSTENCILPROC glad_glClearStencil = NULL; +PFNGLCLIENTACTIVETEXTUREPROC glad_glClientActiveTexture = NULL; +PFNGLCLIENTWAITSYNCPROC glad_glClientWaitSync = NULL; +PFNGLCLIPPLANEPROC glad_glClipPlane = NULL; +PFNGLCOLOR3BPROC glad_glColor3b = NULL; +PFNGLCOLOR3BVPROC glad_glColor3bv = NULL; +PFNGLCOLOR3DPROC glad_glColor3d = NULL; +PFNGLCOLOR3DVPROC glad_glColor3dv = NULL; +PFNGLCOLOR3FPROC glad_glColor3f = NULL; +PFNGLCOLOR3FVPROC glad_glColor3fv = NULL; +PFNGLCOLOR3IPROC glad_glColor3i = NULL; +PFNGLCOLOR3IVPROC glad_glColor3iv = NULL; +PFNGLCOLOR3SPROC glad_glColor3s = NULL; +PFNGLCOLOR3SVPROC glad_glColor3sv = NULL; +PFNGLCOLOR3UBPROC glad_glColor3ub = NULL; +PFNGLCOLOR3UBVPROC glad_glColor3ubv = NULL; +PFNGLCOLOR3UIPROC glad_glColor3ui = NULL; +PFNGLCOLOR3UIVPROC glad_glColor3uiv = NULL; +PFNGLCOLOR3USPROC glad_glColor3us = NULL; +PFNGLCOLOR3USVPROC glad_glColor3usv = NULL; +PFNGLCOLOR4BPROC glad_glColor4b = NULL; +PFNGLCOLOR4BVPROC glad_glColor4bv = NULL; +PFNGLCOLOR4DPROC glad_glColor4d = NULL; +PFNGLCOLOR4DVPROC glad_glColor4dv = NULL; +PFNGLCOLOR4FPROC glad_glColor4f = NULL; +PFNGLCOLOR4FVPROC glad_glColor4fv = NULL; +PFNGLCOLOR4IPROC glad_glColor4i = NULL; +PFNGLCOLOR4IVPROC glad_glColor4iv = NULL; +PFNGLCOLOR4SPROC glad_glColor4s = NULL; +PFNGLCOLOR4SVPROC glad_glColor4sv = NULL; +PFNGLCOLOR4UBPROC glad_glColor4ub = NULL; +PFNGLCOLOR4UBVPROC glad_glColor4ubv = NULL; +PFNGLCOLOR4UIPROC glad_glColor4ui = NULL; +PFNGLCOLOR4UIVPROC glad_glColor4uiv = NULL; +PFNGLCOLOR4USPROC glad_glColor4us = NULL; +PFNGLCOLOR4USVPROC glad_glColor4usv = NULL; +PFNGLCOLORMASKPROC glad_glColorMask = NULL; +PFNGLCOLORMASKIPROC glad_glColorMaski = NULL; +PFNGLCOLORMATERIALPROC glad_glColorMaterial = NULL; +PFNGLCOLORP3UIPROC glad_glColorP3ui = NULL; +PFNGLCOLORP3UIVPROC glad_glColorP3uiv = NULL; +PFNGLCOLORP4UIPROC glad_glColorP4ui = NULL; +PFNGLCOLORP4UIVPROC glad_glColorP4uiv = NULL; +PFNGLCOLORPOINTERPROC glad_glColorPointer = NULL; +PFNGLCOMPILESHADERPROC glad_glCompileShader = NULL; +PFNGLCOMPRESSEDTEXIMAGE1DPROC glad_glCompressedTexImage1D = NULL; +PFNGLCOMPRESSEDTEXIMAGE2DPROC glad_glCompressedTexImage2D = NULL; +PFNGLCOMPRESSEDTEXIMAGE3DPROC glad_glCompressedTexImage3D = NULL; +PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC glad_glCompressedTexSubImage1D = NULL; +PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC glad_glCompressedTexSubImage2D = NULL; +PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC glad_glCompressedTexSubImage3D = NULL; +PFNGLCOPYBUFFERSUBDATAPROC glad_glCopyBufferSubData = NULL; +PFNGLCOPYPIXELSPROC glad_glCopyPixels = NULL; +PFNGLCOPYTEXIMAGE1DPROC glad_glCopyTexImage1D = NULL; +PFNGLCOPYTEXIMAGE2DPROC glad_glCopyTexImage2D = NULL; +PFNGLCOPYTEXSUBIMAGE1DPROC glad_glCopyTexSubImage1D = NULL; +PFNGLCOPYTEXSUBIMAGE2DPROC glad_glCopyTexSubImage2D = NULL; +PFNGLCOPYTEXSUBIMAGE3DPROC glad_glCopyTexSubImage3D = NULL; +PFNGLCREATEPROGRAMPROC glad_glCreateProgram = NULL; +PFNGLCREATESHADERPROC glad_glCreateShader = NULL; +PFNGLCULLFACEPROC glad_glCullFace = NULL; +PFNGLDEBUGMESSAGECALLBACKPROC glad_glDebugMessageCallback = NULL; +PFNGLDEBUGMESSAGECONTROLPROC glad_glDebugMessageControl = NULL; +PFNGLDEBUGMESSAGEINSERTPROC glad_glDebugMessageInsert = NULL; +PFNGLDELETEBUFFERSPROC glad_glDeleteBuffers = NULL; +PFNGLDELETEFRAMEBUFFERSPROC glad_glDeleteFramebuffers = NULL; +PFNGLDELETELISTSPROC glad_glDeleteLists = NULL; +PFNGLDELETEPROGRAMPROC glad_glDeleteProgram = NULL; +PFNGLDELETEQUERIESPROC glad_glDeleteQueries = NULL; +PFNGLDELETERENDERBUFFERSPROC glad_glDeleteRenderbuffers = NULL; +PFNGLDELETESAMPLERSPROC glad_glDeleteSamplers = NULL; +PFNGLDELETESHADERPROC glad_glDeleteShader = NULL; +PFNGLDELETESYNCPROC glad_glDeleteSync = NULL; +PFNGLDELETETEXTURESPROC glad_glDeleteTextures = NULL; +PFNGLDELETEVERTEXARRAYSPROC glad_glDeleteVertexArrays = NULL; +PFNGLDEPTHFUNCPROC glad_glDepthFunc = NULL; +PFNGLDEPTHMASKPROC glad_glDepthMask = NULL; +PFNGLDEPTHRANGEPROC glad_glDepthRange = NULL; +PFNGLDETACHSHADERPROC glad_glDetachShader = NULL; +PFNGLDISABLEPROC glad_glDisable = NULL; +PFNGLDISABLECLIENTSTATEPROC glad_glDisableClientState = NULL; +PFNGLDISABLEVERTEXATTRIBARRAYPROC glad_glDisableVertexAttribArray = NULL; +PFNGLDISABLEIPROC glad_glDisablei = NULL; +PFNGLDRAWARRAYSPROC glad_glDrawArrays = NULL; +PFNGLDRAWARRAYSINSTANCEDPROC glad_glDrawArraysInstanced = NULL; +PFNGLDRAWBUFFERPROC glad_glDrawBuffer = NULL; +PFNGLDRAWBUFFERSPROC glad_glDrawBuffers = NULL; +PFNGLDRAWELEMENTSPROC glad_glDrawElements = NULL; +PFNGLDRAWELEMENTSBASEVERTEXPROC glad_glDrawElementsBaseVertex = NULL; +PFNGLDRAWELEMENTSINSTANCEDPROC glad_glDrawElementsInstanced = NULL; +PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC glad_glDrawElementsInstancedBaseVertex = NULL; +PFNGLDRAWPIXELSPROC glad_glDrawPixels = NULL; +PFNGLDRAWRANGEELEMENTSPROC glad_glDrawRangeElements = NULL; +PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC glad_glDrawRangeElementsBaseVertex = NULL; +PFNGLEDGEFLAGPROC glad_glEdgeFlag = NULL; +PFNGLEDGEFLAGPOINTERPROC glad_glEdgeFlagPointer = NULL; +PFNGLEDGEFLAGVPROC glad_glEdgeFlagv = NULL; +PFNGLENABLEPROC glad_glEnable = NULL; +PFNGLENABLECLIENTSTATEPROC glad_glEnableClientState = NULL; +PFNGLENABLEVERTEXATTRIBARRAYPROC glad_glEnableVertexAttribArray = NULL; +PFNGLENABLEIPROC glad_glEnablei = NULL; +PFNGLENDPROC glad_glEnd = NULL; +PFNGLENDCONDITIONALRENDERPROC glad_glEndConditionalRender = NULL; +PFNGLENDLISTPROC glad_glEndList = NULL; +PFNGLENDQUERYPROC glad_glEndQuery = NULL; +PFNGLENDTRANSFORMFEEDBACKPROC glad_glEndTransformFeedback = NULL; +PFNGLEVALCOORD1DPROC glad_glEvalCoord1d = NULL; +PFNGLEVALCOORD1DVPROC glad_glEvalCoord1dv = NULL; +PFNGLEVALCOORD1FPROC glad_glEvalCoord1f = NULL; +PFNGLEVALCOORD1FVPROC glad_glEvalCoord1fv = NULL; +PFNGLEVALCOORD2DPROC glad_glEvalCoord2d = NULL; +PFNGLEVALCOORD2DVPROC glad_glEvalCoord2dv = NULL; +PFNGLEVALCOORD2FPROC glad_glEvalCoord2f = NULL; +PFNGLEVALCOORD2FVPROC glad_glEvalCoord2fv = NULL; +PFNGLEVALMESH1PROC glad_glEvalMesh1 = NULL; +PFNGLEVALMESH2PROC glad_glEvalMesh2 = NULL; +PFNGLEVALPOINT1PROC glad_glEvalPoint1 = NULL; +PFNGLEVALPOINT2PROC glad_glEvalPoint2 = NULL; +PFNGLFEEDBACKBUFFERPROC glad_glFeedbackBuffer = NULL; +PFNGLFENCESYNCPROC glad_glFenceSync = NULL; +PFNGLFINISHPROC glad_glFinish = NULL; +PFNGLFLUSHPROC glad_glFlush = NULL; +PFNGLFLUSHMAPPEDBUFFERRANGEPROC glad_glFlushMappedBufferRange = NULL; +PFNGLFOGCOORDPOINTERPROC glad_glFogCoordPointer = NULL; +PFNGLFOGCOORDDPROC glad_glFogCoordd = NULL; +PFNGLFOGCOORDDVPROC glad_glFogCoorddv = NULL; +PFNGLFOGCOORDFPROC glad_glFogCoordf = NULL; +PFNGLFOGCOORDFVPROC glad_glFogCoordfv = NULL; +PFNGLFOGFPROC glad_glFogf = NULL; +PFNGLFOGFVPROC glad_glFogfv = NULL; +PFNGLFOGIPROC glad_glFogi = NULL; +PFNGLFOGIVPROC glad_glFogiv = NULL; +PFNGLFRAMEBUFFERRENDERBUFFERPROC glad_glFramebufferRenderbuffer = NULL; +PFNGLFRAMEBUFFERTEXTUREPROC glad_glFramebufferTexture = NULL; +PFNGLFRAMEBUFFERTEXTURE1DPROC glad_glFramebufferTexture1D = NULL; +PFNGLFRAMEBUFFERTEXTURE2DPROC glad_glFramebufferTexture2D = NULL; +PFNGLFRAMEBUFFERTEXTURE3DPROC glad_glFramebufferTexture3D = NULL; +PFNGLFRAMEBUFFERTEXTURELAYERPROC glad_glFramebufferTextureLayer = NULL; +PFNGLFRONTFACEPROC glad_glFrontFace = NULL; +PFNGLFRUSTUMPROC glad_glFrustum = NULL; +PFNGLGENBUFFERSPROC glad_glGenBuffers = NULL; +PFNGLGENFRAMEBUFFERSPROC glad_glGenFramebuffers = NULL; +PFNGLGENLISTSPROC glad_glGenLists = NULL; +PFNGLGENQUERIESPROC glad_glGenQueries = NULL; +PFNGLGENRENDERBUFFERSPROC glad_glGenRenderbuffers = NULL; +PFNGLGENSAMPLERSPROC glad_glGenSamplers = NULL; +PFNGLGENTEXTURESPROC glad_glGenTextures = NULL; +PFNGLGENVERTEXARRAYSPROC glad_glGenVertexArrays = NULL; +PFNGLGENERATEMIPMAPPROC glad_glGenerateMipmap = NULL; +PFNGLGETACTIVEATTRIBPROC glad_glGetActiveAttrib = NULL; +PFNGLGETACTIVEUNIFORMPROC glad_glGetActiveUniform = NULL; +PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC glad_glGetActiveUniformBlockName = NULL; +PFNGLGETACTIVEUNIFORMBLOCKIVPROC glad_glGetActiveUniformBlockiv = NULL; +PFNGLGETACTIVEUNIFORMNAMEPROC glad_glGetActiveUniformName = NULL; +PFNGLGETACTIVEUNIFORMSIVPROC glad_glGetActiveUniformsiv = NULL; +PFNGLGETATTACHEDSHADERSPROC glad_glGetAttachedShaders = NULL; +PFNGLGETATTRIBLOCATIONPROC glad_glGetAttribLocation = NULL; +PFNGLGETBOOLEANI_VPROC glad_glGetBooleani_v = NULL; +PFNGLGETBOOLEANVPROC glad_glGetBooleanv = NULL; +PFNGLGETBUFFERPARAMETERI64VPROC glad_glGetBufferParameteri64v = NULL; +PFNGLGETBUFFERPARAMETERIVPROC glad_glGetBufferParameteriv = NULL; +PFNGLGETBUFFERPOINTERVPROC glad_glGetBufferPointerv = NULL; +PFNGLGETBUFFERSUBDATAPROC glad_glGetBufferSubData = NULL; +PFNGLGETCLIPPLANEPROC glad_glGetClipPlane = NULL; +PFNGLGETCOMPRESSEDTEXIMAGEPROC glad_glGetCompressedTexImage = NULL; +PFNGLGETDEBUGMESSAGELOGPROC glad_glGetDebugMessageLog = NULL; +PFNGLGETDOUBLEVPROC glad_glGetDoublev = NULL; +PFNGLGETERRORPROC glad_glGetError = NULL; +PFNGLGETFLOATVPROC glad_glGetFloatv = NULL; +PFNGLGETFRAGDATAINDEXPROC glad_glGetFragDataIndex = NULL; +PFNGLGETFRAGDATALOCATIONPROC glad_glGetFragDataLocation = NULL; +PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC glad_glGetFramebufferAttachmentParameteriv = NULL; +PFNGLGETGRAPHICSRESETSTATUSARBPROC glad_glGetGraphicsResetStatusARB = NULL; +PFNGLGETINTEGER64I_VPROC glad_glGetInteger64i_v = NULL; +PFNGLGETINTEGER64VPROC glad_glGetInteger64v = NULL; +PFNGLGETINTEGERI_VPROC glad_glGetIntegeri_v = NULL; +PFNGLGETINTEGERVPROC glad_glGetIntegerv = NULL; +PFNGLGETLIGHTFVPROC glad_glGetLightfv = NULL; +PFNGLGETLIGHTIVPROC glad_glGetLightiv = NULL; +PFNGLGETMAPDVPROC glad_glGetMapdv = NULL; +PFNGLGETMAPFVPROC glad_glGetMapfv = NULL; +PFNGLGETMAPIVPROC glad_glGetMapiv = NULL; +PFNGLGETMATERIALFVPROC glad_glGetMaterialfv = NULL; +PFNGLGETMATERIALIVPROC glad_glGetMaterialiv = NULL; +PFNGLGETMULTISAMPLEFVPROC glad_glGetMultisamplefv = NULL; +PFNGLGETOBJECTLABELPROC glad_glGetObjectLabel = NULL; +PFNGLGETOBJECTPTRLABELPROC glad_glGetObjectPtrLabel = NULL; +PFNGLGETPIXELMAPFVPROC glad_glGetPixelMapfv = NULL; +PFNGLGETPIXELMAPUIVPROC glad_glGetPixelMapuiv = NULL; +PFNGLGETPIXELMAPUSVPROC glad_glGetPixelMapusv = NULL; +PFNGLGETPOINTERVPROC glad_glGetPointerv = NULL; +PFNGLGETPOLYGONSTIPPLEPROC glad_glGetPolygonStipple = NULL; +PFNGLGETPROGRAMINFOLOGPROC glad_glGetProgramInfoLog = NULL; +PFNGLGETPROGRAMIVPROC glad_glGetProgramiv = NULL; +PFNGLGETQUERYOBJECTI64VPROC glad_glGetQueryObjecti64v = NULL; +PFNGLGETQUERYOBJECTIVPROC glad_glGetQueryObjectiv = NULL; +PFNGLGETQUERYOBJECTUI64VPROC glad_glGetQueryObjectui64v = NULL; +PFNGLGETQUERYOBJECTUIVPROC glad_glGetQueryObjectuiv = NULL; +PFNGLGETQUERYIVPROC glad_glGetQueryiv = NULL; +PFNGLGETRENDERBUFFERPARAMETERIVPROC glad_glGetRenderbufferParameteriv = NULL; +PFNGLGETSAMPLERPARAMETERIIVPROC glad_glGetSamplerParameterIiv = NULL; +PFNGLGETSAMPLERPARAMETERIUIVPROC glad_glGetSamplerParameterIuiv = NULL; +PFNGLGETSAMPLERPARAMETERFVPROC glad_glGetSamplerParameterfv = NULL; +PFNGLGETSAMPLERPARAMETERIVPROC glad_glGetSamplerParameteriv = NULL; +PFNGLGETSHADERINFOLOGPROC glad_glGetShaderInfoLog = NULL; +PFNGLGETSHADERSOURCEPROC glad_glGetShaderSource = NULL; +PFNGLGETSHADERIVPROC glad_glGetShaderiv = NULL; +PFNGLGETSTRINGPROC glad_glGetString = NULL; +PFNGLGETSTRINGIPROC glad_glGetStringi = NULL; +PFNGLGETSYNCIVPROC glad_glGetSynciv = NULL; +PFNGLGETTEXENVFVPROC glad_glGetTexEnvfv = NULL; +PFNGLGETTEXENVIVPROC glad_glGetTexEnviv = NULL; +PFNGLGETTEXGENDVPROC glad_glGetTexGendv = NULL; +PFNGLGETTEXGENFVPROC glad_glGetTexGenfv = NULL; +PFNGLGETTEXGENIVPROC glad_glGetTexGeniv = NULL; +PFNGLGETTEXIMAGEPROC glad_glGetTexImage = NULL; +PFNGLGETTEXLEVELPARAMETERFVPROC glad_glGetTexLevelParameterfv = NULL; +PFNGLGETTEXLEVELPARAMETERIVPROC glad_glGetTexLevelParameteriv = NULL; +PFNGLGETTEXPARAMETERIIVPROC glad_glGetTexParameterIiv = NULL; +PFNGLGETTEXPARAMETERIUIVPROC glad_glGetTexParameterIuiv = NULL; +PFNGLGETTEXPARAMETERFVPROC glad_glGetTexParameterfv = NULL; +PFNGLGETTEXPARAMETERIVPROC glad_glGetTexParameteriv = NULL; +PFNGLGETTRANSFORMFEEDBACKVARYINGPROC glad_glGetTransformFeedbackVarying = NULL; +PFNGLGETUNIFORMBLOCKINDEXPROC glad_glGetUniformBlockIndex = NULL; +PFNGLGETUNIFORMINDICESPROC glad_glGetUniformIndices = NULL; +PFNGLGETUNIFORMLOCATIONPROC glad_glGetUniformLocation = NULL; +PFNGLGETUNIFORMFVPROC glad_glGetUniformfv = NULL; +PFNGLGETUNIFORMIVPROC glad_glGetUniformiv = NULL; +PFNGLGETUNIFORMUIVPROC glad_glGetUniformuiv = NULL; +PFNGLGETVERTEXATTRIBIIVPROC glad_glGetVertexAttribIiv = NULL; +PFNGLGETVERTEXATTRIBIUIVPROC glad_glGetVertexAttribIuiv = NULL; +PFNGLGETVERTEXATTRIBPOINTERVPROC glad_glGetVertexAttribPointerv = NULL; +PFNGLGETVERTEXATTRIBDVPROC glad_glGetVertexAttribdv = NULL; +PFNGLGETVERTEXATTRIBFVPROC glad_glGetVertexAttribfv = NULL; +PFNGLGETVERTEXATTRIBIVPROC glad_glGetVertexAttribiv = NULL; +PFNGLGETNCOLORTABLEARBPROC glad_glGetnColorTableARB = NULL; +PFNGLGETNCOMPRESSEDTEXIMAGEARBPROC glad_glGetnCompressedTexImageARB = NULL; +PFNGLGETNCONVOLUTIONFILTERARBPROC glad_glGetnConvolutionFilterARB = NULL; +PFNGLGETNHISTOGRAMARBPROC glad_glGetnHistogramARB = NULL; +PFNGLGETNMAPDVARBPROC glad_glGetnMapdvARB = NULL; +PFNGLGETNMAPFVARBPROC glad_glGetnMapfvARB = NULL; +PFNGLGETNMAPIVARBPROC glad_glGetnMapivARB = NULL; +PFNGLGETNMINMAXARBPROC glad_glGetnMinmaxARB = NULL; +PFNGLGETNPIXELMAPFVARBPROC glad_glGetnPixelMapfvARB = NULL; +PFNGLGETNPIXELMAPUIVARBPROC glad_glGetnPixelMapuivARB = NULL; +PFNGLGETNPIXELMAPUSVARBPROC glad_glGetnPixelMapusvARB = NULL; +PFNGLGETNPOLYGONSTIPPLEARBPROC glad_glGetnPolygonStippleARB = NULL; +PFNGLGETNSEPARABLEFILTERARBPROC glad_glGetnSeparableFilterARB = NULL; +PFNGLGETNTEXIMAGEARBPROC glad_glGetnTexImageARB = NULL; +PFNGLGETNUNIFORMDVARBPROC glad_glGetnUniformdvARB = NULL; +PFNGLGETNUNIFORMFVARBPROC glad_glGetnUniformfvARB = NULL; +PFNGLGETNUNIFORMIVARBPROC glad_glGetnUniformivARB = NULL; +PFNGLGETNUNIFORMUIVARBPROC glad_glGetnUniformuivARB = NULL; +PFNGLHINTPROC glad_glHint = NULL; +PFNGLINDEXMASKPROC glad_glIndexMask = NULL; +PFNGLINDEXPOINTERPROC glad_glIndexPointer = NULL; +PFNGLINDEXDPROC glad_glIndexd = NULL; +PFNGLINDEXDVPROC glad_glIndexdv = NULL; +PFNGLINDEXFPROC glad_glIndexf = NULL; +PFNGLINDEXFVPROC glad_glIndexfv = NULL; +PFNGLINDEXIPROC glad_glIndexi = NULL; +PFNGLINDEXIVPROC glad_glIndexiv = NULL; +PFNGLINDEXSPROC glad_glIndexs = NULL; +PFNGLINDEXSVPROC glad_glIndexsv = NULL; +PFNGLINDEXUBPROC glad_glIndexub = NULL; +PFNGLINDEXUBVPROC glad_glIndexubv = NULL; +PFNGLINITNAMESPROC glad_glInitNames = NULL; +PFNGLINTERLEAVEDARRAYSPROC glad_glInterleavedArrays = NULL; +PFNGLISBUFFERPROC glad_glIsBuffer = NULL; +PFNGLISENABLEDPROC glad_glIsEnabled = NULL; +PFNGLISENABLEDIPROC glad_glIsEnabledi = NULL; +PFNGLISFRAMEBUFFERPROC glad_glIsFramebuffer = NULL; +PFNGLISLISTPROC glad_glIsList = NULL; +PFNGLISPROGRAMPROC glad_glIsProgram = NULL; +PFNGLISQUERYPROC glad_glIsQuery = NULL; +PFNGLISRENDERBUFFERPROC glad_glIsRenderbuffer = NULL; +PFNGLISSAMPLERPROC glad_glIsSampler = NULL; +PFNGLISSHADERPROC glad_glIsShader = NULL; +PFNGLISSYNCPROC glad_glIsSync = NULL; +PFNGLISTEXTUREPROC glad_glIsTexture = NULL; +PFNGLISVERTEXARRAYPROC glad_glIsVertexArray = NULL; +PFNGLLIGHTMODELFPROC glad_glLightModelf = NULL; +PFNGLLIGHTMODELFVPROC glad_glLightModelfv = NULL; +PFNGLLIGHTMODELIPROC glad_glLightModeli = NULL; +PFNGLLIGHTMODELIVPROC glad_glLightModeliv = NULL; +PFNGLLIGHTFPROC glad_glLightf = NULL; +PFNGLLIGHTFVPROC glad_glLightfv = NULL; +PFNGLLIGHTIPROC glad_glLighti = NULL; +PFNGLLIGHTIVPROC glad_glLightiv = NULL; +PFNGLLINESTIPPLEPROC glad_glLineStipple = NULL; +PFNGLLINEWIDTHPROC glad_glLineWidth = NULL; +PFNGLLINKPROGRAMPROC glad_glLinkProgram = NULL; +PFNGLLISTBASEPROC glad_glListBase = NULL; +PFNGLLOADIDENTITYPROC glad_glLoadIdentity = NULL; +PFNGLLOADMATRIXDPROC glad_glLoadMatrixd = NULL; +PFNGLLOADMATRIXFPROC glad_glLoadMatrixf = NULL; +PFNGLLOADNAMEPROC glad_glLoadName = NULL; +PFNGLLOADTRANSPOSEMATRIXDPROC glad_glLoadTransposeMatrixd = NULL; +PFNGLLOADTRANSPOSEMATRIXFPROC glad_glLoadTransposeMatrixf = NULL; +PFNGLLOGICOPPROC glad_glLogicOp = NULL; +PFNGLMAP1DPROC glad_glMap1d = NULL; +PFNGLMAP1FPROC glad_glMap1f = NULL; +PFNGLMAP2DPROC glad_glMap2d = NULL; +PFNGLMAP2FPROC glad_glMap2f = NULL; +PFNGLMAPBUFFERPROC glad_glMapBuffer = NULL; +PFNGLMAPBUFFERRANGEPROC glad_glMapBufferRange = NULL; +PFNGLMAPGRID1DPROC glad_glMapGrid1d = NULL; +PFNGLMAPGRID1FPROC glad_glMapGrid1f = NULL; +PFNGLMAPGRID2DPROC glad_glMapGrid2d = NULL; +PFNGLMAPGRID2FPROC glad_glMapGrid2f = NULL; +PFNGLMATERIALFPROC glad_glMaterialf = NULL; +PFNGLMATERIALFVPROC glad_glMaterialfv = NULL; +PFNGLMATERIALIPROC glad_glMateriali = NULL; +PFNGLMATERIALIVPROC glad_glMaterialiv = NULL; +PFNGLMATRIXMODEPROC glad_glMatrixMode = NULL; +PFNGLMULTMATRIXDPROC glad_glMultMatrixd = NULL; +PFNGLMULTMATRIXFPROC glad_glMultMatrixf = NULL; +PFNGLMULTTRANSPOSEMATRIXDPROC glad_glMultTransposeMatrixd = NULL; +PFNGLMULTTRANSPOSEMATRIXFPROC glad_glMultTransposeMatrixf = NULL; +PFNGLMULTIDRAWARRAYSPROC glad_glMultiDrawArrays = NULL; +PFNGLMULTIDRAWELEMENTSPROC glad_glMultiDrawElements = NULL; +PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC glad_glMultiDrawElementsBaseVertex = NULL; +PFNGLMULTITEXCOORD1DPROC glad_glMultiTexCoord1d = NULL; +PFNGLMULTITEXCOORD1DVPROC glad_glMultiTexCoord1dv = NULL; +PFNGLMULTITEXCOORD1FPROC glad_glMultiTexCoord1f = NULL; +PFNGLMULTITEXCOORD1FVPROC glad_glMultiTexCoord1fv = NULL; +PFNGLMULTITEXCOORD1IPROC glad_glMultiTexCoord1i = NULL; +PFNGLMULTITEXCOORD1IVPROC glad_glMultiTexCoord1iv = NULL; +PFNGLMULTITEXCOORD1SPROC glad_glMultiTexCoord1s = NULL; +PFNGLMULTITEXCOORD1SVPROC glad_glMultiTexCoord1sv = NULL; +PFNGLMULTITEXCOORD2DPROC glad_glMultiTexCoord2d = NULL; +PFNGLMULTITEXCOORD2DVPROC glad_glMultiTexCoord2dv = NULL; +PFNGLMULTITEXCOORD2FPROC glad_glMultiTexCoord2f = NULL; +PFNGLMULTITEXCOORD2FVPROC glad_glMultiTexCoord2fv = NULL; +PFNGLMULTITEXCOORD2IPROC glad_glMultiTexCoord2i = NULL; +PFNGLMULTITEXCOORD2IVPROC glad_glMultiTexCoord2iv = NULL; +PFNGLMULTITEXCOORD2SPROC glad_glMultiTexCoord2s = NULL; +PFNGLMULTITEXCOORD2SVPROC glad_glMultiTexCoord2sv = NULL; +PFNGLMULTITEXCOORD3DPROC glad_glMultiTexCoord3d = NULL; +PFNGLMULTITEXCOORD3DVPROC glad_glMultiTexCoord3dv = NULL; +PFNGLMULTITEXCOORD3FPROC glad_glMultiTexCoord3f = NULL; +PFNGLMULTITEXCOORD3FVPROC glad_glMultiTexCoord3fv = NULL; +PFNGLMULTITEXCOORD3IPROC glad_glMultiTexCoord3i = NULL; +PFNGLMULTITEXCOORD3IVPROC glad_glMultiTexCoord3iv = NULL; +PFNGLMULTITEXCOORD3SPROC glad_glMultiTexCoord3s = NULL; +PFNGLMULTITEXCOORD3SVPROC glad_glMultiTexCoord3sv = NULL; +PFNGLMULTITEXCOORD4DPROC glad_glMultiTexCoord4d = NULL; +PFNGLMULTITEXCOORD4DVPROC glad_glMultiTexCoord4dv = NULL; +PFNGLMULTITEXCOORD4FPROC glad_glMultiTexCoord4f = NULL; +PFNGLMULTITEXCOORD4FVPROC glad_glMultiTexCoord4fv = NULL; +PFNGLMULTITEXCOORD4IPROC glad_glMultiTexCoord4i = NULL; +PFNGLMULTITEXCOORD4IVPROC glad_glMultiTexCoord4iv = NULL; +PFNGLMULTITEXCOORD4SPROC glad_glMultiTexCoord4s = NULL; +PFNGLMULTITEXCOORD4SVPROC glad_glMultiTexCoord4sv = NULL; +PFNGLMULTITEXCOORDP1UIPROC glad_glMultiTexCoordP1ui = NULL; +PFNGLMULTITEXCOORDP1UIVPROC glad_glMultiTexCoordP1uiv = NULL; +PFNGLMULTITEXCOORDP2UIPROC glad_glMultiTexCoordP2ui = NULL; +PFNGLMULTITEXCOORDP2UIVPROC glad_glMultiTexCoordP2uiv = NULL; +PFNGLMULTITEXCOORDP3UIPROC glad_glMultiTexCoordP3ui = NULL; +PFNGLMULTITEXCOORDP3UIVPROC glad_glMultiTexCoordP3uiv = NULL; +PFNGLMULTITEXCOORDP4UIPROC glad_glMultiTexCoordP4ui = NULL; +PFNGLMULTITEXCOORDP4UIVPROC glad_glMultiTexCoordP4uiv = NULL; +PFNGLNEWLISTPROC glad_glNewList = NULL; +PFNGLNORMAL3BPROC glad_glNormal3b = NULL; +PFNGLNORMAL3BVPROC glad_glNormal3bv = NULL; +PFNGLNORMAL3DPROC glad_glNormal3d = NULL; +PFNGLNORMAL3DVPROC glad_glNormal3dv = NULL; +PFNGLNORMAL3FPROC glad_glNormal3f = NULL; +PFNGLNORMAL3FVPROC glad_glNormal3fv = NULL; +PFNGLNORMAL3IPROC glad_glNormal3i = NULL; +PFNGLNORMAL3IVPROC glad_glNormal3iv = NULL; +PFNGLNORMAL3SPROC glad_glNormal3s = NULL; +PFNGLNORMAL3SVPROC glad_glNormal3sv = NULL; +PFNGLNORMALP3UIPROC glad_glNormalP3ui = NULL; +PFNGLNORMALP3UIVPROC glad_glNormalP3uiv = NULL; +PFNGLNORMALPOINTERPROC glad_glNormalPointer = NULL; +PFNGLOBJECTLABELPROC glad_glObjectLabel = NULL; +PFNGLOBJECTPTRLABELPROC glad_glObjectPtrLabel = NULL; +PFNGLORTHOPROC glad_glOrtho = NULL; +PFNGLPASSTHROUGHPROC glad_glPassThrough = NULL; +PFNGLPIXELMAPFVPROC glad_glPixelMapfv = NULL; +PFNGLPIXELMAPUIVPROC glad_glPixelMapuiv = NULL; +PFNGLPIXELMAPUSVPROC glad_glPixelMapusv = NULL; +PFNGLPIXELSTOREFPROC glad_glPixelStoref = NULL; +PFNGLPIXELSTOREIPROC glad_glPixelStorei = NULL; +PFNGLPIXELTRANSFERFPROC glad_glPixelTransferf = NULL; +PFNGLPIXELTRANSFERIPROC glad_glPixelTransferi = NULL; +PFNGLPIXELZOOMPROC glad_glPixelZoom = NULL; +PFNGLPOINTPARAMETERFPROC glad_glPointParameterf = NULL; +PFNGLPOINTPARAMETERFVPROC glad_glPointParameterfv = NULL; +PFNGLPOINTPARAMETERIPROC glad_glPointParameteri = NULL; +PFNGLPOINTPARAMETERIVPROC glad_glPointParameteriv = NULL; +PFNGLPOINTSIZEPROC glad_glPointSize = NULL; +PFNGLPOLYGONMODEPROC glad_glPolygonMode = NULL; +PFNGLPOLYGONOFFSETPROC glad_glPolygonOffset = NULL; +PFNGLPOLYGONSTIPPLEPROC glad_glPolygonStipple = NULL; +PFNGLPOPATTRIBPROC glad_glPopAttrib = NULL; +PFNGLPOPCLIENTATTRIBPROC glad_glPopClientAttrib = NULL; +PFNGLPOPDEBUGGROUPPROC glad_glPopDebugGroup = NULL; +PFNGLPOPMATRIXPROC glad_glPopMatrix = NULL; +PFNGLPOPNAMEPROC glad_glPopName = NULL; +PFNGLPRIMITIVERESTARTINDEXPROC glad_glPrimitiveRestartIndex = NULL; +PFNGLPRIORITIZETEXTURESPROC glad_glPrioritizeTextures = NULL; +PFNGLPROVOKINGVERTEXPROC glad_glProvokingVertex = NULL; +PFNGLPUSHATTRIBPROC glad_glPushAttrib = NULL; +PFNGLPUSHCLIENTATTRIBPROC glad_glPushClientAttrib = NULL; +PFNGLPUSHDEBUGGROUPPROC glad_glPushDebugGroup = NULL; +PFNGLPUSHMATRIXPROC glad_glPushMatrix = NULL; +PFNGLPUSHNAMEPROC glad_glPushName = NULL; +PFNGLQUERYCOUNTERPROC glad_glQueryCounter = NULL; +PFNGLRASTERPOS2DPROC glad_glRasterPos2d = NULL; +PFNGLRASTERPOS2DVPROC glad_glRasterPos2dv = NULL; +PFNGLRASTERPOS2FPROC glad_glRasterPos2f = NULL; +PFNGLRASTERPOS2FVPROC glad_glRasterPos2fv = NULL; +PFNGLRASTERPOS2IPROC glad_glRasterPos2i = NULL; +PFNGLRASTERPOS2IVPROC glad_glRasterPos2iv = NULL; +PFNGLRASTERPOS2SPROC glad_glRasterPos2s = NULL; +PFNGLRASTERPOS2SVPROC glad_glRasterPos2sv = NULL; +PFNGLRASTERPOS3DPROC glad_glRasterPos3d = NULL; +PFNGLRASTERPOS3DVPROC glad_glRasterPos3dv = NULL; +PFNGLRASTERPOS3FPROC glad_glRasterPos3f = NULL; +PFNGLRASTERPOS3FVPROC glad_glRasterPos3fv = NULL; +PFNGLRASTERPOS3IPROC glad_glRasterPos3i = NULL; +PFNGLRASTERPOS3IVPROC glad_glRasterPos3iv = NULL; +PFNGLRASTERPOS3SPROC glad_glRasterPos3s = NULL; +PFNGLRASTERPOS3SVPROC glad_glRasterPos3sv = NULL; +PFNGLRASTERPOS4DPROC glad_glRasterPos4d = NULL; +PFNGLRASTERPOS4DVPROC glad_glRasterPos4dv = NULL; +PFNGLRASTERPOS4FPROC glad_glRasterPos4f = NULL; +PFNGLRASTERPOS4FVPROC glad_glRasterPos4fv = NULL; +PFNGLRASTERPOS4IPROC glad_glRasterPos4i = NULL; +PFNGLRASTERPOS4IVPROC glad_glRasterPos4iv = NULL; +PFNGLRASTERPOS4SPROC glad_glRasterPos4s = NULL; +PFNGLRASTERPOS4SVPROC glad_glRasterPos4sv = NULL; +PFNGLREADBUFFERPROC glad_glReadBuffer = NULL; +PFNGLREADPIXELSPROC glad_glReadPixels = NULL; +PFNGLREADNPIXELSARBPROC glad_glReadnPixelsARB = NULL; +PFNGLRECTDPROC glad_glRectd = NULL; +PFNGLRECTDVPROC glad_glRectdv = NULL; +PFNGLRECTFPROC glad_glRectf = NULL; +PFNGLRECTFVPROC glad_glRectfv = NULL; +PFNGLRECTIPROC glad_glRecti = NULL; +PFNGLRECTIVPROC glad_glRectiv = NULL; +PFNGLRECTSPROC glad_glRects = NULL; +PFNGLRECTSVPROC glad_glRectsv = NULL; +PFNGLRENDERMODEPROC glad_glRenderMode = NULL; +PFNGLRENDERBUFFERSTORAGEPROC glad_glRenderbufferStorage = NULL; +PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC glad_glRenderbufferStorageMultisample = NULL; +PFNGLROTATEDPROC glad_glRotated = NULL; +PFNGLROTATEFPROC glad_glRotatef = NULL; +PFNGLSAMPLECOVERAGEPROC glad_glSampleCoverage = NULL; +PFNGLSAMPLECOVERAGEARBPROC glad_glSampleCoverageARB = NULL; +PFNGLSAMPLEMASKIPROC glad_glSampleMaski = NULL; +PFNGLSAMPLERPARAMETERIIVPROC glad_glSamplerParameterIiv = NULL; +PFNGLSAMPLERPARAMETERIUIVPROC glad_glSamplerParameterIuiv = NULL; +PFNGLSAMPLERPARAMETERFPROC glad_glSamplerParameterf = NULL; +PFNGLSAMPLERPARAMETERFVPROC glad_glSamplerParameterfv = NULL; +PFNGLSAMPLERPARAMETERIPROC glad_glSamplerParameteri = NULL; +PFNGLSAMPLERPARAMETERIVPROC glad_glSamplerParameteriv = NULL; +PFNGLSCALEDPROC glad_glScaled = NULL; +PFNGLSCALEFPROC glad_glScalef = NULL; +PFNGLSCISSORPROC glad_glScissor = NULL; +PFNGLSECONDARYCOLOR3BPROC glad_glSecondaryColor3b = NULL; +PFNGLSECONDARYCOLOR3BVPROC glad_glSecondaryColor3bv = NULL; +PFNGLSECONDARYCOLOR3DPROC glad_glSecondaryColor3d = NULL; +PFNGLSECONDARYCOLOR3DVPROC glad_glSecondaryColor3dv = NULL; +PFNGLSECONDARYCOLOR3FPROC glad_glSecondaryColor3f = NULL; +PFNGLSECONDARYCOLOR3FVPROC glad_glSecondaryColor3fv = NULL; +PFNGLSECONDARYCOLOR3IPROC glad_glSecondaryColor3i = NULL; +PFNGLSECONDARYCOLOR3IVPROC glad_glSecondaryColor3iv = NULL; +PFNGLSECONDARYCOLOR3SPROC glad_glSecondaryColor3s = NULL; +PFNGLSECONDARYCOLOR3SVPROC glad_glSecondaryColor3sv = NULL; +PFNGLSECONDARYCOLOR3UBPROC glad_glSecondaryColor3ub = NULL; +PFNGLSECONDARYCOLOR3UBVPROC glad_glSecondaryColor3ubv = NULL; +PFNGLSECONDARYCOLOR3UIPROC glad_glSecondaryColor3ui = NULL; +PFNGLSECONDARYCOLOR3UIVPROC glad_glSecondaryColor3uiv = NULL; +PFNGLSECONDARYCOLOR3USPROC glad_glSecondaryColor3us = NULL; +PFNGLSECONDARYCOLOR3USVPROC glad_glSecondaryColor3usv = NULL; +PFNGLSECONDARYCOLORP3UIPROC glad_glSecondaryColorP3ui = NULL; +PFNGLSECONDARYCOLORP3UIVPROC glad_glSecondaryColorP3uiv = NULL; +PFNGLSECONDARYCOLORPOINTERPROC glad_glSecondaryColorPointer = NULL; +PFNGLSELECTBUFFERPROC glad_glSelectBuffer = NULL; +PFNGLSHADEMODELPROC glad_glShadeModel = NULL; +PFNGLSHADERSOURCEPROC glad_glShaderSource = NULL; +PFNGLSTENCILFUNCPROC glad_glStencilFunc = NULL; +PFNGLSTENCILFUNCSEPARATEPROC glad_glStencilFuncSeparate = NULL; +PFNGLSTENCILMASKPROC glad_glStencilMask = NULL; +PFNGLSTENCILMASKSEPARATEPROC glad_glStencilMaskSeparate = NULL; +PFNGLSTENCILOPPROC glad_glStencilOp = NULL; +PFNGLSTENCILOPSEPARATEPROC glad_glStencilOpSeparate = NULL; +PFNGLTEXBUFFERPROC glad_glTexBuffer = NULL; +PFNGLTEXCOORD1DPROC glad_glTexCoord1d = NULL; +PFNGLTEXCOORD1DVPROC glad_glTexCoord1dv = NULL; +PFNGLTEXCOORD1FPROC glad_glTexCoord1f = NULL; +PFNGLTEXCOORD1FVPROC glad_glTexCoord1fv = NULL; +PFNGLTEXCOORD1IPROC glad_glTexCoord1i = NULL; +PFNGLTEXCOORD1IVPROC glad_glTexCoord1iv = NULL; +PFNGLTEXCOORD1SPROC glad_glTexCoord1s = NULL; +PFNGLTEXCOORD1SVPROC glad_glTexCoord1sv = NULL; +PFNGLTEXCOORD2DPROC glad_glTexCoord2d = NULL; +PFNGLTEXCOORD2DVPROC glad_glTexCoord2dv = NULL; +PFNGLTEXCOORD2FPROC glad_glTexCoord2f = NULL; +PFNGLTEXCOORD2FVPROC glad_glTexCoord2fv = NULL; +PFNGLTEXCOORD2IPROC glad_glTexCoord2i = NULL; +PFNGLTEXCOORD2IVPROC glad_glTexCoord2iv = NULL; +PFNGLTEXCOORD2SPROC glad_glTexCoord2s = NULL; +PFNGLTEXCOORD2SVPROC glad_glTexCoord2sv = NULL; +PFNGLTEXCOORD3DPROC glad_glTexCoord3d = NULL; +PFNGLTEXCOORD3DVPROC glad_glTexCoord3dv = NULL; +PFNGLTEXCOORD3FPROC glad_glTexCoord3f = NULL; +PFNGLTEXCOORD3FVPROC glad_glTexCoord3fv = NULL; +PFNGLTEXCOORD3IPROC glad_glTexCoord3i = NULL; +PFNGLTEXCOORD3IVPROC glad_glTexCoord3iv = NULL; +PFNGLTEXCOORD3SPROC glad_glTexCoord3s = NULL; +PFNGLTEXCOORD3SVPROC glad_glTexCoord3sv = NULL; +PFNGLTEXCOORD4DPROC glad_glTexCoord4d = NULL; +PFNGLTEXCOORD4DVPROC glad_glTexCoord4dv = NULL; +PFNGLTEXCOORD4FPROC glad_glTexCoord4f = NULL; +PFNGLTEXCOORD4FVPROC glad_glTexCoord4fv = NULL; +PFNGLTEXCOORD4IPROC glad_glTexCoord4i = NULL; +PFNGLTEXCOORD4IVPROC glad_glTexCoord4iv = NULL; +PFNGLTEXCOORD4SPROC glad_glTexCoord4s = NULL; +PFNGLTEXCOORD4SVPROC glad_glTexCoord4sv = NULL; +PFNGLTEXCOORDP1UIPROC glad_glTexCoordP1ui = NULL; +PFNGLTEXCOORDP1UIVPROC glad_glTexCoordP1uiv = NULL; +PFNGLTEXCOORDP2UIPROC glad_glTexCoordP2ui = NULL; +PFNGLTEXCOORDP2UIVPROC glad_glTexCoordP2uiv = NULL; +PFNGLTEXCOORDP3UIPROC glad_glTexCoordP3ui = NULL; +PFNGLTEXCOORDP3UIVPROC glad_glTexCoordP3uiv = NULL; +PFNGLTEXCOORDP4UIPROC glad_glTexCoordP4ui = NULL; +PFNGLTEXCOORDP4UIVPROC glad_glTexCoordP4uiv = NULL; +PFNGLTEXCOORDPOINTERPROC glad_glTexCoordPointer = NULL; +PFNGLTEXENVFPROC glad_glTexEnvf = NULL; +PFNGLTEXENVFVPROC glad_glTexEnvfv = NULL; +PFNGLTEXENVIPROC glad_glTexEnvi = NULL; +PFNGLTEXENVIVPROC glad_glTexEnviv = NULL; +PFNGLTEXGENDPROC glad_glTexGend = NULL; +PFNGLTEXGENDVPROC glad_glTexGendv = NULL; +PFNGLTEXGENFPROC glad_glTexGenf = NULL; +PFNGLTEXGENFVPROC glad_glTexGenfv = NULL; +PFNGLTEXGENIPROC glad_glTexGeni = NULL; +PFNGLTEXGENIVPROC glad_glTexGeniv = NULL; +PFNGLTEXIMAGE1DPROC glad_glTexImage1D = NULL; +PFNGLTEXIMAGE2DPROC glad_glTexImage2D = NULL; +PFNGLTEXIMAGE2DMULTISAMPLEPROC glad_glTexImage2DMultisample = NULL; +PFNGLTEXIMAGE3DPROC glad_glTexImage3D = NULL; +PFNGLTEXIMAGE3DMULTISAMPLEPROC glad_glTexImage3DMultisample = NULL; +PFNGLTEXPARAMETERIIVPROC glad_glTexParameterIiv = NULL; +PFNGLTEXPARAMETERIUIVPROC glad_glTexParameterIuiv = NULL; +PFNGLTEXPARAMETERFPROC glad_glTexParameterf = NULL; +PFNGLTEXPARAMETERFVPROC glad_glTexParameterfv = NULL; +PFNGLTEXPARAMETERIPROC glad_glTexParameteri = NULL; +PFNGLTEXPARAMETERIVPROC glad_glTexParameteriv = NULL; +PFNGLTEXSUBIMAGE1DPROC glad_glTexSubImage1D = NULL; +PFNGLTEXSUBIMAGE2DPROC glad_glTexSubImage2D = NULL; +PFNGLTEXSUBIMAGE3DPROC glad_glTexSubImage3D = NULL; +PFNGLTRANSFORMFEEDBACKVARYINGSPROC glad_glTransformFeedbackVaryings = NULL; +PFNGLTRANSLATEDPROC glad_glTranslated = NULL; +PFNGLTRANSLATEFPROC glad_glTranslatef = NULL; +PFNGLUNIFORM1FPROC glad_glUniform1f = NULL; +PFNGLUNIFORM1FVPROC glad_glUniform1fv = NULL; +PFNGLUNIFORM1IPROC glad_glUniform1i = NULL; +PFNGLUNIFORM1IVPROC glad_glUniform1iv = NULL; +PFNGLUNIFORM1UIPROC glad_glUniform1ui = NULL; +PFNGLUNIFORM1UIVPROC glad_glUniform1uiv = NULL; +PFNGLUNIFORM2FPROC glad_glUniform2f = NULL; +PFNGLUNIFORM2FVPROC glad_glUniform2fv = NULL; +PFNGLUNIFORM2IPROC glad_glUniform2i = NULL; +PFNGLUNIFORM2IVPROC glad_glUniform2iv = NULL; +PFNGLUNIFORM2UIPROC glad_glUniform2ui = NULL; +PFNGLUNIFORM2UIVPROC glad_glUniform2uiv = NULL; +PFNGLUNIFORM3FPROC glad_glUniform3f = NULL; +PFNGLUNIFORM3FVPROC glad_glUniform3fv = NULL; +PFNGLUNIFORM3IPROC glad_glUniform3i = NULL; +PFNGLUNIFORM3IVPROC glad_glUniform3iv = NULL; +PFNGLUNIFORM3UIPROC glad_glUniform3ui = NULL; +PFNGLUNIFORM3UIVPROC glad_glUniform3uiv = NULL; +PFNGLUNIFORM4FPROC glad_glUniform4f = NULL; +PFNGLUNIFORM4FVPROC glad_glUniform4fv = NULL; +PFNGLUNIFORM4IPROC glad_glUniform4i = NULL; +PFNGLUNIFORM4IVPROC glad_glUniform4iv = NULL; +PFNGLUNIFORM4UIPROC glad_glUniform4ui = NULL; +PFNGLUNIFORM4UIVPROC glad_glUniform4uiv = NULL; +PFNGLUNIFORMBLOCKBINDINGPROC glad_glUniformBlockBinding = NULL; +PFNGLUNIFORMMATRIX2FVPROC glad_glUniformMatrix2fv = NULL; +PFNGLUNIFORMMATRIX2X3FVPROC glad_glUniformMatrix2x3fv = NULL; +PFNGLUNIFORMMATRIX2X4FVPROC glad_glUniformMatrix2x4fv = NULL; +PFNGLUNIFORMMATRIX3FVPROC glad_glUniformMatrix3fv = NULL; +PFNGLUNIFORMMATRIX3X2FVPROC glad_glUniformMatrix3x2fv = NULL; +PFNGLUNIFORMMATRIX3X4FVPROC glad_glUniformMatrix3x4fv = NULL; +PFNGLUNIFORMMATRIX4FVPROC glad_glUniformMatrix4fv = NULL; +PFNGLUNIFORMMATRIX4X2FVPROC glad_glUniformMatrix4x2fv = NULL; +PFNGLUNIFORMMATRIX4X3FVPROC glad_glUniformMatrix4x3fv = NULL; +PFNGLUNMAPBUFFERPROC glad_glUnmapBuffer = NULL; +PFNGLUSEPROGRAMPROC glad_glUseProgram = NULL; +PFNGLVALIDATEPROGRAMPROC glad_glValidateProgram = NULL; +PFNGLVERTEX2DPROC glad_glVertex2d = NULL; +PFNGLVERTEX2DVPROC glad_glVertex2dv = NULL; +PFNGLVERTEX2FPROC glad_glVertex2f = NULL; +PFNGLVERTEX2FVPROC glad_glVertex2fv = NULL; +PFNGLVERTEX2IPROC glad_glVertex2i = NULL; +PFNGLVERTEX2IVPROC glad_glVertex2iv = NULL; +PFNGLVERTEX2SPROC glad_glVertex2s = NULL; +PFNGLVERTEX2SVPROC glad_glVertex2sv = NULL; +PFNGLVERTEX3DPROC glad_glVertex3d = NULL; +PFNGLVERTEX3DVPROC glad_glVertex3dv = NULL; +PFNGLVERTEX3FPROC glad_glVertex3f = NULL; +PFNGLVERTEX3FVPROC glad_glVertex3fv = NULL; +PFNGLVERTEX3IPROC glad_glVertex3i = NULL; +PFNGLVERTEX3IVPROC glad_glVertex3iv = NULL; +PFNGLVERTEX3SPROC glad_glVertex3s = NULL; +PFNGLVERTEX3SVPROC glad_glVertex3sv = NULL; +PFNGLVERTEX4DPROC glad_glVertex4d = NULL; +PFNGLVERTEX4DVPROC glad_glVertex4dv = NULL; +PFNGLVERTEX4FPROC glad_glVertex4f = NULL; +PFNGLVERTEX4FVPROC glad_glVertex4fv = NULL; +PFNGLVERTEX4IPROC glad_glVertex4i = NULL; +PFNGLVERTEX4IVPROC glad_glVertex4iv = NULL; +PFNGLVERTEX4SPROC glad_glVertex4s = NULL; +PFNGLVERTEX4SVPROC glad_glVertex4sv = NULL; +PFNGLVERTEXATTRIB1DPROC glad_glVertexAttrib1d = NULL; +PFNGLVERTEXATTRIB1DVPROC glad_glVertexAttrib1dv = NULL; +PFNGLVERTEXATTRIB1FPROC glad_glVertexAttrib1f = NULL; +PFNGLVERTEXATTRIB1FVPROC glad_glVertexAttrib1fv = NULL; +PFNGLVERTEXATTRIB1SPROC glad_glVertexAttrib1s = NULL; +PFNGLVERTEXATTRIB1SVPROC glad_glVertexAttrib1sv = NULL; +PFNGLVERTEXATTRIB2DPROC glad_glVertexAttrib2d = NULL; +PFNGLVERTEXATTRIB2DVPROC glad_glVertexAttrib2dv = NULL; +PFNGLVERTEXATTRIB2FPROC glad_glVertexAttrib2f = NULL; +PFNGLVERTEXATTRIB2FVPROC glad_glVertexAttrib2fv = NULL; +PFNGLVERTEXATTRIB2SPROC glad_glVertexAttrib2s = NULL; +PFNGLVERTEXATTRIB2SVPROC glad_glVertexAttrib2sv = NULL; +PFNGLVERTEXATTRIB3DPROC glad_glVertexAttrib3d = NULL; +PFNGLVERTEXATTRIB3DVPROC glad_glVertexAttrib3dv = NULL; +PFNGLVERTEXATTRIB3FPROC glad_glVertexAttrib3f = NULL; +PFNGLVERTEXATTRIB3FVPROC glad_glVertexAttrib3fv = NULL; +PFNGLVERTEXATTRIB3SPROC glad_glVertexAttrib3s = NULL; +PFNGLVERTEXATTRIB3SVPROC glad_glVertexAttrib3sv = NULL; +PFNGLVERTEXATTRIB4NBVPROC glad_glVertexAttrib4Nbv = NULL; +PFNGLVERTEXATTRIB4NIVPROC glad_glVertexAttrib4Niv = NULL; +PFNGLVERTEXATTRIB4NSVPROC glad_glVertexAttrib4Nsv = NULL; +PFNGLVERTEXATTRIB4NUBPROC glad_glVertexAttrib4Nub = NULL; +PFNGLVERTEXATTRIB4NUBVPROC glad_glVertexAttrib4Nubv = NULL; +PFNGLVERTEXATTRIB4NUIVPROC glad_glVertexAttrib4Nuiv = NULL; +PFNGLVERTEXATTRIB4NUSVPROC glad_glVertexAttrib4Nusv = NULL; +PFNGLVERTEXATTRIB4BVPROC glad_glVertexAttrib4bv = NULL; +PFNGLVERTEXATTRIB4DPROC glad_glVertexAttrib4d = NULL; +PFNGLVERTEXATTRIB4DVPROC glad_glVertexAttrib4dv = NULL; +PFNGLVERTEXATTRIB4FPROC glad_glVertexAttrib4f = NULL; +PFNGLVERTEXATTRIB4FVPROC glad_glVertexAttrib4fv = NULL; +PFNGLVERTEXATTRIB4IVPROC glad_glVertexAttrib4iv = NULL; +PFNGLVERTEXATTRIB4SPROC glad_glVertexAttrib4s = NULL; +PFNGLVERTEXATTRIB4SVPROC glad_glVertexAttrib4sv = NULL; +PFNGLVERTEXATTRIB4UBVPROC glad_glVertexAttrib4ubv = NULL; +PFNGLVERTEXATTRIB4UIVPROC glad_glVertexAttrib4uiv = NULL; +PFNGLVERTEXATTRIB4USVPROC glad_glVertexAttrib4usv = NULL; +PFNGLVERTEXATTRIBDIVISORPROC glad_glVertexAttribDivisor = NULL; +PFNGLVERTEXATTRIBI1IPROC glad_glVertexAttribI1i = NULL; +PFNGLVERTEXATTRIBI1IVPROC glad_glVertexAttribI1iv = NULL; +PFNGLVERTEXATTRIBI1UIPROC glad_glVertexAttribI1ui = NULL; +PFNGLVERTEXATTRIBI1UIVPROC glad_glVertexAttribI1uiv = NULL; +PFNGLVERTEXATTRIBI2IPROC glad_glVertexAttribI2i = NULL; +PFNGLVERTEXATTRIBI2IVPROC glad_glVertexAttribI2iv = NULL; +PFNGLVERTEXATTRIBI2UIPROC glad_glVertexAttribI2ui = NULL; +PFNGLVERTEXATTRIBI2UIVPROC glad_glVertexAttribI2uiv = NULL; +PFNGLVERTEXATTRIBI3IPROC glad_glVertexAttribI3i = NULL; +PFNGLVERTEXATTRIBI3IVPROC glad_glVertexAttribI3iv = NULL; +PFNGLVERTEXATTRIBI3UIPROC glad_glVertexAttribI3ui = NULL; +PFNGLVERTEXATTRIBI3UIVPROC glad_glVertexAttribI3uiv = NULL; +PFNGLVERTEXATTRIBI4BVPROC glad_glVertexAttribI4bv = NULL; +PFNGLVERTEXATTRIBI4IPROC glad_glVertexAttribI4i = NULL; +PFNGLVERTEXATTRIBI4IVPROC glad_glVertexAttribI4iv = NULL; +PFNGLVERTEXATTRIBI4SVPROC glad_glVertexAttribI4sv = NULL; +PFNGLVERTEXATTRIBI4UBVPROC glad_glVertexAttribI4ubv = NULL; +PFNGLVERTEXATTRIBI4UIPROC glad_glVertexAttribI4ui = NULL; +PFNGLVERTEXATTRIBI4UIVPROC glad_glVertexAttribI4uiv = NULL; +PFNGLVERTEXATTRIBI4USVPROC glad_glVertexAttribI4usv = NULL; +PFNGLVERTEXATTRIBIPOINTERPROC glad_glVertexAttribIPointer = NULL; +PFNGLVERTEXATTRIBP1UIPROC glad_glVertexAttribP1ui = NULL; +PFNGLVERTEXATTRIBP1UIVPROC glad_glVertexAttribP1uiv = NULL; +PFNGLVERTEXATTRIBP2UIPROC glad_glVertexAttribP2ui = NULL; +PFNGLVERTEXATTRIBP2UIVPROC glad_glVertexAttribP2uiv = NULL; +PFNGLVERTEXATTRIBP3UIPROC glad_glVertexAttribP3ui = NULL; +PFNGLVERTEXATTRIBP3UIVPROC glad_glVertexAttribP3uiv = NULL; +PFNGLVERTEXATTRIBP4UIPROC glad_glVertexAttribP4ui = NULL; +PFNGLVERTEXATTRIBP4UIVPROC glad_glVertexAttribP4uiv = NULL; +PFNGLVERTEXATTRIBPOINTERPROC glad_glVertexAttribPointer = NULL; +PFNGLVERTEXP2UIPROC glad_glVertexP2ui = NULL; +PFNGLVERTEXP2UIVPROC glad_glVertexP2uiv = NULL; +PFNGLVERTEXP3UIPROC glad_glVertexP3ui = NULL; +PFNGLVERTEXP3UIVPROC glad_glVertexP3uiv = NULL; +PFNGLVERTEXP4UIPROC glad_glVertexP4ui = NULL; +PFNGLVERTEXP4UIVPROC glad_glVertexP4uiv = NULL; +PFNGLVERTEXPOINTERPROC glad_glVertexPointer = NULL; +PFNGLVIEWPORTPROC glad_glViewport = NULL; +PFNGLWAITSYNCPROC glad_glWaitSync = NULL; +PFNGLWINDOWPOS2DPROC glad_glWindowPos2d = NULL; +PFNGLWINDOWPOS2DVPROC glad_glWindowPos2dv = NULL; +PFNGLWINDOWPOS2FPROC glad_glWindowPos2f = NULL; +PFNGLWINDOWPOS2FVPROC glad_glWindowPos2fv = NULL; +PFNGLWINDOWPOS2IPROC glad_glWindowPos2i = NULL; +PFNGLWINDOWPOS2IVPROC glad_glWindowPos2iv = NULL; +PFNGLWINDOWPOS2SPROC glad_glWindowPos2s = NULL; +PFNGLWINDOWPOS2SVPROC glad_glWindowPos2sv = NULL; +PFNGLWINDOWPOS3DPROC glad_glWindowPos3d = NULL; +PFNGLWINDOWPOS3DVPROC glad_glWindowPos3dv = NULL; +PFNGLWINDOWPOS3FPROC glad_glWindowPos3f = NULL; +PFNGLWINDOWPOS3FVPROC glad_glWindowPos3fv = NULL; +PFNGLWINDOWPOS3IPROC glad_glWindowPos3i = NULL; +PFNGLWINDOWPOS3IVPROC glad_glWindowPos3iv = NULL; +PFNGLWINDOWPOS3SPROC glad_glWindowPos3s = NULL; +PFNGLWINDOWPOS3SVPROC glad_glWindowPos3sv = NULL; + + +static void glad_gl_load_GL_VERSION_1_0( GLADuserptrloadfunc load, void* userptr) { + if(!GLAD_GL_VERSION_1_0) return; + glad_glAccum = (PFNGLACCUMPROC) load(userptr, "glAccum"); + glad_glAlphaFunc = (PFNGLALPHAFUNCPROC) load(userptr, "glAlphaFunc"); + glad_glBegin = (PFNGLBEGINPROC) load(userptr, "glBegin"); + glad_glBitmap = (PFNGLBITMAPPROC) load(userptr, "glBitmap"); + glad_glBlendFunc = (PFNGLBLENDFUNCPROC) load(userptr, "glBlendFunc"); + glad_glCallList = (PFNGLCALLLISTPROC) load(userptr, "glCallList"); + glad_glCallLists = (PFNGLCALLLISTSPROC) load(userptr, "glCallLists"); + glad_glClear = (PFNGLCLEARPROC) load(userptr, "glClear"); + glad_glClearAccum = (PFNGLCLEARACCUMPROC) load(userptr, "glClearAccum"); + glad_glClearColor = (PFNGLCLEARCOLORPROC) load(userptr, "glClearColor"); + glad_glClearDepth = (PFNGLCLEARDEPTHPROC) load(userptr, "glClearDepth"); + glad_glClearIndex = (PFNGLCLEARINDEXPROC) load(userptr, "glClearIndex"); + glad_glClearStencil = (PFNGLCLEARSTENCILPROC) load(userptr, "glClearStencil"); + glad_glClipPlane = (PFNGLCLIPPLANEPROC) load(userptr, "glClipPlane"); + glad_glColor3b = (PFNGLCOLOR3BPROC) load(userptr, "glColor3b"); + glad_glColor3bv = (PFNGLCOLOR3BVPROC) load(userptr, "glColor3bv"); + glad_glColor3d = (PFNGLCOLOR3DPROC) load(userptr, "glColor3d"); + glad_glColor3dv = (PFNGLCOLOR3DVPROC) load(userptr, "glColor3dv"); + glad_glColor3f = (PFNGLCOLOR3FPROC) load(userptr, "glColor3f"); + glad_glColor3fv = (PFNGLCOLOR3FVPROC) load(userptr, "glColor3fv"); + glad_glColor3i = (PFNGLCOLOR3IPROC) load(userptr, "glColor3i"); + glad_glColor3iv = (PFNGLCOLOR3IVPROC) load(userptr, "glColor3iv"); + glad_glColor3s = (PFNGLCOLOR3SPROC) load(userptr, "glColor3s"); + glad_glColor3sv = (PFNGLCOLOR3SVPROC) load(userptr, "glColor3sv"); + glad_glColor3ub = (PFNGLCOLOR3UBPROC) load(userptr, "glColor3ub"); + glad_glColor3ubv = (PFNGLCOLOR3UBVPROC) load(userptr, "glColor3ubv"); + glad_glColor3ui = (PFNGLCOLOR3UIPROC) load(userptr, "glColor3ui"); + glad_glColor3uiv = (PFNGLCOLOR3UIVPROC) load(userptr, "glColor3uiv"); + glad_glColor3us = (PFNGLCOLOR3USPROC) load(userptr, "glColor3us"); + glad_glColor3usv = (PFNGLCOLOR3USVPROC) load(userptr, "glColor3usv"); + glad_glColor4b = (PFNGLCOLOR4BPROC) load(userptr, "glColor4b"); + glad_glColor4bv = (PFNGLCOLOR4BVPROC) load(userptr, "glColor4bv"); + glad_glColor4d = (PFNGLCOLOR4DPROC) load(userptr, "glColor4d"); + glad_glColor4dv = (PFNGLCOLOR4DVPROC) load(userptr, "glColor4dv"); + glad_glColor4f = (PFNGLCOLOR4FPROC) load(userptr, "glColor4f"); + glad_glColor4fv = (PFNGLCOLOR4FVPROC) load(userptr, "glColor4fv"); + glad_glColor4i = (PFNGLCOLOR4IPROC) load(userptr, "glColor4i"); + glad_glColor4iv = (PFNGLCOLOR4IVPROC) load(userptr, "glColor4iv"); + glad_glColor4s = (PFNGLCOLOR4SPROC) load(userptr, "glColor4s"); + glad_glColor4sv = (PFNGLCOLOR4SVPROC) load(userptr, "glColor4sv"); + glad_glColor4ub = (PFNGLCOLOR4UBPROC) load(userptr, "glColor4ub"); + glad_glColor4ubv = (PFNGLCOLOR4UBVPROC) load(userptr, "glColor4ubv"); + glad_glColor4ui = (PFNGLCOLOR4UIPROC) load(userptr, "glColor4ui"); + glad_glColor4uiv = (PFNGLCOLOR4UIVPROC) load(userptr, "glColor4uiv"); + glad_glColor4us = (PFNGLCOLOR4USPROC) load(userptr, "glColor4us"); + glad_glColor4usv = (PFNGLCOLOR4USVPROC) load(userptr, "glColor4usv"); + glad_glColorMask = (PFNGLCOLORMASKPROC) load(userptr, "glColorMask"); + glad_glColorMaterial = (PFNGLCOLORMATERIALPROC) load(userptr, "glColorMaterial"); + glad_glCopyPixels = (PFNGLCOPYPIXELSPROC) load(userptr, "glCopyPixels"); + glad_glCullFace = (PFNGLCULLFACEPROC) load(userptr, "glCullFace"); + glad_glDeleteLists = (PFNGLDELETELISTSPROC) load(userptr, "glDeleteLists"); + glad_glDepthFunc = (PFNGLDEPTHFUNCPROC) load(userptr, "glDepthFunc"); + glad_glDepthMask = (PFNGLDEPTHMASKPROC) load(userptr, "glDepthMask"); + glad_glDepthRange = (PFNGLDEPTHRANGEPROC) load(userptr, "glDepthRange"); + glad_glDisable = (PFNGLDISABLEPROC) load(userptr, "glDisable"); + glad_glDrawBuffer = (PFNGLDRAWBUFFERPROC) load(userptr, "glDrawBuffer"); + glad_glDrawPixels = (PFNGLDRAWPIXELSPROC) load(userptr, "glDrawPixels"); + glad_glEdgeFlag = (PFNGLEDGEFLAGPROC) load(userptr, "glEdgeFlag"); + glad_glEdgeFlagv = (PFNGLEDGEFLAGVPROC) load(userptr, "glEdgeFlagv"); + glad_glEnable = (PFNGLENABLEPROC) load(userptr, "glEnable"); + glad_glEnd = (PFNGLENDPROC) load(userptr, "glEnd"); + glad_glEndList = (PFNGLENDLISTPROC) load(userptr, "glEndList"); + glad_glEvalCoord1d = (PFNGLEVALCOORD1DPROC) load(userptr, "glEvalCoord1d"); + glad_glEvalCoord1dv = (PFNGLEVALCOORD1DVPROC) load(userptr, "glEvalCoord1dv"); + glad_glEvalCoord1f = (PFNGLEVALCOORD1FPROC) load(userptr, "glEvalCoord1f"); + glad_glEvalCoord1fv = (PFNGLEVALCOORD1FVPROC) load(userptr, "glEvalCoord1fv"); + glad_glEvalCoord2d = (PFNGLEVALCOORD2DPROC) load(userptr, "glEvalCoord2d"); + glad_glEvalCoord2dv = (PFNGLEVALCOORD2DVPROC) load(userptr, "glEvalCoord2dv"); + glad_glEvalCoord2f = (PFNGLEVALCOORD2FPROC) load(userptr, "glEvalCoord2f"); + glad_glEvalCoord2fv = (PFNGLEVALCOORD2FVPROC) load(userptr, "glEvalCoord2fv"); + glad_glEvalMesh1 = (PFNGLEVALMESH1PROC) load(userptr, "glEvalMesh1"); + glad_glEvalMesh2 = (PFNGLEVALMESH2PROC) load(userptr, "glEvalMesh2"); + glad_glEvalPoint1 = (PFNGLEVALPOINT1PROC) load(userptr, "glEvalPoint1"); + glad_glEvalPoint2 = (PFNGLEVALPOINT2PROC) load(userptr, "glEvalPoint2"); + glad_glFeedbackBuffer = (PFNGLFEEDBACKBUFFERPROC) load(userptr, "glFeedbackBuffer"); + glad_glFinish = (PFNGLFINISHPROC) load(userptr, "glFinish"); + glad_glFlush = (PFNGLFLUSHPROC) load(userptr, "glFlush"); + glad_glFogf = (PFNGLFOGFPROC) load(userptr, "glFogf"); + glad_glFogfv = (PFNGLFOGFVPROC) load(userptr, "glFogfv"); + glad_glFogi = (PFNGLFOGIPROC) load(userptr, "glFogi"); + glad_glFogiv = (PFNGLFOGIVPROC) load(userptr, "glFogiv"); + glad_glFrontFace = (PFNGLFRONTFACEPROC) load(userptr, "glFrontFace"); + glad_glFrustum = (PFNGLFRUSTUMPROC) load(userptr, "glFrustum"); + glad_glGenLists = (PFNGLGENLISTSPROC) load(userptr, "glGenLists"); + glad_glGetBooleanv = (PFNGLGETBOOLEANVPROC) load(userptr, "glGetBooleanv"); + glad_glGetClipPlane = (PFNGLGETCLIPPLANEPROC) load(userptr, "glGetClipPlane"); + glad_glGetDoublev = (PFNGLGETDOUBLEVPROC) load(userptr, "glGetDoublev"); + glad_glGetError = (PFNGLGETERRORPROC) load(userptr, "glGetError"); + glad_glGetFloatv = (PFNGLGETFLOATVPROC) load(userptr, "glGetFloatv"); + glad_glGetIntegerv = (PFNGLGETINTEGERVPROC) load(userptr, "glGetIntegerv"); + glad_glGetLightfv = (PFNGLGETLIGHTFVPROC) load(userptr, "glGetLightfv"); + glad_glGetLightiv = (PFNGLGETLIGHTIVPROC) load(userptr, "glGetLightiv"); + glad_glGetMapdv = (PFNGLGETMAPDVPROC) load(userptr, "glGetMapdv"); + glad_glGetMapfv = (PFNGLGETMAPFVPROC) load(userptr, "glGetMapfv"); + glad_glGetMapiv = (PFNGLGETMAPIVPROC) load(userptr, "glGetMapiv"); + glad_glGetMaterialfv = (PFNGLGETMATERIALFVPROC) load(userptr, "glGetMaterialfv"); + glad_glGetMaterialiv = (PFNGLGETMATERIALIVPROC) load(userptr, "glGetMaterialiv"); + glad_glGetPixelMapfv = (PFNGLGETPIXELMAPFVPROC) load(userptr, "glGetPixelMapfv"); + glad_glGetPixelMapuiv = (PFNGLGETPIXELMAPUIVPROC) load(userptr, "glGetPixelMapuiv"); + glad_glGetPixelMapusv = (PFNGLGETPIXELMAPUSVPROC) load(userptr, "glGetPixelMapusv"); + glad_glGetPolygonStipple = (PFNGLGETPOLYGONSTIPPLEPROC) load(userptr, "glGetPolygonStipple"); + glad_glGetString = (PFNGLGETSTRINGPROC) load(userptr, "glGetString"); + glad_glGetTexEnvfv = (PFNGLGETTEXENVFVPROC) load(userptr, "glGetTexEnvfv"); + glad_glGetTexEnviv = (PFNGLGETTEXENVIVPROC) load(userptr, "glGetTexEnviv"); + glad_glGetTexGendv = (PFNGLGETTEXGENDVPROC) load(userptr, "glGetTexGendv"); + glad_glGetTexGenfv = (PFNGLGETTEXGENFVPROC) load(userptr, "glGetTexGenfv"); + glad_glGetTexGeniv = (PFNGLGETTEXGENIVPROC) load(userptr, "glGetTexGeniv"); + glad_glGetTexImage = (PFNGLGETTEXIMAGEPROC) load(userptr, "glGetTexImage"); + glad_glGetTexLevelParameterfv = (PFNGLGETTEXLEVELPARAMETERFVPROC) load(userptr, "glGetTexLevelParameterfv"); + glad_glGetTexLevelParameteriv = (PFNGLGETTEXLEVELPARAMETERIVPROC) load(userptr, "glGetTexLevelParameteriv"); + glad_glGetTexParameterfv = (PFNGLGETTEXPARAMETERFVPROC) load(userptr, "glGetTexParameterfv"); + glad_glGetTexParameteriv = (PFNGLGETTEXPARAMETERIVPROC) load(userptr, "glGetTexParameteriv"); + glad_glHint = (PFNGLHINTPROC) load(userptr, "glHint"); + glad_glIndexMask = (PFNGLINDEXMASKPROC) load(userptr, "glIndexMask"); + glad_glIndexd = (PFNGLINDEXDPROC) load(userptr, "glIndexd"); + glad_glIndexdv = (PFNGLINDEXDVPROC) load(userptr, "glIndexdv"); + glad_glIndexf = (PFNGLINDEXFPROC) load(userptr, "glIndexf"); + glad_glIndexfv = (PFNGLINDEXFVPROC) load(userptr, "glIndexfv"); + glad_glIndexi = (PFNGLINDEXIPROC) load(userptr, "glIndexi"); + glad_glIndexiv = (PFNGLINDEXIVPROC) load(userptr, "glIndexiv"); + glad_glIndexs = (PFNGLINDEXSPROC) load(userptr, "glIndexs"); + glad_glIndexsv = (PFNGLINDEXSVPROC) load(userptr, "glIndexsv"); + glad_glInitNames = (PFNGLINITNAMESPROC) load(userptr, "glInitNames"); + glad_glIsEnabled = (PFNGLISENABLEDPROC) load(userptr, "glIsEnabled"); + glad_glIsList = (PFNGLISLISTPROC) load(userptr, "glIsList"); + glad_glLightModelf = (PFNGLLIGHTMODELFPROC) load(userptr, "glLightModelf"); + glad_glLightModelfv = (PFNGLLIGHTMODELFVPROC) load(userptr, "glLightModelfv"); + glad_glLightModeli = (PFNGLLIGHTMODELIPROC) load(userptr, "glLightModeli"); + glad_glLightModeliv = (PFNGLLIGHTMODELIVPROC) load(userptr, "glLightModeliv"); + glad_glLightf = (PFNGLLIGHTFPROC) load(userptr, "glLightf"); + glad_glLightfv = (PFNGLLIGHTFVPROC) load(userptr, "glLightfv"); + glad_glLighti = (PFNGLLIGHTIPROC) load(userptr, "glLighti"); + glad_glLightiv = (PFNGLLIGHTIVPROC) load(userptr, "glLightiv"); + glad_glLineStipple = (PFNGLLINESTIPPLEPROC) load(userptr, "glLineStipple"); + glad_glLineWidth = (PFNGLLINEWIDTHPROC) load(userptr, "glLineWidth"); + glad_glListBase = (PFNGLLISTBASEPROC) load(userptr, "glListBase"); + glad_glLoadIdentity = (PFNGLLOADIDENTITYPROC) load(userptr, "glLoadIdentity"); + glad_glLoadMatrixd = (PFNGLLOADMATRIXDPROC) load(userptr, "glLoadMatrixd"); + glad_glLoadMatrixf = (PFNGLLOADMATRIXFPROC) load(userptr, "glLoadMatrixf"); + glad_glLoadName = (PFNGLLOADNAMEPROC) load(userptr, "glLoadName"); + glad_glLogicOp = (PFNGLLOGICOPPROC) load(userptr, "glLogicOp"); + glad_glMap1d = (PFNGLMAP1DPROC) load(userptr, "glMap1d"); + glad_glMap1f = (PFNGLMAP1FPROC) load(userptr, "glMap1f"); + glad_glMap2d = (PFNGLMAP2DPROC) load(userptr, "glMap2d"); + glad_glMap2f = (PFNGLMAP2FPROC) load(userptr, "glMap2f"); + glad_glMapGrid1d = (PFNGLMAPGRID1DPROC) load(userptr, "glMapGrid1d"); + glad_glMapGrid1f = (PFNGLMAPGRID1FPROC) load(userptr, "glMapGrid1f"); + glad_glMapGrid2d = (PFNGLMAPGRID2DPROC) load(userptr, "glMapGrid2d"); + glad_glMapGrid2f = (PFNGLMAPGRID2FPROC) load(userptr, "glMapGrid2f"); + glad_glMaterialf = (PFNGLMATERIALFPROC) load(userptr, "glMaterialf"); + glad_glMaterialfv = (PFNGLMATERIALFVPROC) load(userptr, "glMaterialfv"); + glad_glMateriali = (PFNGLMATERIALIPROC) load(userptr, "glMateriali"); + glad_glMaterialiv = (PFNGLMATERIALIVPROC) load(userptr, "glMaterialiv"); + glad_glMatrixMode = (PFNGLMATRIXMODEPROC) load(userptr, "glMatrixMode"); + glad_glMultMatrixd = (PFNGLMULTMATRIXDPROC) load(userptr, "glMultMatrixd"); + glad_glMultMatrixf = (PFNGLMULTMATRIXFPROC) load(userptr, "glMultMatrixf"); + glad_glNewList = (PFNGLNEWLISTPROC) load(userptr, "glNewList"); + glad_glNormal3b = (PFNGLNORMAL3BPROC) load(userptr, "glNormal3b"); + glad_glNormal3bv = (PFNGLNORMAL3BVPROC) load(userptr, "glNormal3bv"); + glad_glNormal3d = (PFNGLNORMAL3DPROC) load(userptr, "glNormal3d"); + glad_glNormal3dv = (PFNGLNORMAL3DVPROC) load(userptr, "glNormal3dv"); + glad_glNormal3f = (PFNGLNORMAL3FPROC) load(userptr, "glNormal3f"); + glad_glNormal3fv = (PFNGLNORMAL3FVPROC) load(userptr, "glNormal3fv"); + glad_glNormal3i = (PFNGLNORMAL3IPROC) load(userptr, "glNormal3i"); + glad_glNormal3iv = (PFNGLNORMAL3IVPROC) load(userptr, "glNormal3iv"); + glad_glNormal3s = (PFNGLNORMAL3SPROC) load(userptr, "glNormal3s"); + glad_glNormal3sv = (PFNGLNORMAL3SVPROC) load(userptr, "glNormal3sv"); + glad_glOrtho = (PFNGLORTHOPROC) load(userptr, "glOrtho"); + glad_glPassThrough = (PFNGLPASSTHROUGHPROC) load(userptr, "glPassThrough"); + glad_glPixelMapfv = (PFNGLPIXELMAPFVPROC) load(userptr, "glPixelMapfv"); + glad_glPixelMapuiv = (PFNGLPIXELMAPUIVPROC) load(userptr, "glPixelMapuiv"); + glad_glPixelMapusv = (PFNGLPIXELMAPUSVPROC) load(userptr, "glPixelMapusv"); + glad_glPixelStoref = (PFNGLPIXELSTOREFPROC) load(userptr, "glPixelStoref"); + glad_glPixelStorei = (PFNGLPIXELSTOREIPROC) load(userptr, "glPixelStorei"); + glad_glPixelTransferf = (PFNGLPIXELTRANSFERFPROC) load(userptr, "glPixelTransferf"); + glad_glPixelTransferi = (PFNGLPIXELTRANSFERIPROC) load(userptr, "glPixelTransferi"); + glad_glPixelZoom = (PFNGLPIXELZOOMPROC) load(userptr, "glPixelZoom"); + glad_glPointSize = (PFNGLPOINTSIZEPROC) load(userptr, "glPointSize"); + glad_glPolygonMode = (PFNGLPOLYGONMODEPROC) load(userptr, "glPolygonMode"); + glad_glPolygonStipple = (PFNGLPOLYGONSTIPPLEPROC) load(userptr, "glPolygonStipple"); + glad_glPopAttrib = (PFNGLPOPATTRIBPROC) load(userptr, "glPopAttrib"); + glad_glPopMatrix = (PFNGLPOPMATRIXPROC) load(userptr, "glPopMatrix"); + glad_glPopName = (PFNGLPOPNAMEPROC) load(userptr, "glPopName"); + glad_glPushAttrib = (PFNGLPUSHATTRIBPROC) load(userptr, "glPushAttrib"); + glad_glPushMatrix = (PFNGLPUSHMATRIXPROC) load(userptr, "glPushMatrix"); + glad_glPushName = (PFNGLPUSHNAMEPROC) load(userptr, "glPushName"); + glad_glRasterPos2d = (PFNGLRASTERPOS2DPROC) load(userptr, "glRasterPos2d"); + glad_glRasterPos2dv = (PFNGLRASTERPOS2DVPROC) load(userptr, "glRasterPos2dv"); + glad_glRasterPos2f = (PFNGLRASTERPOS2FPROC) load(userptr, "glRasterPos2f"); + glad_glRasterPos2fv = (PFNGLRASTERPOS2FVPROC) load(userptr, "glRasterPos2fv"); + glad_glRasterPos2i = (PFNGLRASTERPOS2IPROC) load(userptr, "glRasterPos2i"); + glad_glRasterPos2iv = (PFNGLRASTERPOS2IVPROC) load(userptr, "glRasterPos2iv"); + glad_glRasterPos2s = (PFNGLRASTERPOS2SPROC) load(userptr, "glRasterPos2s"); + glad_glRasterPos2sv = (PFNGLRASTERPOS2SVPROC) load(userptr, "glRasterPos2sv"); + glad_glRasterPos3d = (PFNGLRASTERPOS3DPROC) load(userptr, "glRasterPos3d"); + glad_glRasterPos3dv = (PFNGLRASTERPOS3DVPROC) load(userptr, "glRasterPos3dv"); + glad_glRasterPos3f = (PFNGLRASTERPOS3FPROC) load(userptr, "glRasterPos3f"); + glad_glRasterPos3fv = (PFNGLRASTERPOS3FVPROC) load(userptr, "glRasterPos3fv"); + glad_glRasterPos3i = (PFNGLRASTERPOS3IPROC) load(userptr, "glRasterPos3i"); + glad_glRasterPos3iv = (PFNGLRASTERPOS3IVPROC) load(userptr, "glRasterPos3iv"); + glad_glRasterPos3s = (PFNGLRASTERPOS3SPROC) load(userptr, "glRasterPos3s"); + glad_glRasterPos3sv = (PFNGLRASTERPOS3SVPROC) load(userptr, "glRasterPos3sv"); + glad_glRasterPos4d = (PFNGLRASTERPOS4DPROC) load(userptr, "glRasterPos4d"); + glad_glRasterPos4dv = (PFNGLRASTERPOS4DVPROC) load(userptr, "glRasterPos4dv"); + glad_glRasterPos4f = (PFNGLRASTERPOS4FPROC) load(userptr, "glRasterPos4f"); + glad_glRasterPos4fv = (PFNGLRASTERPOS4FVPROC) load(userptr, "glRasterPos4fv"); + glad_glRasterPos4i = (PFNGLRASTERPOS4IPROC) load(userptr, "glRasterPos4i"); + glad_glRasterPos4iv = (PFNGLRASTERPOS4IVPROC) load(userptr, "glRasterPos4iv"); + glad_glRasterPos4s = (PFNGLRASTERPOS4SPROC) load(userptr, "glRasterPos4s"); + glad_glRasterPos4sv = (PFNGLRASTERPOS4SVPROC) load(userptr, "glRasterPos4sv"); + glad_glReadBuffer = (PFNGLREADBUFFERPROC) load(userptr, "glReadBuffer"); + glad_glReadPixels = (PFNGLREADPIXELSPROC) load(userptr, "glReadPixels"); + glad_glRectd = (PFNGLRECTDPROC) load(userptr, "glRectd"); + glad_glRectdv = (PFNGLRECTDVPROC) load(userptr, "glRectdv"); + glad_glRectf = (PFNGLRECTFPROC) load(userptr, "glRectf"); + glad_glRectfv = (PFNGLRECTFVPROC) load(userptr, "glRectfv"); + glad_glRecti = (PFNGLRECTIPROC) load(userptr, "glRecti"); + glad_glRectiv = (PFNGLRECTIVPROC) load(userptr, "glRectiv"); + glad_glRects = (PFNGLRECTSPROC) load(userptr, "glRects"); + glad_glRectsv = (PFNGLRECTSVPROC) load(userptr, "glRectsv"); + glad_glRenderMode = (PFNGLRENDERMODEPROC) load(userptr, "glRenderMode"); + glad_glRotated = (PFNGLROTATEDPROC) load(userptr, "glRotated"); + glad_glRotatef = (PFNGLROTATEFPROC) load(userptr, "glRotatef"); + glad_glScaled = (PFNGLSCALEDPROC) load(userptr, "glScaled"); + glad_glScalef = (PFNGLSCALEFPROC) load(userptr, "glScalef"); + glad_glScissor = (PFNGLSCISSORPROC) load(userptr, "glScissor"); + glad_glSelectBuffer = (PFNGLSELECTBUFFERPROC) load(userptr, "glSelectBuffer"); + glad_glShadeModel = (PFNGLSHADEMODELPROC) load(userptr, "glShadeModel"); + glad_glStencilFunc = (PFNGLSTENCILFUNCPROC) load(userptr, "glStencilFunc"); + glad_glStencilMask = (PFNGLSTENCILMASKPROC) load(userptr, "glStencilMask"); + glad_glStencilOp = (PFNGLSTENCILOPPROC) load(userptr, "glStencilOp"); + glad_glTexCoord1d = (PFNGLTEXCOORD1DPROC) load(userptr, "glTexCoord1d"); + glad_glTexCoord1dv = (PFNGLTEXCOORD1DVPROC) load(userptr, "glTexCoord1dv"); + glad_glTexCoord1f = (PFNGLTEXCOORD1FPROC) load(userptr, "glTexCoord1f"); + glad_glTexCoord1fv = (PFNGLTEXCOORD1FVPROC) load(userptr, "glTexCoord1fv"); + glad_glTexCoord1i = (PFNGLTEXCOORD1IPROC) load(userptr, "glTexCoord1i"); + glad_glTexCoord1iv = (PFNGLTEXCOORD1IVPROC) load(userptr, "glTexCoord1iv"); + glad_glTexCoord1s = (PFNGLTEXCOORD1SPROC) load(userptr, "glTexCoord1s"); + glad_glTexCoord1sv = (PFNGLTEXCOORD1SVPROC) load(userptr, "glTexCoord1sv"); + glad_glTexCoord2d = (PFNGLTEXCOORD2DPROC) load(userptr, "glTexCoord2d"); + glad_glTexCoord2dv = (PFNGLTEXCOORD2DVPROC) load(userptr, "glTexCoord2dv"); + glad_glTexCoord2f = (PFNGLTEXCOORD2FPROC) load(userptr, "glTexCoord2f"); + glad_glTexCoord2fv = (PFNGLTEXCOORD2FVPROC) load(userptr, "glTexCoord2fv"); + glad_glTexCoord2i = (PFNGLTEXCOORD2IPROC) load(userptr, "glTexCoord2i"); + glad_glTexCoord2iv = (PFNGLTEXCOORD2IVPROC) load(userptr, "glTexCoord2iv"); + glad_glTexCoord2s = (PFNGLTEXCOORD2SPROC) load(userptr, "glTexCoord2s"); + glad_glTexCoord2sv = (PFNGLTEXCOORD2SVPROC) load(userptr, "glTexCoord2sv"); + glad_glTexCoord3d = (PFNGLTEXCOORD3DPROC) load(userptr, "glTexCoord3d"); + glad_glTexCoord3dv = (PFNGLTEXCOORD3DVPROC) load(userptr, "glTexCoord3dv"); + glad_glTexCoord3f = (PFNGLTEXCOORD3FPROC) load(userptr, "glTexCoord3f"); + glad_glTexCoord3fv = (PFNGLTEXCOORD3FVPROC) load(userptr, "glTexCoord3fv"); + glad_glTexCoord3i = (PFNGLTEXCOORD3IPROC) load(userptr, "glTexCoord3i"); + glad_glTexCoord3iv = (PFNGLTEXCOORD3IVPROC) load(userptr, "glTexCoord3iv"); + glad_glTexCoord3s = (PFNGLTEXCOORD3SPROC) load(userptr, "glTexCoord3s"); + glad_glTexCoord3sv = (PFNGLTEXCOORD3SVPROC) load(userptr, "glTexCoord3sv"); + glad_glTexCoord4d = (PFNGLTEXCOORD4DPROC) load(userptr, "glTexCoord4d"); + glad_glTexCoord4dv = (PFNGLTEXCOORD4DVPROC) load(userptr, "glTexCoord4dv"); + glad_glTexCoord4f = (PFNGLTEXCOORD4FPROC) load(userptr, "glTexCoord4f"); + glad_glTexCoord4fv = (PFNGLTEXCOORD4FVPROC) load(userptr, "glTexCoord4fv"); + glad_glTexCoord4i = (PFNGLTEXCOORD4IPROC) load(userptr, "glTexCoord4i"); + glad_glTexCoord4iv = (PFNGLTEXCOORD4IVPROC) load(userptr, "glTexCoord4iv"); + glad_glTexCoord4s = (PFNGLTEXCOORD4SPROC) load(userptr, "glTexCoord4s"); + glad_glTexCoord4sv = (PFNGLTEXCOORD4SVPROC) load(userptr, "glTexCoord4sv"); + glad_glTexEnvf = (PFNGLTEXENVFPROC) load(userptr, "glTexEnvf"); + glad_glTexEnvfv = (PFNGLTEXENVFVPROC) load(userptr, "glTexEnvfv"); + glad_glTexEnvi = (PFNGLTEXENVIPROC) load(userptr, "glTexEnvi"); + glad_glTexEnviv = (PFNGLTEXENVIVPROC) load(userptr, "glTexEnviv"); + glad_glTexGend = (PFNGLTEXGENDPROC) load(userptr, "glTexGend"); + glad_glTexGendv = (PFNGLTEXGENDVPROC) load(userptr, "glTexGendv"); + glad_glTexGenf = (PFNGLTEXGENFPROC) load(userptr, "glTexGenf"); + glad_glTexGenfv = (PFNGLTEXGENFVPROC) load(userptr, "glTexGenfv"); + glad_glTexGeni = (PFNGLTEXGENIPROC) load(userptr, "glTexGeni"); + glad_glTexGeniv = (PFNGLTEXGENIVPROC) load(userptr, "glTexGeniv"); + glad_glTexImage1D = (PFNGLTEXIMAGE1DPROC) load(userptr, "glTexImage1D"); + glad_glTexImage2D = (PFNGLTEXIMAGE2DPROC) load(userptr, "glTexImage2D"); + glad_glTexParameterf = (PFNGLTEXPARAMETERFPROC) load(userptr, "glTexParameterf"); + glad_glTexParameterfv = (PFNGLTEXPARAMETERFVPROC) load(userptr, "glTexParameterfv"); + glad_glTexParameteri = (PFNGLTEXPARAMETERIPROC) load(userptr, "glTexParameteri"); + glad_glTexParameteriv = (PFNGLTEXPARAMETERIVPROC) load(userptr, "glTexParameteriv"); + glad_glTranslated = (PFNGLTRANSLATEDPROC) load(userptr, "glTranslated"); + glad_glTranslatef = (PFNGLTRANSLATEFPROC) load(userptr, "glTranslatef"); + glad_glVertex2d = (PFNGLVERTEX2DPROC) load(userptr, "glVertex2d"); + glad_glVertex2dv = (PFNGLVERTEX2DVPROC) load(userptr, "glVertex2dv"); + glad_glVertex2f = (PFNGLVERTEX2FPROC) load(userptr, "glVertex2f"); + glad_glVertex2fv = (PFNGLVERTEX2FVPROC) load(userptr, "glVertex2fv"); + glad_glVertex2i = (PFNGLVERTEX2IPROC) load(userptr, "glVertex2i"); + glad_glVertex2iv = (PFNGLVERTEX2IVPROC) load(userptr, "glVertex2iv"); + glad_glVertex2s = (PFNGLVERTEX2SPROC) load(userptr, "glVertex2s"); + glad_glVertex2sv = (PFNGLVERTEX2SVPROC) load(userptr, "glVertex2sv"); + glad_glVertex3d = (PFNGLVERTEX3DPROC) load(userptr, "glVertex3d"); + glad_glVertex3dv = (PFNGLVERTEX3DVPROC) load(userptr, "glVertex3dv"); + glad_glVertex3f = (PFNGLVERTEX3FPROC) load(userptr, "glVertex3f"); + glad_glVertex3fv = (PFNGLVERTEX3FVPROC) load(userptr, "glVertex3fv"); + glad_glVertex3i = (PFNGLVERTEX3IPROC) load(userptr, "glVertex3i"); + glad_glVertex3iv = (PFNGLVERTEX3IVPROC) load(userptr, "glVertex3iv"); + glad_glVertex3s = (PFNGLVERTEX3SPROC) load(userptr, "glVertex3s"); + glad_glVertex3sv = (PFNGLVERTEX3SVPROC) load(userptr, "glVertex3sv"); + glad_glVertex4d = (PFNGLVERTEX4DPROC) load(userptr, "glVertex4d"); + glad_glVertex4dv = (PFNGLVERTEX4DVPROC) load(userptr, "glVertex4dv"); + glad_glVertex4f = (PFNGLVERTEX4FPROC) load(userptr, "glVertex4f"); + glad_glVertex4fv = (PFNGLVERTEX4FVPROC) load(userptr, "glVertex4fv"); + glad_glVertex4i = (PFNGLVERTEX4IPROC) load(userptr, "glVertex4i"); + glad_glVertex4iv = (PFNGLVERTEX4IVPROC) load(userptr, "glVertex4iv"); + glad_glVertex4s = (PFNGLVERTEX4SPROC) load(userptr, "glVertex4s"); + glad_glVertex4sv = (PFNGLVERTEX4SVPROC) load(userptr, "glVertex4sv"); + glad_glViewport = (PFNGLVIEWPORTPROC) load(userptr, "glViewport"); +} +static void glad_gl_load_GL_VERSION_1_1( GLADuserptrloadfunc load, void* userptr) { + if(!GLAD_GL_VERSION_1_1) return; + glad_glAreTexturesResident = (PFNGLARETEXTURESRESIDENTPROC) load(userptr, "glAreTexturesResident"); + glad_glArrayElement = (PFNGLARRAYELEMENTPROC) load(userptr, "glArrayElement"); + glad_glBindTexture = (PFNGLBINDTEXTUREPROC) load(userptr, "glBindTexture"); + glad_glColorPointer = (PFNGLCOLORPOINTERPROC) load(userptr, "glColorPointer"); + glad_glCopyTexImage1D = (PFNGLCOPYTEXIMAGE1DPROC) load(userptr, "glCopyTexImage1D"); + glad_glCopyTexImage2D = (PFNGLCOPYTEXIMAGE2DPROC) load(userptr, "glCopyTexImage2D"); + glad_glCopyTexSubImage1D = (PFNGLCOPYTEXSUBIMAGE1DPROC) load(userptr, "glCopyTexSubImage1D"); + glad_glCopyTexSubImage2D = (PFNGLCOPYTEXSUBIMAGE2DPROC) load(userptr, "glCopyTexSubImage2D"); + glad_glDeleteTextures = (PFNGLDELETETEXTURESPROC) load(userptr, "glDeleteTextures"); + glad_glDisableClientState = (PFNGLDISABLECLIENTSTATEPROC) load(userptr, "glDisableClientState"); + glad_glDrawArrays = (PFNGLDRAWARRAYSPROC) load(userptr, "glDrawArrays"); + glad_glDrawElements = (PFNGLDRAWELEMENTSPROC) load(userptr, "glDrawElements"); + glad_glEdgeFlagPointer = (PFNGLEDGEFLAGPOINTERPROC) load(userptr, "glEdgeFlagPointer"); + glad_glEnableClientState = (PFNGLENABLECLIENTSTATEPROC) load(userptr, "glEnableClientState"); + glad_glGenTextures = (PFNGLGENTEXTURESPROC) load(userptr, "glGenTextures"); + glad_glGetPointerv = (PFNGLGETPOINTERVPROC) load(userptr, "glGetPointerv"); + glad_glIndexPointer = (PFNGLINDEXPOINTERPROC) load(userptr, "glIndexPointer"); + glad_glIndexub = (PFNGLINDEXUBPROC) load(userptr, "glIndexub"); + glad_glIndexubv = (PFNGLINDEXUBVPROC) load(userptr, "glIndexubv"); + glad_glInterleavedArrays = (PFNGLINTERLEAVEDARRAYSPROC) load(userptr, "glInterleavedArrays"); + glad_glIsTexture = (PFNGLISTEXTUREPROC) load(userptr, "glIsTexture"); + glad_glNormalPointer = (PFNGLNORMALPOINTERPROC) load(userptr, "glNormalPointer"); + glad_glPolygonOffset = (PFNGLPOLYGONOFFSETPROC) load(userptr, "glPolygonOffset"); + glad_glPopClientAttrib = (PFNGLPOPCLIENTATTRIBPROC) load(userptr, "glPopClientAttrib"); + glad_glPrioritizeTextures = (PFNGLPRIORITIZETEXTURESPROC) load(userptr, "glPrioritizeTextures"); + glad_glPushClientAttrib = (PFNGLPUSHCLIENTATTRIBPROC) load(userptr, "glPushClientAttrib"); + glad_glTexCoordPointer = (PFNGLTEXCOORDPOINTERPROC) load(userptr, "glTexCoordPointer"); + glad_glTexSubImage1D = (PFNGLTEXSUBIMAGE1DPROC) load(userptr, "glTexSubImage1D"); + glad_glTexSubImage2D = (PFNGLTEXSUBIMAGE2DPROC) load(userptr, "glTexSubImage2D"); + glad_glVertexPointer = (PFNGLVERTEXPOINTERPROC) load(userptr, "glVertexPointer"); +} +static void glad_gl_load_GL_VERSION_1_2( GLADuserptrloadfunc load, void* userptr) { + if(!GLAD_GL_VERSION_1_2) return; + glad_glCopyTexSubImage3D = (PFNGLCOPYTEXSUBIMAGE3DPROC) load(userptr, "glCopyTexSubImage3D"); + glad_glDrawRangeElements = (PFNGLDRAWRANGEELEMENTSPROC) load(userptr, "glDrawRangeElements"); + glad_glTexImage3D = (PFNGLTEXIMAGE3DPROC) load(userptr, "glTexImage3D"); + glad_glTexSubImage3D = (PFNGLTEXSUBIMAGE3DPROC) load(userptr, "glTexSubImage3D"); +} +static void glad_gl_load_GL_VERSION_1_3( GLADuserptrloadfunc load, void* userptr) { + if(!GLAD_GL_VERSION_1_3) return; + glad_glActiveTexture = (PFNGLACTIVETEXTUREPROC) load(userptr, "glActiveTexture"); + glad_glClientActiveTexture = (PFNGLCLIENTACTIVETEXTUREPROC) load(userptr, "glClientActiveTexture"); + glad_glCompressedTexImage1D = (PFNGLCOMPRESSEDTEXIMAGE1DPROC) load(userptr, "glCompressedTexImage1D"); + glad_glCompressedTexImage2D = (PFNGLCOMPRESSEDTEXIMAGE2DPROC) load(userptr, "glCompressedTexImage2D"); + glad_glCompressedTexImage3D = (PFNGLCOMPRESSEDTEXIMAGE3DPROC) load(userptr, "glCompressedTexImage3D"); + glad_glCompressedTexSubImage1D = (PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) load(userptr, "glCompressedTexSubImage1D"); + glad_glCompressedTexSubImage2D = (PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) load(userptr, "glCompressedTexSubImage2D"); + glad_glCompressedTexSubImage3D = (PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) load(userptr, "glCompressedTexSubImage3D"); + glad_glGetCompressedTexImage = (PFNGLGETCOMPRESSEDTEXIMAGEPROC) load(userptr, "glGetCompressedTexImage"); + glad_glLoadTransposeMatrixd = (PFNGLLOADTRANSPOSEMATRIXDPROC) load(userptr, "glLoadTransposeMatrixd"); + glad_glLoadTransposeMatrixf = (PFNGLLOADTRANSPOSEMATRIXFPROC) load(userptr, "glLoadTransposeMatrixf"); + glad_glMultTransposeMatrixd = (PFNGLMULTTRANSPOSEMATRIXDPROC) load(userptr, "glMultTransposeMatrixd"); + glad_glMultTransposeMatrixf = (PFNGLMULTTRANSPOSEMATRIXFPROC) load(userptr, "glMultTransposeMatrixf"); + glad_glMultiTexCoord1d = (PFNGLMULTITEXCOORD1DPROC) load(userptr, "glMultiTexCoord1d"); + glad_glMultiTexCoord1dv = (PFNGLMULTITEXCOORD1DVPROC) load(userptr, "glMultiTexCoord1dv"); + glad_glMultiTexCoord1f = (PFNGLMULTITEXCOORD1FPROC) load(userptr, "glMultiTexCoord1f"); + glad_glMultiTexCoord1fv = (PFNGLMULTITEXCOORD1FVPROC) load(userptr, "glMultiTexCoord1fv"); + glad_glMultiTexCoord1i = (PFNGLMULTITEXCOORD1IPROC) load(userptr, "glMultiTexCoord1i"); + glad_glMultiTexCoord1iv = (PFNGLMULTITEXCOORD1IVPROC) load(userptr, "glMultiTexCoord1iv"); + glad_glMultiTexCoord1s = (PFNGLMULTITEXCOORD1SPROC) load(userptr, "glMultiTexCoord1s"); + glad_glMultiTexCoord1sv = (PFNGLMULTITEXCOORD1SVPROC) load(userptr, "glMultiTexCoord1sv"); + glad_glMultiTexCoord2d = (PFNGLMULTITEXCOORD2DPROC) load(userptr, "glMultiTexCoord2d"); + glad_glMultiTexCoord2dv = (PFNGLMULTITEXCOORD2DVPROC) load(userptr, "glMultiTexCoord2dv"); + glad_glMultiTexCoord2f = (PFNGLMULTITEXCOORD2FPROC) load(userptr, "glMultiTexCoord2f"); + glad_glMultiTexCoord2fv = (PFNGLMULTITEXCOORD2FVPROC) load(userptr, "glMultiTexCoord2fv"); + glad_glMultiTexCoord2i = (PFNGLMULTITEXCOORD2IPROC) load(userptr, "glMultiTexCoord2i"); + glad_glMultiTexCoord2iv = (PFNGLMULTITEXCOORD2IVPROC) load(userptr, "glMultiTexCoord2iv"); + glad_glMultiTexCoord2s = (PFNGLMULTITEXCOORD2SPROC) load(userptr, "glMultiTexCoord2s"); + glad_glMultiTexCoord2sv = (PFNGLMULTITEXCOORD2SVPROC) load(userptr, "glMultiTexCoord2sv"); + glad_glMultiTexCoord3d = (PFNGLMULTITEXCOORD3DPROC) load(userptr, "glMultiTexCoord3d"); + glad_glMultiTexCoord3dv = (PFNGLMULTITEXCOORD3DVPROC) load(userptr, "glMultiTexCoord3dv"); + glad_glMultiTexCoord3f = (PFNGLMULTITEXCOORD3FPROC) load(userptr, "glMultiTexCoord3f"); + glad_glMultiTexCoord3fv = (PFNGLMULTITEXCOORD3FVPROC) load(userptr, "glMultiTexCoord3fv"); + glad_glMultiTexCoord3i = (PFNGLMULTITEXCOORD3IPROC) load(userptr, "glMultiTexCoord3i"); + glad_glMultiTexCoord3iv = (PFNGLMULTITEXCOORD3IVPROC) load(userptr, "glMultiTexCoord3iv"); + glad_glMultiTexCoord3s = (PFNGLMULTITEXCOORD3SPROC) load(userptr, "glMultiTexCoord3s"); + glad_glMultiTexCoord3sv = (PFNGLMULTITEXCOORD3SVPROC) load(userptr, "glMultiTexCoord3sv"); + glad_glMultiTexCoord4d = (PFNGLMULTITEXCOORD4DPROC) load(userptr, "glMultiTexCoord4d"); + glad_glMultiTexCoord4dv = (PFNGLMULTITEXCOORD4DVPROC) load(userptr, "glMultiTexCoord4dv"); + glad_glMultiTexCoord4f = (PFNGLMULTITEXCOORD4FPROC) load(userptr, "glMultiTexCoord4f"); + glad_glMultiTexCoord4fv = (PFNGLMULTITEXCOORD4FVPROC) load(userptr, "glMultiTexCoord4fv"); + glad_glMultiTexCoord4i = (PFNGLMULTITEXCOORD4IPROC) load(userptr, "glMultiTexCoord4i"); + glad_glMultiTexCoord4iv = (PFNGLMULTITEXCOORD4IVPROC) load(userptr, "glMultiTexCoord4iv"); + glad_glMultiTexCoord4s = (PFNGLMULTITEXCOORD4SPROC) load(userptr, "glMultiTexCoord4s"); + glad_glMultiTexCoord4sv = (PFNGLMULTITEXCOORD4SVPROC) load(userptr, "glMultiTexCoord4sv"); + glad_glSampleCoverage = (PFNGLSAMPLECOVERAGEPROC) load(userptr, "glSampleCoverage"); +} +static void glad_gl_load_GL_VERSION_1_4( GLADuserptrloadfunc load, void* userptr) { + if(!GLAD_GL_VERSION_1_4) return; + glad_glBlendColor = (PFNGLBLENDCOLORPROC) load(userptr, "glBlendColor"); + glad_glBlendEquation = (PFNGLBLENDEQUATIONPROC) load(userptr, "glBlendEquation"); + glad_glBlendFuncSeparate = (PFNGLBLENDFUNCSEPARATEPROC) load(userptr, "glBlendFuncSeparate"); + glad_glFogCoordPointer = (PFNGLFOGCOORDPOINTERPROC) load(userptr, "glFogCoordPointer"); + glad_glFogCoordd = (PFNGLFOGCOORDDPROC) load(userptr, "glFogCoordd"); + glad_glFogCoorddv = (PFNGLFOGCOORDDVPROC) load(userptr, "glFogCoorddv"); + glad_glFogCoordf = (PFNGLFOGCOORDFPROC) load(userptr, "glFogCoordf"); + glad_glFogCoordfv = (PFNGLFOGCOORDFVPROC) load(userptr, "glFogCoordfv"); + glad_glMultiDrawArrays = (PFNGLMULTIDRAWARRAYSPROC) load(userptr, "glMultiDrawArrays"); + glad_glMultiDrawElements = (PFNGLMULTIDRAWELEMENTSPROC) load(userptr, "glMultiDrawElements"); + glad_glPointParameterf = (PFNGLPOINTPARAMETERFPROC) load(userptr, "glPointParameterf"); + glad_glPointParameterfv = (PFNGLPOINTPARAMETERFVPROC) load(userptr, "glPointParameterfv"); + glad_glPointParameteri = (PFNGLPOINTPARAMETERIPROC) load(userptr, "glPointParameteri"); + glad_glPointParameteriv = (PFNGLPOINTPARAMETERIVPROC) load(userptr, "glPointParameteriv"); + glad_glSecondaryColor3b = (PFNGLSECONDARYCOLOR3BPROC) load(userptr, "glSecondaryColor3b"); + glad_glSecondaryColor3bv = (PFNGLSECONDARYCOLOR3BVPROC) load(userptr, "glSecondaryColor3bv"); + glad_glSecondaryColor3d = (PFNGLSECONDARYCOLOR3DPROC) load(userptr, "glSecondaryColor3d"); + glad_glSecondaryColor3dv = (PFNGLSECONDARYCOLOR3DVPROC) load(userptr, "glSecondaryColor3dv"); + glad_glSecondaryColor3f = (PFNGLSECONDARYCOLOR3FPROC) load(userptr, "glSecondaryColor3f"); + glad_glSecondaryColor3fv = (PFNGLSECONDARYCOLOR3FVPROC) load(userptr, "glSecondaryColor3fv"); + glad_glSecondaryColor3i = (PFNGLSECONDARYCOLOR3IPROC) load(userptr, "glSecondaryColor3i"); + glad_glSecondaryColor3iv = (PFNGLSECONDARYCOLOR3IVPROC) load(userptr, "glSecondaryColor3iv"); + glad_glSecondaryColor3s = (PFNGLSECONDARYCOLOR3SPROC) load(userptr, "glSecondaryColor3s"); + glad_glSecondaryColor3sv = (PFNGLSECONDARYCOLOR3SVPROC) load(userptr, "glSecondaryColor3sv"); + glad_glSecondaryColor3ub = (PFNGLSECONDARYCOLOR3UBPROC) load(userptr, "glSecondaryColor3ub"); + glad_glSecondaryColor3ubv = (PFNGLSECONDARYCOLOR3UBVPROC) load(userptr, "glSecondaryColor3ubv"); + glad_glSecondaryColor3ui = (PFNGLSECONDARYCOLOR3UIPROC) load(userptr, "glSecondaryColor3ui"); + glad_glSecondaryColor3uiv = (PFNGLSECONDARYCOLOR3UIVPROC) load(userptr, "glSecondaryColor3uiv"); + glad_glSecondaryColor3us = (PFNGLSECONDARYCOLOR3USPROC) load(userptr, "glSecondaryColor3us"); + glad_glSecondaryColor3usv = (PFNGLSECONDARYCOLOR3USVPROC) load(userptr, "glSecondaryColor3usv"); + glad_glSecondaryColorPointer = (PFNGLSECONDARYCOLORPOINTERPROC) load(userptr, "glSecondaryColorPointer"); + glad_glWindowPos2d = (PFNGLWINDOWPOS2DPROC) load(userptr, "glWindowPos2d"); + glad_glWindowPos2dv = (PFNGLWINDOWPOS2DVPROC) load(userptr, "glWindowPos2dv"); + glad_glWindowPos2f = (PFNGLWINDOWPOS2FPROC) load(userptr, "glWindowPos2f"); + glad_glWindowPos2fv = (PFNGLWINDOWPOS2FVPROC) load(userptr, "glWindowPos2fv"); + glad_glWindowPos2i = (PFNGLWINDOWPOS2IPROC) load(userptr, "glWindowPos2i"); + glad_glWindowPos2iv = (PFNGLWINDOWPOS2IVPROC) load(userptr, "glWindowPos2iv"); + glad_glWindowPos2s = (PFNGLWINDOWPOS2SPROC) load(userptr, "glWindowPos2s"); + glad_glWindowPos2sv = (PFNGLWINDOWPOS2SVPROC) load(userptr, "glWindowPos2sv"); + glad_glWindowPos3d = (PFNGLWINDOWPOS3DPROC) load(userptr, "glWindowPos3d"); + glad_glWindowPos3dv = (PFNGLWINDOWPOS3DVPROC) load(userptr, "glWindowPos3dv"); + glad_glWindowPos3f = (PFNGLWINDOWPOS3FPROC) load(userptr, "glWindowPos3f"); + glad_glWindowPos3fv = (PFNGLWINDOWPOS3FVPROC) load(userptr, "glWindowPos3fv"); + glad_glWindowPos3i = (PFNGLWINDOWPOS3IPROC) load(userptr, "glWindowPos3i"); + glad_glWindowPos3iv = (PFNGLWINDOWPOS3IVPROC) load(userptr, "glWindowPos3iv"); + glad_glWindowPos3s = (PFNGLWINDOWPOS3SPROC) load(userptr, "glWindowPos3s"); + glad_glWindowPos3sv = (PFNGLWINDOWPOS3SVPROC) load(userptr, "glWindowPos3sv"); +} +static void glad_gl_load_GL_VERSION_1_5( GLADuserptrloadfunc load, void* userptr) { + if(!GLAD_GL_VERSION_1_5) return; + glad_glBeginQuery = (PFNGLBEGINQUERYPROC) load(userptr, "glBeginQuery"); + glad_glBindBuffer = (PFNGLBINDBUFFERPROC) load(userptr, "glBindBuffer"); + glad_glBufferData = (PFNGLBUFFERDATAPROC) load(userptr, "glBufferData"); + glad_glBufferSubData = (PFNGLBUFFERSUBDATAPROC) load(userptr, "glBufferSubData"); + glad_glDeleteBuffers = (PFNGLDELETEBUFFERSPROC) load(userptr, "glDeleteBuffers"); + glad_glDeleteQueries = (PFNGLDELETEQUERIESPROC) load(userptr, "glDeleteQueries"); + glad_glEndQuery = (PFNGLENDQUERYPROC) load(userptr, "glEndQuery"); + glad_glGenBuffers = (PFNGLGENBUFFERSPROC) load(userptr, "glGenBuffers"); + glad_glGenQueries = (PFNGLGENQUERIESPROC) load(userptr, "glGenQueries"); + glad_glGetBufferParameteriv = (PFNGLGETBUFFERPARAMETERIVPROC) load(userptr, "glGetBufferParameteriv"); + glad_glGetBufferPointerv = (PFNGLGETBUFFERPOINTERVPROC) load(userptr, "glGetBufferPointerv"); + glad_glGetBufferSubData = (PFNGLGETBUFFERSUBDATAPROC) load(userptr, "glGetBufferSubData"); + glad_glGetQueryObjectiv = (PFNGLGETQUERYOBJECTIVPROC) load(userptr, "glGetQueryObjectiv"); + glad_glGetQueryObjectuiv = (PFNGLGETQUERYOBJECTUIVPROC) load(userptr, "glGetQueryObjectuiv"); + glad_glGetQueryiv = (PFNGLGETQUERYIVPROC) load(userptr, "glGetQueryiv"); + glad_glIsBuffer = (PFNGLISBUFFERPROC) load(userptr, "glIsBuffer"); + glad_glIsQuery = (PFNGLISQUERYPROC) load(userptr, "glIsQuery"); + glad_glMapBuffer = (PFNGLMAPBUFFERPROC) load(userptr, "glMapBuffer"); + glad_glUnmapBuffer = (PFNGLUNMAPBUFFERPROC) load(userptr, "glUnmapBuffer"); +} +static void glad_gl_load_GL_VERSION_2_0( GLADuserptrloadfunc load, void* userptr) { + if(!GLAD_GL_VERSION_2_0) return; + glad_glAttachShader = (PFNGLATTACHSHADERPROC) load(userptr, "glAttachShader"); + glad_glBindAttribLocation = (PFNGLBINDATTRIBLOCATIONPROC) load(userptr, "glBindAttribLocation"); + glad_glBlendEquationSeparate = (PFNGLBLENDEQUATIONSEPARATEPROC) load(userptr, "glBlendEquationSeparate"); + glad_glCompileShader = (PFNGLCOMPILESHADERPROC) load(userptr, "glCompileShader"); + glad_glCreateProgram = (PFNGLCREATEPROGRAMPROC) load(userptr, "glCreateProgram"); + glad_glCreateShader = (PFNGLCREATESHADERPROC) load(userptr, "glCreateShader"); + glad_glDeleteProgram = (PFNGLDELETEPROGRAMPROC) load(userptr, "glDeleteProgram"); + glad_glDeleteShader = (PFNGLDELETESHADERPROC) load(userptr, "glDeleteShader"); + glad_glDetachShader = (PFNGLDETACHSHADERPROC) load(userptr, "glDetachShader"); + glad_glDisableVertexAttribArray = (PFNGLDISABLEVERTEXATTRIBARRAYPROC) load(userptr, "glDisableVertexAttribArray"); + glad_glDrawBuffers = (PFNGLDRAWBUFFERSPROC) load(userptr, "glDrawBuffers"); + glad_glEnableVertexAttribArray = (PFNGLENABLEVERTEXATTRIBARRAYPROC) load(userptr, "glEnableVertexAttribArray"); + glad_glGetActiveAttrib = (PFNGLGETACTIVEATTRIBPROC) load(userptr, "glGetActiveAttrib"); + glad_glGetActiveUniform = (PFNGLGETACTIVEUNIFORMPROC) load(userptr, "glGetActiveUniform"); + glad_glGetAttachedShaders = (PFNGLGETATTACHEDSHADERSPROC) load(userptr, "glGetAttachedShaders"); + glad_glGetAttribLocation = (PFNGLGETATTRIBLOCATIONPROC) load(userptr, "glGetAttribLocation"); + glad_glGetProgramInfoLog = (PFNGLGETPROGRAMINFOLOGPROC) load(userptr, "glGetProgramInfoLog"); + glad_glGetProgramiv = (PFNGLGETPROGRAMIVPROC) load(userptr, "glGetProgramiv"); + glad_glGetShaderInfoLog = (PFNGLGETSHADERINFOLOGPROC) load(userptr, "glGetShaderInfoLog"); + glad_glGetShaderSource = (PFNGLGETSHADERSOURCEPROC) load(userptr, "glGetShaderSource"); + glad_glGetShaderiv = (PFNGLGETSHADERIVPROC) load(userptr, "glGetShaderiv"); + glad_glGetUniformLocation = (PFNGLGETUNIFORMLOCATIONPROC) load(userptr, "glGetUniformLocation"); + glad_glGetUniformfv = (PFNGLGETUNIFORMFVPROC) load(userptr, "glGetUniformfv"); + glad_glGetUniformiv = (PFNGLGETUNIFORMIVPROC) load(userptr, "glGetUniformiv"); + glad_glGetVertexAttribPointerv = (PFNGLGETVERTEXATTRIBPOINTERVPROC) load(userptr, "glGetVertexAttribPointerv"); + glad_glGetVertexAttribdv = (PFNGLGETVERTEXATTRIBDVPROC) load(userptr, "glGetVertexAttribdv"); + glad_glGetVertexAttribfv = (PFNGLGETVERTEXATTRIBFVPROC) load(userptr, "glGetVertexAttribfv"); + glad_glGetVertexAttribiv = (PFNGLGETVERTEXATTRIBIVPROC) load(userptr, "glGetVertexAttribiv"); + glad_glIsProgram = (PFNGLISPROGRAMPROC) load(userptr, "glIsProgram"); + glad_glIsShader = (PFNGLISSHADERPROC) load(userptr, "glIsShader"); + glad_glLinkProgram = (PFNGLLINKPROGRAMPROC) load(userptr, "glLinkProgram"); + glad_glShaderSource = (PFNGLSHADERSOURCEPROC) load(userptr, "glShaderSource"); + glad_glStencilFuncSeparate = (PFNGLSTENCILFUNCSEPARATEPROC) load(userptr, "glStencilFuncSeparate"); + glad_glStencilMaskSeparate = (PFNGLSTENCILMASKSEPARATEPROC) load(userptr, "glStencilMaskSeparate"); + glad_glStencilOpSeparate = (PFNGLSTENCILOPSEPARATEPROC) load(userptr, "glStencilOpSeparate"); + glad_glUniform1f = (PFNGLUNIFORM1FPROC) load(userptr, "glUniform1f"); + glad_glUniform1fv = (PFNGLUNIFORM1FVPROC) load(userptr, "glUniform1fv"); + glad_glUniform1i = (PFNGLUNIFORM1IPROC) load(userptr, "glUniform1i"); + glad_glUniform1iv = (PFNGLUNIFORM1IVPROC) load(userptr, "glUniform1iv"); + glad_glUniform2f = (PFNGLUNIFORM2FPROC) load(userptr, "glUniform2f"); + glad_glUniform2fv = (PFNGLUNIFORM2FVPROC) load(userptr, "glUniform2fv"); + glad_glUniform2i = (PFNGLUNIFORM2IPROC) load(userptr, "glUniform2i"); + glad_glUniform2iv = (PFNGLUNIFORM2IVPROC) load(userptr, "glUniform2iv"); + glad_glUniform3f = (PFNGLUNIFORM3FPROC) load(userptr, "glUniform3f"); + glad_glUniform3fv = (PFNGLUNIFORM3FVPROC) load(userptr, "glUniform3fv"); + glad_glUniform3i = (PFNGLUNIFORM3IPROC) load(userptr, "glUniform3i"); + glad_glUniform3iv = (PFNGLUNIFORM3IVPROC) load(userptr, "glUniform3iv"); + glad_glUniform4f = (PFNGLUNIFORM4FPROC) load(userptr, "glUniform4f"); + glad_glUniform4fv = (PFNGLUNIFORM4FVPROC) load(userptr, "glUniform4fv"); + glad_glUniform4i = (PFNGLUNIFORM4IPROC) load(userptr, "glUniform4i"); + glad_glUniform4iv = (PFNGLUNIFORM4IVPROC) load(userptr, "glUniform4iv"); + glad_glUniformMatrix2fv = (PFNGLUNIFORMMATRIX2FVPROC) load(userptr, "glUniformMatrix2fv"); + glad_glUniformMatrix3fv = (PFNGLUNIFORMMATRIX3FVPROC) load(userptr, "glUniformMatrix3fv"); + glad_glUniformMatrix4fv = (PFNGLUNIFORMMATRIX4FVPROC) load(userptr, "glUniformMatrix4fv"); + glad_glUseProgram = (PFNGLUSEPROGRAMPROC) load(userptr, "glUseProgram"); + glad_glValidateProgram = (PFNGLVALIDATEPROGRAMPROC) load(userptr, "glValidateProgram"); + glad_glVertexAttrib1d = (PFNGLVERTEXATTRIB1DPROC) load(userptr, "glVertexAttrib1d"); + glad_glVertexAttrib1dv = (PFNGLVERTEXATTRIB1DVPROC) load(userptr, "glVertexAttrib1dv"); + glad_glVertexAttrib1f = (PFNGLVERTEXATTRIB1FPROC) load(userptr, "glVertexAttrib1f"); + glad_glVertexAttrib1fv = (PFNGLVERTEXATTRIB1FVPROC) load(userptr, "glVertexAttrib1fv"); + glad_glVertexAttrib1s = (PFNGLVERTEXATTRIB1SPROC) load(userptr, "glVertexAttrib1s"); + glad_glVertexAttrib1sv = (PFNGLVERTEXATTRIB1SVPROC) load(userptr, "glVertexAttrib1sv"); + glad_glVertexAttrib2d = (PFNGLVERTEXATTRIB2DPROC) load(userptr, "glVertexAttrib2d"); + glad_glVertexAttrib2dv = (PFNGLVERTEXATTRIB2DVPROC) load(userptr, "glVertexAttrib2dv"); + glad_glVertexAttrib2f = (PFNGLVERTEXATTRIB2FPROC) load(userptr, "glVertexAttrib2f"); + glad_glVertexAttrib2fv = (PFNGLVERTEXATTRIB2FVPROC) load(userptr, "glVertexAttrib2fv"); + glad_glVertexAttrib2s = (PFNGLVERTEXATTRIB2SPROC) load(userptr, "glVertexAttrib2s"); + glad_glVertexAttrib2sv = (PFNGLVERTEXATTRIB2SVPROC) load(userptr, "glVertexAttrib2sv"); + glad_glVertexAttrib3d = (PFNGLVERTEXATTRIB3DPROC) load(userptr, "glVertexAttrib3d"); + glad_glVertexAttrib3dv = (PFNGLVERTEXATTRIB3DVPROC) load(userptr, "glVertexAttrib3dv"); + glad_glVertexAttrib3f = (PFNGLVERTEXATTRIB3FPROC) load(userptr, "glVertexAttrib3f"); + glad_glVertexAttrib3fv = (PFNGLVERTEXATTRIB3FVPROC) load(userptr, "glVertexAttrib3fv"); + glad_glVertexAttrib3s = (PFNGLVERTEXATTRIB3SPROC) load(userptr, "glVertexAttrib3s"); + glad_glVertexAttrib3sv = (PFNGLVERTEXATTRIB3SVPROC) load(userptr, "glVertexAttrib3sv"); + glad_glVertexAttrib4Nbv = (PFNGLVERTEXATTRIB4NBVPROC) load(userptr, "glVertexAttrib4Nbv"); + glad_glVertexAttrib4Niv = (PFNGLVERTEXATTRIB4NIVPROC) load(userptr, "glVertexAttrib4Niv"); + glad_glVertexAttrib4Nsv = (PFNGLVERTEXATTRIB4NSVPROC) load(userptr, "glVertexAttrib4Nsv"); + glad_glVertexAttrib4Nub = (PFNGLVERTEXATTRIB4NUBPROC) load(userptr, "glVertexAttrib4Nub"); + glad_glVertexAttrib4Nubv = (PFNGLVERTEXATTRIB4NUBVPROC) load(userptr, "glVertexAttrib4Nubv"); + glad_glVertexAttrib4Nuiv = (PFNGLVERTEXATTRIB4NUIVPROC) load(userptr, "glVertexAttrib4Nuiv"); + glad_glVertexAttrib4Nusv = (PFNGLVERTEXATTRIB4NUSVPROC) load(userptr, "glVertexAttrib4Nusv"); + glad_glVertexAttrib4bv = (PFNGLVERTEXATTRIB4BVPROC) load(userptr, "glVertexAttrib4bv"); + glad_glVertexAttrib4d = (PFNGLVERTEXATTRIB4DPROC) load(userptr, "glVertexAttrib4d"); + glad_glVertexAttrib4dv = (PFNGLVERTEXATTRIB4DVPROC) load(userptr, "glVertexAttrib4dv"); + glad_glVertexAttrib4f = (PFNGLVERTEXATTRIB4FPROC) load(userptr, "glVertexAttrib4f"); + glad_glVertexAttrib4fv = (PFNGLVERTEXATTRIB4FVPROC) load(userptr, "glVertexAttrib4fv"); + glad_glVertexAttrib4iv = (PFNGLVERTEXATTRIB4IVPROC) load(userptr, "glVertexAttrib4iv"); + glad_glVertexAttrib4s = (PFNGLVERTEXATTRIB4SPROC) load(userptr, "glVertexAttrib4s"); + glad_glVertexAttrib4sv = (PFNGLVERTEXATTRIB4SVPROC) load(userptr, "glVertexAttrib4sv"); + glad_glVertexAttrib4ubv = (PFNGLVERTEXATTRIB4UBVPROC) load(userptr, "glVertexAttrib4ubv"); + glad_glVertexAttrib4uiv = (PFNGLVERTEXATTRIB4UIVPROC) load(userptr, "glVertexAttrib4uiv"); + glad_glVertexAttrib4usv = (PFNGLVERTEXATTRIB4USVPROC) load(userptr, "glVertexAttrib4usv"); + glad_glVertexAttribPointer = (PFNGLVERTEXATTRIBPOINTERPROC) load(userptr, "glVertexAttribPointer"); +} +static void glad_gl_load_GL_VERSION_2_1( GLADuserptrloadfunc load, void* userptr) { + if(!GLAD_GL_VERSION_2_1) return; + glad_glUniformMatrix2x3fv = (PFNGLUNIFORMMATRIX2X3FVPROC) load(userptr, "glUniformMatrix2x3fv"); + glad_glUniformMatrix2x4fv = (PFNGLUNIFORMMATRIX2X4FVPROC) load(userptr, "glUniformMatrix2x4fv"); + glad_glUniformMatrix3x2fv = (PFNGLUNIFORMMATRIX3X2FVPROC) load(userptr, "glUniformMatrix3x2fv"); + glad_glUniformMatrix3x4fv = (PFNGLUNIFORMMATRIX3X4FVPROC) load(userptr, "glUniformMatrix3x4fv"); + glad_glUniformMatrix4x2fv = (PFNGLUNIFORMMATRIX4X2FVPROC) load(userptr, "glUniformMatrix4x2fv"); + glad_glUniformMatrix4x3fv = (PFNGLUNIFORMMATRIX4X3FVPROC) load(userptr, "glUniformMatrix4x3fv"); +} +static void glad_gl_load_GL_VERSION_3_0( GLADuserptrloadfunc load, void* userptr) { + if(!GLAD_GL_VERSION_3_0) return; + glad_glBeginConditionalRender = (PFNGLBEGINCONDITIONALRENDERPROC) load(userptr, "glBeginConditionalRender"); + glad_glBeginTransformFeedback = (PFNGLBEGINTRANSFORMFEEDBACKPROC) load(userptr, "glBeginTransformFeedback"); + glad_glBindBufferBase = (PFNGLBINDBUFFERBASEPROC) load(userptr, "glBindBufferBase"); + glad_glBindBufferRange = (PFNGLBINDBUFFERRANGEPROC) load(userptr, "glBindBufferRange"); + glad_glBindFragDataLocation = (PFNGLBINDFRAGDATALOCATIONPROC) load(userptr, "glBindFragDataLocation"); + glad_glBindFramebuffer = (PFNGLBINDFRAMEBUFFERPROC) load(userptr, "glBindFramebuffer"); + glad_glBindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC) load(userptr, "glBindRenderbuffer"); + glad_glBindVertexArray = (PFNGLBINDVERTEXARRAYPROC) load(userptr, "glBindVertexArray"); + glad_glBlitFramebuffer = (PFNGLBLITFRAMEBUFFERPROC) load(userptr, "glBlitFramebuffer"); + glad_glCheckFramebufferStatus = (PFNGLCHECKFRAMEBUFFERSTATUSPROC) load(userptr, "glCheckFramebufferStatus"); + glad_glClampColor = (PFNGLCLAMPCOLORPROC) load(userptr, "glClampColor"); + glad_glClearBufferfi = (PFNGLCLEARBUFFERFIPROC) load(userptr, "glClearBufferfi"); + glad_glClearBufferfv = (PFNGLCLEARBUFFERFVPROC) load(userptr, "glClearBufferfv"); + glad_glClearBufferiv = (PFNGLCLEARBUFFERIVPROC) load(userptr, "glClearBufferiv"); + glad_glClearBufferuiv = (PFNGLCLEARBUFFERUIVPROC) load(userptr, "glClearBufferuiv"); + glad_glColorMaski = (PFNGLCOLORMASKIPROC) load(userptr, "glColorMaski"); + glad_glDeleteFramebuffers = (PFNGLDELETEFRAMEBUFFERSPROC) load(userptr, "glDeleteFramebuffers"); + glad_glDeleteRenderbuffers = (PFNGLDELETERENDERBUFFERSPROC) load(userptr, "glDeleteRenderbuffers"); + glad_glDeleteVertexArrays = (PFNGLDELETEVERTEXARRAYSPROC) load(userptr, "glDeleteVertexArrays"); + glad_glDisablei = (PFNGLDISABLEIPROC) load(userptr, "glDisablei"); + glad_glEnablei = (PFNGLENABLEIPROC) load(userptr, "glEnablei"); + glad_glEndConditionalRender = (PFNGLENDCONDITIONALRENDERPROC) load(userptr, "glEndConditionalRender"); + glad_glEndTransformFeedback = (PFNGLENDTRANSFORMFEEDBACKPROC) load(userptr, "glEndTransformFeedback"); + glad_glFlushMappedBufferRange = (PFNGLFLUSHMAPPEDBUFFERRANGEPROC) load(userptr, "glFlushMappedBufferRange"); + glad_glFramebufferRenderbuffer = (PFNGLFRAMEBUFFERRENDERBUFFERPROC) load(userptr, "glFramebufferRenderbuffer"); + glad_glFramebufferTexture1D = (PFNGLFRAMEBUFFERTEXTURE1DPROC) load(userptr, "glFramebufferTexture1D"); + glad_glFramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DPROC) load(userptr, "glFramebufferTexture2D"); + glad_glFramebufferTexture3D = (PFNGLFRAMEBUFFERTEXTURE3DPROC) load(userptr, "glFramebufferTexture3D"); + glad_glFramebufferTextureLayer = (PFNGLFRAMEBUFFERTEXTURELAYERPROC) load(userptr, "glFramebufferTextureLayer"); + glad_glGenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC) load(userptr, "glGenFramebuffers"); + glad_glGenRenderbuffers = (PFNGLGENRENDERBUFFERSPROC) load(userptr, "glGenRenderbuffers"); + glad_glGenVertexArrays = (PFNGLGENVERTEXARRAYSPROC) load(userptr, "glGenVertexArrays"); + glad_glGenerateMipmap = (PFNGLGENERATEMIPMAPPROC) load(userptr, "glGenerateMipmap"); + glad_glGetBooleani_v = (PFNGLGETBOOLEANI_VPROC) load(userptr, "glGetBooleani_v"); + glad_glGetFragDataLocation = (PFNGLGETFRAGDATALOCATIONPROC) load(userptr, "glGetFragDataLocation"); + glad_glGetFramebufferAttachmentParameteriv = (PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC) load(userptr, "glGetFramebufferAttachmentParameteriv"); + glad_glGetIntegeri_v = (PFNGLGETINTEGERI_VPROC) load(userptr, "glGetIntegeri_v"); + glad_glGetRenderbufferParameteriv = (PFNGLGETRENDERBUFFERPARAMETERIVPROC) load(userptr, "glGetRenderbufferParameteriv"); + glad_glGetStringi = (PFNGLGETSTRINGIPROC) load(userptr, "glGetStringi"); + glad_glGetTexParameterIiv = (PFNGLGETTEXPARAMETERIIVPROC) load(userptr, "glGetTexParameterIiv"); + glad_glGetTexParameterIuiv = (PFNGLGETTEXPARAMETERIUIVPROC) load(userptr, "glGetTexParameterIuiv"); + glad_glGetTransformFeedbackVarying = (PFNGLGETTRANSFORMFEEDBACKVARYINGPROC) load(userptr, "glGetTransformFeedbackVarying"); + glad_glGetUniformuiv = (PFNGLGETUNIFORMUIVPROC) load(userptr, "glGetUniformuiv"); + glad_glGetVertexAttribIiv = (PFNGLGETVERTEXATTRIBIIVPROC) load(userptr, "glGetVertexAttribIiv"); + glad_glGetVertexAttribIuiv = (PFNGLGETVERTEXATTRIBIUIVPROC) load(userptr, "glGetVertexAttribIuiv"); + glad_glIsEnabledi = (PFNGLISENABLEDIPROC) load(userptr, "glIsEnabledi"); + glad_glIsFramebuffer = (PFNGLISFRAMEBUFFERPROC) load(userptr, "glIsFramebuffer"); + glad_glIsRenderbuffer = (PFNGLISRENDERBUFFERPROC) load(userptr, "glIsRenderbuffer"); + glad_glIsVertexArray = (PFNGLISVERTEXARRAYPROC) load(userptr, "glIsVertexArray"); + glad_glMapBufferRange = (PFNGLMAPBUFFERRANGEPROC) load(userptr, "glMapBufferRange"); + glad_glRenderbufferStorage = (PFNGLRENDERBUFFERSTORAGEPROC) load(userptr, "glRenderbufferStorage"); + glad_glRenderbufferStorageMultisample = (PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC) load(userptr, "glRenderbufferStorageMultisample"); + glad_glTexParameterIiv = (PFNGLTEXPARAMETERIIVPROC) load(userptr, "glTexParameterIiv"); + glad_glTexParameterIuiv = (PFNGLTEXPARAMETERIUIVPROC) load(userptr, "glTexParameterIuiv"); + glad_glTransformFeedbackVaryings = (PFNGLTRANSFORMFEEDBACKVARYINGSPROC) load(userptr, "glTransformFeedbackVaryings"); + glad_glUniform1ui = (PFNGLUNIFORM1UIPROC) load(userptr, "glUniform1ui"); + glad_glUniform1uiv = (PFNGLUNIFORM1UIVPROC) load(userptr, "glUniform1uiv"); + glad_glUniform2ui = (PFNGLUNIFORM2UIPROC) load(userptr, "glUniform2ui"); + glad_glUniform2uiv = (PFNGLUNIFORM2UIVPROC) load(userptr, "glUniform2uiv"); + glad_glUniform3ui = (PFNGLUNIFORM3UIPROC) load(userptr, "glUniform3ui"); + glad_glUniform3uiv = (PFNGLUNIFORM3UIVPROC) load(userptr, "glUniform3uiv"); + glad_glUniform4ui = (PFNGLUNIFORM4UIPROC) load(userptr, "glUniform4ui"); + glad_glUniform4uiv = (PFNGLUNIFORM4UIVPROC) load(userptr, "glUniform4uiv"); + glad_glVertexAttribI1i = (PFNGLVERTEXATTRIBI1IPROC) load(userptr, "glVertexAttribI1i"); + glad_glVertexAttribI1iv = (PFNGLVERTEXATTRIBI1IVPROC) load(userptr, "glVertexAttribI1iv"); + glad_glVertexAttribI1ui = (PFNGLVERTEXATTRIBI1UIPROC) load(userptr, "glVertexAttribI1ui"); + glad_glVertexAttribI1uiv = (PFNGLVERTEXATTRIBI1UIVPROC) load(userptr, "glVertexAttribI1uiv"); + glad_glVertexAttribI2i = (PFNGLVERTEXATTRIBI2IPROC) load(userptr, "glVertexAttribI2i"); + glad_glVertexAttribI2iv = (PFNGLVERTEXATTRIBI2IVPROC) load(userptr, "glVertexAttribI2iv"); + glad_glVertexAttribI2ui = (PFNGLVERTEXATTRIBI2UIPROC) load(userptr, "glVertexAttribI2ui"); + glad_glVertexAttribI2uiv = (PFNGLVERTEXATTRIBI2UIVPROC) load(userptr, "glVertexAttribI2uiv"); + glad_glVertexAttribI3i = (PFNGLVERTEXATTRIBI3IPROC) load(userptr, "glVertexAttribI3i"); + glad_glVertexAttribI3iv = (PFNGLVERTEXATTRIBI3IVPROC) load(userptr, "glVertexAttribI3iv"); + glad_glVertexAttribI3ui = (PFNGLVERTEXATTRIBI3UIPROC) load(userptr, "glVertexAttribI3ui"); + glad_glVertexAttribI3uiv = (PFNGLVERTEXATTRIBI3UIVPROC) load(userptr, "glVertexAttribI3uiv"); + glad_glVertexAttribI4bv = (PFNGLVERTEXATTRIBI4BVPROC) load(userptr, "glVertexAttribI4bv"); + glad_glVertexAttribI4i = (PFNGLVERTEXATTRIBI4IPROC) load(userptr, "glVertexAttribI4i"); + glad_glVertexAttribI4iv = (PFNGLVERTEXATTRIBI4IVPROC) load(userptr, "glVertexAttribI4iv"); + glad_glVertexAttribI4sv = (PFNGLVERTEXATTRIBI4SVPROC) load(userptr, "glVertexAttribI4sv"); + glad_glVertexAttribI4ubv = (PFNGLVERTEXATTRIBI4UBVPROC) load(userptr, "glVertexAttribI4ubv"); + glad_glVertexAttribI4ui = (PFNGLVERTEXATTRIBI4UIPROC) load(userptr, "glVertexAttribI4ui"); + glad_glVertexAttribI4uiv = (PFNGLVERTEXATTRIBI4UIVPROC) load(userptr, "glVertexAttribI4uiv"); + glad_glVertexAttribI4usv = (PFNGLVERTEXATTRIBI4USVPROC) load(userptr, "glVertexAttribI4usv"); + glad_glVertexAttribIPointer = (PFNGLVERTEXATTRIBIPOINTERPROC) load(userptr, "glVertexAttribIPointer"); +} +static void glad_gl_load_GL_VERSION_3_1( GLADuserptrloadfunc load, void* userptr) { + if(!GLAD_GL_VERSION_3_1) return; + glad_glBindBufferBase = (PFNGLBINDBUFFERBASEPROC) load(userptr, "glBindBufferBase"); + glad_glBindBufferRange = (PFNGLBINDBUFFERRANGEPROC) load(userptr, "glBindBufferRange"); + glad_glCopyBufferSubData = (PFNGLCOPYBUFFERSUBDATAPROC) load(userptr, "glCopyBufferSubData"); + glad_glDrawArraysInstanced = (PFNGLDRAWARRAYSINSTANCEDPROC) load(userptr, "glDrawArraysInstanced"); + glad_glDrawElementsInstanced = (PFNGLDRAWELEMENTSINSTANCEDPROC) load(userptr, "glDrawElementsInstanced"); + glad_glGetActiveUniformBlockName = (PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC) load(userptr, "glGetActiveUniformBlockName"); + glad_glGetActiveUniformBlockiv = (PFNGLGETACTIVEUNIFORMBLOCKIVPROC) load(userptr, "glGetActiveUniformBlockiv"); + glad_glGetActiveUniformName = (PFNGLGETACTIVEUNIFORMNAMEPROC) load(userptr, "glGetActiveUniformName"); + glad_glGetActiveUniformsiv = (PFNGLGETACTIVEUNIFORMSIVPROC) load(userptr, "glGetActiveUniformsiv"); + glad_glGetIntegeri_v = (PFNGLGETINTEGERI_VPROC) load(userptr, "glGetIntegeri_v"); + glad_glGetUniformBlockIndex = (PFNGLGETUNIFORMBLOCKINDEXPROC) load(userptr, "glGetUniformBlockIndex"); + glad_glGetUniformIndices = (PFNGLGETUNIFORMINDICESPROC) load(userptr, "glGetUniformIndices"); + glad_glPrimitiveRestartIndex = (PFNGLPRIMITIVERESTARTINDEXPROC) load(userptr, "glPrimitiveRestartIndex"); + glad_glTexBuffer = (PFNGLTEXBUFFERPROC) load(userptr, "glTexBuffer"); + glad_glUniformBlockBinding = (PFNGLUNIFORMBLOCKBINDINGPROC) load(userptr, "glUniformBlockBinding"); +} +static void glad_gl_load_GL_VERSION_3_2( GLADuserptrloadfunc load, void* userptr) { + if(!GLAD_GL_VERSION_3_2) return; + glad_glClientWaitSync = (PFNGLCLIENTWAITSYNCPROC) load(userptr, "glClientWaitSync"); + glad_glDeleteSync = (PFNGLDELETESYNCPROC) load(userptr, "glDeleteSync"); + glad_glDrawElementsBaseVertex = (PFNGLDRAWELEMENTSBASEVERTEXPROC) load(userptr, "glDrawElementsBaseVertex"); + glad_glDrawElementsInstancedBaseVertex = (PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC) load(userptr, "glDrawElementsInstancedBaseVertex"); + glad_glDrawRangeElementsBaseVertex = (PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC) load(userptr, "glDrawRangeElementsBaseVertex"); + glad_glFenceSync = (PFNGLFENCESYNCPROC) load(userptr, "glFenceSync"); + glad_glFramebufferTexture = (PFNGLFRAMEBUFFERTEXTUREPROC) load(userptr, "glFramebufferTexture"); + glad_glGetBufferParameteri64v = (PFNGLGETBUFFERPARAMETERI64VPROC) load(userptr, "glGetBufferParameteri64v"); + glad_glGetInteger64i_v = (PFNGLGETINTEGER64I_VPROC) load(userptr, "glGetInteger64i_v"); + glad_glGetInteger64v = (PFNGLGETINTEGER64VPROC) load(userptr, "glGetInteger64v"); + glad_glGetMultisamplefv = (PFNGLGETMULTISAMPLEFVPROC) load(userptr, "glGetMultisamplefv"); + glad_glGetSynciv = (PFNGLGETSYNCIVPROC) load(userptr, "glGetSynciv"); + glad_glIsSync = (PFNGLISSYNCPROC) load(userptr, "glIsSync"); + glad_glMultiDrawElementsBaseVertex = (PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC) load(userptr, "glMultiDrawElementsBaseVertex"); + glad_glProvokingVertex = (PFNGLPROVOKINGVERTEXPROC) load(userptr, "glProvokingVertex"); + glad_glSampleMaski = (PFNGLSAMPLEMASKIPROC) load(userptr, "glSampleMaski"); + glad_glTexImage2DMultisample = (PFNGLTEXIMAGE2DMULTISAMPLEPROC) load(userptr, "glTexImage2DMultisample"); + glad_glTexImage3DMultisample = (PFNGLTEXIMAGE3DMULTISAMPLEPROC) load(userptr, "glTexImage3DMultisample"); + glad_glWaitSync = (PFNGLWAITSYNCPROC) load(userptr, "glWaitSync"); +} +static void glad_gl_load_GL_VERSION_3_3( GLADuserptrloadfunc load, void* userptr) { + if(!GLAD_GL_VERSION_3_3) return; + glad_glBindFragDataLocationIndexed = (PFNGLBINDFRAGDATALOCATIONINDEXEDPROC) load(userptr, "glBindFragDataLocationIndexed"); + glad_glBindSampler = (PFNGLBINDSAMPLERPROC) load(userptr, "glBindSampler"); + glad_glColorP3ui = (PFNGLCOLORP3UIPROC) load(userptr, "glColorP3ui"); + glad_glColorP3uiv = (PFNGLCOLORP3UIVPROC) load(userptr, "glColorP3uiv"); + glad_glColorP4ui = (PFNGLCOLORP4UIPROC) load(userptr, "glColorP4ui"); + glad_glColorP4uiv = (PFNGLCOLORP4UIVPROC) load(userptr, "glColorP4uiv"); + glad_glDeleteSamplers = (PFNGLDELETESAMPLERSPROC) load(userptr, "glDeleteSamplers"); + glad_glGenSamplers = (PFNGLGENSAMPLERSPROC) load(userptr, "glGenSamplers"); + glad_glGetFragDataIndex = (PFNGLGETFRAGDATAINDEXPROC) load(userptr, "glGetFragDataIndex"); + glad_glGetQueryObjecti64v = (PFNGLGETQUERYOBJECTI64VPROC) load(userptr, "glGetQueryObjecti64v"); + glad_glGetQueryObjectui64v = (PFNGLGETQUERYOBJECTUI64VPROC) load(userptr, "glGetQueryObjectui64v"); + glad_glGetSamplerParameterIiv = (PFNGLGETSAMPLERPARAMETERIIVPROC) load(userptr, "glGetSamplerParameterIiv"); + glad_glGetSamplerParameterIuiv = (PFNGLGETSAMPLERPARAMETERIUIVPROC) load(userptr, "glGetSamplerParameterIuiv"); + glad_glGetSamplerParameterfv = (PFNGLGETSAMPLERPARAMETERFVPROC) load(userptr, "glGetSamplerParameterfv"); + glad_glGetSamplerParameteriv = (PFNGLGETSAMPLERPARAMETERIVPROC) load(userptr, "glGetSamplerParameteriv"); + glad_glIsSampler = (PFNGLISSAMPLERPROC) load(userptr, "glIsSampler"); + glad_glMultiTexCoordP1ui = (PFNGLMULTITEXCOORDP1UIPROC) load(userptr, "glMultiTexCoordP1ui"); + glad_glMultiTexCoordP1uiv = (PFNGLMULTITEXCOORDP1UIVPROC) load(userptr, "glMultiTexCoordP1uiv"); + glad_glMultiTexCoordP2ui = (PFNGLMULTITEXCOORDP2UIPROC) load(userptr, "glMultiTexCoordP2ui"); + glad_glMultiTexCoordP2uiv = (PFNGLMULTITEXCOORDP2UIVPROC) load(userptr, "glMultiTexCoordP2uiv"); + glad_glMultiTexCoordP3ui = (PFNGLMULTITEXCOORDP3UIPROC) load(userptr, "glMultiTexCoordP3ui"); + glad_glMultiTexCoordP3uiv = (PFNGLMULTITEXCOORDP3UIVPROC) load(userptr, "glMultiTexCoordP3uiv"); + glad_glMultiTexCoordP4ui = (PFNGLMULTITEXCOORDP4UIPROC) load(userptr, "glMultiTexCoordP4ui"); + glad_glMultiTexCoordP4uiv = (PFNGLMULTITEXCOORDP4UIVPROC) load(userptr, "glMultiTexCoordP4uiv"); + glad_glNormalP3ui = (PFNGLNORMALP3UIPROC) load(userptr, "glNormalP3ui"); + glad_glNormalP3uiv = (PFNGLNORMALP3UIVPROC) load(userptr, "glNormalP3uiv"); + glad_glQueryCounter = (PFNGLQUERYCOUNTERPROC) load(userptr, "glQueryCounter"); + glad_glSamplerParameterIiv = (PFNGLSAMPLERPARAMETERIIVPROC) load(userptr, "glSamplerParameterIiv"); + glad_glSamplerParameterIuiv = (PFNGLSAMPLERPARAMETERIUIVPROC) load(userptr, "glSamplerParameterIuiv"); + glad_glSamplerParameterf = (PFNGLSAMPLERPARAMETERFPROC) load(userptr, "glSamplerParameterf"); + glad_glSamplerParameterfv = (PFNGLSAMPLERPARAMETERFVPROC) load(userptr, "glSamplerParameterfv"); + glad_glSamplerParameteri = (PFNGLSAMPLERPARAMETERIPROC) load(userptr, "glSamplerParameteri"); + glad_glSamplerParameteriv = (PFNGLSAMPLERPARAMETERIVPROC) load(userptr, "glSamplerParameteriv"); + glad_glSecondaryColorP3ui = (PFNGLSECONDARYCOLORP3UIPROC) load(userptr, "glSecondaryColorP3ui"); + glad_glSecondaryColorP3uiv = (PFNGLSECONDARYCOLORP3UIVPROC) load(userptr, "glSecondaryColorP3uiv"); + glad_glTexCoordP1ui = (PFNGLTEXCOORDP1UIPROC) load(userptr, "glTexCoordP1ui"); + glad_glTexCoordP1uiv = (PFNGLTEXCOORDP1UIVPROC) load(userptr, "glTexCoordP1uiv"); + glad_glTexCoordP2ui = (PFNGLTEXCOORDP2UIPROC) load(userptr, "glTexCoordP2ui"); + glad_glTexCoordP2uiv = (PFNGLTEXCOORDP2UIVPROC) load(userptr, "glTexCoordP2uiv"); + glad_glTexCoordP3ui = (PFNGLTEXCOORDP3UIPROC) load(userptr, "glTexCoordP3ui"); + glad_glTexCoordP3uiv = (PFNGLTEXCOORDP3UIVPROC) load(userptr, "glTexCoordP3uiv"); + glad_glTexCoordP4ui = (PFNGLTEXCOORDP4UIPROC) load(userptr, "glTexCoordP4ui"); + glad_glTexCoordP4uiv = (PFNGLTEXCOORDP4UIVPROC) load(userptr, "glTexCoordP4uiv"); + glad_glVertexAttribDivisor = (PFNGLVERTEXATTRIBDIVISORPROC) load(userptr, "glVertexAttribDivisor"); + glad_glVertexAttribP1ui = (PFNGLVERTEXATTRIBP1UIPROC) load(userptr, "glVertexAttribP1ui"); + glad_glVertexAttribP1uiv = (PFNGLVERTEXATTRIBP1UIVPROC) load(userptr, "glVertexAttribP1uiv"); + glad_glVertexAttribP2ui = (PFNGLVERTEXATTRIBP2UIPROC) load(userptr, "glVertexAttribP2ui"); + glad_glVertexAttribP2uiv = (PFNGLVERTEXATTRIBP2UIVPROC) load(userptr, "glVertexAttribP2uiv"); + glad_glVertexAttribP3ui = (PFNGLVERTEXATTRIBP3UIPROC) load(userptr, "glVertexAttribP3ui"); + glad_glVertexAttribP3uiv = (PFNGLVERTEXATTRIBP3UIVPROC) load(userptr, "glVertexAttribP3uiv"); + glad_glVertexAttribP4ui = (PFNGLVERTEXATTRIBP4UIPROC) load(userptr, "glVertexAttribP4ui"); + glad_glVertexAttribP4uiv = (PFNGLVERTEXATTRIBP4UIVPROC) load(userptr, "glVertexAttribP4uiv"); + glad_glVertexP2ui = (PFNGLVERTEXP2UIPROC) load(userptr, "glVertexP2ui"); + glad_glVertexP2uiv = (PFNGLVERTEXP2UIVPROC) load(userptr, "glVertexP2uiv"); + glad_glVertexP3ui = (PFNGLVERTEXP3UIPROC) load(userptr, "glVertexP3ui"); + glad_glVertexP3uiv = (PFNGLVERTEXP3UIVPROC) load(userptr, "glVertexP3uiv"); + glad_glVertexP4ui = (PFNGLVERTEXP4UIPROC) load(userptr, "glVertexP4ui"); + glad_glVertexP4uiv = (PFNGLVERTEXP4UIVPROC) load(userptr, "glVertexP4uiv"); +} +static void glad_gl_load_GL_ARB_multisample( GLADuserptrloadfunc load, void* userptr) { + if(!GLAD_GL_ARB_multisample) return; + glad_glSampleCoverageARB = (PFNGLSAMPLECOVERAGEARBPROC) load(userptr, "glSampleCoverageARB"); +} +static void glad_gl_load_GL_ARB_robustness( GLADuserptrloadfunc load, void* userptr) { + if(!GLAD_GL_ARB_robustness) return; + glad_glGetGraphicsResetStatusARB = (PFNGLGETGRAPHICSRESETSTATUSARBPROC) load(userptr, "glGetGraphicsResetStatusARB"); + glad_glGetnColorTableARB = (PFNGLGETNCOLORTABLEARBPROC) load(userptr, "glGetnColorTableARB"); + glad_glGetnCompressedTexImageARB = (PFNGLGETNCOMPRESSEDTEXIMAGEARBPROC) load(userptr, "glGetnCompressedTexImageARB"); + glad_glGetnConvolutionFilterARB = (PFNGLGETNCONVOLUTIONFILTERARBPROC) load(userptr, "glGetnConvolutionFilterARB"); + glad_glGetnHistogramARB = (PFNGLGETNHISTOGRAMARBPROC) load(userptr, "glGetnHistogramARB"); + glad_glGetnMapdvARB = (PFNGLGETNMAPDVARBPROC) load(userptr, "glGetnMapdvARB"); + glad_glGetnMapfvARB = (PFNGLGETNMAPFVARBPROC) load(userptr, "glGetnMapfvARB"); + glad_glGetnMapivARB = (PFNGLGETNMAPIVARBPROC) load(userptr, "glGetnMapivARB"); + glad_glGetnMinmaxARB = (PFNGLGETNMINMAXARBPROC) load(userptr, "glGetnMinmaxARB"); + glad_glGetnPixelMapfvARB = (PFNGLGETNPIXELMAPFVARBPROC) load(userptr, "glGetnPixelMapfvARB"); + glad_glGetnPixelMapuivARB = (PFNGLGETNPIXELMAPUIVARBPROC) load(userptr, "glGetnPixelMapuivARB"); + glad_glGetnPixelMapusvARB = (PFNGLGETNPIXELMAPUSVARBPROC) load(userptr, "glGetnPixelMapusvARB"); + glad_glGetnPolygonStippleARB = (PFNGLGETNPOLYGONSTIPPLEARBPROC) load(userptr, "glGetnPolygonStippleARB"); + glad_glGetnSeparableFilterARB = (PFNGLGETNSEPARABLEFILTERARBPROC) load(userptr, "glGetnSeparableFilterARB"); + glad_glGetnTexImageARB = (PFNGLGETNTEXIMAGEARBPROC) load(userptr, "glGetnTexImageARB"); + glad_glGetnUniformdvARB = (PFNGLGETNUNIFORMDVARBPROC) load(userptr, "glGetnUniformdvARB"); + glad_glGetnUniformfvARB = (PFNGLGETNUNIFORMFVARBPROC) load(userptr, "glGetnUniformfvARB"); + glad_glGetnUniformivARB = (PFNGLGETNUNIFORMIVARBPROC) load(userptr, "glGetnUniformivARB"); + glad_glGetnUniformuivARB = (PFNGLGETNUNIFORMUIVARBPROC) load(userptr, "glGetnUniformuivARB"); + glad_glReadnPixelsARB = (PFNGLREADNPIXELSARBPROC) load(userptr, "glReadnPixelsARB"); +} +static void glad_gl_load_GL_KHR_debug( GLADuserptrloadfunc load, void* userptr) { + if(!GLAD_GL_KHR_debug) return; + glad_glDebugMessageCallback = (PFNGLDEBUGMESSAGECALLBACKPROC) load(userptr, "glDebugMessageCallback"); + glad_glDebugMessageControl = (PFNGLDEBUGMESSAGECONTROLPROC) load(userptr, "glDebugMessageControl"); + glad_glDebugMessageInsert = (PFNGLDEBUGMESSAGEINSERTPROC) load(userptr, "glDebugMessageInsert"); + glad_glGetDebugMessageLog = (PFNGLGETDEBUGMESSAGELOGPROC) load(userptr, "glGetDebugMessageLog"); + glad_glGetObjectLabel = (PFNGLGETOBJECTLABELPROC) load(userptr, "glGetObjectLabel"); + glad_glGetObjectPtrLabel = (PFNGLGETOBJECTPTRLABELPROC) load(userptr, "glGetObjectPtrLabel"); + glad_glGetPointerv = (PFNGLGETPOINTERVPROC) load(userptr, "glGetPointerv"); + glad_glObjectLabel = (PFNGLOBJECTLABELPROC) load(userptr, "glObjectLabel"); + glad_glObjectPtrLabel = (PFNGLOBJECTPTRLABELPROC) load(userptr, "glObjectPtrLabel"); + glad_glPopDebugGroup = (PFNGLPOPDEBUGGROUPPROC) load(userptr, "glPopDebugGroup"); + glad_glPushDebugGroup = (PFNGLPUSHDEBUGGROUPPROC) load(userptr, "glPushDebugGroup"); +} + + + +#if defined(GL_ES_VERSION_3_0) || defined(GL_VERSION_3_0) +#define GLAD_GL_IS_SOME_NEW_VERSION 1 +#else +#define GLAD_GL_IS_SOME_NEW_VERSION 0 +#endif + +static int glad_gl_get_extensions( int version, const char **out_exts, unsigned int *out_num_exts_i, char ***out_exts_i) { +#if GLAD_GL_IS_SOME_NEW_VERSION + if(GLAD_VERSION_MAJOR(version) < 3) { +#else + (void) version; + (void) out_num_exts_i; + (void) out_exts_i; +#endif + if (glad_glGetString == NULL) { + return 0; + } + *out_exts = (const char *)glad_glGetString(GL_EXTENSIONS); +#if GLAD_GL_IS_SOME_NEW_VERSION + } else { + unsigned int index = 0; + unsigned int num_exts_i = 0; + char **exts_i = NULL; + if (glad_glGetStringi == NULL || glad_glGetIntegerv == NULL) { + return 0; + } + glad_glGetIntegerv(GL_NUM_EXTENSIONS, (int*) &num_exts_i); + if (num_exts_i > 0) { + exts_i = (char **) malloc(num_exts_i * (sizeof *exts_i)); + } + if (exts_i == NULL) { + return 0; + } + for(index = 0; index < num_exts_i; index++) { + const char *gl_str_tmp = (const char*) glad_glGetStringi(GL_EXTENSIONS, index); + size_t len = strlen(gl_str_tmp) + 1; + + char *local_str = (char*) malloc(len * sizeof(char)); + if(local_str != NULL) { + memcpy(local_str, gl_str_tmp, len * sizeof(char)); + } + + exts_i[index] = local_str; + } + + *out_num_exts_i = num_exts_i; + *out_exts_i = exts_i; + } +#endif + return 1; +} +static void glad_gl_free_extensions(char **exts_i, unsigned int num_exts_i) { + if (exts_i != NULL) { + unsigned int index; + for(index = 0; index < num_exts_i; index++) { + free((void *) (exts_i[index])); + } + free((void *)exts_i); + exts_i = NULL; + } +} +static int glad_gl_has_extension(int version, const char *exts, unsigned int num_exts_i, char **exts_i, const char *ext) { + if(GLAD_VERSION_MAJOR(version) < 3 || !GLAD_GL_IS_SOME_NEW_VERSION) { + const char *extensions; + const char *loc; + const char *terminator; + extensions = exts; + if(extensions == NULL || ext == NULL) { + return 0; + } + while(1) { + loc = strstr(extensions, ext); + if(loc == NULL) { + return 0; + } + terminator = loc + strlen(ext); + if((loc == extensions || *(loc - 1) == ' ') && + (*terminator == ' ' || *terminator == '\0')) { + return 1; + } + extensions = terminator; + } + } else { + unsigned int index; + for(index = 0; index < num_exts_i; index++) { + const char *e = exts_i[index]; + if(strcmp(e, ext) == 0) { + return 1; + } + } + } + return 0; +} + +static GLADapiproc glad_gl_get_proc_from_userptr(void *userptr, const char* name) { + return (GLAD_GNUC_EXTENSION (GLADapiproc (*)(const char *name)) userptr)(name); +} + +static int glad_gl_find_extensions_gl( int version) { + const char *exts = NULL; + unsigned int num_exts_i = 0; + char **exts_i = NULL; + if (!glad_gl_get_extensions(version, &exts, &num_exts_i, &exts_i)) return 0; + + GLAD_GL_ARB_multisample = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_multisample"); + GLAD_GL_ARB_robustness = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_robustness"); + GLAD_GL_KHR_debug = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_KHR_debug"); + + glad_gl_free_extensions(exts_i, num_exts_i); + + return 1; +} + +static int glad_gl_find_core_gl(void) { + int i; + const char* version; + const char* prefixes[] = { + "OpenGL ES-CM ", + "OpenGL ES-CL ", + "OpenGL ES ", + "OpenGL SC ", + NULL + }; + int major = 0; + int minor = 0; + version = (const char*) glad_glGetString(GL_VERSION); + if (!version) return 0; + for (i = 0; prefixes[i]; i++) { + const size_t length = strlen(prefixes[i]); + if (strncmp(version, prefixes[i], length) == 0) { + version += length; + break; + } + } + + GLAD_IMPL_UTIL_SSCANF(version, "%d.%d", &major, &minor); + + GLAD_GL_VERSION_1_0 = (major == 1 && minor >= 0) || major > 1; + GLAD_GL_VERSION_1_1 = (major == 1 && minor >= 1) || major > 1; + GLAD_GL_VERSION_1_2 = (major == 1 && minor >= 2) || major > 1; + GLAD_GL_VERSION_1_3 = (major == 1 && minor >= 3) || major > 1; + GLAD_GL_VERSION_1_4 = (major == 1 && minor >= 4) || major > 1; + GLAD_GL_VERSION_1_5 = (major == 1 && minor >= 5) || major > 1; + GLAD_GL_VERSION_2_0 = (major == 2 && minor >= 0) || major > 2; + GLAD_GL_VERSION_2_1 = (major == 2 && minor >= 1) || major > 2; + GLAD_GL_VERSION_3_0 = (major == 3 && minor >= 0) || major > 3; + GLAD_GL_VERSION_3_1 = (major == 3 && minor >= 1) || major > 3; + GLAD_GL_VERSION_3_2 = (major == 3 && minor >= 2) || major > 3; + GLAD_GL_VERSION_3_3 = (major == 3 && minor >= 3) || major > 3; + + return GLAD_MAKE_VERSION(major, minor); +} + +int gladLoadGLUserPtr( GLADuserptrloadfunc load, void *userptr) { + int version; + + glad_glGetString = (PFNGLGETSTRINGPROC) load(userptr, "glGetString"); + if(glad_glGetString == NULL) return 0; + if(glad_glGetString(GL_VERSION) == NULL) return 0; + version = glad_gl_find_core_gl(); + + glad_gl_load_GL_VERSION_1_0(load, userptr); + glad_gl_load_GL_VERSION_1_1(load, userptr); + glad_gl_load_GL_VERSION_1_2(load, userptr); + glad_gl_load_GL_VERSION_1_3(load, userptr); + glad_gl_load_GL_VERSION_1_4(load, userptr); + glad_gl_load_GL_VERSION_1_5(load, userptr); + glad_gl_load_GL_VERSION_2_0(load, userptr); + glad_gl_load_GL_VERSION_2_1(load, userptr); + glad_gl_load_GL_VERSION_3_0(load, userptr); + glad_gl_load_GL_VERSION_3_1(load, userptr); + glad_gl_load_GL_VERSION_3_2(load, userptr); + glad_gl_load_GL_VERSION_3_3(load, userptr); + + if (!glad_gl_find_extensions_gl(version)) return 0; + glad_gl_load_GL_ARB_multisample(load, userptr); + glad_gl_load_GL_ARB_robustness(load, userptr); + glad_gl_load_GL_KHR_debug(load, userptr); + + + + return version; +} + + +int gladLoadGL( GLADloadfunc load) { + return gladLoadGLUserPtr( glad_gl_get_proc_from_userptr, GLAD_GNUC_EXTENSION (void*) load); +} + + + + + + +#ifdef __cplusplus +} +#endif + +#endif /* GLAD_GL_IMPLEMENTATION */ + diff --git a/deps/glad/khrplatform.h b/deps/glad/khrplatform.h deleted file mode 100644 index 975bbffe..00000000 --- a/deps/glad/khrplatform.h +++ /dev/null @@ -1,282 +0,0 @@ -#ifndef __khrplatform_h_ -#define __khrplatform_h_ - -/* -** Copyright (c) 2008-2018 The Khronos Group Inc. -** -** Permission is hereby granted, free of charge, to any person obtaining a -** copy of this software and/or associated documentation files (the -** "Materials"), to deal in the Materials without restriction, including -** without limitation the rights to use, copy, modify, merge, publish, -** distribute, sublicense, and/or sell copies of the Materials, and to -** permit persons to whom the Materials are furnished to do so, subject to -** the following conditions: -** -** The above copyright notice and this permission notice shall be included -** in all copies or substantial portions of the Materials. -** -** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. -*/ - -/* Khronos platform-specific types and definitions. - * - * The master copy of khrplatform.h is maintained in the Khronos EGL - * Registry repository at https://github.com/KhronosGroup/EGL-Registry - * The last semantic modification to khrplatform.h was at commit ID: - * 67a3e0864c2d75ea5287b9f3d2eb74a745936692 - * - * Adopters may modify this file to suit their platform. Adopters are - * encouraged to submit platform specific modifications to the Khronos - * group so that they can be included in future versions of this file. - * Please submit changes by filing pull requests or issues on - * the EGL Registry repository linked above. - * - * - * See the Implementer's Guidelines for information about where this file - * should be located on your system and for more details of its use: - * http://www.khronos.org/registry/implementers_guide.pdf - * - * This file should be included as - * #include - * by Khronos client API header files that use its types and defines. - * - * The types in khrplatform.h should only be used to define API-specific types. - * - * Types defined in khrplatform.h: - * khronos_int8_t signed 8 bit - * khronos_uint8_t unsigned 8 bit - * khronos_int16_t signed 16 bit - * khronos_uint16_t unsigned 16 bit - * khronos_int32_t signed 32 bit - * khronos_uint32_t unsigned 32 bit - * khronos_int64_t signed 64 bit - * khronos_uint64_t unsigned 64 bit - * khronos_intptr_t signed same number of bits as a pointer - * khronos_uintptr_t unsigned same number of bits as a pointer - * khronos_ssize_t signed size - * khronos_usize_t unsigned size - * khronos_float_t signed 32 bit floating point - * khronos_time_ns_t unsigned 64 bit time in nanoseconds - * khronos_utime_nanoseconds_t unsigned time interval or absolute time in - * nanoseconds - * khronos_stime_nanoseconds_t signed time interval in nanoseconds - * khronos_boolean_enum_t enumerated boolean type. This should - * only be used as a base type when a client API's boolean type is - * an enum. Client APIs which use an integer or other type for - * booleans cannot use this as the base type for their boolean. - * - * Tokens defined in khrplatform.h: - * - * KHRONOS_FALSE, KHRONOS_TRUE Enumerated boolean false/true values. - * - * KHRONOS_SUPPORT_INT64 is 1 if 64 bit integers are supported; otherwise 0. - * KHRONOS_SUPPORT_FLOAT is 1 if floats are supported; otherwise 0. - * - * Calling convention macros defined in this file: - * KHRONOS_APICALL - * KHRONOS_APIENTRY - * KHRONOS_APIATTRIBUTES - * - * These may be used in function prototypes as: - * - * KHRONOS_APICALL void KHRONOS_APIENTRY funcname( - * int arg1, - * int arg2) KHRONOS_APIATTRIBUTES; - */ - -/*------------------------------------------------------------------------- - * Definition of KHRONOS_APICALL - *------------------------------------------------------------------------- - * This precedes the return type of the function in the function prototype. - */ -#if defined(_WIN32) && !defined(__SCITECH_SNAP__) -# define KHRONOS_APICALL __declspec(dllimport) -#elif defined (__SYMBIAN32__) -# define KHRONOS_APICALL IMPORT_C -#elif defined(__ANDROID__) -# define KHRONOS_APICALL __attribute__((visibility("default"))) -#else -# define KHRONOS_APICALL -#endif - -/*------------------------------------------------------------------------- - * Definition of KHRONOS_APIENTRY - *------------------------------------------------------------------------- - * This follows the return type of the function and precedes the function - * name in the function prototype. - */ -#if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(__SCITECH_SNAP__) - /* Win32 but not WinCE */ -# define KHRONOS_APIENTRY __stdcall -#else -# define KHRONOS_APIENTRY -#endif - -/*------------------------------------------------------------------------- - * Definition of KHRONOS_APIATTRIBUTES - *------------------------------------------------------------------------- - * This follows the closing parenthesis of the function prototype arguments. - */ -#if defined (__ARMCC_2__) -#define KHRONOS_APIATTRIBUTES __softfp -#else -#define KHRONOS_APIATTRIBUTES -#endif - -/*------------------------------------------------------------------------- - * basic type definitions - *-----------------------------------------------------------------------*/ -#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__GNUC__) || defined(__SCO__) || defined(__USLC__) - - -/* - * Using - */ -#include -typedef int32_t khronos_int32_t; -typedef uint32_t khronos_uint32_t; -typedef int64_t khronos_int64_t; -typedef uint64_t khronos_uint64_t; -#define KHRONOS_SUPPORT_INT64 1 -#define KHRONOS_SUPPORT_FLOAT 1 - -#elif defined(__VMS ) || defined(__sgi) - -/* - * Using - */ -#include -typedef int32_t khronos_int32_t; -typedef uint32_t khronos_uint32_t; -typedef int64_t khronos_int64_t; -typedef uint64_t khronos_uint64_t; -#define KHRONOS_SUPPORT_INT64 1 -#define KHRONOS_SUPPORT_FLOAT 1 - -#elif defined(_WIN32) && !defined(__SCITECH_SNAP__) - -/* - * Win32 - */ -typedef __int32 khronos_int32_t; -typedef unsigned __int32 khronos_uint32_t; -typedef __int64 khronos_int64_t; -typedef unsigned __int64 khronos_uint64_t; -#define KHRONOS_SUPPORT_INT64 1 -#define KHRONOS_SUPPORT_FLOAT 1 - -#elif defined(__sun__) || defined(__digital__) - -/* - * Sun or Digital - */ -typedef int khronos_int32_t; -typedef unsigned int khronos_uint32_t; -#if defined(__arch64__) || defined(_LP64) -typedef long int khronos_int64_t; -typedef unsigned long int khronos_uint64_t; -#else -typedef long long int khronos_int64_t; -typedef unsigned long long int khronos_uint64_t; -#endif /* __arch64__ */ -#define KHRONOS_SUPPORT_INT64 1 -#define KHRONOS_SUPPORT_FLOAT 1 - -#elif 0 - -/* - * Hypothetical platform with no float or int64 support - */ -typedef int khronos_int32_t; -typedef unsigned int khronos_uint32_t; -#define KHRONOS_SUPPORT_INT64 0 -#define KHRONOS_SUPPORT_FLOAT 0 - -#else - -/* - * Generic fallback - */ -#include -typedef int32_t khronos_int32_t; -typedef uint32_t khronos_uint32_t; -typedef int64_t khronos_int64_t; -typedef uint64_t khronos_uint64_t; -#define KHRONOS_SUPPORT_INT64 1 -#define KHRONOS_SUPPORT_FLOAT 1 - -#endif - - -/* - * Types that are (so far) the same on all platforms - */ -typedef signed char khronos_int8_t; -typedef unsigned char khronos_uint8_t; -typedef signed short int khronos_int16_t; -typedef unsigned short int khronos_uint16_t; - -/* - * Types that differ between LLP64 and LP64 architectures - in LLP64, - * pointers are 64 bits, but 'long' is still 32 bits. Win64 appears - * to be the only LLP64 architecture in current use. - */ -#ifdef _WIN64 -typedef signed long long int khronos_intptr_t; -typedef unsigned long long int khronos_uintptr_t; -typedef signed long long int khronos_ssize_t; -typedef unsigned long long int khronos_usize_t; -#else -typedef signed long int khronos_intptr_t; -typedef unsigned long int khronos_uintptr_t; -typedef signed long int khronos_ssize_t; -typedef unsigned long int khronos_usize_t; -#endif - -#if KHRONOS_SUPPORT_FLOAT -/* - * Float type - */ -typedef float khronos_float_t; -#endif - -#if KHRONOS_SUPPORT_INT64 -/* Time types - * - * These types can be used to represent a time interval in nanoseconds or - * an absolute Unadjusted System Time. Unadjusted System Time is the number - * of nanoseconds since some arbitrary system event (e.g. since the last - * time the system booted). The Unadjusted System Time is an unsigned - * 64 bit value that wraps back to 0 every 584 years. Time intervals - * may be either signed or unsigned. - */ -typedef khronos_uint64_t khronos_utime_nanoseconds_t; -typedef khronos_int64_t khronos_stime_nanoseconds_t; -#endif - -/* - * Dummy value used to pad enum types to 32 bits. - */ -#ifndef KHRONOS_MAX_ENUM -#define KHRONOS_MAX_ENUM 0x7FFFFFFF -#endif - -/* - * Enumerated boolean type - * - * Values other than zero should be considered to be true. Therefore - * comparisons should not be made against KHRONOS_TRUE. - */ -typedef enum { - KHRONOS_FALSE = 0, - KHRONOS_TRUE = 1, - KHRONOS_BOOLEAN_ENUM_FORCE_SIZE = KHRONOS_MAX_ENUM -} khronos_boolean_enum_t; - -#endif /* __khrplatform_h_ */ diff --git a/deps/glad/vk_platform.h b/deps/glad/vk_platform.h deleted file mode 100644 index d7d22e1e..00000000 --- a/deps/glad/vk_platform.h +++ /dev/null @@ -1,92 +0,0 @@ -/* */ -/* File: vk_platform.h */ -/* */ -/* -** Copyright (c) 2014-2017 The Khronos Group Inc. -** -** Licensed under the Apache License, Version 2.0 (the "License"); -** you may not use this file except in compliance with the License. -** You may obtain a copy of the License at -** -** http://www.apache.org/licenses/LICENSE-2.0 -** -** Unless required by applicable law or agreed to in writing, software -** distributed under the License is distributed on an "AS IS" BASIS, -** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -** See the License for the specific language governing permissions and -** limitations under the License. -*/ - - -#ifndef VK_PLATFORM_H_ -#define VK_PLATFORM_H_ - -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ - -/* -*************************************************************************************************** -* Platform-specific directives and type declarations -*************************************************************************************************** -*/ - -/* Platform-specific calling convention macros. - * - * Platforms should define these so that Vulkan clients call Vulkan commands - * with the same calling conventions that the Vulkan implementation expects. - * - * VKAPI_ATTR - Placed before the return type in function declarations. - * Useful for C++11 and GCC/Clang-style function attribute syntax. - * VKAPI_CALL - Placed after the return type in function declarations. - * Useful for MSVC-style calling convention syntax. - * VKAPI_PTR - Placed between the '(' and '*' in function pointer types. - * - * Function declaration: VKAPI_ATTR void VKAPI_CALL vkCommand(void); - * Function pointer type: typedef void (VKAPI_PTR *PFN_vkCommand)(void); - */ -#if defined(_WIN32) - /* On Windows, Vulkan commands use the stdcall convention */ - #define VKAPI_ATTR - #define VKAPI_CALL __stdcall - #define VKAPI_PTR VKAPI_CALL -#elif defined(__ANDROID__) && defined(__ARM_ARCH) && __ARM_ARCH < 7 - #error "Vulkan isn't supported for the 'armeabi' NDK ABI" -#elif defined(__ANDROID__) && defined(__ARM_ARCH) && __ARM_ARCH >= 7 && defined(__ARM_32BIT_STATE) - /* On Android 32-bit ARM targets, Vulkan functions use the "hardfloat" */ - /* calling convention, i.e. float parameters are passed in registers. This */ - /* is true even if the rest of the application passes floats on the stack, */ - /* as it does by default when compiling for the armeabi-v7a NDK ABI. */ - #define VKAPI_ATTR __attribute__((pcs("aapcs-vfp"))) - #define VKAPI_CALL - #define VKAPI_PTR VKAPI_ATTR -#else - /* On other platforms, use the default calling convention */ - #define VKAPI_ATTR - #define VKAPI_CALL - #define VKAPI_PTR -#endif - -#include - -#if !defined(VK_NO_STDINT_H) - #if defined(_MSC_VER) && (_MSC_VER < 1600) - typedef signed __int8 int8_t; - typedef unsigned __int8 uint8_t; - typedef signed __int16 int16_t; - typedef unsigned __int16 uint16_t; - typedef signed __int32 int32_t; - typedef unsigned __int32 uint32_t; - typedef signed __int64 int64_t; - typedef unsigned __int64 uint64_t; - #else - #include - #endif -#endif /* !defined(VK_NO_STDINT_H) */ - -#ifdef __cplusplus -} /* extern "C" */ -#endif /* __cplusplus */ - -#endif diff --git a/deps/glad/vulkan.h b/deps/glad/vulkan.h index 6bace71d..9e78dad9 100644 --- a/deps/glad/vulkan.h +++ b/deps/glad/vulkan.h @@ -1,5 +1,5 @@ /** - * Loader generated by glad 2.0.0-beta on Sun Apr 14 17:03:38 2019 + * Loader generated by glad 2.0.0-beta on Wed Aug 25 21:20:29 2021 * * Generator: C/C++ * Specification: vk @@ -9,18 +9,19 @@ * - vulkan=1.1 * * Options: - * - MX_GLOBAL = False - * - LOADER = False * - ALIAS = False - * - HEADER_ONLY = False * - DEBUG = False + * - HEADER_ONLY = True + * - LOADER = False * - MX = False + * - MX_GLOBAL = False + * - ON_DEMAND = False * * Commandline: - * --api='vulkan=1.1' --extensions='VK_EXT_debug_report,VK_KHR_surface,VK_KHR_swapchain' c + * --api='vulkan=1.1' --extensions='VK_EXT_debug_report,VK_KHR_surface,VK_KHR_swapchain' c --header-only * * Online: - * http://glad.sh/#api=vulkan%3D1.1&extensions=VK_EXT_debug_report%2CVK_KHR_surface%2CVK_KHR_swapchain&generator=c&options= + * http://glad.sh/#api=vulkan%3D1.1&extensions=VK_EXT_debug_report%2CVK_KHR_surface%2CVK_KHR_swapchain&generator=c&options=HEADER_ONLY * */ @@ -28,17 +29,18 @@ #define GLAD_VULKAN_H_ #ifdef VULKAN_H_ - #error header already included (API: vulkan), remove previous include! + #error header already included (API: vulkan), remove previous include! #endif #define VULKAN_H_ 1 #ifdef VULKAN_CORE_H_ - #error header already included (API: vulkan), remove previous include! + #error header already included (API: vulkan), remove previous include! #endif #define VULKAN_CORE_H_ 1 #define GLAD_VULKAN +#define GLAD_OPTION_VULKAN_HEADER_ONLY #ifdef __cplusplus extern "C" { @@ -142,15 +144,16 @@ extern "C" { #define GLAPIENTRY GLAD_API_PTR #endif - #define GLAD_MAKE_VERSION(major, minor) (major * 10000 + minor) #define GLAD_VERSION_MAJOR(version) (version / 10000) #define GLAD_VERSION_MINOR(version) (version % 10000) +#define GLAD_GENERATOR_VERSION "2.0.0-beta" + typedef void (*GLADapiproc)(void); typedef GLADapiproc (*GLADloadfunc)(const char *name); -typedef GLADapiproc (*GLADuserptrloadfunc)(const char *name, void *userptr); +typedef GLADapiproc (*GLADuserptrloadfunc)(void *userptr, const char *name); typedef void (*GLADprecallback)(const char *name, GLADapiproc apiproc, int len_args, ...); typedef void (*GLADpostcallback)(void *ret, const char *name, GLADapiproc apiproc, int len_args, ...); @@ -183,21 +186,115 @@ typedef void (*GLADpostcallback)(void *ret, const char *name, GLADapiproc apipro #define VK_WHOLE_SIZE (~0ULL) -#include +/* */ +/* File: vk_platform.h */ +/* */ +/* +** Copyright (c) 2014-2020 The Khronos Group Inc. +** +** SPDX-License-Identifier: Apache-2.0 +*/ + + +#ifndef VK_PLATFORM_H_ +#define VK_PLATFORM_H_ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +/* +*************************************************************************************************** +* Platform-specific directives and type declarations +*************************************************************************************************** +*/ + +/* Platform-specific calling convention macros. + * + * Platforms should define these so that Vulkan clients call Vulkan commands + * with the same calling conventions that the Vulkan implementation expects. + * + * VKAPI_ATTR - Placed before the return type in function declarations. + * Useful for C++11 and GCC/Clang-style function attribute syntax. + * VKAPI_CALL - Placed after the return type in function declarations. + * Useful for MSVC-style calling convention syntax. + * VKAPI_PTR - Placed between the '(' and '*' in function pointer types. + * + * Function declaration: VKAPI_ATTR void VKAPI_CALL vkCommand(void); + * Function pointer type: typedef void (VKAPI_PTR *PFN_vkCommand)(void); + */ +#if defined(_WIN32) + /* On Windows, Vulkan commands use the stdcall convention */ + #define VKAPI_ATTR + #define VKAPI_CALL __stdcall + #define VKAPI_PTR VKAPI_CALL +#elif defined(__ANDROID__) && defined(__ARM_ARCH) && __ARM_ARCH < 7 + #error "Vulkan isn't supported for the 'armeabi' NDK ABI" +#elif defined(__ANDROID__) && defined(__ARM_ARCH) && __ARM_ARCH >= 7 && defined(__ARM_32BIT_STATE) + /* On Android 32-bit ARM targets, Vulkan functions use the "hardfloat" */ + /* calling convention, i.e. float parameters are passed in registers. This */ + /* is true even if the rest of the application passes floats on the stack, */ + /* as it does by default when compiling for the armeabi-v7a NDK ABI. */ + #define VKAPI_ATTR __attribute__((pcs("aapcs-vfp"))) + #define VKAPI_CALL + #define VKAPI_PTR VKAPI_ATTR +#else + /* On other platforms, use the default calling convention */ + #define VKAPI_ATTR + #define VKAPI_CALL + #define VKAPI_PTR +#endif + +#include + +#if !defined(VK_NO_STDINT_H) + #if defined(_MSC_VER) && (_MSC_VER < 1600) + typedef signed __int8 int8_t; + typedef unsigned __int8 uint8_t; + typedef signed __int16 int16_t; + typedef unsigned __int16 uint16_t; + typedef signed __int32 int32_t; + typedef unsigned __int32 uint32_t; + typedef signed __int64 int64_t; + typedef unsigned __int64 uint64_t; + #else + #include + #endif +#endif /* !defined(VK_NO_STDINT_H) */ + +#ifdef __cplusplus +} /* extern "C" */ +#endif /* __cplusplus */ + +#endif + #define VK_MAKE_VERSION(major, minor, patch) \ - (((major) << 22) | ((minor) << 12) | (patch)) + ((((uint32_t)(major)) << 22) | (((uint32_t)(minor)) << 12) | ((uint32_t)(patch))) + #define VK_VERSION_MAJOR(version) ((uint32_t)(version) >> 22) + #define VK_VERSION_MINOR(version) (((uint32_t)(version) >> 12) & 0x3ff) + #define VK_VERSION_PATCH(version) ((uint32_t)(version) & 0xfff) + /* DEPRECATED: This define has been removed. Specific version defines (e.g. VK_API_VERSION_1_0), or the VK_MAKE_VERSION macro, should be used instead. */ /*#define VK_API_VERSION VK_MAKE_VERSION(1, 0, 0) // Patch version should always be set to 0 */ + /* Vulkan 1.0 version number */ #define VK_API_VERSION_1_0 VK_MAKE_VERSION(1, 0, 0)/* Patch version should always be set to 0 */ + /* Vulkan 1.1 version number */ #define VK_API_VERSION_1_1 VK_MAKE_VERSION(1, 1, 0)/* Patch version should always be set to 0 */ + /* Version of this file */ -#define VK_HEADER_VERSION 106 +#define VK_HEADER_VERSION 152 + +/* Complete version of this file */ +#define VK_HEADER_VERSION_COMPLETE VK_MAKE_VERSION(1, 2, VK_HEADER_VERSION) + #define VK_DEFINE_HANDLE(object) typedef struct object##_T* object; + #if !defined(VK_DEFINE_NON_DISPATCHABLE_HANDLE) #if defined(__LP64__) || defined(_WIN64) || (defined(__x86_64__) && !defined(__ILP32__) ) || defined(_M_X64) || defined(__ia64) || defined (_M_IA64) || defined(__aarch64__) || defined(__powerpc64__) #define VK_DEFINE_NON_DISPATCHABLE_HANDLE(object) typedef struct object##_T *object; @@ -205,6 +302,7 @@ typedef void (*GLADpostcallback)(void *ret, const char *name, GLADapiproc apipro #define VK_DEFINE_NON_DISPATCHABLE_HANDLE(object) typedef uint64_t object; #endif #endif + #define VK_NULL_HANDLE 0 @@ -214,45 +312,78 @@ typedef void (*GLADpostcallback)(void *ret, const char *name, GLADapiproc apipro + VK_DEFINE_HANDLE(VkInstance) + VK_DEFINE_HANDLE(VkPhysicalDevice) + VK_DEFINE_HANDLE(VkDevice) + VK_DEFINE_HANDLE(VkQueue) + VK_DEFINE_HANDLE(VkCommandBuffer) + VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkDeviceMemory) + VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkCommandPool) + VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkBuffer) + VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkBufferView) + VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkImage) + VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkImageView) + VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkShaderModule) + VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkPipeline) + VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkPipelineLayout) + VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkSampler) + VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkDescriptorSet) + VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkDescriptorSetLayout) + VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkDescriptorPool) + VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkFence) + VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkSemaphore) + VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkEvent) + VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkQueryPool) + VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkFramebuffer) + VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkRenderPass) + VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkPipelineCache) + VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkDescriptorUpdateTemplate) + VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkSamplerYcbcrConversion) + VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkSurfaceKHR) + VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkSwapchainKHR) + VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkDebugReportCallbackEXT) + typedef enum VkAttachmentLoadOp { VK_ATTACHMENT_LOAD_OP_LOAD = 0, VK_ATTACHMENT_LOAD_OP_CLEAR = 1, VK_ATTACHMENT_LOAD_OP_DONT_CARE = 2 } VkAttachmentLoadOp; + typedef enum VkAttachmentStoreOp { VK_ATTACHMENT_STORE_OP_STORE = 0, VK_ATTACHMENT_STORE_OP_DONT_CARE = 1 } VkAttachmentStoreOp; + typedef enum VkBlendFactor { VK_BLEND_FACTOR_ZERO = 0, VK_BLEND_FACTOR_ONE = 1, @@ -274,6 +405,7 @@ typedef enum VkBlendFactor { VK_BLEND_FACTOR_SRC1_ALPHA = 17, VK_BLEND_FACTOR_ONE_MINUS_SRC1_ALPHA = 18 } VkBlendFactor; + typedef enum VkBlendOp { VK_BLEND_OP_ADD = 0, VK_BLEND_OP_SUBTRACT = 1, @@ -281,6 +413,7 @@ typedef enum VkBlendOp { VK_BLEND_OP_MIN = 3, VK_BLEND_OP_MAX = 4 } VkBlendOp; + typedef enum VkBorderColor { VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK = 0, VK_BORDER_COLOR_INT_TRANSPARENT_BLACK = 1, @@ -290,19 +423,27 @@ typedef enum VkBorderColor { VK_BORDER_COLOR_INT_OPAQUE_WHITE = 5 } VkBorderColor; + + + typedef enum VkPipelineCacheHeaderVersion { VK_PIPELINE_CACHE_HEADER_VERSION_ONE = 1 } VkPipelineCacheHeaderVersion; + + + typedef enum VkDeviceQueueCreateFlagBits { VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT = 1 } VkDeviceQueueCreateFlagBits; + typedef enum VkBufferCreateFlagBits { VK_BUFFER_CREATE_SPARSE_BINDING_BIT = 1, VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT = 2, VK_BUFFER_CREATE_SPARSE_ALIASED_BIT = 4, VK_BUFFER_CREATE_PROTECTED_BIT = 8 } VkBufferCreateFlagBits; + typedef enum VkBufferUsageFlagBits { VK_BUFFER_USAGE_TRANSFER_SRC_BIT = 1, VK_BUFFER_USAGE_TRANSFER_DST_BIT = 2, @@ -314,12 +455,14 @@ typedef enum VkBufferUsageFlagBits { VK_BUFFER_USAGE_VERTEX_BUFFER_BIT = 128, VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT = 256 } VkBufferUsageFlagBits; + typedef enum VkColorComponentFlagBits { VK_COLOR_COMPONENT_R_BIT = 1, VK_COLOR_COMPONENT_G_BIT = 2, VK_COLOR_COMPONENT_B_BIT = 4, VK_COLOR_COMPONENT_A_BIT = 8 } VkColorComponentFlagBits; + typedef enum VkComponentSwizzle { VK_COMPONENT_SWIZZLE_IDENTITY = 0, VK_COMPONENT_SWIZZLE_ZERO = 1, @@ -329,26 +472,32 @@ typedef enum VkComponentSwizzle { VK_COMPONENT_SWIZZLE_B = 5, VK_COMPONENT_SWIZZLE_A = 6 } VkComponentSwizzle; + typedef enum VkCommandPoolCreateFlagBits { VK_COMMAND_POOL_CREATE_TRANSIENT_BIT = 1, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT = 2, VK_COMMAND_POOL_CREATE_PROTECTED_BIT = 4 } VkCommandPoolCreateFlagBits; + typedef enum VkCommandPoolResetFlagBits { VK_COMMAND_POOL_RESET_RELEASE_RESOURCES_BIT = 1 } VkCommandPoolResetFlagBits; + typedef enum VkCommandBufferResetFlagBits { VK_COMMAND_BUFFER_RESET_RELEASE_RESOURCES_BIT = 1 } VkCommandBufferResetFlagBits; + typedef enum VkCommandBufferLevel { VK_COMMAND_BUFFER_LEVEL_PRIMARY = 0, VK_COMMAND_BUFFER_LEVEL_SECONDARY = 1 } VkCommandBufferLevel; + typedef enum VkCommandBufferUsageFlagBits { VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT = 1, VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT = 2, VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT = 4 } VkCommandBufferUsageFlagBits; + typedef enum VkCompareOp { VK_COMPARE_OP_NEVER = 0, VK_COMPARE_OP_LESS = 1, @@ -359,12 +508,14 @@ typedef enum VkCompareOp { VK_COMPARE_OP_GREATER_OR_EQUAL = 6, VK_COMPARE_OP_ALWAYS = 7 } VkCompareOp; + typedef enum VkCullModeFlagBits { VK_CULL_MODE_NONE = 0, VK_CULL_MODE_FRONT_BIT = 1, VK_CULL_MODE_BACK_BIT = 2, VK_CULL_MODE_FRONT_AND_BACK = 0x00000003 } VkCullModeFlagBits; + typedef enum VkDescriptorType { VK_DESCRIPTOR_TYPE_SAMPLER = 0, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER = 1, @@ -378,6 +529,7 @@ typedef enum VkDescriptorType { VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC = 9, VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT = 10 } VkDescriptorType; + typedef enum VkDynamicState { VK_DYNAMIC_STATE_VIEWPORT = 0, VK_DYNAMIC_STATE_SCISSOR = 1, @@ -387,17 +539,19 @@ typedef enum VkDynamicState { VK_DYNAMIC_STATE_DEPTH_BOUNDS = 5, VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK = 6, VK_DYNAMIC_STATE_STENCIL_WRITE_MASK = 7, - VK_DYNAMIC_STATE_STENCIL_REFERENCE = 8, - VK_DYNAMIC_STATE_RANGE_SIZE = (VK_DYNAMIC_STATE_STENCIL_REFERENCE - VK_DYNAMIC_STATE_VIEWPORT + 1) + VK_DYNAMIC_STATE_STENCIL_REFERENCE = 8 } VkDynamicState; + typedef enum VkFenceCreateFlagBits { VK_FENCE_CREATE_SIGNALED_BIT = 1 } VkFenceCreateFlagBits; + typedef enum VkPolygonMode { VK_POLYGON_MODE_FILL = 0, VK_POLYGON_MODE_LINE = 1, VK_POLYGON_MODE_POINT = 2 } VkPolygonMode; + typedef enum VkFormat { VK_FORMAT_UNDEFINED = 0, VK_FORMAT_R4G4_UNORM_PACK8 = 1, @@ -619,6 +773,7 @@ typedef enum VkFormat { VK_FORMAT_G16_B16R16_2PLANE_422_UNORM = 1000156032, VK_FORMAT_G16_B16_R16_3PLANE_444_UNORM = 1000156033 } VkFormat; + typedef enum VkFormatFeatureFlagBits { VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT = 1, VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT = 2, @@ -643,10 +798,12 @@ typedef enum VkFormatFeatureFlagBits { VK_FORMAT_FEATURE_DISJOINT_BIT = 4194304, VK_FORMAT_FEATURE_COSITED_CHROMA_SAMPLES_BIT = 8388608 } VkFormatFeatureFlagBits; + typedef enum VkFrontFace { VK_FRONT_FACE_COUNTER_CLOCKWISE = 0, VK_FRONT_FACE_CLOCKWISE = 1 } VkFrontFace; + typedef enum VkImageAspectFlagBits { VK_IMAGE_ASPECT_COLOR_BIT = 1, VK_IMAGE_ASPECT_DEPTH_BIT = 2, @@ -656,6 +813,7 @@ typedef enum VkImageAspectFlagBits { VK_IMAGE_ASPECT_PLANE_1_BIT = 32, VK_IMAGE_ASPECT_PLANE_2_BIT = 64 } VkImageAspectFlagBits; + typedef enum VkImageCreateFlagBits { VK_IMAGE_CREATE_SPARSE_BINDING_BIT = 1, VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT = 2, @@ -670,6 +828,7 @@ typedef enum VkImageCreateFlagBits { VK_IMAGE_CREATE_PROTECTED_BIT = 2048, VK_IMAGE_CREATE_DISJOINT_BIT = 512 } VkImageCreateFlagBits; + typedef enum VkImageLayout { VK_IMAGE_LAYOUT_UNDEFINED = 0, VK_IMAGE_LAYOUT_GENERAL = 1, @@ -684,15 +843,18 @@ typedef enum VkImageLayout { VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL = 1000117001, VK_IMAGE_LAYOUT_PRESENT_SRC_KHR = 1000001002 } VkImageLayout; + typedef enum VkImageTiling { VK_IMAGE_TILING_OPTIMAL = 0, VK_IMAGE_TILING_LINEAR = 1 } VkImageTiling; + typedef enum VkImageType { VK_IMAGE_TYPE_1D = 0, VK_IMAGE_TYPE_2D = 1, VK_IMAGE_TYPE_3D = 2 } VkImageType; + typedef enum VkImageUsageFlagBits { VK_IMAGE_USAGE_TRANSFER_SRC_BIT = 1, VK_IMAGE_USAGE_TRANSFER_DST_BIT = 2, @@ -704,6 +866,7 @@ typedef enum VkImageUsageFlagBits { VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT = 128 } VkImageUsageFlagBits; + typedef enum VkImageViewType { VK_IMAGE_VIEW_TYPE_1D = 0, VK_IMAGE_VIEW_TYPE_2D = 1, @@ -713,14 +876,17 @@ typedef enum VkImageViewType { VK_IMAGE_VIEW_TYPE_2D_ARRAY = 5, VK_IMAGE_VIEW_TYPE_CUBE_ARRAY = 6 } VkImageViewType; + typedef enum VkSharingMode { VK_SHARING_MODE_EXCLUSIVE = 0, VK_SHARING_MODE_CONCURRENT = 1 } VkSharingMode; + typedef enum VkIndexType { VK_INDEX_TYPE_UINT16 = 0, VK_INDEX_TYPE_UINT32 = 1 } VkIndexType; + typedef enum VkLogicOp { VK_LOGIC_OP_CLEAR = 0, VK_LOGIC_OP_AND = 1, @@ -739,10 +905,12 @@ typedef enum VkLogicOp { VK_LOGIC_OP_NAND = 14, VK_LOGIC_OP_SET = 15 } VkLogicOp; + typedef enum VkMemoryHeapFlagBits { VK_MEMORY_HEAP_DEVICE_LOCAL_BIT = 1, VK_MEMORY_HEAP_MULTI_INSTANCE_BIT = 2 } VkMemoryHeapFlagBits; + typedef enum VkAccessFlagBits { VK_ACCESS_INDIRECT_COMMAND_READ_BIT = 1, VK_ACCESS_INDEX_READ_BIT = 2, @@ -762,6 +930,7 @@ typedef enum VkAccessFlagBits { VK_ACCESS_MEMORY_READ_BIT = 32768, VK_ACCESS_MEMORY_WRITE_BIT = 65536 } VkAccessFlagBits; + typedef enum VkMemoryPropertyFlagBits { VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT = 1, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT = 2, @@ -770,6 +939,7 @@ typedef enum VkMemoryPropertyFlagBits { VK_MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT = 16, VK_MEMORY_PROPERTY_PROTECTED_BIT = 32 } VkMemoryPropertyFlagBits; + typedef enum VkPhysicalDeviceType { VK_PHYSICAL_DEVICE_TYPE_OTHER = 0, VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU = 1, @@ -777,17 +947,21 @@ typedef enum VkPhysicalDeviceType { VK_PHYSICAL_DEVICE_TYPE_VIRTUAL_GPU = 3, VK_PHYSICAL_DEVICE_TYPE_CPU = 4 } VkPhysicalDeviceType; + typedef enum VkPipelineBindPoint { VK_PIPELINE_BIND_POINT_GRAPHICS = 0, VK_PIPELINE_BIND_POINT_COMPUTE = 1 } VkPipelineBindPoint; + typedef enum VkPipelineCreateFlagBits { VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT = 1, VK_PIPELINE_CREATE_ALLOW_DERIVATIVES_BIT = 2, VK_PIPELINE_CREATE_DERIVATIVE_BIT = 4, VK_PIPELINE_CREATE_VIEW_INDEX_FROM_DEVICE_INDEX_BIT = 8, - VK_PIPELINE_CREATE_DISPATCH_BASE = 16 + VK_PIPELINE_CREATE_DISPATCH_BASE_BIT = 16, + VK_PIPELINE_CREATE_DISPATCH_BASE = VK_PIPELINE_CREATE_DISPATCH_BASE_BIT } VkPipelineCreateFlagBits; + typedef enum VkPrimitiveTopology { VK_PRIMITIVE_TOPOLOGY_POINT_LIST = 0, VK_PRIMITIVE_TOPOLOGY_LINE_LIST = 1, @@ -801,9 +975,11 @@ typedef enum VkPrimitiveTopology { VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_WITH_ADJACENCY = 9, VK_PRIMITIVE_TOPOLOGY_PATCH_LIST = 10 } VkPrimitiveTopology; + typedef enum VkQueryControlFlagBits { VK_QUERY_CONTROL_PRECISE_BIT = 1 } VkQueryControlFlagBits; + typedef enum VkQueryPipelineStatisticFlagBits { VK_QUERY_PIPELINE_STATISTIC_INPUT_ASSEMBLY_VERTICES_BIT = 1, VK_QUERY_PIPELINE_STATISTIC_INPUT_ASSEMBLY_PRIMITIVES_BIT = 2, @@ -817,17 +993,20 @@ typedef enum VkQueryPipelineStatisticFlagBits { VK_QUERY_PIPELINE_STATISTIC_TESSELLATION_EVALUATION_SHADER_INVOCATIONS_BIT = 512, VK_QUERY_PIPELINE_STATISTIC_COMPUTE_SHADER_INVOCATIONS_BIT = 1024 } VkQueryPipelineStatisticFlagBits; + typedef enum VkQueryResultFlagBits { VK_QUERY_RESULT_64_BIT = 1, VK_QUERY_RESULT_WAIT_BIT = 2, VK_QUERY_RESULT_WITH_AVAILABILITY_BIT = 4, VK_QUERY_RESULT_PARTIAL_BIT = 8 } VkQueryResultFlagBits; + typedef enum VkQueryType { VK_QUERY_TYPE_OCCLUSION = 0, VK_QUERY_TYPE_PIPELINE_STATISTICS = 1, VK_QUERY_TYPE_TIMESTAMP = 2 } VkQueryType; + typedef enum VkQueueFlagBits { VK_QUEUE_GRAPHICS_BIT = 1, VK_QUEUE_COMPUTE_BIT = 2, @@ -835,10 +1014,12 @@ typedef enum VkQueueFlagBits { VK_QUEUE_SPARSE_BINDING_BIT = 8, VK_QUEUE_PROTECTED_BIT = 16 } VkQueueFlagBits; + typedef enum VkSubpassContents { VK_SUBPASS_CONTENTS_INLINE = 0, VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS = 1 } VkSubpassContents; + typedef enum VkResult { VK_SUCCESS = 0, VK_NOT_READY = 1, @@ -858,6 +1039,7 @@ typedef enum VkResult { VK_ERROR_TOO_MANY_OBJECTS = -10, VK_ERROR_FORMAT_NOT_SUPPORTED = -11, VK_ERROR_FRAGMENTED_POOL = -12, + VK_ERROR_UNKNOWN = -13, VK_ERROR_OUT_OF_POOL_MEMORY = -1000069000, VK_ERROR_INVALID_EXTERNAL_HANDLE = -1000072003, VK_ERROR_SURFACE_LOST_KHR = -1000000000, @@ -866,6 +1048,7 @@ typedef enum VkResult { VK_ERROR_OUT_OF_DATE_KHR = -1000001004, VK_ERROR_VALIDATION_FAILED_EXT = -1000011001 } VkResult; + typedef enum VkShaderStageFlagBits { VK_SHADER_STAGE_VERTEX_BIT = 1, VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT = 2, @@ -876,14 +1059,18 @@ typedef enum VkShaderStageFlagBits { VK_SHADER_STAGE_ALL_GRAPHICS = 0x0000001F, VK_SHADER_STAGE_ALL = 0x7FFFFFFF } VkShaderStageFlagBits; + typedef enum VkSparseMemoryBindFlagBits { VK_SPARSE_MEMORY_BIND_METADATA_BIT = 1 } VkSparseMemoryBindFlagBits; + typedef enum VkStencilFaceFlagBits { VK_STENCIL_FACE_FRONT_BIT = 1, VK_STENCIL_FACE_BACK_BIT = 2, - VK_STENCIL_FRONT_AND_BACK = 0x00000003 + VK_STENCIL_FACE_FRONT_AND_BACK = 0x00000003, + VK_STENCIL_FRONT_AND_BACK = VK_STENCIL_FACE_FRONT_AND_BACK } VkStencilFaceFlagBits; + typedef enum VkStencilOp { VK_STENCIL_OP_KEEP = 0, VK_STENCIL_OP_ZERO = 1, @@ -894,6 +1081,7 @@ typedef enum VkStencilOp { VK_STENCIL_OP_INCREMENT_AND_WRAP = 6, VK_STENCIL_OP_DECREMENT_AND_WRAP = 7 } VkStencilOp; + typedef enum VkStructureType { VK_STRUCTURE_TYPE_APPLICATION_INFO = 0, VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO = 1, @@ -1022,6 +1210,7 @@ typedef enum VkStructureType { VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT = 1000011000, VK_STRUCTURE_TYPE_DEBUG_REPORT_CREATE_INFO_EXT = VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT } VkStructureType; + typedef enum VkSystemAllocationScope { VK_SYSTEM_ALLOCATION_SCOPE_COMMAND = 0, VK_SYSTEM_ALLOCATION_SCOPE_OBJECT = 1, @@ -1029,27 +1218,33 @@ typedef enum VkSystemAllocationScope { VK_SYSTEM_ALLOCATION_SCOPE_DEVICE = 3, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE = 4 } VkSystemAllocationScope; + typedef enum VkInternalAllocationType { VK_INTERNAL_ALLOCATION_TYPE_EXECUTABLE = 0 } VkInternalAllocationType; + typedef enum VkSamplerAddressMode { VK_SAMPLER_ADDRESS_MODE_REPEAT = 0, VK_SAMPLER_ADDRESS_MODE_MIRRORED_REPEAT = 1, VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE = 2, VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER = 3 } VkSamplerAddressMode; + typedef enum VkFilter { VK_FILTER_NEAREST = 0, VK_FILTER_LINEAR = 1 } VkFilter; + typedef enum VkSamplerMipmapMode { VK_SAMPLER_MIPMAP_MODE_NEAREST = 0, VK_SAMPLER_MIPMAP_MODE_LINEAR = 1 } VkSamplerMipmapMode; + typedef enum VkVertexInputRate { VK_VERTEX_INPUT_RATE_VERTEX = 0, VK_VERTEX_INPUT_RATE_INSTANCE = 1 } VkVertexInputRate; + typedef enum VkPipelineStageFlagBits { VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT = 1, VK_PIPELINE_STAGE_DRAW_INDIRECT_BIT = 2, @@ -1069,11 +1264,13 @@ typedef enum VkPipelineStageFlagBits { VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT = 32768, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT = 65536 } VkPipelineStageFlagBits; + typedef enum VkSparseImageFormatFlagBits { VK_SPARSE_IMAGE_FORMAT_SINGLE_MIPTAIL_BIT = 1, VK_SPARSE_IMAGE_FORMAT_ALIGNED_MIP_SIZE_BIT = 2, VK_SPARSE_IMAGE_FORMAT_NONSTANDARD_BLOCK_SIZE_BIT = 4 } VkSparseImageFormatFlagBits; + typedef enum VkSampleCountFlagBits { VK_SAMPLE_COUNT_1_BIT = 1, VK_SAMPLE_COUNT_2_BIT = 2, @@ -1083,17 +1280,21 @@ typedef enum VkSampleCountFlagBits { VK_SAMPLE_COUNT_32_BIT = 32, VK_SAMPLE_COUNT_64_BIT = 64 } VkSampleCountFlagBits; + typedef enum VkAttachmentDescriptionFlagBits { VK_ATTACHMENT_DESCRIPTION_MAY_ALIAS_BIT = 1 } VkAttachmentDescriptionFlagBits; + typedef enum VkDescriptorPoolCreateFlagBits { VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT = 1 } VkDescriptorPoolCreateFlagBits; + typedef enum VkDependencyFlagBits { VK_DEPENDENCY_BY_REGION_BIT = 1, VK_DEPENDENCY_DEVICE_GROUP_BIT = 4, VK_DEPENDENCY_VIEW_LOCAL_BIT = 2 } VkDependencyFlagBits; + typedef enum VkObjectType { VK_OBJECT_TYPE_UNKNOWN = 0, VK_OBJECT_TYPE_INSTANCE = 1, @@ -1127,30 +1328,37 @@ typedef enum VkObjectType { VK_OBJECT_TYPE_SWAPCHAIN_KHR = 1000001000, VK_OBJECT_TYPE_DEBUG_REPORT_CALLBACK_EXT = 1000011000 } VkObjectType; + typedef enum VkDescriptorUpdateTemplateType { VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_DESCRIPTOR_SET = 0 } VkDescriptorUpdateTemplateType; + typedef enum VkPointClippingBehavior { VK_POINT_CLIPPING_BEHAVIOR_ALL_CLIP_PLANES = 0, VK_POINT_CLIPPING_BEHAVIOR_USER_CLIP_PLANES_ONLY = 1 } VkPointClippingBehavior; + + typedef enum VkColorSpaceKHR { VK_COLOR_SPACE_SRGB_NONLINEAR_KHR = 0, VK_COLORSPACE_SRGB_NONLINEAR_KHR = VK_COLOR_SPACE_SRGB_NONLINEAR_KHR } VkColorSpaceKHR; + typedef enum VkCompositeAlphaFlagBitsKHR { VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR = 1, VK_COMPOSITE_ALPHA_PRE_MULTIPLIED_BIT_KHR = 2, VK_COMPOSITE_ALPHA_POST_MULTIPLIED_BIT_KHR = 4, VK_COMPOSITE_ALPHA_INHERIT_BIT_KHR = 8 } VkCompositeAlphaFlagBitsKHR; + typedef enum VkPresentModeKHR { VK_PRESENT_MODE_IMMEDIATE_KHR = 0, VK_PRESENT_MODE_MAILBOX_KHR = 1, VK_PRESENT_MODE_FIFO_KHR = 2, VK_PRESENT_MODE_FIFO_RELAXED_KHR = 3 } VkPresentModeKHR; + typedef enum VkSurfaceTransformFlagBitsKHR { VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR = 1, VK_SURFACE_TRANSFORM_ROTATE_90_BIT_KHR = 2, @@ -1162,6 +1370,7 @@ typedef enum VkSurfaceTransformFlagBitsKHR { VK_SURFACE_TRANSFORM_HORIZONTAL_MIRROR_ROTATE_270_BIT_KHR = 128, VK_SURFACE_TRANSFORM_INHERIT_BIT_KHR = 256 } VkSurfaceTransformFlagBitsKHR; + typedef enum VkDebugReportFlagBitsEXT { VK_DEBUG_REPORT_INFORMATION_BIT_EXT = 1, VK_DEBUG_REPORT_WARNING_BIT_EXT = 2, @@ -1169,6 +1378,7 @@ typedef enum VkDebugReportFlagBitsEXT { VK_DEBUG_REPORT_ERROR_BIT_EXT = 8, VK_DEBUG_REPORT_DEBUG_BIT_EXT = 16 } VkDebugReportFlagBitsEXT; + typedef enum VkDebugReportObjectTypeEXT { VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT = 0, VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT = 1, @@ -1202,13 +1412,12 @@ typedef enum VkDebugReportObjectTypeEXT { VK_DEBUG_REPORT_OBJECT_TYPE_DEBUG_REPORT_EXT = VK_DEBUG_REPORT_OBJECT_TYPE_DEBUG_REPORT_CALLBACK_EXT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DISPLAY_KHR_EXT = 29, VK_DEBUG_REPORT_OBJECT_TYPE_DISPLAY_MODE_KHR_EXT = 30, - VK_DEBUG_REPORT_OBJECT_TYPE_OBJECT_TABLE_NVX_EXT = 31, - VK_DEBUG_REPORT_OBJECT_TYPE_INDIRECT_COMMANDS_LAYOUT_NVX_EXT = 32, VK_DEBUG_REPORT_OBJECT_TYPE_VALIDATION_CACHE_EXT_EXT = 33, VK_DEBUG_REPORT_OBJECT_TYPE_VALIDATION_CACHE_EXT = VK_DEBUG_REPORT_OBJECT_TYPE_VALIDATION_CACHE_EXT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_SAMPLER_YCBCR_CONVERSION_EXT = 1000156000, VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_UPDATE_TEMPLATE_EXT = 1000085000 } VkDebugReportObjectTypeEXT; + typedef enum VkExternalMemoryHandleTypeFlagBits { VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT = 1, VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_BIT = 2, @@ -1218,57 +1427,70 @@ typedef enum VkExternalMemoryHandleTypeFlagBits { VK_EXTERNAL_MEMORY_HANDLE_TYPE_D3D12_HEAP_BIT = 32, VK_EXTERNAL_MEMORY_HANDLE_TYPE_D3D12_RESOURCE_BIT = 64 } VkExternalMemoryHandleTypeFlagBits; + typedef enum VkExternalMemoryFeatureFlagBits { VK_EXTERNAL_MEMORY_FEATURE_DEDICATED_ONLY_BIT = 1, VK_EXTERNAL_MEMORY_FEATURE_EXPORTABLE_BIT = 2, VK_EXTERNAL_MEMORY_FEATURE_IMPORTABLE_BIT = 4 } VkExternalMemoryFeatureFlagBits; + typedef enum VkExternalSemaphoreHandleTypeFlagBits { VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT = 1, VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_BIT = 2, VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_KMT_BIT = 4, VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_D3D12_FENCE_BIT = 8, + VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_D3D11_FENCE_BIT = VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_D3D12_FENCE_BIT, VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT = 16 } VkExternalSemaphoreHandleTypeFlagBits; + typedef enum VkExternalSemaphoreFeatureFlagBits { VK_EXTERNAL_SEMAPHORE_FEATURE_EXPORTABLE_BIT = 1, VK_EXTERNAL_SEMAPHORE_FEATURE_IMPORTABLE_BIT = 2 } VkExternalSemaphoreFeatureFlagBits; + typedef enum VkSemaphoreImportFlagBits { VK_SEMAPHORE_IMPORT_TEMPORARY_BIT = 1 } VkSemaphoreImportFlagBits; + typedef enum VkExternalFenceHandleTypeFlagBits { VK_EXTERNAL_FENCE_HANDLE_TYPE_OPAQUE_FD_BIT = 1, VK_EXTERNAL_FENCE_HANDLE_TYPE_OPAQUE_WIN32_BIT = 2, VK_EXTERNAL_FENCE_HANDLE_TYPE_OPAQUE_WIN32_KMT_BIT = 4, VK_EXTERNAL_FENCE_HANDLE_TYPE_SYNC_FD_BIT = 8 } VkExternalFenceHandleTypeFlagBits; + typedef enum VkExternalFenceFeatureFlagBits { VK_EXTERNAL_FENCE_FEATURE_EXPORTABLE_BIT = 1, VK_EXTERNAL_FENCE_FEATURE_IMPORTABLE_BIT = 2 } VkExternalFenceFeatureFlagBits; + typedef enum VkFenceImportFlagBits { VK_FENCE_IMPORT_TEMPORARY_BIT = 1 } VkFenceImportFlagBits; + typedef enum VkPeerMemoryFeatureFlagBits { VK_PEER_MEMORY_FEATURE_COPY_SRC_BIT = 1, VK_PEER_MEMORY_FEATURE_COPY_DST_BIT = 2, VK_PEER_MEMORY_FEATURE_GENERIC_SRC_BIT = 4, VK_PEER_MEMORY_FEATURE_GENERIC_DST_BIT = 8 } VkPeerMemoryFeatureFlagBits; + typedef enum VkMemoryAllocateFlagBits { VK_MEMORY_ALLOCATE_DEVICE_MASK_BIT = 1 } VkMemoryAllocateFlagBits; + typedef enum VkDeviceGroupPresentModeFlagBitsKHR { VK_DEVICE_GROUP_PRESENT_MODE_LOCAL_BIT_KHR = 1, VK_DEVICE_GROUP_PRESENT_MODE_REMOTE_BIT_KHR = 2, VK_DEVICE_GROUP_PRESENT_MODE_SUM_BIT_KHR = 4, VK_DEVICE_GROUP_PRESENT_MODE_LOCAL_MULTI_DEVICE_BIT_KHR = 8 } VkDeviceGroupPresentModeFlagBitsKHR; + typedef enum VkSwapchainCreateFlagBitsKHR { VK_SWAPCHAIN_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT_KHR = 1, VK_SWAPCHAIN_CREATE_PROTECTED_BIT_KHR = 2 } VkSwapchainCreateFlagBitsKHR; + typedef enum VkSubgroupFeatureFlagBits { VK_SUBGROUP_FEATURE_BASIC_BIT = 1, VK_SUBGROUP_FEATURE_VOTE_BIT = 2, @@ -1279,10 +1501,12 @@ typedef enum VkSubgroupFeatureFlagBits { VK_SUBGROUP_FEATURE_CLUSTERED_BIT = 64, VK_SUBGROUP_FEATURE_QUAD_BIT = 128 } VkSubgroupFeatureFlagBits; + typedef enum VkTessellationDomainOrigin { VK_TESSELLATION_DOMAIN_ORIGIN_UPPER_LEFT = 0, VK_TESSELLATION_DOMAIN_ORIGIN_LOWER_LEFT = 1 } VkTessellationDomainOrigin; + typedef enum VkSamplerYcbcrModelConversion { VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY = 0, VK_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_IDENTITY = 1, @@ -1290,70 +1514,88 @@ typedef enum VkSamplerYcbcrModelConversion { VK_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_601 = 3, VK_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_2020 = 4 } VkSamplerYcbcrModelConversion; + typedef enum VkSamplerYcbcrRange { VK_SAMPLER_YCBCR_RANGE_ITU_FULL = 0, VK_SAMPLER_YCBCR_RANGE_ITU_NARROW = 1 } VkSamplerYcbcrRange; + typedef enum VkChromaLocation { VK_CHROMA_LOCATION_COSITED_EVEN = 0, VK_CHROMA_LOCATION_MIDPOINT = 1 } VkChromaLocation; + typedef enum VkVendorId { VK_VENDOR_ID_VIV = 0x10001, VK_VENDOR_ID_VSI = 0x10002, - VK_VENDOR_ID_KAZAN = 0x10003 + VK_VENDOR_ID_KAZAN = 0x10003, + VK_VENDOR_ID_CODEPLAY = 0x10004, + VK_VENDOR_ID_MESA = 0x10005 } VkVendorId; + typedef void (VKAPI_PTR *PFN_vkInternalAllocationNotification)( void* pUserData, size_t size, VkInternalAllocationType allocationType, VkSystemAllocationScope allocationScope); + typedef void (VKAPI_PTR *PFN_vkInternalFreeNotification)( void* pUserData, size_t size, VkInternalAllocationType allocationType, VkSystemAllocationScope allocationScope); + typedef void* (VKAPI_PTR *PFN_vkReallocationFunction)( void* pUserData, void* pOriginal, size_t size, size_t alignment, VkSystemAllocationScope allocationScope); + typedef void* (VKAPI_PTR *PFN_vkAllocationFunction)( void* pUserData, size_t size, size_t alignment, VkSystemAllocationScope allocationScope); + typedef void (VKAPI_PTR *PFN_vkFreeFunction)( void* pUserData, void* pMemory); + typedef void (VKAPI_PTR *PFN_vkVoidFunction)(void); + typedef struct VkBaseOutStructure { VkStructureType sType; struct VkBaseOutStructure * pNext; } VkBaseOutStructure; + typedef struct VkBaseInStructure { VkStructureType sType; const struct VkBaseInStructure * pNext; } VkBaseInStructure; + typedef struct VkOffset2D { int32_t x; int32_t y; } VkOffset2D; + typedef struct VkOffset3D { int32_t x; int32_t y; int32_t z; } VkOffset3D; + typedef struct VkExtent2D { uint32_t width; uint32_t height; } VkExtent2D; + typedef struct VkExtent3D { uint32_t width; uint32_t height; uint32_t depth; } VkExtent3D; + typedef struct VkViewport { float x; float y; @@ -1362,31 +1604,37 @@ typedef struct VkViewport { float minDepth; float maxDepth; } VkViewport; + typedef struct VkRect2D { VkOffset2D offset; VkExtent2D extent; } VkRect2D; + typedef struct VkClearRect { VkRect2D rect; uint32_t baseArrayLayer; uint32_t layerCount; } VkClearRect; + typedef struct VkComponentMapping { VkComponentSwizzle r; VkComponentSwizzle g; VkComponentSwizzle b; VkComponentSwizzle a; } VkComponentMapping; + typedef struct VkExtensionProperties { char extensionName [ VK_MAX_EXTENSION_NAME_SIZE ]; uint32_t specVersion; } VkExtensionProperties; + typedef struct VkLayerProperties { char layerName [ VK_MAX_EXTENSION_NAME_SIZE ]; uint32_t specVersion; uint32_t implementationVersion; char description [ VK_MAX_DESCRIPTION_SIZE ]; } VkLayerProperties; + typedef struct VkApplicationInfo { VkStructureType sType; const void * pNext; @@ -1396,6 +1644,7 @@ typedef struct VkApplicationInfo { uint32_t engineVersion; uint32_t apiVersion; } VkApplicationInfo; + typedef struct VkAllocationCallbacks { void * pUserData; PFN_vkAllocationFunction pfnAllocation; @@ -1404,11 +1653,13 @@ typedef struct VkAllocationCallbacks { PFN_vkInternalAllocationNotification pfnInternalAllocation; PFN_vkInternalFreeNotification pfnInternalFree; } VkAllocationCallbacks; + typedef struct VkDescriptorImageInfo { VkSampler sampler; VkImageView imageView; VkImageLayout imageLayout; } VkDescriptorImageInfo; + typedef struct VkCopyDescriptorSet { VkStructureType sType; const void * pNext; @@ -1420,10 +1671,12 @@ typedef struct VkCopyDescriptorSet { uint32_t dstArrayElement; uint32_t descriptorCount; } VkCopyDescriptorSet; + typedef struct VkDescriptorPoolSize { VkDescriptorType type; uint32_t descriptorCount; } VkDescriptorPoolSize; + typedef struct VkDescriptorSetAllocateInfo { VkStructureType sType; const void * pNext; @@ -1431,28 +1684,33 @@ typedef struct VkDescriptorSetAllocateInfo { uint32_t descriptorSetCount; const VkDescriptorSetLayout * pSetLayouts; } VkDescriptorSetAllocateInfo; + typedef struct VkSpecializationMapEntry { uint32_t constantID; uint32_t offset; size_t size; } VkSpecializationMapEntry; + typedef struct VkSpecializationInfo { uint32_t mapEntryCount; const VkSpecializationMapEntry * pMapEntries; size_t dataSize; const void * pData; } VkSpecializationInfo; + typedef struct VkVertexInputBindingDescription { uint32_t binding; uint32_t stride; VkVertexInputRate inputRate; } VkVertexInputBindingDescription; + typedef struct VkVertexInputAttributeDescription { uint32_t location; uint32_t binding; VkFormat format; uint32_t offset; } VkVertexInputAttributeDescription; + typedef struct VkStencilOpState { VkStencilOp failOp; VkStencilOp passOp; @@ -1462,6 +1720,7 @@ typedef struct VkStencilOpState { uint32_t writeMask; uint32_t reference; } VkStencilOpState; + typedef struct VkCommandBufferAllocateInfo { VkStructureType sType; const void * pNext; @@ -1469,29 +1728,35 @@ typedef struct VkCommandBufferAllocateInfo { VkCommandBufferLevel level; uint32_t commandBufferCount; } VkCommandBufferAllocateInfo; + typedef union VkClearColorValue { float float32 [4]; int32_t int32 [4]; uint32_t uint32 [4]; } VkClearColorValue; + typedef struct VkClearDepthStencilValue { float depth; uint32_t stencil; } VkClearDepthStencilValue; + typedef union VkClearValue { VkClearColorValue color; VkClearDepthStencilValue depthStencil; } VkClearValue; + typedef struct VkAttachmentReference { uint32_t attachment; VkImageLayout layout; } VkAttachmentReference; + typedef struct VkDrawIndirectCommand { uint32_t vertexCount; uint32_t instanceCount; uint32_t firstVertex; uint32_t firstInstance; } VkDrawIndirectCommand; + typedef struct VkDrawIndexedIndirectCommand { uint32_t indexCount; uint32_t instanceCount; @@ -1499,15 +1764,18 @@ typedef struct VkDrawIndexedIndirectCommand { int32_t vertexOffset; uint32_t firstInstance; } VkDrawIndexedIndirectCommand; + typedef struct VkDispatchIndirectCommand { uint32_t x; uint32_t y; uint32_t z; } VkDispatchIndirectCommand; + typedef struct VkSurfaceFormatKHR { VkFormat format; VkColorSpaceKHR colorSpace; } VkSurfaceFormatKHR; + typedef struct VkPresentInfoKHR { VkStructureType sType; const void * pNext; @@ -1518,27 +1786,32 @@ typedef struct VkPresentInfoKHR { const uint32_t * pImageIndices; VkResult * pResults; } VkPresentInfoKHR; + typedef struct VkPhysicalDeviceExternalImageFormatInfo { VkStructureType sType; const void * pNext; VkExternalMemoryHandleTypeFlagBits handleType; } VkPhysicalDeviceExternalImageFormatInfo; + typedef struct VkPhysicalDeviceExternalSemaphoreInfo { VkStructureType sType; const void * pNext; VkExternalSemaphoreHandleTypeFlagBits handleType; } VkPhysicalDeviceExternalSemaphoreInfo; + typedef struct VkPhysicalDeviceExternalFenceInfo { VkStructureType sType; const void * pNext; VkExternalFenceHandleTypeFlagBits handleType; } VkPhysicalDeviceExternalFenceInfo; + typedef struct VkPhysicalDeviceMultiviewProperties { VkStructureType sType; void * pNext; uint32_t maxMultiviewViewCount; uint32_t maxMultiviewInstanceIndex; } VkPhysicalDeviceMultiviewProperties; + typedef struct VkRenderPassMultiviewCreateInfo { VkStructureType sType; const void * pNext; @@ -1549,12 +1822,14 @@ typedef struct VkRenderPassMultiviewCreateInfo { uint32_t correlationMaskCount; const uint32_t * pCorrelationMasks; } VkRenderPassMultiviewCreateInfo; + typedef struct VkBindBufferMemoryDeviceGroupInfo { VkStructureType sType; const void * pNext; uint32_t deviceIndexCount; const uint32_t * pDeviceIndices; } VkBindBufferMemoryDeviceGroupInfo; + typedef struct VkBindImageMemoryDeviceGroupInfo { VkStructureType sType; const void * pNext; @@ -1563,6 +1838,7 @@ typedef struct VkBindImageMemoryDeviceGroupInfo { uint32_t splitInstanceBindRegionCount; const VkRect2D * pSplitInstanceBindRegions; } VkBindImageMemoryDeviceGroupInfo; + typedef struct VkDeviceGroupRenderPassBeginInfo { VkStructureType sType; const void * pNext; @@ -1570,11 +1846,13 @@ typedef struct VkDeviceGroupRenderPassBeginInfo { uint32_t deviceRenderAreaCount; const VkRect2D * pDeviceRenderAreas; } VkDeviceGroupRenderPassBeginInfo; + typedef struct VkDeviceGroupCommandBufferBeginInfo { VkStructureType sType; const void * pNext; uint32_t deviceMask; } VkDeviceGroupCommandBufferBeginInfo; + typedef struct VkDeviceGroupSubmitInfo { VkStructureType sType; const void * pNext; @@ -1585,23 +1863,27 @@ typedef struct VkDeviceGroupSubmitInfo { uint32_t signalSemaphoreCount; const uint32_t * pSignalSemaphoreDeviceIndices; } VkDeviceGroupSubmitInfo; + typedef struct VkDeviceGroupBindSparseInfo { VkStructureType sType; const void * pNext; uint32_t resourceDeviceIndex; uint32_t memoryDeviceIndex; } VkDeviceGroupBindSparseInfo; + typedef struct VkImageSwapchainCreateInfoKHR { VkStructureType sType; const void * pNext; VkSwapchainKHR swapchain; } VkImageSwapchainCreateInfoKHR; + typedef struct VkBindImageMemorySwapchainInfoKHR { VkStructureType sType; const void * pNext; VkSwapchainKHR swapchain; uint32_t imageIndex; } VkBindImageMemorySwapchainInfoKHR; + typedef struct VkAcquireNextImageInfoKHR { VkStructureType sType; const void * pNext; @@ -1611,6 +1893,7 @@ typedef struct VkAcquireNextImageInfoKHR { VkFence fence; uint32_t deviceMask; } VkAcquireNextImageInfoKHR; + typedef struct VkDeviceGroupPresentInfoKHR { VkStructureType sType; const void * pNext; @@ -1618,12 +1901,14 @@ typedef struct VkDeviceGroupPresentInfoKHR { const uint32_t * pDeviceMasks; VkDeviceGroupPresentModeFlagBitsKHR mode; } VkDeviceGroupPresentInfoKHR; + typedef struct VkDeviceGroupDeviceCreateInfo { VkStructureType sType; const void * pNext; uint32_t physicalDeviceCount; const VkPhysicalDevice * pPhysicalDevices; } VkDeviceGroupDeviceCreateInfo; + typedef struct VkDescriptorUpdateTemplateEntry { uint32_t dstBinding; uint32_t dstArrayElement; @@ -1632,137 +1917,230 @@ typedef struct VkDescriptorUpdateTemplateEntry { size_t offset; size_t stride; } VkDescriptorUpdateTemplateEntry; + typedef struct VkBufferMemoryRequirementsInfo2 { VkStructureType sType; const void * pNext; VkBuffer buffer; } VkBufferMemoryRequirementsInfo2; + typedef struct VkImageMemoryRequirementsInfo2 { VkStructureType sType; const void * pNext; VkImage image; } VkImageMemoryRequirementsInfo2; + typedef struct VkImageSparseMemoryRequirementsInfo2 { VkStructureType sType; const void * pNext; VkImage image; } VkImageSparseMemoryRequirementsInfo2; + typedef struct VkPhysicalDevicePointClippingProperties { VkStructureType sType; void * pNext; VkPointClippingBehavior pointClippingBehavior; } VkPhysicalDevicePointClippingProperties; + typedef struct VkMemoryDedicatedAllocateInfo { VkStructureType sType; const void * pNext; VkImage image; VkBuffer buffer; } VkMemoryDedicatedAllocateInfo; + typedef struct VkPipelineTessellationDomainOriginStateCreateInfo { VkStructureType sType; const void * pNext; VkTessellationDomainOrigin domainOrigin; } VkPipelineTessellationDomainOriginStateCreateInfo; + typedef struct VkSamplerYcbcrConversionInfo { VkStructureType sType; const void * pNext; VkSamplerYcbcrConversion conversion; } VkSamplerYcbcrConversionInfo; + typedef struct VkBindImagePlaneMemoryInfo { VkStructureType sType; const void * pNext; VkImageAspectFlagBits planeAspect; } VkBindImagePlaneMemoryInfo; + typedef struct VkImagePlaneMemoryRequirementsInfo { VkStructureType sType; const void * pNext; VkImageAspectFlagBits planeAspect; } VkImagePlaneMemoryRequirementsInfo; + typedef struct VkSamplerYcbcrConversionImageFormatProperties { VkStructureType sType; void * pNext; uint32_t combinedImageSamplerDescriptorCount; } VkSamplerYcbcrConversionImageFormatProperties; + typedef uint32_t VkSampleMask; + typedef uint32_t VkBool32; + typedef uint32_t VkFlags; + typedef uint64_t VkDeviceSize; + +typedef uint64_t VkDeviceAddress; + typedef VkFlags VkFramebufferCreateFlags; + typedef VkFlags VkQueryPoolCreateFlags; + typedef VkFlags VkRenderPassCreateFlags; + typedef VkFlags VkSamplerCreateFlags; + typedef VkFlags VkPipelineLayoutCreateFlags; + typedef VkFlags VkPipelineCacheCreateFlags; + typedef VkFlags VkPipelineDepthStencilStateCreateFlags; + typedef VkFlags VkPipelineDynamicStateCreateFlags; + typedef VkFlags VkPipelineColorBlendStateCreateFlags; + typedef VkFlags VkPipelineMultisampleStateCreateFlags; + typedef VkFlags VkPipelineRasterizationStateCreateFlags; + typedef VkFlags VkPipelineViewportStateCreateFlags; + typedef VkFlags VkPipelineTessellationStateCreateFlags; + typedef VkFlags VkPipelineInputAssemblyStateCreateFlags; + typedef VkFlags VkPipelineVertexInputStateCreateFlags; + typedef VkFlags VkPipelineShaderStageCreateFlags; + typedef VkFlags VkDescriptorSetLayoutCreateFlags; + typedef VkFlags VkBufferViewCreateFlags; + typedef VkFlags VkInstanceCreateFlags; + typedef VkFlags VkDeviceCreateFlags; + typedef VkFlags VkDeviceQueueCreateFlags; + typedef VkFlags VkQueueFlags; + typedef VkFlags VkMemoryPropertyFlags; + typedef VkFlags VkMemoryHeapFlags; + typedef VkFlags VkAccessFlags; + typedef VkFlags VkBufferUsageFlags; + typedef VkFlags VkBufferCreateFlags; + typedef VkFlags VkShaderStageFlags; + typedef VkFlags VkImageUsageFlags; + typedef VkFlags VkImageCreateFlags; + typedef VkFlags VkImageViewCreateFlags; + typedef VkFlags VkPipelineCreateFlags; + typedef VkFlags VkColorComponentFlags; + typedef VkFlags VkFenceCreateFlags; + typedef VkFlags VkSemaphoreCreateFlags; + typedef VkFlags VkFormatFeatureFlags; + typedef VkFlags VkQueryControlFlags; + typedef VkFlags VkQueryResultFlags; + typedef VkFlags VkShaderModuleCreateFlags; + typedef VkFlags VkEventCreateFlags; + typedef VkFlags VkCommandPoolCreateFlags; + typedef VkFlags VkCommandPoolResetFlags; + typedef VkFlags VkCommandBufferResetFlags; + typedef VkFlags VkCommandBufferUsageFlags; + typedef VkFlags VkQueryPipelineStatisticFlags; + typedef VkFlags VkMemoryMapFlags; + typedef VkFlags VkImageAspectFlags; + typedef VkFlags VkSparseMemoryBindFlags; + typedef VkFlags VkSparseImageFormatFlags; + typedef VkFlags VkSubpassDescriptionFlags; + typedef VkFlags VkPipelineStageFlags; + typedef VkFlags VkSampleCountFlags; + typedef VkFlags VkAttachmentDescriptionFlags; + typedef VkFlags VkStencilFaceFlags; + typedef VkFlags VkCullModeFlags; + typedef VkFlags VkDescriptorPoolCreateFlags; + typedef VkFlags VkDescriptorPoolResetFlags; + typedef VkFlags VkDependencyFlags; + typedef VkFlags VkSubgroupFeatureFlags; + typedef VkFlags VkDescriptorUpdateTemplateCreateFlags; + typedef VkFlags VkCompositeAlphaFlagsKHR; + typedef VkFlags VkSurfaceTransformFlagsKHR; + typedef VkFlags VkSwapchainCreateFlagsKHR; + typedef VkFlags VkPeerMemoryFeatureFlags; + typedef VkFlags VkMemoryAllocateFlags; + typedef VkFlags VkDeviceGroupPresentModeFlagsKHR; + typedef VkFlags VkDebugReportFlagsEXT; + typedef VkFlags VkCommandPoolTrimFlags; + typedef VkFlags VkExternalMemoryHandleTypeFlags; + typedef VkFlags VkExternalMemoryFeatureFlags; + typedef VkFlags VkExternalSemaphoreHandleTypeFlags; + typedef VkFlags VkExternalSemaphoreFeatureFlags; + typedef VkFlags VkSemaphoreImportFlags; + typedef VkFlags VkExternalFenceHandleTypeFlags; + typedef VkFlags VkExternalFenceFeatureFlags; + typedef VkFlags VkFenceImportFlags; + typedef VkBool32 (VKAPI_PTR *PFN_vkDebugReportCallbackEXT)( VkDebugReportFlagsEXT flags, VkDebugReportObjectTypeEXT objectType, @@ -1772,6 +2150,7 @@ typedef VkBool32 (VKAPI_PTR *PFN_vkDebugReportCallbackEXT)( const char* pLayerPrefix, const char* pMessage, void* pUserData); + typedef struct VkDeviceQueueCreateInfo { VkStructureType sType; const void * pNext; @@ -1780,6 +2159,7 @@ typedef struct VkDeviceQueueCreateInfo { uint32_t queueCount; const float * pQueuePriorities; } VkDeviceQueueCreateInfo; + typedef struct VkInstanceCreateInfo { VkStructureType sType; const void * pNext; @@ -1790,28 +2170,33 @@ typedef struct VkInstanceCreateInfo { uint32_t enabledExtensionCount; const char * const* ppEnabledExtensionNames; } VkInstanceCreateInfo; + typedef struct VkQueueFamilyProperties { VkQueueFlags queueFlags; uint32_t queueCount; uint32_t timestampValidBits; VkExtent3D minImageTransferGranularity; } VkQueueFamilyProperties; + typedef struct VkMemoryAllocateInfo { VkStructureType sType; const void * pNext; VkDeviceSize allocationSize; uint32_t memoryTypeIndex; } VkMemoryAllocateInfo; + typedef struct VkMemoryRequirements { VkDeviceSize size; VkDeviceSize alignment; uint32_t memoryTypeBits; } VkMemoryRequirements; + typedef struct VkSparseImageFormatProperties { VkImageAspectFlags aspectMask; VkExtent3D imageGranularity; VkSparseImageFormatFlags flags; } VkSparseImageFormatProperties; + typedef struct VkSparseImageMemoryRequirements { VkSparseImageFormatProperties formatProperties; uint32_t imageMipTailFirstLod; @@ -1819,14 +2204,17 @@ typedef struct VkSparseImageMemoryRequirements { VkDeviceSize imageMipTailOffset; VkDeviceSize imageMipTailStride; } VkSparseImageMemoryRequirements; + typedef struct VkMemoryType { VkMemoryPropertyFlags propertyFlags; uint32_t heapIndex; } VkMemoryType; + typedef struct VkMemoryHeap { VkDeviceSize size; VkMemoryHeapFlags flags; } VkMemoryHeap; + typedef struct VkMappedMemoryRange { VkStructureType sType; const void * pNext; @@ -1834,11 +2222,13 @@ typedef struct VkMappedMemoryRange { VkDeviceSize offset; VkDeviceSize size; } VkMappedMemoryRange; + typedef struct VkFormatProperties { VkFormatFeatureFlags linearTilingFeatures; VkFormatFeatureFlags optimalTilingFeatures; VkFormatFeatureFlags bufferFeatures; } VkFormatProperties; + typedef struct VkImageFormatProperties { VkExtent3D maxExtent; uint32_t maxMipLevels; @@ -1846,11 +2236,13 @@ typedef struct VkImageFormatProperties { VkSampleCountFlags sampleCounts; VkDeviceSize maxResourceSize; } VkImageFormatProperties; + typedef struct VkDescriptorBufferInfo { VkBuffer buffer; VkDeviceSize offset; VkDeviceSize range; } VkDescriptorBufferInfo; + typedef struct VkWriteDescriptorSet { VkStructureType sType; const void * pNext; @@ -1863,6 +2255,7 @@ typedef struct VkWriteDescriptorSet { const VkDescriptorBufferInfo * pBufferInfo; const VkBufferView * pTexelBufferView; } VkWriteDescriptorSet; + typedef struct VkBufferCreateInfo { VkStructureType sType; const void * pNext; @@ -1873,6 +2266,7 @@ typedef struct VkBufferCreateInfo { uint32_t queueFamilyIndexCount; const uint32_t * pQueueFamilyIndices; } VkBufferCreateInfo; + typedef struct VkBufferViewCreateInfo { VkStructureType sType; const void * pNext; @@ -1882,17 +2276,20 @@ typedef struct VkBufferViewCreateInfo { VkDeviceSize offset; VkDeviceSize range; } VkBufferViewCreateInfo; + typedef struct VkImageSubresource { VkImageAspectFlags aspectMask; uint32_t mipLevel; uint32_t arrayLayer; } VkImageSubresource; + typedef struct VkImageSubresourceLayers { VkImageAspectFlags aspectMask; uint32_t mipLevel; uint32_t baseArrayLayer; uint32_t layerCount; } VkImageSubresourceLayers; + typedef struct VkImageSubresourceRange { VkImageAspectFlags aspectMask; uint32_t baseMipLevel; @@ -1900,12 +2297,14 @@ typedef struct VkImageSubresourceRange { uint32_t baseArrayLayer; uint32_t layerCount; } VkImageSubresourceRange; + typedef struct VkMemoryBarrier { VkStructureType sType; const void * pNext; VkAccessFlags srcAccessMask; VkAccessFlags dstAccessMask; } VkMemoryBarrier; + typedef struct VkBufferMemoryBarrier { VkStructureType sType; const void * pNext; @@ -1917,6 +2316,7 @@ typedef struct VkBufferMemoryBarrier { VkDeviceSize offset; VkDeviceSize size; } VkBufferMemoryBarrier; + typedef struct VkImageMemoryBarrier { VkStructureType sType; const void * pNext; @@ -1929,6 +2329,7 @@ typedef struct VkImageMemoryBarrier { VkImage image; VkImageSubresourceRange subresourceRange; } VkImageMemoryBarrier; + typedef struct VkImageCreateInfo { VkStructureType sType; const void * pNext; @@ -1946,6 +2347,7 @@ typedef struct VkImageCreateInfo { const uint32_t * pQueueFamilyIndices; VkImageLayout initialLayout; } VkImageCreateInfo; + typedef struct VkSubresourceLayout { VkDeviceSize offset; VkDeviceSize size; @@ -1953,6 +2355,7 @@ typedef struct VkSubresourceLayout { VkDeviceSize arrayPitch; VkDeviceSize depthPitch; } VkSubresourceLayout; + typedef struct VkImageViewCreateInfo { VkStructureType sType; const void * pNext; @@ -1963,11 +2366,13 @@ typedef struct VkImageViewCreateInfo { VkComponentMapping components; VkImageSubresourceRange subresourceRange; } VkImageViewCreateInfo; + typedef struct VkBufferCopy { VkDeviceSize srcOffset; VkDeviceSize dstOffset; VkDeviceSize size; } VkBufferCopy; + typedef struct VkSparseMemoryBind { VkDeviceSize resourceOffset; VkDeviceSize size; @@ -1975,6 +2380,7 @@ typedef struct VkSparseMemoryBind { VkDeviceSize memoryOffset; VkSparseMemoryBindFlags flags; } VkSparseMemoryBind; + typedef struct VkSparseImageMemoryBind { VkImageSubresource subresource; VkOffset3D offset; @@ -1983,21 +2389,25 @@ typedef struct VkSparseImageMemoryBind { VkDeviceSize memoryOffset; VkSparseMemoryBindFlags flags; } VkSparseImageMemoryBind; + typedef struct VkSparseBufferMemoryBindInfo { VkBuffer buffer; uint32_t bindCount; const VkSparseMemoryBind * pBinds; } VkSparseBufferMemoryBindInfo; + typedef struct VkSparseImageOpaqueMemoryBindInfo { VkImage image; uint32_t bindCount; const VkSparseMemoryBind * pBinds; } VkSparseImageOpaqueMemoryBindInfo; + typedef struct VkSparseImageMemoryBindInfo { VkImage image; uint32_t bindCount; const VkSparseImageMemoryBind * pBinds; } VkSparseImageMemoryBindInfo; + typedef struct VkBindSparseInfo { VkStructureType sType; const void * pNext; @@ -2012,6 +2422,7 @@ typedef struct VkBindSparseInfo { uint32_t signalSemaphoreCount; const VkSemaphore * pSignalSemaphores; } VkBindSparseInfo; + typedef struct VkImageCopy { VkImageSubresourceLayers srcSubresource; VkOffset3D srcOffset; @@ -2019,12 +2430,14 @@ typedef struct VkImageCopy { VkOffset3D dstOffset; VkExtent3D extent; } VkImageCopy; + typedef struct VkImageBlit { VkImageSubresourceLayers srcSubresource; VkOffset3D srcOffsets [2]; VkImageSubresourceLayers dstSubresource; VkOffset3D dstOffsets [2]; } VkImageBlit; + typedef struct VkBufferImageCopy { VkDeviceSize bufferOffset; uint32_t bufferRowLength; @@ -2033,6 +2446,7 @@ typedef struct VkBufferImageCopy { VkOffset3D imageOffset; VkExtent3D imageExtent; } VkBufferImageCopy; + typedef struct VkImageResolve { VkImageSubresourceLayers srcSubresource; VkOffset3D srcOffset; @@ -2040,6 +2454,7 @@ typedef struct VkImageResolve { VkOffset3D dstOffset; VkExtent3D extent; } VkImageResolve; + typedef struct VkShaderModuleCreateInfo { VkStructureType sType; const void * pNext; @@ -2047,6 +2462,7 @@ typedef struct VkShaderModuleCreateInfo { size_t codeSize; const uint32_t * pCode; } VkShaderModuleCreateInfo; + typedef struct VkDescriptorSetLayoutBinding { uint32_t binding; VkDescriptorType descriptorType; @@ -2054,6 +2470,7 @@ typedef struct VkDescriptorSetLayoutBinding { VkShaderStageFlags stageFlags; const VkSampler * pImmutableSamplers; } VkDescriptorSetLayoutBinding; + typedef struct VkDescriptorSetLayoutCreateInfo { VkStructureType sType; const void * pNext; @@ -2061,6 +2478,7 @@ typedef struct VkDescriptorSetLayoutCreateInfo { uint32_t bindingCount; const VkDescriptorSetLayoutBinding * pBindings; } VkDescriptorSetLayoutCreateInfo; + typedef struct VkDescriptorPoolCreateInfo { VkStructureType sType; const void * pNext; @@ -2069,6 +2487,7 @@ typedef struct VkDescriptorPoolCreateInfo { uint32_t poolSizeCount; const VkDescriptorPoolSize * pPoolSizes; } VkDescriptorPoolCreateInfo; + typedef struct VkPipelineShaderStageCreateInfo { VkStructureType sType; const void * pNext; @@ -2078,6 +2497,7 @@ typedef struct VkPipelineShaderStageCreateInfo { const char * pName; const VkSpecializationInfo * pSpecializationInfo; } VkPipelineShaderStageCreateInfo; + typedef struct VkComputePipelineCreateInfo { VkStructureType sType; const void * pNext; @@ -2087,6 +2507,7 @@ typedef struct VkComputePipelineCreateInfo { VkPipeline basePipelineHandle; int32_t basePipelineIndex; } VkComputePipelineCreateInfo; + typedef struct VkPipelineVertexInputStateCreateInfo { VkStructureType sType; const void * pNext; @@ -2096,6 +2517,7 @@ typedef struct VkPipelineVertexInputStateCreateInfo { uint32_t vertexAttributeDescriptionCount; const VkVertexInputAttributeDescription * pVertexAttributeDescriptions; } VkPipelineVertexInputStateCreateInfo; + typedef struct VkPipelineInputAssemblyStateCreateInfo { VkStructureType sType; const void * pNext; @@ -2103,12 +2525,14 @@ typedef struct VkPipelineInputAssemblyStateCreateInfo { VkPrimitiveTopology topology; VkBool32 primitiveRestartEnable; } VkPipelineInputAssemblyStateCreateInfo; + typedef struct VkPipelineTessellationStateCreateInfo { VkStructureType sType; const void * pNext; VkPipelineTessellationStateCreateFlags flags; uint32_t patchControlPoints; } VkPipelineTessellationStateCreateInfo; + typedef struct VkPipelineViewportStateCreateInfo { VkStructureType sType; const void * pNext; @@ -2118,6 +2542,7 @@ typedef struct VkPipelineViewportStateCreateInfo { uint32_t scissorCount; const VkRect2D * pScissors; } VkPipelineViewportStateCreateInfo; + typedef struct VkPipelineRasterizationStateCreateInfo { VkStructureType sType; const void * pNext; @@ -2133,6 +2558,7 @@ typedef struct VkPipelineRasterizationStateCreateInfo { float depthBiasSlopeFactor; float lineWidth; } VkPipelineRasterizationStateCreateInfo; + typedef struct VkPipelineMultisampleStateCreateInfo { VkStructureType sType; const void * pNext; @@ -2144,6 +2570,7 @@ typedef struct VkPipelineMultisampleStateCreateInfo { VkBool32 alphaToCoverageEnable; VkBool32 alphaToOneEnable; } VkPipelineMultisampleStateCreateInfo; + typedef struct VkPipelineColorBlendAttachmentState { VkBool32 blendEnable; VkBlendFactor srcColorBlendFactor; @@ -2154,6 +2581,7 @@ typedef struct VkPipelineColorBlendAttachmentState { VkBlendOp alphaBlendOp; VkColorComponentFlags colorWriteMask; } VkPipelineColorBlendAttachmentState; + typedef struct VkPipelineColorBlendStateCreateInfo { VkStructureType sType; const void * pNext; @@ -2164,6 +2592,7 @@ typedef struct VkPipelineColorBlendStateCreateInfo { const VkPipelineColorBlendAttachmentState * pAttachments; float blendConstants [4]; } VkPipelineColorBlendStateCreateInfo; + typedef struct VkPipelineDynamicStateCreateInfo { VkStructureType sType; const void * pNext; @@ -2171,6 +2600,7 @@ typedef struct VkPipelineDynamicStateCreateInfo { uint32_t dynamicStateCount; const VkDynamicState * pDynamicStates; } VkPipelineDynamicStateCreateInfo; + typedef struct VkPipelineDepthStencilStateCreateInfo { VkStructureType sType; const void * pNext; @@ -2185,6 +2615,7 @@ typedef struct VkPipelineDepthStencilStateCreateInfo { float minDepthBounds; float maxDepthBounds; } VkPipelineDepthStencilStateCreateInfo; + typedef struct VkGraphicsPipelineCreateInfo { VkStructureType sType; const void * pNext; @@ -2206,6 +2637,7 @@ typedef struct VkGraphicsPipelineCreateInfo { VkPipeline basePipelineHandle; int32_t basePipelineIndex; } VkGraphicsPipelineCreateInfo; + typedef struct VkPipelineCacheCreateInfo { VkStructureType sType; const void * pNext; @@ -2213,11 +2645,13 @@ typedef struct VkPipelineCacheCreateInfo { size_t initialDataSize; const void * pInitialData; } VkPipelineCacheCreateInfo; + typedef struct VkPushConstantRange { VkShaderStageFlags stageFlags; uint32_t offset; uint32_t size; } VkPushConstantRange; + typedef struct VkPipelineLayoutCreateInfo { VkStructureType sType; const void * pNext; @@ -2227,6 +2661,7 @@ typedef struct VkPipelineLayoutCreateInfo { uint32_t pushConstantRangeCount; const VkPushConstantRange * pPushConstantRanges; } VkPipelineLayoutCreateInfo; + typedef struct VkSamplerCreateInfo { VkStructureType sType; const void * pNext; @@ -2247,12 +2682,14 @@ typedef struct VkSamplerCreateInfo { VkBorderColor borderColor; VkBool32 unnormalizedCoordinates; } VkSamplerCreateInfo; + typedef struct VkCommandPoolCreateInfo { VkStructureType sType; const void * pNext; VkCommandPoolCreateFlags flags; uint32_t queueFamilyIndex; } VkCommandPoolCreateInfo; + typedef struct VkCommandBufferInheritanceInfo { VkStructureType sType; const void * pNext; @@ -2263,12 +2700,14 @@ typedef struct VkCommandBufferInheritanceInfo { VkQueryControlFlags queryFlags; VkQueryPipelineStatisticFlags pipelineStatistics; } VkCommandBufferInheritanceInfo; + typedef struct VkCommandBufferBeginInfo { VkStructureType sType; const void * pNext; VkCommandBufferUsageFlags flags; const VkCommandBufferInheritanceInfo * pInheritanceInfo; } VkCommandBufferBeginInfo; + typedef struct VkRenderPassBeginInfo { VkStructureType sType; const void * pNext; @@ -2278,11 +2717,13 @@ typedef struct VkRenderPassBeginInfo { uint32_t clearValueCount; const VkClearValue * pClearValues; } VkRenderPassBeginInfo; + typedef struct VkClearAttachment { VkImageAspectFlags aspectMask; uint32_t colorAttachment; VkClearValue clearValue; } VkClearAttachment; + typedef struct VkAttachmentDescription { VkAttachmentDescriptionFlags flags; VkFormat format; @@ -2294,6 +2735,7 @@ typedef struct VkAttachmentDescription { VkImageLayout initialLayout; VkImageLayout finalLayout; } VkAttachmentDescription; + typedef struct VkSubpassDescription { VkSubpassDescriptionFlags flags; VkPipelineBindPoint pipelineBindPoint; @@ -2306,6 +2748,7 @@ typedef struct VkSubpassDescription { uint32_t preserveAttachmentCount; const uint32_t * pPreserveAttachments; } VkSubpassDescription; + typedef struct VkSubpassDependency { uint32_t srcSubpass; uint32_t dstSubpass; @@ -2315,10 +2758,11 @@ typedef struct VkSubpassDependency { VkAccessFlags dstAccessMask; VkDependencyFlags dependencyFlags; } VkSubpassDependency; + typedef struct VkRenderPassCreateInfo { VkStructureType sType; const void * pNext; - VkRenderPassCreateFlags flags; + VkRenderPassCreateFlags flags; uint32_t attachmentCount; const VkAttachmentDescription * pAttachments; uint32_t subpassCount; @@ -2326,16 +2770,19 @@ typedef struct VkRenderPassCreateInfo { uint32_t dependencyCount; const VkSubpassDependency * pDependencies; } VkRenderPassCreateInfo; + typedef struct VkEventCreateInfo { VkStructureType sType; const void * pNext; VkEventCreateFlags flags; } VkEventCreateInfo; + typedef struct VkFenceCreateInfo { VkStructureType sType; const void * pNext; VkFenceCreateFlags flags; } VkFenceCreateInfo; + typedef struct VkPhysicalDeviceFeatures { VkBool32 robustBufferAccess; VkBool32 fullDrawIndexUint32; @@ -2393,6 +2840,7 @@ typedef struct VkPhysicalDeviceFeatures { VkBool32 variableMultisampleRate; VkBool32 inheritedQueries; } VkPhysicalDeviceFeatures; + typedef struct VkPhysicalDeviceSparseProperties { VkBool32 residencyStandard2DBlockShape; VkBool32 residencyStandard2DMultisampleBlockShape; @@ -2400,6 +2848,7 @@ typedef struct VkPhysicalDeviceSparseProperties { VkBool32 residencyAlignedMipSize; VkBool32 residencyNonResidentStrict; } VkPhysicalDeviceSparseProperties; + typedef struct VkPhysicalDeviceLimits { uint32_t maxImageDimension1D; uint32_t maxImageDimension2D; @@ -2508,11 +2957,13 @@ typedef struct VkPhysicalDeviceLimits { VkDeviceSize optimalBufferCopyRowPitchAlignment; VkDeviceSize nonCoherentAtomSize; } VkPhysicalDeviceLimits; + typedef struct VkSemaphoreCreateInfo { VkStructureType sType; const void * pNext; VkSemaphoreCreateFlags flags; } VkSemaphoreCreateInfo; + typedef struct VkQueryPoolCreateInfo { VkStructureType sType; const void * pNext; @@ -2521,6 +2972,7 @@ typedef struct VkQueryPoolCreateInfo { uint32_t queryCount; VkQueryPipelineStatisticFlags pipelineStatistics; } VkQueryPoolCreateInfo; + typedef struct VkFramebufferCreateInfo { VkStructureType sType; const void * pNext; @@ -2532,6 +2984,7 @@ typedef struct VkFramebufferCreateInfo { uint32_t height; uint32_t layers; } VkFramebufferCreateInfo; + typedef struct VkSubmitInfo { VkStructureType sType; const void * pNext; @@ -2543,6 +2996,7 @@ typedef struct VkSubmitInfo { uint32_t signalSemaphoreCount; const VkSemaphore * pSignalSemaphores; } VkSubmitInfo; + typedef struct VkSurfaceCapabilitiesKHR { uint32_t minImageCount; uint32_t maxImageCount; @@ -2555,6 +3009,7 @@ typedef struct VkSurfaceCapabilitiesKHR { VkCompositeAlphaFlagsKHR supportedCompositeAlpha; VkImageUsageFlags supportedUsageFlags; } VkSurfaceCapabilitiesKHR; + typedef struct VkSwapchainCreateInfoKHR { VkStructureType sType; const void * pNext; @@ -2575,6 +3030,7 @@ typedef struct VkSwapchainCreateInfoKHR { VkBool32 clipped; VkSwapchainKHR oldSwapchain; } VkSwapchainCreateInfoKHR; + typedef struct VkDebugReportCallbackCreateInfoEXT { VkStructureType sType; const void * pNext; @@ -2582,21 +3038,25 @@ typedef struct VkDebugReportCallbackCreateInfoEXT { PFN_vkDebugReportCallbackEXT pfnCallback; void * pUserData; } VkDebugReportCallbackCreateInfoEXT; + typedef struct VkPhysicalDeviceFeatures2 { VkStructureType sType; void * pNext; VkPhysicalDeviceFeatures features; } VkPhysicalDeviceFeatures2; + typedef struct VkFormatProperties2 { VkStructureType sType; void * pNext; VkFormatProperties formatProperties; } VkFormatProperties2; + typedef struct VkImageFormatProperties2 { VkStructureType sType; void * pNext; VkImageFormatProperties imageFormatProperties; } VkImageFormatProperties2; + typedef struct VkPhysicalDeviceImageFormatInfo2 { VkStructureType sType; const void * pNext; @@ -2606,16 +3066,19 @@ typedef struct VkPhysicalDeviceImageFormatInfo2 { VkImageUsageFlags usage; VkImageCreateFlags flags; } VkPhysicalDeviceImageFormatInfo2; + typedef struct VkQueueFamilyProperties2 { VkStructureType sType; void * pNext; VkQueueFamilyProperties queueFamilyProperties; } VkQueueFamilyProperties2; + typedef struct VkSparseImageFormatProperties2 { VkStructureType sType; void * pNext; VkSparseImageFormatProperties properties; } VkSparseImageFormatProperties2; + typedef struct VkPhysicalDeviceSparseImageFormatInfo2 { VkStructureType sType; const void * pNext; @@ -2625,23 +3088,28 @@ typedef struct VkPhysicalDeviceSparseImageFormatInfo2 { VkImageUsageFlags usage; VkImageTiling tiling; } VkPhysicalDeviceSparseImageFormatInfo2; + typedef struct VkPhysicalDeviceVariablePointersFeatures { VkStructureType sType; void * pNext; VkBool32 variablePointersStorageBuffer; VkBool32 variablePointers; } VkPhysicalDeviceVariablePointersFeatures; -typedef struct VkPhysicalDeviceVariablePointerFeatures VkPhysicalDeviceVariablePointerFeatures; + +typedef struct VkPhysicalDeviceVariablePointersFeatures VkPhysicalDeviceVariablePointerFeatures; + typedef struct VkExternalMemoryProperties { VkExternalMemoryFeatureFlags externalMemoryFeatures; VkExternalMemoryHandleTypeFlags exportFromImportedHandleTypes; VkExternalMemoryHandleTypeFlags compatibleHandleTypes; } VkExternalMemoryProperties; + typedef struct VkExternalImageFormatProperties { VkStructureType sType; void * pNext; VkExternalMemoryProperties externalMemoryProperties; } VkExternalImageFormatProperties; + typedef struct VkPhysicalDeviceExternalBufferInfo { VkStructureType sType; const void * pNext; @@ -2649,11 +3117,13 @@ typedef struct VkPhysicalDeviceExternalBufferInfo { VkBufferUsageFlags usage; VkExternalMemoryHandleTypeFlagBits handleType; } VkPhysicalDeviceExternalBufferInfo; + typedef struct VkExternalBufferProperties { VkStructureType sType; void * pNext; VkExternalMemoryProperties externalMemoryProperties; } VkExternalBufferProperties; + typedef struct VkPhysicalDeviceIDProperties { VkStructureType sType; void * pNext; @@ -2663,21 +3133,25 @@ typedef struct VkPhysicalDeviceIDProperties { uint32_t deviceNodeMask; VkBool32 deviceLUIDValid; } VkPhysicalDeviceIDProperties; + typedef struct VkExternalMemoryImageCreateInfo { VkStructureType sType; const void * pNext; VkExternalMemoryHandleTypeFlags handleTypes; } VkExternalMemoryImageCreateInfo; + typedef struct VkExternalMemoryBufferCreateInfo { VkStructureType sType; const void * pNext; VkExternalMemoryHandleTypeFlags handleTypes; } VkExternalMemoryBufferCreateInfo; + typedef struct VkExportMemoryAllocateInfo { VkStructureType sType; const void * pNext; VkExternalMemoryHandleTypeFlags handleTypes; } VkExportMemoryAllocateInfo; + typedef struct VkExternalSemaphoreProperties { VkStructureType sType; void * pNext; @@ -2685,11 +3159,13 @@ typedef struct VkExternalSemaphoreProperties { VkExternalSemaphoreHandleTypeFlags compatibleHandleTypes; VkExternalSemaphoreFeatureFlags externalSemaphoreFeatures; } VkExternalSemaphoreProperties; + typedef struct VkExportSemaphoreCreateInfo { VkStructureType sType; const void * pNext; VkExternalSemaphoreHandleTypeFlags handleTypes; } VkExportSemaphoreCreateInfo; + typedef struct VkExternalFenceProperties { VkStructureType sType; void * pNext; @@ -2697,11 +3173,13 @@ typedef struct VkExternalFenceProperties { VkExternalFenceHandleTypeFlags compatibleHandleTypes; VkExternalFenceFeatureFlags externalFenceFeatures; } VkExternalFenceProperties; + typedef struct VkExportFenceCreateInfo { VkStructureType sType; const void * pNext; VkExternalFenceHandleTypeFlags handleTypes; } VkExportFenceCreateInfo; + typedef struct VkPhysicalDeviceMultiviewFeatures { VkStructureType sType; void * pNext; @@ -2709,6 +3187,7 @@ typedef struct VkPhysicalDeviceMultiviewFeatures { VkBool32 multiviewGeometryShader; VkBool32 multiviewTessellationShader; } VkPhysicalDeviceMultiviewFeatures; + typedef struct VkPhysicalDeviceGroupProperties { VkStructureType sType; void * pNext; @@ -2716,12 +3195,14 @@ typedef struct VkPhysicalDeviceGroupProperties { VkPhysicalDevice physicalDevices [ VK_MAX_DEVICE_GROUP_SIZE ]; VkBool32 subsetAllocation; } VkPhysicalDeviceGroupProperties; + typedef struct VkMemoryAllocateFlagsInfo { VkStructureType sType; const void * pNext; VkMemoryAllocateFlags flags; uint32_t deviceMask; } VkMemoryAllocateFlagsInfo; + typedef struct VkBindBufferMemoryInfo { VkStructureType sType; const void * pNext; @@ -2729,6 +3210,7 @@ typedef struct VkBindBufferMemoryInfo { VkDeviceMemory memory; VkDeviceSize memoryOffset; } VkBindBufferMemoryInfo; + typedef struct VkBindImageMemoryInfo { VkStructureType sType; const void * pNext; @@ -2736,17 +3218,20 @@ typedef struct VkBindImageMemoryInfo { VkDeviceMemory memory; VkDeviceSize memoryOffset; } VkBindImageMemoryInfo; + typedef struct VkDeviceGroupPresentCapabilitiesKHR { VkStructureType sType; const void * pNext; uint32_t presentMask [ VK_MAX_DEVICE_GROUP_SIZE ]; VkDeviceGroupPresentModeFlagsKHR modes; } VkDeviceGroupPresentCapabilitiesKHR; + typedef struct VkDeviceGroupSwapchainCreateInfoKHR { VkStructureType sType; const void * pNext; VkDeviceGroupPresentModeFlagsKHR modes; } VkDeviceGroupSwapchainCreateInfoKHR; + typedef struct VkDescriptorUpdateTemplateCreateInfo { VkStructureType sType; const void * pNext; @@ -2759,17 +3244,20 @@ typedef struct VkDescriptorUpdateTemplateCreateInfo { VkPipelineLayout pipelineLayout; uint32_t set; } VkDescriptorUpdateTemplateCreateInfo; + typedef struct VkInputAttachmentAspectReference { uint32_t subpass; uint32_t inputAttachmentIndex; VkImageAspectFlags aspectMask; } VkInputAttachmentAspectReference; + typedef struct VkRenderPassInputAttachmentAspectCreateInfo { VkStructureType sType; const void * pNext; uint32_t aspectReferenceCount; const VkInputAttachmentAspectReference * pAspectReferences; } VkRenderPassInputAttachmentAspectCreateInfo; + typedef struct VkPhysicalDevice16BitStorageFeatures { VkStructureType sType; void * pNext; @@ -2778,6 +3266,7 @@ typedef struct VkPhysicalDevice16BitStorageFeatures { VkBool32 storagePushConstant16; VkBool32 storageInputOutput16; } VkPhysicalDevice16BitStorageFeatures; + typedef struct VkPhysicalDeviceSubgroupProperties { VkStructureType sType; void * pNext; @@ -2786,28 +3275,32 @@ typedef struct VkPhysicalDeviceSubgroupProperties { VkSubgroupFeatureFlags supportedOperations; VkBool32 quadOperationsInAllStages; } VkPhysicalDeviceSubgroupProperties; + typedef struct VkMemoryRequirements2 { VkStructureType sType; void * pNext; VkMemoryRequirements memoryRequirements; } VkMemoryRequirements2; -typedef struct VkMemoryRequirements2KHR VkMemoryRequirements2KHR; + typedef struct VkSparseImageMemoryRequirements2 { VkStructureType sType; void * pNext; VkSparseImageMemoryRequirements memoryRequirements; } VkSparseImageMemoryRequirements2; + typedef struct VkMemoryDedicatedRequirements { VkStructureType sType; void * pNext; VkBool32 prefersDedicatedAllocation; VkBool32 requiresDedicatedAllocation; } VkMemoryDedicatedRequirements; + typedef struct VkImageViewUsageCreateInfo { VkStructureType sType; const void * pNext; VkImageUsageFlags usage; } VkImageViewUsageCreateInfo; + typedef struct VkSamplerYcbcrConversionCreateInfo { VkStructureType sType; const void * pNext; @@ -2820,26 +3313,31 @@ typedef struct VkSamplerYcbcrConversionCreateInfo { VkFilter chromaFilter; VkBool32 forceExplicitReconstruction; } VkSamplerYcbcrConversionCreateInfo; + typedef struct VkPhysicalDeviceSamplerYcbcrConversionFeatures { VkStructureType sType; void * pNext; VkBool32 samplerYcbcrConversion; } VkPhysicalDeviceSamplerYcbcrConversionFeatures; + typedef struct VkProtectedSubmitInfo { VkStructureType sType; const void * pNext; VkBool32 protectedSubmit; } VkProtectedSubmitInfo; + typedef struct VkPhysicalDeviceProtectedMemoryFeatures { VkStructureType sType; void * pNext; VkBool32 protectedMemory; } VkPhysicalDeviceProtectedMemoryFeatures; + typedef struct VkPhysicalDeviceProtectedMemoryProperties { VkStructureType sType; void * pNext; VkBool32 protectedNoFault; } VkPhysicalDeviceProtectedMemoryProperties; + typedef struct VkDeviceQueueInfo2 { VkStructureType sType; const void * pNext; @@ -2847,23 +3345,28 @@ typedef struct VkDeviceQueueInfo2 { uint32_t queueFamilyIndex; uint32_t queueIndex; } VkDeviceQueueInfo2; + typedef struct VkPhysicalDeviceMaintenance3Properties { VkStructureType sType; void * pNext; uint32_t maxPerSetDescriptors; VkDeviceSize maxMemoryAllocationSize; } VkPhysicalDeviceMaintenance3Properties; + typedef struct VkDescriptorSetLayoutSupport { VkStructureType sType; void * pNext; VkBool32 supported; } VkDescriptorSetLayoutSupport; + typedef struct VkPhysicalDeviceShaderDrawParametersFeatures { VkStructureType sType; void * pNext; VkBool32 shaderDrawParameters; } VkPhysicalDeviceShaderDrawParametersFeatures; -typedef struct VkPhysicalDeviceShaderDrawParameterFeatures VkPhysicalDeviceShaderDrawParameterFeatures; + +typedef struct VkPhysicalDeviceShaderDrawParametersFeatures VkPhysicalDeviceShaderDrawParameterFeatures; + typedef struct VkPhysicalDeviceProperties { uint32_t apiVersion; uint32_t driverVersion; @@ -2875,6 +3378,7 @@ typedef struct VkPhysicalDeviceProperties { VkPhysicalDeviceLimits limits; VkPhysicalDeviceSparseProperties sparseProperties; } VkPhysicalDeviceProperties; + typedef struct VkDeviceCreateInfo { VkStructureType sType; const void * pNext; @@ -2887,17 +3391,20 @@ typedef struct VkDeviceCreateInfo { const char * const* ppEnabledExtensionNames; const VkPhysicalDeviceFeatures * pEnabledFeatures; } VkDeviceCreateInfo; + typedef struct VkPhysicalDeviceMemoryProperties { uint32_t memoryTypeCount; VkMemoryType memoryTypes [ VK_MAX_MEMORY_TYPES ]; uint32_t memoryHeapCount; VkMemoryHeap memoryHeaps [ VK_MAX_MEMORY_HEAPS ]; } VkPhysicalDeviceMemoryProperties; + typedef struct VkPhysicalDeviceProperties2 { VkStructureType sType; void * pNext; VkPhysicalDeviceProperties properties; } VkPhysicalDeviceProperties2; + typedef struct VkPhysicalDeviceMemoryProperties2 { VkStructureType sType; void * pNext; @@ -2905,6 +3412,7 @@ typedef struct VkPhysicalDeviceMemoryProperties2 { } VkPhysicalDeviceMemoryProperties2; + #define VK_VERSION_1_0 1 GLAD_API_CALL int GLAD_VK_VERSION_1_0; #define VK_VERSION_1_1 1 @@ -2917,188 +3425,188 @@ GLAD_API_CALL int GLAD_VK_KHR_surface; GLAD_API_CALL int GLAD_VK_KHR_swapchain; -typedef VkResult (GLAD_API_PTR *PFN_vkAcquireNextImage2KHR)(VkDevice device, const VkAcquireNextImageInfoKHR * pAcquireInfo, uint32_t * pImageIndex); -typedef VkResult (GLAD_API_PTR *PFN_vkAcquireNextImageKHR)(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout, VkSemaphore semaphore, VkFence fence, uint32_t * pImageIndex); -typedef VkResult (GLAD_API_PTR *PFN_vkAllocateCommandBuffers)(VkDevice device, const VkCommandBufferAllocateInfo * pAllocateInfo, VkCommandBuffer * pCommandBuffers); -typedef VkResult (GLAD_API_PTR *PFN_vkAllocateDescriptorSets)(VkDevice device, const VkDescriptorSetAllocateInfo * pAllocateInfo, VkDescriptorSet * pDescriptorSets); -typedef VkResult (GLAD_API_PTR *PFN_vkAllocateMemory)(VkDevice device, const VkMemoryAllocateInfo * pAllocateInfo, const VkAllocationCallbacks * pAllocator, VkDeviceMemory * pMemory); -typedef VkResult (GLAD_API_PTR *PFN_vkBeginCommandBuffer)(VkCommandBuffer commandBuffer, const VkCommandBufferBeginInfo * pBeginInfo); -typedef VkResult (GLAD_API_PTR *PFN_vkBindBufferMemory)(VkDevice device, VkBuffer buffer, VkDeviceMemory memory, VkDeviceSize memoryOffset); -typedef VkResult (GLAD_API_PTR *PFN_vkBindBufferMemory2)(VkDevice device, uint32_t bindInfoCount, const VkBindBufferMemoryInfo * pBindInfos); -typedef VkResult (GLAD_API_PTR *PFN_vkBindImageMemory)(VkDevice device, VkImage image, VkDeviceMemory memory, VkDeviceSize memoryOffset); -typedef VkResult (GLAD_API_PTR *PFN_vkBindImageMemory2)(VkDevice device, uint32_t bindInfoCount, const VkBindImageMemoryInfo * pBindInfos); -typedef void (GLAD_API_PTR *PFN_vkCmdBeginQuery)(VkCommandBuffer commandBuffer, VkQueryPool queryPool, uint32_t query, VkQueryControlFlags flags); -typedef void (GLAD_API_PTR *PFN_vkCmdBeginRenderPass)(VkCommandBuffer commandBuffer, const VkRenderPassBeginInfo * pRenderPassBegin, VkSubpassContents contents); -typedef void (GLAD_API_PTR *PFN_vkCmdBindDescriptorSets)(VkCommandBuffer commandBuffer, VkPipelineBindPoint pipelineBindPoint, VkPipelineLayout layout, uint32_t firstSet, uint32_t descriptorSetCount, const VkDescriptorSet * pDescriptorSets, uint32_t dynamicOffsetCount, const uint32_t * pDynamicOffsets); -typedef void (GLAD_API_PTR *PFN_vkCmdBindIndexBuffer)(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, VkIndexType indexType); -typedef void (GLAD_API_PTR *PFN_vkCmdBindPipeline)(VkCommandBuffer commandBuffer, VkPipelineBindPoint pipelineBindPoint, VkPipeline pipeline); -typedef void (GLAD_API_PTR *PFN_vkCmdBindVertexBuffers)(VkCommandBuffer commandBuffer, uint32_t firstBinding, uint32_t bindingCount, const VkBuffer * pBuffers, const VkDeviceSize * pOffsets); -typedef void (GLAD_API_PTR *PFN_vkCmdBlitImage)(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount, const VkImageBlit * pRegions, VkFilter filter); -typedef void (GLAD_API_PTR *PFN_vkCmdClearAttachments)(VkCommandBuffer commandBuffer, uint32_t attachmentCount, const VkClearAttachment * pAttachments, uint32_t rectCount, const VkClearRect * pRects); -typedef void (GLAD_API_PTR *PFN_vkCmdClearColorImage)(VkCommandBuffer commandBuffer, VkImage image, VkImageLayout imageLayout, const VkClearColorValue * pColor, uint32_t rangeCount, const VkImageSubresourceRange * pRanges); -typedef void (GLAD_API_PTR *PFN_vkCmdClearDepthStencilImage)(VkCommandBuffer commandBuffer, VkImage image, VkImageLayout imageLayout, const VkClearDepthStencilValue * pDepthStencil, uint32_t rangeCount, const VkImageSubresourceRange * pRanges); -typedef void (GLAD_API_PTR *PFN_vkCmdCopyBuffer)(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer, uint32_t regionCount, const VkBufferCopy * pRegions); -typedef void (GLAD_API_PTR *PFN_vkCmdCopyBufferToImage)(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount, const VkBufferImageCopy * pRegions); -typedef void (GLAD_API_PTR *PFN_vkCmdCopyImage)(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount, const VkImageCopy * pRegions); -typedef void (GLAD_API_PTR *PFN_vkCmdCopyImageToBuffer)(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkBuffer dstBuffer, uint32_t regionCount, const VkBufferImageCopy * pRegions); -typedef void (GLAD_API_PTR *PFN_vkCmdCopyQueryPoolResults)(VkCommandBuffer commandBuffer, VkQueryPool queryPool, uint32_t firstQuery, uint32_t queryCount, VkBuffer dstBuffer, VkDeviceSize dstOffset, VkDeviceSize stride, VkQueryResultFlags flags); -typedef void (GLAD_API_PTR *PFN_vkCmdDispatch)(VkCommandBuffer commandBuffer, uint32_t groupCountX, uint32_t groupCountY, uint32_t groupCountZ); -typedef void (GLAD_API_PTR *PFN_vkCmdDispatchBase)(VkCommandBuffer commandBuffer, uint32_t baseGroupX, uint32_t baseGroupY, uint32_t baseGroupZ, uint32_t groupCountX, uint32_t groupCountY, uint32_t groupCountZ); -typedef void (GLAD_API_PTR *PFN_vkCmdDispatchIndirect)(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset); -typedef void (GLAD_API_PTR *PFN_vkCmdDraw)(VkCommandBuffer commandBuffer, uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance); -typedef void (GLAD_API_PTR *PFN_vkCmdDrawIndexed)(VkCommandBuffer commandBuffer, uint32_t indexCount, uint32_t instanceCount, uint32_t firstIndex, int32_t vertexOffset, uint32_t firstInstance); -typedef void (GLAD_API_PTR *PFN_vkCmdDrawIndexedIndirect)(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t drawCount, uint32_t stride); -typedef void (GLAD_API_PTR *PFN_vkCmdDrawIndirect)(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t drawCount, uint32_t stride); -typedef void (GLAD_API_PTR *PFN_vkCmdEndQuery)(VkCommandBuffer commandBuffer, VkQueryPool queryPool, uint32_t query); -typedef void (GLAD_API_PTR *PFN_vkCmdEndRenderPass)(VkCommandBuffer commandBuffer); -typedef void (GLAD_API_PTR *PFN_vkCmdExecuteCommands)(VkCommandBuffer commandBuffer, uint32_t commandBufferCount, const VkCommandBuffer * pCommandBuffers); -typedef void (GLAD_API_PTR *PFN_vkCmdFillBuffer)(VkCommandBuffer commandBuffer, VkBuffer dstBuffer, VkDeviceSize dstOffset, VkDeviceSize size, uint32_t data); -typedef void (GLAD_API_PTR *PFN_vkCmdNextSubpass)(VkCommandBuffer commandBuffer, VkSubpassContents contents); -typedef void (GLAD_API_PTR *PFN_vkCmdPipelineBarrier)(VkCommandBuffer commandBuffer, VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkDependencyFlags dependencyFlags, uint32_t memoryBarrierCount, const VkMemoryBarrier * pMemoryBarriers, uint32_t bufferMemoryBarrierCount, const VkBufferMemoryBarrier * pBufferMemoryBarriers, uint32_t imageMemoryBarrierCount, const VkImageMemoryBarrier * pImageMemoryBarriers); -typedef void (GLAD_API_PTR *PFN_vkCmdPushConstants)(VkCommandBuffer commandBuffer, VkPipelineLayout layout, VkShaderStageFlags stageFlags, uint32_t offset, uint32_t size, const void * pValues); -typedef void (GLAD_API_PTR *PFN_vkCmdResetEvent)(VkCommandBuffer commandBuffer, VkEvent event, VkPipelineStageFlags stageMask); -typedef void (GLAD_API_PTR *PFN_vkCmdResetQueryPool)(VkCommandBuffer commandBuffer, VkQueryPool queryPool, uint32_t firstQuery, uint32_t queryCount); -typedef void (GLAD_API_PTR *PFN_vkCmdResolveImage)(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount, const VkImageResolve * pRegions); -typedef void (GLAD_API_PTR *PFN_vkCmdSetBlendConstants)(VkCommandBuffer commandBuffer, const float blendConstants [4]); -typedef void (GLAD_API_PTR *PFN_vkCmdSetDepthBias)(VkCommandBuffer commandBuffer, float depthBiasConstantFactor, float depthBiasClamp, float depthBiasSlopeFactor); -typedef void (GLAD_API_PTR *PFN_vkCmdSetDepthBounds)(VkCommandBuffer commandBuffer, float minDepthBounds, float maxDepthBounds); -typedef void (GLAD_API_PTR *PFN_vkCmdSetDeviceMask)(VkCommandBuffer commandBuffer, uint32_t deviceMask); -typedef void (GLAD_API_PTR *PFN_vkCmdSetEvent)(VkCommandBuffer commandBuffer, VkEvent event, VkPipelineStageFlags stageMask); -typedef void (GLAD_API_PTR *PFN_vkCmdSetLineWidth)(VkCommandBuffer commandBuffer, float lineWidth); -typedef void (GLAD_API_PTR *PFN_vkCmdSetScissor)(VkCommandBuffer commandBuffer, uint32_t firstScissor, uint32_t scissorCount, const VkRect2D * pScissors); -typedef void (GLAD_API_PTR *PFN_vkCmdSetStencilCompareMask)(VkCommandBuffer commandBuffer, VkStencilFaceFlags faceMask, uint32_t compareMask); -typedef void (GLAD_API_PTR *PFN_vkCmdSetStencilReference)(VkCommandBuffer commandBuffer, VkStencilFaceFlags faceMask, uint32_t reference); -typedef void (GLAD_API_PTR *PFN_vkCmdSetStencilWriteMask)(VkCommandBuffer commandBuffer, VkStencilFaceFlags faceMask, uint32_t writeMask); -typedef void (GLAD_API_PTR *PFN_vkCmdSetViewport)(VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount, const VkViewport * pViewports); -typedef void (GLAD_API_PTR *PFN_vkCmdUpdateBuffer)(VkCommandBuffer commandBuffer, VkBuffer dstBuffer, VkDeviceSize dstOffset, VkDeviceSize dataSize, const void * pData); -typedef void (GLAD_API_PTR *PFN_vkCmdWaitEvents)(VkCommandBuffer commandBuffer, uint32_t eventCount, const VkEvent * pEvents, VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, uint32_t memoryBarrierCount, const VkMemoryBarrier * pMemoryBarriers, uint32_t bufferMemoryBarrierCount, const VkBufferMemoryBarrier * pBufferMemoryBarriers, uint32_t imageMemoryBarrierCount, const VkImageMemoryBarrier * pImageMemoryBarriers); -typedef void (GLAD_API_PTR *PFN_vkCmdWriteTimestamp)(VkCommandBuffer commandBuffer, VkPipelineStageFlagBits pipelineStage, VkQueryPool queryPool, uint32_t query); -typedef VkResult (GLAD_API_PTR *PFN_vkCreateBuffer)(VkDevice device, const VkBufferCreateInfo * pCreateInfo, const VkAllocationCallbacks * pAllocator, VkBuffer * pBuffer); -typedef VkResult (GLAD_API_PTR *PFN_vkCreateBufferView)(VkDevice device, const VkBufferViewCreateInfo * pCreateInfo, const VkAllocationCallbacks * pAllocator, VkBufferView * pView); -typedef VkResult (GLAD_API_PTR *PFN_vkCreateCommandPool)(VkDevice device, const VkCommandPoolCreateInfo * pCreateInfo, const VkAllocationCallbacks * pAllocator, VkCommandPool * pCommandPool); -typedef VkResult (GLAD_API_PTR *PFN_vkCreateComputePipelines)(VkDevice device, VkPipelineCache pipelineCache, uint32_t createInfoCount, const VkComputePipelineCreateInfo * pCreateInfos, const VkAllocationCallbacks * pAllocator, VkPipeline * pPipelines); -typedef VkResult (GLAD_API_PTR *PFN_vkCreateDebugReportCallbackEXT)(VkInstance instance, const VkDebugReportCallbackCreateInfoEXT * pCreateInfo, const VkAllocationCallbacks * pAllocator, VkDebugReportCallbackEXT * pCallback); -typedef VkResult (GLAD_API_PTR *PFN_vkCreateDescriptorPool)(VkDevice device, const VkDescriptorPoolCreateInfo * pCreateInfo, const VkAllocationCallbacks * pAllocator, VkDescriptorPool * pDescriptorPool); -typedef VkResult (GLAD_API_PTR *PFN_vkCreateDescriptorSetLayout)(VkDevice device, const VkDescriptorSetLayoutCreateInfo * pCreateInfo, const VkAllocationCallbacks * pAllocator, VkDescriptorSetLayout * pSetLayout); -typedef VkResult (GLAD_API_PTR *PFN_vkCreateDescriptorUpdateTemplate)(VkDevice device, const VkDescriptorUpdateTemplateCreateInfo * pCreateInfo, const VkAllocationCallbacks * pAllocator, VkDescriptorUpdateTemplate * pDescriptorUpdateTemplate); -typedef VkResult (GLAD_API_PTR *PFN_vkCreateDevice)(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo * pCreateInfo, const VkAllocationCallbacks * pAllocator, VkDevice * pDevice); -typedef VkResult (GLAD_API_PTR *PFN_vkCreateEvent)(VkDevice device, const VkEventCreateInfo * pCreateInfo, const VkAllocationCallbacks * pAllocator, VkEvent * pEvent); -typedef VkResult (GLAD_API_PTR *PFN_vkCreateFence)(VkDevice device, const VkFenceCreateInfo * pCreateInfo, const VkAllocationCallbacks * pAllocator, VkFence * pFence); -typedef VkResult (GLAD_API_PTR *PFN_vkCreateFramebuffer)(VkDevice device, const VkFramebufferCreateInfo * pCreateInfo, const VkAllocationCallbacks * pAllocator, VkFramebuffer * pFramebuffer); -typedef VkResult (GLAD_API_PTR *PFN_vkCreateGraphicsPipelines)(VkDevice device, VkPipelineCache pipelineCache, uint32_t createInfoCount, const VkGraphicsPipelineCreateInfo * pCreateInfos, const VkAllocationCallbacks * pAllocator, VkPipeline * pPipelines); -typedef VkResult (GLAD_API_PTR *PFN_vkCreateImage)(VkDevice device, const VkImageCreateInfo * pCreateInfo, const VkAllocationCallbacks * pAllocator, VkImage * pImage); -typedef VkResult (GLAD_API_PTR *PFN_vkCreateImageView)(VkDevice device, const VkImageViewCreateInfo * pCreateInfo, const VkAllocationCallbacks * pAllocator, VkImageView * pView); -typedef VkResult (GLAD_API_PTR *PFN_vkCreateInstance)(const VkInstanceCreateInfo * pCreateInfo, const VkAllocationCallbacks * pAllocator, VkInstance * pInstance); -typedef VkResult (GLAD_API_PTR *PFN_vkCreatePipelineCache)(VkDevice device, const VkPipelineCacheCreateInfo * pCreateInfo, const VkAllocationCallbacks * pAllocator, VkPipelineCache * pPipelineCache); -typedef VkResult (GLAD_API_PTR *PFN_vkCreatePipelineLayout)(VkDevice device, const VkPipelineLayoutCreateInfo * pCreateInfo, const VkAllocationCallbacks * pAllocator, VkPipelineLayout * pPipelineLayout); -typedef VkResult (GLAD_API_PTR *PFN_vkCreateQueryPool)(VkDevice device, const VkQueryPoolCreateInfo * pCreateInfo, const VkAllocationCallbacks * pAllocator, VkQueryPool * pQueryPool); -typedef VkResult (GLAD_API_PTR *PFN_vkCreateRenderPass)(VkDevice device, const VkRenderPassCreateInfo * pCreateInfo, const VkAllocationCallbacks * pAllocator, VkRenderPass * pRenderPass); -typedef VkResult (GLAD_API_PTR *PFN_vkCreateSampler)(VkDevice device, const VkSamplerCreateInfo * pCreateInfo, const VkAllocationCallbacks * pAllocator, VkSampler * pSampler); -typedef VkResult (GLAD_API_PTR *PFN_vkCreateSamplerYcbcrConversion)(VkDevice device, const VkSamplerYcbcrConversionCreateInfo * pCreateInfo, const VkAllocationCallbacks * pAllocator, VkSamplerYcbcrConversion * pYcbcrConversion); -typedef VkResult (GLAD_API_PTR *PFN_vkCreateSemaphore)(VkDevice device, const VkSemaphoreCreateInfo * pCreateInfo, const VkAllocationCallbacks * pAllocator, VkSemaphore * pSemaphore); -typedef VkResult (GLAD_API_PTR *PFN_vkCreateShaderModule)(VkDevice device, const VkShaderModuleCreateInfo * pCreateInfo, const VkAllocationCallbacks * pAllocator, VkShaderModule * pShaderModule); -typedef VkResult (GLAD_API_PTR *PFN_vkCreateSwapchainKHR)(VkDevice device, const VkSwapchainCreateInfoKHR * pCreateInfo, const VkAllocationCallbacks * pAllocator, VkSwapchainKHR * pSwapchain); -typedef void (GLAD_API_PTR *PFN_vkDebugReportMessageEXT)(VkInstance instance, VkDebugReportFlagsEXT flags, VkDebugReportObjectTypeEXT objectType, uint64_t object, size_t location, int32_t messageCode, const char * pLayerPrefix, const char * pMessage); -typedef void (GLAD_API_PTR *PFN_vkDestroyBuffer)(VkDevice device, VkBuffer buffer, const VkAllocationCallbacks * pAllocator); -typedef void (GLAD_API_PTR *PFN_vkDestroyBufferView)(VkDevice device, VkBufferView bufferView, const VkAllocationCallbacks * pAllocator); -typedef void (GLAD_API_PTR *PFN_vkDestroyCommandPool)(VkDevice device, VkCommandPool commandPool, const VkAllocationCallbacks * pAllocator); -typedef void (GLAD_API_PTR *PFN_vkDestroyDebugReportCallbackEXT)(VkInstance instance, VkDebugReportCallbackEXT callback, const VkAllocationCallbacks * pAllocator); -typedef void (GLAD_API_PTR *PFN_vkDestroyDescriptorPool)(VkDevice device, VkDescriptorPool descriptorPool, const VkAllocationCallbacks * pAllocator); -typedef void (GLAD_API_PTR *PFN_vkDestroyDescriptorSetLayout)(VkDevice device, VkDescriptorSetLayout descriptorSetLayout, const VkAllocationCallbacks * pAllocator); -typedef void (GLAD_API_PTR *PFN_vkDestroyDescriptorUpdateTemplate)(VkDevice device, VkDescriptorUpdateTemplate descriptorUpdateTemplate, const VkAllocationCallbacks * pAllocator); -typedef void (GLAD_API_PTR *PFN_vkDestroyDevice)(VkDevice device, const VkAllocationCallbacks * pAllocator); -typedef void (GLAD_API_PTR *PFN_vkDestroyEvent)(VkDevice device, VkEvent event, const VkAllocationCallbacks * pAllocator); -typedef void (GLAD_API_PTR *PFN_vkDestroyFence)(VkDevice device, VkFence fence, const VkAllocationCallbacks * pAllocator); -typedef void (GLAD_API_PTR *PFN_vkDestroyFramebuffer)(VkDevice device, VkFramebuffer framebuffer, const VkAllocationCallbacks * pAllocator); -typedef void (GLAD_API_PTR *PFN_vkDestroyImage)(VkDevice device, VkImage image, const VkAllocationCallbacks * pAllocator); -typedef void (GLAD_API_PTR *PFN_vkDestroyImageView)(VkDevice device, VkImageView imageView, const VkAllocationCallbacks * pAllocator); -typedef void (GLAD_API_PTR *PFN_vkDestroyInstance)(VkInstance instance, const VkAllocationCallbacks * pAllocator); -typedef void (GLAD_API_PTR *PFN_vkDestroyPipeline)(VkDevice device, VkPipeline pipeline, const VkAllocationCallbacks * pAllocator); -typedef void (GLAD_API_PTR *PFN_vkDestroyPipelineCache)(VkDevice device, VkPipelineCache pipelineCache, const VkAllocationCallbacks * pAllocator); -typedef void (GLAD_API_PTR *PFN_vkDestroyPipelineLayout)(VkDevice device, VkPipelineLayout pipelineLayout, const VkAllocationCallbacks * pAllocator); -typedef void (GLAD_API_PTR *PFN_vkDestroyQueryPool)(VkDevice device, VkQueryPool queryPool, const VkAllocationCallbacks * pAllocator); -typedef void (GLAD_API_PTR *PFN_vkDestroyRenderPass)(VkDevice device, VkRenderPass renderPass, const VkAllocationCallbacks * pAllocator); -typedef void (GLAD_API_PTR *PFN_vkDestroySampler)(VkDevice device, VkSampler sampler, const VkAllocationCallbacks * pAllocator); -typedef void (GLAD_API_PTR *PFN_vkDestroySamplerYcbcrConversion)(VkDevice device, VkSamplerYcbcrConversion ycbcrConversion, const VkAllocationCallbacks * pAllocator); -typedef void (GLAD_API_PTR *PFN_vkDestroySemaphore)(VkDevice device, VkSemaphore semaphore, const VkAllocationCallbacks * pAllocator); -typedef void (GLAD_API_PTR *PFN_vkDestroyShaderModule)(VkDevice device, VkShaderModule shaderModule, const VkAllocationCallbacks * pAllocator); -typedef void (GLAD_API_PTR *PFN_vkDestroySurfaceKHR)(VkInstance instance, VkSurfaceKHR surface, const VkAllocationCallbacks * pAllocator); -typedef void (GLAD_API_PTR *PFN_vkDestroySwapchainKHR)(VkDevice device, VkSwapchainKHR swapchain, const VkAllocationCallbacks * pAllocator); -typedef VkResult (GLAD_API_PTR *PFN_vkDeviceWaitIdle)(VkDevice device); -typedef VkResult (GLAD_API_PTR *PFN_vkEndCommandBuffer)(VkCommandBuffer commandBuffer); -typedef VkResult (GLAD_API_PTR *PFN_vkEnumerateDeviceExtensionProperties)(VkPhysicalDevice physicalDevice, const char * pLayerName, uint32_t * pPropertyCount, VkExtensionProperties * pProperties); -typedef VkResult (GLAD_API_PTR *PFN_vkEnumerateDeviceLayerProperties)(VkPhysicalDevice physicalDevice, uint32_t * pPropertyCount, VkLayerProperties * pProperties); -typedef VkResult (GLAD_API_PTR *PFN_vkEnumerateInstanceExtensionProperties)(const char * pLayerName, uint32_t * pPropertyCount, VkExtensionProperties * pProperties); -typedef VkResult (GLAD_API_PTR *PFN_vkEnumerateInstanceLayerProperties)(uint32_t * pPropertyCount, VkLayerProperties * pProperties); -typedef VkResult (GLAD_API_PTR *PFN_vkEnumerateInstanceVersion)(uint32_t * pApiVersion); -typedef VkResult (GLAD_API_PTR *PFN_vkEnumeratePhysicalDeviceGroups)(VkInstance instance, uint32_t * pPhysicalDeviceGroupCount, VkPhysicalDeviceGroupProperties * pPhysicalDeviceGroupProperties); -typedef VkResult (GLAD_API_PTR *PFN_vkEnumeratePhysicalDevices)(VkInstance instance, uint32_t * pPhysicalDeviceCount, VkPhysicalDevice * pPhysicalDevices); -typedef VkResult (GLAD_API_PTR *PFN_vkFlushMappedMemoryRanges)(VkDevice device, uint32_t memoryRangeCount, const VkMappedMemoryRange * pMemoryRanges); -typedef void (GLAD_API_PTR *PFN_vkFreeCommandBuffers)(VkDevice device, VkCommandPool commandPool, uint32_t commandBufferCount, const VkCommandBuffer * pCommandBuffers); -typedef VkResult (GLAD_API_PTR *PFN_vkFreeDescriptorSets)(VkDevice device, VkDescriptorPool descriptorPool, uint32_t descriptorSetCount, const VkDescriptorSet * pDescriptorSets); -typedef void (GLAD_API_PTR *PFN_vkFreeMemory)(VkDevice device, VkDeviceMemory memory, const VkAllocationCallbacks * pAllocator); -typedef void (GLAD_API_PTR *PFN_vkGetBufferMemoryRequirements)(VkDevice device, VkBuffer buffer, VkMemoryRequirements * pMemoryRequirements); -typedef void (GLAD_API_PTR *PFN_vkGetBufferMemoryRequirements2)(VkDevice device, const VkBufferMemoryRequirementsInfo2 * pInfo, VkMemoryRequirements2 * pMemoryRequirements); -typedef void (GLAD_API_PTR *PFN_vkGetDescriptorSetLayoutSupport)(VkDevice device, const VkDescriptorSetLayoutCreateInfo * pCreateInfo, VkDescriptorSetLayoutSupport * pSupport); -typedef void (GLAD_API_PTR *PFN_vkGetDeviceGroupPeerMemoryFeatures)(VkDevice device, uint32_t heapIndex, uint32_t localDeviceIndex, uint32_t remoteDeviceIndex, VkPeerMemoryFeatureFlags * pPeerMemoryFeatures); -typedef VkResult (GLAD_API_PTR *PFN_vkGetDeviceGroupPresentCapabilitiesKHR)(VkDevice device, VkDeviceGroupPresentCapabilitiesKHR * pDeviceGroupPresentCapabilities); -typedef VkResult (GLAD_API_PTR *PFN_vkGetDeviceGroupSurfacePresentModesKHR)(VkDevice device, VkSurfaceKHR surface, VkDeviceGroupPresentModeFlagsKHR * pModes); -typedef void (GLAD_API_PTR *PFN_vkGetDeviceMemoryCommitment)(VkDevice device, VkDeviceMemory memory, VkDeviceSize * pCommittedMemoryInBytes); -typedef PFN_vkVoidFunction (GLAD_API_PTR *PFN_vkGetDeviceProcAddr)(VkDevice device, const char * pName); -typedef void (GLAD_API_PTR *PFN_vkGetDeviceQueue)(VkDevice device, uint32_t queueFamilyIndex, uint32_t queueIndex, VkQueue * pQueue); -typedef void (GLAD_API_PTR *PFN_vkGetDeviceQueue2)(VkDevice device, const VkDeviceQueueInfo2 * pQueueInfo, VkQueue * pQueue); -typedef VkResult (GLAD_API_PTR *PFN_vkGetEventStatus)(VkDevice device, VkEvent event); -typedef VkResult (GLAD_API_PTR *PFN_vkGetFenceStatus)(VkDevice device, VkFence fence); -typedef void (GLAD_API_PTR *PFN_vkGetImageMemoryRequirements)(VkDevice device, VkImage image, VkMemoryRequirements * pMemoryRequirements); -typedef void (GLAD_API_PTR *PFN_vkGetImageMemoryRequirements2)(VkDevice device, const VkImageMemoryRequirementsInfo2 * pInfo, VkMemoryRequirements2 * pMemoryRequirements); -typedef void (GLAD_API_PTR *PFN_vkGetImageSparseMemoryRequirements)(VkDevice device, VkImage image, uint32_t * pSparseMemoryRequirementCount, VkSparseImageMemoryRequirements * pSparseMemoryRequirements); -typedef void (GLAD_API_PTR *PFN_vkGetImageSparseMemoryRequirements2)(VkDevice device, const VkImageSparseMemoryRequirementsInfo2 * pInfo, uint32_t * pSparseMemoryRequirementCount, VkSparseImageMemoryRequirements2 * pSparseMemoryRequirements); -typedef void (GLAD_API_PTR *PFN_vkGetImageSubresourceLayout)(VkDevice device, VkImage image, const VkImageSubresource * pSubresource, VkSubresourceLayout * pLayout); -typedef PFN_vkVoidFunction (GLAD_API_PTR *PFN_vkGetInstanceProcAddr)(VkInstance instance, const char * pName); -typedef void (GLAD_API_PTR *PFN_vkGetPhysicalDeviceExternalBufferProperties)(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceExternalBufferInfo * pExternalBufferInfo, VkExternalBufferProperties * pExternalBufferProperties); -typedef void (GLAD_API_PTR *PFN_vkGetPhysicalDeviceExternalFenceProperties)(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceExternalFenceInfo * pExternalFenceInfo, VkExternalFenceProperties * pExternalFenceProperties); -typedef void (GLAD_API_PTR *PFN_vkGetPhysicalDeviceExternalSemaphoreProperties)(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceExternalSemaphoreInfo * pExternalSemaphoreInfo, VkExternalSemaphoreProperties * pExternalSemaphoreProperties); -typedef void (GLAD_API_PTR *PFN_vkGetPhysicalDeviceFeatures)(VkPhysicalDevice physicalDevice, VkPhysicalDeviceFeatures * pFeatures); -typedef void (GLAD_API_PTR *PFN_vkGetPhysicalDeviceFeatures2)(VkPhysicalDevice physicalDevice, VkPhysicalDeviceFeatures2 * pFeatures); -typedef void (GLAD_API_PTR *PFN_vkGetPhysicalDeviceFormatProperties)(VkPhysicalDevice physicalDevice, VkFormat format, VkFormatProperties * pFormatProperties); -typedef void (GLAD_API_PTR *PFN_vkGetPhysicalDeviceFormatProperties2)(VkPhysicalDevice physicalDevice, VkFormat format, VkFormatProperties2 * pFormatProperties); -typedef VkResult (GLAD_API_PTR *PFN_vkGetPhysicalDeviceImageFormatProperties)(VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage, VkImageCreateFlags flags, VkImageFormatProperties * pImageFormatProperties); -typedef VkResult (GLAD_API_PTR *PFN_vkGetPhysicalDeviceImageFormatProperties2)(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 * pImageFormatInfo, VkImageFormatProperties2 * pImageFormatProperties); -typedef void (GLAD_API_PTR *PFN_vkGetPhysicalDeviceMemoryProperties)(VkPhysicalDevice physicalDevice, VkPhysicalDeviceMemoryProperties * pMemoryProperties); -typedef void (GLAD_API_PTR *PFN_vkGetPhysicalDeviceMemoryProperties2)(VkPhysicalDevice physicalDevice, VkPhysicalDeviceMemoryProperties2 * pMemoryProperties); -typedef VkResult (GLAD_API_PTR *PFN_vkGetPhysicalDevicePresentRectanglesKHR)(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, uint32_t * pRectCount, VkRect2D * pRects); -typedef void (GLAD_API_PTR *PFN_vkGetPhysicalDeviceProperties)(VkPhysicalDevice physicalDevice, VkPhysicalDeviceProperties * pProperties); -typedef void (GLAD_API_PTR *PFN_vkGetPhysicalDeviceProperties2)(VkPhysicalDevice physicalDevice, VkPhysicalDeviceProperties2 * pProperties); -typedef void (GLAD_API_PTR *PFN_vkGetPhysicalDeviceQueueFamilyProperties)(VkPhysicalDevice physicalDevice, uint32_t * pQueueFamilyPropertyCount, VkQueueFamilyProperties * pQueueFamilyProperties); -typedef void (GLAD_API_PTR *PFN_vkGetPhysicalDeviceQueueFamilyProperties2)(VkPhysicalDevice physicalDevice, uint32_t * pQueueFamilyPropertyCount, VkQueueFamilyProperties2 * pQueueFamilyProperties); -typedef void (GLAD_API_PTR *PFN_vkGetPhysicalDeviceSparseImageFormatProperties)(VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkSampleCountFlagBits samples, VkImageUsageFlags usage, VkImageTiling tiling, uint32_t * pPropertyCount, VkSparseImageFormatProperties * pProperties); -typedef void (GLAD_API_PTR *PFN_vkGetPhysicalDeviceSparseImageFormatProperties2)(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSparseImageFormatInfo2 * pFormatInfo, uint32_t * pPropertyCount, VkSparseImageFormatProperties2 * pProperties); -typedef VkResult (GLAD_API_PTR *PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR)(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, VkSurfaceCapabilitiesKHR * pSurfaceCapabilities); -typedef VkResult (GLAD_API_PTR *PFN_vkGetPhysicalDeviceSurfaceFormatsKHR)(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, uint32_t * pSurfaceFormatCount, VkSurfaceFormatKHR * pSurfaceFormats); -typedef VkResult (GLAD_API_PTR *PFN_vkGetPhysicalDeviceSurfacePresentModesKHR)(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, uint32_t * pPresentModeCount, VkPresentModeKHR * pPresentModes); -typedef VkResult (GLAD_API_PTR *PFN_vkGetPhysicalDeviceSurfaceSupportKHR)(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, VkSurfaceKHR surface, VkBool32 * pSupported); -typedef VkResult (GLAD_API_PTR *PFN_vkGetPipelineCacheData)(VkDevice device, VkPipelineCache pipelineCache, size_t * pDataSize, void * pData); -typedef VkResult (GLAD_API_PTR *PFN_vkGetQueryPoolResults)(VkDevice device, VkQueryPool queryPool, uint32_t firstQuery, uint32_t queryCount, size_t dataSize, void * pData, VkDeviceSize stride, VkQueryResultFlags flags); -typedef void (GLAD_API_PTR *PFN_vkGetRenderAreaGranularity)(VkDevice device, VkRenderPass renderPass, VkExtent2D * pGranularity); -typedef VkResult (GLAD_API_PTR *PFN_vkGetSwapchainImagesKHR)(VkDevice device, VkSwapchainKHR swapchain, uint32_t * pSwapchainImageCount, VkImage * pSwapchainImages); -typedef VkResult (GLAD_API_PTR *PFN_vkInvalidateMappedMemoryRanges)(VkDevice device, uint32_t memoryRangeCount, const VkMappedMemoryRange * pMemoryRanges); -typedef VkResult (GLAD_API_PTR *PFN_vkMapMemory)(VkDevice device, VkDeviceMemory memory, VkDeviceSize offset, VkDeviceSize size, VkMemoryMapFlags flags, void ** ppData); -typedef VkResult (GLAD_API_PTR *PFN_vkMergePipelineCaches)(VkDevice device, VkPipelineCache dstCache, uint32_t srcCacheCount, const VkPipelineCache * pSrcCaches); -typedef VkResult (GLAD_API_PTR *PFN_vkQueueBindSparse)(VkQueue queue, uint32_t bindInfoCount, const VkBindSparseInfo * pBindInfo, VkFence fence); -typedef VkResult (GLAD_API_PTR *PFN_vkQueuePresentKHR)(VkQueue queue, const VkPresentInfoKHR * pPresentInfo); -typedef VkResult (GLAD_API_PTR *PFN_vkQueueSubmit)(VkQueue queue, uint32_t submitCount, const VkSubmitInfo * pSubmits, VkFence fence); -typedef VkResult (GLAD_API_PTR *PFN_vkQueueWaitIdle)(VkQueue queue); -typedef VkResult (GLAD_API_PTR *PFN_vkResetCommandBuffer)(VkCommandBuffer commandBuffer, VkCommandBufferResetFlags flags); -typedef VkResult (GLAD_API_PTR *PFN_vkResetCommandPool)(VkDevice device, VkCommandPool commandPool, VkCommandPoolResetFlags flags); -typedef VkResult (GLAD_API_PTR *PFN_vkResetDescriptorPool)(VkDevice device, VkDescriptorPool descriptorPool, VkDescriptorPoolResetFlags flags); -typedef VkResult (GLAD_API_PTR *PFN_vkResetEvent)(VkDevice device, VkEvent event); -typedef VkResult (GLAD_API_PTR *PFN_vkResetFences)(VkDevice device, uint32_t fenceCount, const VkFence * pFences); -typedef VkResult (GLAD_API_PTR *PFN_vkSetEvent)(VkDevice device, VkEvent event); -typedef void (GLAD_API_PTR *PFN_vkTrimCommandPool)(VkDevice device, VkCommandPool commandPool, VkCommandPoolTrimFlags flags); -typedef void (GLAD_API_PTR *PFN_vkUnmapMemory)(VkDevice device, VkDeviceMemory memory); -typedef void (GLAD_API_PTR *PFN_vkUpdateDescriptorSetWithTemplate)(VkDevice device, VkDescriptorSet descriptorSet, VkDescriptorUpdateTemplate descriptorUpdateTemplate, const void * pData); -typedef void (GLAD_API_PTR *PFN_vkUpdateDescriptorSets)(VkDevice device, uint32_t descriptorWriteCount, const VkWriteDescriptorSet * pDescriptorWrites, uint32_t descriptorCopyCount, const VkCopyDescriptorSet * pDescriptorCopies); -typedef VkResult (GLAD_API_PTR *PFN_vkWaitForFences)(VkDevice device, uint32_t fenceCount, const VkFence * pFences, VkBool32 waitAll, uint64_t timeout); +typedef VkResult (GLAD_API_PTR *PFN_vkAcquireNextImage2KHR)(VkDevice device, const VkAcquireNextImageInfoKHR * pAcquireInfo, uint32_t * pImageIndex); +typedef VkResult (GLAD_API_PTR *PFN_vkAcquireNextImageKHR)(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout, VkSemaphore semaphore, VkFence fence, uint32_t * pImageIndex); +typedef VkResult (GLAD_API_PTR *PFN_vkAllocateCommandBuffers)(VkDevice device, const VkCommandBufferAllocateInfo * pAllocateInfo, VkCommandBuffer * pCommandBuffers); +typedef VkResult (GLAD_API_PTR *PFN_vkAllocateDescriptorSets)(VkDevice device, const VkDescriptorSetAllocateInfo * pAllocateInfo, VkDescriptorSet * pDescriptorSets); +typedef VkResult (GLAD_API_PTR *PFN_vkAllocateMemory)(VkDevice device, const VkMemoryAllocateInfo * pAllocateInfo, const VkAllocationCallbacks * pAllocator, VkDeviceMemory * pMemory); +typedef VkResult (GLAD_API_PTR *PFN_vkBeginCommandBuffer)(VkCommandBuffer commandBuffer, const VkCommandBufferBeginInfo * pBeginInfo); +typedef VkResult (GLAD_API_PTR *PFN_vkBindBufferMemory)(VkDevice device, VkBuffer buffer, VkDeviceMemory memory, VkDeviceSize memoryOffset); +typedef VkResult (GLAD_API_PTR *PFN_vkBindBufferMemory2)(VkDevice device, uint32_t bindInfoCount, const VkBindBufferMemoryInfo * pBindInfos); +typedef VkResult (GLAD_API_PTR *PFN_vkBindImageMemory)(VkDevice device, VkImage image, VkDeviceMemory memory, VkDeviceSize memoryOffset); +typedef VkResult (GLAD_API_PTR *PFN_vkBindImageMemory2)(VkDevice device, uint32_t bindInfoCount, const VkBindImageMemoryInfo * pBindInfos); +typedef void (GLAD_API_PTR *PFN_vkCmdBeginQuery)(VkCommandBuffer commandBuffer, VkQueryPool queryPool, uint32_t query, VkQueryControlFlags flags); +typedef void (GLAD_API_PTR *PFN_vkCmdBeginRenderPass)(VkCommandBuffer commandBuffer, const VkRenderPassBeginInfo * pRenderPassBegin, VkSubpassContents contents); +typedef void (GLAD_API_PTR *PFN_vkCmdBindDescriptorSets)(VkCommandBuffer commandBuffer, VkPipelineBindPoint pipelineBindPoint, VkPipelineLayout layout, uint32_t firstSet, uint32_t descriptorSetCount, const VkDescriptorSet * pDescriptorSets, uint32_t dynamicOffsetCount, const uint32_t * pDynamicOffsets); +typedef void (GLAD_API_PTR *PFN_vkCmdBindIndexBuffer)(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, VkIndexType indexType); +typedef void (GLAD_API_PTR *PFN_vkCmdBindPipeline)(VkCommandBuffer commandBuffer, VkPipelineBindPoint pipelineBindPoint, VkPipeline pipeline); +typedef void (GLAD_API_PTR *PFN_vkCmdBindVertexBuffers)(VkCommandBuffer commandBuffer, uint32_t firstBinding, uint32_t bindingCount, const VkBuffer * pBuffers, const VkDeviceSize * pOffsets); +typedef void (GLAD_API_PTR *PFN_vkCmdBlitImage)(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount, const VkImageBlit * pRegions, VkFilter filter); +typedef void (GLAD_API_PTR *PFN_vkCmdClearAttachments)(VkCommandBuffer commandBuffer, uint32_t attachmentCount, const VkClearAttachment * pAttachments, uint32_t rectCount, const VkClearRect * pRects); +typedef void (GLAD_API_PTR *PFN_vkCmdClearColorImage)(VkCommandBuffer commandBuffer, VkImage image, VkImageLayout imageLayout, const VkClearColorValue * pColor, uint32_t rangeCount, const VkImageSubresourceRange * pRanges); +typedef void (GLAD_API_PTR *PFN_vkCmdClearDepthStencilImage)(VkCommandBuffer commandBuffer, VkImage image, VkImageLayout imageLayout, const VkClearDepthStencilValue * pDepthStencil, uint32_t rangeCount, const VkImageSubresourceRange * pRanges); +typedef void (GLAD_API_PTR *PFN_vkCmdCopyBuffer)(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer, uint32_t regionCount, const VkBufferCopy * pRegions); +typedef void (GLAD_API_PTR *PFN_vkCmdCopyBufferToImage)(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount, const VkBufferImageCopy * pRegions); +typedef void (GLAD_API_PTR *PFN_vkCmdCopyImage)(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount, const VkImageCopy * pRegions); +typedef void (GLAD_API_PTR *PFN_vkCmdCopyImageToBuffer)(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkBuffer dstBuffer, uint32_t regionCount, const VkBufferImageCopy * pRegions); +typedef void (GLAD_API_PTR *PFN_vkCmdCopyQueryPoolResults)(VkCommandBuffer commandBuffer, VkQueryPool queryPool, uint32_t firstQuery, uint32_t queryCount, VkBuffer dstBuffer, VkDeviceSize dstOffset, VkDeviceSize stride, VkQueryResultFlags flags); +typedef void (GLAD_API_PTR *PFN_vkCmdDispatch)(VkCommandBuffer commandBuffer, uint32_t groupCountX, uint32_t groupCountY, uint32_t groupCountZ); +typedef void (GLAD_API_PTR *PFN_vkCmdDispatchBase)(VkCommandBuffer commandBuffer, uint32_t baseGroupX, uint32_t baseGroupY, uint32_t baseGroupZ, uint32_t groupCountX, uint32_t groupCountY, uint32_t groupCountZ); +typedef void (GLAD_API_PTR *PFN_vkCmdDispatchIndirect)(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset); +typedef void (GLAD_API_PTR *PFN_vkCmdDraw)(VkCommandBuffer commandBuffer, uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance); +typedef void (GLAD_API_PTR *PFN_vkCmdDrawIndexed)(VkCommandBuffer commandBuffer, uint32_t indexCount, uint32_t instanceCount, uint32_t firstIndex, int32_t vertexOffset, uint32_t firstInstance); +typedef void (GLAD_API_PTR *PFN_vkCmdDrawIndexedIndirect)(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t drawCount, uint32_t stride); +typedef void (GLAD_API_PTR *PFN_vkCmdDrawIndirect)(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t drawCount, uint32_t stride); +typedef void (GLAD_API_PTR *PFN_vkCmdEndQuery)(VkCommandBuffer commandBuffer, VkQueryPool queryPool, uint32_t query); +typedef void (GLAD_API_PTR *PFN_vkCmdEndRenderPass)(VkCommandBuffer commandBuffer); +typedef void (GLAD_API_PTR *PFN_vkCmdExecuteCommands)(VkCommandBuffer commandBuffer, uint32_t commandBufferCount, const VkCommandBuffer * pCommandBuffers); +typedef void (GLAD_API_PTR *PFN_vkCmdFillBuffer)(VkCommandBuffer commandBuffer, VkBuffer dstBuffer, VkDeviceSize dstOffset, VkDeviceSize size, uint32_t data); +typedef void (GLAD_API_PTR *PFN_vkCmdNextSubpass)(VkCommandBuffer commandBuffer, VkSubpassContents contents); +typedef void (GLAD_API_PTR *PFN_vkCmdPipelineBarrier)(VkCommandBuffer commandBuffer, VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkDependencyFlags dependencyFlags, uint32_t memoryBarrierCount, const VkMemoryBarrier * pMemoryBarriers, uint32_t bufferMemoryBarrierCount, const VkBufferMemoryBarrier * pBufferMemoryBarriers, uint32_t imageMemoryBarrierCount, const VkImageMemoryBarrier * pImageMemoryBarriers); +typedef void (GLAD_API_PTR *PFN_vkCmdPushConstants)(VkCommandBuffer commandBuffer, VkPipelineLayout layout, VkShaderStageFlags stageFlags, uint32_t offset, uint32_t size, const void * pValues); +typedef void (GLAD_API_PTR *PFN_vkCmdResetEvent)(VkCommandBuffer commandBuffer, VkEvent event, VkPipelineStageFlags stageMask); +typedef void (GLAD_API_PTR *PFN_vkCmdResetQueryPool)(VkCommandBuffer commandBuffer, VkQueryPool queryPool, uint32_t firstQuery, uint32_t queryCount); +typedef void (GLAD_API_PTR *PFN_vkCmdResolveImage)(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount, const VkImageResolve * pRegions); +typedef void (GLAD_API_PTR *PFN_vkCmdSetBlendConstants)(VkCommandBuffer commandBuffer, const float blendConstants [4]); +typedef void (GLAD_API_PTR *PFN_vkCmdSetDepthBias)(VkCommandBuffer commandBuffer, float depthBiasConstantFactor, float depthBiasClamp, float depthBiasSlopeFactor); +typedef void (GLAD_API_PTR *PFN_vkCmdSetDepthBounds)(VkCommandBuffer commandBuffer, float minDepthBounds, float maxDepthBounds); +typedef void (GLAD_API_PTR *PFN_vkCmdSetDeviceMask)(VkCommandBuffer commandBuffer, uint32_t deviceMask); +typedef void (GLAD_API_PTR *PFN_vkCmdSetEvent)(VkCommandBuffer commandBuffer, VkEvent event, VkPipelineStageFlags stageMask); +typedef void (GLAD_API_PTR *PFN_vkCmdSetLineWidth)(VkCommandBuffer commandBuffer, float lineWidth); +typedef void (GLAD_API_PTR *PFN_vkCmdSetScissor)(VkCommandBuffer commandBuffer, uint32_t firstScissor, uint32_t scissorCount, const VkRect2D * pScissors); +typedef void (GLAD_API_PTR *PFN_vkCmdSetStencilCompareMask)(VkCommandBuffer commandBuffer, VkStencilFaceFlags faceMask, uint32_t compareMask); +typedef void (GLAD_API_PTR *PFN_vkCmdSetStencilReference)(VkCommandBuffer commandBuffer, VkStencilFaceFlags faceMask, uint32_t reference); +typedef void (GLAD_API_PTR *PFN_vkCmdSetStencilWriteMask)(VkCommandBuffer commandBuffer, VkStencilFaceFlags faceMask, uint32_t writeMask); +typedef void (GLAD_API_PTR *PFN_vkCmdSetViewport)(VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount, const VkViewport * pViewports); +typedef void (GLAD_API_PTR *PFN_vkCmdUpdateBuffer)(VkCommandBuffer commandBuffer, VkBuffer dstBuffer, VkDeviceSize dstOffset, VkDeviceSize dataSize, const void * pData); +typedef void (GLAD_API_PTR *PFN_vkCmdWaitEvents)(VkCommandBuffer commandBuffer, uint32_t eventCount, const VkEvent * pEvents, VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, uint32_t memoryBarrierCount, const VkMemoryBarrier * pMemoryBarriers, uint32_t bufferMemoryBarrierCount, const VkBufferMemoryBarrier * pBufferMemoryBarriers, uint32_t imageMemoryBarrierCount, const VkImageMemoryBarrier * pImageMemoryBarriers); +typedef void (GLAD_API_PTR *PFN_vkCmdWriteTimestamp)(VkCommandBuffer commandBuffer, VkPipelineStageFlagBits pipelineStage, VkQueryPool queryPool, uint32_t query); +typedef VkResult (GLAD_API_PTR *PFN_vkCreateBuffer)(VkDevice device, const VkBufferCreateInfo * pCreateInfo, const VkAllocationCallbacks * pAllocator, VkBuffer * pBuffer); +typedef VkResult (GLAD_API_PTR *PFN_vkCreateBufferView)(VkDevice device, const VkBufferViewCreateInfo * pCreateInfo, const VkAllocationCallbacks * pAllocator, VkBufferView * pView); +typedef VkResult (GLAD_API_PTR *PFN_vkCreateCommandPool)(VkDevice device, const VkCommandPoolCreateInfo * pCreateInfo, const VkAllocationCallbacks * pAllocator, VkCommandPool * pCommandPool); +typedef VkResult (GLAD_API_PTR *PFN_vkCreateComputePipelines)(VkDevice device, VkPipelineCache pipelineCache, uint32_t createInfoCount, const VkComputePipelineCreateInfo * pCreateInfos, const VkAllocationCallbacks * pAllocator, VkPipeline * pPipelines); +typedef VkResult (GLAD_API_PTR *PFN_vkCreateDebugReportCallbackEXT)(VkInstance instance, const VkDebugReportCallbackCreateInfoEXT * pCreateInfo, const VkAllocationCallbacks * pAllocator, VkDebugReportCallbackEXT * pCallback); +typedef VkResult (GLAD_API_PTR *PFN_vkCreateDescriptorPool)(VkDevice device, const VkDescriptorPoolCreateInfo * pCreateInfo, const VkAllocationCallbacks * pAllocator, VkDescriptorPool * pDescriptorPool); +typedef VkResult (GLAD_API_PTR *PFN_vkCreateDescriptorSetLayout)(VkDevice device, const VkDescriptorSetLayoutCreateInfo * pCreateInfo, const VkAllocationCallbacks * pAllocator, VkDescriptorSetLayout * pSetLayout); +typedef VkResult (GLAD_API_PTR *PFN_vkCreateDescriptorUpdateTemplate)(VkDevice device, const VkDescriptorUpdateTemplateCreateInfo * pCreateInfo, const VkAllocationCallbacks * pAllocator, VkDescriptorUpdateTemplate * pDescriptorUpdateTemplate); +typedef VkResult (GLAD_API_PTR *PFN_vkCreateDevice)(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo * pCreateInfo, const VkAllocationCallbacks * pAllocator, VkDevice * pDevice); +typedef VkResult (GLAD_API_PTR *PFN_vkCreateEvent)(VkDevice device, const VkEventCreateInfo * pCreateInfo, const VkAllocationCallbacks * pAllocator, VkEvent * pEvent); +typedef VkResult (GLAD_API_PTR *PFN_vkCreateFence)(VkDevice device, const VkFenceCreateInfo * pCreateInfo, const VkAllocationCallbacks * pAllocator, VkFence * pFence); +typedef VkResult (GLAD_API_PTR *PFN_vkCreateFramebuffer)(VkDevice device, const VkFramebufferCreateInfo * pCreateInfo, const VkAllocationCallbacks * pAllocator, VkFramebuffer * pFramebuffer); +typedef VkResult (GLAD_API_PTR *PFN_vkCreateGraphicsPipelines)(VkDevice device, VkPipelineCache pipelineCache, uint32_t createInfoCount, const VkGraphicsPipelineCreateInfo * pCreateInfos, const VkAllocationCallbacks * pAllocator, VkPipeline * pPipelines); +typedef VkResult (GLAD_API_PTR *PFN_vkCreateImage)(VkDevice device, const VkImageCreateInfo * pCreateInfo, const VkAllocationCallbacks * pAllocator, VkImage * pImage); +typedef VkResult (GLAD_API_PTR *PFN_vkCreateImageView)(VkDevice device, const VkImageViewCreateInfo * pCreateInfo, const VkAllocationCallbacks * pAllocator, VkImageView * pView); +typedef VkResult (GLAD_API_PTR *PFN_vkCreateInstance)(const VkInstanceCreateInfo * pCreateInfo, const VkAllocationCallbacks * pAllocator, VkInstance * pInstance); +typedef VkResult (GLAD_API_PTR *PFN_vkCreatePipelineCache)(VkDevice device, const VkPipelineCacheCreateInfo * pCreateInfo, const VkAllocationCallbacks * pAllocator, VkPipelineCache * pPipelineCache); +typedef VkResult (GLAD_API_PTR *PFN_vkCreatePipelineLayout)(VkDevice device, const VkPipelineLayoutCreateInfo * pCreateInfo, const VkAllocationCallbacks * pAllocator, VkPipelineLayout * pPipelineLayout); +typedef VkResult (GLAD_API_PTR *PFN_vkCreateQueryPool)(VkDevice device, const VkQueryPoolCreateInfo * pCreateInfo, const VkAllocationCallbacks * pAllocator, VkQueryPool * pQueryPool); +typedef VkResult (GLAD_API_PTR *PFN_vkCreateRenderPass)(VkDevice device, const VkRenderPassCreateInfo * pCreateInfo, const VkAllocationCallbacks * pAllocator, VkRenderPass * pRenderPass); +typedef VkResult (GLAD_API_PTR *PFN_vkCreateSampler)(VkDevice device, const VkSamplerCreateInfo * pCreateInfo, const VkAllocationCallbacks * pAllocator, VkSampler * pSampler); +typedef VkResult (GLAD_API_PTR *PFN_vkCreateSamplerYcbcrConversion)(VkDevice device, const VkSamplerYcbcrConversionCreateInfo * pCreateInfo, const VkAllocationCallbacks * pAllocator, VkSamplerYcbcrConversion * pYcbcrConversion); +typedef VkResult (GLAD_API_PTR *PFN_vkCreateSemaphore)(VkDevice device, const VkSemaphoreCreateInfo * pCreateInfo, const VkAllocationCallbacks * pAllocator, VkSemaphore * pSemaphore); +typedef VkResult (GLAD_API_PTR *PFN_vkCreateShaderModule)(VkDevice device, const VkShaderModuleCreateInfo * pCreateInfo, const VkAllocationCallbacks * pAllocator, VkShaderModule * pShaderModule); +typedef VkResult (GLAD_API_PTR *PFN_vkCreateSwapchainKHR)(VkDevice device, const VkSwapchainCreateInfoKHR * pCreateInfo, const VkAllocationCallbacks * pAllocator, VkSwapchainKHR * pSwapchain); +typedef void (GLAD_API_PTR *PFN_vkDebugReportMessageEXT)(VkInstance instance, VkDebugReportFlagsEXT flags, VkDebugReportObjectTypeEXT objectType, uint64_t object, size_t location, int32_t messageCode, const char * pLayerPrefix, const char * pMessage); +typedef void (GLAD_API_PTR *PFN_vkDestroyBuffer)(VkDevice device, VkBuffer buffer, const VkAllocationCallbacks * pAllocator); +typedef void (GLAD_API_PTR *PFN_vkDestroyBufferView)(VkDevice device, VkBufferView bufferView, const VkAllocationCallbacks * pAllocator); +typedef void (GLAD_API_PTR *PFN_vkDestroyCommandPool)(VkDevice device, VkCommandPool commandPool, const VkAllocationCallbacks * pAllocator); +typedef void (GLAD_API_PTR *PFN_vkDestroyDebugReportCallbackEXT)(VkInstance instance, VkDebugReportCallbackEXT callback, const VkAllocationCallbacks * pAllocator); +typedef void (GLAD_API_PTR *PFN_vkDestroyDescriptorPool)(VkDevice device, VkDescriptorPool descriptorPool, const VkAllocationCallbacks * pAllocator); +typedef void (GLAD_API_PTR *PFN_vkDestroyDescriptorSetLayout)(VkDevice device, VkDescriptorSetLayout descriptorSetLayout, const VkAllocationCallbacks * pAllocator); +typedef void (GLAD_API_PTR *PFN_vkDestroyDescriptorUpdateTemplate)(VkDevice device, VkDescriptorUpdateTemplate descriptorUpdateTemplate, const VkAllocationCallbacks * pAllocator); +typedef void (GLAD_API_PTR *PFN_vkDestroyDevice)(VkDevice device, const VkAllocationCallbacks * pAllocator); +typedef void (GLAD_API_PTR *PFN_vkDestroyEvent)(VkDevice device, VkEvent event, const VkAllocationCallbacks * pAllocator); +typedef void (GLAD_API_PTR *PFN_vkDestroyFence)(VkDevice device, VkFence fence, const VkAllocationCallbacks * pAllocator); +typedef void (GLAD_API_PTR *PFN_vkDestroyFramebuffer)(VkDevice device, VkFramebuffer framebuffer, const VkAllocationCallbacks * pAllocator); +typedef void (GLAD_API_PTR *PFN_vkDestroyImage)(VkDevice device, VkImage image, const VkAllocationCallbacks * pAllocator); +typedef void (GLAD_API_PTR *PFN_vkDestroyImageView)(VkDevice device, VkImageView imageView, const VkAllocationCallbacks * pAllocator); +typedef void (GLAD_API_PTR *PFN_vkDestroyInstance)(VkInstance instance, const VkAllocationCallbacks * pAllocator); +typedef void (GLAD_API_PTR *PFN_vkDestroyPipeline)(VkDevice device, VkPipeline pipeline, const VkAllocationCallbacks * pAllocator); +typedef void (GLAD_API_PTR *PFN_vkDestroyPipelineCache)(VkDevice device, VkPipelineCache pipelineCache, const VkAllocationCallbacks * pAllocator); +typedef void (GLAD_API_PTR *PFN_vkDestroyPipelineLayout)(VkDevice device, VkPipelineLayout pipelineLayout, const VkAllocationCallbacks * pAllocator); +typedef void (GLAD_API_PTR *PFN_vkDestroyQueryPool)(VkDevice device, VkQueryPool queryPool, const VkAllocationCallbacks * pAllocator); +typedef void (GLAD_API_PTR *PFN_vkDestroyRenderPass)(VkDevice device, VkRenderPass renderPass, const VkAllocationCallbacks * pAllocator); +typedef void (GLAD_API_PTR *PFN_vkDestroySampler)(VkDevice device, VkSampler sampler, const VkAllocationCallbacks * pAllocator); +typedef void (GLAD_API_PTR *PFN_vkDestroySamplerYcbcrConversion)(VkDevice device, VkSamplerYcbcrConversion ycbcrConversion, const VkAllocationCallbacks * pAllocator); +typedef void (GLAD_API_PTR *PFN_vkDestroySemaphore)(VkDevice device, VkSemaphore semaphore, const VkAllocationCallbacks * pAllocator); +typedef void (GLAD_API_PTR *PFN_vkDestroyShaderModule)(VkDevice device, VkShaderModule shaderModule, const VkAllocationCallbacks * pAllocator); +typedef void (GLAD_API_PTR *PFN_vkDestroySurfaceKHR)(VkInstance instance, VkSurfaceKHR surface, const VkAllocationCallbacks * pAllocator); +typedef void (GLAD_API_PTR *PFN_vkDestroySwapchainKHR)(VkDevice device, VkSwapchainKHR swapchain, const VkAllocationCallbacks * pAllocator); +typedef VkResult (GLAD_API_PTR *PFN_vkDeviceWaitIdle)(VkDevice device); +typedef VkResult (GLAD_API_PTR *PFN_vkEndCommandBuffer)(VkCommandBuffer commandBuffer); +typedef VkResult (GLAD_API_PTR *PFN_vkEnumerateDeviceExtensionProperties)(VkPhysicalDevice physicalDevice, const char * pLayerName, uint32_t * pPropertyCount, VkExtensionProperties * pProperties); +typedef VkResult (GLAD_API_PTR *PFN_vkEnumerateDeviceLayerProperties)(VkPhysicalDevice physicalDevice, uint32_t * pPropertyCount, VkLayerProperties * pProperties); +typedef VkResult (GLAD_API_PTR *PFN_vkEnumerateInstanceExtensionProperties)(const char * pLayerName, uint32_t * pPropertyCount, VkExtensionProperties * pProperties); +typedef VkResult (GLAD_API_PTR *PFN_vkEnumerateInstanceLayerProperties)(uint32_t * pPropertyCount, VkLayerProperties * pProperties); +typedef VkResult (GLAD_API_PTR *PFN_vkEnumerateInstanceVersion)(uint32_t * pApiVersion); +typedef VkResult (GLAD_API_PTR *PFN_vkEnumeratePhysicalDeviceGroups)(VkInstance instance, uint32_t * pPhysicalDeviceGroupCount, VkPhysicalDeviceGroupProperties * pPhysicalDeviceGroupProperties); +typedef VkResult (GLAD_API_PTR *PFN_vkEnumeratePhysicalDevices)(VkInstance instance, uint32_t * pPhysicalDeviceCount, VkPhysicalDevice * pPhysicalDevices); +typedef VkResult (GLAD_API_PTR *PFN_vkFlushMappedMemoryRanges)(VkDevice device, uint32_t memoryRangeCount, const VkMappedMemoryRange * pMemoryRanges); +typedef void (GLAD_API_PTR *PFN_vkFreeCommandBuffers)(VkDevice device, VkCommandPool commandPool, uint32_t commandBufferCount, const VkCommandBuffer * pCommandBuffers); +typedef VkResult (GLAD_API_PTR *PFN_vkFreeDescriptorSets)(VkDevice device, VkDescriptorPool descriptorPool, uint32_t descriptorSetCount, const VkDescriptorSet * pDescriptorSets); +typedef void (GLAD_API_PTR *PFN_vkFreeMemory)(VkDevice device, VkDeviceMemory memory, const VkAllocationCallbacks * pAllocator); +typedef void (GLAD_API_PTR *PFN_vkGetBufferMemoryRequirements)(VkDevice device, VkBuffer buffer, VkMemoryRequirements * pMemoryRequirements); +typedef void (GLAD_API_PTR *PFN_vkGetBufferMemoryRequirements2)(VkDevice device, const VkBufferMemoryRequirementsInfo2 * pInfo, VkMemoryRequirements2 * pMemoryRequirements); +typedef void (GLAD_API_PTR *PFN_vkGetDescriptorSetLayoutSupport)(VkDevice device, const VkDescriptorSetLayoutCreateInfo * pCreateInfo, VkDescriptorSetLayoutSupport * pSupport); +typedef void (GLAD_API_PTR *PFN_vkGetDeviceGroupPeerMemoryFeatures)(VkDevice device, uint32_t heapIndex, uint32_t localDeviceIndex, uint32_t remoteDeviceIndex, VkPeerMemoryFeatureFlags * pPeerMemoryFeatures); +typedef VkResult (GLAD_API_PTR *PFN_vkGetDeviceGroupPresentCapabilitiesKHR)(VkDevice device, VkDeviceGroupPresentCapabilitiesKHR * pDeviceGroupPresentCapabilities); +typedef VkResult (GLAD_API_PTR *PFN_vkGetDeviceGroupSurfacePresentModesKHR)(VkDevice device, VkSurfaceKHR surface, VkDeviceGroupPresentModeFlagsKHR * pModes); +typedef void (GLAD_API_PTR *PFN_vkGetDeviceMemoryCommitment)(VkDevice device, VkDeviceMemory memory, VkDeviceSize * pCommittedMemoryInBytes); +typedef PFN_vkVoidFunction (GLAD_API_PTR *PFN_vkGetDeviceProcAddr)(VkDevice device, const char * pName); +typedef void (GLAD_API_PTR *PFN_vkGetDeviceQueue)(VkDevice device, uint32_t queueFamilyIndex, uint32_t queueIndex, VkQueue * pQueue); +typedef void (GLAD_API_PTR *PFN_vkGetDeviceQueue2)(VkDevice device, const VkDeviceQueueInfo2 * pQueueInfo, VkQueue * pQueue); +typedef VkResult (GLAD_API_PTR *PFN_vkGetEventStatus)(VkDevice device, VkEvent event); +typedef VkResult (GLAD_API_PTR *PFN_vkGetFenceStatus)(VkDevice device, VkFence fence); +typedef void (GLAD_API_PTR *PFN_vkGetImageMemoryRequirements)(VkDevice device, VkImage image, VkMemoryRequirements * pMemoryRequirements); +typedef void (GLAD_API_PTR *PFN_vkGetImageMemoryRequirements2)(VkDevice device, const VkImageMemoryRequirementsInfo2 * pInfo, VkMemoryRequirements2 * pMemoryRequirements); +typedef void (GLAD_API_PTR *PFN_vkGetImageSparseMemoryRequirements)(VkDevice device, VkImage image, uint32_t * pSparseMemoryRequirementCount, VkSparseImageMemoryRequirements * pSparseMemoryRequirements); +typedef void (GLAD_API_PTR *PFN_vkGetImageSparseMemoryRequirements2)(VkDevice device, const VkImageSparseMemoryRequirementsInfo2 * pInfo, uint32_t * pSparseMemoryRequirementCount, VkSparseImageMemoryRequirements2 * pSparseMemoryRequirements); +typedef void (GLAD_API_PTR *PFN_vkGetImageSubresourceLayout)(VkDevice device, VkImage image, const VkImageSubresource * pSubresource, VkSubresourceLayout * pLayout); +typedef PFN_vkVoidFunction (GLAD_API_PTR *PFN_vkGetInstanceProcAddr)(VkInstance instance, const char * pName); +typedef void (GLAD_API_PTR *PFN_vkGetPhysicalDeviceExternalBufferProperties)(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceExternalBufferInfo * pExternalBufferInfo, VkExternalBufferProperties * pExternalBufferProperties); +typedef void (GLAD_API_PTR *PFN_vkGetPhysicalDeviceExternalFenceProperties)(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceExternalFenceInfo * pExternalFenceInfo, VkExternalFenceProperties * pExternalFenceProperties); +typedef void (GLAD_API_PTR *PFN_vkGetPhysicalDeviceExternalSemaphoreProperties)(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceExternalSemaphoreInfo * pExternalSemaphoreInfo, VkExternalSemaphoreProperties * pExternalSemaphoreProperties); +typedef void (GLAD_API_PTR *PFN_vkGetPhysicalDeviceFeatures)(VkPhysicalDevice physicalDevice, VkPhysicalDeviceFeatures * pFeatures); +typedef void (GLAD_API_PTR *PFN_vkGetPhysicalDeviceFeatures2)(VkPhysicalDevice physicalDevice, VkPhysicalDeviceFeatures2 * pFeatures); +typedef void (GLAD_API_PTR *PFN_vkGetPhysicalDeviceFormatProperties)(VkPhysicalDevice physicalDevice, VkFormat format, VkFormatProperties * pFormatProperties); +typedef void (GLAD_API_PTR *PFN_vkGetPhysicalDeviceFormatProperties2)(VkPhysicalDevice physicalDevice, VkFormat format, VkFormatProperties2 * pFormatProperties); +typedef VkResult (GLAD_API_PTR *PFN_vkGetPhysicalDeviceImageFormatProperties)(VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage, VkImageCreateFlags flags, VkImageFormatProperties * pImageFormatProperties); +typedef VkResult (GLAD_API_PTR *PFN_vkGetPhysicalDeviceImageFormatProperties2)(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 * pImageFormatInfo, VkImageFormatProperties2 * pImageFormatProperties); +typedef void (GLAD_API_PTR *PFN_vkGetPhysicalDeviceMemoryProperties)(VkPhysicalDevice physicalDevice, VkPhysicalDeviceMemoryProperties * pMemoryProperties); +typedef void (GLAD_API_PTR *PFN_vkGetPhysicalDeviceMemoryProperties2)(VkPhysicalDevice physicalDevice, VkPhysicalDeviceMemoryProperties2 * pMemoryProperties); +typedef VkResult (GLAD_API_PTR *PFN_vkGetPhysicalDevicePresentRectanglesKHR)(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, uint32_t * pRectCount, VkRect2D * pRects); +typedef void (GLAD_API_PTR *PFN_vkGetPhysicalDeviceProperties)(VkPhysicalDevice physicalDevice, VkPhysicalDeviceProperties * pProperties); +typedef void (GLAD_API_PTR *PFN_vkGetPhysicalDeviceProperties2)(VkPhysicalDevice physicalDevice, VkPhysicalDeviceProperties2 * pProperties); +typedef void (GLAD_API_PTR *PFN_vkGetPhysicalDeviceQueueFamilyProperties)(VkPhysicalDevice physicalDevice, uint32_t * pQueueFamilyPropertyCount, VkQueueFamilyProperties * pQueueFamilyProperties); +typedef void (GLAD_API_PTR *PFN_vkGetPhysicalDeviceQueueFamilyProperties2)(VkPhysicalDevice physicalDevice, uint32_t * pQueueFamilyPropertyCount, VkQueueFamilyProperties2 * pQueueFamilyProperties); +typedef void (GLAD_API_PTR *PFN_vkGetPhysicalDeviceSparseImageFormatProperties)(VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkSampleCountFlagBits samples, VkImageUsageFlags usage, VkImageTiling tiling, uint32_t * pPropertyCount, VkSparseImageFormatProperties * pProperties); +typedef void (GLAD_API_PTR *PFN_vkGetPhysicalDeviceSparseImageFormatProperties2)(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSparseImageFormatInfo2 * pFormatInfo, uint32_t * pPropertyCount, VkSparseImageFormatProperties2 * pProperties); +typedef VkResult (GLAD_API_PTR *PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR)(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, VkSurfaceCapabilitiesKHR * pSurfaceCapabilities); +typedef VkResult (GLAD_API_PTR *PFN_vkGetPhysicalDeviceSurfaceFormatsKHR)(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, uint32_t * pSurfaceFormatCount, VkSurfaceFormatKHR * pSurfaceFormats); +typedef VkResult (GLAD_API_PTR *PFN_vkGetPhysicalDeviceSurfacePresentModesKHR)(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, uint32_t * pPresentModeCount, VkPresentModeKHR * pPresentModes); +typedef VkResult (GLAD_API_PTR *PFN_vkGetPhysicalDeviceSurfaceSupportKHR)(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, VkSurfaceKHR surface, VkBool32 * pSupported); +typedef VkResult (GLAD_API_PTR *PFN_vkGetPipelineCacheData)(VkDevice device, VkPipelineCache pipelineCache, size_t * pDataSize, void * pData); +typedef VkResult (GLAD_API_PTR *PFN_vkGetQueryPoolResults)(VkDevice device, VkQueryPool queryPool, uint32_t firstQuery, uint32_t queryCount, size_t dataSize, void * pData, VkDeviceSize stride, VkQueryResultFlags flags); +typedef void (GLAD_API_PTR *PFN_vkGetRenderAreaGranularity)(VkDevice device, VkRenderPass renderPass, VkExtent2D * pGranularity); +typedef VkResult (GLAD_API_PTR *PFN_vkGetSwapchainImagesKHR)(VkDevice device, VkSwapchainKHR swapchain, uint32_t * pSwapchainImageCount, VkImage * pSwapchainImages); +typedef VkResult (GLAD_API_PTR *PFN_vkInvalidateMappedMemoryRanges)(VkDevice device, uint32_t memoryRangeCount, const VkMappedMemoryRange * pMemoryRanges); +typedef VkResult (GLAD_API_PTR *PFN_vkMapMemory)(VkDevice device, VkDeviceMemory memory, VkDeviceSize offset, VkDeviceSize size, VkMemoryMapFlags flags, void ** ppData); +typedef VkResult (GLAD_API_PTR *PFN_vkMergePipelineCaches)(VkDevice device, VkPipelineCache dstCache, uint32_t srcCacheCount, const VkPipelineCache * pSrcCaches); +typedef VkResult (GLAD_API_PTR *PFN_vkQueueBindSparse)(VkQueue queue, uint32_t bindInfoCount, const VkBindSparseInfo * pBindInfo, VkFence fence); +typedef VkResult (GLAD_API_PTR *PFN_vkQueuePresentKHR)(VkQueue queue, const VkPresentInfoKHR * pPresentInfo); +typedef VkResult (GLAD_API_PTR *PFN_vkQueueSubmit)(VkQueue queue, uint32_t submitCount, const VkSubmitInfo * pSubmits, VkFence fence); +typedef VkResult (GLAD_API_PTR *PFN_vkQueueWaitIdle)(VkQueue queue); +typedef VkResult (GLAD_API_PTR *PFN_vkResetCommandBuffer)(VkCommandBuffer commandBuffer, VkCommandBufferResetFlags flags); +typedef VkResult (GLAD_API_PTR *PFN_vkResetCommandPool)(VkDevice device, VkCommandPool commandPool, VkCommandPoolResetFlags flags); +typedef VkResult (GLAD_API_PTR *PFN_vkResetDescriptorPool)(VkDevice device, VkDescriptorPool descriptorPool, VkDescriptorPoolResetFlags flags); +typedef VkResult (GLAD_API_PTR *PFN_vkResetEvent)(VkDevice device, VkEvent event); +typedef VkResult (GLAD_API_PTR *PFN_vkResetFences)(VkDevice device, uint32_t fenceCount, const VkFence * pFences); +typedef VkResult (GLAD_API_PTR *PFN_vkSetEvent)(VkDevice device, VkEvent event); +typedef void (GLAD_API_PTR *PFN_vkTrimCommandPool)(VkDevice device, VkCommandPool commandPool, VkCommandPoolTrimFlags flags); +typedef void (GLAD_API_PTR *PFN_vkUnmapMemory)(VkDevice device, VkDeviceMemory memory); +typedef void (GLAD_API_PTR *PFN_vkUpdateDescriptorSetWithTemplate)(VkDevice device, VkDescriptorSet descriptorSet, VkDescriptorUpdateTemplate descriptorUpdateTemplate, const void * pData); +typedef void (GLAD_API_PTR *PFN_vkUpdateDescriptorSets)(VkDevice device, uint32_t descriptorWriteCount, const VkWriteDescriptorSet * pDescriptorWrites, uint32_t descriptorCopyCount, const VkCopyDescriptorSet * pDescriptorCopies); +typedef VkResult (GLAD_API_PTR *PFN_vkWaitForFences)(VkDevice device, uint32_t fenceCount, const VkFence * pFences, VkBool32 waitAll, uint64_t timeout); GLAD_API_CALL PFN_vkAcquireNextImage2KHR glad_vkAcquireNextImage2KHR; #define vkAcquireNextImage2KHR glad_vkAcquireNextImage2KHR @@ -3466,15 +3974,639 @@ GLAD_API_CALL PFN_vkWaitForFences glad_vkWaitForFences; #define vkWaitForFences glad_vkWaitForFences + + + GLAD_API_CALL int gladLoadVulkanUserPtr( VkPhysicalDevice physical_device, GLADuserptrloadfunc load, void *userptr); GLAD_API_CALL int gladLoadVulkan( VkPhysicalDevice physical_device, GLADloadfunc load); - - - #ifdef __cplusplus } #endif #endif + +/* Source */ +#ifdef GLAD_VULKAN_IMPLEMENTATION +#include +#include +#include + +#ifndef GLAD_IMPL_UTIL_C_ +#define GLAD_IMPL_UTIL_C_ + +#ifdef _MSC_VER +#define GLAD_IMPL_UTIL_SSCANF sscanf_s +#else +#define GLAD_IMPL_UTIL_SSCANF sscanf +#endif + +#endif /* GLAD_IMPL_UTIL_C_ */ + +#ifdef __cplusplus +extern "C" { +#endif + + + +int GLAD_VK_VERSION_1_0 = 0; +int GLAD_VK_VERSION_1_1 = 0; +int GLAD_VK_EXT_debug_report = 0; +int GLAD_VK_KHR_surface = 0; +int GLAD_VK_KHR_swapchain = 0; + + + +PFN_vkAcquireNextImage2KHR glad_vkAcquireNextImage2KHR = NULL; +PFN_vkAcquireNextImageKHR glad_vkAcquireNextImageKHR = NULL; +PFN_vkAllocateCommandBuffers glad_vkAllocateCommandBuffers = NULL; +PFN_vkAllocateDescriptorSets glad_vkAllocateDescriptorSets = NULL; +PFN_vkAllocateMemory glad_vkAllocateMemory = NULL; +PFN_vkBeginCommandBuffer glad_vkBeginCommandBuffer = NULL; +PFN_vkBindBufferMemory glad_vkBindBufferMemory = NULL; +PFN_vkBindBufferMemory2 glad_vkBindBufferMemory2 = NULL; +PFN_vkBindImageMemory glad_vkBindImageMemory = NULL; +PFN_vkBindImageMemory2 glad_vkBindImageMemory2 = NULL; +PFN_vkCmdBeginQuery glad_vkCmdBeginQuery = NULL; +PFN_vkCmdBeginRenderPass glad_vkCmdBeginRenderPass = NULL; +PFN_vkCmdBindDescriptorSets glad_vkCmdBindDescriptorSets = NULL; +PFN_vkCmdBindIndexBuffer glad_vkCmdBindIndexBuffer = NULL; +PFN_vkCmdBindPipeline glad_vkCmdBindPipeline = NULL; +PFN_vkCmdBindVertexBuffers glad_vkCmdBindVertexBuffers = NULL; +PFN_vkCmdBlitImage glad_vkCmdBlitImage = NULL; +PFN_vkCmdClearAttachments glad_vkCmdClearAttachments = NULL; +PFN_vkCmdClearColorImage glad_vkCmdClearColorImage = NULL; +PFN_vkCmdClearDepthStencilImage glad_vkCmdClearDepthStencilImage = NULL; +PFN_vkCmdCopyBuffer glad_vkCmdCopyBuffer = NULL; +PFN_vkCmdCopyBufferToImage glad_vkCmdCopyBufferToImage = NULL; +PFN_vkCmdCopyImage glad_vkCmdCopyImage = NULL; +PFN_vkCmdCopyImageToBuffer glad_vkCmdCopyImageToBuffer = NULL; +PFN_vkCmdCopyQueryPoolResults glad_vkCmdCopyQueryPoolResults = NULL; +PFN_vkCmdDispatch glad_vkCmdDispatch = NULL; +PFN_vkCmdDispatchBase glad_vkCmdDispatchBase = NULL; +PFN_vkCmdDispatchIndirect glad_vkCmdDispatchIndirect = NULL; +PFN_vkCmdDraw glad_vkCmdDraw = NULL; +PFN_vkCmdDrawIndexed glad_vkCmdDrawIndexed = NULL; +PFN_vkCmdDrawIndexedIndirect glad_vkCmdDrawIndexedIndirect = NULL; +PFN_vkCmdDrawIndirect glad_vkCmdDrawIndirect = NULL; +PFN_vkCmdEndQuery glad_vkCmdEndQuery = NULL; +PFN_vkCmdEndRenderPass glad_vkCmdEndRenderPass = NULL; +PFN_vkCmdExecuteCommands glad_vkCmdExecuteCommands = NULL; +PFN_vkCmdFillBuffer glad_vkCmdFillBuffer = NULL; +PFN_vkCmdNextSubpass glad_vkCmdNextSubpass = NULL; +PFN_vkCmdPipelineBarrier glad_vkCmdPipelineBarrier = NULL; +PFN_vkCmdPushConstants glad_vkCmdPushConstants = NULL; +PFN_vkCmdResetEvent glad_vkCmdResetEvent = NULL; +PFN_vkCmdResetQueryPool glad_vkCmdResetQueryPool = NULL; +PFN_vkCmdResolveImage glad_vkCmdResolveImage = NULL; +PFN_vkCmdSetBlendConstants glad_vkCmdSetBlendConstants = NULL; +PFN_vkCmdSetDepthBias glad_vkCmdSetDepthBias = NULL; +PFN_vkCmdSetDepthBounds glad_vkCmdSetDepthBounds = NULL; +PFN_vkCmdSetDeviceMask glad_vkCmdSetDeviceMask = NULL; +PFN_vkCmdSetEvent glad_vkCmdSetEvent = NULL; +PFN_vkCmdSetLineWidth glad_vkCmdSetLineWidth = NULL; +PFN_vkCmdSetScissor glad_vkCmdSetScissor = NULL; +PFN_vkCmdSetStencilCompareMask glad_vkCmdSetStencilCompareMask = NULL; +PFN_vkCmdSetStencilReference glad_vkCmdSetStencilReference = NULL; +PFN_vkCmdSetStencilWriteMask glad_vkCmdSetStencilWriteMask = NULL; +PFN_vkCmdSetViewport glad_vkCmdSetViewport = NULL; +PFN_vkCmdUpdateBuffer glad_vkCmdUpdateBuffer = NULL; +PFN_vkCmdWaitEvents glad_vkCmdWaitEvents = NULL; +PFN_vkCmdWriteTimestamp glad_vkCmdWriteTimestamp = NULL; +PFN_vkCreateBuffer glad_vkCreateBuffer = NULL; +PFN_vkCreateBufferView glad_vkCreateBufferView = NULL; +PFN_vkCreateCommandPool glad_vkCreateCommandPool = NULL; +PFN_vkCreateComputePipelines glad_vkCreateComputePipelines = NULL; +PFN_vkCreateDebugReportCallbackEXT glad_vkCreateDebugReportCallbackEXT = NULL; +PFN_vkCreateDescriptorPool glad_vkCreateDescriptorPool = NULL; +PFN_vkCreateDescriptorSetLayout glad_vkCreateDescriptorSetLayout = NULL; +PFN_vkCreateDescriptorUpdateTemplate glad_vkCreateDescriptorUpdateTemplate = NULL; +PFN_vkCreateDevice glad_vkCreateDevice = NULL; +PFN_vkCreateEvent glad_vkCreateEvent = NULL; +PFN_vkCreateFence glad_vkCreateFence = NULL; +PFN_vkCreateFramebuffer glad_vkCreateFramebuffer = NULL; +PFN_vkCreateGraphicsPipelines glad_vkCreateGraphicsPipelines = NULL; +PFN_vkCreateImage glad_vkCreateImage = NULL; +PFN_vkCreateImageView glad_vkCreateImageView = NULL; +PFN_vkCreateInstance glad_vkCreateInstance = NULL; +PFN_vkCreatePipelineCache glad_vkCreatePipelineCache = NULL; +PFN_vkCreatePipelineLayout glad_vkCreatePipelineLayout = NULL; +PFN_vkCreateQueryPool glad_vkCreateQueryPool = NULL; +PFN_vkCreateRenderPass glad_vkCreateRenderPass = NULL; +PFN_vkCreateSampler glad_vkCreateSampler = NULL; +PFN_vkCreateSamplerYcbcrConversion glad_vkCreateSamplerYcbcrConversion = NULL; +PFN_vkCreateSemaphore glad_vkCreateSemaphore = NULL; +PFN_vkCreateShaderModule glad_vkCreateShaderModule = NULL; +PFN_vkCreateSwapchainKHR glad_vkCreateSwapchainKHR = NULL; +PFN_vkDebugReportMessageEXT glad_vkDebugReportMessageEXT = NULL; +PFN_vkDestroyBuffer glad_vkDestroyBuffer = NULL; +PFN_vkDestroyBufferView glad_vkDestroyBufferView = NULL; +PFN_vkDestroyCommandPool glad_vkDestroyCommandPool = NULL; +PFN_vkDestroyDebugReportCallbackEXT glad_vkDestroyDebugReportCallbackEXT = NULL; +PFN_vkDestroyDescriptorPool glad_vkDestroyDescriptorPool = NULL; +PFN_vkDestroyDescriptorSetLayout glad_vkDestroyDescriptorSetLayout = NULL; +PFN_vkDestroyDescriptorUpdateTemplate glad_vkDestroyDescriptorUpdateTemplate = NULL; +PFN_vkDestroyDevice glad_vkDestroyDevice = NULL; +PFN_vkDestroyEvent glad_vkDestroyEvent = NULL; +PFN_vkDestroyFence glad_vkDestroyFence = NULL; +PFN_vkDestroyFramebuffer glad_vkDestroyFramebuffer = NULL; +PFN_vkDestroyImage glad_vkDestroyImage = NULL; +PFN_vkDestroyImageView glad_vkDestroyImageView = NULL; +PFN_vkDestroyInstance glad_vkDestroyInstance = NULL; +PFN_vkDestroyPipeline glad_vkDestroyPipeline = NULL; +PFN_vkDestroyPipelineCache glad_vkDestroyPipelineCache = NULL; +PFN_vkDestroyPipelineLayout glad_vkDestroyPipelineLayout = NULL; +PFN_vkDestroyQueryPool glad_vkDestroyQueryPool = NULL; +PFN_vkDestroyRenderPass glad_vkDestroyRenderPass = NULL; +PFN_vkDestroySampler glad_vkDestroySampler = NULL; +PFN_vkDestroySamplerYcbcrConversion glad_vkDestroySamplerYcbcrConversion = NULL; +PFN_vkDestroySemaphore glad_vkDestroySemaphore = NULL; +PFN_vkDestroyShaderModule glad_vkDestroyShaderModule = NULL; +PFN_vkDestroySurfaceKHR glad_vkDestroySurfaceKHR = NULL; +PFN_vkDestroySwapchainKHR glad_vkDestroySwapchainKHR = NULL; +PFN_vkDeviceWaitIdle glad_vkDeviceWaitIdle = NULL; +PFN_vkEndCommandBuffer glad_vkEndCommandBuffer = NULL; +PFN_vkEnumerateDeviceExtensionProperties glad_vkEnumerateDeviceExtensionProperties = NULL; +PFN_vkEnumerateDeviceLayerProperties glad_vkEnumerateDeviceLayerProperties = NULL; +PFN_vkEnumerateInstanceExtensionProperties glad_vkEnumerateInstanceExtensionProperties = NULL; +PFN_vkEnumerateInstanceLayerProperties glad_vkEnumerateInstanceLayerProperties = NULL; +PFN_vkEnumerateInstanceVersion glad_vkEnumerateInstanceVersion = NULL; +PFN_vkEnumeratePhysicalDeviceGroups glad_vkEnumeratePhysicalDeviceGroups = NULL; +PFN_vkEnumeratePhysicalDevices glad_vkEnumeratePhysicalDevices = NULL; +PFN_vkFlushMappedMemoryRanges glad_vkFlushMappedMemoryRanges = NULL; +PFN_vkFreeCommandBuffers glad_vkFreeCommandBuffers = NULL; +PFN_vkFreeDescriptorSets glad_vkFreeDescriptorSets = NULL; +PFN_vkFreeMemory glad_vkFreeMemory = NULL; +PFN_vkGetBufferMemoryRequirements glad_vkGetBufferMemoryRequirements = NULL; +PFN_vkGetBufferMemoryRequirements2 glad_vkGetBufferMemoryRequirements2 = NULL; +PFN_vkGetDescriptorSetLayoutSupport glad_vkGetDescriptorSetLayoutSupport = NULL; +PFN_vkGetDeviceGroupPeerMemoryFeatures glad_vkGetDeviceGroupPeerMemoryFeatures = NULL; +PFN_vkGetDeviceGroupPresentCapabilitiesKHR glad_vkGetDeviceGroupPresentCapabilitiesKHR = NULL; +PFN_vkGetDeviceGroupSurfacePresentModesKHR glad_vkGetDeviceGroupSurfacePresentModesKHR = NULL; +PFN_vkGetDeviceMemoryCommitment glad_vkGetDeviceMemoryCommitment = NULL; +PFN_vkGetDeviceProcAddr glad_vkGetDeviceProcAddr = NULL; +PFN_vkGetDeviceQueue glad_vkGetDeviceQueue = NULL; +PFN_vkGetDeviceQueue2 glad_vkGetDeviceQueue2 = NULL; +PFN_vkGetEventStatus glad_vkGetEventStatus = NULL; +PFN_vkGetFenceStatus glad_vkGetFenceStatus = NULL; +PFN_vkGetImageMemoryRequirements glad_vkGetImageMemoryRequirements = NULL; +PFN_vkGetImageMemoryRequirements2 glad_vkGetImageMemoryRequirements2 = NULL; +PFN_vkGetImageSparseMemoryRequirements glad_vkGetImageSparseMemoryRequirements = NULL; +PFN_vkGetImageSparseMemoryRequirements2 glad_vkGetImageSparseMemoryRequirements2 = NULL; +PFN_vkGetImageSubresourceLayout glad_vkGetImageSubresourceLayout = NULL; +PFN_vkGetInstanceProcAddr glad_vkGetInstanceProcAddr = NULL; +PFN_vkGetPhysicalDeviceExternalBufferProperties glad_vkGetPhysicalDeviceExternalBufferProperties = NULL; +PFN_vkGetPhysicalDeviceExternalFenceProperties glad_vkGetPhysicalDeviceExternalFenceProperties = NULL; +PFN_vkGetPhysicalDeviceExternalSemaphoreProperties glad_vkGetPhysicalDeviceExternalSemaphoreProperties = NULL; +PFN_vkGetPhysicalDeviceFeatures glad_vkGetPhysicalDeviceFeatures = NULL; +PFN_vkGetPhysicalDeviceFeatures2 glad_vkGetPhysicalDeviceFeatures2 = NULL; +PFN_vkGetPhysicalDeviceFormatProperties glad_vkGetPhysicalDeviceFormatProperties = NULL; +PFN_vkGetPhysicalDeviceFormatProperties2 glad_vkGetPhysicalDeviceFormatProperties2 = NULL; +PFN_vkGetPhysicalDeviceImageFormatProperties glad_vkGetPhysicalDeviceImageFormatProperties = NULL; +PFN_vkGetPhysicalDeviceImageFormatProperties2 glad_vkGetPhysicalDeviceImageFormatProperties2 = NULL; +PFN_vkGetPhysicalDeviceMemoryProperties glad_vkGetPhysicalDeviceMemoryProperties = NULL; +PFN_vkGetPhysicalDeviceMemoryProperties2 glad_vkGetPhysicalDeviceMemoryProperties2 = NULL; +PFN_vkGetPhysicalDevicePresentRectanglesKHR glad_vkGetPhysicalDevicePresentRectanglesKHR = NULL; +PFN_vkGetPhysicalDeviceProperties glad_vkGetPhysicalDeviceProperties = NULL; +PFN_vkGetPhysicalDeviceProperties2 glad_vkGetPhysicalDeviceProperties2 = NULL; +PFN_vkGetPhysicalDeviceQueueFamilyProperties glad_vkGetPhysicalDeviceQueueFamilyProperties = NULL; +PFN_vkGetPhysicalDeviceQueueFamilyProperties2 glad_vkGetPhysicalDeviceQueueFamilyProperties2 = NULL; +PFN_vkGetPhysicalDeviceSparseImageFormatProperties glad_vkGetPhysicalDeviceSparseImageFormatProperties = NULL; +PFN_vkGetPhysicalDeviceSparseImageFormatProperties2 glad_vkGetPhysicalDeviceSparseImageFormatProperties2 = NULL; +PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR glad_vkGetPhysicalDeviceSurfaceCapabilitiesKHR = NULL; +PFN_vkGetPhysicalDeviceSurfaceFormatsKHR glad_vkGetPhysicalDeviceSurfaceFormatsKHR = NULL; +PFN_vkGetPhysicalDeviceSurfacePresentModesKHR glad_vkGetPhysicalDeviceSurfacePresentModesKHR = NULL; +PFN_vkGetPhysicalDeviceSurfaceSupportKHR glad_vkGetPhysicalDeviceSurfaceSupportKHR = NULL; +PFN_vkGetPipelineCacheData glad_vkGetPipelineCacheData = NULL; +PFN_vkGetQueryPoolResults glad_vkGetQueryPoolResults = NULL; +PFN_vkGetRenderAreaGranularity glad_vkGetRenderAreaGranularity = NULL; +PFN_vkGetSwapchainImagesKHR glad_vkGetSwapchainImagesKHR = NULL; +PFN_vkInvalidateMappedMemoryRanges glad_vkInvalidateMappedMemoryRanges = NULL; +PFN_vkMapMemory glad_vkMapMemory = NULL; +PFN_vkMergePipelineCaches glad_vkMergePipelineCaches = NULL; +PFN_vkQueueBindSparse glad_vkQueueBindSparse = NULL; +PFN_vkQueuePresentKHR glad_vkQueuePresentKHR = NULL; +PFN_vkQueueSubmit glad_vkQueueSubmit = NULL; +PFN_vkQueueWaitIdle glad_vkQueueWaitIdle = NULL; +PFN_vkResetCommandBuffer glad_vkResetCommandBuffer = NULL; +PFN_vkResetCommandPool glad_vkResetCommandPool = NULL; +PFN_vkResetDescriptorPool glad_vkResetDescriptorPool = NULL; +PFN_vkResetEvent glad_vkResetEvent = NULL; +PFN_vkResetFences glad_vkResetFences = NULL; +PFN_vkSetEvent glad_vkSetEvent = NULL; +PFN_vkTrimCommandPool glad_vkTrimCommandPool = NULL; +PFN_vkUnmapMemory glad_vkUnmapMemory = NULL; +PFN_vkUpdateDescriptorSetWithTemplate glad_vkUpdateDescriptorSetWithTemplate = NULL; +PFN_vkUpdateDescriptorSets glad_vkUpdateDescriptorSets = NULL; +PFN_vkWaitForFences glad_vkWaitForFences = NULL; + + +static void glad_vk_load_VK_VERSION_1_0( GLADuserptrloadfunc load, void* userptr) { + if(!GLAD_VK_VERSION_1_0) return; + glad_vkAllocateCommandBuffers = (PFN_vkAllocateCommandBuffers) load(userptr, "vkAllocateCommandBuffers"); + glad_vkAllocateDescriptorSets = (PFN_vkAllocateDescriptorSets) load(userptr, "vkAllocateDescriptorSets"); + glad_vkAllocateMemory = (PFN_vkAllocateMemory) load(userptr, "vkAllocateMemory"); + glad_vkBeginCommandBuffer = (PFN_vkBeginCommandBuffer) load(userptr, "vkBeginCommandBuffer"); + glad_vkBindBufferMemory = (PFN_vkBindBufferMemory) load(userptr, "vkBindBufferMemory"); + glad_vkBindImageMemory = (PFN_vkBindImageMemory) load(userptr, "vkBindImageMemory"); + glad_vkCmdBeginQuery = (PFN_vkCmdBeginQuery) load(userptr, "vkCmdBeginQuery"); + glad_vkCmdBeginRenderPass = (PFN_vkCmdBeginRenderPass) load(userptr, "vkCmdBeginRenderPass"); + glad_vkCmdBindDescriptorSets = (PFN_vkCmdBindDescriptorSets) load(userptr, "vkCmdBindDescriptorSets"); + glad_vkCmdBindIndexBuffer = (PFN_vkCmdBindIndexBuffer) load(userptr, "vkCmdBindIndexBuffer"); + glad_vkCmdBindPipeline = (PFN_vkCmdBindPipeline) load(userptr, "vkCmdBindPipeline"); + glad_vkCmdBindVertexBuffers = (PFN_vkCmdBindVertexBuffers) load(userptr, "vkCmdBindVertexBuffers"); + glad_vkCmdBlitImage = (PFN_vkCmdBlitImage) load(userptr, "vkCmdBlitImage"); + glad_vkCmdClearAttachments = (PFN_vkCmdClearAttachments) load(userptr, "vkCmdClearAttachments"); + glad_vkCmdClearColorImage = (PFN_vkCmdClearColorImage) load(userptr, "vkCmdClearColorImage"); + glad_vkCmdClearDepthStencilImage = (PFN_vkCmdClearDepthStencilImage) load(userptr, "vkCmdClearDepthStencilImage"); + glad_vkCmdCopyBuffer = (PFN_vkCmdCopyBuffer) load(userptr, "vkCmdCopyBuffer"); + glad_vkCmdCopyBufferToImage = (PFN_vkCmdCopyBufferToImage) load(userptr, "vkCmdCopyBufferToImage"); + glad_vkCmdCopyImage = (PFN_vkCmdCopyImage) load(userptr, "vkCmdCopyImage"); + glad_vkCmdCopyImageToBuffer = (PFN_vkCmdCopyImageToBuffer) load(userptr, "vkCmdCopyImageToBuffer"); + glad_vkCmdCopyQueryPoolResults = (PFN_vkCmdCopyQueryPoolResults) load(userptr, "vkCmdCopyQueryPoolResults"); + glad_vkCmdDispatch = (PFN_vkCmdDispatch) load(userptr, "vkCmdDispatch"); + glad_vkCmdDispatchIndirect = (PFN_vkCmdDispatchIndirect) load(userptr, "vkCmdDispatchIndirect"); + glad_vkCmdDraw = (PFN_vkCmdDraw) load(userptr, "vkCmdDraw"); + glad_vkCmdDrawIndexed = (PFN_vkCmdDrawIndexed) load(userptr, "vkCmdDrawIndexed"); + glad_vkCmdDrawIndexedIndirect = (PFN_vkCmdDrawIndexedIndirect) load(userptr, "vkCmdDrawIndexedIndirect"); + glad_vkCmdDrawIndirect = (PFN_vkCmdDrawIndirect) load(userptr, "vkCmdDrawIndirect"); + glad_vkCmdEndQuery = (PFN_vkCmdEndQuery) load(userptr, "vkCmdEndQuery"); + glad_vkCmdEndRenderPass = (PFN_vkCmdEndRenderPass) load(userptr, "vkCmdEndRenderPass"); + glad_vkCmdExecuteCommands = (PFN_vkCmdExecuteCommands) load(userptr, "vkCmdExecuteCommands"); + glad_vkCmdFillBuffer = (PFN_vkCmdFillBuffer) load(userptr, "vkCmdFillBuffer"); + glad_vkCmdNextSubpass = (PFN_vkCmdNextSubpass) load(userptr, "vkCmdNextSubpass"); + glad_vkCmdPipelineBarrier = (PFN_vkCmdPipelineBarrier) load(userptr, "vkCmdPipelineBarrier"); + glad_vkCmdPushConstants = (PFN_vkCmdPushConstants) load(userptr, "vkCmdPushConstants"); + glad_vkCmdResetEvent = (PFN_vkCmdResetEvent) load(userptr, "vkCmdResetEvent"); + glad_vkCmdResetQueryPool = (PFN_vkCmdResetQueryPool) load(userptr, "vkCmdResetQueryPool"); + glad_vkCmdResolveImage = (PFN_vkCmdResolveImage) load(userptr, "vkCmdResolveImage"); + glad_vkCmdSetBlendConstants = (PFN_vkCmdSetBlendConstants) load(userptr, "vkCmdSetBlendConstants"); + glad_vkCmdSetDepthBias = (PFN_vkCmdSetDepthBias) load(userptr, "vkCmdSetDepthBias"); + glad_vkCmdSetDepthBounds = (PFN_vkCmdSetDepthBounds) load(userptr, "vkCmdSetDepthBounds"); + glad_vkCmdSetEvent = (PFN_vkCmdSetEvent) load(userptr, "vkCmdSetEvent"); + glad_vkCmdSetLineWidth = (PFN_vkCmdSetLineWidth) load(userptr, "vkCmdSetLineWidth"); + glad_vkCmdSetScissor = (PFN_vkCmdSetScissor) load(userptr, "vkCmdSetScissor"); + glad_vkCmdSetStencilCompareMask = (PFN_vkCmdSetStencilCompareMask) load(userptr, "vkCmdSetStencilCompareMask"); + glad_vkCmdSetStencilReference = (PFN_vkCmdSetStencilReference) load(userptr, "vkCmdSetStencilReference"); + glad_vkCmdSetStencilWriteMask = (PFN_vkCmdSetStencilWriteMask) load(userptr, "vkCmdSetStencilWriteMask"); + glad_vkCmdSetViewport = (PFN_vkCmdSetViewport) load(userptr, "vkCmdSetViewport"); + glad_vkCmdUpdateBuffer = (PFN_vkCmdUpdateBuffer) load(userptr, "vkCmdUpdateBuffer"); + glad_vkCmdWaitEvents = (PFN_vkCmdWaitEvents) load(userptr, "vkCmdWaitEvents"); + glad_vkCmdWriteTimestamp = (PFN_vkCmdWriteTimestamp) load(userptr, "vkCmdWriteTimestamp"); + glad_vkCreateBuffer = (PFN_vkCreateBuffer) load(userptr, "vkCreateBuffer"); + glad_vkCreateBufferView = (PFN_vkCreateBufferView) load(userptr, "vkCreateBufferView"); + glad_vkCreateCommandPool = (PFN_vkCreateCommandPool) load(userptr, "vkCreateCommandPool"); + glad_vkCreateComputePipelines = (PFN_vkCreateComputePipelines) load(userptr, "vkCreateComputePipelines"); + glad_vkCreateDescriptorPool = (PFN_vkCreateDescriptorPool) load(userptr, "vkCreateDescriptorPool"); + glad_vkCreateDescriptorSetLayout = (PFN_vkCreateDescriptorSetLayout) load(userptr, "vkCreateDescriptorSetLayout"); + glad_vkCreateDevice = (PFN_vkCreateDevice) load(userptr, "vkCreateDevice"); + glad_vkCreateEvent = (PFN_vkCreateEvent) load(userptr, "vkCreateEvent"); + glad_vkCreateFence = (PFN_vkCreateFence) load(userptr, "vkCreateFence"); + glad_vkCreateFramebuffer = (PFN_vkCreateFramebuffer) load(userptr, "vkCreateFramebuffer"); + glad_vkCreateGraphicsPipelines = (PFN_vkCreateGraphicsPipelines) load(userptr, "vkCreateGraphicsPipelines"); + glad_vkCreateImage = (PFN_vkCreateImage) load(userptr, "vkCreateImage"); + glad_vkCreateImageView = (PFN_vkCreateImageView) load(userptr, "vkCreateImageView"); + glad_vkCreateInstance = (PFN_vkCreateInstance) load(userptr, "vkCreateInstance"); + glad_vkCreatePipelineCache = (PFN_vkCreatePipelineCache) load(userptr, "vkCreatePipelineCache"); + glad_vkCreatePipelineLayout = (PFN_vkCreatePipelineLayout) load(userptr, "vkCreatePipelineLayout"); + glad_vkCreateQueryPool = (PFN_vkCreateQueryPool) load(userptr, "vkCreateQueryPool"); + glad_vkCreateRenderPass = (PFN_vkCreateRenderPass) load(userptr, "vkCreateRenderPass"); + glad_vkCreateSampler = (PFN_vkCreateSampler) load(userptr, "vkCreateSampler"); + glad_vkCreateSemaphore = (PFN_vkCreateSemaphore) load(userptr, "vkCreateSemaphore"); + glad_vkCreateShaderModule = (PFN_vkCreateShaderModule) load(userptr, "vkCreateShaderModule"); + glad_vkDestroyBuffer = (PFN_vkDestroyBuffer) load(userptr, "vkDestroyBuffer"); + glad_vkDestroyBufferView = (PFN_vkDestroyBufferView) load(userptr, "vkDestroyBufferView"); + glad_vkDestroyCommandPool = (PFN_vkDestroyCommandPool) load(userptr, "vkDestroyCommandPool"); + glad_vkDestroyDescriptorPool = (PFN_vkDestroyDescriptorPool) load(userptr, "vkDestroyDescriptorPool"); + glad_vkDestroyDescriptorSetLayout = (PFN_vkDestroyDescriptorSetLayout) load(userptr, "vkDestroyDescriptorSetLayout"); + glad_vkDestroyDevice = (PFN_vkDestroyDevice) load(userptr, "vkDestroyDevice"); + glad_vkDestroyEvent = (PFN_vkDestroyEvent) load(userptr, "vkDestroyEvent"); + glad_vkDestroyFence = (PFN_vkDestroyFence) load(userptr, "vkDestroyFence"); + glad_vkDestroyFramebuffer = (PFN_vkDestroyFramebuffer) load(userptr, "vkDestroyFramebuffer"); + glad_vkDestroyImage = (PFN_vkDestroyImage) load(userptr, "vkDestroyImage"); + glad_vkDestroyImageView = (PFN_vkDestroyImageView) load(userptr, "vkDestroyImageView"); + glad_vkDestroyInstance = (PFN_vkDestroyInstance) load(userptr, "vkDestroyInstance"); + glad_vkDestroyPipeline = (PFN_vkDestroyPipeline) load(userptr, "vkDestroyPipeline"); + glad_vkDestroyPipelineCache = (PFN_vkDestroyPipelineCache) load(userptr, "vkDestroyPipelineCache"); + glad_vkDestroyPipelineLayout = (PFN_vkDestroyPipelineLayout) load(userptr, "vkDestroyPipelineLayout"); + glad_vkDestroyQueryPool = (PFN_vkDestroyQueryPool) load(userptr, "vkDestroyQueryPool"); + glad_vkDestroyRenderPass = (PFN_vkDestroyRenderPass) load(userptr, "vkDestroyRenderPass"); + glad_vkDestroySampler = (PFN_vkDestroySampler) load(userptr, "vkDestroySampler"); + glad_vkDestroySemaphore = (PFN_vkDestroySemaphore) load(userptr, "vkDestroySemaphore"); + glad_vkDestroyShaderModule = (PFN_vkDestroyShaderModule) load(userptr, "vkDestroyShaderModule"); + glad_vkDeviceWaitIdle = (PFN_vkDeviceWaitIdle) load(userptr, "vkDeviceWaitIdle"); + glad_vkEndCommandBuffer = (PFN_vkEndCommandBuffer) load(userptr, "vkEndCommandBuffer"); + glad_vkEnumerateDeviceExtensionProperties = (PFN_vkEnumerateDeviceExtensionProperties) load(userptr, "vkEnumerateDeviceExtensionProperties"); + glad_vkEnumerateDeviceLayerProperties = (PFN_vkEnumerateDeviceLayerProperties) load(userptr, "vkEnumerateDeviceLayerProperties"); + glad_vkEnumerateInstanceExtensionProperties = (PFN_vkEnumerateInstanceExtensionProperties) load(userptr, "vkEnumerateInstanceExtensionProperties"); + glad_vkEnumerateInstanceLayerProperties = (PFN_vkEnumerateInstanceLayerProperties) load(userptr, "vkEnumerateInstanceLayerProperties"); + glad_vkEnumeratePhysicalDevices = (PFN_vkEnumeratePhysicalDevices) load(userptr, "vkEnumeratePhysicalDevices"); + glad_vkFlushMappedMemoryRanges = (PFN_vkFlushMappedMemoryRanges) load(userptr, "vkFlushMappedMemoryRanges"); + glad_vkFreeCommandBuffers = (PFN_vkFreeCommandBuffers) load(userptr, "vkFreeCommandBuffers"); + glad_vkFreeDescriptorSets = (PFN_vkFreeDescriptorSets) load(userptr, "vkFreeDescriptorSets"); + glad_vkFreeMemory = (PFN_vkFreeMemory) load(userptr, "vkFreeMemory"); + glad_vkGetBufferMemoryRequirements = (PFN_vkGetBufferMemoryRequirements) load(userptr, "vkGetBufferMemoryRequirements"); + glad_vkGetDeviceMemoryCommitment = (PFN_vkGetDeviceMemoryCommitment) load(userptr, "vkGetDeviceMemoryCommitment"); + glad_vkGetDeviceProcAddr = (PFN_vkGetDeviceProcAddr) load(userptr, "vkGetDeviceProcAddr"); + glad_vkGetDeviceQueue = (PFN_vkGetDeviceQueue) load(userptr, "vkGetDeviceQueue"); + glad_vkGetEventStatus = (PFN_vkGetEventStatus) load(userptr, "vkGetEventStatus"); + glad_vkGetFenceStatus = (PFN_vkGetFenceStatus) load(userptr, "vkGetFenceStatus"); + glad_vkGetImageMemoryRequirements = (PFN_vkGetImageMemoryRequirements) load(userptr, "vkGetImageMemoryRequirements"); + glad_vkGetImageSparseMemoryRequirements = (PFN_vkGetImageSparseMemoryRequirements) load(userptr, "vkGetImageSparseMemoryRequirements"); + glad_vkGetImageSubresourceLayout = (PFN_vkGetImageSubresourceLayout) load(userptr, "vkGetImageSubresourceLayout"); + glad_vkGetInstanceProcAddr = (PFN_vkGetInstanceProcAddr) load(userptr, "vkGetInstanceProcAddr"); + glad_vkGetPhysicalDeviceFeatures = (PFN_vkGetPhysicalDeviceFeatures) load(userptr, "vkGetPhysicalDeviceFeatures"); + glad_vkGetPhysicalDeviceFormatProperties = (PFN_vkGetPhysicalDeviceFormatProperties) load(userptr, "vkGetPhysicalDeviceFormatProperties"); + glad_vkGetPhysicalDeviceImageFormatProperties = (PFN_vkGetPhysicalDeviceImageFormatProperties) load(userptr, "vkGetPhysicalDeviceImageFormatProperties"); + glad_vkGetPhysicalDeviceMemoryProperties = (PFN_vkGetPhysicalDeviceMemoryProperties) load(userptr, "vkGetPhysicalDeviceMemoryProperties"); + glad_vkGetPhysicalDeviceProperties = (PFN_vkGetPhysicalDeviceProperties) load(userptr, "vkGetPhysicalDeviceProperties"); + glad_vkGetPhysicalDeviceQueueFamilyProperties = (PFN_vkGetPhysicalDeviceQueueFamilyProperties) load(userptr, "vkGetPhysicalDeviceQueueFamilyProperties"); + glad_vkGetPhysicalDeviceSparseImageFormatProperties = (PFN_vkGetPhysicalDeviceSparseImageFormatProperties) load(userptr, "vkGetPhysicalDeviceSparseImageFormatProperties"); + glad_vkGetPipelineCacheData = (PFN_vkGetPipelineCacheData) load(userptr, "vkGetPipelineCacheData"); + glad_vkGetQueryPoolResults = (PFN_vkGetQueryPoolResults) load(userptr, "vkGetQueryPoolResults"); + glad_vkGetRenderAreaGranularity = (PFN_vkGetRenderAreaGranularity) load(userptr, "vkGetRenderAreaGranularity"); + glad_vkInvalidateMappedMemoryRanges = (PFN_vkInvalidateMappedMemoryRanges) load(userptr, "vkInvalidateMappedMemoryRanges"); + glad_vkMapMemory = (PFN_vkMapMemory) load(userptr, "vkMapMemory"); + glad_vkMergePipelineCaches = (PFN_vkMergePipelineCaches) load(userptr, "vkMergePipelineCaches"); + glad_vkQueueBindSparse = (PFN_vkQueueBindSparse) load(userptr, "vkQueueBindSparse"); + glad_vkQueueSubmit = (PFN_vkQueueSubmit) load(userptr, "vkQueueSubmit"); + glad_vkQueueWaitIdle = (PFN_vkQueueWaitIdle) load(userptr, "vkQueueWaitIdle"); + glad_vkResetCommandBuffer = (PFN_vkResetCommandBuffer) load(userptr, "vkResetCommandBuffer"); + glad_vkResetCommandPool = (PFN_vkResetCommandPool) load(userptr, "vkResetCommandPool"); + glad_vkResetDescriptorPool = (PFN_vkResetDescriptorPool) load(userptr, "vkResetDescriptorPool"); + glad_vkResetEvent = (PFN_vkResetEvent) load(userptr, "vkResetEvent"); + glad_vkResetFences = (PFN_vkResetFences) load(userptr, "vkResetFences"); + glad_vkSetEvent = (PFN_vkSetEvent) load(userptr, "vkSetEvent"); + glad_vkUnmapMemory = (PFN_vkUnmapMemory) load(userptr, "vkUnmapMemory"); + glad_vkUpdateDescriptorSets = (PFN_vkUpdateDescriptorSets) load(userptr, "vkUpdateDescriptorSets"); + glad_vkWaitForFences = (PFN_vkWaitForFences) load(userptr, "vkWaitForFences"); +} +static void glad_vk_load_VK_VERSION_1_1( GLADuserptrloadfunc load, void* userptr) { + if(!GLAD_VK_VERSION_1_1) return; + glad_vkBindBufferMemory2 = (PFN_vkBindBufferMemory2) load(userptr, "vkBindBufferMemory2"); + glad_vkBindImageMemory2 = (PFN_vkBindImageMemory2) load(userptr, "vkBindImageMemory2"); + glad_vkCmdDispatchBase = (PFN_vkCmdDispatchBase) load(userptr, "vkCmdDispatchBase"); + glad_vkCmdSetDeviceMask = (PFN_vkCmdSetDeviceMask) load(userptr, "vkCmdSetDeviceMask"); + glad_vkCreateDescriptorUpdateTemplate = (PFN_vkCreateDescriptorUpdateTemplate) load(userptr, "vkCreateDescriptorUpdateTemplate"); + glad_vkCreateSamplerYcbcrConversion = (PFN_vkCreateSamplerYcbcrConversion) load(userptr, "vkCreateSamplerYcbcrConversion"); + glad_vkDestroyDescriptorUpdateTemplate = (PFN_vkDestroyDescriptorUpdateTemplate) load(userptr, "vkDestroyDescriptorUpdateTemplate"); + glad_vkDestroySamplerYcbcrConversion = (PFN_vkDestroySamplerYcbcrConversion) load(userptr, "vkDestroySamplerYcbcrConversion"); + glad_vkEnumerateInstanceVersion = (PFN_vkEnumerateInstanceVersion) load(userptr, "vkEnumerateInstanceVersion"); + glad_vkEnumeratePhysicalDeviceGroups = (PFN_vkEnumeratePhysicalDeviceGroups) load(userptr, "vkEnumeratePhysicalDeviceGroups"); + glad_vkGetBufferMemoryRequirements2 = (PFN_vkGetBufferMemoryRequirements2) load(userptr, "vkGetBufferMemoryRequirements2"); + glad_vkGetDescriptorSetLayoutSupport = (PFN_vkGetDescriptorSetLayoutSupport) load(userptr, "vkGetDescriptorSetLayoutSupport"); + glad_vkGetDeviceGroupPeerMemoryFeatures = (PFN_vkGetDeviceGroupPeerMemoryFeatures) load(userptr, "vkGetDeviceGroupPeerMemoryFeatures"); + glad_vkGetDeviceQueue2 = (PFN_vkGetDeviceQueue2) load(userptr, "vkGetDeviceQueue2"); + glad_vkGetImageMemoryRequirements2 = (PFN_vkGetImageMemoryRequirements2) load(userptr, "vkGetImageMemoryRequirements2"); + glad_vkGetImageSparseMemoryRequirements2 = (PFN_vkGetImageSparseMemoryRequirements2) load(userptr, "vkGetImageSparseMemoryRequirements2"); + glad_vkGetPhysicalDeviceExternalBufferProperties = (PFN_vkGetPhysicalDeviceExternalBufferProperties) load(userptr, "vkGetPhysicalDeviceExternalBufferProperties"); + glad_vkGetPhysicalDeviceExternalFenceProperties = (PFN_vkGetPhysicalDeviceExternalFenceProperties) load(userptr, "vkGetPhysicalDeviceExternalFenceProperties"); + glad_vkGetPhysicalDeviceExternalSemaphoreProperties = (PFN_vkGetPhysicalDeviceExternalSemaphoreProperties) load(userptr, "vkGetPhysicalDeviceExternalSemaphoreProperties"); + glad_vkGetPhysicalDeviceFeatures2 = (PFN_vkGetPhysicalDeviceFeatures2) load(userptr, "vkGetPhysicalDeviceFeatures2"); + glad_vkGetPhysicalDeviceFormatProperties2 = (PFN_vkGetPhysicalDeviceFormatProperties2) load(userptr, "vkGetPhysicalDeviceFormatProperties2"); + glad_vkGetPhysicalDeviceImageFormatProperties2 = (PFN_vkGetPhysicalDeviceImageFormatProperties2) load(userptr, "vkGetPhysicalDeviceImageFormatProperties2"); + glad_vkGetPhysicalDeviceMemoryProperties2 = (PFN_vkGetPhysicalDeviceMemoryProperties2) load(userptr, "vkGetPhysicalDeviceMemoryProperties2"); + glad_vkGetPhysicalDeviceProperties2 = (PFN_vkGetPhysicalDeviceProperties2) load(userptr, "vkGetPhysicalDeviceProperties2"); + glad_vkGetPhysicalDeviceQueueFamilyProperties2 = (PFN_vkGetPhysicalDeviceQueueFamilyProperties2) load(userptr, "vkGetPhysicalDeviceQueueFamilyProperties2"); + glad_vkGetPhysicalDeviceSparseImageFormatProperties2 = (PFN_vkGetPhysicalDeviceSparseImageFormatProperties2) load(userptr, "vkGetPhysicalDeviceSparseImageFormatProperties2"); + glad_vkTrimCommandPool = (PFN_vkTrimCommandPool) load(userptr, "vkTrimCommandPool"); + glad_vkUpdateDescriptorSetWithTemplate = (PFN_vkUpdateDescriptorSetWithTemplate) load(userptr, "vkUpdateDescriptorSetWithTemplate"); +} +static void glad_vk_load_VK_EXT_debug_report( GLADuserptrloadfunc load, void* userptr) { + if(!GLAD_VK_EXT_debug_report) return; + glad_vkCreateDebugReportCallbackEXT = (PFN_vkCreateDebugReportCallbackEXT) load(userptr, "vkCreateDebugReportCallbackEXT"); + glad_vkDebugReportMessageEXT = (PFN_vkDebugReportMessageEXT) load(userptr, "vkDebugReportMessageEXT"); + glad_vkDestroyDebugReportCallbackEXT = (PFN_vkDestroyDebugReportCallbackEXT) load(userptr, "vkDestroyDebugReportCallbackEXT"); +} +static void glad_vk_load_VK_KHR_surface( GLADuserptrloadfunc load, void* userptr) { + if(!GLAD_VK_KHR_surface) return; + glad_vkDestroySurfaceKHR = (PFN_vkDestroySurfaceKHR) load(userptr, "vkDestroySurfaceKHR"); + glad_vkGetPhysicalDeviceSurfaceCapabilitiesKHR = (PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR) load(userptr, "vkGetPhysicalDeviceSurfaceCapabilitiesKHR"); + glad_vkGetPhysicalDeviceSurfaceFormatsKHR = (PFN_vkGetPhysicalDeviceSurfaceFormatsKHR) load(userptr, "vkGetPhysicalDeviceSurfaceFormatsKHR"); + glad_vkGetPhysicalDeviceSurfacePresentModesKHR = (PFN_vkGetPhysicalDeviceSurfacePresentModesKHR) load(userptr, "vkGetPhysicalDeviceSurfacePresentModesKHR"); + glad_vkGetPhysicalDeviceSurfaceSupportKHR = (PFN_vkGetPhysicalDeviceSurfaceSupportKHR) load(userptr, "vkGetPhysicalDeviceSurfaceSupportKHR"); +} +static void glad_vk_load_VK_KHR_swapchain( GLADuserptrloadfunc load, void* userptr) { + if(!GLAD_VK_KHR_swapchain) return; + glad_vkAcquireNextImage2KHR = (PFN_vkAcquireNextImage2KHR) load(userptr, "vkAcquireNextImage2KHR"); + glad_vkAcquireNextImageKHR = (PFN_vkAcquireNextImageKHR) load(userptr, "vkAcquireNextImageKHR"); + glad_vkCreateSwapchainKHR = (PFN_vkCreateSwapchainKHR) load(userptr, "vkCreateSwapchainKHR"); + glad_vkDestroySwapchainKHR = (PFN_vkDestroySwapchainKHR) load(userptr, "vkDestroySwapchainKHR"); + glad_vkGetDeviceGroupPresentCapabilitiesKHR = (PFN_vkGetDeviceGroupPresentCapabilitiesKHR) load(userptr, "vkGetDeviceGroupPresentCapabilitiesKHR"); + glad_vkGetDeviceGroupSurfacePresentModesKHR = (PFN_vkGetDeviceGroupSurfacePresentModesKHR) load(userptr, "vkGetDeviceGroupSurfacePresentModesKHR"); + glad_vkGetPhysicalDevicePresentRectanglesKHR = (PFN_vkGetPhysicalDevicePresentRectanglesKHR) load(userptr, "vkGetPhysicalDevicePresentRectanglesKHR"); + glad_vkGetSwapchainImagesKHR = (PFN_vkGetSwapchainImagesKHR) load(userptr, "vkGetSwapchainImagesKHR"); + glad_vkQueuePresentKHR = (PFN_vkQueuePresentKHR) load(userptr, "vkQueuePresentKHR"); +} + + + +static int glad_vk_get_extensions( VkPhysicalDevice physical_device, uint32_t *out_extension_count, char ***out_extensions) { + uint32_t i; + uint32_t instance_extension_count = 0; + uint32_t device_extension_count = 0; + uint32_t max_extension_count = 0; + uint32_t total_extension_count = 0; + char **extensions = NULL; + VkExtensionProperties *ext_properties = NULL; + VkResult result; + + if (glad_vkEnumerateInstanceExtensionProperties == NULL || (physical_device != NULL && glad_vkEnumerateDeviceExtensionProperties == NULL)) { + return 0; + } + + result = glad_vkEnumerateInstanceExtensionProperties(NULL, &instance_extension_count, NULL); + if (result != VK_SUCCESS) { + return 0; + } + + if (physical_device != NULL) { + result = glad_vkEnumerateDeviceExtensionProperties(physical_device, NULL, &device_extension_count, NULL); + if (result != VK_SUCCESS) { + return 0; + } + } + + total_extension_count = instance_extension_count + device_extension_count; + if (total_extension_count <= 0) { + return 0; + } + + max_extension_count = instance_extension_count > device_extension_count + ? instance_extension_count : device_extension_count; + + ext_properties = (VkExtensionProperties*) malloc(max_extension_count * sizeof(VkExtensionProperties)); + if (ext_properties == NULL) { + goto glad_vk_get_extensions_error; + } + + result = glad_vkEnumerateInstanceExtensionProperties(NULL, &instance_extension_count, ext_properties); + if (result != VK_SUCCESS) { + goto glad_vk_get_extensions_error; + } + + extensions = (char**) calloc(total_extension_count, sizeof(char*)); + if (extensions == NULL) { + goto glad_vk_get_extensions_error; + } + + for (i = 0; i < instance_extension_count; ++i) { + VkExtensionProperties ext = ext_properties[i]; + + size_t extension_name_length = strlen(ext.extensionName) + 1; + extensions[i] = (char*) malloc(extension_name_length * sizeof(char)); + if (extensions[i] == NULL) { + goto glad_vk_get_extensions_error; + } + memcpy(extensions[i], ext.extensionName, extension_name_length * sizeof(char)); + } + + if (physical_device != NULL) { + result = glad_vkEnumerateDeviceExtensionProperties(physical_device, NULL, &device_extension_count, ext_properties); + if (result != VK_SUCCESS) { + goto glad_vk_get_extensions_error; + } + + for (i = 0; i < device_extension_count; ++i) { + VkExtensionProperties ext = ext_properties[i]; + + size_t extension_name_length = strlen(ext.extensionName) + 1; + extensions[instance_extension_count + i] = (char*) malloc(extension_name_length * sizeof(char)); + if (extensions[instance_extension_count + i] == NULL) { + goto glad_vk_get_extensions_error; + } + memcpy(extensions[instance_extension_count + i], ext.extensionName, extension_name_length * sizeof(char)); + } + } + + free((void*) ext_properties); + + *out_extension_count = total_extension_count; + *out_extensions = extensions; + + return 1; + +glad_vk_get_extensions_error: + free((void*) ext_properties); + if (extensions != NULL) { + for (i = 0; i < total_extension_count; ++i) { + free((void*) extensions[i]); + } + free(extensions); + } + return 0; +} + +static void glad_vk_free_extensions(uint32_t extension_count, char **extensions) { + uint32_t i; + + for(i = 0; i < extension_count ; ++i) { + free((void*) (extensions[i])); + } + + free((void*) extensions); +} + +static int glad_vk_has_extension(const char *name, uint32_t extension_count, char **extensions) { + uint32_t i; + + for (i = 0; i < extension_count; ++i) { + if(extensions[i] != NULL && strcmp(name, extensions[i]) == 0) { + return 1; + } + } + + return 0; +} + +static GLADapiproc glad_vk_get_proc_from_userptr(void *userptr, const char* name) { + return (GLAD_GNUC_EXTENSION (GLADapiproc (*)(const char *name)) userptr)(name); +} + +static int glad_vk_find_extensions_vulkan( VkPhysicalDevice physical_device) { + uint32_t extension_count = 0; + char **extensions = NULL; + if (!glad_vk_get_extensions(physical_device, &extension_count, &extensions)) return 0; + + GLAD_VK_EXT_debug_report = glad_vk_has_extension("VK_EXT_debug_report", extension_count, extensions); + GLAD_VK_KHR_surface = glad_vk_has_extension("VK_KHR_surface", extension_count, extensions); + GLAD_VK_KHR_swapchain = glad_vk_has_extension("VK_KHR_swapchain", extension_count, extensions); + + (void) glad_vk_has_extension; + + glad_vk_free_extensions(extension_count, extensions); + + return 1; +} + +static int glad_vk_find_core_vulkan( VkPhysicalDevice physical_device) { + int major = 1; + int minor = 0; + +#ifdef VK_VERSION_1_1 + if (glad_vkEnumerateInstanceVersion != NULL) { + uint32_t version; + VkResult result; + + result = glad_vkEnumerateInstanceVersion(&version); + if (result == VK_SUCCESS) { + major = (int) VK_VERSION_MAJOR(version); + minor = (int) VK_VERSION_MINOR(version); + } + } +#endif + + if (physical_device != NULL && glad_vkGetPhysicalDeviceProperties != NULL) { + VkPhysicalDeviceProperties properties; + glad_vkGetPhysicalDeviceProperties(physical_device, &properties); + + major = (int) VK_VERSION_MAJOR(properties.apiVersion); + minor = (int) VK_VERSION_MINOR(properties.apiVersion); + } + + GLAD_VK_VERSION_1_0 = (major == 1 && minor >= 0) || major > 1; + GLAD_VK_VERSION_1_1 = (major == 1 && minor >= 1) || major > 1; + + return GLAD_MAKE_VERSION(major, minor); +} + +int gladLoadVulkanUserPtr( VkPhysicalDevice physical_device, GLADuserptrloadfunc load, void *userptr) { + int version; + +#ifdef VK_VERSION_1_1 + glad_vkEnumerateInstanceVersion = (PFN_vkEnumerateInstanceVersion) load(userptr, "vkEnumerateInstanceVersion"); +#endif + version = glad_vk_find_core_vulkan( physical_device); + if (!version) { + return 0; + } + + glad_vk_load_VK_VERSION_1_0(load, userptr); + glad_vk_load_VK_VERSION_1_1(load, userptr); + + if (!glad_vk_find_extensions_vulkan( physical_device)) return 0; + glad_vk_load_VK_EXT_debug_report(load, userptr); + glad_vk_load_VK_KHR_surface(load, userptr); + glad_vk_load_VK_KHR_swapchain(load, userptr); + + + return version; +} + + +int gladLoadVulkan( VkPhysicalDevice physical_device, GLADloadfunc load) { + return gladLoadVulkanUserPtr( physical_device, glad_vk_get_proc_from_userptr, GLAD_GNUC_EXTENSION (void*) load); +} + + + + + + +#ifdef __cplusplus +} +#endif + +#endif /* GLAD_VULKAN_IMPLEMENTATION */ + diff --git a/deps/glad_gl.c b/deps/glad_gl.c deleted file mode 100644 index 2d4c87fe..00000000 --- a/deps/glad_gl.c +++ /dev/null @@ -1,1791 +0,0 @@ -#include -#include -#include -#include - -#ifndef GLAD_IMPL_UTIL_C_ -#define GLAD_IMPL_UTIL_C_ - -#ifdef _MSC_VER -#define GLAD_IMPL_UTIL_SSCANF sscanf_s -#else -#define GLAD_IMPL_UTIL_SSCANF sscanf -#endif - -#endif /* GLAD_IMPL_UTIL_C_ */ - - -int GLAD_GL_VERSION_1_0 = 0; -int GLAD_GL_VERSION_1_1 = 0; -int GLAD_GL_VERSION_1_2 = 0; -int GLAD_GL_VERSION_1_3 = 0; -int GLAD_GL_VERSION_1_4 = 0; -int GLAD_GL_VERSION_1_5 = 0; -int GLAD_GL_VERSION_2_0 = 0; -int GLAD_GL_VERSION_2_1 = 0; -int GLAD_GL_VERSION_3_0 = 0; -int GLAD_GL_VERSION_3_1 = 0; -int GLAD_GL_VERSION_3_2 = 0; -int GLAD_GL_VERSION_3_3 = 0; -int GLAD_GL_ARB_multisample = 0; -int GLAD_GL_ARB_robustness = 0; -int GLAD_GL_KHR_debug = 0; - - - -PFNGLACCUMPROC glad_glAccum = NULL; -PFNGLACTIVETEXTUREPROC glad_glActiveTexture = NULL; -PFNGLALPHAFUNCPROC glad_glAlphaFunc = NULL; -PFNGLARETEXTURESRESIDENTPROC glad_glAreTexturesResident = NULL; -PFNGLARRAYELEMENTPROC glad_glArrayElement = NULL; -PFNGLATTACHSHADERPROC glad_glAttachShader = NULL; -PFNGLBEGINPROC glad_glBegin = NULL; -PFNGLBEGINCONDITIONALRENDERPROC glad_glBeginConditionalRender = NULL; -PFNGLBEGINQUERYPROC glad_glBeginQuery = NULL; -PFNGLBEGINTRANSFORMFEEDBACKPROC glad_glBeginTransformFeedback = NULL; -PFNGLBINDATTRIBLOCATIONPROC glad_glBindAttribLocation = NULL; -PFNGLBINDBUFFERPROC glad_glBindBuffer = NULL; -PFNGLBINDBUFFERBASEPROC glad_glBindBufferBase = NULL; -PFNGLBINDBUFFERRANGEPROC glad_glBindBufferRange = NULL; -PFNGLBINDFRAGDATALOCATIONPROC glad_glBindFragDataLocation = NULL; -PFNGLBINDFRAGDATALOCATIONINDEXEDPROC glad_glBindFragDataLocationIndexed = NULL; -PFNGLBINDFRAMEBUFFERPROC glad_glBindFramebuffer = NULL; -PFNGLBINDRENDERBUFFERPROC glad_glBindRenderbuffer = NULL; -PFNGLBINDSAMPLERPROC glad_glBindSampler = NULL; -PFNGLBINDTEXTUREPROC glad_glBindTexture = NULL; -PFNGLBINDVERTEXARRAYPROC glad_glBindVertexArray = NULL; -PFNGLBITMAPPROC glad_glBitmap = NULL; -PFNGLBLENDCOLORPROC glad_glBlendColor = NULL; -PFNGLBLENDEQUATIONPROC glad_glBlendEquation = NULL; -PFNGLBLENDEQUATIONSEPARATEPROC glad_glBlendEquationSeparate = NULL; -PFNGLBLENDFUNCPROC glad_glBlendFunc = NULL; -PFNGLBLENDFUNCSEPARATEPROC glad_glBlendFuncSeparate = NULL; -PFNGLBLITFRAMEBUFFERPROC glad_glBlitFramebuffer = NULL; -PFNGLBUFFERDATAPROC glad_glBufferData = NULL; -PFNGLBUFFERSUBDATAPROC glad_glBufferSubData = NULL; -PFNGLCALLLISTPROC glad_glCallList = NULL; -PFNGLCALLLISTSPROC glad_glCallLists = NULL; -PFNGLCHECKFRAMEBUFFERSTATUSPROC glad_glCheckFramebufferStatus = NULL; -PFNGLCLAMPCOLORPROC glad_glClampColor = NULL; -PFNGLCLEARPROC glad_glClear = NULL; -PFNGLCLEARACCUMPROC glad_glClearAccum = NULL; -PFNGLCLEARBUFFERFIPROC glad_glClearBufferfi = NULL; -PFNGLCLEARBUFFERFVPROC glad_glClearBufferfv = NULL; -PFNGLCLEARBUFFERIVPROC glad_glClearBufferiv = NULL; -PFNGLCLEARBUFFERUIVPROC glad_glClearBufferuiv = NULL; -PFNGLCLEARCOLORPROC glad_glClearColor = NULL; -PFNGLCLEARDEPTHPROC glad_glClearDepth = NULL; -PFNGLCLEARINDEXPROC glad_glClearIndex = NULL; -PFNGLCLEARSTENCILPROC glad_glClearStencil = NULL; -PFNGLCLIENTACTIVETEXTUREPROC glad_glClientActiveTexture = NULL; -PFNGLCLIENTWAITSYNCPROC glad_glClientWaitSync = NULL; -PFNGLCLIPPLANEPROC glad_glClipPlane = NULL; -PFNGLCOLOR3BPROC glad_glColor3b = NULL; -PFNGLCOLOR3BVPROC glad_glColor3bv = NULL; -PFNGLCOLOR3DPROC glad_glColor3d = NULL; -PFNGLCOLOR3DVPROC glad_glColor3dv = NULL; -PFNGLCOLOR3FPROC glad_glColor3f = NULL; -PFNGLCOLOR3FVPROC glad_glColor3fv = NULL; -PFNGLCOLOR3IPROC glad_glColor3i = NULL; -PFNGLCOLOR3IVPROC glad_glColor3iv = NULL; -PFNGLCOLOR3SPROC glad_glColor3s = NULL; -PFNGLCOLOR3SVPROC glad_glColor3sv = NULL; -PFNGLCOLOR3UBPROC glad_glColor3ub = NULL; -PFNGLCOLOR3UBVPROC glad_glColor3ubv = NULL; -PFNGLCOLOR3UIPROC glad_glColor3ui = NULL; -PFNGLCOLOR3UIVPROC glad_glColor3uiv = NULL; -PFNGLCOLOR3USPROC glad_glColor3us = NULL; -PFNGLCOLOR3USVPROC glad_glColor3usv = NULL; -PFNGLCOLOR4BPROC glad_glColor4b = NULL; -PFNGLCOLOR4BVPROC glad_glColor4bv = NULL; -PFNGLCOLOR4DPROC glad_glColor4d = NULL; -PFNGLCOLOR4DVPROC glad_glColor4dv = NULL; -PFNGLCOLOR4FPROC glad_glColor4f = NULL; -PFNGLCOLOR4FVPROC glad_glColor4fv = NULL; -PFNGLCOLOR4IPROC glad_glColor4i = NULL; -PFNGLCOLOR4IVPROC glad_glColor4iv = NULL; -PFNGLCOLOR4SPROC glad_glColor4s = NULL; -PFNGLCOLOR4SVPROC glad_glColor4sv = NULL; -PFNGLCOLOR4UBPROC glad_glColor4ub = NULL; -PFNGLCOLOR4UBVPROC glad_glColor4ubv = NULL; -PFNGLCOLOR4UIPROC glad_glColor4ui = NULL; -PFNGLCOLOR4UIVPROC glad_glColor4uiv = NULL; -PFNGLCOLOR4USPROC glad_glColor4us = NULL; -PFNGLCOLOR4USVPROC glad_glColor4usv = NULL; -PFNGLCOLORMASKPROC glad_glColorMask = NULL; -PFNGLCOLORMASKIPROC glad_glColorMaski = NULL; -PFNGLCOLORMATERIALPROC glad_glColorMaterial = NULL; -PFNGLCOLORP3UIPROC glad_glColorP3ui = NULL; -PFNGLCOLORP3UIVPROC glad_glColorP3uiv = NULL; -PFNGLCOLORP4UIPROC glad_glColorP4ui = NULL; -PFNGLCOLORP4UIVPROC glad_glColorP4uiv = NULL; -PFNGLCOLORPOINTERPROC glad_glColorPointer = NULL; -PFNGLCOMPILESHADERPROC glad_glCompileShader = NULL; -PFNGLCOMPRESSEDTEXIMAGE1DPROC glad_glCompressedTexImage1D = NULL; -PFNGLCOMPRESSEDTEXIMAGE2DPROC glad_glCompressedTexImage2D = NULL; -PFNGLCOMPRESSEDTEXIMAGE3DPROC glad_glCompressedTexImage3D = NULL; -PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC glad_glCompressedTexSubImage1D = NULL; -PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC glad_glCompressedTexSubImage2D = NULL; -PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC glad_glCompressedTexSubImage3D = NULL; -PFNGLCOPYBUFFERSUBDATAPROC glad_glCopyBufferSubData = NULL; -PFNGLCOPYPIXELSPROC glad_glCopyPixels = NULL; -PFNGLCOPYTEXIMAGE1DPROC glad_glCopyTexImage1D = NULL; -PFNGLCOPYTEXIMAGE2DPROC glad_glCopyTexImage2D = NULL; -PFNGLCOPYTEXSUBIMAGE1DPROC glad_glCopyTexSubImage1D = NULL; -PFNGLCOPYTEXSUBIMAGE2DPROC glad_glCopyTexSubImage2D = NULL; -PFNGLCOPYTEXSUBIMAGE3DPROC glad_glCopyTexSubImage3D = NULL; -PFNGLCREATEPROGRAMPROC glad_glCreateProgram = NULL; -PFNGLCREATESHADERPROC glad_glCreateShader = NULL; -PFNGLCULLFACEPROC glad_glCullFace = NULL; -PFNGLDEBUGMESSAGECALLBACKPROC glad_glDebugMessageCallback = NULL; -PFNGLDEBUGMESSAGECONTROLPROC glad_glDebugMessageControl = NULL; -PFNGLDEBUGMESSAGEINSERTPROC glad_glDebugMessageInsert = NULL; -PFNGLDELETEBUFFERSPROC glad_glDeleteBuffers = NULL; -PFNGLDELETEFRAMEBUFFERSPROC glad_glDeleteFramebuffers = NULL; -PFNGLDELETELISTSPROC glad_glDeleteLists = NULL; -PFNGLDELETEPROGRAMPROC glad_glDeleteProgram = NULL; -PFNGLDELETEQUERIESPROC glad_glDeleteQueries = NULL; -PFNGLDELETERENDERBUFFERSPROC glad_glDeleteRenderbuffers = NULL; -PFNGLDELETESAMPLERSPROC glad_glDeleteSamplers = NULL; -PFNGLDELETESHADERPROC glad_glDeleteShader = NULL; -PFNGLDELETESYNCPROC glad_glDeleteSync = NULL; -PFNGLDELETETEXTURESPROC glad_glDeleteTextures = NULL; -PFNGLDELETEVERTEXARRAYSPROC glad_glDeleteVertexArrays = NULL; -PFNGLDEPTHFUNCPROC glad_glDepthFunc = NULL; -PFNGLDEPTHMASKPROC glad_glDepthMask = NULL; -PFNGLDEPTHRANGEPROC glad_glDepthRange = NULL; -PFNGLDETACHSHADERPROC glad_glDetachShader = NULL; -PFNGLDISABLEPROC glad_glDisable = NULL; -PFNGLDISABLECLIENTSTATEPROC glad_glDisableClientState = NULL; -PFNGLDISABLEVERTEXATTRIBARRAYPROC glad_glDisableVertexAttribArray = NULL; -PFNGLDISABLEIPROC glad_glDisablei = NULL; -PFNGLDRAWARRAYSPROC glad_glDrawArrays = NULL; -PFNGLDRAWARRAYSINSTANCEDPROC glad_glDrawArraysInstanced = NULL; -PFNGLDRAWBUFFERPROC glad_glDrawBuffer = NULL; -PFNGLDRAWBUFFERSPROC glad_glDrawBuffers = NULL; -PFNGLDRAWELEMENTSPROC glad_glDrawElements = NULL; -PFNGLDRAWELEMENTSBASEVERTEXPROC glad_glDrawElementsBaseVertex = NULL; -PFNGLDRAWELEMENTSINSTANCEDPROC glad_glDrawElementsInstanced = NULL; -PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC glad_glDrawElementsInstancedBaseVertex = NULL; -PFNGLDRAWPIXELSPROC glad_glDrawPixels = NULL; -PFNGLDRAWRANGEELEMENTSPROC glad_glDrawRangeElements = NULL; -PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC glad_glDrawRangeElementsBaseVertex = NULL; -PFNGLEDGEFLAGPROC glad_glEdgeFlag = NULL; -PFNGLEDGEFLAGPOINTERPROC glad_glEdgeFlagPointer = NULL; -PFNGLEDGEFLAGVPROC glad_glEdgeFlagv = NULL; -PFNGLENABLEPROC glad_glEnable = NULL; -PFNGLENABLECLIENTSTATEPROC glad_glEnableClientState = NULL; -PFNGLENABLEVERTEXATTRIBARRAYPROC glad_glEnableVertexAttribArray = NULL; -PFNGLENABLEIPROC glad_glEnablei = NULL; -PFNGLENDPROC glad_glEnd = NULL; -PFNGLENDCONDITIONALRENDERPROC glad_glEndConditionalRender = NULL; -PFNGLENDLISTPROC glad_glEndList = NULL; -PFNGLENDQUERYPROC glad_glEndQuery = NULL; -PFNGLENDTRANSFORMFEEDBACKPROC glad_glEndTransformFeedback = NULL; -PFNGLEVALCOORD1DPROC glad_glEvalCoord1d = NULL; -PFNGLEVALCOORD1DVPROC glad_glEvalCoord1dv = NULL; -PFNGLEVALCOORD1FPROC glad_glEvalCoord1f = NULL; -PFNGLEVALCOORD1FVPROC glad_glEvalCoord1fv = NULL; -PFNGLEVALCOORD2DPROC glad_glEvalCoord2d = NULL; -PFNGLEVALCOORD2DVPROC glad_glEvalCoord2dv = NULL; -PFNGLEVALCOORD2FPROC glad_glEvalCoord2f = NULL; -PFNGLEVALCOORD2FVPROC glad_glEvalCoord2fv = NULL; -PFNGLEVALMESH1PROC glad_glEvalMesh1 = NULL; -PFNGLEVALMESH2PROC glad_glEvalMesh2 = NULL; -PFNGLEVALPOINT1PROC glad_glEvalPoint1 = NULL; -PFNGLEVALPOINT2PROC glad_glEvalPoint2 = NULL; -PFNGLFEEDBACKBUFFERPROC glad_glFeedbackBuffer = NULL; -PFNGLFENCESYNCPROC glad_glFenceSync = NULL; -PFNGLFINISHPROC glad_glFinish = NULL; -PFNGLFLUSHPROC glad_glFlush = NULL; -PFNGLFLUSHMAPPEDBUFFERRANGEPROC glad_glFlushMappedBufferRange = NULL; -PFNGLFOGCOORDPOINTERPROC glad_glFogCoordPointer = NULL; -PFNGLFOGCOORDDPROC glad_glFogCoordd = NULL; -PFNGLFOGCOORDDVPROC glad_glFogCoorddv = NULL; -PFNGLFOGCOORDFPROC glad_glFogCoordf = NULL; -PFNGLFOGCOORDFVPROC glad_glFogCoordfv = NULL; -PFNGLFOGFPROC glad_glFogf = NULL; -PFNGLFOGFVPROC glad_glFogfv = NULL; -PFNGLFOGIPROC glad_glFogi = NULL; -PFNGLFOGIVPROC glad_glFogiv = NULL; -PFNGLFRAMEBUFFERRENDERBUFFERPROC glad_glFramebufferRenderbuffer = NULL; -PFNGLFRAMEBUFFERTEXTUREPROC glad_glFramebufferTexture = NULL; -PFNGLFRAMEBUFFERTEXTURE1DPROC glad_glFramebufferTexture1D = NULL; -PFNGLFRAMEBUFFERTEXTURE2DPROC glad_glFramebufferTexture2D = NULL; -PFNGLFRAMEBUFFERTEXTURE3DPROC glad_glFramebufferTexture3D = NULL; -PFNGLFRAMEBUFFERTEXTURELAYERPROC glad_glFramebufferTextureLayer = NULL; -PFNGLFRONTFACEPROC glad_glFrontFace = NULL; -PFNGLFRUSTUMPROC glad_glFrustum = NULL; -PFNGLGENBUFFERSPROC glad_glGenBuffers = NULL; -PFNGLGENFRAMEBUFFERSPROC glad_glGenFramebuffers = NULL; -PFNGLGENLISTSPROC glad_glGenLists = NULL; -PFNGLGENQUERIESPROC glad_glGenQueries = NULL; -PFNGLGENRENDERBUFFERSPROC glad_glGenRenderbuffers = NULL; -PFNGLGENSAMPLERSPROC glad_glGenSamplers = NULL; -PFNGLGENTEXTURESPROC glad_glGenTextures = NULL; -PFNGLGENVERTEXARRAYSPROC glad_glGenVertexArrays = NULL; -PFNGLGENERATEMIPMAPPROC glad_glGenerateMipmap = NULL; -PFNGLGETACTIVEATTRIBPROC glad_glGetActiveAttrib = NULL; -PFNGLGETACTIVEUNIFORMPROC glad_glGetActiveUniform = NULL; -PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC glad_glGetActiveUniformBlockName = NULL; -PFNGLGETACTIVEUNIFORMBLOCKIVPROC glad_glGetActiveUniformBlockiv = NULL; -PFNGLGETACTIVEUNIFORMNAMEPROC glad_glGetActiveUniformName = NULL; -PFNGLGETACTIVEUNIFORMSIVPROC glad_glGetActiveUniformsiv = NULL; -PFNGLGETATTACHEDSHADERSPROC glad_glGetAttachedShaders = NULL; -PFNGLGETATTRIBLOCATIONPROC glad_glGetAttribLocation = NULL; -PFNGLGETBOOLEANI_VPROC glad_glGetBooleani_v = NULL; -PFNGLGETBOOLEANVPROC glad_glGetBooleanv = NULL; -PFNGLGETBUFFERPARAMETERI64VPROC glad_glGetBufferParameteri64v = NULL; -PFNGLGETBUFFERPARAMETERIVPROC glad_glGetBufferParameteriv = NULL; -PFNGLGETBUFFERPOINTERVPROC glad_glGetBufferPointerv = NULL; -PFNGLGETBUFFERSUBDATAPROC glad_glGetBufferSubData = NULL; -PFNGLGETCLIPPLANEPROC glad_glGetClipPlane = NULL; -PFNGLGETCOMPRESSEDTEXIMAGEPROC glad_glGetCompressedTexImage = NULL; -PFNGLGETDEBUGMESSAGELOGPROC glad_glGetDebugMessageLog = NULL; -PFNGLGETDOUBLEVPROC glad_glGetDoublev = NULL; -PFNGLGETERRORPROC glad_glGetError = NULL; -PFNGLGETFLOATVPROC glad_glGetFloatv = NULL; -PFNGLGETFRAGDATAINDEXPROC glad_glGetFragDataIndex = NULL; -PFNGLGETFRAGDATALOCATIONPROC glad_glGetFragDataLocation = NULL; -PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC glad_glGetFramebufferAttachmentParameteriv = NULL; -PFNGLGETGRAPHICSRESETSTATUSARBPROC glad_glGetGraphicsResetStatusARB = NULL; -PFNGLGETINTEGER64I_VPROC glad_glGetInteger64i_v = NULL; -PFNGLGETINTEGER64VPROC glad_glGetInteger64v = NULL; -PFNGLGETINTEGERI_VPROC glad_glGetIntegeri_v = NULL; -PFNGLGETINTEGERVPROC glad_glGetIntegerv = NULL; -PFNGLGETLIGHTFVPROC glad_glGetLightfv = NULL; -PFNGLGETLIGHTIVPROC glad_glGetLightiv = NULL; -PFNGLGETMAPDVPROC glad_glGetMapdv = NULL; -PFNGLGETMAPFVPROC glad_glGetMapfv = NULL; -PFNGLGETMAPIVPROC glad_glGetMapiv = NULL; -PFNGLGETMATERIALFVPROC glad_glGetMaterialfv = NULL; -PFNGLGETMATERIALIVPROC glad_glGetMaterialiv = NULL; -PFNGLGETMULTISAMPLEFVPROC glad_glGetMultisamplefv = NULL; -PFNGLGETOBJECTLABELPROC glad_glGetObjectLabel = NULL; -PFNGLGETOBJECTPTRLABELPROC glad_glGetObjectPtrLabel = NULL; -PFNGLGETPIXELMAPFVPROC glad_glGetPixelMapfv = NULL; -PFNGLGETPIXELMAPUIVPROC glad_glGetPixelMapuiv = NULL; -PFNGLGETPIXELMAPUSVPROC glad_glGetPixelMapusv = NULL; -PFNGLGETPOINTERVPROC glad_glGetPointerv = NULL; -PFNGLGETPOLYGONSTIPPLEPROC glad_glGetPolygonStipple = NULL; -PFNGLGETPROGRAMINFOLOGPROC glad_glGetProgramInfoLog = NULL; -PFNGLGETPROGRAMIVPROC glad_glGetProgramiv = NULL; -PFNGLGETQUERYOBJECTI64VPROC glad_glGetQueryObjecti64v = NULL; -PFNGLGETQUERYOBJECTIVPROC glad_glGetQueryObjectiv = NULL; -PFNGLGETQUERYOBJECTUI64VPROC glad_glGetQueryObjectui64v = NULL; -PFNGLGETQUERYOBJECTUIVPROC glad_glGetQueryObjectuiv = NULL; -PFNGLGETQUERYIVPROC glad_glGetQueryiv = NULL; -PFNGLGETRENDERBUFFERPARAMETERIVPROC glad_glGetRenderbufferParameteriv = NULL; -PFNGLGETSAMPLERPARAMETERIIVPROC glad_glGetSamplerParameterIiv = NULL; -PFNGLGETSAMPLERPARAMETERIUIVPROC glad_glGetSamplerParameterIuiv = NULL; -PFNGLGETSAMPLERPARAMETERFVPROC glad_glGetSamplerParameterfv = NULL; -PFNGLGETSAMPLERPARAMETERIVPROC glad_glGetSamplerParameteriv = NULL; -PFNGLGETSHADERINFOLOGPROC glad_glGetShaderInfoLog = NULL; -PFNGLGETSHADERSOURCEPROC glad_glGetShaderSource = NULL; -PFNGLGETSHADERIVPROC glad_glGetShaderiv = NULL; -PFNGLGETSTRINGPROC glad_glGetString = NULL; -PFNGLGETSTRINGIPROC glad_glGetStringi = NULL; -PFNGLGETSYNCIVPROC glad_glGetSynciv = NULL; -PFNGLGETTEXENVFVPROC glad_glGetTexEnvfv = NULL; -PFNGLGETTEXENVIVPROC glad_glGetTexEnviv = NULL; -PFNGLGETTEXGENDVPROC glad_glGetTexGendv = NULL; -PFNGLGETTEXGENFVPROC glad_glGetTexGenfv = NULL; -PFNGLGETTEXGENIVPROC glad_glGetTexGeniv = NULL; -PFNGLGETTEXIMAGEPROC glad_glGetTexImage = NULL; -PFNGLGETTEXLEVELPARAMETERFVPROC glad_glGetTexLevelParameterfv = NULL; -PFNGLGETTEXLEVELPARAMETERIVPROC glad_glGetTexLevelParameteriv = NULL; -PFNGLGETTEXPARAMETERIIVPROC glad_glGetTexParameterIiv = NULL; -PFNGLGETTEXPARAMETERIUIVPROC glad_glGetTexParameterIuiv = NULL; -PFNGLGETTEXPARAMETERFVPROC glad_glGetTexParameterfv = NULL; -PFNGLGETTEXPARAMETERIVPROC glad_glGetTexParameteriv = NULL; -PFNGLGETTRANSFORMFEEDBACKVARYINGPROC glad_glGetTransformFeedbackVarying = NULL; -PFNGLGETUNIFORMBLOCKINDEXPROC glad_glGetUniformBlockIndex = NULL; -PFNGLGETUNIFORMINDICESPROC glad_glGetUniformIndices = NULL; -PFNGLGETUNIFORMLOCATIONPROC glad_glGetUniformLocation = NULL; -PFNGLGETUNIFORMFVPROC glad_glGetUniformfv = NULL; -PFNGLGETUNIFORMIVPROC glad_glGetUniformiv = NULL; -PFNGLGETUNIFORMUIVPROC glad_glGetUniformuiv = NULL; -PFNGLGETVERTEXATTRIBIIVPROC glad_glGetVertexAttribIiv = NULL; -PFNGLGETVERTEXATTRIBIUIVPROC glad_glGetVertexAttribIuiv = NULL; -PFNGLGETVERTEXATTRIBPOINTERVPROC glad_glGetVertexAttribPointerv = NULL; -PFNGLGETVERTEXATTRIBDVPROC glad_glGetVertexAttribdv = NULL; -PFNGLGETVERTEXATTRIBFVPROC glad_glGetVertexAttribfv = NULL; -PFNGLGETVERTEXATTRIBIVPROC glad_glGetVertexAttribiv = NULL; -PFNGLGETNCOLORTABLEARBPROC glad_glGetnColorTableARB = NULL; -PFNGLGETNCOMPRESSEDTEXIMAGEARBPROC glad_glGetnCompressedTexImageARB = NULL; -PFNGLGETNCONVOLUTIONFILTERARBPROC glad_glGetnConvolutionFilterARB = NULL; -PFNGLGETNHISTOGRAMARBPROC glad_glGetnHistogramARB = NULL; -PFNGLGETNMAPDVARBPROC glad_glGetnMapdvARB = NULL; -PFNGLGETNMAPFVARBPROC glad_glGetnMapfvARB = NULL; -PFNGLGETNMAPIVARBPROC glad_glGetnMapivARB = NULL; -PFNGLGETNMINMAXARBPROC glad_glGetnMinmaxARB = NULL; -PFNGLGETNPIXELMAPFVARBPROC glad_glGetnPixelMapfvARB = NULL; -PFNGLGETNPIXELMAPUIVARBPROC glad_glGetnPixelMapuivARB = NULL; -PFNGLGETNPIXELMAPUSVARBPROC glad_glGetnPixelMapusvARB = NULL; -PFNGLGETNPOLYGONSTIPPLEARBPROC glad_glGetnPolygonStippleARB = NULL; -PFNGLGETNSEPARABLEFILTERARBPROC glad_glGetnSeparableFilterARB = NULL; -PFNGLGETNTEXIMAGEARBPROC glad_glGetnTexImageARB = NULL; -PFNGLGETNUNIFORMDVARBPROC glad_glGetnUniformdvARB = NULL; -PFNGLGETNUNIFORMFVARBPROC glad_glGetnUniformfvARB = NULL; -PFNGLGETNUNIFORMIVARBPROC glad_glGetnUniformivARB = NULL; -PFNGLGETNUNIFORMUIVARBPROC glad_glGetnUniformuivARB = NULL; -PFNGLHINTPROC glad_glHint = NULL; -PFNGLINDEXMASKPROC glad_glIndexMask = NULL; -PFNGLINDEXPOINTERPROC glad_glIndexPointer = NULL; -PFNGLINDEXDPROC glad_glIndexd = NULL; -PFNGLINDEXDVPROC glad_glIndexdv = NULL; -PFNGLINDEXFPROC glad_glIndexf = NULL; -PFNGLINDEXFVPROC glad_glIndexfv = NULL; -PFNGLINDEXIPROC glad_glIndexi = NULL; -PFNGLINDEXIVPROC glad_glIndexiv = NULL; -PFNGLINDEXSPROC glad_glIndexs = NULL; -PFNGLINDEXSVPROC glad_glIndexsv = NULL; -PFNGLINDEXUBPROC glad_glIndexub = NULL; -PFNGLINDEXUBVPROC glad_glIndexubv = NULL; -PFNGLINITNAMESPROC glad_glInitNames = NULL; -PFNGLINTERLEAVEDARRAYSPROC glad_glInterleavedArrays = NULL; -PFNGLISBUFFERPROC glad_glIsBuffer = NULL; -PFNGLISENABLEDPROC glad_glIsEnabled = NULL; -PFNGLISENABLEDIPROC glad_glIsEnabledi = NULL; -PFNGLISFRAMEBUFFERPROC glad_glIsFramebuffer = NULL; -PFNGLISLISTPROC glad_glIsList = NULL; -PFNGLISPROGRAMPROC glad_glIsProgram = NULL; -PFNGLISQUERYPROC glad_glIsQuery = NULL; -PFNGLISRENDERBUFFERPROC glad_glIsRenderbuffer = NULL; -PFNGLISSAMPLERPROC glad_glIsSampler = NULL; -PFNGLISSHADERPROC glad_glIsShader = NULL; -PFNGLISSYNCPROC glad_glIsSync = NULL; -PFNGLISTEXTUREPROC glad_glIsTexture = NULL; -PFNGLISVERTEXARRAYPROC glad_glIsVertexArray = NULL; -PFNGLLIGHTMODELFPROC glad_glLightModelf = NULL; -PFNGLLIGHTMODELFVPROC glad_glLightModelfv = NULL; -PFNGLLIGHTMODELIPROC glad_glLightModeli = NULL; -PFNGLLIGHTMODELIVPROC glad_glLightModeliv = NULL; -PFNGLLIGHTFPROC glad_glLightf = NULL; -PFNGLLIGHTFVPROC glad_glLightfv = NULL; -PFNGLLIGHTIPROC glad_glLighti = NULL; -PFNGLLIGHTIVPROC glad_glLightiv = NULL; -PFNGLLINESTIPPLEPROC glad_glLineStipple = NULL; -PFNGLLINEWIDTHPROC glad_glLineWidth = NULL; -PFNGLLINKPROGRAMPROC glad_glLinkProgram = NULL; -PFNGLLISTBASEPROC glad_glListBase = NULL; -PFNGLLOADIDENTITYPROC glad_glLoadIdentity = NULL; -PFNGLLOADMATRIXDPROC glad_glLoadMatrixd = NULL; -PFNGLLOADMATRIXFPROC glad_glLoadMatrixf = NULL; -PFNGLLOADNAMEPROC glad_glLoadName = NULL; -PFNGLLOADTRANSPOSEMATRIXDPROC glad_glLoadTransposeMatrixd = NULL; -PFNGLLOADTRANSPOSEMATRIXFPROC glad_glLoadTransposeMatrixf = NULL; -PFNGLLOGICOPPROC glad_glLogicOp = NULL; -PFNGLMAP1DPROC glad_glMap1d = NULL; -PFNGLMAP1FPROC glad_glMap1f = NULL; -PFNGLMAP2DPROC glad_glMap2d = NULL; -PFNGLMAP2FPROC glad_glMap2f = NULL; -PFNGLMAPBUFFERPROC glad_glMapBuffer = NULL; -PFNGLMAPBUFFERRANGEPROC glad_glMapBufferRange = NULL; -PFNGLMAPGRID1DPROC glad_glMapGrid1d = NULL; -PFNGLMAPGRID1FPROC glad_glMapGrid1f = NULL; -PFNGLMAPGRID2DPROC glad_glMapGrid2d = NULL; -PFNGLMAPGRID2FPROC glad_glMapGrid2f = NULL; -PFNGLMATERIALFPROC glad_glMaterialf = NULL; -PFNGLMATERIALFVPROC glad_glMaterialfv = NULL; -PFNGLMATERIALIPROC glad_glMateriali = NULL; -PFNGLMATERIALIVPROC glad_glMaterialiv = NULL; -PFNGLMATRIXMODEPROC glad_glMatrixMode = NULL; -PFNGLMULTMATRIXDPROC glad_glMultMatrixd = NULL; -PFNGLMULTMATRIXFPROC glad_glMultMatrixf = NULL; -PFNGLMULTTRANSPOSEMATRIXDPROC glad_glMultTransposeMatrixd = NULL; -PFNGLMULTTRANSPOSEMATRIXFPROC glad_glMultTransposeMatrixf = NULL; -PFNGLMULTIDRAWARRAYSPROC glad_glMultiDrawArrays = NULL; -PFNGLMULTIDRAWELEMENTSPROC glad_glMultiDrawElements = NULL; -PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC glad_glMultiDrawElementsBaseVertex = NULL; -PFNGLMULTITEXCOORD1DPROC glad_glMultiTexCoord1d = NULL; -PFNGLMULTITEXCOORD1DVPROC glad_glMultiTexCoord1dv = NULL; -PFNGLMULTITEXCOORD1FPROC glad_glMultiTexCoord1f = NULL; -PFNGLMULTITEXCOORD1FVPROC glad_glMultiTexCoord1fv = NULL; -PFNGLMULTITEXCOORD1IPROC glad_glMultiTexCoord1i = NULL; -PFNGLMULTITEXCOORD1IVPROC glad_glMultiTexCoord1iv = NULL; -PFNGLMULTITEXCOORD1SPROC glad_glMultiTexCoord1s = NULL; -PFNGLMULTITEXCOORD1SVPROC glad_glMultiTexCoord1sv = NULL; -PFNGLMULTITEXCOORD2DPROC glad_glMultiTexCoord2d = NULL; -PFNGLMULTITEXCOORD2DVPROC glad_glMultiTexCoord2dv = NULL; -PFNGLMULTITEXCOORD2FPROC glad_glMultiTexCoord2f = NULL; -PFNGLMULTITEXCOORD2FVPROC glad_glMultiTexCoord2fv = NULL; -PFNGLMULTITEXCOORD2IPROC glad_glMultiTexCoord2i = NULL; -PFNGLMULTITEXCOORD2IVPROC glad_glMultiTexCoord2iv = NULL; -PFNGLMULTITEXCOORD2SPROC glad_glMultiTexCoord2s = NULL; -PFNGLMULTITEXCOORD2SVPROC glad_glMultiTexCoord2sv = NULL; -PFNGLMULTITEXCOORD3DPROC glad_glMultiTexCoord3d = NULL; -PFNGLMULTITEXCOORD3DVPROC glad_glMultiTexCoord3dv = NULL; -PFNGLMULTITEXCOORD3FPROC glad_glMultiTexCoord3f = NULL; -PFNGLMULTITEXCOORD3FVPROC glad_glMultiTexCoord3fv = NULL; -PFNGLMULTITEXCOORD3IPROC glad_glMultiTexCoord3i = NULL; -PFNGLMULTITEXCOORD3IVPROC glad_glMultiTexCoord3iv = NULL; -PFNGLMULTITEXCOORD3SPROC glad_glMultiTexCoord3s = NULL; -PFNGLMULTITEXCOORD3SVPROC glad_glMultiTexCoord3sv = NULL; -PFNGLMULTITEXCOORD4DPROC glad_glMultiTexCoord4d = NULL; -PFNGLMULTITEXCOORD4DVPROC glad_glMultiTexCoord4dv = NULL; -PFNGLMULTITEXCOORD4FPROC glad_glMultiTexCoord4f = NULL; -PFNGLMULTITEXCOORD4FVPROC glad_glMultiTexCoord4fv = NULL; -PFNGLMULTITEXCOORD4IPROC glad_glMultiTexCoord4i = NULL; -PFNGLMULTITEXCOORD4IVPROC glad_glMultiTexCoord4iv = NULL; -PFNGLMULTITEXCOORD4SPROC glad_glMultiTexCoord4s = NULL; -PFNGLMULTITEXCOORD4SVPROC glad_glMultiTexCoord4sv = NULL; -PFNGLMULTITEXCOORDP1UIPROC glad_glMultiTexCoordP1ui = NULL; -PFNGLMULTITEXCOORDP1UIVPROC glad_glMultiTexCoordP1uiv = NULL; -PFNGLMULTITEXCOORDP2UIPROC glad_glMultiTexCoordP2ui = NULL; -PFNGLMULTITEXCOORDP2UIVPROC glad_glMultiTexCoordP2uiv = NULL; -PFNGLMULTITEXCOORDP3UIPROC glad_glMultiTexCoordP3ui = NULL; -PFNGLMULTITEXCOORDP3UIVPROC glad_glMultiTexCoordP3uiv = NULL; -PFNGLMULTITEXCOORDP4UIPROC glad_glMultiTexCoordP4ui = NULL; -PFNGLMULTITEXCOORDP4UIVPROC glad_glMultiTexCoordP4uiv = NULL; -PFNGLNEWLISTPROC glad_glNewList = NULL; -PFNGLNORMAL3BPROC glad_glNormal3b = NULL; -PFNGLNORMAL3BVPROC glad_glNormal3bv = NULL; -PFNGLNORMAL3DPROC glad_glNormal3d = NULL; -PFNGLNORMAL3DVPROC glad_glNormal3dv = NULL; -PFNGLNORMAL3FPROC glad_glNormal3f = NULL; -PFNGLNORMAL3FVPROC glad_glNormal3fv = NULL; -PFNGLNORMAL3IPROC glad_glNormal3i = NULL; -PFNGLNORMAL3IVPROC glad_glNormal3iv = NULL; -PFNGLNORMAL3SPROC glad_glNormal3s = NULL; -PFNGLNORMAL3SVPROC glad_glNormal3sv = NULL; -PFNGLNORMALP3UIPROC glad_glNormalP3ui = NULL; -PFNGLNORMALP3UIVPROC glad_glNormalP3uiv = NULL; -PFNGLNORMALPOINTERPROC glad_glNormalPointer = NULL; -PFNGLOBJECTLABELPROC glad_glObjectLabel = NULL; -PFNGLOBJECTPTRLABELPROC glad_glObjectPtrLabel = NULL; -PFNGLORTHOPROC glad_glOrtho = NULL; -PFNGLPASSTHROUGHPROC glad_glPassThrough = NULL; -PFNGLPIXELMAPFVPROC glad_glPixelMapfv = NULL; -PFNGLPIXELMAPUIVPROC glad_glPixelMapuiv = NULL; -PFNGLPIXELMAPUSVPROC glad_glPixelMapusv = NULL; -PFNGLPIXELSTOREFPROC glad_glPixelStoref = NULL; -PFNGLPIXELSTOREIPROC glad_glPixelStorei = NULL; -PFNGLPIXELTRANSFERFPROC glad_glPixelTransferf = NULL; -PFNGLPIXELTRANSFERIPROC glad_glPixelTransferi = NULL; -PFNGLPIXELZOOMPROC glad_glPixelZoom = NULL; -PFNGLPOINTPARAMETERFPROC glad_glPointParameterf = NULL; -PFNGLPOINTPARAMETERFVPROC glad_glPointParameterfv = NULL; -PFNGLPOINTPARAMETERIPROC glad_glPointParameteri = NULL; -PFNGLPOINTPARAMETERIVPROC glad_glPointParameteriv = NULL; -PFNGLPOINTSIZEPROC glad_glPointSize = NULL; -PFNGLPOLYGONMODEPROC glad_glPolygonMode = NULL; -PFNGLPOLYGONOFFSETPROC glad_glPolygonOffset = NULL; -PFNGLPOLYGONSTIPPLEPROC glad_glPolygonStipple = NULL; -PFNGLPOPATTRIBPROC glad_glPopAttrib = NULL; -PFNGLPOPCLIENTATTRIBPROC glad_glPopClientAttrib = NULL; -PFNGLPOPDEBUGGROUPPROC glad_glPopDebugGroup = NULL; -PFNGLPOPMATRIXPROC glad_glPopMatrix = NULL; -PFNGLPOPNAMEPROC glad_glPopName = NULL; -PFNGLPRIMITIVERESTARTINDEXPROC glad_glPrimitiveRestartIndex = NULL; -PFNGLPRIORITIZETEXTURESPROC glad_glPrioritizeTextures = NULL; -PFNGLPROVOKINGVERTEXPROC glad_glProvokingVertex = NULL; -PFNGLPUSHATTRIBPROC glad_glPushAttrib = NULL; -PFNGLPUSHCLIENTATTRIBPROC glad_glPushClientAttrib = NULL; -PFNGLPUSHDEBUGGROUPPROC glad_glPushDebugGroup = NULL; -PFNGLPUSHMATRIXPROC glad_glPushMatrix = NULL; -PFNGLPUSHNAMEPROC glad_glPushName = NULL; -PFNGLQUERYCOUNTERPROC glad_glQueryCounter = NULL; -PFNGLRASTERPOS2DPROC glad_glRasterPos2d = NULL; -PFNGLRASTERPOS2DVPROC glad_glRasterPos2dv = NULL; -PFNGLRASTERPOS2FPROC glad_glRasterPos2f = NULL; -PFNGLRASTERPOS2FVPROC glad_glRasterPos2fv = NULL; -PFNGLRASTERPOS2IPROC glad_glRasterPos2i = NULL; -PFNGLRASTERPOS2IVPROC glad_glRasterPos2iv = NULL; -PFNGLRASTERPOS2SPROC glad_glRasterPos2s = NULL; -PFNGLRASTERPOS2SVPROC glad_glRasterPos2sv = NULL; -PFNGLRASTERPOS3DPROC glad_glRasterPos3d = NULL; -PFNGLRASTERPOS3DVPROC glad_glRasterPos3dv = NULL; -PFNGLRASTERPOS3FPROC glad_glRasterPos3f = NULL; -PFNGLRASTERPOS3FVPROC glad_glRasterPos3fv = NULL; -PFNGLRASTERPOS3IPROC glad_glRasterPos3i = NULL; -PFNGLRASTERPOS3IVPROC glad_glRasterPos3iv = NULL; -PFNGLRASTERPOS3SPROC glad_glRasterPos3s = NULL; -PFNGLRASTERPOS3SVPROC glad_glRasterPos3sv = NULL; -PFNGLRASTERPOS4DPROC glad_glRasterPos4d = NULL; -PFNGLRASTERPOS4DVPROC glad_glRasterPos4dv = NULL; -PFNGLRASTERPOS4FPROC glad_glRasterPos4f = NULL; -PFNGLRASTERPOS4FVPROC glad_glRasterPos4fv = NULL; -PFNGLRASTERPOS4IPROC glad_glRasterPos4i = NULL; -PFNGLRASTERPOS4IVPROC glad_glRasterPos4iv = NULL; -PFNGLRASTERPOS4SPROC glad_glRasterPos4s = NULL; -PFNGLRASTERPOS4SVPROC glad_glRasterPos4sv = NULL; -PFNGLREADBUFFERPROC glad_glReadBuffer = NULL; -PFNGLREADPIXELSPROC glad_glReadPixels = NULL; -PFNGLREADNPIXELSPROC glad_glReadnPixels = NULL; -PFNGLREADNPIXELSARBPROC glad_glReadnPixelsARB = NULL; -PFNGLRECTDPROC glad_glRectd = NULL; -PFNGLRECTDVPROC glad_glRectdv = NULL; -PFNGLRECTFPROC glad_glRectf = NULL; -PFNGLRECTFVPROC glad_glRectfv = NULL; -PFNGLRECTIPROC glad_glRecti = NULL; -PFNGLRECTIVPROC glad_glRectiv = NULL; -PFNGLRECTSPROC glad_glRects = NULL; -PFNGLRECTSVPROC glad_glRectsv = NULL; -PFNGLRENDERMODEPROC glad_glRenderMode = NULL; -PFNGLRENDERBUFFERSTORAGEPROC glad_glRenderbufferStorage = NULL; -PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC glad_glRenderbufferStorageMultisample = NULL; -PFNGLROTATEDPROC glad_glRotated = NULL; -PFNGLROTATEFPROC glad_glRotatef = NULL; -PFNGLSAMPLECOVERAGEPROC glad_glSampleCoverage = NULL; -PFNGLSAMPLECOVERAGEARBPROC glad_glSampleCoverageARB = NULL; -PFNGLSAMPLEMASKIPROC glad_glSampleMaski = NULL; -PFNGLSAMPLERPARAMETERIIVPROC glad_glSamplerParameterIiv = NULL; -PFNGLSAMPLERPARAMETERIUIVPROC glad_glSamplerParameterIuiv = NULL; -PFNGLSAMPLERPARAMETERFPROC glad_glSamplerParameterf = NULL; -PFNGLSAMPLERPARAMETERFVPROC glad_glSamplerParameterfv = NULL; -PFNGLSAMPLERPARAMETERIPROC glad_glSamplerParameteri = NULL; -PFNGLSAMPLERPARAMETERIVPROC glad_glSamplerParameteriv = NULL; -PFNGLSCALEDPROC glad_glScaled = NULL; -PFNGLSCALEFPROC glad_glScalef = NULL; -PFNGLSCISSORPROC glad_glScissor = NULL; -PFNGLSECONDARYCOLOR3BPROC glad_glSecondaryColor3b = NULL; -PFNGLSECONDARYCOLOR3BVPROC glad_glSecondaryColor3bv = NULL; -PFNGLSECONDARYCOLOR3DPROC glad_glSecondaryColor3d = NULL; -PFNGLSECONDARYCOLOR3DVPROC glad_glSecondaryColor3dv = NULL; -PFNGLSECONDARYCOLOR3FPROC glad_glSecondaryColor3f = NULL; -PFNGLSECONDARYCOLOR3FVPROC glad_glSecondaryColor3fv = NULL; -PFNGLSECONDARYCOLOR3IPROC glad_glSecondaryColor3i = NULL; -PFNGLSECONDARYCOLOR3IVPROC glad_glSecondaryColor3iv = NULL; -PFNGLSECONDARYCOLOR3SPROC glad_glSecondaryColor3s = NULL; -PFNGLSECONDARYCOLOR3SVPROC glad_glSecondaryColor3sv = NULL; -PFNGLSECONDARYCOLOR3UBPROC glad_glSecondaryColor3ub = NULL; -PFNGLSECONDARYCOLOR3UBVPROC glad_glSecondaryColor3ubv = NULL; -PFNGLSECONDARYCOLOR3UIPROC glad_glSecondaryColor3ui = NULL; -PFNGLSECONDARYCOLOR3UIVPROC glad_glSecondaryColor3uiv = NULL; -PFNGLSECONDARYCOLOR3USPROC glad_glSecondaryColor3us = NULL; -PFNGLSECONDARYCOLOR3USVPROC glad_glSecondaryColor3usv = NULL; -PFNGLSECONDARYCOLORP3UIPROC glad_glSecondaryColorP3ui = NULL; -PFNGLSECONDARYCOLORP3UIVPROC glad_glSecondaryColorP3uiv = NULL; -PFNGLSECONDARYCOLORPOINTERPROC glad_glSecondaryColorPointer = NULL; -PFNGLSELECTBUFFERPROC glad_glSelectBuffer = NULL; -PFNGLSHADEMODELPROC glad_glShadeModel = NULL; -PFNGLSHADERSOURCEPROC glad_glShaderSource = NULL; -PFNGLSTENCILFUNCPROC glad_glStencilFunc = NULL; -PFNGLSTENCILFUNCSEPARATEPROC glad_glStencilFuncSeparate = NULL; -PFNGLSTENCILMASKPROC glad_glStencilMask = NULL; -PFNGLSTENCILMASKSEPARATEPROC glad_glStencilMaskSeparate = NULL; -PFNGLSTENCILOPPROC glad_glStencilOp = NULL; -PFNGLSTENCILOPSEPARATEPROC glad_glStencilOpSeparate = NULL; -PFNGLTEXBUFFERPROC glad_glTexBuffer = NULL; -PFNGLTEXCOORD1DPROC glad_glTexCoord1d = NULL; -PFNGLTEXCOORD1DVPROC glad_glTexCoord1dv = NULL; -PFNGLTEXCOORD1FPROC glad_glTexCoord1f = NULL; -PFNGLTEXCOORD1FVPROC glad_glTexCoord1fv = NULL; -PFNGLTEXCOORD1IPROC glad_glTexCoord1i = NULL; -PFNGLTEXCOORD1IVPROC glad_glTexCoord1iv = NULL; -PFNGLTEXCOORD1SPROC glad_glTexCoord1s = NULL; -PFNGLTEXCOORD1SVPROC glad_glTexCoord1sv = NULL; -PFNGLTEXCOORD2DPROC glad_glTexCoord2d = NULL; -PFNGLTEXCOORD2DVPROC glad_glTexCoord2dv = NULL; -PFNGLTEXCOORD2FPROC glad_glTexCoord2f = NULL; -PFNGLTEXCOORD2FVPROC glad_glTexCoord2fv = NULL; -PFNGLTEXCOORD2IPROC glad_glTexCoord2i = NULL; -PFNGLTEXCOORD2IVPROC glad_glTexCoord2iv = NULL; -PFNGLTEXCOORD2SPROC glad_glTexCoord2s = NULL; -PFNGLTEXCOORD2SVPROC glad_glTexCoord2sv = NULL; -PFNGLTEXCOORD3DPROC glad_glTexCoord3d = NULL; -PFNGLTEXCOORD3DVPROC glad_glTexCoord3dv = NULL; -PFNGLTEXCOORD3FPROC glad_glTexCoord3f = NULL; -PFNGLTEXCOORD3FVPROC glad_glTexCoord3fv = NULL; -PFNGLTEXCOORD3IPROC glad_glTexCoord3i = NULL; -PFNGLTEXCOORD3IVPROC glad_glTexCoord3iv = NULL; -PFNGLTEXCOORD3SPROC glad_glTexCoord3s = NULL; -PFNGLTEXCOORD3SVPROC glad_glTexCoord3sv = NULL; -PFNGLTEXCOORD4DPROC glad_glTexCoord4d = NULL; -PFNGLTEXCOORD4DVPROC glad_glTexCoord4dv = NULL; -PFNGLTEXCOORD4FPROC glad_glTexCoord4f = NULL; -PFNGLTEXCOORD4FVPROC glad_glTexCoord4fv = NULL; -PFNGLTEXCOORD4IPROC glad_glTexCoord4i = NULL; -PFNGLTEXCOORD4IVPROC glad_glTexCoord4iv = NULL; -PFNGLTEXCOORD4SPROC glad_glTexCoord4s = NULL; -PFNGLTEXCOORD4SVPROC glad_glTexCoord4sv = NULL; -PFNGLTEXCOORDP1UIPROC glad_glTexCoordP1ui = NULL; -PFNGLTEXCOORDP1UIVPROC glad_glTexCoordP1uiv = NULL; -PFNGLTEXCOORDP2UIPROC glad_glTexCoordP2ui = NULL; -PFNGLTEXCOORDP2UIVPROC glad_glTexCoordP2uiv = NULL; -PFNGLTEXCOORDP3UIPROC glad_glTexCoordP3ui = NULL; -PFNGLTEXCOORDP3UIVPROC glad_glTexCoordP3uiv = NULL; -PFNGLTEXCOORDP4UIPROC glad_glTexCoordP4ui = NULL; -PFNGLTEXCOORDP4UIVPROC glad_glTexCoordP4uiv = NULL; -PFNGLTEXCOORDPOINTERPROC glad_glTexCoordPointer = NULL; -PFNGLTEXENVFPROC glad_glTexEnvf = NULL; -PFNGLTEXENVFVPROC glad_glTexEnvfv = NULL; -PFNGLTEXENVIPROC glad_glTexEnvi = NULL; -PFNGLTEXENVIVPROC glad_glTexEnviv = NULL; -PFNGLTEXGENDPROC glad_glTexGend = NULL; -PFNGLTEXGENDVPROC glad_glTexGendv = NULL; -PFNGLTEXGENFPROC glad_glTexGenf = NULL; -PFNGLTEXGENFVPROC glad_glTexGenfv = NULL; -PFNGLTEXGENIPROC glad_glTexGeni = NULL; -PFNGLTEXGENIVPROC glad_glTexGeniv = NULL; -PFNGLTEXIMAGE1DPROC glad_glTexImage1D = NULL; -PFNGLTEXIMAGE2DPROC glad_glTexImage2D = NULL; -PFNGLTEXIMAGE2DMULTISAMPLEPROC glad_glTexImage2DMultisample = NULL; -PFNGLTEXIMAGE3DPROC glad_glTexImage3D = NULL; -PFNGLTEXIMAGE3DMULTISAMPLEPROC glad_glTexImage3DMultisample = NULL; -PFNGLTEXPARAMETERIIVPROC glad_glTexParameterIiv = NULL; -PFNGLTEXPARAMETERIUIVPROC glad_glTexParameterIuiv = NULL; -PFNGLTEXPARAMETERFPROC glad_glTexParameterf = NULL; -PFNGLTEXPARAMETERFVPROC glad_glTexParameterfv = NULL; -PFNGLTEXPARAMETERIPROC glad_glTexParameteri = NULL; -PFNGLTEXPARAMETERIVPROC glad_glTexParameteriv = NULL; -PFNGLTEXSUBIMAGE1DPROC glad_glTexSubImage1D = NULL; -PFNGLTEXSUBIMAGE2DPROC glad_glTexSubImage2D = NULL; -PFNGLTEXSUBIMAGE3DPROC glad_glTexSubImage3D = NULL; -PFNGLTRANSFORMFEEDBACKVARYINGSPROC glad_glTransformFeedbackVaryings = NULL; -PFNGLTRANSLATEDPROC glad_glTranslated = NULL; -PFNGLTRANSLATEFPROC glad_glTranslatef = NULL; -PFNGLUNIFORM1FPROC glad_glUniform1f = NULL; -PFNGLUNIFORM1FVPROC glad_glUniform1fv = NULL; -PFNGLUNIFORM1IPROC glad_glUniform1i = NULL; -PFNGLUNIFORM1IVPROC glad_glUniform1iv = NULL; -PFNGLUNIFORM1UIPROC glad_glUniform1ui = NULL; -PFNGLUNIFORM1UIVPROC glad_glUniform1uiv = NULL; -PFNGLUNIFORM2FPROC glad_glUniform2f = NULL; -PFNGLUNIFORM2FVPROC glad_glUniform2fv = NULL; -PFNGLUNIFORM2IPROC glad_glUniform2i = NULL; -PFNGLUNIFORM2IVPROC glad_glUniform2iv = NULL; -PFNGLUNIFORM2UIPROC glad_glUniform2ui = NULL; -PFNGLUNIFORM2UIVPROC glad_glUniform2uiv = NULL; -PFNGLUNIFORM3FPROC glad_glUniform3f = NULL; -PFNGLUNIFORM3FVPROC glad_glUniform3fv = NULL; -PFNGLUNIFORM3IPROC glad_glUniform3i = NULL; -PFNGLUNIFORM3IVPROC glad_glUniform3iv = NULL; -PFNGLUNIFORM3UIPROC glad_glUniform3ui = NULL; -PFNGLUNIFORM3UIVPROC glad_glUniform3uiv = NULL; -PFNGLUNIFORM4FPROC glad_glUniform4f = NULL; -PFNGLUNIFORM4FVPROC glad_glUniform4fv = NULL; -PFNGLUNIFORM4IPROC glad_glUniform4i = NULL; -PFNGLUNIFORM4IVPROC glad_glUniform4iv = NULL; -PFNGLUNIFORM4UIPROC glad_glUniform4ui = NULL; -PFNGLUNIFORM4UIVPROC glad_glUniform4uiv = NULL; -PFNGLUNIFORMBLOCKBINDINGPROC glad_glUniformBlockBinding = NULL; -PFNGLUNIFORMMATRIX2FVPROC glad_glUniformMatrix2fv = NULL; -PFNGLUNIFORMMATRIX2X3FVPROC glad_glUniformMatrix2x3fv = NULL; -PFNGLUNIFORMMATRIX2X4FVPROC glad_glUniformMatrix2x4fv = NULL; -PFNGLUNIFORMMATRIX3FVPROC glad_glUniformMatrix3fv = NULL; -PFNGLUNIFORMMATRIX3X2FVPROC glad_glUniformMatrix3x2fv = NULL; -PFNGLUNIFORMMATRIX3X4FVPROC glad_glUniformMatrix3x4fv = NULL; -PFNGLUNIFORMMATRIX4FVPROC glad_glUniformMatrix4fv = NULL; -PFNGLUNIFORMMATRIX4X2FVPROC glad_glUniformMatrix4x2fv = NULL; -PFNGLUNIFORMMATRIX4X3FVPROC glad_glUniformMatrix4x3fv = NULL; -PFNGLUNMAPBUFFERPROC glad_glUnmapBuffer = NULL; -PFNGLUSEPROGRAMPROC glad_glUseProgram = NULL; -PFNGLVALIDATEPROGRAMPROC glad_glValidateProgram = NULL; -PFNGLVERTEX2DPROC glad_glVertex2d = NULL; -PFNGLVERTEX2DVPROC glad_glVertex2dv = NULL; -PFNGLVERTEX2FPROC glad_glVertex2f = NULL; -PFNGLVERTEX2FVPROC glad_glVertex2fv = NULL; -PFNGLVERTEX2IPROC glad_glVertex2i = NULL; -PFNGLVERTEX2IVPROC glad_glVertex2iv = NULL; -PFNGLVERTEX2SPROC glad_glVertex2s = NULL; -PFNGLVERTEX2SVPROC glad_glVertex2sv = NULL; -PFNGLVERTEX3DPROC glad_glVertex3d = NULL; -PFNGLVERTEX3DVPROC glad_glVertex3dv = NULL; -PFNGLVERTEX3FPROC glad_glVertex3f = NULL; -PFNGLVERTEX3FVPROC glad_glVertex3fv = NULL; -PFNGLVERTEX3IPROC glad_glVertex3i = NULL; -PFNGLVERTEX3IVPROC glad_glVertex3iv = NULL; -PFNGLVERTEX3SPROC glad_glVertex3s = NULL; -PFNGLVERTEX3SVPROC glad_glVertex3sv = NULL; -PFNGLVERTEX4DPROC glad_glVertex4d = NULL; -PFNGLVERTEX4DVPROC glad_glVertex4dv = NULL; -PFNGLVERTEX4FPROC glad_glVertex4f = NULL; -PFNGLVERTEX4FVPROC glad_glVertex4fv = NULL; -PFNGLVERTEX4IPROC glad_glVertex4i = NULL; -PFNGLVERTEX4IVPROC glad_glVertex4iv = NULL; -PFNGLVERTEX4SPROC glad_glVertex4s = NULL; -PFNGLVERTEX4SVPROC glad_glVertex4sv = NULL; -PFNGLVERTEXATTRIB1DPROC glad_glVertexAttrib1d = NULL; -PFNGLVERTEXATTRIB1DVPROC glad_glVertexAttrib1dv = NULL; -PFNGLVERTEXATTRIB1FPROC glad_glVertexAttrib1f = NULL; -PFNGLVERTEXATTRIB1FVPROC glad_glVertexAttrib1fv = NULL; -PFNGLVERTEXATTRIB1SPROC glad_glVertexAttrib1s = NULL; -PFNGLVERTEXATTRIB1SVPROC glad_glVertexAttrib1sv = NULL; -PFNGLVERTEXATTRIB2DPROC glad_glVertexAttrib2d = NULL; -PFNGLVERTEXATTRIB2DVPROC glad_glVertexAttrib2dv = NULL; -PFNGLVERTEXATTRIB2FPROC glad_glVertexAttrib2f = NULL; -PFNGLVERTEXATTRIB2FVPROC glad_glVertexAttrib2fv = NULL; -PFNGLVERTEXATTRIB2SPROC glad_glVertexAttrib2s = NULL; -PFNGLVERTEXATTRIB2SVPROC glad_glVertexAttrib2sv = NULL; -PFNGLVERTEXATTRIB3DPROC glad_glVertexAttrib3d = NULL; -PFNGLVERTEXATTRIB3DVPROC glad_glVertexAttrib3dv = NULL; -PFNGLVERTEXATTRIB3FPROC glad_glVertexAttrib3f = NULL; -PFNGLVERTEXATTRIB3FVPROC glad_glVertexAttrib3fv = NULL; -PFNGLVERTEXATTRIB3SPROC glad_glVertexAttrib3s = NULL; -PFNGLVERTEXATTRIB3SVPROC glad_glVertexAttrib3sv = NULL; -PFNGLVERTEXATTRIB4NBVPROC glad_glVertexAttrib4Nbv = NULL; -PFNGLVERTEXATTRIB4NIVPROC glad_glVertexAttrib4Niv = NULL; -PFNGLVERTEXATTRIB4NSVPROC glad_glVertexAttrib4Nsv = NULL; -PFNGLVERTEXATTRIB4NUBPROC glad_glVertexAttrib4Nub = NULL; -PFNGLVERTEXATTRIB4NUBVPROC glad_glVertexAttrib4Nubv = NULL; -PFNGLVERTEXATTRIB4NUIVPROC glad_glVertexAttrib4Nuiv = NULL; -PFNGLVERTEXATTRIB4NUSVPROC glad_glVertexAttrib4Nusv = NULL; -PFNGLVERTEXATTRIB4BVPROC glad_glVertexAttrib4bv = NULL; -PFNGLVERTEXATTRIB4DPROC glad_glVertexAttrib4d = NULL; -PFNGLVERTEXATTRIB4DVPROC glad_glVertexAttrib4dv = NULL; -PFNGLVERTEXATTRIB4FPROC glad_glVertexAttrib4f = NULL; -PFNGLVERTEXATTRIB4FVPROC glad_glVertexAttrib4fv = NULL; -PFNGLVERTEXATTRIB4IVPROC glad_glVertexAttrib4iv = NULL; -PFNGLVERTEXATTRIB4SPROC glad_glVertexAttrib4s = NULL; -PFNGLVERTEXATTRIB4SVPROC glad_glVertexAttrib4sv = NULL; -PFNGLVERTEXATTRIB4UBVPROC glad_glVertexAttrib4ubv = NULL; -PFNGLVERTEXATTRIB4UIVPROC glad_glVertexAttrib4uiv = NULL; -PFNGLVERTEXATTRIB4USVPROC glad_glVertexAttrib4usv = NULL; -PFNGLVERTEXATTRIBDIVISORPROC glad_glVertexAttribDivisor = NULL; -PFNGLVERTEXATTRIBI1IPROC glad_glVertexAttribI1i = NULL; -PFNGLVERTEXATTRIBI1IVPROC glad_glVertexAttribI1iv = NULL; -PFNGLVERTEXATTRIBI1UIPROC glad_glVertexAttribI1ui = NULL; -PFNGLVERTEXATTRIBI1UIVPROC glad_glVertexAttribI1uiv = NULL; -PFNGLVERTEXATTRIBI2IPROC glad_glVertexAttribI2i = NULL; -PFNGLVERTEXATTRIBI2IVPROC glad_glVertexAttribI2iv = NULL; -PFNGLVERTEXATTRIBI2UIPROC glad_glVertexAttribI2ui = NULL; -PFNGLVERTEXATTRIBI2UIVPROC glad_glVertexAttribI2uiv = NULL; -PFNGLVERTEXATTRIBI3IPROC glad_glVertexAttribI3i = NULL; -PFNGLVERTEXATTRIBI3IVPROC glad_glVertexAttribI3iv = NULL; -PFNGLVERTEXATTRIBI3UIPROC glad_glVertexAttribI3ui = NULL; -PFNGLVERTEXATTRIBI3UIVPROC glad_glVertexAttribI3uiv = NULL; -PFNGLVERTEXATTRIBI4BVPROC glad_glVertexAttribI4bv = NULL; -PFNGLVERTEXATTRIBI4IPROC glad_glVertexAttribI4i = NULL; -PFNGLVERTEXATTRIBI4IVPROC glad_glVertexAttribI4iv = NULL; -PFNGLVERTEXATTRIBI4SVPROC glad_glVertexAttribI4sv = NULL; -PFNGLVERTEXATTRIBI4UBVPROC glad_glVertexAttribI4ubv = NULL; -PFNGLVERTEXATTRIBI4UIPROC glad_glVertexAttribI4ui = NULL; -PFNGLVERTEXATTRIBI4UIVPROC glad_glVertexAttribI4uiv = NULL; -PFNGLVERTEXATTRIBI4USVPROC glad_glVertexAttribI4usv = NULL; -PFNGLVERTEXATTRIBIPOINTERPROC glad_glVertexAttribIPointer = NULL; -PFNGLVERTEXATTRIBP1UIPROC glad_glVertexAttribP1ui = NULL; -PFNGLVERTEXATTRIBP1UIVPROC glad_glVertexAttribP1uiv = NULL; -PFNGLVERTEXATTRIBP2UIPROC glad_glVertexAttribP2ui = NULL; -PFNGLVERTEXATTRIBP2UIVPROC glad_glVertexAttribP2uiv = NULL; -PFNGLVERTEXATTRIBP3UIPROC glad_glVertexAttribP3ui = NULL; -PFNGLVERTEXATTRIBP3UIVPROC glad_glVertexAttribP3uiv = NULL; -PFNGLVERTEXATTRIBP4UIPROC glad_glVertexAttribP4ui = NULL; -PFNGLVERTEXATTRIBP4UIVPROC glad_glVertexAttribP4uiv = NULL; -PFNGLVERTEXATTRIBPOINTERPROC glad_glVertexAttribPointer = NULL; -PFNGLVERTEXP2UIPROC glad_glVertexP2ui = NULL; -PFNGLVERTEXP2UIVPROC glad_glVertexP2uiv = NULL; -PFNGLVERTEXP3UIPROC glad_glVertexP3ui = NULL; -PFNGLVERTEXP3UIVPROC glad_glVertexP3uiv = NULL; -PFNGLVERTEXP4UIPROC glad_glVertexP4ui = NULL; -PFNGLVERTEXP4UIVPROC glad_glVertexP4uiv = NULL; -PFNGLVERTEXPOINTERPROC glad_glVertexPointer = NULL; -PFNGLVIEWPORTPROC glad_glViewport = NULL; -PFNGLWAITSYNCPROC glad_glWaitSync = NULL; -PFNGLWINDOWPOS2DPROC glad_glWindowPos2d = NULL; -PFNGLWINDOWPOS2DVPROC glad_glWindowPos2dv = NULL; -PFNGLWINDOWPOS2FPROC glad_glWindowPos2f = NULL; -PFNGLWINDOWPOS2FVPROC glad_glWindowPos2fv = NULL; -PFNGLWINDOWPOS2IPROC glad_glWindowPos2i = NULL; -PFNGLWINDOWPOS2IVPROC glad_glWindowPos2iv = NULL; -PFNGLWINDOWPOS2SPROC glad_glWindowPos2s = NULL; -PFNGLWINDOWPOS2SVPROC glad_glWindowPos2sv = NULL; -PFNGLWINDOWPOS3DPROC glad_glWindowPos3d = NULL; -PFNGLWINDOWPOS3DVPROC glad_glWindowPos3dv = NULL; -PFNGLWINDOWPOS3FPROC glad_glWindowPos3f = NULL; -PFNGLWINDOWPOS3FVPROC glad_glWindowPos3fv = NULL; -PFNGLWINDOWPOS3IPROC glad_glWindowPos3i = NULL; -PFNGLWINDOWPOS3IVPROC glad_glWindowPos3iv = NULL; -PFNGLWINDOWPOS3SPROC glad_glWindowPos3s = NULL; -PFNGLWINDOWPOS3SVPROC glad_glWindowPos3sv = NULL; - - -static void glad_gl_load_GL_VERSION_1_0( GLADuserptrloadfunc load, void* userptr) { - if(!GLAD_GL_VERSION_1_0) return; - glAccum = (PFNGLACCUMPROC) load("glAccum", userptr); - glAlphaFunc = (PFNGLALPHAFUNCPROC) load("glAlphaFunc", userptr); - glBegin = (PFNGLBEGINPROC) load("glBegin", userptr); - glBitmap = (PFNGLBITMAPPROC) load("glBitmap", userptr); - glBlendFunc = (PFNGLBLENDFUNCPROC) load("glBlendFunc", userptr); - glCallList = (PFNGLCALLLISTPROC) load("glCallList", userptr); - glCallLists = (PFNGLCALLLISTSPROC) load("glCallLists", userptr); - glClear = (PFNGLCLEARPROC) load("glClear", userptr); - glClearAccum = (PFNGLCLEARACCUMPROC) load("glClearAccum", userptr); - glClearColor = (PFNGLCLEARCOLORPROC) load("glClearColor", userptr); - glClearDepth = (PFNGLCLEARDEPTHPROC) load("glClearDepth", userptr); - glClearIndex = (PFNGLCLEARINDEXPROC) load("glClearIndex", userptr); - glClearStencil = (PFNGLCLEARSTENCILPROC) load("glClearStencil", userptr); - glClipPlane = (PFNGLCLIPPLANEPROC) load("glClipPlane", userptr); - glColor3b = (PFNGLCOLOR3BPROC) load("glColor3b", userptr); - glColor3bv = (PFNGLCOLOR3BVPROC) load("glColor3bv", userptr); - glColor3d = (PFNGLCOLOR3DPROC) load("glColor3d", userptr); - glColor3dv = (PFNGLCOLOR3DVPROC) load("glColor3dv", userptr); - glColor3f = (PFNGLCOLOR3FPROC) load("glColor3f", userptr); - glColor3fv = (PFNGLCOLOR3FVPROC) load("glColor3fv", userptr); - glColor3i = (PFNGLCOLOR3IPROC) load("glColor3i", userptr); - glColor3iv = (PFNGLCOLOR3IVPROC) load("glColor3iv", userptr); - glColor3s = (PFNGLCOLOR3SPROC) load("glColor3s", userptr); - glColor3sv = (PFNGLCOLOR3SVPROC) load("glColor3sv", userptr); - glColor3ub = (PFNGLCOLOR3UBPROC) load("glColor3ub", userptr); - glColor3ubv = (PFNGLCOLOR3UBVPROC) load("glColor3ubv", userptr); - glColor3ui = (PFNGLCOLOR3UIPROC) load("glColor3ui", userptr); - glColor3uiv = (PFNGLCOLOR3UIVPROC) load("glColor3uiv", userptr); - glColor3us = (PFNGLCOLOR3USPROC) load("glColor3us", userptr); - glColor3usv = (PFNGLCOLOR3USVPROC) load("glColor3usv", userptr); - glColor4b = (PFNGLCOLOR4BPROC) load("glColor4b", userptr); - glColor4bv = (PFNGLCOLOR4BVPROC) load("glColor4bv", userptr); - glColor4d = (PFNGLCOLOR4DPROC) load("glColor4d", userptr); - glColor4dv = (PFNGLCOLOR4DVPROC) load("glColor4dv", userptr); - glColor4f = (PFNGLCOLOR4FPROC) load("glColor4f", userptr); - glColor4fv = (PFNGLCOLOR4FVPROC) load("glColor4fv", userptr); - glColor4i = (PFNGLCOLOR4IPROC) load("glColor4i", userptr); - glColor4iv = (PFNGLCOLOR4IVPROC) load("glColor4iv", userptr); - glColor4s = (PFNGLCOLOR4SPROC) load("glColor4s", userptr); - glColor4sv = (PFNGLCOLOR4SVPROC) load("glColor4sv", userptr); - glColor4ub = (PFNGLCOLOR4UBPROC) load("glColor4ub", userptr); - glColor4ubv = (PFNGLCOLOR4UBVPROC) load("glColor4ubv", userptr); - glColor4ui = (PFNGLCOLOR4UIPROC) load("glColor4ui", userptr); - glColor4uiv = (PFNGLCOLOR4UIVPROC) load("glColor4uiv", userptr); - glColor4us = (PFNGLCOLOR4USPROC) load("glColor4us", userptr); - glColor4usv = (PFNGLCOLOR4USVPROC) load("glColor4usv", userptr); - glColorMask = (PFNGLCOLORMASKPROC) load("glColorMask", userptr); - glColorMaterial = (PFNGLCOLORMATERIALPROC) load("glColorMaterial", userptr); - glCopyPixels = (PFNGLCOPYPIXELSPROC) load("glCopyPixels", userptr); - glCullFace = (PFNGLCULLFACEPROC) load("glCullFace", userptr); - glDeleteLists = (PFNGLDELETELISTSPROC) load("glDeleteLists", userptr); - glDepthFunc = (PFNGLDEPTHFUNCPROC) load("glDepthFunc", userptr); - glDepthMask = (PFNGLDEPTHMASKPROC) load("glDepthMask", userptr); - glDepthRange = (PFNGLDEPTHRANGEPROC) load("glDepthRange", userptr); - glDisable = (PFNGLDISABLEPROC) load("glDisable", userptr); - glDrawBuffer = (PFNGLDRAWBUFFERPROC) load("glDrawBuffer", userptr); - glDrawPixels = (PFNGLDRAWPIXELSPROC) load("glDrawPixels", userptr); - glEdgeFlag = (PFNGLEDGEFLAGPROC) load("glEdgeFlag", userptr); - glEdgeFlagv = (PFNGLEDGEFLAGVPROC) load("glEdgeFlagv", userptr); - glEnable = (PFNGLENABLEPROC) load("glEnable", userptr); - glEnd = (PFNGLENDPROC) load("glEnd", userptr); - glEndList = (PFNGLENDLISTPROC) load("glEndList", userptr); - glEvalCoord1d = (PFNGLEVALCOORD1DPROC) load("glEvalCoord1d", userptr); - glEvalCoord1dv = (PFNGLEVALCOORD1DVPROC) load("glEvalCoord1dv", userptr); - glEvalCoord1f = (PFNGLEVALCOORD1FPROC) load("glEvalCoord1f", userptr); - glEvalCoord1fv = (PFNGLEVALCOORD1FVPROC) load("glEvalCoord1fv", userptr); - glEvalCoord2d = (PFNGLEVALCOORD2DPROC) load("glEvalCoord2d", userptr); - glEvalCoord2dv = (PFNGLEVALCOORD2DVPROC) load("glEvalCoord2dv", userptr); - glEvalCoord2f = (PFNGLEVALCOORD2FPROC) load("glEvalCoord2f", userptr); - glEvalCoord2fv = (PFNGLEVALCOORD2FVPROC) load("glEvalCoord2fv", userptr); - glEvalMesh1 = (PFNGLEVALMESH1PROC) load("glEvalMesh1", userptr); - glEvalMesh2 = (PFNGLEVALMESH2PROC) load("glEvalMesh2", userptr); - glEvalPoint1 = (PFNGLEVALPOINT1PROC) load("glEvalPoint1", userptr); - glEvalPoint2 = (PFNGLEVALPOINT2PROC) load("glEvalPoint2", userptr); - glFeedbackBuffer = (PFNGLFEEDBACKBUFFERPROC) load("glFeedbackBuffer", userptr); - glFinish = (PFNGLFINISHPROC) load("glFinish", userptr); - glFlush = (PFNGLFLUSHPROC) load("glFlush", userptr); - glFogf = (PFNGLFOGFPROC) load("glFogf", userptr); - glFogfv = (PFNGLFOGFVPROC) load("glFogfv", userptr); - glFogi = (PFNGLFOGIPROC) load("glFogi", userptr); - glFogiv = (PFNGLFOGIVPROC) load("glFogiv", userptr); - glFrontFace = (PFNGLFRONTFACEPROC) load("glFrontFace", userptr); - glFrustum = (PFNGLFRUSTUMPROC) load("glFrustum", userptr); - glGenLists = (PFNGLGENLISTSPROC) load("glGenLists", userptr); - glGetBooleanv = (PFNGLGETBOOLEANVPROC) load("glGetBooleanv", userptr); - glGetClipPlane = (PFNGLGETCLIPPLANEPROC) load("glGetClipPlane", userptr); - glGetDoublev = (PFNGLGETDOUBLEVPROC) load("glGetDoublev", userptr); - glGetError = (PFNGLGETERRORPROC) load("glGetError", userptr); - glGetFloatv = (PFNGLGETFLOATVPROC) load("glGetFloatv", userptr); - glGetIntegerv = (PFNGLGETINTEGERVPROC) load("glGetIntegerv", userptr); - glGetLightfv = (PFNGLGETLIGHTFVPROC) load("glGetLightfv", userptr); - glGetLightiv = (PFNGLGETLIGHTIVPROC) load("glGetLightiv", userptr); - glGetMapdv = (PFNGLGETMAPDVPROC) load("glGetMapdv", userptr); - glGetMapfv = (PFNGLGETMAPFVPROC) load("glGetMapfv", userptr); - glGetMapiv = (PFNGLGETMAPIVPROC) load("glGetMapiv", userptr); - glGetMaterialfv = (PFNGLGETMATERIALFVPROC) load("glGetMaterialfv", userptr); - glGetMaterialiv = (PFNGLGETMATERIALIVPROC) load("glGetMaterialiv", userptr); - glGetPixelMapfv = (PFNGLGETPIXELMAPFVPROC) load("glGetPixelMapfv", userptr); - glGetPixelMapuiv = (PFNGLGETPIXELMAPUIVPROC) load("glGetPixelMapuiv", userptr); - glGetPixelMapusv = (PFNGLGETPIXELMAPUSVPROC) load("glGetPixelMapusv", userptr); - glGetPolygonStipple = (PFNGLGETPOLYGONSTIPPLEPROC) load("glGetPolygonStipple", userptr); - glGetString = (PFNGLGETSTRINGPROC) load("glGetString", userptr); - glGetTexEnvfv = (PFNGLGETTEXENVFVPROC) load("glGetTexEnvfv", userptr); - glGetTexEnviv = (PFNGLGETTEXENVIVPROC) load("glGetTexEnviv", userptr); - glGetTexGendv = (PFNGLGETTEXGENDVPROC) load("glGetTexGendv", userptr); - glGetTexGenfv = (PFNGLGETTEXGENFVPROC) load("glGetTexGenfv", userptr); - glGetTexGeniv = (PFNGLGETTEXGENIVPROC) load("glGetTexGeniv", userptr); - glGetTexImage = (PFNGLGETTEXIMAGEPROC) load("glGetTexImage", userptr); - glGetTexLevelParameterfv = (PFNGLGETTEXLEVELPARAMETERFVPROC) load("glGetTexLevelParameterfv", userptr); - glGetTexLevelParameteriv = (PFNGLGETTEXLEVELPARAMETERIVPROC) load("glGetTexLevelParameteriv", userptr); - glGetTexParameterfv = (PFNGLGETTEXPARAMETERFVPROC) load("glGetTexParameterfv", userptr); - glGetTexParameteriv = (PFNGLGETTEXPARAMETERIVPROC) load("glGetTexParameteriv", userptr); - glHint = (PFNGLHINTPROC) load("glHint", userptr); - glIndexMask = (PFNGLINDEXMASKPROC) load("glIndexMask", userptr); - glIndexd = (PFNGLINDEXDPROC) load("glIndexd", userptr); - glIndexdv = (PFNGLINDEXDVPROC) load("glIndexdv", userptr); - glIndexf = (PFNGLINDEXFPROC) load("glIndexf", userptr); - glIndexfv = (PFNGLINDEXFVPROC) load("glIndexfv", userptr); - glIndexi = (PFNGLINDEXIPROC) load("glIndexi", userptr); - glIndexiv = (PFNGLINDEXIVPROC) load("glIndexiv", userptr); - glIndexs = (PFNGLINDEXSPROC) load("glIndexs", userptr); - glIndexsv = (PFNGLINDEXSVPROC) load("glIndexsv", userptr); - glInitNames = (PFNGLINITNAMESPROC) load("glInitNames", userptr); - glIsEnabled = (PFNGLISENABLEDPROC) load("glIsEnabled", userptr); - glIsList = (PFNGLISLISTPROC) load("glIsList", userptr); - glLightModelf = (PFNGLLIGHTMODELFPROC) load("glLightModelf", userptr); - glLightModelfv = (PFNGLLIGHTMODELFVPROC) load("glLightModelfv", userptr); - glLightModeli = (PFNGLLIGHTMODELIPROC) load("glLightModeli", userptr); - glLightModeliv = (PFNGLLIGHTMODELIVPROC) load("glLightModeliv", userptr); - glLightf = (PFNGLLIGHTFPROC) load("glLightf", userptr); - glLightfv = (PFNGLLIGHTFVPROC) load("glLightfv", userptr); - glLighti = (PFNGLLIGHTIPROC) load("glLighti", userptr); - glLightiv = (PFNGLLIGHTIVPROC) load("glLightiv", userptr); - glLineStipple = (PFNGLLINESTIPPLEPROC) load("glLineStipple", userptr); - glLineWidth = (PFNGLLINEWIDTHPROC) load("glLineWidth", userptr); - glListBase = (PFNGLLISTBASEPROC) load("glListBase", userptr); - glLoadIdentity = (PFNGLLOADIDENTITYPROC) load("glLoadIdentity", userptr); - glLoadMatrixd = (PFNGLLOADMATRIXDPROC) load("glLoadMatrixd", userptr); - glLoadMatrixf = (PFNGLLOADMATRIXFPROC) load("glLoadMatrixf", userptr); - glLoadName = (PFNGLLOADNAMEPROC) load("glLoadName", userptr); - glLogicOp = (PFNGLLOGICOPPROC) load("glLogicOp", userptr); - glMap1d = (PFNGLMAP1DPROC) load("glMap1d", userptr); - glMap1f = (PFNGLMAP1FPROC) load("glMap1f", userptr); - glMap2d = (PFNGLMAP2DPROC) load("glMap2d", userptr); - glMap2f = (PFNGLMAP2FPROC) load("glMap2f", userptr); - glMapGrid1d = (PFNGLMAPGRID1DPROC) load("glMapGrid1d", userptr); - glMapGrid1f = (PFNGLMAPGRID1FPROC) load("glMapGrid1f", userptr); - glMapGrid2d = (PFNGLMAPGRID2DPROC) load("glMapGrid2d", userptr); - glMapGrid2f = (PFNGLMAPGRID2FPROC) load("glMapGrid2f", userptr); - glMaterialf = (PFNGLMATERIALFPROC) load("glMaterialf", userptr); - glMaterialfv = (PFNGLMATERIALFVPROC) load("glMaterialfv", userptr); - glMateriali = (PFNGLMATERIALIPROC) load("glMateriali", userptr); - glMaterialiv = (PFNGLMATERIALIVPROC) load("glMaterialiv", userptr); - glMatrixMode = (PFNGLMATRIXMODEPROC) load("glMatrixMode", userptr); - glMultMatrixd = (PFNGLMULTMATRIXDPROC) load("glMultMatrixd", userptr); - glMultMatrixf = (PFNGLMULTMATRIXFPROC) load("glMultMatrixf", userptr); - glNewList = (PFNGLNEWLISTPROC) load("glNewList", userptr); - glNormal3b = (PFNGLNORMAL3BPROC) load("glNormal3b", userptr); - glNormal3bv = (PFNGLNORMAL3BVPROC) load("glNormal3bv", userptr); - glNormal3d = (PFNGLNORMAL3DPROC) load("glNormal3d", userptr); - glNormal3dv = (PFNGLNORMAL3DVPROC) load("glNormal3dv", userptr); - glNormal3f = (PFNGLNORMAL3FPROC) load("glNormal3f", userptr); - glNormal3fv = (PFNGLNORMAL3FVPROC) load("glNormal3fv", userptr); - glNormal3i = (PFNGLNORMAL3IPROC) load("glNormal3i", userptr); - glNormal3iv = (PFNGLNORMAL3IVPROC) load("glNormal3iv", userptr); - glNormal3s = (PFNGLNORMAL3SPROC) load("glNormal3s", userptr); - glNormal3sv = (PFNGLNORMAL3SVPROC) load("glNormal3sv", userptr); - glOrtho = (PFNGLORTHOPROC) load("glOrtho", userptr); - glPassThrough = (PFNGLPASSTHROUGHPROC) load("glPassThrough", userptr); - glPixelMapfv = (PFNGLPIXELMAPFVPROC) load("glPixelMapfv", userptr); - glPixelMapuiv = (PFNGLPIXELMAPUIVPROC) load("glPixelMapuiv", userptr); - glPixelMapusv = (PFNGLPIXELMAPUSVPROC) load("glPixelMapusv", userptr); - glPixelStoref = (PFNGLPIXELSTOREFPROC) load("glPixelStoref", userptr); - glPixelStorei = (PFNGLPIXELSTOREIPROC) load("glPixelStorei", userptr); - glPixelTransferf = (PFNGLPIXELTRANSFERFPROC) load("glPixelTransferf", userptr); - glPixelTransferi = (PFNGLPIXELTRANSFERIPROC) load("glPixelTransferi", userptr); - glPixelZoom = (PFNGLPIXELZOOMPROC) load("glPixelZoom", userptr); - glPointSize = (PFNGLPOINTSIZEPROC) load("glPointSize", userptr); - glPolygonMode = (PFNGLPOLYGONMODEPROC) load("glPolygonMode", userptr); - glPolygonStipple = (PFNGLPOLYGONSTIPPLEPROC) load("glPolygonStipple", userptr); - glPopAttrib = (PFNGLPOPATTRIBPROC) load("glPopAttrib", userptr); - glPopMatrix = (PFNGLPOPMATRIXPROC) load("glPopMatrix", userptr); - glPopName = (PFNGLPOPNAMEPROC) load("glPopName", userptr); - glPushAttrib = (PFNGLPUSHATTRIBPROC) load("glPushAttrib", userptr); - glPushMatrix = (PFNGLPUSHMATRIXPROC) load("glPushMatrix", userptr); - glPushName = (PFNGLPUSHNAMEPROC) load("glPushName", userptr); - glRasterPos2d = (PFNGLRASTERPOS2DPROC) load("glRasterPos2d", userptr); - glRasterPos2dv = (PFNGLRASTERPOS2DVPROC) load("glRasterPos2dv", userptr); - glRasterPos2f = (PFNGLRASTERPOS2FPROC) load("glRasterPos2f", userptr); - glRasterPos2fv = (PFNGLRASTERPOS2FVPROC) load("glRasterPos2fv", userptr); - glRasterPos2i = (PFNGLRASTERPOS2IPROC) load("glRasterPos2i", userptr); - glRasterPos2iv = (PFNGLRASTERPOS2IVPROC) load("glRasterPos2iv", userptr); - glRasterPos2s = (PFNGLRASTERPOS2SPROC) load("glRasterPos2s", userptr); - glRasterPos2sv = (PFNGLRASTERPOS2SVPROC) load("glRasterPos2sv", userptr); - glRasterPos3d = (PFNGLRASTERPOS3DPROC) load("glRasterPos3d", userptr); - glRasterPos3dv = (PFNGLRASTERPOS3DVPROC) load("glRasterPos3dv", userptr); - glRasterPos3f = (PFNGLRASTERPOS3FPROC) load("glRasterPos3f", userptr); - glRasterPos3fv = (PFNGLRASTERPOS3FVPROC) load("glRasterPos3fv", userptr); - glRasterPos3i = (PFNGLRASTERPOS3IPROC) load("glRasterPos3i", userptr); - glRasterPos3iv = (PFNGLRASTERPOS3IVPROC) load("glRasterPos3iv", userptr); - glRasterPos3s = (PFNGLRASTERPOS3SPROC) load("glRasterPos3s", userptr); - glRasterPos3sv = (PFNGLRASTERPOS3SVPROC) load("glRasterPos3sv", userptr); - glRasterPos4d = (PFNGLRASTERPOS4DPROC) load("glRasterPos4d", userptr); - glRasterPos4dv = (PFNGLRASTERPOS4DVPROC) load("glRasterPos4dv", userptr); - glRasterPos4f = (PFNGLRASTERPOS4FPROC) load("glRasterPos4f", userptr); - glRasterPos4fv = (PFNGLRASTERPOS4FVPROC) load("glRasterPos4fv", userptr); - glRasterPos4i = (PFNGLRASTERPOS4IPROC) load("glRasterPos4i", userptr); - glRasterPos4iv = (PFNGLRASTERPOS4IVPROC) load("glRasterPos4iv", userptr); - glRasterPos4s = (PFNGLRASTERPOS4SPROC) load("glRasterPos4s", userptr); - glRasterPos4sv = (PFNGLRASTERPOS4SVPROC) load("glRasterPos4sv", userptr); - glReadBuffer = (PFNGLREADBUFFERPROC) load("glReadBuffer", userptr); - glReadPixels = (PFNGLREADPIXELSPROC) load("glReadPixels", userptr); - glRectd = (PFNGLRECTDPROC) load("glRectd", userptr); - glRectdv = (PFNGLRECTDVPROC) load("glRectdv", userptr); - glRectf = (PFNGLRECTFPROC) load("glRectf", userptr); - glRectfv = (PFNGLRECTFVPROC) load("glRectfv", userptr); - glRecti = (PFNGLRECTIPROC) load("glRecti", userptr); - glRectiv = (PFNGLRECTIVPROC) load("glRectiv", userptr); - glRects = (PFNGLRECTSPROC) load("glRects", userptr); - glRectsv = (PFNGLRECTSVPROC) load("glRectsv", userptr); - glRenderMode = (PFNGLRENDERMODEPROC) load("glRenderMode", userptr); - glRotated = (PFNGLROTATEDPROC) load("glRotated", userptr); - glRotatef = (PFNGLROTATEFPROC) load("glRotatef", userptr); - glScaled = (PFNGLSCALEDPROC) load("glScaled", userptr); - glScalef = (PFNGLSCALEFPROC) load("glScalef", userptr); - glScissor = (PFNGLSCISSORPROC) load("glScissor", userptr); - glSelectBuffer = (PFNGLSELECTBUFFERPROC) load("glSelectBuffer", userptr); - glShadeModel = (PFNGLSHADEMODELPROC) load("glShadeModel", userptr); - glStencilFunc = (PFNGLSTENCILFUNCPROC) load("glStencilFunc", userptr); - glStencilMask = (PFNGLSTENCILMASKPROC) load("glStencilMask", userptr); - glStencilOp = (PFNGLSTENCILOPPROC) load("glStencilOp", userptr); - glTexCoord1d = (PFNGLTEXCOORD1DPROC) load("glTexCoord1d", userptr); - glTexCoord1dv = (PFNGLTEXCOORD1DVPROC) load("glTexCoord1dv", userptr); - glTexCoord1f = (PFNGLTEXCOORD1FPROC) load("glTexCoord1f", userptr); - glTexCoord1fv = (PFNGLTEXCOORD1FVPROC) load("glTexCoord1fv", userptr); - glTexCoord1i = (PFNGLTEXCOORD1IPROC) load("glTexCoord1i", userptr); - glTexCoord1iv = (PFNGLTEXCOORD1IVPROC) load("glTexCoord1iv", userptr); - glTexCoord1s = (PFNGLTEXCOORD1SPROC) load("glTexCoord1s", userptr); - glTexCoord1sv = (PFNGLTEXCOORD1SVPROC) load("glTexCoord1sv", userptr); - glTexCoord2d = (PFNGLTEXCOORD2DPROC) load("glTexCoord2d", userptr); - glTexCoord2dv = (PFNGLTEXCOORD2DVPROC) load("glTexCoord2dv", userptr); - glTexCoord2f = (PFNGLTEXCOORD2FPROC) load("glTexCoord2f", userptr); - glTexCoord2fv = (PFNGLTEXCOORD2FVPROC) load("glTexCoord2fv", userptr); - glTexCoord2i = (PFNGLTEXCOORD2IPROC) load("glTexCoord2i", userptr); - glTexCoord2iv = (PFNGLTEXCOORD2IVPROC) load("glTexCoord2iv", userptr); - glTexCoord2s = (PFNGLTEXCOORD2SPROC) load("glTexCoord2s", userptr); - glTexCoord2sv = (PFNGLTEXCOORD2SVPROC) load("glTexCoord2sv", userptr); - glTexCoord3d = (PFNGLTEXCOORD3DPROC) load("glTexCoord3d", userptr); - glTexCoord3dv = (PFNGLTEXCOORD3DVPROC) load("glTexCoord3dv", userptr); - glTexCoord3f = (PFNGLTEXCOORD3FPROC) load("glTexCoord3f", userptr); - glTexCoord3fv = (PFNGLTEXCOORD3FVPROC) load("glTexCoord3fv", userptr); - glTexCoord3i = (PFNGLTEXCOORD3IPROC) load("glTexCoord3i", userptr); - glTexCoord3iv = (PFNGLTEXCOORD3IVPROC) load("glTexCoord3iv", userptr); - glTexCoord3s = (PFNGLTEXCOORD3SPROC) load("glTexCoord3s", userptr); - glTexCoord3sv = (PFNGLTEXCOORD3SVPROC) load("glTexCoord3sv", userptr); - glTexCoord4d = (PFNGLTEXCOORD4DPROC) load("glTexCoord4d", userptr); - glTexCoord4dv = (PFNGLTEXCOORD4DVPROC) load("glTexCoord4dv", userptr); - glTexCoord4f = (PFNGLTEXCOORD4FPROC) load("glTexCoord4f", userptr); - glTexCoord4fv = (PFNGLTEXCOORD4FVPROC) load("glTexCoord4fv", userptr); - glTexCoord4i = (PFNGLTEXCOORD4IPROC) load("glTexCoord4i", userptr); - glTexCoord4iv = (PFNGLTEXCOORD4IVPROC) load("glTexCoord4iv", userptr); - glTexCoord4s = (PFNGLTEXCOORD4SPROC) load("glTexCoord4s", userptr); - glTexCoord4sv = (PFNGLTEXCOORD4SVPROC) load("glTexCoord4sv", userptr); - glTexEnvf = (PFNGLTEXENVFPROC) load("glTexEnvf", userptr); - glTexEnvfv = (PFNGLTEXENVFVPROC) load("glTexEnvfv", userptr); - glTexEnvi = (PFNGLTEXENVIPROC) load("glTexEnvi", userptr); - glTexEnviv = (PFNGLTEXENVIVPROC) load("glTexEnviv", userptr); - glTexGend = (PFNGLTEXGENDPROC) load("glTexGend", userptr); - glTexGendv = (PFNGLTEXGENDVPROC) load("glTexGendv", userptr); - glTexGenf = (PFNGLTEXGENFPROC) load("glTexGenf", userptr); - glTexGenfv = (PFNGLTEXGENFVPROC) load("glTexGenfv", userptr); - glTexGeni = (PFNGLTEXGENIPROC) load("glTexGeni", userptr); - glTexGeniv = (PFNGLTEXGENIVPROC) load("glTexGeniv", userptr); - glTexImage1D = (PFNGLTEXIMAGE1DPROC) load("glTexImage1D", userptr); - glTexImage2D = (PFNGLTEXIMAGE2DPROC) load("glTexImage2D", userptr); - glTexParameterf = (PFNGLTEXPARAMETERFPROC) load("glTexParameterf", userptr); - glTexParameterfv = (PFNGLTEXPARAMETERFVPROC) load("glTexParameterfv", userptr); - glTexParameteri = (PFNGLTEXPARAMETERIPROC) load("glTexParameteri", userptr); - glTexParameteriv = (PFNGLTEXPARAMETERIVPROC) load("glTexParameteriv", userptr); - glTranslated = (PFNGLTRANSLATEDPROC) load("glTranslated", userptr); - glTranslatef = (PFNGLTRANSLATEFPROC) load("glTranslatef", userptr); - glVertex2d = (PFNGLVERTEX2DPROC) load("glVertex2d", userptr); - glVertex2dv = (PFNGLVERTEX2DVPROC) load("glVertex2dv", userptr); - glVertex2f = (PFNGLVERTEX2FPROC) load("glVertex2f", userptr); - glVertex2fv = (PFNGLVERTEX2FVPROC) load("glVertex2fv", userptr); - glVertex2i = (PFNGLVERTEX2IPROC) load("glVertex2i", userptr); - glVertex2iv = (PFNGLVERTEX2IVPROC) load("glVertex2iv", userptr); - glVertex2s = (PFNGLVERTEX2SPROC) load("glVertex2s", userptr); - glVertex2sv = (PFNGLVERTEX2SVPROC) load("glVertex2sv", userptr); - glVertex3d = (PFNGLVERTEX3DPROC) load("glVertex3d", userptr); - glVertex3dv = (PFNGLVERTEX3DVPROC) load("glVertex3dv", userptr); - glVertex3f = (PFNGLVERTEX3FPROC) load("glVertex3f", userptr); - glVertex3fv = (PFNGLVERTEX3FVPROC) load("glVertex3fv", userptr); - glVertex3i = (PFNGLVERTEX3IPROC) load("glVertex3i", userptr); - glVertex3iv = (PFNGLVERTEX3IVPROC) load("glVertex3iv", userptr); - glVertex3s = (PFNGLVERTEX3SPROC) load("glVertex3s", userptr); - glVertex3sv = (PFNGLVERTEX3SVPROC) load("glVertex3sv", userptr); - glVertex4d = (PFNGLVERTEX4DPROC) load("glVertex4d", userptr); - glVertex4dv = (PFNGLVERTEX4DVPROC) load("glVertex4dv", userptr); - glVertex4f = (PFNGLVERTEX4FPROC) load("glVertex4f", userptr); - glVertex4fv = (PFNGLVERTEX4FVPROC) load("glVertex4fv", userptr); - glVertex4i = (PFNGLVERTEX4IPROC) load("glVertex4i", userptr); - glVertex4iv = (PFNGLVERTEX4IVPROC) load("glVertex4iv", userptr); - glVertex4s = (PFNGLVERTEX4SPROC) load("glVertex4s", userptr); - glVertex4sv = (PFNGLVERTEX4SVPROC) load("glVertex4sv", userptr); - glViewport = (PFNGLVIEWPORTPROC) load("glViewport", userptr); -} -static void glad_gl_load_GL_VERSION_1_1( GLADuserptrloadfunc load, void* userptr) { - if(!GLAD_GL_VERSION_1_1) return; - glAreTexturesResident = (PFNGLARETEXTURESRESIDENTPROC) load("glAreTexturesResident", userptr); - glArrayElement = (PFNGLARRAYELEMENTPROC) load("glArrayElement", userptr); - glBindTexture = (PFNGLBINDTEXTUREPROC) load("glBindTexture", userptr); - glColorPointer = (PFNGLCOLORPOINTERPROC) load("glColorPointer", userptr); - glCopyTexImage1D = (PFNGLCOPYTEXIMAGE1DPROC) load("glCopyTexImage1D", userptr); - glCopyTexImage2D = (PFNGLCOPYTEXIMAGE2DPROC) load("glCopyTexImage2D", userptr); - glCopyTexSubImage1D = (PFNGLCOPYTEXSUBIMAGE1DPROC) load("glCopyTexSubImage1D", userptr); - glCopyTexSubImage2D = (PFNGLCOPYTEXSUBIMAGE2DPROC) load("glCopyTexSubImage2D", userptr); - glDeleteTextures = (PFNGLDELETETEXTURESPROC) load("glDeleteTextures", userptr); - glDisableClientState = (PFNGLDISABLECLIENTSTATEPROC) load("glDisableClientState", userptr); - glDrawArrays = (PFNGLDRAWARRAYSPROC) load("glDrawArrays", userptr); - glDrawElements = (PFNGLDRAWELEMENTSPROC) load("glDrawElements", userptr); - glEdgeFlagPointer = (PFNGLEDGEFLAGPOINTERPROC) load("glEdgeFlagPointer", userptr); - glEnableClientState = (PFNGLENABLECLIENTSTATEPROC) load("glEnableClientState", userptr); - glGenTextures = (PFNGLGENTEXTURESPROC) load("glGenTextures", userptr); - glGetPointerv = (PFNGLGETPOINTERVPROC) load("glGetPointerv", userptr); - glIndexPointer = (PFNGLINDEXPOINTERPROC) load("glIndexPointer", userptr); - glIndexub = (PFNGLINDEXUBPROC) load("glIndexub", userptr); - glIndexubv = (PFNGLINDEXUBVPROC) load("glIndexubv", userptr); - glInterleavedArrays = (PFNGLINTERLEAVEDARRAYSPROC) load("glInterleavedArrays", userptr); - glIsTexture = (PFNGLISTEXTUREPROC) load("glIsTexture", userptr); - glNormalPointer = (PFNGLNORMALPOINTERPROC) load("glNormalPointer", userptr); - glPolygonOffset = (PFNGLPOLYGONOFFSETPROC) load("glPolygonOffset", userptr); - glPopClientAttrib = (PFNGLPOPCLIENTATTRIBPROC) load("glPopClientAttrib", userptr); - glPrioritizeTextures = (PFNGLPRIORITIZETEXTURESPROC) load("glPrioritizeTextures", userptr); - glPushClientAttrib = (PFNGLPUSHCLIENTATTRIBPROC) load("glPushClientAttrib", userptr); - glTexCoordPointer = (PFNGLTEXCOORDPOINTERPROC) load("glTexCoordPointer", userptr); - glTexSubImage1D = (PFNGLTEXSUBIMAGE1DPROC) load("glTexSubImage1D", userptr); - glTexSubImage2D = (PFNGLTEXSUBIMAGE2DPROC) load("glTexSubImage2D", userptr); - glVertexPointer = (PFNGLVERTEXPOINTERPROC) load("glVertexPointer", userptr); -} -static void glad_gl_load_GL_VERSION_1_2( GLADuserptrloadfunc load, void* userptr) { - if(!GLAD_GL_VERSION_1_2) return; - glCopyTexSubImage3D = (PFNGLCOPYTEXSUBIMAGE3DPROC) load("glCopyTexSubImage3D", userptr); - glDrawRangeElements = (PFNGLDRAWRANGEELEMENTSPROC) load("glDrawRangeElements", userptr); - glTexImage3D = (PFNGLTEXIMAGE3DPROC) load("glTexImage3D", userptr); - glTexSubImage3D = (PFNGLTEXSUBIMAGE3DPROC) load("glTexSubImage3D", userptr); -} -static void glad_gl_load_GL_VERSION_1_3( GLADuserptrloadfunc load, void* userptr) { - if(!GLAD_GL_VERSION_1_3) return; - glActiveTexture = (PFNGLACTIVETEXTUREPROC) load("glActiveTexture", userptr); - glClientActiveTexture = (PFNGLCLIENTACTIVETEXTUREPROC) load("glClientActiveTexture", userptr); - glCompressedTexImage1D = (PFNGLCOMPRESSEDTEXIMAGE1DPROC) load("glCompressedTexImage1D", userptr); - glCompressedTexImage2D = (PFNGLCOMPRESSEDTEXIMAGE2DPROC) load("glCompressedTexImage2D", userptr); - glCompressedTexImage3D = (PFNGLCOMPRESSEDTEXIMAGE3DPROC) load("glCompressedTexImage3D", userptr); - glCompressedTexSubImage1D = (PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) load("glCompressedTexSubImage1D", userptr); - glCompressedTexSubImage2D = (PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) load("glCompressedTexSubImage2D", userptr); - glCompressedTexSubImage3D = (PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) load("glCompressedTexSubImage3D", userptr); - glGetCompressedTexImage = (PFNGLGETCOMPRESSEDTEXIMAGEPROC) load("glGetCompressedTexImage", userptr); - glLoadTransposeMatrixd = (PFNGLLOADTRANSPOSEMATRIXDPROC) load("glLoadTransposeMatrixd", userptr); - glLoadTransposeMatrixf = (PFNGLLOADTRANSPOSEMATRIXFPROC) load("glLoadTransposeMatrixf", userptr); - glMultTransposeMatrixd = (PFNGLMULTTRANSPOSEMATRIXDPROC) load("glMultTransposeMatrixd", userptr); - glMultTransposeMatrixf = (PFNGLMULTTRANSPOSEMATRIXFPROC) load("glMultTransposeMatrixf", userptr); - glMultiTexCoord1d = (PFNGLMULTITEXCOORD1DPROC) load("glMultiTexCoord1d", userptr); - glMultiTexCoord1dv = (PFNGLMULTITEXCOORD1DVPROC) load("glMultiTexCoord1dv", userptr); - glMultiTexCoord1f = (PFNGLMULTITEXCOORD1FPROC) load("glMultiTexCoord1f", userptr); - glMultiTexCoord1fv = (PFNGLMULTITEXCOORD1FVPROC) load("glMultiTexCoord1fv", userptr); - glMultiTexCoord1i = (PFNGLMULTITEXCOORD1IPROC) load("glMultiTexCoord1i", userptr); - glMultiTexCoord1iv = (PFNGLMULTITEXCOORD1IVPROC) load("glMultiTexCoord1iv", userptr); - glMultiTexCoord1s = (PFNGLMULTITEXCOORD1SPROC) load("glMultiTexCoord1s", userptr); - glMultiTexCoord1sv = (PFNGLMULTITEXCOORD1SVPROC) load("glMultiTexCoord1sv", userptr); - glMultiTexCoord2d = (PFNGLMULTITEXCOORD2DPROC) load("glMultiTexCoord2d", userptr); - glMultiTexCoord2dv = (PFNGLMULTITEXCOORD2DVPROC) load("glMultiTexCoord2dv", userptr); - glMultiTexCoord2f = (PFNGLMULTITEXCOORD2FPROC) load("glMultiTexCoord2f", userptr); - glMultiTexCoord2fv = (PFNGLMULTITEXCOORD2FVPROC) load("glMultiTexCoord2fv", userptr); - glMultiTexCoord2i = (PFNGLMULTITEXCOORD2IPROC) load("glMultiTexCoord2i", userptr); - glMultiTexCoord2iv = (PFNGLMULTITEXCOORD2IVPROC) load("glMultiTexCoord2iv", userptr); - glMultiTexCoord2s = (PFNGLMULTITEXCOORD2SPROC) load("glMultiTexCoord2s", userptr); - glMultiTexCoord2sv = (PFNGLMULTITEXCOORD2SVPROC) load("glMultiTexCoord2sv", userptr); - glMultiTexCoord3d = (PFNGLMULTITEXCOORD3DPROC) load("glMultiTexCoord3d", userptr); - glMultiTexCoord3dv = (PFNGLMULTITEXCOORD3DVPROC) load("glMultiTexCoord3dv", userptr); - glMultiTexCoord3f = (PFNGLMULTITEXCOORD3FPROC) load("glMultiTexCoord3f", userptr); - glMultiTexCoord3fv = (PFNGLMULTITEXCOORD3FVPROC) load("glMultiTexCoord3fv", userptr); - glMultiTexCoord3i = (PFNGLMULTITEXCOORD3IPROC) load("glMultiTexCoord3i", userptr); - glMultiTexCoord3iv = (PFNGLMULTITEXCOORD3IVPROC) load("glMultiTexCoord3iv", userptr); - glMultiTexCoord3s = (PFNGLMULTITEXCOORD3SPROC) load("glMultiTexCoord3s", userptr); - glMultiTexCoord3sv = (PFNGLMULTITEXCOORD3SVPROC) load("glMultiTexCoord3sv", userptr); - glMultiTexCoord4d = (PFNGLMULTITEXCOORD4DPROC) load("glMultiTexCoord4d", userptr); - glMultiTexCoord4dv = (PFNGLMULTITEXCOORD4DVPROC) load("glMultiTexCoord4dv", userptr); - glMultiTexCoord4f = (PFNGLMULTITEXCOORD4FPROC) load("glMultiTexCoord4f", userptr); - glMultiTexCoord4fv = (PFNGLMULTITEXCOORD4FVPROC) load("glMultiTexCoord4fv", userptr); - glMultiTexCoord4i = (PFNGLMULTITEXCOORD4IPROC) load("glMultiTexCoord4i", userptr); - glMultiTexCoord4iv = (PFNGLMULTITEXCOORD4IVPROC) load("glMultiTexCoord4iv", userptr); - glMultiTexCoord4s = (PFNGLMULTITEXCOORD4SPROC) load("glMultiTexCoord4s", userptr); - glMultiTexCoord4sv = (PFNGLMULTITEXCOORD4SVPROC) load("glMultiTexCoord4sv", userptr); - glSampleCoverage = (PFNGLSAMPLECOVERAGEPROC) load("glSampleCoverage", userptr); -} -static void glad_gl_load_GL_VERSION_1_4( GLADuserptrloadfunc load, void* userptr) { - if(!GLAD_GL_VERSION_1_4) return; - glBlendColor = (PFNGLBLENDCOLORPROC) load("glBlendColor", userptr); - glBlendEquation = (PFNGLBLENDEQUATIONPROC) load("glBlendEquation", userptr); - glBlendFuncSeparate = (PFNGLBLENDFUNCSEPARATEPROC) load("glBlendFuncSeparate", userptr); - glFogCoordPointer = (PFNGLFOGCOORDPOINTERPROC) load("glFogCoordPointer", userptr); - glFogCoordd = (PFNGLFOGCOORDDPROC) load("glFogCoordd", userptr); - glFogCoorddv = (PFNGLFOGCOORDDVPROC) load("glFogCoorddv", userptr); - glFogCoordf = (PFNGLFOGCOORDFPROC) load("glFogCoordf", userptr); - glFogCoordfv = (PFNGLFOGCOORDFVPROC) load("glFogCoordfv", userptr); - glMultiDrawArrays = (PFNGLMULTIDRAWARRAYSPROC) load("glMultiDrawArrays", userptr); - glMultiDrawElements = (PFNGLMULTIDRAWELEMENTSPROC) load("glMultiDrawElements", userptr); - glPointParameterf = (PFNGLPOINTPARAMETERFPROC) load("glPointParameterf", userptr); - glPointParameterfv = (PFNGLPOINTPARAMETERFVPROC) load("glPointParameterfv", userptr); - glPointParameteri = (PFNGLPOINTPARAMETERIPROC) load("glPointParameteri", userptr); - glPointParameteriv = (PFNGLPOINTPARAMETERIVPROC) load("glPointParameteriv", userptr); - glSecondaryColor3b = (PFNGLSECONDARYCOLOR3BPROC) load("glSecondaryColor3b", userptr); - glSecondaryColor3bv = (PFNGLSECONDARYCOLOR3BVPROC) load("glSecondaryColor3bv", userptr); - glSecondaryColor3d = (PFNGLSECONDARYCOLOR3DPROC) load("glSecondaryColor3d", userptr); - glSecondaryColor3dv = (PFNGLSECONDARYCOLOR3DVPROC) load("glSecondaryColor3dv", userptr); - glSecondaryColor3f = (PFNGLSECONDARYCOLOR3FPROC) load("glSecondaryColor3f", userptr); - glSecondaryColor3fv = (PFNGLSECONDARYCOLOR3FVPROC) load("glSecondaryColor3fv", userptr); - glSecondaryColor3i = (PFNGLSECONDARYCOLOR3IPROC) load("glSecondaryColor3i", userptr); - glSecondaryColor3iv = (PFNGLSECONDARYCOLOR3IVPROC) load("glSecondaryColor3iv", userptr); - glSecondaryColor3s = (PFNGLSECONDARYCOLOR3SPROC) load("glSecondaryColor3s", userptr); - glSecondaryColor3sv = (PFNGLSECONDARYCOLOR3SVPROC) load("glSecondaryColor3sv", userptr); - glSecondaryColor3ub = (PFNGLSECONDARYCOLOR3UBPROC) load("glSecondaryColor3ub", userptr); - glSecondaryColor3ubv = (PFNGLSECONDARYCOLOR3UBVPROC) load("glSecondaryColor3ubv", userptr); - glSecondaryColor3ui = (PFNGLSECONDARYCOLOR3UIPROC) load("glSecondaryColor3ui", userptr); - glSecondaryColor3uiv = (PFNGLSECONDARYCOLOR3UIVPROC) load("glSecondaryColor3uiv", userptr); - glSecondaryColor3us = (PFNGLSECONDARYCOLOR3USPROC) load("glSecondaryColor3us", userptr); - glSecondaryColor3usv = (PFNGLSECONDARYCOLOR3USVPROC) load("glSecondaryColor3usv", userptr); - glSecondaryColorPointer = (PFNGLSECONDARYCOLORPOINTERPROC) load("glSecondaryColorPointer", userptr); - glWindowPos2d = (PFNGLWINDOWPOS2DPROC) load("glWindowPos2d", userptr); - glWindowPos2dv = (PFNGLWINDOWPOS2DVPROC) load("glWindowPos2dv", userptr); - glWindowPos2f = (PFNGLWINDOWPOS2FPROC) load("glWindowPos2f", userptr); - glWindowPos2fv = (PFNGLWINDOWPOS2FVPROC) load("glWindowPos2fv", userptr); - glWindowPos2i = (PFNGLWINDOWPOS2IPROC) load("glWindowPos2i", userptr); - glWindowPos2iv = (PFNGLWINDOWPOS2IVPROC) load("glWindowPos2iv", userptr); - glWindowPos2s = (PFNGLWINDOWPOS2SPROC) load("glWindowPos2s", userptr); - glWindowPos2sv = (PFNGLWINDOWPOS2SVPROC) load("glWindowPos2sv", userptr); - glWindowPos3d = (PFNGLWINDOWPOS3DPROC) load("glWindowPos3d", userptr); - glWindowPos3dv = (PFNGLWINDOWPOS3DVPROC) load("glWindowPos3dv", userptr); - glWindowPos3f = (PFNGLWINDOWPOS3FPROC) load("glWindowPos3f", userptr); - glWindowPos3fv = (PFNGLWINDOWPOS3FVPROC) load("glWindowPos3fv", userptr); - glWindowPos3i = (PFNGLWINDOWPOS3IPROC) load("glWindowPos3i", userptr); - glWindowPos3iv = (PFNGLWINDOWPOS3IVPROC) load("glWindowPos3iv", userptr); - glWindowPos3s = (PFNGLWINDOWPOS3SPROC) load("glWindowPos3s", userptr); - glWindowPos3sv = (PFNGLWINDOWPOS3SVPROC) load("glWindowPos3sv", userptr); -} -static void glad_gl_load_GL_VERSION_1_5( GLADuserptrloadfunc load, void* userptr) { - if(!GLAD_GL_VERSION_1_5) return; - glBeginQuery = (PFNGLBEGINQUERYPROC) load("glBeginQuery", userptr); - glBindBuffer = (PFNGLBINDBUFFERPROC) load("glBindBuffer", userptr); - glBufferData = (PFNGLBUFFERDATAPROC) load("glBufferData", userptr); - glBufferSubData = (PFNGLBUFFERSUBDATAPROC) load("glBufferSubData", userptr); - glDeleteBuffers = (PFNGLDELETEBUFFERSPROC) load("glDeleteBuffers", userptr); - glDeleteQueries = (PFNGLDELETEQUERIESPROC) load("glDeleteQueries", userptr); - glEndQuery = (PFNGLENDQUERYPROC) load("glEndQuery", userptr); - glGenBuffers = (PFNGLGENBUFFERSPROC) load("glGenBuffers", userptr); - glGenQueries = (PFNGLGENQUERIESPROC) load("glGenQueries", userptr); - glGetBufferParameteriv = (PFNGLGETBUFFERPARAMETERIVPROC) load("glGetBufferParameteriv", userptr); - glGetBufferPointerv = (PFNGLGETBUFFERPOINTERVPROC) load("glGetBufferPointerv", userptr); - glGetBufferSubData = (PFNGLGETBUFFERSUBDATAPROC) load("glGetBufferSubData", userptr); - glGetQueryObjectiv = (PFNGLGETQUERYOBJECTIVPROC) load("glGetQueryObjectiv", userptr); - glGetQueryObjectuiv = (PFNGLGETQUERYOBJECTUIVPROC) load("glGetQueryObjectuiv", userptr); - glGetQueryiv = (PFNGLGETQUERYIVPROC) load("glGetQueryiv", userptr); - glIsBuffer = (PFNGLISBUFFERPROC) load("glIsBuffer", userptr); - glIsQuery = (PFNGLISQUERYPROC) load("glIsQuery", userptr); - glMapBuffer = (PFNGLMAPBUFFERPROC) load("glMapBuffer", userptr); - glUnmapBuffer = (PFNGLUNMAPBUFFERPROC) load("glUnmapBuffer", userptr); -} -static void glad_gl_load_GL_VERSION_2_0( GLADuserptrloadfunc load, void* userptr) { - if(!GLAD_GL_VERSION_2_0) return; - glAttachShader = (PFNGLATTACHSHADERPROC) load("glAttachShader", userptr); - glBindAttribLocation = (PFNGLBINDATTRIBLOCATIONPROC) load("glBindAttribLocation", userptr); - glBlendEquationSeparate = (PFNGLBLENDEQUATIONSEPARATEPROC) load("glBlendEquationSeparate", userptr); - glCompileShader = (PFNGLCOMPILESHADERPROC) load("glCompileShader", userptr); - glCreateProgram = (PFNGLCREATEPROGRAMPROC) load("glCreateProgram", userptr); - glCreateShader = (PFNGLCREATESHADERPROC) load("glCreateShader", userptr); - glDeleteProgram = (PFNGLDELETEPROGRAMPROC) load("glDeleteProgram", userptr); - glDeleteShader = (PFNGLDELETESHADERPROC) load("glDeleteShader", userptr); - glDetachShader = (PFNGLDETACHSHADERPROC) load("glDetachShader", userptr); - glDisableVertexAttribArray = (PFNGLDISABLEVERTEXATTRIBARRAYPROC) load("glDisableVertexAttribArray", userptr); - glDrawBuffers = (PFNGLDRAWBUFFERSPROC) load("glDrawBuffers", userptr); - glEnableVertexAttribArray = (PFNGLENABLEVERTEXATTRIBARRAYPROC) load("glEnableVertexAttribArray", userptr); - glGetActiveAttrib = (PFNGLGETACTIVEATTRIBPROC) load("glGetActiveAttrib", userptr); - glGetActiveUniform = (PFNGLGETACTIVEUNIFORMPROC) load("glGetActiveUniform", userptr); - glGetAttachedShaders = (PFNGLGETATTACHEDSHADERSPROC) load("glGetAttachedShaders", userptr); - glGetAttribLocation = (PFNGLGETATTRIBLOCATIONPROC) load("glGetAttribLocation", userptr); - glGetProgramInfoLog = (PFNGLGETPROGRAMINFOLOGPROC) load("glGetProgramInfoLog", userptr); - glGetProgramiv = (PFNGLGETPROGRAMIVPROC) load("glGetProgramiv", userptr); - glGetShaderInfoLog = (PFNGLGETSHADERINFOLOGPROC) load("glGetShaderInfoLog", userptr); - glGetShaderSource = (PFNGLGETSHADERSOURCEPROC) load("glGetShaderSource", userptr); - glGetShaderiv = (PFNGLGETSHADERIVPROC) load("glGetShaderiv", userptr); - glGetUniformLocation = (PFNGLGETUNIFORMLOCATIONPROC) load("glGetUniformLocation", userptr); - glGetUniformfv = (PFNGLGETUNIFORMFVPROC) load("glGetUniformfv", userptr); - glGetUniformiv = (PFNGLGETUNIFORMIVPROC) load("glGetUniformiv", userptr); - glGetVertexAttribPointerv = (PFNGLGETVERTEXATTRIBPOINTERVPROC) load("glGetVertexAttribPointerv", userptr); - glGetVertexAttribdv = (PFNGLGETVERTEXATTRIBDVPROC) load("glGetVertexAttribdv", userptr); - glGetVertexAttribfv = (PFNGLGETVERTEXATTRIBFVPROC) load("glGetVertexAttribfv", userptr); - glGetVertexAttribiv = (PFNGLGETVERTEXATTRIBIVPROC) load("glGetVertexAttribiv", userptr); - glIsProgram = (PFNGLISPROGRAMPROC) load("glIsProgram", userptr); - glIsShader = (PFNGLISSHADERPROC) load("glIsShader", userptr); - glLinkProgram = (PFNGLLINKPROGRAMPROC) load("glLinkProgram", userptr); - glShaderSource = (PFNGLSHADERSOURCEPROC) load("glShaderSource", userptr); - glStencilFuncSeparate = (PFNGLSTENCILFUNCSEPARATEPROC) load("glStencilFuncSeparate", userptr); - glStencilMaskSeparate = (PFNGLSTENCILMASKSEPARATEPROC) load("glStencilMaskSeparate", userptr); - glStencilOpSeparate = (PFNGLSTENCILOPSEPARATEPROC) load("glStencilOpSeparate", userptr); - glUniform1f = (PFNGLUNIFORM1FPROC) load("glUniform1f", userptr); - glUniform1fv = (PFNGLUNIFORM1FVPROC) load("glUniform1fv", userptr); - glUniform1i = (PFNGLUNIFORM1IPROC) load("glUniform1i", userptr); - glUniform1iv = (PFNGLUNIFORM1IVPROC) load("glUniform1iv", userptr); - glUniform2f = (PFNGLUNIFORM2FPROC) load("glUniform2f", userptr); - glUniform2fv = (PFNGLUNIFORM2FVPROC) load("glUniform2fv", userptr); - glUniform2i = (PFNGLUNIFORM2IPROC) load("glUniform2i", userptr); - glUniform2iv = (PFNGLUNIFORM2IVPROC) load("glUniform2iv", userptr); - glUniform3f = (PFNGLUNIFORM3FPROC) load("glUniform3f", userptr); - glUniform3fv = (PFNGLUNIFORM3FVPROC) load("glUniform3fv", userptr); - glUniform3i = (PFNGLUNIFORM3IPROC) load("glUniform3i", userptr); - glUniform3iv = (PFNGLUNIFORM3IVPROC) load("glUniform3iv", userptr); - glUniform4f = (PFNGLUNIFORM4FPROC) load("glUniform4f", userptr); - glUniform4fv = (PFNGLUNIFORM4FVPROC) load("glUniform4fv", userptr); - glUniform4i = (PFNGLUNIFORM4IPROC) load("glUniform4i", userptr); - glUniform4iv = (PFNGLUNIFORM4IVPROC) load("glUniform4iv", userptr); - glUniformMatrix2fv = (PFNGLUNIFORMMATRIX2FVPROC) load("glUniformMatrix2fv", userptr); - glUniformMatrix3fv = (PFNGLUNIFORMMATRIX3FVPROC) load("glUniformMatrix3fv", userptr); - glUniformMatrix4fv = (PFNGLUNIFORMMATRIX4FVPROC) load("glUniformMatrix4fv", userptr); - glUseProgram = (PFNGLUSEPROGRAMPROC) load("glUseProgram", userptr); - glValidateProgram = (PFNGLVALIDATEPROGRAMPROC) load("glValidateProgram", userptr); - glVertexAttrib1d = (PFNGLVERTEXATTRIB1DPROC) load("glVertexAttrib1d", userptr); - glVertexAttrib1dv = (PFNGLVERTEXATTRIB1DVPROC) load("glVertexAttrib1dv", userptr); - glVertexAttrib1f = (PFNGLVERTEXATTRIB1FPROC) load("glVertexAttrib1f", userptr); - glVertexAttrib1fv = (PFNGLVERTEXATTRIB1FVPROC) load("glVertexAttrib1fv", userptr); - glVertexAttrib1s = (PFNGLVERTEXATTRIB1SPROC) load("glVertexAttrib1s", userptr); - glVertexAttrib1sv = (PFNGLVERTEXATTRIB1SVPROC) load("glVertexAttrib1sv", userptr); - glVertexAttrib2d = (PFNGLVERTEXATTRIB2DPROC) load("glVertexAttrib2d", userptr); - glVertexAttrib2dv = (PFNGLVERTEXATTRIB2DVPROC) load("glVertexAttrib2dv", userptr); - glVertexAttrib2f = (PFNGLVERTEXATTRIB2FPROC) load("glVertexAttrib2f", userptr); - glVertexAttrib2fv = (PFNGLVERTEXATTRIB2FVPROC) load("glVertexAttrib2fv", userptr); - glVertexAttrib2s = (PFNGLVERTEXATTRIB2SPROC) load("glVertexAttrib2s", userptr); - glVertexAttrib2sv = (PFNGLVERTEXATTRIB2SVPROC) load("glVertexAttrib2sv", userptr); - glVertexAttrib3d = (PFNGLVERTEXATTRIB3DPROC) load("glVertexAttrib3d", userptr); - glVertexAttrib3dv = (PFNGLVERTEXATTRIB3DVPROC) load("glVertexAttrib3dv", userptr); - glVertexAttrib3f = (PFNGLVERTEXATTRIB3FPROC) load("glVertexAttrib3f", userptr); - glVertexAttrib3fv = (PFNGLVERTEXATTRIB3FVPROC) load("glVertexAttrib3fv", userptr); - glVertexAttrib3s = (PFNGLVERTEXATTRIB3SPROC) load("glVertexAttrib3s", userptr); - glVertexAttrib3sv = (PFNGLVERTEXATTRIB3SVPROC) load("glVertexAttrib3sv", userptr); - glVertexAttrib4Nbv = (PFNGLVERTEXATTRIB4NBVPROC) load("glVertexAttrib4Nbv", userptr); - glVertexAttrib4Niv = (PFNGLVERTEXATTRIB4NIVPROC) load("glVertexAttrib4Niv", userptr); - glVertexAttrib4Nsv = (PFNGLVERTEXATTRIB4NSVPROC) load("glVertexAttrib4Nsv", userptr); - glVertexAttrib4Nub = (PFNGLVERTEXATTRIB4NUBPROC) load("glVertexAttrib4Nub", userptr); - glVertexAttrib4Nubv = (PFNGLVERTEXATTRIB4NUBVPROC) load("glVertexAttrib4Nubv", userptr); - glVertexAttrib4Nuiv = (PFNGLVERTEXATTRIB4NUIVPROC) load("glVertexAttrib4Nuiv", userptr); - glVertexAttrib4Nusv = (PFNGLVERTEXATTRIB4NUSVPROC) load("glVertexAttrib4Nusv", userptr); - glVertexAttrib4bv = (PFNGLVERTEXATTRIB4BVPROC) load("glVertexAttrib4bv", userptr); - glVertexAttrib4d = (PFNGLVERTEXATTRIB4DPROC) load("glVertexAttrib4d", userptr); - glVertexAttrib4dv = (PFNGLVERTEXATTRIB4DVPROC) load("glVertexAttrib4dv", userptr); - glVertexAttrib4f = (PFNGLVERTEXATTRIB4FPROC) load("glVertexAttrib4f", userptr); - glVertexAttrib4fv = (PFNGLVERTEXATTRIB4FVPROC) load("glVertexAttrib4fv", userptr); - glVertexAttrib4iv = (PFNGLVERTEXATTRIB4IVPROC) load("glVertexAttrib4iv", userptr); - glVertexAttrib4s = (PFNGLVERTEXATTRIB4SPROC) load("glVertexAttrib4s", userptr); - glVertexAttrib4sv = (PFNGLVERTEXATTRIB4SVPROC) load("glVertexAttrib4sv", userptr); - glVertexAttrib4ubv = (PFNGLVERTEXATTRIB4UBVPROC) load("glVertexAttrib4ubv", userptr); - glVertexAttrib4uiv = (PFNGLVERTEXATTRIB4UIVPROC) load("glVertexAttrib4uiv", userptr); - glVertexAttrib4usv = (PFNGLVERTEXATTRIB4USVPROC) load("glVertexAttrib4usv", userptr); - glVertexAttribPointer = (PFNGLVERTEXATTRIBPOINTERPROC) load("glVertexAttribPointer", userptr); -} -static void glad_gl_load_GL_VERSION_2_1( GLADuserptrloadfunc load, void* userptr) { - if(!GLAD_GL_VERSION_2_1) return; - glUniformMatrix2x3fv = (PFNGLUNIFORMMATRIX2X3FVPROC) load("glUniformMatrix2x3fv", userptr); - glUniformMatrix2x4fv = (PFNGLUNIFORMMATRIX2X4FVPROC) load("glUniformMatrix2x4fv", userptr); - glUniformMatrix3x2fv = (PFNGLUNIFORMMATRIX3X2FVPROC) load("glUniformMatrix3x2fv", userptr); - glUniformMatrix3x4fv = (PFNGLUNIFORMMATRIX3X4FVPROC) load("glUniformMatrix3x4fv", userptr); - glUniformMatrix4x2fv = (PFNGLUNIFORMMATRIX4X2FVPROC) load("glUniformMatrix4x2fv", userptr); - glUniformMatrix4x3fv = (PFNGLUNIFORMMATRIX4X3FVPROC) load("glUniformMatrix4x3fv", userptr); -} -static void glad_gl_load_GL_VERSION_3_0( GLADuserptrloadfunc load, void* userptr) { - if(!GLAD_GL_VERSION_3_0) return; - glBeginConditionalRender = (PFNGLBEGINCONDITIONALRENDERPROC) load("glBeginConditionalRender", userptr); - glBeginTransformFeedback = (PFNGLBEGINTRANSFORMFEEDBACKPROC) load("glBeginTransformFeedback", userptr); - glBindBufferBase = (PFNGLBINDBUFFERBASEPROC) load("glBindBufferBase", userptr); - glBindBufferRange = (PFNGLBINDBUFFERRANGEPROC) load("glBindBufferRange", userptr); - glBindFragDataLocation = (PFNGLBINDFRAGDATALOCATIONPROC) load("glBindFragDataLocation", userptr); - glBindFramebuffer = (PFNGLBINDFRAMEBUFFERPROC) load("glBindFramebuffer", userptr); - glBindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC) load("glBindRenderbuffer", userptr); - glBindVertexArray = (PFNGLBINDVERTEXARRAYPROC) load("glBindVertexArray", userptr); - glBlitFramebuffer = (PFNGLBLITFRAMEBUFFERPROC) load("glBlitFramebuffer", userptr); - glCheckFramebufferStatus = (PFNGLCHECKFRAMEBUFFERSTATUSPROC) load("glCheckFramebufferStatus", userptr); - glClampColor = (PFNGLCLAMPCOLORPROC) load("glClampColor", userptr); - glClearBufferfi = (PFNGLCLEARBUFFERFIPROC) load("glClearBufferfi", userptr); - glClearBufferfv = (PFNGLCLEARBUFFERFVPROC) load("glClearBufferfv", userptr); - glClearBufferiv = (PFNGLCLEARBUFFERIVPROC) load("glClearBufferiv", userptr); - glClearBufferuiv = (PFNGLCLEARBUFFERUIVPROC) load("glClearBufferuiv", userptr); - glColorMaski = (PFNGLCOLORMASKIPROC) load("glColorMaski", userptr); - glDeleteFramebuffers = (PFNGLDELETEFRAMEBUFFERSPROC) load("glDeleteFramebuffers", userptr); - glDeleteRenderbuffers = (PFNGLDELETERENDERBUFFERSPROC) load("glDeleteRenderbuffers", userptr); - glDeleteVertexArrays = (PFNGLDELETEVERTEXARRAYSPROC) load("glDeleteVertexArrays", userptr); - glDisablei = (PFNGLDISABLEIPROC) load("glDisablei", userptr); - glEnablei = (PFNGLENABLEIPROC) load("glEnablei", userptr); - glEndConditionalRender = (PFNGLENDCONDITIONALRENDERPROC) load("glEndConditionalRender", userptr); - glEndTransformFeedback = (PFNGLENDTRANSFORMFEEDBACKPROC) load("glEndTransformFeedback", userptr); - glFlushMappedBufferRange = (PFNGLFLUSHMAPPEDBUFFERRANGEPROC) load("glFlushMappedBufferRange", userptr); - glFramebufferRenderbuffer = (PFNGLFRAMEBUFFERRENDERBUFFERPROC) load("glFramebufferRenderbuffer", userptr); - glFramebufferTexture1D = (PFNGLFRAMEBUFFERTEXTURE1DPROC) load("glFramebufferTexture1D", userptr); - glFramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DPROC) load("glFramebufferTexture2D", userptr); - glFramebufferTexture3D = (PFNGLFRAMEBUFFERTEXTURE3DPROC) load("glFramebufferTexture3D", userptr); - glFramebufferTextureLayer = (PFNGLFRAMEBUFFERTEXTURELAYERPROC) load("glFramebufferTextureLayer", userptr); - glGenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC) load("glGenFramebuffers", userptr); - glGenRenderbuffers = (PFNGLGENRENDERBUFFERSPROC) load("glGenRenderbuffers", userptr); - glGenVertexArrays = (PFNGLGENVERTEXARRAYSPROC) load("glGenVertexArrays", userptr); - glGenerateMipmap = (PFNGLGENERATEMIPMAPPROC) load("glGenerateMipmap", userptr); - glGetBooleani_v = (PFNGLGETBOOLEANI_VPROC) load("glGetBooleani_v", userptr); - glGetFragDataLocation = (PFNGLGETFRAGDATALOCATIONPROC) load("glGetFragDataLocation", userptr); - glGetFramebufferAttachmentParameteriv = (PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC) load("glGetFramebufferAttachmentParameteriv", userptr); - glGetIntegeri_v = (PFNGLGETINTEGERI_VPROC) load("glGetIntegeri_v", userptr); - glGetRenderbufferParameteriv = (PFNGLGETRENDERBUFFERPARAMETERIVPROC) load("glGetRenderbufferParameteriv", userptr); - glGetStringi = (PFNGLGETSTRINGIPROC) load("glGetStringi", userptr); - glGetTexParameterIiv = (PFNGLGETTEXPARAMETERIIVPROC) load("glGetTexParameterIiv", userptr); - glGetTexParameterIuiv = (PFNGLGETTEXPARAMETERIUIVPROC) load("glGetTexParameterIuiv", userptr); - glGetTransformFeedbackVarying = (PFNGLGETTRANSFORMFEEDBACKVARYINGPROC) load("glGetTransformFeedbackVarying", userptr); - glGetUniformuiv = (PFNGLGETUNIFORMUIVPROC) load("glGetUniformuiv", userptr); - glGetVertexAttribIiv = (PFNGLGETVERTEXATTRIBIIVPROC) load("glGetVertexAttribIiv", userptr); - glGetVertexAttribIuiv = (PFNGLGETVERTEXATTRIBIUIVPROC) load("glGetVertexAttribIuiv", userptr); - glIsEnabledi = (PFNGLISENABLEDIPROC) load("glIsEnabledi", userptr); - glIsFramebuffer = (PFNGLISFRAMEBUFFERPROC) load("glIsFramebuffer", userptr); - glIsRenderbuffer = (PFNGLISRENDERBUFFERPROC) load("glIsRenderbuffer", userptr); - glIsVertexArray = (PFNGLISVERTEXARRAYPROC) load("glIsVertexArray", userptr); - glMapBufferRange = (PFNGLMAPBUFFERRANGEPROC) load("glMapBufferRange", userptr); - glRenderbufferStorage = (PFNGLRENDERBUFFERSTORAGEPROC) load("glRenderbufferStorage", userptr); - glRenderbufferStorageMultisample = (PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC) load("glRenderbufferStorageMultisample", userptr); - glTexParameterIiv = (PFNGLTEXPARAMETERIIVPROC) load("glTexParameterIiv", userptr); - glTexParameterIuiv = (PFNGLTEXPARAMETERIUIVPROC) load("glTexParameterIuiv", userptr); - glTransformFeedbackVaryings = (PFNGLTRANSFORMFEEDBACKVARYINGSPROC) load("glTransformFeedbackVaryings", userptr); - glUniform1ui = (PFNGLUNIFORM1UIPROC) load("glUniform1ui", userptr); - glUniform1uiv = (PFNGLUNIFORM1UIVPROC) load("glUniform1uiv", userptr); - glUniform2ui = (PFNGLUNIFORM2UIPROC) load("glUniform2ui", userptr); - glUniform2uiv = (PFNGLUNIFORM2UIVPROC) load("glUniform2uiv", userptr); - glUniform3ui = (PFNGLUNIFORM3UIPROC) load("glUniform3ui", userptr); - glUniform3uiv = (PFNGLUNIFORM3UIVPROC) load("glUniform3uiv", userptr); - glUniform4ui = (PFNGLUNIFORM4UIPROC) load("glUniform4ui", userptr); - glUniform4uiv = (PFNGLUNIFORM4UIVPROC) load("glUniform4uiv", userptr); - glVertexAttribI1i = (PFNGLVERTEXATTRIBI1IPROC) load("glVertexAttribI1i", userptr); - glVertexAttribI1iv = (PFNGLVERTEXATTRIBI1IVPROC) load("glVertexAttribI1iv", userptr); - glVertexAttribI1ui = (PFNGLVERTEXATTRIBI1UIPROC) load("glVertexAttribI1ui", userptr); - glVertexAttribI1uiv = (PFNGLVERTEXATTRIBI1UIVPROC) load("glVertexAttribI1uiv", userptr); - glVertexAttribI2i = (PFNGLVERTEXATTRIBI2IPROC) load("glVertexAttribI2i", userptr); - glVertexAttribI2iv = (PFNGLVERTEXATTRIBI2IVPROC) load("glVertexAttribI2iv", userptr); - glVertexAttribI2ui = (PFNGLVERTEXATTRIBI2UIPROC) load("glVertexAttribI2ui", userptr); - glVertexAttribI2uiv = (PFNGLVERTEXATTRIBI2UIVPROC) load("glVertexAttribI2uiv", userptr); - glVertexAttribI3i = (PFNGLVERTEXATTRIBI3IPROC) load("glVertexAttribI3i", userptr); - glVertexAttribI3iv = (PFNGLVERTEXATTRIBI3IVPROC) load("glVertexAttribI3iv", userptr); - glVertexAttribI3ui = (PFNGLVERTEXATTRIBI3UIPROC) load("glVertexAttribI3ui", userptr); - glVertexAttribI3uiv = (PFNGLVERTEXATTRIBI3UIVPROC) load("glVertexAttribI3uiv", userptr); - glVertexAttribI4bv = (PFNGLVERTEXATTRIBI4BVPROC) load("glVertexAttribI4bv", userptr); - glVertexAttribI4i = (PFNGLVERTEXATTRIBI4IPROC) load("glVertexAttribI4i", userptr); - glVertexAttribI4iv = (PFNGLVERTEXATTRIBI4IVPROC) load("glVertexAttribI4iv", userptr); - glVertexAttribI4sv = (PFNGLVERTEXATTRIBI4SVPROC) load("glVertexAttribI4sv", userptr); - glVertexAttribI4ubv = (PFNGLVERTEXATTRIBI4UBVPROC) load("glVertexAttribI4ubv", userptr); - glVertexAttribI4ui = (PFNGLVERTEXATTRIBI4UIPROC) load("glVertexAttribI4ui", userptr); - glVertexAttribI4uiv = (PFNGLVERTEXATTRIBI4UIVPROC) load("glVertexAttribI4uiv", userptr); - glVertexAttribI4usv = (PFNGLVERTEXATTRIBI4USVPROC) load("glVertexAttribI4usv", userptr); - glVertexAttribIPointer = (PFNGLVERTEXATTRIBIPOINTERPROC) load("glVertexAttribIPointer", userptr); -} -static void glad_gl_load_GL_VERSION_3_1( GLADuserptrloadfunc load, void* userptr) { - if(!GLAD_GL_VERSION_3_1) return; - glBindBufferBase = (PFNGLBINDBUFFERBASEPROC) load("glBindBufferBase", userptr); - glBindBufferRange = (PFNGLBINDBUFFERRANGEPROC) load("glBindBufferRange", userptr); - glCopyBufferSubData = (PFNGLCOPYBUFFERSUBDATAPROC) load("glCopyBufferSubData", userptr); - glDrawArraysInstanced = (PFNGLDRAWARRAYSINSTANCEDPROC) load("glDrawArraysInstanced", userptr); - glDrawElementsInstanced = (PFNGLDRAWELEMENTSINSTANCEDPROC) load("glDrawElementsInstanced", userptr); - glGetActiveUniformBlockName = (PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC) load("glGetActiveUniformBlockName", userptr); - glGetActiveUniformBlockiv = (PFNGLGETACTIVEUNIFORMBLOCKIVPROC) load("glGetActiveUniformBlockiv", userptr); - glGetActiveUniformName = (PFNGLGETACTIVEUNIFORMNAMEPROC) load("glGetActiveUniformName", userptr); - glGetActiveUniformsiv = (PFNGLGETACTIVEUNIFORMSIVPROC) load("glGetActiveUniformsiv", userptr); - glGetIntegeri_v = (PFNGLGETINTEGERI_VPROC) load("glGetIntegeri_v", userptr); - glGetUniformBlockIndex = (PFNGLGETUNIFORMBLOCKINDEXPROC) load("glGetUniformBlockIndex", userptr); - glGetUniformIndices = (PFNGLGETUNIFORMINDICESPROC) load("glGetUniformIndices", userptr); - glPrimitiveRestartIndex = (PFNGLPRIMITIVERESTARTINDEXPROC) load("glPrimitiveRestartIndex", userptr); - glTexBuffer = (PFNGLTEXBUFFERPROC) load("glTexBuffer", userptr); - glUniformBlockBinding = (PFNGLUNIFORMBLOCKBINDINGPROC) load("glUniformBlockBinding", userptr); -} -static void glad_gl_load_GL_VERSION_3_2( GLADuserptrloadfunc load, void* userptr) { - if(!GLAD_GL_VERSION_3_2) return; - glClientWaitSync = (PFNGLCLIENTWAITSYNCPROC) load("glClientWaitSync", userptr); - glDeleteSync = (PFNGLDELETESYNCPROC) load("glDeleteSync", userptr); - glDrawElementsBaseVertex = (PFNGLDRAWELEMENTSBASEVERTEXPROC) load("glDrawElementsBaseVertex", userptr); - glDrawElementsInstancedBaseVertex = (PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC) load("glDrawElementsInstancedBaseVertex", userptr); - glDrawRangeElementsBaseVertex = (PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC) load("glDrawRangeElementsBaseVertex", userptr); - glFenceSync = (PFNGLFENCESYNCPROC) load("glFenceSync", userptr); - glFramebufferTexture = (PFNGLFRAMEBUFFERTEXTUREPROC) load("glFramebufferTexture", userptr); - glGetBufferParameteri64v = (PFNGLGETBUFFERPARAMETERI64VPROC) load("glGetBufferParameteri64v", userptr); - glGetInteger64i_v = (PFNGLGETINTEGER64I_VPROC) load("glGetInteger64i_v", userptr); - glGetInteger64v = (PFNGLGETINTEGER64VPROC) load("glGetInteger64v", userptr); - glGetMultisamplefv = (PFNGLGETMULTISAMPLEFVPROC) load("glGetMultisamplefv", userptr); - glGetSynciv = (PFNGLGETSYNCIVPROC) load("glGetSynciv", userptr); - glIsSync = (PFNGLISSYNCPROC) load("glIsSync", userptr); - glMultiDrawElementsBaseVertex = (PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC) load("glMultiDrawElementsBaseVertex", userptr); - glProvokingVertex = (PFNGLPROVOKINGVERTEXPROC) load("glProvokingVertex", userptr); - glSampleMaski = (PFNGLSAMPLEMASKIPROC) load("glSampleMaski", userptr); - glTexImage2DMultisample = (PFNGLTEXIMAGE2DMULTISAMPLEPROC) load("glTexImage2DMultisample", userptr); - glTexImage3DMultisample = (PFNGLTEXIMAGE3DMULTISAMPLEPROC) load("glTexImage3DMultisample", userptr); - glWaitSync = (PFNGLWAITSYNCPROC) load("glWaitSync", userptr); -} -static void glad_gl_load_GL_VERSION_3_3( GLADuserptrloadfunc load, void* userptr) { - if(!GLAD_GL_VERSION_3_3) return; - glBindFragDataLocationIndexed = (PFNGLBINDFRAGDATALOCATIONINDEXEDPROC) load("glBindFragDataLocationIndexed", userptr); - glBindSampler = (PFNGLBINDSAMPLERPROC) load("glBindSampler", userptr); - glColorP3ui = (PFNGLCOLORP3UIPROC) load("glColorP3ui", userptr); - glColorP3uiv = (PFNGLCOLORP3UIVPROC) load("glColorP3uiv", userptr); - glColorP4ui = (PFNGLCOLORP4UIPROC) load("glColorP4ui", userptr); - glColorP4uiv = (PFNGLCOLORP4UIVPROC) load("glColorP4uiv", userptr); - glDeleteSamplers = (PFNGLDELETESAMPLERSPROC) load("glDeleteSamplers", userptr); - glGenSamplers = (PFNGLGENSAMPLERSPROC) load("glGenSamplers", userptr); - glGetFragDataIndex = (PFNGLGETFRAGDATAINDEXPROC) load("glGetFragDataIndex", userptr); - glGetQueryObjecti64v = (PFNGLGETQUERYOBJECTI64VPROC) load("glGetQueryObjecti64v", userptr); - glGetQueryObjectui64v = (PFNGLGETQUERYOBJECTUI64VPROC) load("glGetQueryObjectui64v", userptr); - glGetSamplerParameterIiv = (PFNGLGETSAMPLERPARAMETERIIVPROC) load("glGetSamplerParameterIiv", userptr); - glGetSamplerParameterIuiv = (PFNGLGETSAMPLERPARAMETERIUIVPROC) load("glGetSamplerParameterIuiv", userptr); - glGetSamplerParameterfv = (PFNGLGETSAMPLERPARAMETERFVPROC) load("glGetSamplerParameterfv", userptr); - glGetSamplerParameteriv = (PFNGLGETSAMPLERPARAMETERIVPROC) load("glGetSamplerParameteriv", userptr); - glIsSampler = (PFNGLISSAMPLERPROC) load("glIsSampler", userptr); - glMultiTexCoordP1ui = (PFNGLMULTITEXCOORDP1UIPROC) load("glMultiTexCoordP1ui", userptr); - glMultiTexCoordP1uiv = (PFNGLMULTITEXCOORDP1UIVPROC) load("glMultiTexCoordP1uiv", userptr); - glMultiTexCoordP2ui = (PFNGLMULTITEXCOORDP2UIPROC) load("glMultiTexCoordP2ui", userptr); - glMultiTexCoordP2uiv = (PFNGLMULTITEXCOORDP2UIVPROC) load("glMultiTexCoordP2uiv", userptr); - glMultiTexCoordP3ui = (PFNGLMULTITEXCOORDP3UIPROC) load("glMultiTexCoordP3ui", userptr); - glMultiTexCoordP3uiv = (PFNGLMULTITEXCOORDP3UIVPROC) load("glMultiTexCoordP3uiv", userptr); - glMultiTexCoordP4ui = (PFNGLMULTITEXCOORDP4UIPROC) load("glMultiTexCoordP4ui", userptr); - glMultiTexCoordP4uiv = (PFNGLMULTITEXCOORDP4UIVPROC) load("glMultiTexCoordP4uiv", userptr); - glNormalP3ui = (PFNGLNORMALP3UIPROC) load("glNormalP3ui", userptr); - glNormalP3uiv = (PFNGLNORMALP3UIVPROC) load("glNormalP3uiv", userptr); - glQueryCounter = (PFNGLQUERYCOUNTERPROC) load("glQueryCounter", userptr); - glSamplerParameterIiv = (PFNGLSAMPLERPARAMETERIIVPROC) load("glSamplerParameterIiv", userptr); - glSamplerParameterIuiv = (PFNGLSAMPLERPARAMETERIUIVPROC) load("glSamplerParameterIuiv", userptr); - glSamplerParameterf = (PFNGLSAMPLERPARAMETERFPROC) load("glSamplerParameterf", userptr); - glSamplerParameterfv = (PFNGLSAMPLERPARAMETERFVPROC) load("glSamplerParameterfv", userptr); - glSamplerParameteri = (PFNGLSAMPLERPARAMETERIPROC) load("glSamplerParameteri", userptr); - glSamplerParameteriv = (PFNGLSAMPLERPARAMETERIVPROC) load("glSamplerParameteriv", userptr); - glSecondaryColorP3ui = (PFNGLSECONDARYCOLORP3UIPROC) load("glSecondaryColorP3ui", userptr); - glSecondaryColorP3uiv = (PFNGLSECONDARYCOLORP3UIVPROC) load("glSecondaryColorP3uiv", userptr); - glTexCoordP1ui = (PFNGLTEXCOORDP1UIPROC) load("glTexCoordP1ui", userptr); - glTexCoordP1uiv = (PFNGLTEXCOORDP1UIVPROC) load("glTexCoordP1uiv", userptr); - glTexCoordP2ui = (PFNGLTEXCOORDP2UIPROC) load("glTexCoordP2ui", userptr); - glTexCoordP2uiv = (PFNGLTEXCOORDP2UIVPROC) load("glTexCoordP2uiv", userptr); - glTexCoordP3ui = (PFNGLTEXCOORDP3UIPROC) load("glTexCoordP3ui", userptr); - glTexCoordP3uiv = (PFNGLTEXCOORDP3UIVPROC) load("glTexCoordP3uiv", userptr); - glTexCoordP4ui = (PFNGLTEXCOORDP4UIPROC) load("glTexCoordP4ui", userptr); - glTexCoordP4uiv = (PFNGLTEXCOORDP4UIVPROC) load("glTexCoordP4uiv", userptr); - glVertexAttribDivisor = (PFNGLVERTEXATTRIBDIVISORPROC) load("glVertexAttribDivisor", userptr); - glVertexAttribP1ui = (PFNGLVERTEXATTRIBP1UIPROC) load("glVertexAttribP1ui", userptr); - glVertexAttribP1uiv = (PFNGLVERTEXATTRIBP1UIVPROC) load("glVertexAttribP1uiv", userptr); - glVertexAttribP2ui = (PFNGLVERTEXATTRIBP2UIPROC) load("glVertexAttribP2ui", userptr); - glVertexAttribP2uiv = (PFNGLVERTEXATTRIBP2UIVPROC) load("glVertexAttribP2uiv", userptr); - glVertexAttribP3ui = (PFNGLVERTEXATTRIBP3UIPROC) load("glVertexAttribP3ui", userptr); - glVertexAttribP3uiv = (PFNGLVERTEXATTRIBP3UIVPROC) load("glVertexAttribP3uiv", userptr); - glVertexAttribP4ui = (PFNGLVERTEXATTRIBP4UIPROC) load("glVertexAttribP4ui", userptr); - glVertexAttribP4uiv = (PFNGLVERTEXATTRIBP4UIVPROC) load("glVertexAttribP4uiv", userptr); - glVertexP2ui = (PFNGLVERTEXP2UIPROC) load("glVertexP2ui", userptr); - glVertexP2uiv = (PFNGLVERTEXP2UIVPROC) load("glVertexP2uiv", userptr); - glVertexP3ui = (PFNGLVERTEXP3UIPROC) load("glVertexP3ui", userptr); - glVertexP3uiv = (PFNGLVERTEXP3UIVPROC) load("glVertexP3uiv", userptr); - glVertexP4ui = (PFNGLVERTEXP4UIPROC) load("glVertexP4ui", userptr); - glVertexP4uiv = (PFNGLVERTEXP4UIVPROC) load("glVertexP4uiv", userptr); -} -static void glad_gl_load_GL_ARB_multisample( GLADuserptrloadfunc load, void* userptr) { - if(!GLAD_GL_ARB_multisample) return; - glSampleCoverage = (PFNGLSAMPLECOVERAGEPROC) load("glSampleCoverage", userptr); - glSampleCoverageARB = (PFNGLSAMPLECOVERAGEARBPROC) load("glSampleCoverageARB", userptr); -} -static void glad_gl_load_GL_ARB_robustness( GLADuserptrloadfunc load, void* userptr) { - if(!GLAD_GL_ARB_robustness) return; - glGetGraphicsResetStatusARB = (PFNGLGETGRAPHICSRESETSTATUSARBPROC) load("glGetGraphicsResetStatusARB", userptr); - glGetnColorTableARB = (PFNGLGETNCOLORTABLEARBPROC) load("glGetnColorTableARB", userptr); - glGetnCompressedTexImageARB = (PFNGLGETNCOMPRESSEDTEXIMAGEARBPROC) load("glGetnCompressedTexImageARB", userptr); - glGetnConvolutionFilterARB = (PFNGLGETNCONVOLUTIONFILTERARBPROC) load("glGetnConvolutionFilterARB", userptr); - glGetnHistogramARB = (PFNGLGETNHISTOGRAMARBPROC) load("glGetnHistogramARB", userptr); - glGetnMapdvARB = (PFNGLGETNMAPDVARBPROC) load("glGetnMapdvARB", userptr); - glGetnMapfvARB = (PFNGLGETNMAPFVARBPROC) load("glGetnMapfvARB", userptr); - glGetnMapivARB = (PFNGLGETNMAPIVARBPROC) load("glGetnMapivARB", userptr); - glGetnMinmaxARB = (PFNGLGETNMINMAXARBPROC) load("glGetnMinmaxARB", userptr); - glGetnPixelMapfvARB = (PFNGLGETNPIXELMAPFVARBPROC) load("glGetnPixelMapfvARB", userptr); - glGetnPixelMapuivARB = (PFNGLGETNPIXELMAPUIVARBPROC) load("glGetnPixelMapuivARB", userptr); - glGetnPixelMapusvARB = (PFNGLGETNPIXELMAPUSVARBPROC) load("glGetnPixelMapusvARB", userptr); - glGetnPolygonStippleARB = (PFNGLGETNPOLYGONSTIPPLEARBPROC) load("glGetnPolygonStippleARB", userptr); - glGetnSeparableFilterARB = (PFNGLGETNSEPARABLEFILTERARBPROC) load("glGetnSeparableFilterARB", userptr); - glGetnTexImageARB = (PFNGLGETNTEXIMAGEARBPROC) load("glGetnTexImageARB", userptr); - glGetnUniformdvARB = (PFNGLGETNUNIFORMDVARBPROC) load("glGetnUniformdvARB", userptr); - glGetnUniformfvARB = (PFNGLGETNUNIFORMFVARBPROC) load("glGetnUniformfvARB", userptr); - glGetnUniformivARB = (PFNGLGETNUNIFORMIVARBPROC) load("glGetnUniformivARB", userptr); - glGetnUniformuivARB = (PFNGLGETNUNIFORMUIVARBPROC) load("glGetnUniformuivARB", userptr); - glReadnPixels = (PFNGLREADNPIXELSPROC) load("glReadnPixels", userptr); - glReadnPixelsARB = (PFNGLREADNPIXELSARBPROC) load("glReadnPixelsARB", userptr); -} -static void glad_gl_load_GL_KHR_debug( GLADuserptrloadfunc load, void* userptr) { - if(!GLAD_GL_KHR_debug) return; - glDebugMessageCallback = (PFNGLDEBUGMESSAGECALLBACKPROC) load("glDebugMessageCallback", userptr); - glDebugMessageControl = (PFNGLDEBUGMESSAGECONTROLPROC) load("glDebugMessageControl", userptr); - glDebugMessageInsert = (PFNGLDEBUGMESSAGEINSERTPROC) load("glDebugMessageInsert", userptr); - glGetDebugMessageLog = (PFNGLGETDEBUGMESSAGELOGPROC) load("glGetDebugMessageLog", userptr); - glGetObjectLabel = (PFNGLGETOBJECTLABELPROC) load("glGetObjectLabel", userptr); - glGetObjectPtrLabel = (PFNGLGETOBJECTPTRLABELPROC) load("glGetObjectPtrLabel", userptr); - glGetPointerv = (PFNGLGETPOINTERVPROC) load("glGetPointerv", userptr); - glObjectLabel = (PFNGLOBJECTLABELPROC) load("glObjectLabel", userptr); - glObjectPtrLabel = (PFNGLOBJECTPTRLABELPROC) load("glObjectPtrLabel", userptr); - glPopDebugGroup = (PFNGLPOPDEBUGGROUPPROC) load("glPopDebugGroup", userptr); - glPushDebugGroup = (PFNGLPUSHDEBUGGROUPPROC) load("glPushDebugGroup", userptr); -} - - - -#if defined(GL_ES_VERSION_3_0) || defined(GL_VERSION_3_0) -#define GLAD_GL_IS_SOME_NEW_VERSION 1 -#else -#define GLAD_GL_IS_SOME_NEW_VERSION 0 -#endif - -static int glad_gl_get_extensions( int version, const char **out_exts, unsigned int *out_num_exts_i, char ***out_exts_i) { -#if GLAD_GL_IS_SOME_NEW_VERSION - if(GLAD_VERSION_MAJOR(version) < 3) { -#else - (void) version; - (void) out_num_exts_i; - (void) out_exts_i; -#endif - if (glGetString == NULL) { - return 0; - } - *out_exts = (const char *)glGetString(GL_EXTENSIONS); -#if GLAD_GL_IS_SOME_NEW_VERSION - } else { - unsigned int index = 0; - unsigned int num_exts_i = 0; - char **exts_i = NULL; - if (glGetStringi == NULL || glGetIntegerv == NULL) { - return 0; - } - glGetIntegerv(GL_NUM_EXTENSIONS, (int*) &num_exts_i); - if (num_exts_i > 0) { - exts_i = (char **) malloc(num_exts_i * (sizeof *exts_i)); - } - if (exts_i == NULL) { - return 0; - } - for(index = 0; index < num_exts_i; index++) { - const char *gl_str_tmp = (const char*) glGetStringi(GL_EXTENSIONS, index); - size_t len = strlen(gl_str_tmp) + 1; - - char *local_str = (char*) malloc(len * sizeof(char)); - if(local_str != NULL) { - memcpy(local_str, gl_str_tmp, len * sizeof(char)); - } - - exts_i[index] = local_str; - } - - *out_num_exts_i = num_exts_i; - *out_exts_i = exts_i; - } -#endif - return 1; -} -static void glad_gl_free_extensions(char **exts_i, unsigned int num_exts_i) { - if (exts_i != NULL) { - unsigned int index; - for(index = 0; index < num_exts_i; index++) { - free((void *) (exts_i[index])); - } - free((void *)exts_i); - exts_i = NULL; - } -} -static int glad_gl_has_extension(int version, const char *exts, unsigned int num_exts_i, char **exts_i, const char *ext) { - if(GLAD_VERSION_MAJOR(version) < 3 || !GLAD_GL_IS_SOME_NEW_VERSION) { - const char *extensions; - const char *loc; - const char *terminator; - extensions = exts; - if(extensions == NULL || ext == NULL) { - return 0; - } - while(1) { - loc = strstr(extensions, ext); - if(loc == NULL) { - return 0; - } - terminator = loc + strlen(ext); - if((loc == extensions || *(loc - 1) == ' ') && - (*terminator == ' ' || *terminator == '\0')) { - return 1; - } - extensions = terminator; - } - } else { - unsigned int index; - for(index = 0; index < num_exts_i; index++) { - const char *e = exts_i[index]; - if(strcmp(e, ext) == 0) { - return 1; - } - } - } - return 0; -} - -static GLADapiproc glad_gl_get_proc_from_userptr(const char* name, void *userptr) { - return (GLAD_GNUC_EXTENSION (GLADapiproc (*)(const char *name)) userptr)(name); -} - -static int glad_gl_find_extensions_gl( int version) { - const char *exts = NULL; - unsigned int num_exts_i = 0; - char **exts_i = NULL; - if (!glad_gl_get_extensions(version, &exts, &num_exts_i, &exts_i)) return 0; - - GLAD_GL_ARB_multisample = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_multisample"); - GLAD_GL_ARB_robustness = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_robustness"); - GLAD_GL_KHR_debug = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_KHR_debug"); - - glad_gl_free_extensions(exts_i, num_exts_i); - - return 1; -} - -static int glad_gl_find_core_gl(void) { - int i, major, minor; - const char* version; - const char* prefixes[] = { - "OpenGL ES-CM ", - "OpenGL ES-CL ", - "OpenGL ES ", - NULL - }; - version = (const char*) glGetString(GL_VERSION); - if (!version) return 0; - for (i = 0; prefixes[i]; i++) { - const size_t length = strlen(prefixes[i]); - if (strncmp(version, prefixes[i], length) == 0) { - version += length; - break; - } - } - - GLAD_IMPL_UTIL_SSCANF(version, "%d.%d", &major, &minor); - - GLAD_GL_VERSION_1_0 = (major == 1 && minor >= 0) || major > 1; - GLAD_GL_VERSION_1_1 = (major == 1 && minor >= 1) || major > 1; - GLAD_GL_VERSION_1_2 = (major == 1 && minor >= 2) || major > 1; - GLAD_GL_VERSION_1_3 = (major == 1 && minor >= 3) || major > 1; - GLAD_GL_VERSION_1_4 = (major == 1 && minor >= 4) || major > 1; - GLAD_GL_VERSION_1_5 = (major == 1 && minor >= 5) || major > 1; - GLAD_GL_VERSION_2_0 = (major == 2 && minor >= 0) || major > 2; - GLAD_GL_VERSION_2_1 = (major == 2 && minor >= 1) || major > 2; - GLAD_GL_VERSION_3_0 = (major == 3 && minor >= 0) || major > 3; - GLAD_GL_VERSION_3_1 = (major == 3 && minor >= 1) || major > 3; - GLAD_GL_VERSION_3_2 = (major == 3 && minor >= 2) || major > 3; - GLAD_GL_VERSION_3_3 = (major == 3 && minor >= 3) || major > 3; - - return GLAD_MAKE_VERSION(major, minor); -} - -int gladLoadGLUserPtr( GLADuserptrloadfunc load, void *userptr) { - int version; - - glGetString = (PFNGLGETSTRINGPROC) load("glGetString", userptr); - if(glGetString == NULL) return 0; - if(glGetString(GL_VERSION) == NULL) return 0; - version = glad_gl_find_core_gl(); - - glad_gl_load_GL_VERSION_1_0(load, userptr); - glad_gl_load_GL_VERSION_1_1(load, userptr); - glad_gl_load_GL_VERSION_1_2(load, userptr); - glad_gl_load_GL_VERSION_1_3(load, userptr); - glad_gl_load_GL_VERSION_1_4(load, userptr); - glad_gl_load_GL_VERSION_1_5(load, userptr); - glad_gl_load_GL_VERSION_2_0(load, userptr); - glad_gl_load_GL_VERSION_2_1(load, userptr); - glad_gl_load_GL_VERSION_3_0(load, userptr); - glad_gl_load_GL_VERSION_3_1(load, userptr); - glad_gl_load_GL_VERSION_3_2(load, userptr); - glad_gl_load_GL_VERSION_3_3(load, userptr); - - if (!glad_gl_find_extensions_gl(version)) return 0; - glad_gl_load_GL_ARB_multisample(load, userptr); - glad_gl_load_GL_ARB_robustness(load, userptr); - glad_gl_load_GL_KHR_debug(load, userptr); - - - - return version; -} - - -int gladLoadGL( GLADloadfunc load) { - return gladLoadGLUserPtr( glad_gl_get_proc_from_userptr, GLAD_GNUC_EXTENSION (void*) load); -} - - - - diff --git a/deps/glad_vulkan.c b/deps/glad_vulkan.c deleted file mode 100644 index 5adfbbbe..00000000 --- a/deps/glad_vulkan.c +++ /dev/null @@ -1,593 +0,0 @@ -#include -#include -#include -#include - -#ifndef GLAD_IMPL_UTIL_C_ -#define GLAD_IMPL_UTIL_C_ - -#ifdef _MSC_VER -#define GLAD_IMPL_UTIL_SSCANF sscanf_s -#else -#define GLAD_IMPL_UTIL_SSCANF sscanf -#endif - -#endif /* GLAD_IMPL_UTIL_C_ */ - - -int GLAD_VK_VERSION_1_0 = 0; -int GLAD_VK_VERSION_1_1 = 0; -int GLAD_VK_EXT_debug_report = 0; -int GLAD_VK_KHR_surface = 0; -int GLAD_VK_KHR_swapchain = 0; - - - -PFN_vkAcquireNextImage2KHR glad_vkAcquireNextImage2KHR = NULL; -PFN_vkAcquireNextImageKHR glad_vkAcquireNextImageKHR = NULL; -PFN_vkAllocateCommandBuffers glad_vkAllocateCommandBuffers = NULL; -PFN_vkAllocateDescriptorSets glad_vkAllocateDescriptorSets = NULL; -PFN_vkAllocateMemory glad_vkAllocateMemory = NULL; -PFN_vkBeginCommandBuffer glad_vkBeginCommandBuffer = NULL; -PFN_vkBindBufferMemory glad_vkBindBufferMemory = NULL; -PFN_vkBindBufferMemory2 glad_vkBindBufferMemory2 = NULL; -PFN_vkBindImageMemory glad_vkBindImageMemory = NULL; -PFN_vkBindImageMemory2 glad_vkBindImageMemory2 = NULL; -PFN_vkCmdBeginQuery glad_vkCmdBeginQuery = NULL; -PFN_vkCmdBeginRenderPass glad_vkCmdBeginRenderPass = NULL; -PFN_vkCmdBindDescriptorSets glad_vkCmdBindDescriptorSets = NULL; -PFN_vkCmdBindIndexBuffer glad_vkCmdBindIndexBuffer = NULL; -PFN_vkCmdBindPipeline glad_vkCmdBindPipeline = NULL; -PFN_vkCmdBindVertexBuffers glad_vkCmdBindVertexBuffers = NULL; -PFN_vkCmdBlitImage glad_vkCmdBlitImage = NULL; -PFN_vkCmdClearAttachments glad_vkCmdClearAttachments = NULL; -PFN_vkCmdClearColorImage glad_vkCmdClearColorImage = NULL; -PFN_vkCmdClearDepthStencilImage glad_vkCmdClearDepthStencilImage = NULL; -PFN_vkCmdCopyBuffer glad_vkCmdCopyBuffer = NULL; -PFN_vkCmdCopyBufferToImage glad_vkCmdCopyBufferToImage = NULL; -PFN_vkCmdCopyImage glad_vkCmdCopyImage = NULL; -PFN_vkCmdCopyImageToBuffer glad_vkCmdCopyImageToBuffer = NULL; -PFN_vkCmdCopyQueryPoolResults glad_vkCmdCopyQueryPoolResults = NULL; -PFN_vkCmdDispatch glad_vkCmdDispatch = NULL; -PFN_vkCmdDispatchBase glad_vkCmdDispatchBase = NULL; -PFN_vkCmdDispatchIndirect glad_vkCmdDispatchIndirect = NULL; -PFN_vkCmdDraw glad_vkCmdDraw = NULL; -PFN_vkCmdDrawIndexed glad_vkCmdDrawIndexed = NULL; -PFN_vkCmdDrawIndexedIndirect glad_vkCmdDrawIndexedIndirect = NULL; -PFN_vkCmdDrawIndirect glad_vkCmdDrawIndirect = NULL; -PFN_vkCmdEndQuery glad_vkCmdEndQuery = NULL; -PFN_vkCmdEndRenderPass glad_vkCmdEndRenderPass = NULL; -PFN_vkCmdExecuteCommands glad_vkCmdExecuteCommands = NULL; -PFN_vkCmdFillBuffer glad_vkCmdFillBuffer = NULL; -PFN_vkCmdNextSubpass glad_vkCmdNextSubpass = NULL; -PFN_vkCmdPipelineBarrier glad_vkCmdPipelineBarrier = NULL; -PFN_vkCmdPushConstants glad_vkCmdPushConstants = NULL; -PFN_vkCmdResetEvent glad_vkCmdResetEvent = NULL; -PFN_vkCmdResetQueryPool glad_vkCmdResetQueryPool = NULL; -PFN_vkCmdResolveImage glad_vkCmdResolveImage = NULL; -PFN_vkCmdSetBlendConstants glad_vkCmdSetBlendConstants = NULL; -PFN_vkCmdSetDepthBias glad_vkCmdSetDepthBias = NULL; -PFN_vkCmdSetDepthBounds glad_vkCmdSetDepthBounds = NULL; -PFN_vkCmdSetDeviceMask glad_vkCmdSetDeviceMask = NULL; -PFN_vkCmdSetEvent glad_vkCmdSetEvent = NULL; -PFN_vkCmdSetLineWidth glad_vkCmdSetLineWidth = NULL; -PFN_vkCmdSetScissor glad_vkCmdSetScissor = NULL; -PFN_vkCmdSetStencilCompareMask glad_vkCmdSetStencilCompareMask = NULL; -PFN_vkCmdSetStencilReference glad_vkCmdSetStencilReference = NULL; -PFN_vkCmdSetStencilWriteMask glad_vkCmdSetStencilWriteMask = NULL; -PFN_vkCmdSetViewport glad_vkCmdSetViewport = NULL; -PFN_vkCmdUpdateBuffer glad_vkCmdUpdateBuffer = NULL; -PFN_vkCmdWaitEvents glad_vkCmdWaitEvents = NULL; -PFN_vkCmdWriteTimestamp glad_vkCmdWriteTimestamp = NULL; -PFN_vkCreateBuffer glad_vkCreateBuffer = NULL; -PFN_vkCreateBufferView glad_vkCreateBufferView = NULL; -PFN_vkCreateCommandPool glad_vkCreateCommandPool = NULL; -PFN_vkCreateComputePipelines glad_vkCreateComputePipelines = NULL; -PFN_vkCreateDebugReportCallbackEXT glad_vkCreateDebugReportCallbackEXT = NULL; -PFN_vkCreateDescriptorPool glad_vkCreateDescriptorPool = NULL; -PFN_vkCreateDescriptorSetLayout glad_vkCreateDescriptorSetLayout = NULL; -PFN_vkCreateDescriptorUpdateTemplate glad_vkCreateDescriptorUpdateTemplate = NULL; -PFN_vkCreateDevice glad_vkCreateDevice = NULL; -PFN_vkCreateEvent glad_vkCreateEvent = NULL; -PFN_vkCreateFence glad_vkCreateFence = NULL; -PFN_vkCreateFramebuffer glad_vkCreateFramebuffer = NULL; -PFN_vkCreateGraphicsPipelines glad_vkCreateGraphicsPipelines = NULL; -PFN_vkCreateImage glad_vkCreateImage = NULL; -PFN_vkCreateImageView glad_vkCreateImageView = NULL; -PFN_vkCreateInstance glad_vkCreateInstance = NULL; -PFN_vkCreatePipelineCache glad_vkCreatePipelineCache = NULL; -PFN_vkCreatePipelineLayout glad_vkCreatePipelineLayout = NULL; -PFN_vkCreateQueryPool glad_vkCreateQueryPool = NULL; -PFN_vkCreateRenderPass glad_vkCreateRenderPass = NULL; -PFN_vkCreateSampler glad_vkCreateSampler = NULL; -PFN_vkCreateSamplerYcbcrConversion glad_vkCreateSamplerYcbcrConversion = NULL; -PFN_vkCreateSemaphore glad_vkCreateSemaphore = NULL; -PFN_vkCreateShaderModule glad_vkCreateShaderModule = NULL; -PFN_vkCreateSwapchainKHR glad_vkCreateSwapchainKHR = NULL; -PFN_vkDebugReportMessageEXT glad_vkDebugReportMessageEXT = NULL; -PFN_vkDestroyBuffer glad_vkDestroyBuffer = NULL; -PFN_vkDestroyBufferView glad_vkDestroyBufferView = NULL; -PFN_vkDestroyCommandPool glad_vkDestroyCommandPool = NULL; -PFN_vkDestroyDebugReportCallbackEXT glad_vkDestroyDebugReportCallbackEXT = NULL; -PFN_vkDestroyDescriptorPool glad_vkDestroyDescriptorPool = NULL; -PFN_vkDestroyDescriptorSetLayout glad_vkDestroyDescriptorSetLayout = NULL; -PFN_vkDestroyDescriptorUpdateTemplate glad_vkDestroyDescriptorUpdateTemplate = NULL; -PFN_vkDestroyDevice glad_vkDestroyDevice = NULL; -PFN_vkDestroyEvent glad_vkDestroyEvent = NULL; -PFN_vkDestroyFence glad_vkDestroyFence = NULL; -PFN_vkDestroyFramebuffer glad_vkDestroyFramebuffer = NULL; -PFN_vkDestroyImage glad_vkDestroyImage = NULL; -PFN_vkDestroyImageView glad_vkDestroyImageView = NULL; -PFN_vkDestroyInstance glad_vkDestroyInstance = NULL; -PFN_vkDestroyPipeline glad_vkDestroyPipeline = NULL; -PFN_vkDestroyPipelineCache glad_vkDestroyPipelineCache = NULL; -PFN_vkDestroyPipelineLayout glad_vkDestroyPipelineLayout = NULL; -PFN_vkDestroyQueryPool glad_vkDestroyQueryPool = NULL; -PFN_vkDestroyRenderPass glad_vkDestroyRenderPass = NULL; -PFN_vkDestroySampler glad_vkDestroySampler = NULL; -PFN_vkDestroySamplerYcbcrConversion glad_vkDestroySamplerYcbcrConversion = NULL; -PFN_vkDestroySemaphore glad_vkDestroySemaphore = NULL; -PFN_vkDestroyShaderModule glad_vkDestroyShaderModule = NULL; -PFN_vkDestroySurfaceKHR glad_vkDestroySurfaceKHR = NULL; -PFN_vkDestroySwapchainKHR glad_vkDestroySwapchainKHR = NULL; -PFN_vkDeviceWaitIdle glad_vkDeviceWaitIdle = NULL; -PFN_vkEndCommandBuffer glad_vkEndCommandBuffer = NULL; -PFN_vkEnumerateDeviceExtensionProperties glad_vkEnumerateDeviceExtensionProperties = NULL; -PFN_vkEnumerateDeviceLayerProperties glad_vkEnumerateDeviceLayerProperties = NULL; -PFN_vkEnumerateInstanceExtensionProperties glad_vkEnumerateInstanceExtensionProperties = NULL; -PFN_vkEnumerateInstanceLayerProperties glad_vkEnumerateInstanceLayerProperties = NULL; -PFN_vkEnumerateInstanceVersion glad_vkEnumerateInstanceVersion = NULL; -PFN_vkEnumeratePhysicalDeviceGroups glad_vkEnumeratePhysicalDeviceGroups = NULL; -PFN_vkEnumeratePhysicalDevices glad_vkEnumeratePhysicalDevices = NULL; -PFN_vkFlushMappedMemoryRanges glad_vkFlushMappedMemoryRanges = NULL; -PFN_vkFreeCommandBuffers glad_vkFreeCommandBuffers = NULL; -PFN_vkFreeDescriptorSets glad_vkFreeDescriptorSets = NULL; -PFN_vkFreeMemory glad_vkFreeMemory = NULL; -PFN_vkGetBufferMemoryRequirements glad_vkGetBufferMemoryRequirements = NULL; -PFN_vkGetBufferMemoryRequirements2 glad_vkGetBufferMemoryRequirements2 = NULL; -PFN_vkGetDescriptorSetLayoutSupport glad_vkGetDescriptorSetLayoutSupport = NULL; -PFN_vkGetDeviceGroupPeerMemoryFeatures glad_vkGetDeviceGroupPeerMemoryFeatures = NULL; -PFN_vkGetDeviceGroupPresentCapabilitiesKHR glad_vkGetDeviceGroupPresentCapabilitiesKHR = NULL; -PFN_vkGetDeviceGroupSurfacePresentModesKHR glad_vkGetDeviceGroupSurfacePresentModesKHR = NULL; -PFN_vkGetDeviceMemoryCommitment glad_vkGetDeviceMemoryCommitment = NULL; -PFN_vkGetDeviceProcAddr glad_vkGetDeviceProcAddr = NULL; -PFN_vkGetDeviceQueue glad_vkGetDeviceQueue = NULL; -PFN_vkGetDeviceQueue2 glad_vkGetDeviceQueue2 = NULL; -PFN_vkGetEventStatus glad_vkGetEventStatus = NULL; -PFN_vkGetFenceStatus glad_vkGetFenceStatus = NULL; -PFN_vkGetImageMemoryRequirements glad_vkGetImageMemoryRequirements = NULL; -PFN_vkGetImageMemoryRequirements2 glad_vkGetImageMemoryRequirements2 = NULL; -PFN_vkGetImageSparseMemoryRequirements glad_vkGetImageSparseMemoryRequirements = NULL; -PFN_vkGetImageSparseMemoryRequirements2 glad_vkGetImageSparseMemoryRequirements2 = NULL; -PFN_vkGetImageSubresourceLayout glad_vkGetImageSubresourceLayout = NULL; -PFN_vkGetInstanceProcAddr glad_vkGetInstanceProcAddr = NULL; -PFN_vkGetPhysicalDeviceExternalBufferProperties glad_vkGetPhysicalDeviceExternalBufferProperties = NULL; -PFN_vkGetPhysicalDeviceExternalFenceProperties glad_vkGetPhysicalDeviceExternalFenceProperties = NULL; -PFN_vkGetPhysicalDeviceExternalSemaphoreProperties glad_vkGetPhysicalDeviceExternalSemaphoreProperties = NULL; -PFN_vkGetPhysicalDeviceFeatures glad_vkGetPhysicalDeviceFeatures = NULL; -PFN_vkGetPhysicalDeviceFeatures2 glad_vkGetPhysicalDeviceFeatures2 = NULL; -PFN_vkGetPhysicalDeviceFormatProperties glad_vkGetPhysicalDeviceFormatProperties = NULL; -PFN_vkGetPhysicalDeviceFormatProperties2 glad_vkGetPhysicalDeviceFormatProperties2 = NULL; -PFN_vkGetPhysicalDeviceImageFormatProperties glad_vkGetPhysicalDeviceImageFormatProperties = NULL; -PFN_vkGetPhysicalDeviceImageFormatProperties2 glad_vkGetPhysicalDeviceImageFormatProperties2 = NULL; -PFN_vkGetPhysicalDeviceMemoryProperties glad_vkGetPhysicalDeviceMemoryProperties = NULL; -PFN_vkGetPhysicalDeviceMemoryProperties2 glad_vkGetPhysicalDeviceMemoryProperties2 = NULL; -PFN_vkGetPhysicalDevicePresentRectanglesKHR glad_vkGetPhysicalDevicePresentRectanglesKHR = NULL; -PFN_vkGetPhysicalDeviceProperties glad_vkGetPhysicalDeviceProperties = NULL; -PFN_vkGetPhysicalDeviceProperties2 glad_vkGetPhysicalDeviceProperties2 = NULL; -PFN_vkGetPhysicalDeviceQueueFamilyProperties glad_vkGetPhysicalDeviceQueueFamilyProperties = NULL; -PFN_vkGetPhysicalDeviceQueueFamilyProperties2 glad_vkGetPhysicalDeviceQueueFamilyProperties2 = NULL; -PFN_vkGetPhysicalDeviceSparseImageFormatProperties glad_vkGetPhysicalDeviceSparseImageFormatProperties = NULL; -PFN_vkGetPhysicalDeviceSparseImageFormatProperties2 glad_vkGetPhysicalDeviceSparseImageFormatProperties2 = NULL; -PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR glad_vkGetPhysicalDeviceSurfaceCapabilitiesKHR = NULL; -PFN_vkGetPhysicalDeviceSurfaceFormatsKHR glad_vkGetPhysicalDeviceSurfaceFormatsKHR = NULL; -PFN_vkGetPhysicalDeviceSurfacePresentModesKHR glad_vkGetPhysicalDeviceSurfacePresentModesKHR = NULL; -PFN_vkGetPhysicalDeviceSurfaceSupportKHR glad_vkGetPhysicalDeviceSurfaceSupportKHR = NULL; -PFN_vkGetPipelineCacheData glad_vkGetPipelineCacheData = NULL; -PFN_vkGetQueryPoolResults glad_vkGetQueryPoolResults = NULL; -PFN_vkGetRenderAreaGranularity glad_vkGetRenderAreaGranularity = NULL; -PFN_vkGetSwapchainImagesKHR glad_vkGetSwapchainImagesKHR = NULL; -PFN_vkInvalidateMappedMemoryRanges glad_vkInvalidateMappedMemoryRanges = NULL; -PFN_vkMapMemory glad_vkMapMemory = NULL; -PFN_vkMergePipelineCaches glad_vkMergePipelineCaches = NULL; -PFN_vkQueueBindSparse glad_vkQueueBindSparse = NULL; -PFN_vkQueuePresentKHR glad_vkQueuePresentKHR = NULL; -PFN_vkQueueSubmit glad_vkQueueSubmit = NULL; -PFN_vkQueueWaitIdle glad_vkQueueWaitIdle = NULL; -PFN_vkResetCommandBuffer glad_vkResetCommandBuffer = NULL; -PFN_vkResetCommandPool glad_vkResetCommandPool = NULL; -PFN_vkResetDescriptorPool glad_vkResetDescriptorPool = NULL; -PFN_vkResetEvent glad_vkResetEvent = NULL; -PFN_vkResetFences glad_vkResetFences = NULL; -PFN_vkSetEvent glad_vkSetEvent = NULL; -PFN_vkTrimCommandPool glad_vkTrimCommandPool = NULL; -PFN_vkUnmapMemory glad_vkUnmapMemory = NULL; -PFN_vkUpdateDescriptorSetWithTemplate glad_vkUpdateDescriptorSetWithTemplate = NULL; -PFN_vkUpdateDescriptorSets glad_vkUpdateDescriptorSets = NULL; -PFN_vkWaitForFences glad_vkWaitForFences = NULL; - - -static void glad_vk_load_VK_VERSION_1_0( GLADuserptrloadfunc load, void* userptr) { - if(!GLAD_VK_VERSION_1_0) return; - vkAllocateCommandBuffers = (PFN_vkAllocateCommandBuffers) load("vkAllocateCommandBuffers", userptr); - vkAllocateDescriptorSets = (PFN_vkAllocateDescriptorSets) load("vkAllocateDescriptorSets", userptr); - vkAllocateMemory = (PFN_vkAllocateMemory) load("vkAllocateMemory", userptr); - vkBeginCommandBuffer = (PFN_vkBeginCommandBuffer) load("vkBeginCommandBuffer", userptr); - vkBindBufferMemory = (PFN_vkBindBufferMemory) load("vkBindBufferMemory", userptr); - vkBindImageMemory = (PFN_vkBindImageMemory) load("vkBindImageMemory", userptr); - vkCmdBeginQuery = (PFN_vkCmdBeginQuery) load("vkCmdBeginQuery", userptr); - vkCmdBeginRenderPass = (PFN_vkCmdBeginRenderPass) load("vkCmdBeginRenderPass", userptr); - vkCmdBindDescriptorSets = (PFN_vkCmdBindDescriptorSets) load("vkCmdBindDescriptorSets", userptr); - vkCmdBindIndexBuffer = (PFN_vkCmdBindIndexBuffer) load("vkCmdBindIndexBuffer", userptr); - vkCmdBindPipeline = (PFN_vkCmdBindPipeline) load("vkCmdBindPipeline", userptr); - vkCmdBindVertexBuffers = (PFN_vkCmdBindVertexBuffers) load("vkCmdBindVertexBuffers", userptr); - vkCmdBlitImage = (PFN_vkCmdBlitImage) load("vkCmdBlitImage", userptr); - vkCmdClearAttachments = (PFN_vkCmdClearAttachments) load("vkCmdClearAttachments", userptr); - vkCmdClearColorImage = (PFN_vkCmdClearColorImage) load("vkCmdClearColorImage", userptr); - vkCmdClearDepthStencilImage = (PFN_vkCmdClearDepthStencilImage) load("vkCmdClearDepthStencilImage", userptr); - vkCmdCopyBuffer = (PFN_vkCmdCopyBuffer) load("vkCmdCopyBuffer", userptr); - vkCmdCopyBufferToImage = (PFN_vkCmdCopyBufferToImage) load("vkCmdCopyBufferToImage", userptr); - vkCmdCopyImage = (PFN_vkCmdCopyImage) load("vkCmdCopyImage", userptr); - vkCmdCopyImageToBuffer = (PFN_vkCmdCopyImageToBuffer) load("vkCmdCopyImageToBuffer", userptr); - vkCmdCopyQueryPoolResults = (PFN_vkCmdCopyQueryPoolResults) load("vkCmdCopyQueryPoolResults", userptr); - vkCmdDispatch = (PFN_vkCmdDispatch) load("vkCmdDispatch", userptr); - vkCmdDispatchIndirect = (PFN_vkCmdDispatchIndirect) load("vkCmdDispatchIndirect", userptr); - vkCmdDraw = (PFN_vkCmdDraw) load("vkCmdDraw", userptr); - vkCmdDrawIndexed = (PFN_vkCmdDrawIndexed) load("vkCmdDrawIndexed", userptr); - vkCmdDrawIndexedIndirect = (PFN_vkCmdDrawIndexedIndirect) load("vkCmdDrawIndexedIndirect", userptr); - vkCmdDrawIndirect = (PFN_vkCmdDrawIndirect) load("vkCmdDrawIndirect", userptr); - vkCmdEndQuery = (PFN_vkCmdEndQuery) load("vkCmdEndQuery", userptr); - vkCmdEndRenderPass = (PFN_vkCmdEndRenderPass) load("vkCmdEndRenderPass", userptr); - vkCmdExecuteCommands = (PFN_vkCmdExecuteCommands) load("vkCmdExecuteCommands", userptr); - vkCmdFillBuffer = (PFN_vkCmdFillBuffer) load("vkCmdFillBuffer", userptr); - vkCmdNextSubpass = (PFN_vkCmdNextSubpass) load("vkCmdNextSubpass", userptr); - vkCmdPipelineBarrier = (PFN_vkCmdPipelineBarrier) load("vkCmdPipelineBarrier", userptr); - vkCmdPushConstants = (PFN_vkCmdPushConstants) load("vkCmdPushConstants", userptr); - vkCmdResetEvent = (PFN_vkCmdResetEvent) load("vkCmdResetEvent", userptr); - vkCmdResetQueryPool = (PFN_vkCmdResetQueryPool) load("vkCmdResetQueryPool", userptr); - vkCmdResolveImage = (PFN_vkCmdResolveImage) load("vkCmdResolveImage", userptr); - vkCmdSetBlendConstants = (PFN_vkCmdSetBlendConstants) load("vkCmdSetBlendConstants", userptr); - vkCmdSetDepthBias = (PFN_vkCmdSetDepthBias) load("vkCmdSetDepthBias", userptr); - vkCmdSetDepthBounds = (PFN_vkCmdSetDepthBounds) load("vkCmdSetDepthBounds", userptr); - vkCmdSetEvent = (PFN_vkCmdSetEvent) load("vkCmdSetEvent", userptr); - vkCmdSetLineWidth = (PFN_vkCmdSetLineWidth) load("vkCmdSetLineWidth", userptr); - vkCmdSetScissor = (PFN_vkCmdSetScissor) load("vkCmdSetScissor", userptr); - vkCmdSetStencilCompareMask = (PFN_vkCmdSetStencilCompareMask) load("vkCmdSetStencilCompareMask", userptr); - vkCmdSetStencilReference = (PFN_vkCmdSetStencilReference) load("vkCmdSetStencilReference", userptr); - vkCmdSetStencilWriteMask = (PFN_vkCmdSetStencilWriteMask) load("vkCmdSetStencilWriteMask", userptr); - vkCmdSetViewport = (PFN_vkCmdSetViewport) load("vkCmdSetViewport", userptr); - vkCmdUpdateBuffer = (PFN_vkCmdUpdateBuffer) load("vkCmdUpdateBuffer", userptr); - vkCmdWaitEvents = (PFN_vkCmdWaitEvents) load("vkCmdWaitEvents", userptr); - vkCmdWriteTimestamp = (PFN_vkCmdWriteTimestamp) load("vkCmdWriteTimestamp", userptr); - vkCreateBuffer = (PFN_vkCreateBuffer) load("vkCreateBuffer", userptr); - vkCreateBufferView = (PFN_vkCreateBufferView) load("vkCreateBufferView", userptr); - vkCreateCommandPool = (PFN_vkCreateCommandPool) load("vkCreateCommandPool", userptr); - vkCreateComputePipelines = (PFN_vkCreateComputePipelines) load("vkCreateComputePipelines", userptr); - vkCreateDescriptorPool = (PFN_vkCreateDescriptorPool) load("vkCreateDescriptorPool", userptr); - vkCreateDescriptorSetLayout = (PFN_vkCreateDescriptorSetLayout) load("vkCreateDescriptorSetLayout", userptr); - vkCreateDevice = (PFN_vkCreateDevice) load("vkCreateDevice", userptr); - vkCreateEvent = (PFN_vkCreateEvent) load("vkCreateEvent", userptr); - vkCreateFence = (PFN_vkCreateFence) load("vkCreateFence", userptr); - vkCreateFramebuffer = (PFN_vkCreateFramebuffer) load("vkCreateFramebuffer", userptr); - vkCreateGraphicsPipelines = (PFN_vkCreateGraphicsPipelines) load("vkCreateGraphicsPipelines", userptr); - vkCreateImage = (PFN_vkCreateImage) load("vkCreateImage", userptr); - vkCreateImageView = (PFN_vkCreateImageView) load("vkCreateImageView", userptr); - vkCreateInstance = (PFN_vkCreateInstance) load("vkCreateInstance", userptr); - vkCreatePipelineCache = (PFN_vkCreatePipelineCache) load("vkCreatePipelineCache", userptr); - vkCreatePipelineLayout = (PFN_vkCreatePipelineLayout) load("vkCreatePipelineLayout", userptr); - vkCreateQueryPool = (PFN_vkCreateQueryPool) load("vkCreateQueryPool", userptr); - vkCreateRenderPass = (PFN_vkCreateRenderPass) load("vkCreateRenderPass", userptr); - vkCreateSampler = (PFN_vkCreateSampler) load("vkCreateSampler", userptr); - vkCreateSemaphore = (PFN_vkCreateSemaphore) load("vkCreateSemaphore", userptr); - vkCreateShaderModule = (PFN_vkCreateShaderModule) load("vkCreateShaderModule", userptr); - vkDestroyBuffer = (PFN_vkDestroyBuffer) load("vkDestroyBuffer", userptr); - vkDestroyBufferView = (PFN_vkDestroyBufferView) load("vkDestroyBufferView", userptr); - vkDestroyCommandPool = (PFN_vkDestroyCommandPool) load("vkDestroyCommandPool", userptr); - vkDestroyDescriptorPool = (PFN_vkDestroyDescriptorPool) load("vkDestroyDescriptorPool", userptr); - vkDestroyDescriptorSetLayout = (PFN_vkDestroyDescriptorSetLayout) load("vkDestroyDescriptorSetLayout", userptr); - vkDestroyDevice = (PFN_vkDestroyDevice) load("vkDestroyDevice", userptr); - vkDestroyEvent = (PFN_vkDestroyEvent) load("vkDestroyEvent", userptr); - vkDestroyFence = (PFN_vkDestroyFence) load("vkDestroyFence", userptr); - vkDestroyFramebuffer = (PFN_vkDestroyFramebuffer) load("vkDestroyFramebuffer", userptr); - vkDestroyImage = (PFN_vkDestroyImage) load("vkDestroyImage", userptr); - vkDestroyImageView = (PFN_vkDestroyImageView) load("vkDestroyImageView", userptr); - vkDestroyInstance = (PFN_vkDestroyInstance) load("vkDestroyInstance", userptr); - vkDestroyPipeline = (PFN_vkDestroyPipeline) load("vkDestroyPipeline", userptr); - vkDestroyPipelineCache = (PFN_vkDestroyPipelineCache) load("vkDestroyPipelineCache", userptr); - vkDestroyPipelineLayout = (PFN_vkDestroyPipelineLayout) load("vkDestroyPipelineLayout", userptr); - vkDestroyQueryPool = (PFN_vkDestroyQueryPool) load("vkDestroyQueryPool", userptr); - vkDestroyRenderPass = (PFN_vkDestroyRenderPass) load("vkDestroyRenderPass", userptr); - vkDestroySampler = (PFN_vkDestroySampler) load("vkDestroySampler", userptr); - vkDestroySemaphore = (PFN_vkDestroySemaphore) load("vkDestroySemaphore", userptr); - vkDestroyShaderModule = (PFN_vkDestroyShaderModule) load("vkDestroyShaderModule", userptr); - vkDeviceWaitIdle = (PFN_vkDeviceWaitIdle) load("vkDeviceWaitIdle", userptr); - vkEndCommandBuffer = (PFN_vkEndCommandBuffer) load("vkEndCommandBuffer", userptr); - vkEnumerateDeviceExtensionProperties = (PFN_vkEnumerateDeviceExtensionProperties) load("vkEnumerateDeviceExtensionProperties", userptr); - vkEnumerateDeviceLayerProperties = (PFN_vkEnumerateDeviceLayerProperties) load("vkEnumerateDeviceLayerProperties", userptr); - vkEnumerateInstanceExtensionProperties = (PFN_vkEnumerateInstanceExtensionProperties) load("vkEnumerateInstanceExtensionProperties", userptr); - vkEnumerateInstanceLayerProperties = (PFN_vkEnumerateInstanceLayerProperties) load("vkEnumerateInstanceLayerProperties", userptr); - vkEnumeratePhysicalDevices = (PFN_vkEnumeratePhysicalDevices) load("vkEnumeratePhysicalDevices", userptr); - vkFlushMappedMemoryRanges = (PFN_vkFlushMappedMemoryRanges) load("vkFlushMappedMemoryRanges", userptr); - vkFreeCommandBuffers = (PFN_vkFreeCommandBuffers) load("vkFreeCommandBuffers", userptr); - vkFreeDescriptorSets = (PFN_vkFreeDescriptorSets) load("vkFreeDescriptorSets", userptr); - vkFreeMemory = (PFN_vkFreeMemory) load("vkFreeMemory", userptr); - vkGetBufferMemoryRequirements = (PFN_vkGetBufferMemoryRequirements) load("vkGetBufferMemoryRequirements", userptr); - vkGetDeviceMemoryCommitment = (PFN_vkGetDeviceMemoryCommitment) load("vkGetDeviceMemoryCommitment", userptr); - vkGetDeviceProcAddr = (PFN_vkGetDeviceProcAddr) load("vkGetDeviceProcAddr", userptr); - vkGetDeviceQueue = (PFN_vkGetDeviceQueue) load("vkGetDeviceQueue", userptr); - vkGetEventStatus = (PFN_vkGetEventStatus) load("vkGetEventStatus", userptr); - vkGetFenceStatus = (PFN_vkGetFenceStatus) load("vkGetFenceStatus", userptr); - vkGetImageMemoryRequirements = (PFN_vkGetImageMemoryRequirements) load("vkGetImageMemoryRequirements", userptr); - vkGetImageSparseMemoryRequirements = (PFN_vkGetImageSparseMemoryRequirements) load("vkGetImageSparseMemoryRequirements", userptr); - vkGetImageSubresourceLayout = (PFN_vkGetImageSubresourceLayout) load("vkGetImageSubresourceLayout", userptr); - vkGetInstanceProcAddr = (PFN_vkGetInstanceProcAddr) load("vkGetInstanceProcAddr", userptr); - vkGetPhysicalDeviceFeatures = (PFN_vkGetPhysicalDeviceFeatures) load("vkGetPhysicalDeviceFeatures", userptr); - vkGetPhysicalDeviceFormatProperties = (PFN_vkGetPhysicalDeviceFormatProperties) load("vkGetPhysicalDeviceFormatProperties", userptr); - vkGetPhysicalDeviceImageFormatProperties = (PFN_vkGetPhysicalDeviceImageFormatProperties) load("vkGetPhysicalDeviceImageFormatProperties", userptr); - vkGetPhysicalDeviceMemoryProperties = (PFN_vkGetPhysicalDeviceMemoryProperties) load("vkGetPhysicalDeviceMemoryProperties", userptr); - vkGetPhysicalDeviceProperties = (PFN_vkGetPhysicalDeviceProperties) load("vkGetPhysicalDeviceProperties", userptr); - vkGetPhysicalDeviceQueueFamilyProperties = (PFN_vkGetPhysicalDeviceQueueFamilyProperties) load("vkGetPhysicalDeviceQueueFamilyProperties", userptr); - vkGetPhysicalDeviceSparseImageFormatProperties = (PFN_vkGetPhysicalDeviceSparseImageFormatProperties) load("vkGetPhysicalDeviceSparseImageFormatProperties", userptr); - vkGetPipelineCacheData = (PFN_vkGetPipelineCacheData) load("vkGetPipelineCacheData", userptr); - vkGetQueryPoolResults = (PFN_vkGetQueryPoolResults) load("vkGetQueryPoolResults", userptr); - vkGetRenderAreaGranularity = (PFN_vkGetRenderAreaGranularity) load("vkGetRenderAreaGranularity", userptr); - vkInvalidateMappedMemoryRanges = (PFN_vkInvalidateMappedMemoryRanges) load("vkInvalidateMappedMemoryRanges", userptr); - vkMapMemory = (PFN_vkMapMemory) load("vkMapMemory", userptr); - vkMergePipelineCaches = (PFN_vkMergePipelineCaches) load("vkMergePipelineCaches", userptr); - vkQueueBindSparse = (PFN_vkQueueBindSparse) load("vkQueueBindSparse", userptr); - vkQueueSubmit = (PFN_vkQueueSubmit) load("vkQueueSubmit", userptr); - vkQueueWaitIdle = (PFN_vkQueueWaitIdle) load("vkQueueWaitIdle", userptr); - vkResetCommandBuffer = (PFN_vkResetCommandBuffer) load("vkResetCommandBuffer", userptr); - vkResetCommandPool = (PFN_vkResetCommandPool) load("vkResetCommandPool", userptr); - vkResetDescriptorPool = (PFN_vkResetDescriptorPool) load("vkResetDescriptorPool", userptr); - vkResetEvent = (PFN_vkResetEvent) load("vkResetEvent", userptr); - vkResetFences = (PFN_vkResetFences) load("vkResetFences", userptr); - vkSetEvent = (PFN_vkSetEvent) load("vkSetEvent", userptr); - vkUnmapMemory = (PFN_vkUnmapMemory) load("vkUnmapMemory", userptr); - vkUpdateDescriptorSets = (PFN_vkUpdateDescriptorSets) load("vkUpdateDescriptorSets", userptr); - vkWaitForFences = (PFN_vkWaitForFences) load("vkWaitForFences", userptr); -} -static void glad_vk_load_VK_VERSION_1_1( GLADuserptrloadfunc load, void* userptr) { - if(!GLAD_VK_VERSION_1_1) return; - vkBindBufferMemory2 = (PFN_vkBindBufferMemory2) load("vkBindBufferMemory2", userptr); - vkBindImageMemory2 = (PFN_vkBindImageMemory2) load("vkBindImageMemory2", userptr); - vkCmdDispatchBase = (PFN_vkCmdDispatchBase) load("vkCmdDispatchBase", userptr); - vkCmdSetDeviceMask = (PFN_vkCmdSetDeviceMask) load("vkCmdSetDeviceMask", userptr); - vkCreateDescriptorUpdateTemplate = (PFN_vkCreateDescriptorUpdateTemplate) load("vkCreateDescriptorUpdateTemplate", userptr); - vkCreateSamplerYcbcrConversion = (PFN_vkCreateSamplerYcbcrConversion) load("vkCreateSamplerYcbcrConversion", userptr); - vkDestroyDescriptorUpdateTemplate = (PFN_vkDestroyDescriptorUpdateTemplate) load("vkDestroyDescriptorUpdateTemplate", userptr); - vkDestroySamplerYcbcrConversion = (PFN_vkDestroySamplerYcbcrConversion) load("vkDestroySamplerYcbcrConversion", userptr); - vkEnumerateInstanceVersion = (PFN_vkEnumerateInstanceVersion) load("vkEnumerateInstanceVersion", userptr); - vkEnumeratePhysicalDeviceGroups = (PFN_vkEnumeratePhysicalDeviceGroups) load("vkEnumeratePhysicalDeviceGroups", userptr); - vkGetBufferMemoryRequirements2 = (PFN_vkGetBufferMemoryRequirements2) load("vkGetBufferMemoryRequirements2", userptr); - vkGetDescriptorSetLayoutSupport = (PFN_vkGetDescriptorSetLayoutSupport) load("vkGetDescriptorSetLayoutSupport", userptr); - vkGetDeviceGroupPeerMemoryFeatures = (PFN_vkGetDeviceGroupPeerMemoryFeatures) load("vkGetDeviceGroupPeerMemoryFeatures", userptr); - vkGetDeviceQueue2 = (PFN_vkGetDeviceQueue2) load("vkGetDeviceQueue2", userptr); - vkGetImageMemoryRequirements2 = (PFN_vkGetImageMemoryRequirements2) load("vkGetImageMemoryRequirements2", userptr); - vkGetImageSparseMemoryRequirements2 = (PFN_vkGetImageSparseMemoryRequirements2) load("vkGetImageSparseMemoryRequirements2", userptr); - vkGetPhysicalDeviceExternalBufferProperties = (PFN_vkGetPhysicalDeviceExternalBufferProperties) load("vkGetPhysicalDeviceExternalBufferProperties", userptr); - vkGetPhysicalDeviceExternalFenceProperties = (PFN_vkGetPhysicalDeviceExternalFenceProperties) load("vkGetPhysicalDeviceExternalFenceProperties", userptr); - vkGetPhysicalDeviceExternalSemaphoreProperties = (PFN_vkGetPhysicalDeviceExternalSemaphoreProperties) load("vkGetPhysicalDeviceExternalSemaphoreProperties", userptr); - vkGetPhysicalDeviceFeatures2 = (PFN_vkGetPhysicalDeviceFeatures2) load("vkGetPhysicalDeviceFeatures2", userptr); - vkGetPhysicalDeviceFormatProperties2 = (PFN_vkGetPhysicalDeviceFormatProperties2) load("vkGetPhysicalDeviceFormatProperties2", userptr); - vkGetPhysicalDeviceImageFormatProperties2 = (PFN_vkGetPhysicalDeviceImageFormatProperties2) load("vkGetPhysicalDeviceImageFormatProperties2", userptr); - vkGetPhysicalDeviceMemoryProperties2 = (PFN_vkGetPhysicalDeviceMemoryProperties2) load("vkGetPhysicalDeviceMemoryProperties2", userptr); - vkGetPhysicalDeviceProperties2 = (PFN_vkGetPhysicalDeviceProperties2) load("vkGetPhysicalDeviceProperties2", userptr); - vkGetPhysicalDeviceQueueFamilyProperties2 = (PFN_vkGetPhysicalDeviceQueueFamilyProperties2) load("vkGetPhysicalDeviceQueueFamilyProperties2", userptr); - vkGetPhysicalDeviceSparseImageFormatProperties2 = (PFN_vkGetPhysicalDeviceSparseImageFormatProperties2) load("vkGetPhysicalDeviceSparseImageFormatProperties2", userptr); - vkTrimCommandPool = (PFN_vkTrimCommandPool) load("vkTrimCommandPool", userptr); - vkUpdateDescriptorSetWithTemplate = (PFN_vkUpdateDescriptorSetWithTemplate) load("vkUpdateDescriptorSetWithTemplate", userptr); -} -static void glad_vk_load_VK_EXT_debug_report( GLADuserptrloadfunc load, void* userptr) { - if(!GLAD_VK_EXT_debug_report) return; - vkCreateDebugReportCallbackEXT = (PFN_vkCreateDebugReportCallbackEXT) load("vkCreateDebugReportCallbackEXT", userptr); - vkDebugReportMessageEXT = (PFN_vkDebugReportMessageEXT) load("vkDebugReportMessageEXT", userptr); - vkDestroyDebugReportCallbackEXT = (PFN_vkDestroyDebugReportCallbackEXT) load("vkDestroyDebugReportCallbackEXT", userptr); -} -static void glad_vk_load_VK_KHR_surface( GLADuserptrloadfunc load, void* userptr) { - if(!GLAD_VK_KHR_surface) return; - vkDestroySurfaceKHR = (PFN_vkDestroySurfaceKHR) load("vkDestroySurfaceKHR", userptr); - vkGetPhysicalDeviceSurfaceCapabilitiesKHR = (PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR) load("vkGetPhysicalDeviceSurfaceCapabilitiesKHR", userptr); - vkGetPhysicalDeviceSurfaceFormatsKHR = (PFN_vkGetPhysicalDeviceSurfaceFormatsKHR) load("vkGetPhysicalDeviceSurfaceFormatsKHR", userptr); - vkGetPhysicalDeviceSurfacePresentModesKHR = (PFN_vkGetPhysicalDeviceSurfacePresentModesKHR) load("vkGetPhysicalDeviceSurfacePresentModesKHR", userptr); - vkGetPhysicalDeviceSurfaceSupportKHR = (PFN_vkGetPhysicalDeviceSurfaceSupportKHR) load("vkGetPhysicalDeviceSurfaceSupportKHR", userptr); -} -static void glad_vk_load_VK_KHR_swapchain( GLADuserptrloadfunc load, void* userptr) { - if(!GLAD_VK_KHR_swapchain) return; - vkAcquireNextImage2KHR = (PFN_vkAcquireNextImage2KHR) load("vkAcquireNextImage2KHR", userptr); - vkAcquireNextImageKHR = (PFN_vkAcquireNextImageKHR) load("vkAcquireNextImageKHR", userptr); - vkCreateSwapchainKHR = (PFN_vkCreateSwapchainKHR) load("vkCreateSwapchainKHR", userptr); - vkDestroySwapchainKHR = (PFN_vkDestroySwapchainKHR) load("vkDestroySwapchainKHR", userptr); - vkGetDeviceGroupPresentCapabilitiesKHR = (PFN_vkGetDeviceGroupPresentCapabilitiesKHR) load("vkGetDeviceGroupPresentCapabilitiesKHR", userptr); - vkGetDeviceGroupSurfacePresentModesKHR = (PFN_vkGetDeviceGroupSurfacePresentModesKHR) load("vkGetDeviceGroupSurfacePresentModesKHR", userptr); - vkGetPhysicalDevicePresentRectanglesKHR = (PFN_vkGetPhysicalDevicePresentRectanglesKHR) load("vkGetPhysicalDevicePresentRectanglesKHR", userptr); - vkGetSwapchainImagesKHR = (PFN_vkGetSwapchainImagesKHR) load("vkGetSwapchainImagesKHR", userptr); - vkQueuePresentKHR = (PFN_vkQueuePresentKHR) load("vkQueuePresentKHR", userptr); -} - - - -static int glad_vk_get_extensions( VkPhysicalDevice physical_device, uint32_t *out_extension_count, char ***out_extensions) { - uint32_t i; - uint32_t instance_extension_count = 0; - uint32_t device_extension_count = 0; - uint32_t max_extension_count; - uint32_t total_extension_count; - char **extensions; - VkExtensionProperties *ext_properties; - VkResult result; - - if (vkEnumerateInstanceExtensionProperties == NULL || (physical_device != NULL && vkEnumerateDeviceExtensionProperties == NULL)) { - return 0; - } - - result = vkEnumerateInstanceExtensionProperties(NULL, &instance_extension_count, NULL); - if (result != VK_SUCCESS) { - return 0; - } - - if (physical_device != NULL) { - result = vkEnumerateDeviceExtensionProperties(physical_device, NULL, &device_extension_count, NULL); - if (result != VK_SUCCESS) { - return 0; - } - } - - total_extension_count = instance_extension_count + device_extension_count; - max_extension_count = instance_extension_count > device_extension_count - ? instance_extension_count : device_extension_count; - - ext_properties = (VkExtensionProperties*) malloc(max_extension_count * sizeof(VkExtensionProperties)); - if (ext_properties == NULL) { - return 0; - } - - result = vkEnumerateInstanceExtensionProperties(NULL, &instance_extension_count, ext_properties); - if (result != VK_SUCCESS) { - free((void*) ext_properties); - return 0; - } - - extensions = (char**) calloc(total_extension_count, sizeof(char*)); - if (extensions == NULL) { - free((void*) ext_properties); - return 0; - } - - for (i = 0; i < instance_extension_count; ++i) { - VkExtensionProperties ext = ext_properties[i]; - - size_t extension_name_length = strlen(ext.extensionName) + 1; - extensions[i] = (char*) malloc(extension_name_length * sizeof(char)); - memcpy(extensions[i], ext.extensionName, extension_name_length * sizeof(char)); - } - - if (physical_device != NULL) { - result = vkEnumerateDeviceExtensionProperties(physical_device, NULL, &device_extension_count, ext_properties); - if (result != VK_SUCCESS) { - for (i = 0; i < instance_extension_count; ++i) { - free((void*) extensions[i]); - } - free(extensions); - return 0; - } - - for (i = 0; i < device_extension_count; ++i) { - VkExtensionProperties ext = ext_properties[i]; - - size_t extension_name_length = strlen(ext.extensionName) + 1; - extensions[instance_extension_count + i] = (char*) malloc(extension_name_length * sizeof(char)); - memcpy(extensions[instance_extension_count + i], ext.extensionName, extension_name_length * sizeof(char)); - } - } - - free((void*) ext_properties); - - *out_extension_count = total_extension_count; - *out_extensions = extensions; - - return 1; -} - -static void glad_vk_free_extensions(uint32_t extension_count, char **extensions) { - uint32_t i; - - for(i = 0; i < extension_count ; ++i) { - free((void*) (extensions[i])); - } - - free((void*) extensions); -} - -static int glad_vk_has_extension(const char *name, uint32_t extension_count, char **extensions) { - uint32_t i; - - for (i = 0; i < extension_count; ++i) { - if(strcmp(name, extensions[i]) == 0) { - return 1; - } - } - - return 0; -} - -static GLADapiproc glad_vk_get_proc_from_userptr(const char* name, void *userptr) { - return (GLAD_GNUC_EXTENSION (GLADapiproc (*)(const char *name)) userptr)(name); -} - -static int glad_vk_find_extensions_vulkan( VkPhysicalDevice physical_device) { - uint32_t extension_count = 0; - char **extensions = NULL; - if (!glad_vk_get_extensions(physical_device, &extension_count, &extensions)) return 0; - - GLAD_VK_EXT_debug_report = glad_vk_has_extension("VK_EXT_debug_report", extension_count, extensions); - GLAD_VK_KHR_surface = glad_vk_has_extension("VK_KHR_surface", extension_count, extensions); - GLAD_VK_KHR_swapchain = glad_vk_has_extension("VK_KHR_swapchain", extension_count, extensions); - - glad_vk_free_extensions(extension_count, extensions); - - return 1; -} - -static int glad_vk_find_core_vulkan( VkPhysicalDevice physical_device) { - int major = 1; - int minor = 0; - -#ifdef VK_VERSION_1_1 - if (vkEnumerateInstanceVersion != NULL) { - uint32_t version; - VkResult result; - - result = vkEnumerateInstanceVersion(&version); - if (result == VK_SUCCESS) { - major = (int) VK_VERSION_MAJOR(version); - minor = (int) VK_VERSION_MINOR(version); - } - } -#endif - - if (physical_device != NULL && vkGetPhysicalDeviceProperties != NULL) { - VkPhysicalDeviceProperties properties; - vkGetPhysicalDeviceProperties(physical_device, &properties); - - major = (int) VK_VERSION_MAJOR(properties.apiVersion); - minor = (int) VK_VERSION_MINOR(properties.apiVersion); - } - - GLAD_VK_VERSION_1_0 = (major == 1 && minor >= 0) || major > 1; - GLAD_VK_VERSION_1_1 = (major == 1 && minor >= 1) || major > 1; - - return GLAD_MAKE_VERSION(major, minor); -} - -int gladLoadVulkanUserPtr( VkPhysicalDevice physical_device, GLADuserptrloadfunc load, void *userptr) { - int version; - -#ifdef VK_VERSION_1_1 - vkEnumerateInstanceVersion = (PFN_vkEnumerateInstanceVersion) load("vkEnumerateInstanceVersion", userptr); -#endif - version = glad_vk_find_core_vulkan( physical_device); - if (!version) { - return 0; - } - - glad_vk_load_VK_VERSION_1_0(load, userptr); - glad_vk_load_VK_VERSION_1_1(load, userptr); - - if (!glad_vk_find_extensions_vulkan( physical_device)) return 0; - glad_vk_load_VK_EXT_debug_report(load, userptr); - glad_vk_load_VK_KHR_surface(load, userptr); - glad_vk_load_VK_KHR_swapchain(load, userptr); - - - return version; -} - - -int gladLoadVulkan( VkPhysicalDevice physical_device, GLADloadfunc load) { - return gladLoadVulkanUserPtr( physical_device, glad_vk_get_proc_from_userptr, GLAD_GNUC_EXTENSION (void*) load); -} - - - - diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index c93dbe5f..547f1412 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -18,8 +18,7 @@ elseif (APPLE) set(ICON glfw.icns) endif() -set(GLAD_GL "${GLFW_SOURCE_DIR}/deps/glad/gl.h" - "${GLFW_SOURCE_DIR}/deps/glad_gl.c") +set(GLAD_GL "${GLFW_SOURCE_DIR}/deps/glad/gl.h") set(GETOPT "${GLFW_SOURCE_DIR}/deps/getopt.h" "${GLFW_SOURCE_DIR}/deps/getopt.c") set(TINYCTHREAD "${GLFW_SOURCE_DIR}/deps/tinycthread.h" diff --git a/examples/boing.c b/examples/boing.c index ca389086..ec118a3a 100644 --- a/examples/boing.c +++ b/examples/boing.c @@ -36,6 +36,7 @@ #include #include +#define GLAD_GL_IMPLEMENTATION #include #define GLFW_INCLUDE_NONE #include diff --git a/examples/gears.c b/examples/gears.c index 292f44b5..3d63013d 100644 --- a/examples/gears.c +++ b/examples/gears.c @@ -31,6 +31,7 @@ #include #include +#define GLAD_GL_IMPLEMENTATION #include #define GLFW_INCLUDE_NONE #include diff --git a/examples/heightmap.c b/examples/heightmap.c index 988dd0b8..ad5d47c1 100644 --- a/examples/heightmap.c +++ b/examples/heightmap.c @@ -29,6 +29,7 @@ #include #include +#define GLAD_GL_IMPLEMENTATION #include #define GLFW_INCLUDE_NONE #include diff --git a/examples/offscreen.c b/examples/offscreen.c index 16b8f3c9..b7cd2fd7 100644 --- a/examples/offscreen.c +++ b/examples/offscreen.c @@ -23,6 +23,7 @@ // //======================================================================== +#define GLAD_GL_IMPLEMENTATION #include #define GLFW_INCLUDE_NONE #include diff --git a/examples/particles.c b/examples/particles.c index 9556ccac..baafe826 100644 --- a/examples/particles.c +++ b/examples/particles.c @@ -39,6 +39,7 @@ #include #include +#define GLAD_GL_IMPLEMENTATION #include #define GLFW_INCLUDE_NONE #include diff --git a/examples/sharing.c b/examples/sharing.c index 4a1a2323..d840c58c 100644 --- a/examples/sharing.c +++ b/examples/sharing.c @@ -23,6 +23,7 @@ // //======================================================================== +#define GLAD_GL_IMPLEMENTATION #include #define GLFW_INCLUDE_NONE #include diff --git a/examples/splitview.c b/examples/splitview.c index 58441dbb..4f0a8a98 100644 --- a/examples/splitview.c +++ b/examples/splitview.c @@ -10,6 +10,7 @@ // because I am not a friend of orthogonal projections) //======================================================================== +#define GLAD_GL_IMPLEMENTATION #include #define GLFW_INCLUDE_NONE #include diff --git a/examples/triangle-opengl.c b/examples/triangle-opengl.c index 00bc37dd..ff9e7d3b 100644 --- a/examples/triangle-opengl.c +++ b/examples/triangle-opengl.c @@ -24,6 +24,7 @@ //======================================================================== //! [code] +#define GLAD_GL_IMPLEMENTATION #include #define GLFW_INCLUDE_NONE #include diff --git a/examples/wave.c b/examples/wave.c index 7acb8b92..d7ead493 100644 --- a/examples/wave.c +++ b/examples/wave.c @@ -17,6 +17,7 @@ #include #include +#define GLAD_GL_IMPLEMENTATION #include #define GLFW_INCLUDE_NONE #include diff --git a/examples/windows.c b/examples/windows.c index 94f3ccbc..598e5218 100644 --- a/examples/windows.c +++ b/examples/windows.c @@ -23,6 +23,7 @@ // //======================================================================== +#define GLAD_GL_IMPLEMENTATION #include #define GLFW_INCLUDE_NONE #include diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 0cc9db44..f81cfeb9 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -12,10 +12,8 @@ if (MSVC OR CMAKE_C_SIMULATE_ID STREQUAL "MSVC") add_definitions(-D_CRT_SECURE_NO_WARNINGS) endif() -set(GLAD_GL "${GLFW_SOURCE_DIR}/deps/glad/gl.h" - "${GLFW_SOURCE_DIR}/deps/glad_gl.c") -set(GLAD_VULKAN "${GLFW_SOURCE_DIR}/deps/glad/vulkan.h" - "${GLFW_SOURCE_DIR}/deps/glad_vulkan.c") +set(GLAD_GL "${GLFW_SOURCE_DIR}/deps/glad/gl.h") +set(GLAD_VULKAN "${GLFW_SOURCE_DIR}/deps/glad/vulkan.h") set(GETOPT "${GLFW_SOURCE_DIR}/deps/getopt.h" "${GLFW_SOURCE_DIR}/deps/getopt.c") set(TINYCTHREAD "${GLFW_SOURCE_DIR}/deps/tinycthread.h" diff --git a/tests/allocator.c b/tests/allocator.c index ea9b6409..3fb004d2 100644 --- a/tests/allocator.c +++ b/tests/allocator.c @@ -23,6 +23,7 @@ // //======================================================================== +#define GLAD_GL_IMPLEMENTATION #include #define GLFW_INCLUDE_NONE #include diff --git a/tests/clipboard.c b/tests/clipboard.c index 41454a3c..eaad516d 100644 --- a/tests/clipboard.c +++ b/tests/clipboard.c @@ -27,6 +27,7 @@ // //======================================================================== +#define GLAD_GL_IMPLEMENTATION #include #define GLFW_INCLUDE_NONE #include diff --git a/tests/cursor.c b/tests/cursor.c index f72c0f91..9be42748 100644 --- a/tests/cursor.c +++ b/tests/cursor.c @@ -30,6 +30,7 @@ // //======================================================================== +#define GLAD_GL_IMPLEMENTATION #include #define GLFW_INCLUDE_NONE #include diff --git a/tests/empty.c b/tests/empty.c index c3877a71..72caccbd 100644 --- a/tests/empty.c +++ b/tests/empty.c @@ -29,6 +29,7 @@ #include "tinycthread.h" +#define GLAD_GL_IMPLEMENTATION #include #define GLFW_INCLUDE_NONE #include diff --git a/tests/events.c b/tests/events.c index 86a63df2..a9d4023d 100644 --- a/tests/events.c +++ b/tests/events.c @@ -31,6 +31,7 @@ // //======================================================================== +#define GLAD_GL_IMPLEMENTATION #include #define GLFW_INCLUDE_NONE #include diff --git a/tests/gamma.c b/tests/gamma.c index d1961609..734955cd 100644 --- a/tests/gamma.c +++ b/tests/gamma.c @@ -28,6 +28,7 @@ // //======================================================================== +#define GLAD_GL_IMPLEMENTATION #include #define GLFW_INCLUDE_NONE #include diff --git a/tests/glfwinfo.c b/tests/glfwinfo.c index 4b61a776..87ed385f 100644 --- a/tests/glfwinfo.c +++ b/tests/glfwinfo.c @@ -23,7 +23,9 @@ // //======================================================================== +#define GLAD_GL_IMPLEMENTATION #include +#define GLAD_VULKAN_IMPLEMENTATION #include #define GLFW_INCLUDE_NONE #include @@ -323,11 +325,6 @@ static void print_version(void) printf("GLFW library version string: \"%s\"\n", glfwGetVersionString()); } -static GLADapiproc glad_vulkan_callback(const char* name, void* user) -{ - return glfwGetInstanceProcAddress((VkInstance) user, name); -} - int main(int argc, char** argv) { int ch; @@ -866,7 +863,7 @@ int main(int argc, char** argv) if (glfwVulkanSupported()) { - gladLoadVulkanUserPtr(NULL, glad_vulkan_callback, NULL); + gladLoadVulkanUserPtr(NULL, (GLADuserptrloadfunc) glfwGetInstanceProcAddress, NULL); uint32_t loader_version = VK_API_VERSION_1_0; @@ -923,7 +920,7 @@ int main(int argc, char** argv) exit(EXIT_FAILURE); } - gladLoadVulkanUserPtr(NULL, glad_vulkan_callback, instance); + gladLoadVulkanUserPtr(NULL, (GLADuserptrloadfunc) glfwGetInstanceProcAddress, instance); if (re) { diff --git a/tests/icon.c b/tests/icon.c index aa7ee181..d5baf0a0 100644 --- a/tests/icon.c +++ b/tests/icon.c @@ -27,6 +27,7 @@ // //======================================================================== +#define GLAD_GL_IMPLEMENTATION #include #define GLFW_INCLUDE_NONE #include diff --git a/tests/iconify.c b/tests/iconify.c index ff446d2d..e5a428a0 100644 --- a/tests/iconify.c +++ b/tests/iconify.c @@ -28,6 +28,7 @@ // //======================================================================== +#define GLAD_GL_IMPLEMENTATION #include #define GLFW_INCLUDE_NONE #include diff --git a/tests/inputlag.c b/tests/inputlag.c index 2ed4c49f..12e693f0 100644 --- a/tests/inputlag.c +++ b/tests/inputlag.c @@ -28,6 +28,7 @@ // //======================================================================== +#define GLAD_GL_IMPLEMENTATION #include #define GLFW_INCLUDE_NONE #include diff --git a/tests/joysticks.c b/tests/joysticks.c index d4aef36f..df000210 100644 --- a/tests/joysticks.c +++ b/tests/joysticks.c @@ -28,6 +28,7 @@ // //======================================================================== +#define GLAD_GL_IMPLEMENTATION #include #define GLFW_INCLUDE_NONE #include diff --git a/tests/monitors.c b/tests/monitors.c index c66950bf..1043e66c 100644 --- a/tests/monitors.c +++ b/tests/monitors.c @@ -28,6 +28,7 @@ // //======================================================================== +#define GLAD_GL_IMPLEMENTATION #include #define GLFW_INCLUDE_NONE #include diff --git a/tests/msaa.c b/tests/msaa.c index 33e2ccc3..10bfa3c6 100644 --- a/tests/msaa.c +++ b/tests/msaa.c @@ -29,6 +29,7 @@ // //======================================================================== +#define GLAD_GL_IMPLEMENTATION #include #define GLFW_INCLUDE_NONE #include diff --git a/tests/reopen.c b/tests/reopen.c index 10d22b28..b458755e 100644 --- a/tests/reopen.c +++ b/tests/reopen.c @@ -33,6 +33,7 @@ // //======================================================================== +#define GLAD_GL_IMPLEMENTATION #include #define GLFW_INCLUDE_NONE #include diff --git a/tests/tearing.c b/tests/tearing.c index 17601219..5c7893c2 100644 --- a/tests/tearing.c +++ b/tests/tearing.c @@ -28,6 +28,7 @@ // //======================================================================== +#define GLAD_GL_IMPLEMENTATION #include #define GLFW_INCLUDE_NONE #include diff --git a/tests/threads.c b/tests/threads.c index 98294933..ec13b001 100644 --- a/tests/threads.c +++ b/tests/threads.c @@ -30,6 +30,7 @@ #include "tinycthread.h" +#define GLAD_GL_IMPLEMENTATION #include #define GLFW_INCLUDE_NONE #include diff --git a/tests/timeout.c b/tests/timeout.c index bda2560c..c2737462 100644 --- a/tests/timeout.c +++ b/tests/timeout.c @@ -27,6 +27,7 @@ // //======================================================================== +#define GLAD_GL_IMPLEMENTATION #include #define GLFW_INCLUDE_NONE #include diff --git a/tests/title.c b/tests/title.c index a5bad342..08a24e74 100644 --- a/tests/title.c +++ b/tests/title.c @@ -27,6 +27,7 @@ // //======================================================================== +#define GLAD_GL_IMPLEMENTATION #include #define GLFW_INCLUDE_NONE #include diff --git a/tests/triangle-vulkan.c b/tests/triangle-vulkan.c index 7f783694..fb5db3e2 100644 --- a/tests/triangle-vulkan.c +++ b/tests/triangle-vulkan.c @@ -41,6 +41,7 @@ #include #endif +#define GLAD_VULKAN_IMPLEMENTATION #include #define GLFW_INCLUDE_NONE #include @@ -65,11 +66,6 @@ exit(1); \ } while (0) -static GLADapiproc glad_vulkan_callback(const char* name, void* user) -{ - return glfwGetInstanceProcAddress((VkInstance) user, name); -} - static const uint32_t fragShaderCode[] = { 0x07230203,0x00010000,0x00080007,0x00000014,0x00000000,0x00020011,0x00000001,0x0006000b, 0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001, @@ -1251,7 +1247,7 @@ static void demo_prepare_pipeline(struct demo *demo) { VkPipelineDepthStencilStateCreateInfo ds; VkPipelineViewportStateCreateInfo vp; VkPipelineMultisampleStateCreateInfo ms; - VkDynamicState dynamicStateEnables[VK_DYNAMIC_STATE_RANGE_SIZE]; + VkDynamicState dynamicStateEnables[(VK_DYNAMIC_STATE_STENCIL_REFERENCE - VK_DYNAMIC_STATE_VIEWPORT + 1)]; VkPipelineDynamicStateCreateInfo dynamicState; VkResult U_ASSERT_ONLY err; @@ -1715,7 +1711,7 @@ static void demo_init_vk(struct demo *demo) { "vkCreateInstance Failure"); } - gladLoadVulkanUserPtr(NULL, glad_vulkan_callback, demo->inst); + gladLoadVulkanUserPtr(NULL, (GLADuserptrloadfunc) glfwGetInstanceProcAddress, demo->inst); /* Make initial call to query gpu_count, then second call for gpu info*/ err = vkEnumeratePhysicalDevices(demo->inst, &gpu_count, NULL); @@ -1738,7 +1734,7 @@ static void demo_init_vk(struct demo *demo) { "vkEnumeratePhysicalDevices Failure"); } - gladLoadVulkanUserPtr(demo->gpu, glad_vulkan_callback, demo->inst); + gladLoadVulkanUserPtr(demo->gpu, (GLADuserptrloadfunc) glfwGetInstanceProcAddress, demo->inst); /* Look for device extensions */ uint32_t device_extension_count = 0; @@ -1966,7 +1962,7 @@ static void demo_init_connection(struct demo *demo) { exit(1); } - gladLoadVulkanUserPtr(NULL, glad_vulkan_callback, NULL); + gladLoadVulkanUserPtr(NULL, (GLADuserptrloadfunc) glfwGetInstanceProcAddress, NULL); } static void demo_init(struct demo *demo, const int argc, const char *argv[]) diff --git a/tests/window.c b/tests/window.c index f427fcad..075d3887 100644 --- a/tests/window.c +++ b/tests/window.c @@ -23,6 +23,7 @@ // //======================================================================== +#define GLAD_GL_IMPLEMENTATION #include #define GLFW_INCLUDE_NONE #include From d7b7c3b12a106333d73567bacb4c9057e8d3cc88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 25 Aug 2021 11:40:03 +0200 Subject: [PATCH 012/208] Raise maximum known CMake version to 3.20 This has seemed to work well on all platforms for a while. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6176e16a..bab7f7ad 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.1...3.17 FATAL_ERROR) +cmake_minimum_required(VERSION 3.1...3.20 FATAL_ERROR) project(GLFW VERSION 3.4.0 LANGUAGES C) From daed5edd6ea164b2ed0e9de91f1c9104fd75cd0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 25 Aug 2021 12:07:01 +0200 Subject: [PATCH 013/208] Simplify CMake if-statement variable references Variables in CMake if-statements (and only in if-statements) do not need to be explicitly dereferenced; a thing I did not always know. --- CMake/GenerateMappings.cmake | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CMake/GenerateMappings.cmake b/CMake/GenerateMappings.cmake index 5e5aad3d..e29bb4a8 100644 --- a/CMake/GenerateMappings.cmake +++ b/CMake/GenerateMappings.cmake @@ -23,18 +23,18 @@ endif() file(STRINGS "${source_path}" lines) foreach(line ${lines}) - if ("${line}" MATCHES "^[0-9a-fA-F].*$") - if ("${line}" MATCHES "platform:Windows") + if (line MATCHES "^[0-9a-fA-F].*$") + if (line MATCHES "platform:Windows") if (GLFW_WIN32_MAPPINGS) set(GLFW_WIN32_MAPPINGS "${GLFW_WIN32_MAPPINGS}\n") endif() set(GLFW_WIN32_MAPPINGS "${GLFW_WIN32_MAPPINGS}\"${line}\",") - elseif ("${line}" MATCHES "platform:Mac OS X") + elseif (line MATCHES "platform:Mac OS X") if (GLFW_COCOA_MAPPINGS) set(GLFW_COCOA_MAPPINGS "${GLFW_COCOA_MAPPINGS}\n") endif() set(GLFW_COCOA_MAPPINGS "${GLFW_COCOA_MAPPINGS}\"${line}\",") - elseif ("${line}" MATCHES "platform:Linux") + elseif (line MATCHES "platform:Linux") if (GLFW_LINUX_MAPPINGS) set(GLFW_LINUX_MAPPINGS "${GLFW_LINUX_MAPPINGS}\n") endif() From 7c25dff002b780bcd2f95c072f8a3f79327430be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 25 Aug 2021 12:09:21 +0200 Subject: [PATCH 014/208] Remove truism from end of gamepad mapping regexp The rest of the line is guaranteed to either contain or not contain characters. --- CMake/GenerateMappings.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMake/GenerateMappings.cmake b/CMake/GenerateMappings.cmake index e29bb4a8..47e63741 100644 --- a/CMake/GenerateMappings.cmake +++ b/CMake/GenerateMappings.cmake @@ -23,7 +23,7 @@ endif() file(STRINGS "${source_path}" lines) foreach(line ${lines}) - if (line MATCHES "^[0-9a-fA-F].*$") + if (line MATCHES "^[0-9a-fA-F]") if (line MATCHES "platform:Windows") if (GLFW_WIN32_MAPPINGS) set(GLFW_WIN32_MAPPINGS "${GLFW_WIN32_MAPPINGS}\n") From 4f077c41335f444c6d2793b94e595e7641450efb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 25 Aug 2021 12:15:49 +0200 Subject: [PATCH 015/208] Raise minimum required CMake version to 3.4 CMake 3.4 was released in November 2015. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bab7f7ad..b10848b3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.1...3.20 FATAL_ERROR) +cmake_minimum_required(VERSION 3.4...3.20 FATAL_ERROR) project(GLFW VERSION 3.4.0 LANGUAGES C) From 8c8def5de552c25c4b6eb18f4e53189304c3df9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 25 Aug 2021 12:17:45 +0200 Subject: [PATCH 016/208] Start making use of CMake 3.4 string(APPEND) --- CMake/GenerateMappings.cmake | 12 ++++++------ CMakeLists.txt | 4 ++-- docs/CMakeLists.txt | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/CMake/GenerateMappings.cmake b/CMake/GenerateMappings.cmake index 47e63741..c8c9e23f 100644 --- a/CMake/GenerateMappings.cmake +++ b/CMake/GenerateMappings.cmake @@ -26,19 +26,19 @@ foreach(line ${lines}) if (line MATCHES "^[0-9a-fA-F]") if (line MATCHES "platform:Windows") if (GLFW_WIN32_MAPPINGS) - set(GLFW_WIN32_MAPPINGS "${GLFW_WIN32_MAPPINGS}\n") + string(APPEND GLFW_WIN32_MAPPINGS "\n") endif() - set(GLFW_WIN32_MAPPINGS "${GLFW_WIN32_MAPPINGS}\"${line}\",") + string(APPEND GLFW_WIN32_MAPPINGS "\"${line}\",") elseif (line MATCHES "platform:Mac OS X") if (GLFW_COCOA_MAPPINGS) - set(GLFW_COCOA_MAPPINGS "${GLFW_COCOA_MAPPINGS}\n") + string(APPEND GLFW_COCOA_MAPPINGS "\n") endif() - set(GLFW_COCOA_MAPPINGS "${GLFW_COCOA_MAPPINGS}\"${line}\",") + string(APPEND GLFW_COCOA_MAPPINGS "\"${line}\",") elseif (line MATCHES "platform:Linux") if (GLFW_LINUX_MAPPINGS) - set(GLFW_LINUX_MAPPINGS "${GLFW_LINUX_MAPPINGS}\n") + string(APPEND GLFW_LINUX_MAPPINGS "\n") endif() - set(GLFW_LINUX_MAPPINGS "${GLFW_LINUX_MAPPINGS}\"${line}\",") + string(APPEND GLFW_LINUX_MAPPINGS "\"${line}\",") endif() endif() endforeach() diff --git a/CMakeLists.txt b/CMakeLists.txt index b10848b3..e255863b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -256,10 +256,10 @@ endif() # Export GLFW library dependencies #-------------------------------------------------------------------- foreach(arg ${glfw_PKG_DEPS}) - set(deps "${deps} ${arg}") + string(APPEND deps " ${arg}") endforeach() foreach(arg ${glfw_PKG_LIBS}) - set(libs "${libs} ${arg}") + string(APPEND libs " ${arg}") endforeach() set(GLFW_PKG_CONFIG_REQUIRES_PRIVATE "${deps}" CACHE INTERNAL diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt index 2347858e..d88888d4 100644 --- a/docs/CMakeLists.txt +++ b/docs/CMakeLists.txt @@ -21,7 +21,7 @@ set(GLFW_DOXYGEN_SOURCES # Format the source list into a Doxyfile INPUT value that Doxygen can parse foreach(path IN LISTS GLFW_DOXYGEN_SOURCES) - set(GLFW_DOXYGEN_INPUT "${GLFW_DOXYGEN_INPUT} \\\n\"${GLFW_SOURCE_DIR}/${path}\"") + string(APPEND GLFW_DOXYGEN_INPUT " \\\n\"${GLFW_SOURCE_DIR}/${path}\"") endforeach() configure_file(Doxyfile.in Doxyfile @ONLY) From 150744ecca502c9af0631233d9d398fdf773a4db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 25 Aug 2021 13:12:14 +0200 Subject: [PATCH 017/208] Only rebuild documentation when necessary This teaches CMake about the dependencies of the Doxygen generated documentation so it isn't rebuilt every time. --- docs/CMakeLists.txt | 56 +++++++++++++++++++++++++++------------------ 1 file changed, 34 insertions(+), 22 deletions(-) diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt index d88888d4..19694085 100644 --- a/docs/CMakeLists.txt +++ b/docs/CMakeLists.txt @@ -1,34 +1,46 @@ # NOTE: The order of this list determines the order of items in the Guides # (i.e. Pages) list in the generated documentation -set(GLFW_DOXYGEN_SOURCES - "include/GLFW/glfw3.h" - "include/GLFW/glfw3native.h" - "docs/main.dox" - "docs/news.dox" - "docs/quick.dox" - "docs/moving.dox" - "docs/compile.dox" - "docs/build.dox" - "docs/intro.dox" - "docs/context.dox" - "docs/monitor.dox" - "docs/window.dox" - "docs/input.dox" - "docs/vulkan.dox" - "docs/compat.dox" - "docs/internal.dox") +set(source_files + main.dox + news.dox + quick.dox + moving.dox + compile.dox + build.dox + intro.dox + context.dox + monitor.dox + window.dox + input.dox + vulkan.dox + compat.dox + internal.dox) + +set(extra_files DoxygenLayout.xml extra.css spaces.svg) + +set(header_paths + "${GLFW_SOURCE_DIR}/include/GLFW/glfw3.h" + "${GLFW_SOURCE_DIR}/include/GLFW/glfw3native.h") # Format the source list into a Doxyfile INPUT value that Doxygen can parse -foreach(path IN LISTS GLFW_DOXYGEN_SOURCES) - string(APPEND GLFW_DOXYGEN_INPUT " \\\n\"${GLFW_SOURCE_DIR}/${path}\"") +foreach(path IN LISTS header_paths) + string(APPEND GLFW_DOXYGEN_INPUT " \\\n\"${path}\"") +endforeach() +foreach(file IN LISTS source_files) + string(APPEND GLFW_DOXYGEN_INPUT " \\\n\"${CMAKE_CURRENT_SOURCE_DIR}/${file}\"") endforeach() configure_file(Doxyfile.in Doxyfile @ONLY) -add_custom_target(docs ALL "${DOXYGEN_EXECUTABLE}" - WORKING_DIRECTORY "${GLFW_BINARY_DIR}/docs" - COMMENT "Generating HTML documentation" VERBATIM) +add_custom_command(OUTPUT "html/index.html" + COMMAND "${DOXYGEN_EXECUTABLE}" + WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" + MAIN_DEPENDENCY Doxyfile + DEPENDS ${header_paths} ${source_files} ${extra_files} + COMMENT "Generating HTML documentation" + VERBATIM) +add_custom_target(docs ALL SOURCES "html/index.html") set_target_properties(docs PROPERTIES FOLDER "GLFW3") From 8e23579842005761d3a4668b72ca524a34ef7b01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 25 Aug 2021 17:53:00 +0200 Subject: [PATCH 018/208] Add OpenGL ES 2.0 triangle example --- deps/glad/gles2.h | 1805 ++++++++++++++++++++++++++++++++++ examples/CMakeLists.txt | 5 +- examples/triangle-opengles.c | 170 ++++ 3 files changed, 1979 insertions(+), 1 deletion(-) create mode 100644 deps/glad/gles2.h create mode 100644 examples/triangle-opengles.c diff --git a/deps/glad/gles2.h b/deps/glad/gles2.h new file mode 100644 index 00000000..d67f1107 --- /dev/null +++ b/deps/glad/gles2.h @@ -0,0 +1,1805 @@ +/** + * Loader generated by glad 2.0.0-beta on Tue Aug 24 22:51:42 2021 + * + * Generator: C/C++ + * Specification: gl + * Extensions: 0 + * + * APIs: + * - gles2=2.0 + * + * Options: + * - ALIAS = False + * - DEBUG = False + * - HEADER_ONLY = True + * - LOADER = False + * - MX = False + * - MX_GLOBAL = False + * - ON_DEMAND = False + * + * Commandline: + * --api='gles2=2.0' --extensions='' c --header-only + * + * Online: + * http://glad.sh/#api=gles2%3D2.0&extensions=&generator=c&options=HEADER_ONLY + * + */ + +#ifndef GLAD_GLES2_H_ +#define GLAD_GLES2_H_ + +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wreserved-id-macro" +#endif +#ifdef __gl2_h_ + #error OpenGL ES 2 header already included (API: gles2), remove previous include! +#endif +#define __gl2_h_ 1 +#ifdef __gl3_h_ + #error OpenGL ES 3 header already included (API: gles2), remove previous include! +#endif +#define __gl3_h_ 1 +#ifdef __clang__ +#pragma clang diagnostic pop +#endif + +#define GLAD_GLES2 +#define GLAD_OPTION_GLES2_HEADER_ONLY + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef GLAD_PLATFORM_H_ +#define GLAD_PLATFORM_H_ + +#ifndef GLAD_PLATFORM_WIN32 + #if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(__MINGW32__) + #define GLAD_PLATFORM_WIN32 1 + #else + #define GLAD_PLATFORM_WIN32 0 + #endif +#endif + +#ifndef GLAD_PLATFORM_APPLE + #ifdef __APPLE__ + #define GLAD_PLATFORM_APPLE 1 + #else + #define GLAD_PLATFORM_APPLE 0 + #endif +#endif + +#ifndef GLAD_PLATFORM_EMSCRIPTEN + #ifdef __EMSCRIPTEN__ + #define GLAD_PLATFORM_EMSCRIPTEN 1 + #else + #define GLAD_PLATFORM_EMSCRIPTEN 0 + #endif +#endif + +#ifndef GLAD_PLATFORM_UWP + #if defined(_MSC_VER) && !defined(GLAD_INTERNAL_HAVE_WINAPIFAMILY) + #ifdef __has_include + #if __has_include() + #define GLAD_INTERNAL_HAVE_WINAPIFAMILY 1 + #endif + #elif _MSC_VER >= 1700 && !_USING_V110_SDK71_ + #define GLAD_INTERNAL_HAVE_WINAPIFAMILY 1 + #endif + #endif + + #ifdef GLAD_INTERNAL_HAVE_WINAPIFAMILY + #include + #if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) + #define GLAD_PLATFORM_UWP 1 + #endif + #endif + + #ifndef GLAD_PLATFORM_UWP + #define GLAD_PLATFORM_UWP 0 + #endif +#endif + +#ifdef __GNUC__ + #define GLAD_GNUC_EXTENSION __extension__ +#else + #define GLAD_GNUC_EXTENSION +#endif + +#ifndef GLAD_API_CALL + #if defined(GLAD_API_CALL_EXPORT) + #if GLAD_PLATFORM_WIN32 || defined(__CYGWIN__) + #if defined(GLAD_API_CALL_EXPORT_BUILD) + #if defined(__GNUC__) + #define GLAD_API_CALL __attribute__ ((dllexport)) extern + #else + #define GLAD_API_CALL __declspec(dllexport) extern + #endif + #else + #if defined(__GNUC__) + #define GLAD_API_CALL __attribute__ ((dllimport)) extern + #else + #define GLAD_API_CALL __declspec(dllimport) extern + #endif + #endif + #elif defined(__GNUC__) && defined(GLAD_API_CALL_EXPORT_BUILD) + #define GLAD_API_CALL __attribute__ ((visibility ("default"))) extern + #else + #define GLAD_API_CALL extern + #endif + #else + #define GLAD_API_CALL extern + #endif +#endif + +#ifdef APIENTRY + #define GLAD_API_PTR APIENTRY +#elif GLAD_PLATFORM_WIN32 + #define GLAD_API_PTR __stdcall +#else + #define GLAD_API_PTR +#endif + +#ifndef GLAPI +#define GLAPI GLAD_API_CALL +#endif + +#ifndef GLAPIENTRY +#define GLAPIENTRY GLAD_API_PTR +#endif + +#define GLAD_MAKE_VERSION(major, minor) (major * 10000 + minor) +#define GLAD_VERSION_MAJOR(version) (version / 10000) +#define GLAD_VERSION_MINOR(version) (version % 10000) + +#define GLAD_GENERATOR_VERSION "2.0.0-beta" + +typedef void (*GLADapiproc)(void); + +typedef GLADapiproc (*GLADloadfunc)(const char *name); +typedef GLADapiproc (*GLADuserptrloadfunc)(void *userptr, const char *name); + +typedef void (*GLADprecallback)(const char *name, GLADapiproc apiproc, int len_args, ...); +typedef void (*GLADpostcallback)(void *ret, const char *name, GLADapiproc apiproc, int len_args, ...); + +#endif /* GLAD_PLATFORM_H_ */ + +#define GL_ACTIVE_ATTRIBUTES 0x8B89 +#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A +#define GL_ACTIVE_TEXTURE 0x84E0 +#define GL_ACTIVE_UNIFORMS 0x8B86 +#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87 +#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E +#define GL_ALIASED_POINT_SIZE_RANGE 0x846D +#define GL_ALPHA 0x1906 +#define GL_ALPHA_BITS 0x0D55 +#define GL_ALWAYS 0x0207 +#define GL_ARRAY_BUFFER 0x8892 +#define GL_ARRAY_BUFFER_BINDING 0x8894 +#define GL_ATTACHED_SHADERS 0x8B85 +#define GL_BACK 0x0405 +#define GL_BLEND 0x0BE2 +#define GL_BLEND_COLOR 0x8005 +#define GL_BLEND_DST_ALPHA 0x80CA +#define GL_BLEND_DST_RGB 0x80C8 +#define GL_BLEND_EQUATION 0x8009 +#define GL_BLEND_EQUATION_ALPHA 0x883D +#define GL_BLEND_EQUATION_RGB 0x8009 +#define GL_BLEND_SRC_ALPHA 0x80CB +#define GL_BLEND_SRC_RGB 0x80C9 +#define GL_BLUE_BITS 0x0D54 +#define GL_BOOL 0x8B56 +#define GL_BOOL_VEC2 0x8B57 +#define GL_BOOL_VEC3 0x8B58 +#define GL_BOOL_VEC4 0x8B59 +#define GL_BUFFER_SIZE 0x8764 +#define GL_BUFFER_USAGE 0x8765 +#define GL_BYTE 0x1400 +#define GL_CCW 0x0901 +#define GL_CLAMP_TO_EDGE 0x812F +#define GL_COLOR_ATTACHMENT0 0x8CE0 +#define GL_COLOR_BUFFER_BIT 0x00004000 +#define GL_COLOR_CLEAR_VALUE 0x0C22 +#define GL_COLOR_WRITEMASK 0x0C23 +#define GL_COMPILE_STATUS 0x8B81 +#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 +#define GL_CONSTANT_ALPHA 0x8003 +#define GL_CONSTANT_COLOR 0x8001 +#define GL_CULL_FACE 0x0B44 +#define GL_CULL_FACE_MODE 0x0B45 +#define GL_CURRENT_PROGRAM 0x8B8D +#define GL_CURRENT_VERTEX_ATTRIB 0x8626 +#define GL_CW 0x0900 +#define GL_DECR 0x1E03 +#define GL_DECR_WRAP 0x8508 +#define GL_DELETE_STATUS 0x8B80 +#define GL_DEPTH_ATTACHMENT 0x8D00 +#define GL_DEPTH_BITS 0x0D56 +#define GL_DEPTH_BUFFER_BIT 0x00000100 +#define GL_DEPTH_CLEAR_VALUE 0x0B73 +#define GL_DEPTH_COMPONENT 0x1902 +#define GL_DEPTH_COMPONENT16 0x81A5 +#define GL_DEPTH_FUNC 0x0B74 +#define GL_DEPTH_RANGE 0x0B70 +#define GL_DEPTH_TEST 0x0B71 +#define GL_DEPTH_WRITEMASK 0x0B72 +#define GL_DITHER 0x0BD0 +#define GL_DONT_CARE 0x1100 +#define GL_DST_ALPHA 0x0304 +#define GL_DST_COLOR 0x0306 +#define GL_DYNAMIC_DRAW 0x88E8 +#define GL_ELEMENT_ARRAY_BUFFER 0x8893 +#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895 +#define GL_EQUAL 0x0202 +#define GL_EXTENSIONS 0x1F03 +#define GL_FALSE 0 +#define GL_FASTEST 0x1101 +#define GL_FIXED 0x140C +#define GL_FLOAT 0x1406 +#define GL_FLOAT_MAT2 0x8B5A +#define GL_FLOAT_MAT3 0x8B5B +#define GL_FLOAT_MAT4 0x8B5C +#define GL_FLOAT_VEC2 0x8B50 +#define GL_FLOAT_VEC3 0x8B51 +#define GL_FLOAT_VEC4 0x8B52 +#define GL_FRAGMENT_SHADER 0x8B30 +#define GL_FRAMEBUFFER 0x8D40 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2 +#define GL_FRAMEBUFFER_BINDING 0x8CA6 +#define GL_FRAMEBUFFER_COMPLETE 0x8CD5 +#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6 +#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS 0x8CD9 +#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7 +#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD +#define GL_FRONT 0x0404 +#define GL_FRONT_AND_BACK 0x0408 +#define GL_FRONT_FACE 0x0B46 +#define GL_FUNC_ADD 0x8006 +#define GL_FUNC_REVERSE_SUBTRACT 0x800B +#define GL_FUNC_SUBTRACT 0x800A +#define GL_GENERATE_MIPMAP_HINT 0x8192 +#define GL_GEQUAL 0x0206 +#define GL_GREATER 0x0204 +#define GL_GREEN_BITS 0x0D53 +#define GL_HIGH_FLOAT 0x8DF2 +#define GL_HIGH_INT 0x8DF5 +#define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B +#define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A +#define GL_INCR 0x1E02 +#define GL_INCR_WRAP 0x8507 +#define GL_INFO_LOG_LENGTH 0x8B84 +#define GL_INT 0x1404 +#define GL_INT_VEC2 0x8B53 +#define GL_INT_VEC3 0x8B54 +#define GL_INT_VEC4 0x8B55 +#define GL_INVALID_ENUM 0x0500 +#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506 +#define GL_INVALID_OPERATION 0x0502 +#define GL_INVALID_VALUE 0x0501 +#define GL_INVERT 0x150A +#define GL_KEEP 0x1E00 +#define GL_LEQUAL 0x0203 +#define GL_LESS 0x0201 +#define GL_LINEAR 0x2601 +#define GL_LINEAR_MIPMAP_LINEAR 0x2703 +#define GL_LINEAR_MIPMAP_NEAREST 0x2701 +#define GL_LINES 0x0001 +#define GL_LINE_LOOP 0x0002 +#define GL_LINE_STRIP 0x0003 +#define GL_LINE_WIDTH 0x0B21 +#define GL_LINK_STATUS 0x8B82 +#define GL_LOW_FLOAT 0x8DF0 +#define GL_LOW_INT 0x8DF3 +#define GL_LUMINANCE 0x1909 +#define GL_LUMINANCE_ALPHA 0x190A +#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C +#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD +#define GL_MAX_RENDERBUFFER_SIZE 0x84E8 +#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872 +#define GL_MAX_TEXTURE_SIZE 0x0D33 +#define GL_MAX_VARYING_VECTORS 0x8DFC +#define GL_MAX_VERTEX_ATTRIBS 0x8869 +#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C +#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB +#define GL_MAX_VIEWPORT_DIMS 0x0D3A +#define GL_MEDIUM_FLOAT 0x8DF1 +#define GL_MEDIUM_INT 0x8DF4 +#define GL_MIRRORED_REPEAT 0x8370 +#define GL_NEAREST 0x2600 +#define GL_NEAREST_MIPMAP_LINEAR 0x2702 +#define GL_NEAREST_MIPMAP_NEAREST 0x2700 +#define GL_NEVER 0x0200 +#define GL_NICEST 0x1102 +#define GL_NONE 0 +#define GL_NOTEQUAL 0x0205 +#define GL_NO_ERROR 0 +#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 +#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9 +#define GL_ONE 1 +#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 +#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 +#define GL_ONE_MINUS_DST_ALPHA 0x0305 +#define GL_ONE_MINUS_DST_COLOR 0x0307 +#define GL_ONE_MINUS_SRC_ALPHA 0x0303 +#define GL_ONE_MINUS_SRC_COLOR 0x0301 +#define GL_OUT_OF_MEMORY 0x0505 +#define GL_PACK_ALIGNMENT 0x0D05 +#define GL_POINTS 0x0000 +#define GL_POLYGON_OFFSET_FACTOR 0x8038 +#define GL_POLYGON_OFFSET_FILL 0x8037 +#define GL_POLYGON_OFFSET_UNITS 0x2A00 +#define GL_RED_BITS 0x0D52 +#define GL_RENDERBUFFER 0x8D41 +#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53 +#define GL_RENDERBUFFER_BINDING 0x8CA7 +#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52 +#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54 +#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51 +#define GL_RENDERBUFFER_HEIGHT 0x8D43 +#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44 +#define GL_RENDERBUFFER_RED_SIZE 0x8D50 +#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55 +#define GL_RENDERBUFFER_WIDTH 0x8D42 +#define GL_RENDERER 0x1F01 +#define GL_REPEAT 0x2901 +#define GL_REPLACE 0x1E01 +#define GL_RGB 0x1907 +#define GL_RGB565 0x8D62 +#define GL_RGB5_A1 0x8057 +#define GL_RGBA 0x1908 +#define GL_RGBA4 0x8056 +#define GL_SAMPLER_2D 0x8B5E +#define GL_SAMPLER_CUBE 0x8B60 +#define GL_SAMPLES 0x80A9 +#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E +#define GL_SAMPLE_BUFFERS 0x80A8 +#define GL_SAMPLE_COVERAGE 0x80A0 +#define GL_SAMPLE_COVERAGE_INVERT 0x80AB +#define GL_SAMPLE_COVERAGE_VALUE 0x80AA +#define GL_SCISSOR_BOX 0x0C10 +#define GL_SCISSOR_TEST 0x0C11 +#define GL_SHADER_BINARY_FORMATS 0x8DF8 +#define GL_SHADER_COMPILER 0x8DFA +#define GL_SHADER_SOURCE_LENGTH 0x8B88 +#define GL_SHADER_TYPE 0x8B4F +#define GL_SHADING_LANGUAGE_VERSION 0x8B8C +#define GL_SHORT 0x1402 +#define GL_SRC_ALPHA 0x0302 +#define GL_SRC_ALPHA_SATURATE 0x0308 +#define GL_SRC_COLOR 0x0300 +#define GL_STATIC_DRAW 0x88E4 +#define GL_STENCIL_ATTACHMENT 0x8D20 +#define GL_STENCIL_BACK_FAIL 0x8801 +#define GL_STENCIL_BACK_FUNC 0x8800 +#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802 +#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803 +#define GL_STENCIL_BACK_REF 0x8CA3 +#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4 +#define GL_STENCIL_BACK_WRITEMASK 0x8CA5 +#define GL_STENCIL_BITS 0x0D57 +#define GL_STENCIL_BUFFER_BIT 0x00000400 +#define GL_STENCIL_CLEAR_VALUE 0x0B91 +#define GL_STENCIL_FAIL 0x0B94 +#define GL_STENCIL_FUNC 0x0B92 +#define GL_STENCIL_INDEX8 0x8D48 +#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95 +#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96 +#define GL_STENCIL_REF 0x0B97 +#define GL_STENCIL_TEST 0x0B90 +#define GL_STENCIL_VALUE_MASK 0x0B93 +#define GL_STENCIL_WRITEMASK 0x0B98 +#define GL_STREAM_DRAW 0x88E0 +#define GL_SUBPIXEL_BITS 0x0D50 +#define GL_TEXTURE 0x1702 +#define GL_TEXTURE0 0x84C0 +#define GL_TEXTURE1 0x84C1 +#define GL_TEXTURE10 0x84CA +#define GL_TEXTURE11 0x84CB +#define GL_TEXTURE12 0x84CC +#define GL_TEXTURE13 0x84CD +#define GL_TEXTURE14 0x84CE +#define GL_TEXTURE15 0x84CF +#define GL_TEXTURE16 0x84D0 +#define GL_TEXTURE17 0x84D1 +#define GL_TEXTURE18 0x84D2 +#define GL_TEXTURE19 0x84D3 +#define GL_TEXTURE2 0x84C2 +#define GL_TEXTURE20 0x84D4 +#define GL_TEXTURE21 0x84D5 +#define GL_TEXTURE22 0x84D6 +#define GL_TEXTURE23 0x84D7 +#define GL_TEXTURE24 0x84D8 +#define GL_TEXTURE25 0x84D9 +#define GL_TEXTURE26 0x84DA +#define GL_TEXTURE27 0x84DB +#define GL_TEXTURE28 0x84DC +#define GL_TEXTURE29 0x84DD +#define GL_TEXTURE3 0x84C3 +#define GL_TEXTURE30 0x84DE +#define GL_TEXTURE31 0x84DF +#define GL_TEXTURE4 0x84C4 +#define GL_TEXTURE5 0x84C5 +#define GL_TEXTURE6 0x84C6 +#define GL_TEXTURE7 0x84C7 +#define GL_TEXTURE8 0x84C8 +#define GL_TEXTURE9 0x84C9 +#define GL_TEXTURE_2D 0x0DE1 +#define GL_TEXTURE_BINDING_2D 0x8069 +#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514 +#define GL_TEXTURE_CUBE_MAP 0x8513 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519 +#define GL_TEXTURE_MAG_FILTER 0x2800 +#define GL_TEXTURE_MIN_FILTER 0x2801 +#define GL_TEXTURE_WRAP_S 0x2802 +#define GL_TEXTURE_WRAP_T 0x2803 +#define GL_TRIANGLES 0x0004 +#define GL_TRIANGLE_FAN 0x0006 +#define GL_TRIANGLE_STRIP 0x0005 +#define GL_TRUE 1 +#define GL_UNPACK_ALIGNMENT 0x0CF5 +#define GL_UNSIGNED_BYTE 0x1401 +#define GL_UNSIGNED_INT 0x1405 +#define GL_UNSIGNED_SHORT 0x1403 +#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 +#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 +#define GL_UNSIGNED_SHORT_5_6_5 0x8363 +#define GL_VALIDATE_STATUS 0x8B83 +#define GL_VENDOR 0x1F00 +#define GL_VERSION 0x1F02 +#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F +#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622 +#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A +#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645 +#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623 +#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624 +#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625 +#define GL_VERTEX_SHADER 0x8B31 +#define GL_VIEWPORT 0x0BA2 +#define GL_ZERO 0 + + +#ifndef __khrplatform_h_ +#define __khrplatform_h_ + +/* +** Copyright (c) 2008-2018 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +/* Khronos platform-specific types and definitions. + * + * The master copy of khrplatform.h is maintained in the Khronos EGL + * Registry repository at https://github.com/KhronosGroup/EGL-Registry + * The last semantic modification to khrplatform.h was at commit ID: + * 67a3e0864c2d75ea5287b9f3d2eb74a745936692 + * + * Adopters may modify this file to suit their platform. Adopters are + * encouraged to submit platform specific modifications to the Khronos + * group so that they can be included in future versions of this file. + * Please submit changes by filing pull requests or issues on + * the EGL Registry repository linked above. + * + * + * See the Implementer's Guidelines for information about where this file + * should be located on your system and for more details of its use: + * http://www.khronos.org/registry/implementers_guide.pdf + * + * This file should be included as + * #include + * by Khronos client API header files that use its types and defines. + * + * The types in khrplatform.h should only be used to define API-specific types. + * + * Types defined in khrplatform.h: + * khronos_int8_t signed 8 bit + * khronos_uint8_t unsigned 8 bit + * khronos_int16_t signed 16 bit + * khronos_uint16_t unsigned 16 bit + * khronos_int32_t signed 32 bit + * khronos_uint32_t unsigned 32 bit + * khronos_int64_t signed 64 bit + * khronos_uint64_t unsigned 64 bit + * khronos_intptr_t signed same number of bits as a pointer + * khronos_uintptr_t unsigned same number of bits as a pointer + * khronos_ssize_t signed size + * khronos_usize_t unsigned size + * khronos_float_t signed 32 bit floating point + * khronos_time_ns_t unsigned 64 bit time in nanoseconds + * khronos_utime_nanoseconds_t unsigned time interval or absolute time in + * nanoseconds + * khronos_stime_nanoseconds_t signed time interval in nanoseconds + * khronos_boolean_enum_t enumerated boolean type. This should + * only be used as a base type when a client API's boolean type is + * an enum. Client APIs which use an integer or other type for + * booleans cannot use this as the base type for their boolean. + * + * Tokens defined in khrplatform.h: + * + * KHRONOS_FALSE, KHRONOS_TRUE Enumerated boolean false/true values. + * + * KHRONOS_SUPPORT_INT64 is 1 if 64 bit integers are supported; otherwise 0. + * KHRONOS_SUPPORT_FLOAT is 1 if floats are supported; otherwise 0. + * + * Calling convention macros defined in this file: + * KHRONOS_APICALL + * KHRONOS_GLAD_API_PTR + * KHRONOS_APIATTRIBUTES + * + * These may be used in function prototypes as: + * + * KHRONOS_APICALL void KHRONOS_GLAD_API_PTR funcname( + * int arg1, + * int arg2) KHRONOS_APIATTRIBUTES; + */ + +#if defined(__SCITECH_SNAP__) && !defined(KHRONOS_STATIC) +# define KHRONOS_STATIC 1 +#endif + +/*------------------------------------------------------------------------- + * Definition of KHRONOS_APICALL + *------------------------------------------------------------------------- + * This precedes the return type of the function in the function prototype. + */ +#if defined(KHRONOS_STATIC) + /* If the preprocessor constant KHRONOS_STATIC is defined, make the + * header compatible with static linking. */ +# define KHRONOS_APICALL +#elif defined(_WIN32) +# define KHRONOS_APICALL __declspec(dllimport) +#elif defined (__SYMBIAN32__) +# define KHRONOS_APICALL IMPORT_C +#elif defined(__ANDROID__) +# define KHRONOS_APICALL __attribute__((visibility("default"))) +#else +# define KHRONOS_APICALL +#endif + +/*------------------------------------------------------------------------- + * Definition of KHRONOS_GLAD_API_PTR + *------------------------------------------------------------------------- + * This follows the return type of the function and precedes the function + * name in the function prototype. + */ +#if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(__SCITECH_SNAP__) + /* Win32 but not WinCE */ +# define KHRONOS_GLAD_API_PTR __stdcall +#else +# define KHRONOS_GLAD_API_PTR +#endif + +/*------------------------------------------------------------------------- + * Definition of KHRONOS_APIATTRIBUTES + *------------------------------------------------------------------------- + * This follows the closing parenthesis of the function prototype arguments. + */ +#if defined (__ARMCC_2__) +#define KHRONOS_APIATTRIBUTES __softfp +#else +#define KHRONOS_APIATTRIBUTES +#endif + +/*------------------------------------------------------------------------- + * basic type definitions + *-----------------------------------------------------------------------*/ +#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__GNUC__) || defined(__SCO__) || defined(__USLC__) + + +/* + * Using + */ +#include +typedef int32_t khronos_int32_t; +typedef uint32_t khronos_uint32_t; +typedef int64_t khronos_int64_t; +typedef uint64_t khronos_uint64_t; +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 + +#elif defined(__VMS ) || defined(__sgi) + +/* + * Using + */ +#include +typedef int32_t khronos_int32_t; +typedef uint32_t khronos_uint32_t; +typedef int64_t khronos_int64_t; +typedef uint64_t khronos_uint64_t; +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 + +#elif defined(_WIN32) && !defined(__SCITECH_SNAP__) + +/* + * Win32 + */ +typedef __int32 khronos_int32_t; +typedef unsigned __int32 khronos_uint32_t; +typedef __int64 khronos_int64_t; +typedef unsigned __int64 khronos_uint64_t; +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 + +#elif defined(__sun__) || defined(__digital__) + +/* + * Sun or Digital + */ +typedef int khronos_int32_t; +typedef unsigned int khronos_uint32_t; +#if defined(__arch64__) || defined(_LP64) +typedef long int khronos_int64_t; +typedef unsigned long int khronos_uint64_t; +#else +typedef long long int khronos_int64_t; +typedef unsigned long long int khronos_uint64_t; +#endif /* __arch64__ */ +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 + +#elif 0 + +/* + * Hypothetical platform with no float or int64 support + */ +typedef int khronos_int32_t; +typedef unsigned int khronos_uint32_t; +#define KHRONOS_SUPPORT_INT64 0 +#define KHRONOS_SUPPORT_FLOAT 0 + +#else + +/* + * Generic fallback + */ +#include +typedef int32_t khronos_int32_t; +typedef uint32_t khronos_uint32_t; +typedef int64_t khronos_int64_t; +typedef uint64_t khronos_uint64_t; +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 + +#endif + + +/* + * Types that are (so far) the same on all platforms + */ +typedef signed char khronos_int8_t; +typedef unsigned char khronos_uint8_t; +typedef signed short int khronos_int16_t; +typedef unsigned short int khronos_uint16_t; + +/* + * Types that differ between LLP64 and LP64 architectures - in LLP64, + * pointers are 64 bits, but 'long' is still 32 bits. Win64 appears + * to be the only LLP64 architecture in current use. + */ +#ifdef _WIN64 +typedef signed long long int khronos_intptr_t; +typedef unsigned long long int khronos_uintptr_t; +typedef signed long long int khronos_ssize_t; +typedef unsigned long long int khronos_usize_t; +#else +typedef signed long int khronos_intptr_t; +typedef unsigned long int khronos_uintptr_t; +typedef signed long int khronos_ssize_t; +typedef unsigned long int khronos_usize_t; +#endif + +#if KHRONOS_SUPPORT_FLOAT +/* + * Float type + */ +typedef float khronos_float_t; +#endif + +#if KHRONOS_SUPPORT_INT64 +/* Time types + * + * These types can be used to represent a time interval in nanoseconds or + * an absolute Unadjusted System Time. Unadjusted System Time is the number + * of nanoseconds since some arbitrary system event (e.g. since the last + * time the system booted). The Unadjusted System Time is an unsigned + * 64 bit value that wraps back to 0 every 584 years. Time intervals + * may be either signed or unsigned. + */ +typedef khronos_uint64_t khronos_utime_nanoseconds_t; +typedef khronos_int64_t khronos_stime_nanoseconds_t; +#endif + +/* + * Dummy value used to pad enum types to 32 bits. + */ +#ifndef KHRONOS_MAX_ENUM +#define KHRONOS_MAX_ENUM 0x7FFFFFFF +#endif + +/* + * Enumerated boolean type + * + * Values other than zero should be considered to be true. Therefore + * comparisons should not be made against KHRONOS_TRUE. + */ +typedef enum { + KHRONOS_FALSE = 0, + KHRONOS_TRUE = 1, + KHRONOS_BOOLEAN_ENUM_FORCE_SIZE = KHRONOS_MAX_ENUM +} khronos_boolean_enum_t; + +#endif /* __khrplatform_h_ */ + +typedef unsigned int GLenum; + +typedef unsigned char GLboolean; + +typedef unsigned int GLbitfield; + +typedef void GLvoid; + +typedef khronos_int8_t GLbyte; + +typedef khronos_uint8_t GLubyte; + +typedef khronos_int16_t GLshort; + +typedef khronos_uint16_t GLushort; + +typedef int GLint; + +typedef unsigned int GLuint; + +typedef khronos_int32_t GLclampx; + +typedef int GLsizei; + +typedef khronos_float_t GLfloat; + +typedef khronos_float_t GLclampf; + +typedef double GLdouble; + +typedef double GLclampd; + +typedef void *GLeglClientBufferEXT; + +typedef void *GLeglImageOES; + +typedef char GLchar; + +typedef char GLcharARB; + +#ifdef __APPLE__ +typedef void *GLhandleARB; +#else +typedef unsigned int GLhandleARB; +#endif + +typedef khronos_uint16_t GLhalf; + +typedef khronos_uint16_t GLhalfARB; + +typedef khronos_int32_t GLfixed; + +#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ > 1060) +typedef khronos_intptr_t GLintptr; +#else +typedef khronos_intptr_t GLintptr; +#endif + +#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ > 1060) +typedef khronos_intptr_t GLintptrARB; +#else +typedef khronos_intptr_t GLintptrARB; +#endif + +#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ > 1060) +typedef khronos_ssize_t GLsizeiptr; +#else +typedef khronos_ssize_t GLsizeiptr; +#endif + +#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ > 1060) +typedef khronos_ssize_t GLsizeiptrARB; +#else +typedef khronos_ssize_t GLsizeiptrARB; +#endif + +typedef khronos_int64_t GLint64; + +typedef khronos_int64_t GLint64EXT; + +typedef khronos_uint64_t GLuint64; + +typedef khronos_uint64_t GLuint64EXT; + +typedef struct __GLsync *GLsync; + +struct _cl_context; + +struct _cl_event; + +typedef void (GLAD_API_PTR *GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam); + +typedef void (GLAD_API_PTR *GLDEBUGPROCARB)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam); + +typedef void (GLAD_API_PTR *GLDEBUGPROCKHR)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam); + +typedef void (GLAD_API_PTR *GLDEBUGPROCAMD)(GLuint id,GLenum category,GLenum severity,GLsizei length,const GLchar *message,void *userParam); + +typedef unsigned short GLhalfNV; + +typedef GLintptr GLvdpauSurfaceNV; + +typedef void (GLAD_API_PTR *GLVULKANPROCNV)(void); + + + +#define GL_ES_VERSION_2_0 1 +GLAD_API_CALL int GLAD_GL_ES_VERSION_2_0; + + +typedef void (GLAD_API_PTR *PFNGLACTIVETEXTUREPROC)(GLenum texture); +typedef void (GLAD_API_PTR *PFNGLATTACHSHADERPROC)(GLuint program, GLuint shader); +typedef void (GLAD_API_PTR *PFNGLBINDATTRIBLOCATIONPROC)(GLuint program, GLuint index, const GLchar * name); +typedef void (GLAD_API_PTR *PFNGLBINDBUFFERPROC)(GLenum target, GLuint buffer); +typedef void (GLAD_API_PTR *PFNGLBINDFRAMEBUFFERPROC)(GLenum target, GLuint framebuffer); +typedef void (GLAD_API_PTR *PFNGLBINDRENDERBUFFERPROC)(GLenum target, GLuint renderbuffer); +typedef void (GLAD_API_PTR *PFNGLBINDTEXTUREPROC)(GLenum target, GLuint texture); +typedef void (GLAD_API_PTR *PFNGLBLENDCOLORPROC)(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +typedef void (GLAD_API_PTR *PFNGLBLENDEQUATIONPROC)(GLenum mode); +typedef void (GLAD_API_PTR *PFNGLBLENDEQUATIONSEPARATEPROC)(GLenum modeRGB, GLenum modeAlpha); +typedef void (GLAD_API_PTR *PFNGLBLENDFUNCPROC)(GLenum sfactor, GLenum dfactor); +typedef void (GLAD_API_PTR *PFNGLBLENDFUNCSEPARATEPROC)(GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +typedef void (GLAD_API_PTR *PFNGLBUFFERDATAPROC)(GLenum target, GLsizeiptr size, const void * data, GLenum usage); +typedef void (GLAD_API_PTR *PFNGLBUFFERSUBDATAPROC)(GLenum target, GLintptr offset, GLsizeiptr size, const void * data); +typedef GLenum (GLAD_API_PTR *PFNGLCHECKFRAMEBUFFERSTATUSPROC)(GLenum target); +typedef void (GLAD_API_PTR *PFNGLCLEARPROC)(GLbitfield mask); +typedef void (GLAD_API_PTR *PFNGLCLEARCOLORPROC)(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +typedef void (GLAD_API_PTR *PFNGLCLEARDEPTHFPROC)(GLfloat d); +typedef void (GLAD_API_PTR *PFNGLCLEARSTENCILPROC)(GLint s); +typedef void (GLAD_API_PTR *PFNGLCOLORMASKPROC)(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); +typedef void (GLAD_API_PTR *PFNGLCOMPILESHADERPROC)(GLuint shader); +typedef void (GLAD_API_PTR *PFNGLCOMPRESSEDTEXIMAGE2DPROC)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void * data); +typedef void (GLAD_API_PTR *PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void * data); +typedef void (GLAD_API_PTR *PFNGLCOPYTEXIMAGE2DPROC)(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +typedef void (GLAD_API_PTR *PFNGLCOPYTEXSUBIMAGE2DPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef GLuint (GLAD_API_PTR *PFNGLCREATEPROGRAMPROC)(void); +typedef GLuint (GLAD_API_PTR *PFNGLCREATESHADERPROC)(GLenum type); +typedef void (GLAD_API_PTR *PFNGLCULLFACEPROC)(GLenum mode); +typedef void (GLAD_API_PTR *PFNGLDELETEBUFFERSPROC)(GLsizei n, const GLuint * buffers); +typedef void (GLAD_API_PTR *PFNGLDELETEFRAMEBUFFERSPROC)(GLsizei n, const GLuint * framebuffers); +typedef void (GLAD_API_PTR *PFNGLDELETEPROGRAMPROC)(GLuint program); +typedef void (GLAD_API_PTR *PFNGLDELETERENDERBUFFERSPROC)(GLsizei n, const GLuint * renderbuffers); +typedef void (GLAD_API_PTR *PFNGLDELETESHADERPROC)(GLuint shader); +typedef void (GLAD_API_PTR *PFNGLDELETETEXTURESPROC)(GLsizei n, const GLuint * textures); +typedef void (GLAD_API_PTR *PFNGLDEPTHFUNCPROC)(GLenum func); +typedef void (GLAD_API_PTR *PFNGLDEPTHMASKPROC)(GLboolean flag); +typedef void (GLAD_API_PTR *PFNGLDEPTHRANGEFPROC)(GLfloat n, GLfloat f); +typedef void (GLAD_API_PTR *PFNGLDETACHSHADERPROC)(GLuint program, GLuint shader); +typedef void (GLAD_API_PTR *PFNGLDISABLEPROC)(GLenum cap); +typedef void (GLAD_API_PTR *PFNGLDISABLEVERTEXATTRIBARRAYPROC)(GLuint index); +typedef void (GLAD_API_PTR *PFNGLDRAWARRAYSPROC)(GLenum mode, GLint first, GLsizei count); +typedef void (GLAD_API_PTR *PFNGLDRAWELEMENTSPROC)(GLenum mode, GLsizei count, GLenum type, const void * indices); +typedef void (GLAD_API_PTR *PFNGLENABLEPROC)(GLenum cap); +typedef void (GLAD_API_PTR *PFNGLENABLEVERTEXATTRIBARRAYPROC)(GLuint index); +typedef void (GLAD_API_PTR *PFNGLFINISHPROC)(void); +typedef void (GLAD_API_PTR *PFNGLFLUSHPROC)(void); +typedef void (GLAD_API_PTR *PFNGLFRAMEBUFFERRENDERBUFFERPROC)(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +typedef void (GLAD_API_PTR *PFNGLFRAMEBUFFERTEXTURE2DPROC)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (GLAD_API_PTR *PFNGLFRONTFACEPROC)(GLenum mode); +typedef void (GLAD_API_PTR *PFNGLGENBUFFERSPROC)(GLsizei n, GLuint * buffers); +typedef void (GLAD_API_PTR *PFNGLGENFRAMEBUFFERSPROC)(GLsizei n, GLuint * framebuffers); +typedef void (GLAD_API_PTR *PFNGLGENRENDERBUFFERSPROC)(GLsizei n, GLuint * renderbuffers); +typedef void (GLAD_API_PTR *PFNGLGENTEXTURESPROC)(GLsizei n, GLuint * textures); +typedef void (GLAD_API_PTR *PFNGLGENERATEMIPMAPPROC)(GLenum target); +typedef void (GLAD_API_PTR *PFNGLGETACTIVEATTRIBPROC)(GLuint program, GLuint index, GLsizei bufSize, GLsizei * length, GLint * size, GLenum * type, GLchar * name); +typedef void (GLAD_API_PTR *PFNGLGETACTIVEUNIFORMPROC)(GLuint program, GLuint index, GLsizei bufSize, GLsizei * length, GLint * size, GLenum * type, GLchar * name); +typedef void (GLAD_API_PTR *PFNGLGETATTACHEDSHADERSPROC)(GLuint program, GLsizei maxCount, GLsizei * count, GLuint * shaders); +typedef GLint (GLAD_API_PTR *PFNGLGETATTRIBLOCATIONPROC)(GLuint program, const GLchar * name); +typedef void (GLAD_API_PTR *PFNGLGETBOOLEANVPROC)(GLenum pname, GLboolean * data); +typedef void (GLAD_API_PTR *PFNGLGETBUFFERPARAMETERIVPROC)(GLenum target, GLenum pname, GLint * params); +typedef GLenum (GLAD_API_PTR *PFNGLGETERRORPROC)(void); +typedef void (GLAD_API_PTR *PFNGLGETFLOATVPROC)(GLenum pname, GLfloat * data); +typedef void (GLAD_API_PTR *PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC)(GLenum target, GLenum attachment, GLenum pname, GLint * params); +typedef void (GLAD_API_PTR *PFNGLGETINTEGERVPROC)(GLenum pname, GLint * data); +typedef void (GLAD_API_PTR *PFNGLGETPROGRAMINFOLOGPROC)(GLuint program, GLsizei bufSize, GLsizei * length, GLchar * infoLog); +typedef void (GLAD_API_PTR *PFNGLGETPROGRAMIVPROC)(GLuint program, GLenum pname, GLint * params); +typedef void (GLAD_API_PTR *PFNGLGETRENDERBUFFERPARAMETERIVPROC)(GLenum target, GLenum pname, GLint * params); +typedef void (GLAD_API_PTR *PFNGLGETSHADERINFOLOGPROC)(GLuint shader, GLsizei bufSize, GLsizei * length, GLchar * infoLog); +typedef void (GLAD_API_PTR *PFNGLGETSHADERPRECISIONFORMATPROC)(GLenum shadertype, GLenum precisiontype, GLint * range, GLint * precision); +typedef void (GLAD_API_PTR *PFNGLGETSHADERSOURCEPROC)(GLuint shader, GLsizei bufSize, GLsizei * length, GLchar * source); +typedef void (GLAD_API_PTR *PFNGLGETSHADERIVPROC)(GLuint shader, GLenum pname, GLint * params); +typedef const GLubyte * (GLAD_API_PTR *PFNGLGETSTRINGPROC)(GLenum name); +typedef void (GLAD_API_PTR *PFNGLGETTEXPARAMETERFVPROC)(GLenum target, GLenum pname, GLfloat * params); +typedef void (GLAD_API_PTR *PFNGLGETTEXPARAMETERIVPROC)(GLenum target, GLenum pname, GLint * params); +typedef GLint (GLAD_API_PTR *PFNGLGETUNIFORMLOCATIONPROC)(GLuint program, const GLchar * name); +typedef void (GLAD_API_PTR *PFNGLGETUNIFORMFVPROC)(GLuint program, GLint location, GLfloat * params); +typedef void (GLAD_API_PTR *PFNGLGETUNIFORMIVPROC)(GLuint program, GLint location, GLint * params); +typedef void (GLAD_API_PTR *PFNGLGETVERTEXATTRIBPOINTERVPROC)(GLuint index, GLenum pname, void ** pointer); +typedef void (GLAD_API_PTR *PFNGLGETVERTEXATTRIBFVPROC)(GLuint index, GLenum pname, GLfloat * params); +typedef void (GLAD_API_PTR *PFNGLGETVERTEXATTRIBIVPROC)(GLuint index, GLenum pname, GLint * params); +typedef void (GLAD_API_PTR *PFNGLHINTPROC)(GLenum target, GLenum mode); +typedef GLboolean (GLAD_API_PTR *PFNGLISBUFFERPROC)(GLuint buffer); +typedef GLboolean (GLAD_API_PTR *PFNGLISENABLEDPROC)(GLenum cap); +typedef GLboolean (GLAD_API_PTR *PFNGLISFRAMEBUFFERPROC)(GLuint framebuffer); +typedef GLboolean (GLAD_API_PTR *PFNGLISPROGRAMPROC)(GLuint program); +typedef GLboolean (GLAD_API_PTR *PFNGLISRENDERBUFFERPROC)(GLuint renderbuffer); +typedef GLboolean (GLAD_API_PTR *PFNGLISSHADERPROC)(GLuint shader); +typedef GLboolean (GLAD_API_PTR *PFNGLISTEXTUREPROC)(GLuint texture); +typedef void (GLAD_API_PTR *PFNGLLINEWIDTHPROC)(GLfloat width); +typedef void (GLAD_API_PTR *PFNGLLINKPROGRAMPROC)(GLuint program); +typedef void (GLAD_API_PTR *PFNGLPIXELSTOREIPROC)(GLenum pname, GLint param); +typedef void (GLAD_API_PTR *PFNGLPOLYGONOFFSETPROC)(GLfloat factor, GLfloat units); +typedef void (GLAD_API_PTR *PFNGLREADPIXELSPROC)(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void * pixels); +typedef void (GLAD_API_PTR *PFNGLRELEASESHADERCOMPILERPROC)(void); +typedef void (GLAD_API_PTR *PFNGLRENDERBUFFERSTORAGEPROC)(GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (GLAD_API_PTR *PFNGLSAMPLECOVERAGEPROC)(GLfloat value, GLboolean invert); +typedef void (GLAD_API_PTR *PFNGLSCISSORPROC)(GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (GLAD_API_PTR *PFNGLSHADERBINARYPROC)(GLsizei count, const GLuint * shaders, GLenum binaryFormat, const void * binary, GLsizei length); +typedef void (GLAD_API_PTR *PFNGLSHADERSOURCEPROC)(GLuint shader, GLsizei count, const GLchar *const* string, const GLint * length); +typedef void (GLAD_API_PTR *PFNGLSTENCILFUNCPROC)(GLenum func, GLint ref, GLuint mask); +typedef void (GLAD_API_PTR *PFNGLSTENCILFUNCSEPARATEPROC)(GLenum face, GLenum func, GLint ref, GLuint mask); +typedef void (GLAD_API_PTR *PFNGLSTENCILMASKPROC)(GLuint mask); +typedef void (GLAD_API_PTR *PFNGLSTENCILMASKSEPARATEPROC)(GLenum face, GLuint mask); +typedef void (GLAD_API_PTR *PFNGLSTENCILOPPROC)(GLenum fail, GLenum zfail, GLenum zpass); +typedef void (GLAD_API_PTR *PFNGLSTENCILOPSEPARATEPROC)(GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +typedef void (GLAD_API_PTR *PFNGLTEXIMAGE2DPROC)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void * pixels); +typedef void (GLAD_API_PTR *PFNGLTEXPARAMETERFPROC)(GLenum target, GLenum pname, GLfloat param); +typedef void (GLAD_API_PTR *PFNGLTEXPARAMETERFVPROC)(GLenum target, GLenum pname, const GLfloat * params); +typedef void (GLAD_API_PTR *PFNGLTEXPARAMETERIPROC)(GLenum target, GLenum pname, GLint param); +typedef void (GLAD_API_PTR *PFNGLTEXPARAMETERIVPROC)(GLenum target, GLenum pname, const GLint * params); +typedef void (GLAD_API_PTR *PFNGLTEXSUBIMAGE2DPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void * pixels); +typedef void (GLAD_API_PTR *PFNGLUNIFORM1FPROC)(GLint location, GLfloat v0); +typedef void (GLAD_API_PTR *PFNGLUNIFORM1FVPROC)(GLint location, GLsizei count, const GLfloat * value); +typedef void (GLAD_API_PTR *PFNGLUNIFORM1IPROC)(GLint location, GLint v0); +typedef void (GLAD_API_PTR *PFNGLUNIFORM1IVPROC)(GLint location, GLsizei count, const GLint * value); +typedef void (GLAD_API_PTR *PFNGLUNIFORM2FPROC)(GLint location, GLfloat v0, GLfloat v1); +typedef void (GLAD_API_PTR *PFNGLUNIFORM2FVPROC)(GLint location, GLsizei count, const GLfloat * value); +typedef void (GLAD_API_PTR *PFNGLUNIFORM2IPROC)(GLint location, GLint v0, GLint v1); +typedef void (GLAD_API_PTR *PFNGLUNIFORM2IVPROC)(GLint location, GLsizei count, const GLint * value); +typedef void (GLAD_API_PTR *PFNGLUNIFORM3FPROC)(GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (GLAD_API_PTR *PFNGLUNIFORM3FVPROC)(GLint location, GLsizei count, const GLfloat * value); +typedef void (GLAD_API_PTR *PFNGLUNIFORM3IPROC)(GLint location, GLint v0, GLint v1, GLint v2); +typedef void (GLAD_API_PTR *PFNGLUNIFORM3IVPROC)(GLint location, GLsizei count, const GLint * value); +typedef void (GLAD_API_PTR *PFNGLUNIFORM4FPROC)(GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (GLAD_API_PTR *PFNGLUNIFORM4FVPROC)(GLint location, GLsizei count, const GLfloat * value); +typedef void (GLAD_API_PTR *PFNGLUNIFORM4IPROC)(GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (GLAD_API_PTR *PFNGLUNIFORM4IVPROC)(GLint location, GLsizei count, const GLint * value); +typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX2FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value); +typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX3FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value); +typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX4FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value); +typedef void (GLAD_API_PTR *PFNGLUSEPROGRAMPROC)(GLuint program); +typedef void (GLAD_API_PTR *PFNGLVALIDATEPROGRAMPROC)(GLuint program); +typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB1FPROC)(GLuint index, GLfloat x); +typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB1FVPROC)(GLuint index, const GLfloat * v); +typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB2FPROC)(GLuint index, GLfloat x, GLfloat y); +typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB2FVPROC)(GLuint index, const GLfloat * v); +typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB3FPROC)(GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB3FVPROC)(GLuint index, const GLfloat * v); +typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4FPROC)(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4FVPROC)(GLuint index, const GLfloat * v); +typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBPOINTERPROC)(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void * pointer); +typedef void (GLAD_API_PTR *PFNGLVIEWPORTPROC)(GLint x, GLint y, GLsizei width, GLsizei height); + +GLAD_API_CALL PFNGLACTIVETEXTUREPROC glad_glActiveTexture; +#define glActiveTexture glad_glActiveTexture +GLAD_API_CALL PFNGLATTACHSHADERPROC glad_glAttachShader; +#define glAttachShader glad_glAttachShader +GLAD_API_CALL PFNGLBINDATTRIBLOCATIONPROC glad_glBindAttribLocation; +#define glBindAttribLocation glad_glBindAttribLocation +GLAD_API_CALL PFNGLBINDBUFFERPROC glad_glBindBuffer; +#define glBindBuffer glad_glBindBuffer +GLAD_API_CALL PFNGLBINDFRAMEBUFFERPROC glad_glBindFramebuffer; +#define glBindFramebuffer glad_glBindFramebuffer +GLAD_API_CALL PFNGLBINDRENDERBUFFERPROC glad_glBindRenderbuffer; +#define glBindRenderbuffer glad_glBindRenderbuffer +GLAD_API_CALL PFNGLBINDTEXTUREPROC glad_glBindTexture; +#define glBindTexture glad_glBindTexture +GLAD_API_CALL PFNGLBLENDCOLORPROC glad_glBlendColor; +#define glBlendColor glad_glBlendColor +GLAD_API_CALL PFNGLBLENDEQUATIONPROC glad_glBlendEquation; +#define glBlendEquation glad_glBlendEquation +GLAD_API_CALL PFNGLBLENDEQUATIONSEPARATEPROC glad_glBlendEquationSeparate; +#define glBlendEquationSeparate glad_glBlendEquationSeparate +GLAD_API_CALL PFNGLBLENDFUNCPROC glad_glBlendFunc; +#define glBlendFunc glad_glBlendFunc +GLAD_API_CALL PFNGLBLENDFUNCSEPARATEPROC glad_glBlendFuncSeparate; +#define glBlendFuncSeparate glad_glBlendFuncSeparate +GLAD_API_CALL PFNGLBUFFERDATAPROC glad_glBufferData; +#define glBufferData glad_glBufferData +GLAD_API_CALL PFNGLBUFFERSUBDATAPROC glad_glBufferSubData; +#define glBufferSubData glad_glBufferSubData +GLAD_API_CALL PFNGLCHECKFRAMEBUFFERSTATUSPROC glad_glCheckFramebufferStatus; +#define glCheckFramebufferStatus glad_glCheckFramebufferStatus +GLAD_API_CALL PFNGLCLEARPROC glad_glClear; +#define glClear glad_glClear +GLAD_API_CALL PFNGLCLEARCOLORPROC glad_glClearColor; +#define glClearColor glad_glClearColor +GLAD_API_CALL PFNGLCLEARDEPTHFPROC glad_glClearDepthf; +#define glClearDepthf glad_glClearDepthf +GLAD_API_CALL PFNGLCLEARSTENCILPROC glad_glClearStencil; +#define glClearStencil glad_glClearStencil +GLAD_API_CALL PFNGLCOLORMASKPROC glad_glColorMask; +#define glColorMask glad_glColorMask +GLAD_API_CALL PFNGLCOMPILESHADERPROC glad_glCompileShader; +#define glCompileShader glad_glCompileShader +GLAD_API_CALL PFNGLCOMPRESSEDTEXIMAGE2DPROC glad_glCompressedTexImage2D; +#define glCompressedTexImage2D glad_glCompressedTexImage2D +GLAD_API_CALL PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC glad_glCompressedTexSubImage2D; +#define glCompressedTexSubImage2D glad_glCompressedTexSubImage2D +GLAD_API_CALL PFNGLCOPYTEXIMAGE2DPROC glad_glCopyTexImage2D; +#define glCopyTexImage2D glad_glCopyTexImage2D +GLAD_API_CALL PFNGLCOPYTEXSUBIMAGE2DPROC glad_glCopyTexSubImage2D; +#define glCopyTexSubImage2D glad_glCopyTexSubImage2D +GLAD_API_CALL PFNGLCREATEPROGRAMPROC glad_glCreateProgram; +#define glCreateProgram glad_glCreateProgram +GLAD_API_CALL PFNGLCREATESHADERPROC glad_glCreateShader; +#define glCreateShader glad_glCreateShader +GLAD_API_CALL PFNGLCULLFACEPROC glad_glCullFace; +#define glCullFace glad_glCullFace +GLAD_API_CALL PFNGLDELETEBUFFERSPROC glad_glDeleteBuffers; +#define glDeleteBuffers glad_glDeleteBuffers +GLAD_API_CALL PFNGLDELETEFRAMEBUFFERSPROC glad_glDeleteFramebuffers; +#define glDeleteFramebuffers glad_glDeleteFramebuffers +GLAD_API_CALL PFNGLDELETEPROGRAMPROC glad_glDeleteProgram; +#define glDeleteProgram glad_glDeleteProgram +GLAD_API_CALL PFNGLDELETERENDERBUFFERSPROC glad_glDeleteRenderbuffers; +#define glDeleteRenderbuffers glad_glDeleteRenderbuffers +GLAD_API_CALL PFNGLDELETESHADERPROC glad_glDeleteShader; +#define glDeleteShader glad_glDeleteShader +GLAD_API_CALL PFNGLDELETETEXTURESPROC glad_glDeleteTextures; +#define glDeleteTextures glad_glDeleteTextures +GLAD_API_CALL PFNGLDEPTHFUNCPROC glad_glDepthFunc; +#define glDepthFunc glad_glDepthFunc +GLAD_API_CALL PFNGLDEPTHMASKPROC glad_glDepthMask; +#define glDepthMask glad_glDepthMask +GLAD_API_CALL PFNGLDEPTHRANGEFPROC glad_glDepthRangef; +#define glDepthRangef glad_glDepthRangef +GLAD_API_CALL PFNGLDETACHSHADERPROC glad_glDetachShader; +#define glDetachShader glad_glDetachShader +GLAD_API_CALL PFNGLDISABLEPROC glad_glDisable; +#define glDisable glad_glDisable +GLAD_API_CALL PFNGLDISABLEVERTEXATTRIBARRAYPROC glad_glDisableVertexAttribArray; +#define glDisableVertexAttribArray glad_glDisableVertexAttribArray +GLAD_API_CALL PFNGLDRAWARRAYSPROC glad_glDrawArrays; +#define glDrawArrays glad_glDrawArrays +GLAD_API_CALL PFNGLDRAWELEMENTSPROC glad_glDrawElements; +#define glDrawElements glad_glDrawElements +GLAD_API_CALL PFNGLENABLEPROC glad_glEnable; +#define glEnable glad_glEnable +GLAD_API_CALL PFNGLENABLEVERTEXATTRIBARRAYPROC glad_glEnableVertexAttribArray; +#define glEnableVertexAttribArray glad_glEnableVertexAttribArray +GLAD_API_CALL PFNGLFINISHPROC glad_glFinish; +#define glFinish glad_glFinish +GLAD_API_CALL PFNGLFLUSHPROC glad_glFlush; +#define glFlush glad_glFlush +GLAD_API_CALL PFNGLFRAMEBUFFERRENDERBUFFERPROC glad_glFramebufferRenderbuffer; +#define glFramebufferRenderbuffer glad_glFramebufferRenderbuffer +GLAD_API_CALL PFNGLFRAMEBUFFERTEXTURE2DPROC glad_glFramebufferTexture2D; +#define glFramebufferTexture2D glad_glFramebufferTexture2D +GLAD_API_CALL PFNGLFRONTFACEPROC glad_glFrontFace; +#define glFrontFace glad_glFrontFace +GLAD_API_CALL PFNGLGENBUFFERSPROC glad_glGenBuffers; +#define glGenBuffers glad_glGenBuffers +GLAD_API_CALL PFNGLGENFRAMEBUFFERSPROC glad_glGenFramebuffers; +#define glGenFramebuffers glad_glGenFramebuffers +GLAD_API_CALL PFNGLGENRENDERBUFFERSPROC glad_glGenRenderbuffers; +#define glGenRenderbuffers glad_glGenRenderbuffers +GLAD_API_CALL PFNGLGENTEXTURESPROC glad_glGenTextures; +#define glGenTextures glad_glGenTextures +GLAD_API_CALL PFNGLGENERATEMIPMAPPROC glad_glGenerateMipmap; +#define glGenerateMipmap glad_glGenerateMipmap +GLAD_API_CALL PFNGLGETACTIVEATTRIBPROC glad_glGetActiveAttrib; +#define glGetActiveAttrib glad_glGetActiveAttrib +GLAD_API_CALL PFNGLGETACTIVEUNIFORMPROC glad_glGetActiveUniform; +#define glGetActiveUniform glad_glGetActiveUniform +GLAD_API_CALL PFNGLGETATTACHEDSHADERSPROC glad_glGetAttachedShaders; +#define glGetAttachedShaders glad_glGetAttachedShaders +GLAD_API_CALL PFNGLGETATTRIBLOCATIONPROC glad_glGetAttribLocation; +#define glGetAttribLocation glad_glGetAttribLocation +GLAD_API_CALL PFNGLGETBOOLEANVPROC glad_glGetBooleanv; +#define glGetBooleanv glad_glGetBooleanv +GLAD_API_CALL PFNGLGETBUFFERPARAMETERIVPROC glad_glGetBufferParameteriv; +#define glGetBufferParameteriv glad_glGetBufferParameteriv +GLAD_API_CALL PFNGLGETERRORPROC glad_glGetError; +#define glGetError glad_glGetError +GLAD_API_CALL PFNGLGETFLOATVPROC glad_glGetFloatv; +#define glGetFloatv glad_glGetFloatv +GLAD_API_CALL PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC glad_glGetFramebufferAttachmentParameteriv; +#define glGetFramebufferAttachmentParameteriv glad_glGetFramebufferAttachmentParameteriv +GLAD_API_CALL PFNGLGETINTEGERVPROC glad_glGetIntegerv; +#define glGetIntegerv glad_glGetIntegerv +GLAD_API_CALL PFNGLGETPROGRAMINFOLOGPROC glad_glGetProgramInfoLog; +#define glGetProgramInfoLog glad_glGetProgramInfoLog +GLAD_API_CALL PFNGLGETPROGRAMIVPROC glad_glGetProgramiv; +#define glGetProgramiv glad_glGetProgramiv +GLAD_API_CALL PFNGLGETRENDERBUFFERPARAMETERIVPROC glad_glGetRenderbufferParameteriv; +#define glGetRenderbufferParameteriv glad_glGetRenderbufferParameteriv +GLAD_API_CALL PFNGLGETSHADERINFOLOGPROC glad_glGetShaderInfoLog; +#define glGetShaderInfoLog glad_glGetShaderInfoLog +GLAD_API_CALL PFNGLGETSHADERPRECISIONFORMATPROC glad_glGetShaderPrecisionFormat; +#define glGetShaderPrecisionFormat glad_glGetShaderPrecisionFormat +GLAD_API_CALL PFNGLGETSHADERSOURCEPROC glad_glGetShaderSource; +#define glGetShaderSource glad_glGetShaderSource +GLAD_API_CALL PFNGLGETSHADERIVPROC glad_glGetShaderiv; +#define glGetShaderiv glad_glGetShaderiv +GLAD_API_CALL PFNGLGETSTRINGPROC glad_glGetString; +#define glGetString glad_glGetString +GLAD_API_CALL PFNGLGETTEXPARAMETERFVPROC glad_glGetTexParameterfv; +#define glGetTexParameterfv glad_glGetTexParameterfv +GLAD_API_CALL PFNGLGETTEXPARAMETERIVPROC glad_glGetTexParameteriv; +#define glGetTexParameteriv glad_glGetTexParameteriv +GLAD_API_CALL PFNGLGETUNIFORMLOCATIONPROC glad_glGetUniformLocation; +#define glGetUniformLocation glad_glGetUniformLocation +GLAD_API_CALL PFNGLGETUNIFORMFVPROC glad_glGetUniformfv; +#define glGetUniformfv glad_glGetUniformfv +GLAD_API_CALL PFNGLGETUNIFORMIVPROC glad_glGetUniformiv; +#define glGetUniformiv glad_glGetUniformiv +GLAD_API_CALL PFNGLGETVERTEXATTRIBPOINTERVPROC glad_glGetVertexAttribPointerv; +#define glGetVertexAttribPointerv glad_glGetVertexAttribPointerv +GLAD_API_CALL PFNGLGETVERTEXATTRIBFVPROC glad_glGetVertexAttribfv; +#define glGetVertexAttribfv glad_glGetVertexAttribfv +GLAD_API_CALL PFNGLGETVERTEXATTRIBIVPROC glad_glGetVertexAttribiv; +#define glGetVertexAttribiv glad_glGetVertexAttribiv +GLAD_API_CALL PFNGLHINTPROC glad_glHint; +#define glHint glad_glHint +GLAD_API_CALL PFNGLISBUFFERPROC glad_glIsBuffer; +#define glIsBuffer glad_glIsBuffer +GLAD_API_CALL PFNGLISENABLEDPROC glad_glIsEnabled; +#define glIsEnabled glad_glIsEnabled +GLAD_API_CALL PFNGLISFRAMEBUFFERPROC glad_glIsFramebuffer; +#define glIsFramebuffer glad_glIsFramebuffer +GLAD_API_CALL PFNGLISPROGRAMPROC glad_glIsProgram; +#define glIsProgram glad_glIsProgram +GLAD_API_CALL PFNGLISRENDERBUFFERPROC glad_glIsRenderbuffer; +#define glIsRenderbuffer glad_glIsRenderbuffer +GLAD_API_CALL PFNGLISSHADERPROC glad_glIsShader; +#define glIsShader glad_glIsShader +GLAD_API_CALL PFNGLISTEXTUREPROC glad_glIsTexture; +#define glIsTexture glad_glIsTexture +GLAD_API_CALL PFNGLLINEWIDTHPROC glad_glLineWidth; +#define glLineWidth glad_glLineWidth +GLAD_API_CALL PFNGLLINKPROGRAMPROC glad_glLinkProgram; +#define glLinkProgram glad_glLinkProgram +GLAD_API_CALL PFNGLPIXELSTOREIPROC glad_glPixelStorei; +#define glPixelStorei glad_glPixelStorei +GLAD_API_CALL PFNGLPOLYGONOFFSETPROC glad_glPolygonOffset; +#define glPolygonOffset glad_glPolygonOffset +GLAD_API_CALL PFNGLREADPIXELSPROC glad_glReadPixels; +#define glReadPixels glad_glReadPixels +GLAD_API_CALL PFNGLRELEASESHADERCOMPILERPROC glad_glReleaseShaderCompiler; +#define glReleaseShaderCompiler glad_glReleaseShaderCompiler +GLAD_API_CALL PFNGLRENDERBUFFERSTORAGEPROC glad_glRenderbufferStorage; +#define glRenderbufferStorage glad_glRenderbufferStorage +GLAD_API_CALL PFNGLSAMPLECOVERAGEPROC glad_glSampleCoverage; +#define glSampleCoverage glad_glSampleCoverage +GLAD_API_CALL PFNGLSCISSORPROC glad_glScissor; +#define glScissor glad_glScissor +GLAD_API_CALL PFNGLSHADERBINARYPROC glad_glShaderBinary; +#define glShaderBinary glad_glShaderBinary +GLAD_API_CALL PFNGLSHADERSOURCEPROC glad_glShaderSource; +#define glShaderSource glad_glShaderSource +GLAD_API_CALL PFNGLSTENCILFUNCPROC glad_glStencilFunc; +#define glStencilFunc glad_glStencilFunc +GLAD_API_CALL PFNGLSTENCILFUNCSEPARATEPROC glad_glStencilFuncSeparate; +#define glStencilFuncSeparate glad_glStencilFuncSeparate +GLAD_API_CALL PFNGLSTENCILMASKPROC glad_glStencilMask; +#define glStencilMask glad_glStencilMask +GLAD_API_CALL PFNGLSTENCILMASKSEPARATEPROC glad_glStencilMaskSeparate; +#define glStencilMaskSeparate glad_glStencilMaskSeparate +GLAD_API_CALL PFNGLSTENCILOPPROC glad_glStencilOp; +#define glStencilOp glad_glStencilOp +GLAD_API_CALL PFNGLSTENCILOPSEPARATEPROC glad_glStencilOpSeparate; +#define glStencilOpSeparate glad_glStencilOpSeparate +GLAD_API_CALL PFNGLTEXIMAGE2DPROC glad_glTexImage2D; +#define glTexImage2D glad_glTexImage2D +GLAD_API_CALL PFNGLTEXPARAMETERFPROC glad_glTexParameterf; +#define glTexParameterf glad_glTexParameterf +GLAD_API_CALL PFNGLTEXPARAMETERFVPROC glad_glTexParameterfv; +#define glTexParameterfv glad_glTexParameterfv +GLAD_API_CALL PFNGLTEXPARAMETERIPROC glad_glTexParameteri; +#define glTexParameteri glad_glTexParameteri +GLAD_API_CALL PFNGLTEXPARAMETERIVPROC glad_glTexParameteriv; +#define glTexParameteriv glad_glTexParameteriv +GLAD_API_CALL PFNGLTEXSUBIMAGE2DPROC glad_glTexSubImage2D; +#define glTexSubImage2D glad_glTexSubImage2D +GLAD_API_CALL PFNGLUNIFORM1FPROC glad_glUniform1f; +#define glUniform1f glad_glUniform1f +GLAD_API_CALL PFNGLUNIFORM1FVPROC glad_glUniform1fv; +#define glUniform1fv glad_glUniform1fv +GLAD_API_CALL PFNGLUNIFORM1IPROC glad_glUniform1i; +#define glUniform1i glad_glUniform1i +GLAD_API_CALL PFNGLUNIFORM1IVPROC glad_glUniform1iv; +#define glUniform1iv glad_glUniform1iv +GLAD_API_CALL PFNGLUNIFORM2FPROC glad_glUniform2f; +#define glUniform2f glad_glUniform2f +GLAD_API_CALL PFNGLUNIFORM2FVPROC glad_glUniform2fv; +#define glUniform2fv glad_glUniform2fv +GLAD_API_CALL PFNGLUNIFORM2IPROC glad_glUniform2i; +#define glUniform2i glad_glUniform2i +GLAD_API_CALL PFNGLUNIFORM2IVPROC glad_glUniform2iv; +#define glUniform2iv glad_glUniform2iv +GLAD_API_CALL PFNGLUNIFORM3FPROC glad_glUniform3f; +#define glUniform3f glad_glUniform3f +GLAD_API_CALL PFNGLUNIFORM3FVPROC glad_glUniform3fv; +#define glUniform3fv glad_glUniform3fv +GLAD_API_CALL PFNGLUNIFORM3IPROC glad_glUniform3i; +#define glUniform3i glad_glUniform3i +GLAD_API_CALL PFNGLUNIFORM3IVPROC glad_glUniform3iv; +#define glUniform3iv glad_glUniform3iv +GLAD_API_CALL PFNGLUNIFORM4FPROC glad_glUniform4f; +#define glUniform4f glad_glUniform4f +GLAD_API_CALL PFNGLUNIFORM4FVPROC glad_glUniform4fv; +#define glUniform4fv glad_glUniform4fv +GLAD_API_CALL PFNGLUNIFORM4IPROC glad_glUniform4i; +#define glUniform4i glad_glUniform4i +GLAD_API_CALL PFNGLUNIFORM4IVPROC glad_glUniform4iv; +#define glUniform4iv glad_glUniform4iv +GLAD_API_CALL PFNGLUNIFORMMATRIX2FVPROC glad_glUniformMatrix2fv; +#define glUniformMatrix2fv glad_glUniformMatrix2fv +GLAD_API_CALL PFNGLUNIFORMMATRIX3FVPROC glad_glUniformMatrix3fv; +#define glUniformMatrix3fv glad_glUniformMatrix3fv +GLAD_API_CALL PFNGLUNIFORMMATRIX4FVPROC glad_glUniformMatrix4fv; +#define glUniformMatrix4fv glad_glUniformMatrix4fv +GLAD_API_CALL PFNGLUSEPROGRAMPROC glad_glUseProgram; +#define glUseProgram glad_glUseProgram +GLAD_API_CALL PFNGLVALIDATEPROGRAMPROC glad_glValidateProgram; +#define glValidateProgram glad_glValidateProgram +GLAD_API_CALL PFNGLVERTEXATTRIB1FPROC glad_glVertexAttrib1f; +#define glVertexAttrib1f glad_glVertexAttrib1f +GLAD_API_CALL PFNGLVERTEXATTRIB1FVPROC glad_glVertexAttrib1fv; +#define glVertexAttrib1fv glad_glVertexAttrib1fv +GLAD_API_CALL PFNGLVERTEXATTRIB2FPROC glad_glVertexAttrib2f; +#define glVertexAttrib2f glad_glVertexAttrib2f +GLAD_API_CALL PFNGLVERTEXATTRIB2FVPROC glad_glVertexAttrib2fv; +#define glVertexAttrib2fv glad_glVertexAttrib2fv +GLAD_API_CALL PFNGLVERTEXATTRIB3FPROC glad_glVertexAttrib3f; +#define glVertexAttrib3f glad_glVertexAttrib3f +GLAD_API_CALL PFNGLVERTEXATTRIB3FVPROC glad_glVertexAttrib3fv; +#define glVertexAttrib3fv glad_glVertexAttrib3fv +GLAD_API_CALL PFNGLVERTEXATTRIB4FPROC glad_glVertexAttrib4f; +#define glVertexAttrib4f glad_glVertexAttrib4f +GLAD_API_CALL PFNGLVERTEXATTRIB4FVPROC glad_glVertexAttrib4fv; +#define glVertexAttrib4fv glad_glVertexAttrib4fv +GLAD_API_CALL PFNGLVERTEXATTRIBPOINTERPROC glad_glVertexAttribPointer; +#define glVertexAttribPointer glad_glVertexAttribPointer +GLAD_API_CALL PFNGLVIEWPORTPROC glad_glViewport; +#define glViewport glad_glViewport + + + + + +GLAD_API_CALL int gladLoadGLES2UserPtr( GLADuserptrloadfunc load, void *userptr); +GLAD_API_CALL int gladLoadGLES2( GLADloadfunc load); + + + +#ifdef __cplusplus +} +#endif +#endif + +/* Source */ +#ifdef GLAD_GLES2_IMPLEMENTATION +#include +#include +#include + +#ifndef GLAD_IMPL_UTIL_C_ +#define GLAD_IMPL_UTIL_C_ + +#ifdef _MSC_VER +#define GLAD_IMPL_UTIL_SSCANF sscanf_s +#else +#define GLAD_IMPL_UTIL_SSCANF sscanf +#endif + +#endif /* GLAD_IMPL_UTIL_C_ */ + +#ifdef __cplusplus +extern "C" { +#endif + + + +int GLAD_GL_ES_VERSION_2_0 = 0; + + + +PFNGLACTIVETEXTUREPROC glad_glActiveTexture = NULL; +PFNGLATTACHSHADERPROC glad_glAttachShader = NULL; +PFNGLBINDATTRIBLOCATIONPROC glad_glBindAttribLocation = NULL; +PFNGLBINDBUFFERPROC glad_glBindBuffer = NULL; +PFNGLBINDFRAMEBUFFERPROC glad_glBindFramebuffer = NULL; +PFNGLBINDRENDERBUFFERPROC glad_glBindRenderbuffer = NULL; +PFNGLBINDTEXTUREPROC glad_glBindTexture = NULL; +PFNGLBLENDCOLORPROC glad_glBlendColor = NULL; +PFNGLBLENDEQUATIONPROC glad_glBlendEquation = NULL; +PFNGLBLENDEQUATIONSEPARATEPROC glad_glBlendEquationSeparate = NULL; +PFNGLBLENDFUNCPROC glad_glBlendFunc = NULL; +PFNGLBLENDFUNCSEPARATEPROC glad_glBlendFuncSeparate = NULL; +PFNGLBUFFERDATAPROC glad_glBufferData = NULL; +PFNGLBUFFERSUBDATAPROC glad_glBufferSubData = NULL; +PFNGLCHECKFRAMEBUFFERSTATUSPROC glad_glCheckFramebufferStatus = NULL; +PFNGLCLEARPROC glad_glClear = NULL; +PFNGLCLEARCOLORPROC glad_glClearColor = NULL; +PFNGLCLEARDEPTHFPROC glad_glClearDepthf = NULL; +PFNGLCLEARSTENCILPROC glad_glClearStencil = NULL; +PFNGLCOLORMASKPROC glad_glColorMask = NULL; +PFNGLCOMPILESHADERPROC glad_glCompileShader = NULL; +PFNGLCOMPRESSEDTEXIMAGE2DPROC glad_glCompressedTexImage2D = NULL; +PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC glad_glCompressedTexSubImage2D = NULL; +PFNGLCOPYTEXIMAGE2DPROC glad_glCopyTexImage2D = NULL; +PFNGLCOPYTEXSUBIMAGE2DPROC glad_glCopyTexSubImage2D = NULL; +PFNGLCREATEPROGRAMPROC glad_glCreateProgram = NULL; +PFNGLCREATESHADERPROC glad_glCreateShader = NULL; +PFNGLCULLFACEPROC glad_glCullFace = NULL; +PFNGLDELETEBUFFERSPROC glad_glDeleteBuffers = NULL; +PFNGLDELETEFRAMEBUFFERSPROC glad_glDeleteFramebuffers = NULL; +PFNGLDELETEPROGRAMPROC glad_glDeleteProgram = NULL; +PFNGLDELETERENDERBUFFERSPROC glad_glDeleteRenderbuffers = NULL; +PFNGLDELETESHADERPROC glad_glDeleteShader = NULL; +PFNGLDELETETEXTURESPROC glad_glDeleteTextures = NULL; +PFNGLDEPTHFUNCPROC glad_glDepthFunc = NULL; +PFNGLDEPTHMASKPROC glad_glDepthMask = NULL; +PFNGLDEPTHRANGEFPROC glad_glDepthRangef = NULL; +PFNGLDETACHSHADERPROC glad_glDetachShader = NULL; +PFNGLDISABLEPROC glad_glDisable = NULL; +PFNGLDISABLEVERTEXATTRIBARRAYPROC glad_glDisableVertexAttribArray = NULL; +PFNGLDRAWARRAYSPROC glad_glDrawArrays = NULL; +PFNGLDRAWELEMENTSPROC glad_glDrawElements = NULL; +PFNGLENABLEPROC glad_glEnable = NULL; +PFNGLENABLEVERTEXATTRIBARRAYPROC glad_glEnableVertexAttribArray = NULL; +PFNGLFINISHPROC glad_glFinish = NULL; +PFNGLFLUSHPROC glad_glFlush = NULL; +PFNGLFRAMEBUFFERRENDERBUFFERPROC glad_glFramebufferRenderbuffer = NULL; +PFNGLFRAMEBUFFERTEXTURE2DPROC glad_glFramebufferTexture2D = NULL; +PFNGLFRONTFACEPROC glad_glFrontFace = NULL; +PFNGLGENBUFFERSPROC glad_glGenBuffers = NULL; +PFNGLGENFRAMEBUFFERSPROC glad_glGenFramebuffers = NULL; +PFNGLGENRENDERBUFFERSPROC glad_glGenRenderbuffers = NULL; +PFNGLGENTEXTURESPROC glad_glGenTextures = NULL; +PFNGLGENERATEMIPMAPPROC glad_glGenerateMipmap = NULL; +PFNGLGETACTIVEATTRIBPROC glad_glGetActiveAttrib = NULL; +PFNGLGETACTIVEUNIFORMPROC glad_glGetActiveUniform = NULL; +PFNGLGETATTACHEDSHADERSPROC glad_glGetAttachedShaders = NULL; +PFNGLGETATTRIBLOCATIONPROC glad_glGetAttribLocation = NULL; +PFNGLGETBOOLEANVPROC glad_glGetBooleanv = NULL; +PFNGLGETBUFFERPARAMETERIVPROC glad_glGetBufferParameteriv = NULL; +PFNGLGETERRORPROC glad_glGetError = NULL; +PFNGLGETFLOATVPROC glad_glGetFloatv = NULL; +PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC glad_glGetFramebufferAttachmentParameteriv = NULL; +PFNGLGETINTEGERVPROC glad_glGetIntegerv = NULL; +PFNGLGETPROGRAMINFOLOGPROC glad_glGetProgramInfoLog = NULL; +PFNGLGETPROGRAMIVPROC glad_glGetProgramiv = NULL; +PFNGLGETRENDERBUFFERPARAMETERIVPROC glad_glGetRenderbufferParameteriv = NULL; +PFNGLGETSHADERINFOLOGPROC glad_glGetShaderInfoLog = NULL; +PFNGLGETSHADERPRECISIONFORMATPROC glad_glGetShaderPrecisionFormat = NULL; +PFNGLGETSHADERSOURCEPROC glad_glGetShaderSource = NULL; +PFNGLGETSHADERIVPROC glad_glGetShaderiv = NULL; +PFNGLGETSTRINGPROC glad_glGetString = NULL; +PFNGLGETTEXPARAMETERFVPROC glad_glGetTexParameterfv = NULL; +PFNGLGETTEXPARAMETERIVPROC glad_glGetTexParameteriv = NULL; +PFNGLGETUNIFORMLOCATIONPROC glad_glGetUniformLocation = NULL; +PFNGLGETUNIFORMFVPROC glad_glGetUniformfv = NULL; +PFNGLGETUNIFORMIVPROC glad_glGetUniformiv = NULL; +PFNGLGETVERTEXATTRIBPOINTERVPROC glad_glGetVertexAttribPointerv = NULL; +PFNGLGETVERTEXATTRIBFVPROC glad_glGetVertexAttribfv = NULL; +PFNGLGETVERTEXATTRIBIVPROC glad_glGetVertexAttribiv = NULL; +PFNGLHINTPROC glad_glHint = NULL; +PFNGLISBUFFERPROC glad_glIsBuffer = NULL; +PFNGLISENABLEDPROC glad_glIsEnabled = NULL; +PFNGLISFRAMEBUFFERPROC glad_glIsFramebuffer = NULL; +PFNGLISPROGRAMPROC glad_glIsProgram = NULL; +PFNGLISRENDERBUFFERPROC glad_glIsRenderbuffer = NULL; +PFNGLISSHADERPROC glad_glIsShader = NULL; +PFNGLISTEXTUREPROC glad_glIsTexture = NULL; +PFNGLLINEWIDTHPROC glad_glLineWidth = NULL; +PFNGLLINKPROGRAMPROC glad_glLinkProgram = NULL; +PFNGLPIXELSTOREIPROC glad_glPixelStorei = NULL; +PFNGLPOLYGONOFFSETPROC glad_glPolygonOffset = NULL; +PFNGLREADPIXELSPROC glad_glReadPixels = NULL; +PFNGLRELEASESHADERCOMPILERPROC glad_glReleaseShaderCompiler = NULL; +PFNGLRENDERBUFFERSTORAGEPROC glad_glRenderbufferStorage = NULL; +PFNGLSAMPLECOVERAGEPROC glad_glSampleCoverage = NULL; +PFNGLSCISSORPROC glad_glScissor = NULL; +PFNGLSHADERBINARYPROC glad_glShaderBinary = NULL; +PFNGLSHADERSOURCEPROC glad_glShaderSource = NULL; +PFNGLSTENCILFUNCPROC glad_glStencilFunc = NULL; +PFNGLSTENCILFUNCSEPARATEPROC glad_glStencilFuncSeparate = NULL; +PFNGLSTENCILMASKPROC glad_glStencilMask = NULL; +PFNGLSTENCILMASKSEPARATEPROC glad_glStencilMaskSeparate = NULL; +PFNGLSTENCILOPPROC glad_glStencilOp = NULL; +PFNGLSTENCILOPSEPARATEPROC glad_glStencilOpSeparate = NULL; +PFNGLTEXIMAGE2DPROC glad_glTexImage2D = NULL; +PFNGLTEXPARAMETERFPROC glad_glTexParameterf = NULL; +PFNGLTEXPARAMETERFVPROC glad_glTexParameterfv = NULL; +PFNGLTEXPARAMETERIPROC glad_glTexParameteri = NULL; +PFNGLTEXPARAMETERIVPROC glad_glTexParameteriv = NULL; +PFNGLTEXSUBIMAGE2DPROC glad_glTexSubImage2D = NULL; +PFNGLUNIFORM1FPROC glad_glUniform1f = NULL; +PFNGLUNIFORM1FVPROC glad_glUniform1fv = NULL; +PFNGLUNIFORM1IPROC glad_glUniform1i = NULL; +PFNGLUNIFORM1IVPROC glad_glUniform1iv = NULL; +PFNGLUNIFORM2FPROC glad_glUniform2f = NULL; +PFNGLUNIFORM2FVPROC glad_glUniform2fv = NULL; +PFNGLUNIFORM2IPROC glad_glUniform2i = NULL; +PFNGLUNIFORM2IVPROC glad_glUniform2iv = NULL; +PFNGLUNIFORM3FPROC glad_glUniform3f = NULL; +PFNGLUNIFORM3FVPROC glad_glUniform3fv = NULL; +PFNGLUNIFORM3IPROC glad_glUniform3i = NULL; +PFNGLUNIFORM3IVPROC glad_glUniform3iv = NULL; +PFNGLUNIFORM4FPROC glad_glUniform4f = NULL; +PFNGLUNIFORM4FVPROC glad_glUniform4fv = NULL; +PFNGLUNIFORM4IPROC glad_glUniform4i = NULL; +PFNGLUNIFORM4IVPROC glad_glUniform4iv = NULL; +PFNGLUNIFORMMATRIX2FVPROC glad_glUniformMatrix2fv = NULL; +PFNGLUNIFORMMATRIX3FVPROC glad_glUniformMatrix3fv = NULL; +PFNGLUNIFORMMATRIX4FVPROC glad_glUniformMatrix4fv = NULL; +PFNGLUSEPROGRAMPROC glad_glUseProgram = NULL; +PFNGLVALIDATEPROGRAMPROC glad_glValidateProgram = NULL; +PFNGLVERTEXATTRIB1FPROC glad_glVertexAttrib1f = NULL; +PFNGLVERTEXATTRIB1FVPROC glad_glVertexAttrib1fv = NULL; +PFNGLVERTEXATTRIB2FPROC glad_glVertexAttrib2f = NULL; +PFNGLVERTEXATTRIB2FVPROC glad_glVertexAttrib2fv = NULL; +PFNGLVERTEXATTRIB3FPROC glad_glVertexAttrib3f = NULL; +PFNGLVERTEXATTRIB3FVPROC glad_glVertexAttrib3fv = NULL; +PFNGLVERTEXATTRIB4FPROC glad_glVertexAttrib4f = NULL; +PFNGLVERTEXATTRIB4FVPROC glad_glVertexAttrib4fv = NULL; +PFNGLVERTEXATTRIBPOINTERPROC glad_glVertexAttribPointer = NULL; +PFNGLVIEWPORTPROC glad_glViewport = NULL; + + +static void glad_gl_load_GL_ES_VERSION_2_0( GLADuserptrloadfunc load, void* userptr) { + if(!GLAD_GL_ES_VERSION_2_0) return; + glad_glActiveTexture = (PFNGLACTIVETEXTUREPROC) load(userptr, "glActiveTexture"); + glad_glAttachShader = (PFNGLATTACHSHADERPROC) load(userptr, "glAttachShader"); + glad_glBindAttribLocation = (PFNGLBINDATTRIBLOCATIONPROC) load(userptr, "glBindAttribLocation"); + glad_glBindBuffer = (PFNGLBINDBUFFERPROC) load(userptr, "glBindBuffer"); + glad_glBindFramebuffer = (PFNGLBINDFRAMEBUFFERPROC) load(userptr, "glBindFramebuffer"); + glad_glBindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC) load(userptr, "glBindRenderbuffer"); + glad_glBindTexture = (PFNGLBINDTEXTUREPROC) load(userptr, "glBindTexture"); + glad_glBlendColor = (PFNGLBLENDCOLORPROC) load(userptr, "glBlendColor"); + glad_glBlendEquation = (PFNGLBLENDEQUATIONPROC) load(userptr, "glBlendEquation"); + glad_glBlendEquationSeparate = (PFNGLBLENDEQUATIONSEPARATEPROC) load(userptr, "glBlendEquationSeparate"); + glad_glBlendFunc = (PFNGLBLENDFUNCPROC) load(userptr, "glBlendFunc"); + glad_glBlendFuncSeparate = (PFNGLBLENDFUNCSEPARATEPROC) load(userptr, "glBlendFuncSeparate"); + glad_glBufferData = (PFNGLBUFFERDATAPROC) load(userptr, "glBufferData"); + glad_glBufferSubData = (PFNGLBUFFERSUBDATAPROC) load(userptr, "glBufferSubData"); + glad_glCheckFramebufferStatus = (PFNGLCHECKFRAMEBUFFERSTATUSPROC) load(userptr, "glCheckFramebufferStatus"); + glad_glClear = (PFNGLCLEARPROC) load(userptr, "glClear"); + glad_glClearColor = (PFNGLCLEARCOLORPROC) load(userptr, "glClearColor"); + glad_glClearDepthf = (PFNGLCLEARDEPTHFPROC) load(userptr, "glClearDepthf"); + glad_glClearStencil = (PFNGLCLEARSTENCILPROC) load(userptr, "glClearStencil"); + glad_glColorMask = (PFNGLCOLORMASKPROC) load(userptr, "glColorMask"); + glad_glCompileShader = (PFNGLCOMPILESHADERPROC) load(userptr, "glCompileShader"); + glad_glCompressedTexImage2D = (PFNGLCOMPRESSEDTEXIMAGE2DPROC) load(userptr, "glCompressedTexImage2D"); + glad_glCompressedTexSubImage2D = (PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) load(userptr, "glCompressedTexSubImage2D"); + glad_glCopyTexImage2D = (PFNGLCOPYTEXIMAGE2DPROC) load(userptr, "glCopyTexImage2D"); + glad_glCopyTexSubImage2D = (PFNGLCOPYTEXSUBIMAGE2DPROC) load(userptr, "glCopyTexSubImage2D"); + glad_glCreateProgram = (PFNGLCREATEPROGRAMPROC) load(userptr, "glCreateProgram"); + glad_glCreateShader = (PFNGLCREATESHADERPROC) load(userptr, "glCreateShader"); + glad_glCullFace = (PFNGLCULLFACEPROC) load(userptr, "glCullFace"); + glad_glDeleteBuffers = (PFNGLDELETEBUFFERSPROC) load(userptr, "glDeleteBuffers"); + glad_glDeleteFramebuffers = (PFNGLDELETEFRAMEBUFFERSPROC) load(userptr, "glDeleteFramebuffers"); + glad_glDeleteProgram = (PFNGLDELETEPROGRAMPROC) load(userptr, "glDeleteProgram"); + glad_glDeleteRenderbuffers = (PFNGLDELETERENDERBUFFERSPROC) load(userptr, "glDeleteRenderbuffers"); + glad_glDeleteShader = (PFNGLDELETESHADERPROC) load(userptr, "glDeleteShader"); + glad_glDeleteTextures = (PFNGLDELETETEXTURESPROC) load(userptr, "glDeleteTextures"); + glad_glDepthFunc = (PFNGLDEPTHFUNCPROC) load(userptr, "glDepthFunc"); + glad_glDepthMask = (PFNGLDEPTHMASKPROC) load(userptr, "glDepthMask"); + glad_glDepthRangef = (PFNGLDEPTHRANGEFPROC) load(userptr, "glDepthRangef"); + glad_glDetachShader = (PFNGLDETACHSHADERPROC) load(userptr, "glDetachShader"); + glad_glDisable = (PFNGLDISABLEPROC) load(userptr, "glDisable"); + glad_glDisableVertexAttribArray = (PFNGLDISABLEVERTEXATTRIBARRAYPROC) load(userptr, "glDisableVertexAttribArray"); + glad_glDrawArrays = (PFNGLDRAWARRAYSPROC) load(userptr, "glDrawArrays"); + glad_glDrawElements = (PFNGLDRAWELEMENTSPROC) load(userptr, "glDrawElements"); + glad_glEnable = (PFNGLENABLEPROC) load(userptr, "glEnable"); + glad_glEnableVertexAttribArray = (PFNGLENABLEVERTEXATTRIBARRAYPROC) load(userptr, "glEnableVertexAttribArray"); + glad_glFinish = (PFNGLFINISHPROC) load(userptr, "glFinish"); + glad_glFlush = (PFNGLFLUSHPROC) load(userptr, "glFlush"); + glad_glFramebufferRenderbuffer = (PFNGLFRAMEBUFFERRENDERBUFFERPROC) load(userptr, "glFramebufferRenderbuffer"); + glad_glFramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DPROC) load(userptr, "glFramebufferTexture2D"); + glad_glFrontFace = (PFNGLFRONTFACEPROC) load(userptr, "glFrontFace"); + glad_glGenBuffers = (PFNGLGENBUFFERSPROC) load(userptr, "glGenBuffers"); + glad_glGenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC) load(userptr, "glGenFramebuffers"); + glad_glGenRenderbuffers = (PFNGLGENRENDERBUFFERSPROC) load(userptr, "glGenRenderbuffers"); + glad_glGenTextures = (PFNGLGENTEXTURESPROC) load(userptr, "glGenTextures"); + glad_glGenerateMipmap = (PFNGLGENERATEMIPMAPPROC) load(userptr, "glGenerateMipmap"); + glad_glGetActiveAttrib = (PFNGLGETACTIVEATTRIBPROC) load(userptr, "glGetActiveAttrib"); + glad_glGetActiveUniform = (PFNGLGETACTIVEUNIFORMPROC) load(userptr, "glGetActiveUniform"); + glad_glGetAttachedShaders = (PFNGLGETATTACHEDSHADERSPROC) load(userptr, "glGetAttachedShaders"); + glad_glGetAttribLocation = (PFNGLGETATTRIBLOCATIONPROC) load(userptr, "glGetAttribLocation"); + glad_glGetBooleanv = (PFNGLGETBOOLEANVPROC) load(userptr, "glGetBooleanv"); + glad_glGetBufferParameteriv = (PFNGLGETBUFFERPARAMETERIVPROC) load(userptr, "glGetBufferParameteriv"); + glad_glGetError = (PFNGLGETERRORPROC) load(userptr, "glGetError"); + glad_glGetFloatv = (PFNGLGETFLOATVPROC) load(userptr, "glGetFloatv"); + glad_glGetFramebufferAttachmentParameteriv = (PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC) load(userptr, "glGetFramebufferAttachmentParameteriv"); + glad_glGetIntegerv = (PFNGLGETINTEGERVPROC) load(userptr, "glGetIntegerv"); + glad_glGetProgramInfoLog = (PFNGLGETPROGRAMINFOLOGPROC) load(userptr, "glGetProgramInfoLog"); + glad_glGetProgramiv = (PFNGLGETPROGRAMIVPROC) load(userptr, "glGetProgramiv"); + glad_glGetRenderbufferParameteriv = (PFNGLGETRENDERBUFFERPARAMETERIVPROC) load(userptr, "glGetRenderbufferParameteriv"); + glad_glGetShaderInfoLog = (PFNGLGETSHADERINFOLOGPROC) load(userptr, "glGetShaderInfoLog"); + glad_glGetShaderPrecisionFormat = (PFNGLGETSHADERPRECISIONFORMATPROC) load(userptr, "glGetShaderPrecisionFormat"); + glad_glGetShaderSource = (PFNGLGETSHADERSOURCEPROC) load(userptr, "glGetShaderSource"); + glad_glGetShaderiv = (PFNGLGETSHADERIVPROC) load(userptr, "glGetShaderiv"); + glad_glGetString = (PFNGLGETSTRINGPROC) load(userptr, "glGetString"); + glad_glGetTexParameterfv = (PFNGLGETTEXPARAMETERFVPROC) load(userptr, "glGetTexParameterfv"); + glad_glGetTexParameteriv = (PFNGLGETTEXPARAMETERIVPROC) load(userptr, "glGetTexParameteriv"); + glad_glGetUniformLocation = (PFNGLGETUNIFORMLOCATIONPROC) load(userptr, "glGetUniformLocation"); + glad_glGetUniformfv = (PFNGLGETUNIFORMFVPROC) load(userptr, "glGetUniformfv"); + glad_glGetUniformiv = (PFNGLGETUNIFORMIVPROC) load(userptr, "glGetUniformiv"); + glad_glGetVertexAttribPointerv = (PFNGLGETVERTEXATTRIBPOINTERVPROC) load(userptr, "glGetVertexAttribPointerv"); + glad_glGetVertexAttribfv = (PFNGLGETVERTEXATTRIBFVPROC) load(userptr, "glGetVertexAttribfv"); + glad_glGetVertexAttribiv = (PFNGLGETVERTEXATTRIBIVPROC) load(userptr, "glGetVertexAttribiv"); + glad_glHint = (PFNGLHINTPROC) load(userptr, "glHint"); + glad_glIsBuffer = (PFNGLISBUFFERPROC) load(userptr, "glIsBuffer"); + glad_glIsEnabled = (PFNGLISENABLEDPROC) load(userptr, "glIsEnabled"); + glad_glIsFramebuffer = (PFNGLISFRAMEBUFFERPROC) load(userptr, "glIsFramebuffer"); + glad_glIsProgram = (PFNGLISPROGRAMPROC) load(userptr, "glIsProgram"); + glad_glIsRenderbuffer = (PFNGLISRENDERBUFFERPROC) load(userptr, "glIsRenderbuffer"); + glad_glIsShader = (PFNGLISSHADERPROC) load(userptr, "glIsShader"); + glad_glIsTexture = (PFNGLISTEXTUREPROC) load(userptr, "glIsTexture"); + glad_glLineWidth = (PFNGLLINEWIDTHPROC) load(userptr, "glLineWidth"); + glad_glLinkProgram = (PFNGLLINKPROGRAMPROC) load(userptr, "glLinkProgram"); + glad_glPixelStorei = (PFNGLPIXELSTOREIPROC) load(userptr, "glPixelStorei"); + glad_glPolygonOffset = (PFNGLPOLYGONOFFSETPROC) load(userptr, "glPolygonOffset"); + glad_glReadPixels = (PFNGLREADPIXELSPROC) load(userptr, "glReadPixels"); + glad_glReleaseShaderCompiler = (PFNGLRELEASESHADERCOMPILERPROC) load(userptr, "glReleaseShaderCompiler"); + glad_glRenderbufferStorage = (PFNGLRENDERBUFFERSTORAGEPROC) load(userptr, "glRenderbufferStorage"); + glad_glSampleCoverage = (PFNGLSAMPLECOVERAGEPROC) load(userptr, "glSampleCoverage"); + glad_glScissor = (PFNGLSCISSORPROC) load(userptr, "glScissor"); + glad_glShaderBinary = (PFNGLSHADERBINARYPROC) load(userptr, "glShaderBinary"); + glad_glShaderSource = (PFNGLSHADERSOURCEPROC) load(userptr, "glShaderSource"); + glad_glStencilFunc = (PFNGLSTENCILFUNCPROC) load(userptr, "glStencilFunc"); + glad_glStencilFuncSeparate = (PFNGLSTENCILFUNCSEPARATEPROC) load(userptr, "glStencilFuncSeparate"); + glad_glStencilMask = (PFNGLSTENCILMASKPROC) load(userptr, "glStencilMask"); + glad_glStencilMaskSeparate = (PFNGLSTENCILMASKSEPARATEPROC) load(userptr, "glStencilMaskSeparate"); + glad_glStencilOp = (PFNGLSTENCILOPPROC) load(userptr, "glStencilOp"); + glad_glStencilOpSeparate = (PFNGLSTENCILOPSEPARATEPROC) load(userptr, "glStencilOpSeparate"); + glad_glTexImage2D = (PFNGLTEXIMAGE2DPROC) load(userptr, "glTexImage2D"); + glad_glTexParameterf = (PFNGLTEXPARAMETERFPROC) load(userptr, "glTexParameterf"); + glad_glTexParameterfv = (PFNGLTEXPARAMETERFVPROC) load(userptr, "glTexParameterfv"); + glad_glTexParameteri = (PFNGLTEXPARAMETERIPROC) load(userptr, "glTexParameteri"); + glad_glTexParameteriv = (PFNGLTEXPARAMETERIVPROC) load(userptr, "glTexParameteriv"); + glad_glTexSubImage2D = (PFNGLTEXSUBIMAGE2DPROC) load(userptr, "glTexSubImage2D"); + glad_glUniform1f = (PFNGLUNIFORM1FPROC) load(userptr, "glUniform1f"); + glad_glUniform1fv = (PFNGLUNIFORM1FVPROC) load(userptr, "glUniform1fv"); + glad_glUniform1i = (PFNGLUNIFORM1IPROC) load(userptr, "glUniform1i"); + glad_glUniform1iv = (PFNGLUNIFORM1IVPROC) load(userptr, "glUniform1iv"); + glad_glUniform2f = (PFNGLUNIFORM2FPROC) load(userptr, "glUniform2f"); + glad_glUniform2fv = (PFNGLUNIFORM2FVPROC) load(userptr, "glUniform2fv"); + glad_glUniform2i = (PFNGLUNIFORM2IPROC) load(userptr, "glUniform2i"); + glad_glUniform2iv = (PFNGLUNIFORM2IVPROC) load(userptr, "glUniform2iv"); + glad_glUniform3f = (PFNGLUNIFORM3FPROC) load(userptr, "glUniform3f"); + glad_glUniform3fv = (PFNGLUNIFORM3FVPROC) load(userptr, "glUniform3fv"); + glad_glUniform3i = (PFNGLUNIFORM3IPROC) load(userptr, "glUniform3i"); + glad_glUniform3iv = (PFNGLUNIFORM3IVPROC) load(userptr, "glUniform3iv"); + glad_glUniform4f = (PFNGLUNIFORM4FPROC) load(userptr, "glUniform4f"); + glad_glUniform4fv = (PFNGLUNIFORM4FVPROC) load(userptr, "glUniform4fv"); + glad_glUniform4i = (PFNGLUNIFORM4IPROC) load(userptr, "glUniform4i"); + glad_glUniform4iv = (PFNGLUNIFORM4IVPROC) load(userptr, "glUniform4iv"); + glad_glUniformMatrix2fv = (PFNGLUNIFORMMATRIX2FVPROC) load(userptr, "glUniformMatrix2fv"); + glad_glUniformMatrix3fv = (PFNGLUNIFORMMATRIX3FVPROC) load(userptr, "glUniformMatrix3fv"); + glad_glUniformMatrix4fv = (PFNGLUNIFORMMATRIX4FVPROC) load(userptr, "glUniformMatrix4fv"); + glad_glUseProgram = (PFNGLUSEPROGRAMPROC) load(userptr, "glUseProgram"); + glad_glValidateProgram = (PFNGLVALIDATEPROGRAMPROC) load(userptr, "glValidateProgram"); + glad_glVertexAttrib1f = (PFNGLVERTEXATTRIB1FPROC) load(userptr, "glVertexAttrib1f"); + glad_glVertexAttrib1fv = (PFNGLVERTEXATTRIB1FVPROC) load(userptr, "glVertexAttrib1fv"); + glad_glVertexAttrib2f = (PFNGLVERTEXATTRIB2FPROC) load(userptr, "glVertexAttrib2f"); + glad_glVertexAttrib2fv = (PFNGLVERTEXATTRIB2FVPROC) load(userptr, "glVertexAttrib2fv"); + glad_glVertexAttrib3f = (PFNGLVERTEXATTRIB3FPROC) load(userptr, "glVertexAttrib3f"); + glad_glVertexAttrib3fv = (PFNGLVERTEXATTRIB3FVPROC) load(userptr, "glVertexAttrib3fv"); + glad_glVertexAttrib4f = (PFNGLVERTEXATTRIB4FPROC) load(userptr, "glVertexAttrib4f"); + glad_glVertexAttrib4fv = (PFNGLVERTEXATTRIB4FVPROC) load(userptr, "glVertexAttrib4fv"); + glad_glVertexAttribPointer = (PFNGLVERTEXATTRIBPOINTERPROC) load(userptr, "glVertexAttribPointer"); + glad_glViewport = (PFNGLVIEWPORTPROC) load(userptr, "glViewport"); +} + + + +#if defined(GL_ES_VERSION_3_0) || defined(GL_VERSION_3_0) +#define GLAD_GL_IS_SOME_NEW_VERSION 1 +#else +#define GLAD_GL_IS_SOME_NEW_VERSION 0 +#endif + +static int glad_gl_get_extensions( int version, const char **out_exts, unsigned int *out_num_exts_i, char ***out_exts_i) { +#if GLAD_GL_IS_SOME_NEW_VERSION + if(GLAD_VERSION_MAJOR(version) < 3) { +#else + (void) version; + (void) out_num_exts_i; + (void) out_exts_i; +#endif + if (glad_glGetString == NULL) { + return 0; + } + *out_exts = (const char *)glad_glGetString(GL_EXTENSIONS); +#if GLAD_GL_IS_SOME_NEW_VERSION + } else { + unsigned int index = 0; + unsigned int num_exts_i = 0; + char **exts_i = NULL; + if (glad_glGetStringi == NULL || glad_glGetIntegerv == NULL) { + return 0; + } + glad_glGetIntegerv(GL_NUM_EXTENSIONS, (int*) &num_exts_i); + if (num_exts_i > 0) { + exts_i = (char **) malloc(num_exts_i * (sizeof *exts_i)); + } + if (exts_i == NULL) { + return 0; + } + for(index = 0; index < num_exts_i; index++) { + const char *gl_str_tmp = (const char*) glad_glGetStringi(GL_EXTENSIONS, index); + size_t len = strlen(gl_str_tmp) + 1; + + char *local_str = (char*) malloc(len * sizeof(char)); + if(local_str != NULL) { + memcpy(local_str, gl_str_tmp, len * sizeof(char)); + } + + exts_i[index] = local_str; + } + + *out_num_exts_i = num_exts_i; + *out_exts_i = exts_i; + } +#endif + return 1; +} +static void glad_gl_free_extensions(char **exts_i, unsigned int num_exts_i) { + if (exts_i != NULL) { + unsigned int index; + for(index = 0; index < num_exts_i; index++) { + free((void *) (exts_i[index])); + } + free((void *)exts_i); + exts_i = NULL; + } +} +static int glad_gl_has_extension(int version, const char *exts, unsigned int num_exts_i, char **exts_i, const char *ext) { + if(GLAD_VERSION_MAJOR(version) < 3 || !GLAD_GL_IS_SOME_NEW_VERSION) { + const char *extensions; + const char *loc; + const char *terminator; + extensions = exts; + if(extensions == NULL || ext == NULL) { + return 0; + } + while(1) { + loc = strstr(extensions, ext); + if(loc == NULL) { + return 0; + } + terminator = loc + strlen(ext); + if((loc == extensions || *(loc - 1) == ' ') && + (*terminator == ' ' || *terminator == '\0')) { + return 1; + } + extensions = terminator; + } + } else { + unsigned int index; + for(index = 0; index < num_exts_i; index++) { + const char *e = exts_i[index]; + if(strcmp(e, ext) == 0) { + return 1; + } + } + } + return 0; +} + +static GLADapiproc glad_gl_get_proc_from_userptr(void *userptr, const char* name) { + return (GLAD_GNUC_EXTENSION (GLADapiproc (*)(const char *name)) userptr)(name); +} + +static int glad_gl_find_extensions_gles2( int version) { + const char *exts = NULL; + unsigned int num_exts_i = 0; + char **exts_i = NULL; + if (!glad_gl_get_extensions(version, &exts, &num_exts_i, &exts_i)) return 0; + + (void) glad_gl_has_extension; + + glad_gl_free_extensions(exts_i, num_exts_i); + + return 1; +} + +static int glad_gl_find_core_gles2(void) { + int i; + const char* version; + const char* prefixes[] = { + "OpenGL ES-CM ", + "OpenGL ES-CL ", + "OpenGL ES ", + "OpenGL SC ", + NULL + }; + int major = 0; + int minor = 0; + version = (const char*) glad_glGetString(GL_VERSION); + if (!version) return 0; + for (i = 0; prefixes[i]; i++) { + const size_t length = strlen(prefixes[i]); + if (strncmp(version, prefixes[i], length) == 0) { + version += length; + break; + } + } + + GLAD_IMPL_UTIL_SSCANF(version, "%d.%d", &major, &minor); + + GLAD_GL_ES_VERSION_2_0 = (major == 2 && minor >= 0) || major > 2; + + return GLAD_MAKE_VERSION(major, minor); +} + +int gladLoadGLES2UserPtr( GLADuserptrloadfunc load, void *userptr) { + int version; + + glad_glGetString = (PFNGLGETSTRINGPROC) load(userptr, "glGetString"); + if(glad_glGetString == NULL) return 0; + if(glad_glGetString(GL_VERSION) == NULL) return 0; + version = glad_gl_find_core_gles2(); + + glad_gl_load_GL_ES_VERSION_2_0(load, userptr); + + if (!glad_gl_find_extensions_gles2(version)) return 0; + + + + return version; +} + + +int gladLoadGLES2( GLADloadfunc load) { + return gladLoadGLES2UserPtr( glad_gl_get_proc_from_userptr, GLAD_GNUC_EXTENSION (void*) load); +} + + + + + + +#ifdef __cplusplus +} +#endif + +#endif /* GLAD_GLES2_IMPLEMENTATION */ + diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 547f1412..be8927db 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -19,6 +19,7 @@ elseif (APPLE) endif() set(GLAD_GL "${GLFW_SOURCE_DIR}/deps/glad/gl.h") +set(GLAD_GLES2 "${GLFW_SOURCE_DIR}/deps/glad/gles2.h") set(GETOPT "${GLFW_SOURCE_DIR}/deps/getopt.h" "${GLFW_SOURCE_DIR}/deps/getopt.c") set(TINYCTHREAD "${GLFW_SOURCE_DIR}/deps/tinycthread.h" @@ -32,6 +33,7 @@ add_executable(particles WIN32 MACOSX_BUNDLE particles.c ${ICON} ${TINYCTHREAD} add_executable(sharing WIN32 MACOSX_BUNDLE sharing.c ${ICON} ${GLAD_GL}) add_executable(splitview WIN32 MACOSX_BUNDLE splitview.c ${ICON} ${GLAD_GL}) add_executable(triangle-opengl WIN32 MACOSX_BUNDLE triangle-opengl.c ${ICON} ${GLAD_GL}) +add_executable(triangle-opengles WIN32 MACOSX_BUNDLE triangle-opengles.c ${ICON} ${GLAD_GLES2}) add_executable(wave WIN32 MACOSX_BUNDLE wave.c ${ICON} ${GLAD_GL}) add_executable(windows WIN32 MACOSX_BUNDLE windows.c ${ICON} ${GLAD_GL}) @@ -41,7 +43,7 @@ if (RT_LIBRARY) endif() set(GUI_ONLY_BINARIES boing gears heightmap particles sharing splitview - triangle-opengl wave windows) + triangle-opengl triangle-opengles wave windows) set(CONSOLE_BINARIES offscreen) set_target_properties(${GUI_ONLY_BINARIES} ${CONSOLE_BINARIES} PROPERTIES @@ -70,6 +72,7 @@ if (APPLE) set_target_properties(particles PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Particles") set_target_properties(sharing PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Sharing") set_target_properties(triangle-opengl PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "OpenGL Triangle") + set_target_properties(triangle-opengles PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "OpenGL ES Triangle") set_target_properties(splitview PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "SplitView") set_target_properties(wave PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Wave") set_target_properties(windows PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Windows") diff --git a/examples/triangle-opengles.c b/examples/triangle-opengles.c new file mode 100644 index 00000000..03eb026f --- /dev/null +++ b/examples/triangle-opengles.c @@ -0,0 +1,170 @@ +//======================================================================== +// OpenGL ES 2.0 triangle example +// Copyright (c) Camilla Löwy +// +// This software is provided 'as-is', without any express or implied +// warranty. In no event will the authors be held liable for any damages +// arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it +// freely, subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; you must not +// claim that you wrote the original software. If you use this software +// in a product, an acknowledgment in the product documentation would +// be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, and must not +// be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source +// distribution. +// +//======================================================================== + +#define GLAD_GLES2_IMPLEMENTATION +#include +#define GLFW_INCLUDE_NONE +#include + +#include "linmath.h" + +#include +#include +#include + +typedef struct Vertex +{ + vec2 pos; + vec3 col; +} Vertex; + +static const Vertex vertices[3] = +{ + { { -0.6f, -0.4f }, { 1.f, 0.f, 0.f } }, + { { 0.6f, -0.4f }, { 0.f, 1.f, 0.f } }, + { { 0.f, 0.6f }, { 0.f, 0.f, 1.f } } +}; + +static const char* vertex_shader_text = +"#version 100\n" +"precision mediump float;\n" +"uniform mat4 MVP;\n" +"attribute vec3 vCol;\n" +"attribute vec2 vPos;\n" +"varying vec3 color;\n" +"void main()\n" +"{\n" +" gl_Position = MVP * vec4(vPos, 0.0, 1.0);\n" +" color = vCol;\n" +"}\n"; + +static const char* fragment_shader_text = +"#version 100\n" +"precision mediump float;\n" +"varying vec3 color;\n" +"void main()\n" +"{\n" +" gl_FragColor = vec4(color, 1.0);\n" +"}\n"; + +static void error_callback(int error, const char* description) +{ + fprintf(stderr, "GLFW Error: %s\n", description); +} + +static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) +{ + if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS) + glfwSetWindowShouldClose(window, GLFW_TRUE); +} + +int main(void) +{ + glfwSetErrorCallback(error_callback); + + if (!glfwInit()) + exit(EXIT_FAILURE); + + glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_ES_API); + glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2); + glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0); + glfwWindowHint(GLFW_CONTEXT_CREATION_API, GLFW_EGL_CONTEXT_API); + + GLFWwindow* window = glfwCreateWindow(640, 480, "OpenGL ES 2.0 Triangle (EGL)", NULL, NULL); + if (!window) + { + glfwWindowHint(GLFW_CONTEXT_CREATION_API, GLFW_NATIVE_CONTEXT_API); + window = glfwCreateWindow(640, 480, "OpenGL ES 2.0 Triangle", NULL, NULL); + if (!window) + { + glfwTerminate(); + exit(EXIT_FAILURE); + } + } + + glfwSetKeyCallback(window, key_callback); + + glfwMakeContextCurrent(window); + gladLoadGLES2(glfwGetProcAddress); + glfwSwapInterval(1); + + GLuint vertex_buffer; + glGenBuffers(1, &vertex_buffer); + glBindBuffer(GL_ARRAY_BUFFER, vertex_buffer); + glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW); + + const GLuint vertex_shader = glCreateShader(GL_VERTEX_SHADER); + glShaderSource(vertex_shader, 1, &vertex_shader_text, NULL); + glCompileShader(vertex_shader); + + const GLuint fragment_shader = glCreateShader(GL_FRAGMENT_SHADER); + glShaderSource(fragment_shader, 1, &fragment_shader_text, NULL); + glCompileShader(fragment_shader); + + const GLuint program = glCreateProgram(); + glAttachShader(program, vertex_shader); + glAttachShader(program, fragment_shader); + glLinkProgram(program); + + const GLint mvp_location = glGetUniformLocation(program, "MVP"); + const GLint vpos_location = glGetAttribLocation(program, "vPos"); + const GLint vcol_location = glGetAttribLocation(program, "vCol"); + + glEnableVertexAttribArray(vpos_location); + glEnableVertexAttribArray(vcol_location); + glVertexAttribPointer(vpos_location, 2, GL_FLOAT, GL_FALSE, + sizeof(Vertex), (void*) offsetof(Vertex, pos)); + glVertexAttribPointer(vcol_location, 3, GL_FLOAT, GL_FALSE, + sizeof(Vertex), (void*) offsetof(Vertex, col)); + + while (!glfwWindowShouldClose(window)) + { + int width, height; + glfwGetFramebufferSize(window, &width, &height); + const float ratio = width / (float) height; + + glViewport(0, 0, width, height); + glClear(GL_COLOR_BUFFER_BIT); + + mat4x4 m, p, mvp; + mat4x4_identity(m); + mat4x4_rotate_Z(m, m, (float) glfwGetTime()); + mat4x4_ortho(p, -ratio, ratio, -1.f, 1.f, 1.f, -1.f); + mat4x4_mul(mvp, p, m); + + glUseProgram(program); + glUniformMatrix4fv(mvp_location, 1, GL_FALSE, (const GLfloat*) &mvp); + glDrawArrays(GL_TRIANGLES, 0, 3); + + glfwSwapBuffers(window); + glfwPollEvents(); + } + + glfwDestroyWindow(window); + + glfwTerminate(); + exit(EXIT_SUCCESS); +} + From 63da04e5ced93fcb87a20513acdff5d78b1166ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 26 Aug 2021 17:41:20 +0200 Subject: [PATCH 019/208] Add HTML header and footer to docs dependencies This should have been included in 150744ecca502c9af0631233d9d398fdf773a4db. --- docs/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt index 19694085..79cad560 100644 --- a/docs/CMakeLists.txt +++ b/docs/CMakeLists.txt @@ -17,7 +17,7 @@ set(source_files compat.dox internal.dox) -set(extra_files DoxygenLayout.xml extra.css spaces.svg) +set(extra_files DoxygenLayout.xml header.html footer.html extra.css spaces.svg) set(header_paths "${GLFW_SOURCE_DIR}/include/GLFW/glfw3.h" From 216d5e8402513b582563d5b8433fefb449a1593e Mon Sep 17 00:00:00 2001 From: Koray Kilinc Date: Tue, 1 Jun 2021 13:40:44 -0700 Subject: [PATCH 020/208] Wayland: Fix some keys not repeating According to the libxkbcommon documentation[1], xkb_keymap_key_repeats requires keymap and keycode as input: int xkb_keymap_key_repeats( struct xkb_keymap * keymap, xkb_keycode_t key) However, in inputChar in wl_input.c we are passing in xkb_keysym_t, which was a type mismatch. This results in some keys not repeating when they should and vice versa. [1] https://xkbcommon.org/doc/current/group__components.html#ga9d7f998efeca98b3afc7c257bbac90a8 Closes #1908. --- README.md | 2 ++ src/wl_init.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2ddb647f..cb19510a 100644 --- a/README.md +++ b/README.md @@ -245,6 +245,7 @@ information on what to include when reporting a bug. - [Wayland] Bugfix: Client-Side Decorations were destroyed in the wrong worder (#1798) - [Wayland] Bugfix: Monitors physical size could report zero (#1784,#1792) + - [Wayland] Bugfix: Some keys were not repeating in Wayland (#1908) - [POSIX] Removed use of deprecated function `gettimeofday` - [POSIX] Bugfix: `CLOCK_MONOTONIC` was not correctly tested for or enabled - [NSGL] Removed enforcement of forward-compatible flag for core contexts @@ -357,6 +358,7 @@ skills. - Arseny Kapoulkine - Cem Karan - Osman Keskin + - Koray Kilinc - Josh Kilmer - Byunghoon Kim - Cameron King diff --git a/src/wl_init.c b/src/wl_init.c index f80b4950..ac938795 100644 --- a/src/wl_init.c +++ b/src/wl_init.c @@ -565,7 +565,7 @@ static GLFWbool inputChar(_GLFWwindow* window, uint32_t key) } } - return xkb_keymap_key_repeats(_glfw.wl.xkb.keymap, syms[0]); + return xkb_keymap_key_repeats(_glfw.wl.xkb.keymap, code); } static void keyboardHandleKey(void* data, From 4cbe743b74993bc97829dded273d557b0209940f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 2 Sep 2021 18:30:41 +0200 Subject: [PATCH 021/208] Wayland: Fix standard cursor name selection Regression introduced by 08e5a1706318e4fd32366a88d0778a9f545175af. --- src/wl_window.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/wl_window.c b/src/wl_window.c index dd6f26d5..618c8e7f 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -1299,18 +1299,25 @@ int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape) { case GLFW_ARROW_CURSOR: name = "left_ptr"; + break; case GLFW_IBEAM_CURSOR: name = "xterm"; + break; case GLFW_CROSSHAIR_CURSOR: name = "crosshair"; + break; case GLFW_POINTING_HAND_CURSOR: name = "hand2"; + break; case GLFW_RESIZE_EW_CURSOR: name = "sb_h_double_arrow"; + break; case GLFW_RESIZE_NS_CURSOR: name = "sb_v_double_arrow"; + break; case GLFW_RESIZE_ALL_CURSOR: name = "fleur"; + break; default: _glfwInputError(GLFW_CURSOR_UNAVAILABLE, "Wayland: Standard cursor shape unavailable"); From e7758c506dfcf258566f866c761c1b6bd7d98011 Mon Sep 17 00:00:00 2001 From: Waris Boonyasiriwat Date: Wed, 12 May 2021 00:30:14 -0700 Subject: [PATCH 022/208] Wayland: Fix cursor offset when shape changes The Wayland protocol spec[1] states that set_cursor must be called with the serial number of the enter event. However, GLFW is passing in the serial number of the latest received event, which does not meet the protocol spec. [1] https://wayland.freedesktop.org/docs/html/apa.html#protocol-spec-wl_pointer As a result, set_cursor calls were simply ignored by the compositor. This fix complies with the protocol more closely by specifically caching the enter event serial, and using it for all set_cursor calls. Fixes #1706 Closes #1899 --- README.md | 4 +++- src/wl_init.c | 3 ++- src/wl_platform.h | 1 + src/wl_window.c | 6 +++--- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index cb19510a..5d9ff571 100644 --- a/README.md +++ b/README.md @@ -246,6 +246,7 @@ information on what to include when reporting a bug. (#1798) - [Wayland] Bugfix: Monitors physical size could report zero (#1784,#1792) - [Wayland] Bugfix: Some keys were not repeating in Wayland (#1908) + - [Wayland] Bugfix: Non-arrow cursors are offset from the hotspot (#1706,#1899) - [POSIX] Removed use of deprecated function `gettimeofday` - [POSIX] Bugfix: `CLOCK_MONOTONIC` was not correctly tested for or enabled - [NSGL] Removed enforcement of forward-compatible flag for core contexts @@ -298,6 +299,7 @@ skills. - Denis Bernard - Doug Binks - blanco + - Waris Boonyasiriwat - Kyle Brenneman - Rok Breulj - Kai Burjack @@ -306,6 +308,7 @@ skills. - David Carlier - Arturo Castro - Chi-kwan Chan + - Joseph Chua - Ian Clarkson - Michał Cichoń - Lambert Clara @@ -481,7 +484,6 @@ skills. - Torsten Walluhn - Patrick Walton - Xo Wang - - Waris - Jay Weisskopf - Frank Wille - Andy Williams diff --git a/src/wl_init.c b/src/wl_init.c index ac938795..2c73a7a9 100644 --- a/src/wl_init.c +++ b/src/wl_init.c @@ -118,6 +118,7 @@ static void pointerHandleEnter(void* data, window->wl.decorations.focus = focus; _glfw.wl.serial = serial; + _glfw.wl.pointerEnterSerial = serial; _glfw.wl.pointerFocus = window; window->wl.hovered = GLFW_TRUE; @@ -177,7 +178,7 @@ static void setCursor(_GLFWwindow* window, const char* name) buffer = wl_cursor_image_get_buffer(image); if (!buffer) return; - wl_pointer_set_cursor(_glfw.wl.pointer, _glfw.wl.serial, + wl_pointer_set_cursor(_glfw.wl.pointer, _glfw.wl.pointerEnterSerial, surface, image->hotspot_x / scale, image->hotspot_y / scale); diff --git a/src/wl_platform.h b/src/wl_platform.h index a24943c9..d6017513 100644 --- a/src/wl_platform.h +++ b/src/wl_platform.h @@ -317,6 +317,7 @@ typedef struct _GLFWlibraryWayland const char* cursorPreviousName; int cursorTimerfd; uint32_t serial; + uint32_t pointerEnterSerial; int32_t keyboardRepeatRate; int32_t keyboardRepeatDelay; diff --git a/src/wl_window.c b/src/wl_window.c index 618c8e7f..06cd7084 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -683,7 +683,7 @@ static void setCursorImage(_GLFWwindow* window, cursorWayland->yhot = image->hotspot_y; } - wl_pointer_set_cursor(_glfw.wl.pointer, _glfw.wl.serial, + wl_pointer_set_cursor(_glfw.wl.pointer, _glfw.wl.pointerEnterSerial, surface, cursorWayland->xhot / scale, cursorWayland->yhot / scale); @@ -1455,7 +1455,7 @@ static void lockPointer(_GLFWwindow* window) window->wl.pointerLock.relativePointer = relativePointer; window->wl.pointerLock.lockedPointer = lockedPointer; - wl_pointer_set_cursor(_glfw.wl.pointer, _glfw.wl.serial, + wl_pointer_set_cursor(_glfw.wl.pointer, _glfw.wl.pointerEnterSerial, NULL, 0, 0); } @@ -1519,7 +1519,7 @@ void _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor) } else if (window->cursorMode == GLFW_CURSOR_HIDDEN) { - wl_pointer_set_cursor(_glfw.wl.pointer, _glfw.wl.serial, NULL, 0, 0); + wl_pointer_set_cursor(_glfw.wl.pointer, _glfw.wl.pointerEnterSerial, NULL, 0, 0); } } From 157ebb80aafe263b86fd450f21a193f0412fb717 Mon Sep 17 00:00:00 2001 From: Ioannis Tsakpinis Date: Sun, 5 Sep 2021 22:58:53 +0300 Subject: [PATCH 023/208] Cocoa: Fix unresponsive cursor after ungrab There is a suppression interval (0.25 seconds by default) after a call to CGWarpMouseCursorPosition, during which local hardware events (keyboard and mouse) are ignored. GLFW already calls CGEventSourceSetLocalEventsSuppressionInterval with a value of 0.0, but it doesn't help in this case, there is still a short delay before the cursor can be moved. Moving the CGAssociateMouseAndMouseCursorPosition call after the cursor position has been restored, fixes the issue. Closes #1962 --- src/cocoa_window.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cocoa_window.m b/src/cocoa_window.m index 6ab0ffa6..9408e572 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -114,10 +114,10 @@ static void updateCursorMode(_GLFWwindow* window) else if (_glfw.ns.disabledCursorWindow == window) { _glfw.ns.disabledCursorWindow = NULL; - CGAssociateMouseAndMouseCursorPosition(true); _glfwPlatformSetCursorPos(window, _glfw.ns.restoreCursorPosX, _glfw.ns.restoreCursorPosY); + CGAssociateMouseAndMouseCursorPosition(true); } if (cursorInContentArea(window)) From 6ed5294223fec513c3b1e95f1857b3104e2e9b86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Sun, 12 Sep 2021 17:15:59 +0200 Subject: [PATCH 024/208] Cocoa: Fix unresponsive cursor after cursor warp This is a companion to 157ebb80aafe263b86fd450f21a193f0412fb717 and fixes the same issue for calls to glfwSetCursorPos. Related to #1962 --- README.md | 2 ++ src/cocoa_window.m | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5d9ff571..0e075ee3 100644 --- a/README.md +++ b/README.md @@ -206,6 +206,8 @@ information on what to include when reporting a bug. - [Cocoa] Bugfix: The install name of the installed dylib was relative (#1504) - [Cocoa] Bugfix: The MoltenVK layer contents scale was updated only after related events were emitted + - [Cocoa] Bugfix: Moving the cursor programmatically would freeze it for + a fraction of a second (#1962) - [X11] Bugfix: The CMake files did not check for the XInput headers (#1480) - [X11] Bugfix: Key names were not updated when the keyboard layout changed (#1462,#1528) diff --git a/src/cocoa_window.m b/src/cocoa_window.m index 9408e572..49b50749 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -117,7 +117,8 @@ static void updateCursorMode(_GLFWwindow* window) _glfwPlatformSetCursorPos(window, _glfw.ns.restoreCursorPosX, _glfw.ns.restoreCursorPosY); - CGAssociateMouseAndMouseCursorPosition(true); + // NOTE: The matching CGAssociateMouseAndMouseCursorPosition call is + // made in _glfwPlatformSetCursorPos as part of a workaround } if (cursorInContentArea(window)) @@ -1518,6 +1519,11 @@ void _glfwPlatformSetCursorPos(_GLFWwindow* window, double x, double y) _glfwTransformYNS(globalPoint.y))); } + // HACK: Calling this right after setting the cursor position prevents macOS + // from freezing the cursor for a fraction of a second afterwards + if (window->cursorMode != GLFW_CURSOR_DISABLED) + CGAssociateMouseAndMouseCursorPosition(true); + } // autoreleasepool } From 7614d088e94ad7e245ea00f77f982c8709adb060 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 5 Oct 2021 18:11:00 +0200 Subject: [PATCH 025/208] Fix string buffer sizes in window test --- tests/window.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/window.c b/tests/window.c index 075d3887..3e2bc671 100644 --- a/tests/window.c +++ b/tests/window.c @@ -56,11 +56,11 @@ int main(int argc, char** argv) int limit_aspect_ratio = false, aspect_numer = 1, aspect_denom = 1; int limit_min_size = false, min_width = 400, min_height = 400; int limit_max_size = false, max_width = 400, max_height = 400; - char width_buffer[10] = "", height_buffer[10] = ""; - char xpos_buffer[10] = "", ypos_buffer[10] = ""; - char numer_buffer[10] = "", denom_buffer[10] = ""; - char min_width_buffer[10] = "", min_height_buffer[10] = ""; - char max_width_buffer[10] = "", max_height_buffer[10] = ""; + char width_buffer[12] = "", height_buffer[12] = ""; + char xpos_buffer[12] = "", ypos_buffer[12] = ""; + char numer_buffer[12] = "", denom_buffer[12] = ""; + char min_width_buffer[12] = "", min_height_buffer[12] = ""; + char max_width_buffer[12] = "", max_height_buffer[12] = ""; int may_close = true; if (!glfwInit()) From 6a200531026f383d7f5c260ae802c43be80c2cd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 12 Oct 2021 00:23:37 +0200 Subject: [PATCH 026/208] Fix docs for Windows monitor size calculation This sentence was truncated by 951a9583faf91bdbe96bacd5d24a8969c0cca418 and then not updated when content scale support was added with 16bf872117896fb88493403157fcd367303fd1f6. --- include/GLFW/glfw3.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index 95aac6d9..b41a6ef9 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -2440,8 +2440,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. * From 4be0444ee6462e9c06098462c9e2797f666798ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 12 Oct 2021 12:54:19 +0200 Subject: [PATCH 027/208] Remove potentially incorrect claim --- include/GLFW/glfw3.h | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index b41a6ef9..443af7cd 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -5992,13 +5992,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. From 1d8d1ff3d0b7dac3b3196eda02b063661872aad6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 6 Oct 2021 19:49:34 +0200 Subject: [PATCH 028/208] Fix output for missing Vulkan surface extensions When the Vulkan loader is present but there are no required surface extensions, as will for example happen with the Null platform, glfwinfo caused an error in glfwGetPhysicalDevicePresentationSupport and produced confusing output. --- tests/glfwinfo.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/tests/glfwinfo.c b/tests/glfwinfo.c index 87ed385f..dea3ac22 100644 --- a/tests/glfwinfo.c +++ b/tests/glfwinfo.c @@ -954,14 +954,17 @@ int main(int argc, char** argv) uint32_t qfp_count; vkGetPhysicalDeviceQueueFamilyProperties(pd[i], &qfp_count, NULL); - printf("Vulkan device queue family presentation support:\n"); - for (uint32_t j = 0; j < qfp_count; j++) + if (re) { - printf(" %u: ", j); - if (glfwGetPhysicalDevicePresentationSupport(instance, pd[i], j)) - printf("supported\n"); - else - printf("no\n"); + printf("Vulkan device queue family presentation support:\n"); + for (uint32_t j = 0; j < qfp_count; j++) + { + printf(" %u: ", j); + if (glfwGetPhysicalDevicePresentationSupport(instance, pd[i], j)) + printf("supported\n"); + else + printf("no\n"); + } } if (list_extensions) From 0391b7b27785f509261a96ae41d878f159458037 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 4 Oct 2021 13:21:36 +0200 Subject: [PATCH 029/208] Remove Doxyfile tags deprecated by Doxygen 1.9.2 --- docs/Doxyfile.in | 37 ------------------------------------- 1 file changed, 37 deletions(-) diff --git a/docs/Doxyfile.in b/docs/Doxyfile.in index f5504a83..ef711cd7 100644 --- a/docs/Doxyfile.in +++ b/docs/Doxyfile.in @@ -93,14 +93,6 @@ ALLOW_UNICODE_NAMES = NO OUTPUT_LANGUAGE = English -# The OUTPUT_TEXT_DIRECTION tag is used to specify the direction in which all -# documentation generated by doxygen is written. Doxygen will use this -# information to generate all generated output in the proper direction. -# Possible values are: None, LTR, RTL and Context. -# The default value is: None. - -OUTPUT_TEXT_DIRECTION = None - # If the BRIEF_MEMBER_DESC tag is set to YES, doxygen will include brief member # descriptions after the members that are listed in the file and class # documentation (similar to Javadoc). Set to NO to disable this. @@ -1811,16 +1803,6 @@ LATEX_BATCHMODE = NO LATEX_HIDE_INDICES = NO -# If the LATEX_SOURCE_CODE tag is set to YES then doxygen will include source -# code with syntax highlighting in the LaTeX output. -# -# Note that which sources are shown also depends on other settings such as -# SOURCE_BROWSER. -# The default value is: NO. -# This tag requires that the tag GENERATE_LATEX is set to YES. - -LATEX_SOURCE_CODE = NO - # The LATEX_BIB_STYLE tag can be used to specify the style to use for the # bibliography, e.g. plainnat, or ieeetr. See # https://en.wikipedia.org/wiki/BibTeX and \cite for more info. @@ -1901,16 +1883,6 @@ RTF_STYLESHEET_FILE = RTF_EXTENSIONS_FILE = -# If the RTF_SOURCE_CODE tag is set to YES then doxygen will include source code -# with syntax highlighting in the RTF output. -# -# Note that which sources are shown also depends on other settings such as -# SOURCE_BROWSER. -# The default value is: NO. -# This tag requires that the tag GENERATE_RTF is set to YES. - -RTF_SOURCE_CODE = NO - #--------------------------------------------------------------------------- # Configuration options related to the man page output #--------------------------------------------------------------------------- @@ -2007,15 +1979,6 @@ GENERATE_DOCBOOK = NO DOCBOOK_OUTPUT = docbook -# If the DOCBOOK_PROGRAMLISTING tag is set to YES, doxygen will include the -# program listings (including syntax highlighting and cross-referencing -# information) to the DOCBOOK output. Note that enabling this will significantly -# increase the size of the DOCBOOK output. -# The default value is: NO. -# This tag requires that the tag GENERATE_DOCBOOK is set to YES. - -DOCBOOK_PROGRAMLISTING = NO - #--------------------------------------------------------------------------- # Configuration options for the AutoGen Definitions output #--------------------------------------------------------------------------- From cca9008db29f697dd3dc6d23dc149c1b3d29aa00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 4 Oct 2021 20:32:32 +0200 Subject: [PATCH 030/208] Make native access functions verify context API The native access functions for context handles did not verify that the context had been created with the same API the function was for. This makes these functions emit GLFW_NO_WINDOW_CONTEXT on API mismatch. --- README.md | 1 + src/egl_context.c | 4 ++-- src/glx_context.c | 4 ++-- src/nsgl_context.m | 2 +- src/osmesa_context.c | 14 +++++++++++++- src/wgl_context.c | 2 +- 6 files changed, 20 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 0e075ee3..ea83adac 100644 --- a/README.md +++ b/README.md @@ -150,6 +150,7 @@ information on what to include when reporting a bug. - Bugfix: Buffers were swapped at creation on single-buffered windows (#1873) - Bugfix: Gamepad mapping updates could spam `GLFW_INVALID_VALUE` due to incompatible controllers sharing hardware ID (#1763) + - Bugfix: Native access functions for context handles did not check that the API matched - [Win32] Added the `GLFW_WIN32_KEYBOARD_MENU` window hint for enabling access to the window menu - [Win32] Added a version info resource to the GLFW DLL diff --git a/src/egl_context.c b/src/egl_context.c index 264b233a..d25c5bd1 100644 --- a/src/egl_context.c +++ b/src/egl_context.c @@ -821,7 +821,7 @@ GLFWAPI EGLContext glfwGetEGLContext(GLFWwindow* handle) _GLFWwindow* window = (_GLFWwindow*) handle; _GLFW_REQUIRE_INIT_OR_RETURN(EGL_NO_CONTEXT); - if (window->context.client == GLFW_NO_API) + if (window->context.client != GLFW_EGL_CONTEXT_API) { _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL); return EGL_NO_CONTEXT; @@ -835,7 +835,7 @@ GLFWAPI EGLSurface glfwGetEGLSurface(GLFWwindow* handle) _GLFWwindow* window = (_GLFWwindow*) handle; _GLFW_REQUIRE_INIT_OR_RETURN(EGL_NO_SURFACE); - if (window->context.client == GLFW_NO_API) + if (window->context.client != GLFW_EGL_CONTEXT_API) { _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL); return EGL_NO_SURFACE; diff --git a/src/glx_context.c b/src/glx_context.c index 7207cd55..1abc1797 100644 --- a/src/glx_context.c +++ b/src/glx_context.c @@ -674,7 +674,7 @@ GLFWAPI GLXContext glfwGetGLXContext(GLFWwindow* handle) _GLFWwindow* window = (_GLFWwindow*) handle; _GLFW_REQUIRE_INIT_OR_RETURN(NULL); - if (window->context.client == GLFW_NO_API) + if (window->context.client != GLFW_NATIVE_CONTEXT_API) { _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL); return NULL; @@ -688,7 +688,7 @@ GLFWAPI GLXWindow glfwGetGLXWindow(GLFWwindow* handle) _GLFWwindow* window = (_GLFWwindow*) handle; _GLFW_REQUIRE_INIT_OR_RETURN(None); - if (window->context.client == GLFW_NO_API) + if (window->context.client != GLFW_NATIVE_CONTEXT_API) { _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL); return None; diff --git a/src/nsgl_context.m b/src/nsgl_context.m index 3f73f7a6..940ee848 100644 --- a/src/nsgl_context.m +++ b/src/nsgl_context.m @@ -358,7 +358,7 @@ GLFWAPI id glfwGetNSGLContext(GLFWwindow* handle) _GLFWwindow* window = (_GLFWwindow*) handle; _GLFW_REQUIRE_INIT_OR_RETURN(nil); - if (window->context.client == GLFW_NO_API) + if (window->context.client != GLFW_NATIVE_CONTEXT_API) { _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL); return nil; diff --git a/src/osmesa_context.c b/src/osmesa_context.c index 74a9291b..da39ffcf 100644 --- a/src/osmesa_context.c +++ b/src/osmesa_context.c @@ -302,6 +302,12 @@ GLFWAPI int glfwGetOSMesaColorBuffer(GLFWwindow* handle, int* width, _GLFW_REQUIRE_INIT_OR_RETURN(GLFW_FALSE); + if (window->context.client != GLFW_OSMESA_CONTEXT_API) + { + _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL); + return GLFW_FALSE; + } + if (!OSMesaGetColorBuffer(window->context.osmesa.handle, &mesaWidth, &mesaHeight, &mesaFormat, &mesaBuffer)) @@ -335,6 +341,12 @@ GLFWAPI int glfwGetOSMesaDepthBuffer(GLFWwindow* handle, _GLFW_REQUIRE_INIT_OR_RETURN(GLFW_FALSE); + if (window->context.client != GLFW_OSMESA_CONTEXT_API) + { + _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL); + return GLFW_FALSE; + } + if (!OSMesaGetDepthBuffer(window->context.osmesa.handle, &mesaWidth, &mesaHeight, &mesaBytes, &mesaBuffer)) @@ -361,7 +373,7 @@ GLFWAPI OSMesaContext glfwGetOSMesaContext(GLFWwindow* handle) _GLFWwindow* window = (_GLFWwindow*) handle; _GLFW_REQUIRE_INIT_OR_RETURN(NULL); - if (window->context.client == GLFW_NO_API) + if (window->context.client != GLFW_OSMESA_CONTEXT_API) { _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL); return NULL; diff --git a/src/wgl_context.c b/src/wgl_context.c index 62055847..2c452661 100644 --- a/src/wgl_context.c +++ b/src/wgl_context.c @@ -786,7 +786,7 @@ GLFWAPI HGLRC glfwGetWGLContext(GLFWwindow* handle) _GLFWwindow* window = (_GLFWwindow*) handle; _GLFW_REQUIRE_INIT_OR_RETURN(NULL); - if (window->context.client == GLFW_NO_API) + if (window->context.client != GLFW_NATIVE_CONTEXT_API) { _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL); return NULL; From 983c44b255a322bec7776faa870e43ef492d0656 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 4 Oct 2021 20:39:10 +0200 Subject: [PATCH 031/208] Document possible native access function errors --- include/GLFW/glfw3native.h | 53 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/include/GLFW/glfw3native.h b/include/GLFW/glfw3native.h index 06021ef9..41b2f86b 100644 --- a/include/GLFW/glfw3native.h +++ b/include/GLFW/glfw3native.h @@ -132,6 +132,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. * @@ -147,6 +149,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. * @@ -161,6 +165,8 @@ 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. @@ -185,6 +191,9 @@ 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. @@ -209,6 +218,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. * @@ -223,6 +234,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. * @@ -239,6 +252,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. * @@ -255,6 +271,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. * @@ -269,6 +287,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. * @@ -283,6 +303,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. * @@ -297,6 +319,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. * @@ -363,6 +387,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. * @@ -377,6 +404,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. * @@ -393,6 +423,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. * @@ -407,6 +439,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. * @@ -421,6 +455,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. * @@ -437,6 +473,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. * @@ -451,6 +489,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. * @@ -465,6 +506,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. * @@ -488,6 +532,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. * @@ -509,6 +556,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. * @@ -523,6 +573,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. * From efe764b492b9516e874b2e9b5d4cdc4c48c0e4da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 18 Aug 2021 23:49:03 +0200 Subject: [PATCH 032/208] Remove blank line before the end of some structs --- src/cocoa_platform.h | 5 ----- src/egl_context.h | 2 -- src/glx_context.h | 2 -- src/nsgl_context.h | 2 -- src/osmesa_context.h | 2 -- src/posix_thread.h | 2 -- src/posix_time.h | 1 - src/wgl_context.h | 2 -- src/win32_platform.h | 7 ------- src/wl_platform.h | 5 ----- src/x11_platform.h | 4 ---- 11 files changed, 34 deletions(-) diff --git a/src/cocoa_platform.h b/src/cocoa_platform.h index 64a998ff..f9e80766 100644 --- a/src/cocoa_platform.h +++ b/src/cocoa_platform.h @@ -130,7 +130,6 @@ typedef struct _GLFWwindowNS // since the last cursor motion event was processed // This is kept to counteract Cocoa doing the same internally double cursorWarpDeltaX, cursorWarpDeltaY; - } _GLFWwindowNS; // Cocoa-specific global data @@ -164,7 +163,6 @@ typedef struct _GLFWlibraryNS PFN_LMGetKbdType GetKbdType; CFStringRef kPropertyUnicodeKeyLayoutData; } tis; - } _GLFWlibraryNS; // Cocoa-specific per-monitor data @@ -176,7 +174,6 @@ typedef struct _GLFWmonitorNS uint32_t unitNumber; id screen; double fallbackRefreshRate; - } _GLFWmonitorNS; // Cocoa-specific per-cursor data @@ -184,7 +181,6 @@ typedef struct _GLFWmonitorNS typedef struct _GLFWcursorNS { id object; - } _GLFWcursorNS; // Cocoa-specific global timer data @@ -192,7 +188,6 @@ typedef struct _GLFWcursorNS typedef struct _GLFWtimerNS { uint64_t frequency; - } _GLFWtimerNS; diff --git a/src/egl_context.h b/src/egl_context.h index 4c84072e..22928b5d 100644 --- a/src/egl_context.h +++ b/src/egl_context.h @@ -163,7 +163,6 @@ typedef struct _GLFWcontextEGL EGLSurface surface; void* client; - } _GLFWcontextEGL; // EGL-specific global data @@ -211,7 +210,6 @@ typedef struct _GLFWlibraryEGL PFNEGLGETPLATFORMDISPLAYEXTPROC GetPlatformDisplayEXT; PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC CreatePlatformWindowSurfaceEXT; - } _GLFWlibraryEGL; diff --git a/src/glx_context.h b/src/glx_context.h index 94f07e2e..a50f09bc 100644 --- a/src/glx_context.h +++ b/src/glx_context.h @@ -117,7 +117,6 @@ typedef struct _GLFWcontextGLX { GLXContext handle; GLXWindow window; - } _GLFWcontextGLX; // GLX-specific global data @@ -165,7 +164,6 @@ typedef struct _GLFWlibraryGLX GLFWbool EXT_create_context_es2_profile; GLFWbool ARB_create_context_no_error; GLFWbool ARB_context_flush_control; - } _GLFWlibraryGLX; GLFWbool _glfwInitGLX(void); diff --git a/src/nsgl_context.h b/src/nsgl_context.h index 9c31436c..55b9bf14 100644 --- a/src/nsgl_context.h +++ b/src/nsgl_context.h @@ -44,7 +44,6 @@ typedef struct _GLFWcontextNSGL { id pixelFormat; id object; - } _GLFWcontextNSGL; // NSGL-specific global data @@ -53,7 +52,6 @@ typedef struct _GLFWlibraryNSGL { // dlopen handle for OpenGL.framework (for glfwGetProcAddress) CFBundleRef framework; - } _GLFWlibraryNSGL; diff --git a/src/osmesa_context.h b/src/osmesa_context.h index ce1f1a29..74bc2a99 100644 --- a/src/osmesa_context.h +++ b/src/osmesa_context.h @@ -62,7 +62,6 @@ typedef struct _GLFWcontextOSMesa int width; int height; void* buffer; - } _GLFWcontextOSMesa; // OSMesa-specific global data @@ -78,7 +77,6 @@ typedef struct _GLFWlibraryOSMesa PFN_OSMesaGetColorBuffer GetColorBuffer; PFN_OSMesaGetDepthBuffer GetDepthBuffer; PFN_OSMesaGetProcAddress GetProcAddress; - } _GLFWlibraryOSMesa; diff --git a/src/posix_thread.h b/src/posix_thread.h index 85ce596c..bfb325af 100644 --- a/src/posix_thread.h +++ b/src/posix_thread.h @@ -37,7 +37,6 @@ typedef struct _GLFWtlsPOSIX { GLFWbool allocated; pthread_key_t key; - } _GLFWtlsPOSIX; // POSIX-specific mutex data @@ -46,6 +45,5 @@ typedef struct _GLFWmutexPOSIX { GLFWbool allocated; pthread_mutex_t handle; - } _GLFWmutexPOSIX; diff --git a/src/posix_time.h b/src/posix_time.h index 17805cf6..cc7ba990 100644 --- a/src/posix_time.h +++ b/src/posix_time.h @@ -37,7 +37,6 @@ typedef struct _GLFWtimerPOSIX { clockid_t clock; uint64_t frequency; - } _GLFWtimerPOSIX; diff --git a/src/wgl_context.h b/src/wgl_context.h index 2cf7e4e5..702eaada 100644 --- a/src/wgl_context.h +++ b/src/wgl_context.h @@ -115,7 +115,6 @@ typedef struct _GLFWcontextWGL HDC dc; HGLRC handle; int interval; - } _GLFWcontextWGL; // WGL-specific global data @@ -148,7 +147,6 @@ typedef struct _GLFWlibraryWGL GLFWbool ARB_create_context_robustness; GLFWbool ARB_create_context_no_error; GLFWbool ARB_context_flush_control; - } _GLFWlibraryWGL; diff --git a/src/win32_platform.h b/src/win32_platform.h index a16047ae..500da470 100644 --- a/src/win32_platform.h +++ b/src/win32_platform.h @@ -321,7 +321,6 @@ typedef struct _GLFWwindowWin32 int lastCursorPosX, lastCursorPosY; // The last recevied high surrogate when decoding pairs of UTF-16 messages WCHAR highSurrogate; - } _GLFWwindowWin32; // Win32-specific global data @@ -388,7 +387,6 @@ typedef struct _GLFWlibraryWin32 HINSTANCE instance; PFN_RtlVerifyVersionInfo RtlVerifyVersionInfo_; } ntdll; - } _GLFWlibraryWin32; // Win32-specific per-monitor data @@ -403,7 +401,6 @@ typedef struct _GLFWmonitorWin32 char publicDisplayName[32]; GLFWbool modesPruned; GLFWbool modeChanged; - } _GLFWmonitorWin32; // Win32-specific per-cursor data @@ -411,7 +408,6 @@ typedef struct _GLFWmonitorWin32 typedef struct _GLFWcursorWin32 { HCURSOR handle; - } _GLFWcursorWin32; // Win32-specific global timer data @@ -420,7 +416,6 @@ typedef struct _GLFWtimerWin32 { GLFWbool hasPC; uint64_t frequency; - } _GLFWtimerWin32; // Win32-specific thread local storage data @@ -429,7 +424,6 @@ typedef struct _GLFWtlsWin32 { GLFWbool allocated; DWORD index; - } _GLFWtlsWin32; // Win32-specific mutex data @@ -438,7 +432,6 @@ typedef struct _GLFWmutexWin32 { GLFWbool allocated; CRITICAL_SECTION section; - } _GLFWmutexWin32; diff --git a/src/wl_platform.h b/src/wl_platform.h index d6017513..777ae2e7 100644 --- a/src/wl_platform.h +++ b/src/wl_platform.h @@ -225,7 +225,6 @@ typedef enum _GLFWdecorationSideWayland leftDecoration, rightDecoration, bottomDecoration, - } _GLFWdecorationSideWayland; typedef struct _GLFWdecorationWayland @@ -233,7 +232,6 @@ typedef struct _GLFWdecorationWayland struct wl_surface* surface; struct wl_subsurface* subsurface; struct wp_viewport* viewport; - } _GLFWdecorationWayland; // Wayland-specific per-window data @@ -282,7 +280,6 @@ typedef struct _GLFWwindowWayland _GLFWdecorationWayland top, left, right, bottom; int focus; } decorations; - } _GLFWwindowWayland; // Wayland-specific global data @@ -413,7 +410,6 @@ typedef struct _GLFWlibraryWayland PFN_wl_egl_window_destroy window_destroy; PFN_wl_egl_window_resize window_resize; } egl; - } _GLFWlibraryWayland; // Wayland-specific per-monitor data @@ -427,7 +423,6 @@ typedef struct _GLFWmonitorWayland int x; int y; int scale; - } _GLFWmonitorWayland; // Wayland-specific per-cursor data diff --git a/src/x11_platform.h b/src/x11_platform.h index c5137bc3..2db58eea 100644 --- a/src/x11_platform.h +++ b/src/x11_platform.h @@ -422,7 +422,6 @@ typedef struct _GLFWwindowX11 // The time of the last KeyPress event per keycode, for discarding // duplicate key events generated for some keys by ibus Time keyPressTimes[256]; - } _GLFWwindowX11; // X11-specific global data @@ -751,7 +750,6 @@ typedef struct _GLFWlibraryX11 PFN_XShapeQueryVersion QueryVersion; PFN_XShapeCombineMask ShapeCombineMask; } xshape; - } _GLFWlibraryX11; // X11-specific per-monitor data @@ -765,7 +763,6 @@ typedef struct _GLFWmonitorX11 // Index of corresponding Xinerama screen, // for EWMH full screen window placement int index; - } _GLFWmonitorX11; // X11-specific per-cursor data @@ -773,7 +770,6 @@ typedef struct _GLFWmonitorX11 typedef struct _GLFWcursorX11 { Cursor handle; - } _GLFWcursorX11; From 0a9488e3f0c7c6e63311cd42de6246295b26e29d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 15 Apr 2021 15:33:19 +0200 Subject: [PATCH 033/208] Remove configuration header --- CMakeLists.txt | 24 ++++-------------- README.md | 1 + docs/compile.dox | 9 +++---- docs/internal.dox | 3 +-- src/CMakeLists.txt | 30 ++++++++++++++++++++--- src/glfw_config.h.in | 58 -------------------------------------------- 6 files changed, 37 insertions(+), 88 deletions(-) delete mode 100644 src/glfw_config.h.in diff --git a/CMakeLists.txt b/CMakeLists.txt index e255863b..a7fd9b46 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -61,15 +61,6 @@ else() set(GLFW_LIB_NAME glfw3) endif() -if (GLFW_VULKAN_STATIC) - if (GLFW_BUILD_SHARED_LIBRARY) - # If you absolutely must do this, remove this line and add the Vulkan - # loader static library via the CMAKE_SHARED_LINKER_FLAGS - message(FATAL_ERROR "You are trying to link the Vulkan loader static library into the GLFW shared library") - endif() - set(_GLFW_VULKAN_STATIC 1) -endif() - list(APPEND CMAKE_MODULE_PATH "${GLFW_SOURCE_DIR}/CMake/modules") find_package(Threads REQUIRED) @@ -154,12 +145,7 @@ endif() # Use Win32 for window creation #-------------------------------------------------------------------- if (_GLFW_WIN32) - list(APPEND glfw_PKG_LIBS "-lgdi32") - - if (GLFW_USE_HYBRID_HPG) - set(_GLFW_USE_HYBRID_HPG 1) - endif() endif() #-------------------------------------------------------------------- @@ -217,11 +203,6 @@ if (_GLFW_WAYLAND) list(APPEND glfw_INCLUDE_DIRS "${Wayland_INCLUDE_DIRS}") - include(CheckIncludeFiles) - include(CheckFunctionExists) - check_include_files(xkbcommon/xkbcommon-compose.h HAVE_XKBCOMMON_COMPOSE_H) - check_function_exists(memfd_create HAVE_MEMFD_CREATE) - if (NOT CMAKE_SYSTEM_NAME STREQUAL "Linux") find_package(EpollShim) if (EPOLLSHIM_FOUND) @@ -249,6 +230,11 @@ endif() # Add the Vulkan loader as a dependency if necessary #-------------------------------------------------------------------- if (GLFW_VULKAN_STATIC) + if (BUILD_SHARED_LIBS) + # If you absolutely must do this, remove this line and add the Vulkan + # loader static library via the CMAKE_SHARED_LINKER_FLAGS + message(FATAL_ERROR "You are trying to link the Vulkan loader static library into the GLFW shared library") + endif() list(APPEND glfw_PKG_DEPS "vulkan") endif() diff --git a/README.md b/README.md index ea83adac..4c783f7b 100644 --- a/README.md +++ b/README.md @@ -140,6 +140,7 @@ information on what to include when reporting a bug. - Made `GLFW_DOUBLEBUFFER` a read-only window attribute - Updated the minimum required CMake version to 3.1 - Disabled tests and examples by default when built as a CMake subdirectory + - Removed CMake generated configuration header - Bugfix: The CMake config-file package used an absolute path and was not relocatable (#1470) - Bugfix: Video modes with a duplicate screen area were discarded (#1555,#1556) diff --git a/docs/compile.dox b/docs/compile.dox index d5b839d6..cc32ea68 100644 --- a/docs/compile.dox +++ b/docs/compile.dox @@ -341,11 +341,10 @@ a configuration macro to be defined in order to know what window system it is being compiled for and also has optional, platform-specific ones for various features. -When building with CMake, the `glfw_config.h` configuration header is generated -based on the current platform and CMake options. The GLFW CMake environment -defines @b GLFW_USE_CONFIG_H, which causes this header to be included by -`internal.h`. Without this macro, GLFW will expect the necessary configuration -macros to be defined on the command-line. +When building, GLFW will expect the necessary configuration macros to be defined +on the command-line. The GLFW CMake files set these as private compile +definitions on the GLFW target but if you compile the GLFW sources manually you +will need to define them yourself. The window creation API is used to create windows, handle input, monitors, gamma ramps and clipboard. The options are: diff --git a/docs/internal.dox b/docs/internal.dox index 685c6d13..ec2de50f 100644 --- a/docs/internal.dox +++ b/docs/internal.dox @@ -104,8 +104,7 @@ Examples: `isValidElementForJoystick` @section internals_config Configuration macros GLFW uses a number of configuration macros to select at compile time which -interfaces and code paths to use. They are defined in the glfw_config.h header file, -which is generated from the `glfw_config.h.in` file by CMake. +interfaces and code paths to use. They are defined in the GLFW CMake target. Configuration macros the same style as tokens in the public interface, except with a leading underscore. diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ea16f195..c56793b5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -15,18 +15,21 @@ add_custom_target(update_mappings set_target_properties(update_mappings PROPERTIES FOLDER "GLFW3") if (_GLFW_COCOA) + target_compile_definitions(glfw PRIVATE _GLFW_COCOA) target_sources(glfw PRIVATE cocoa_platform.h cocoa_joystick.h posix_thread.h nsgl_context.h egl_context.h osmesa_context.h cocoa_init.m cocoa_joystick.m cocoa_monitor.m cocoa_window.m cocoa_time.c posix_thread.c nsgl_context.m egl_context.c osmesa_context.c) elseif (_GLFW_WIN32) + target_compile_definitions(glfw PRIVATE _GLFW_WIN32) target_sources(glfw PRIVATE win32_platform.h win32_joystick.h wgl_context.h egl_context.h osmesa_context.h win32_init.c win32_joystick.c win32_monitor.c win32_time.c win32_thread.c win32_window.c wgl_context.c egl_context.c osmesa_context.c) elseif (_GLFW_X11) + target_compile_definitions(glfw PRIVATE _GLFW_X11) target_sources(glfw PRIVATE x11_platform.h xkb_unicode.h posix_time.h posix_thread.h glx_context.h egl_context.h osmesa_context.h x11_init.c x11_monitor.c @@ -34,12 +37,14 @@ elseif (_GLFW_X11) posix_thread.c glx_context.c egl_context.c osmesa_context.c) elseif (_GLFW_WAYLAND) + target_compile_definitions(glfw PRIVATE _GLFW_WAYLAND) target_sources(glfw PRIVATE wl_platform.h posix_time.h posix_thread.h xkb_unicode.h egl_context.h osmesa_context.h wl_init.c wl_monitor.c wl_window.c posix_time.c posix_thread.c xkb_unicode.c egl_context.c osmesa_context.c) elseif (_GLFW_OSMESA) + target_compile_definitions(glfw PRIVATE _GLFW_OSMESA) target_sources(glfw PRIVATE null_platform.h null_joystick.h posix_time.h posix_thread.h osmesa_context.h null_init.c null_monitor.c null_window.c null_joystick.c @@ -55,6 +60,17 @@ if (_GLFW_X11 OR _GLFW_WAYLAND) endif() if (_GLFW_WAYLAND) + include(CheckIncludeFiles) + include(CheckFunctionExists) + check_include_files(xkbcommon/xkbcommon-compose.h HAVE_XKBCOMMON_COMPOSE_H) + if (HAVE_XKBCOMMON_COMPOSE_H) + target_compile_definitions(glfw PRIVATE HAVE_XKBCOMMON_COMPOSE_H) + endif() + check_function_exists(memfd_create HAVE_MEMFD_CREATE) + if (HAVE_MEMFD_CREATE) + target_compile_definitions(glfw PRIVATE HAVE_MEMFD_CREATE) + endif() + find_program(WAYLAND_SCANNER_EXECUTABLE NAMES wayland-scanner) pkg_check_modules(WAYLAND_PROTOCOLS REQUIRED wayland-protocols>=1.15) pkg_get_variable(WAYLAND_PROTOCOLS_BASE wayland-protocols pkgdatadir) @@ -102,10 +118,6 @@ if (WIN32 AND GLFW_BUILD_SHARED_LIBRARY) target_sources(glfw PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/glfw.rc") endif() -configure_file(glfw_config.h.in glfw_config.h @ONLY) -target_compile_definitions(glfw PRIVATE _GLFW_USE_CONFIG_H) -target_sources(glfw PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/glfw_config.h") - set_target_properties(glfw PROPERTIES OUTPUT_NAME ${GLFW_LIB_NAME} VERSION ${GLFW_VERSION_MAJOR}.${GLFW_VERSION_MINOR} @@ -132,6 +144,10 @@ if (CMAKE_VERSION VERSION_LESS "3.16" AND APPLE) LANGUAGE C) endif() +if (GLFW_VULKAN_STATIC) + target_compile_definitions(glfw PRIVATE _GLFW_VULKAN_STATIC) +endif() + # Make GCC warn about declarations that VS 2010 and 2012 won't accept for all # source files that VS will build (Clang ignores this because we set -std=c99) if (CMAKE_C_COMPILER_ID STREQUAL "GNU") @@ -143,6 +159,12 @@ if (CMAKE_C_COMPILER_ID STREQUAL "GNU") COMPILE_FLAGS -Wdeclaration-after-statement) endif() +if (WIN32) + if (GLFW_USE_HYBRID_HPG) + target_compile_definitions(glfw PRIVATE _GLFW_USE_HYBRID_HPG) + endif() +endif() + # Enable a reasonable set of warnings # NOTE: The order matters here, Clang-CL matches both MSVC and Clang if (MSVC) diff --git a/src/glfw_config.h.in b/src/glfw_config.h.in deleted file mode 100644 index f4876da2..00000000 --- a/src/glfw_config.h.in +++ /dev/null @@ -1,58 +0,0 @@ -//======================================================================== -// GLFW 3.4 - www.glfw.org -//------------------------------------------------------------------------ -// Copyright (c) 2010-2016 Camilla Löwy -// -// This software is provided 'as-is', without any express or implied -// warranty. In no event will the authors be held liable for any damages -// arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it -// freely, subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; you must not -// claim that you wrote the original software. If you use this software -// in a product, an acknowledgment in the product documentation would -// be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, and must not -// be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source -// distribution. -// -//======================================================================== -// As glfw_config.h.in, this file is used by CMake to produce the -// glfw_config.h configuration header file. If you are adding a feature -// requiring conditional compilation, this is where to add the macro. -//======================================================================== -// As glfw_config.h, this file defines compile-time option macros for a -// specific platform and development environment. If you are using the -// GLFW CMake files, modify glfw_config.h.in instead of this file. If you -// are using your own build system, make this file define the appropriate -// macros in whatever way is suitable. -//======================================================================== - -// Define this to 1 if building GLFW for X11 -#cmakedefine _GLFW_X11 -// Define this to 1 if building GLFW for Win32 -#cmakedefine _GLFW_WIN32 -// Define this to 1 if building GLFW for Cocoa -#cmakedefine _GLFW_COCOA -// Define this to 1 if building GLFW for Wayland -#cmakedefine _GLFW_WAYLAND -// Define this to 1 if building GLFW for OSMesa -#cmakedefine _GLFW_OSMESA - -// Define this to 1 to use Vulkan loader linked statically into application -#cmakedefine _GLFW_VULKAN_STATIC - -// Define this to 1 to force use of high-performance GPU on hybrid systems -#cmakedefine _GLFW_USE_HYBRID_HPG - -// Define this to 1 if xkbcommon supports the compose key -#cmakedefine HAVE_XKBCOMMON_COMPOSE_H -// Define this to 1 if the libc supports memfd_create() -#cmakedefine HAVE_MEMFD_CREATE - From 8b8d10bc012fff787e242d3a80c81de44b6878b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 18 Aug 2021 19:36:36 +0200 Subject: [PATCH 034/208] Move library dependency logic to src directory This finally eliminates the glfw_INCLUDE_DIRS and glfw_LIBRARIES CMake variables entirely. --- CMakeLists.txt | 145 --------------------------------------------- src/CMakeLists.txt | 116 +++++++++++++++++++++++++++++++++++- 2 files changed, 113 insertions(+), 148 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a7fd9b46..a1169171 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -54,13 +54,6 @@ else() set(GLFW_BUILD_SHARED_LIBRARY ${BUILD_SHARED_LIBS}) endif() -if (UNIX AND GLFW_BUILD_SHARED_LIBRARY) - # On Unix-like systems, shared libraries can use the soname system. - set(GLFW_LIB_NAME glfw) -else() - set(GLFW_LIB_NAME glfw3) -endif() - list(APPEND CMAKE_MODULE_PATH "${GLFW_SOURCE_DIR}/CMake/modules") find_package(Threads REQUIRED) @@ -117,142 +110,6 @@ else() message(FATAL_ERROR "No supported platform was detected") endif() -#-------------------------------------------------------------------- -# Find and add Unix math and time libraries -#-------------------------------------------------------------------- -if (UNIX AND NOT APPLE) - find_library(RT_LIBRARY rt) - mark_as_advanced(RT_LIBRARY) - if (RT_LIBRARY) - list(APPEND glfw_LIBRARIES "${RT_LIBRARY}") - list(APPEND glfw_PKG_LIBS "-lrt") - endif() - - find_library(MATH_LIBRARY m) - mark_as_advanced(MATH_LIBRARY) - if (MATH_LIBRARY) - list(APPEND glfw_LIBRARIES "${MATH_LIBRARY}") - list(APPEND glfw_PKG_LIBS "-lm") - endif() - - if (CMAKE_DL_LIBS) - list(APPEND glfw_LIBRARIES "${CMAKE_DL_LIBS}") - list(APPEND glfw_PKG_LIBS "-l${CMAKE_DL_LIBS}") - endif() -endif() - -#-------------------------------------------------------------------- -# Use Win32 for window creation -#-------------------------------------------------------------------- -if (_GLFW_WIN32) - list(APPEND glfw_PKG_LIBS "-lgdi32") -endif() - -#-------------------------------------------------------------------- -# Use X11 for window creation -#-------------------------------------------------------------------- -if (_GLFW_X11) - - find_package(X11 REQUIRED) - - # Set up library and include paths - list(APPEND glfw_INCLUDE_DIRS "${X11_X11_INCLUDE_PATH}") - - # Check for XRandR (modern resolution switching and gamma control) - if (NOT X11_Xrandr_INCLUDE_PATH) - message(FATAL_ERROR "RandR headers not found; install libxrandr development package") - endif() - - # Check for Xinerama (legacy multi-monitor support) - if (NOT X11_Xinerama_INCLUDE_PATH) - message(FATAL_ERROR "Xinerama headers not found; install libxinerama development package") - endif() - - # Check for Xkb (X keyboard extension) - if (NOT X11_Xkb_INCLUDE_PATH) - message(FATAL_ERROR "XKB headers not found; install X11 development package") - endif() - - # Check for Xcursor (cursor creation from RGBA images) - if (NOT X11_Xcursor_INCLUDE_PATH) - message(FATAL_ERROR "Xcursor headers not found; install libxcursor development package") - endif() - - # Check for XInput (modern HID input) - if (NOT X11_Xi_INCLUDE_PATH) - message(FATAL_ERROR "XInput headers not found; install libxi development package") - endif() - - # Check for X Shape (custom window input shape) - if (NOT X11_Xshape_INCLUDE_PATH) - message(FATAL_ERROR "X Shape headers not found; install libxext development package") - endif() -endif() - -#-------------------------------------------------------------------- -# Use Wayland for window creation -#-------------------------------------------------------------------- -if (_GLFW_WAYLAND) - - include(FindPkgConfig) - pkg_check_modules(Wayland REQUIRED - wayland-client>=0.2.7 - wayland-cursor>=0.2.7 - wayland-egl>=0.2.7 - xkbcommon) - - list(APPEND glfw_INCLUDE_DIRS "${Wayland_INCLUDE_DIRS}") - - if (NOT CMAKE_SYSTEM_NAME STREQUAL "Linux") - find_package(EpollShim) - if (EPOLLSHIM_FOUND) - list(APPEND glfw_INCLUDE_DIRS "${EPOLLSHIM_INCLUDE_DIRS}") - list(APPEND glfw_LIBRARIES "${EPOLLSHIM_LIBRARIES}") - endif() - endif() -endif() - -#-------------------------------------------------------------------- -# Use Cocoa for window creation and NSOpenGL for context creation -#-------------------------------------------------------------------- -if (_GLFW_COCOA) - - list(APPEND glfw_LIBRARIES - "-framework Cocoa" - "-framework IOKit" - "-framework CoreFoundation") - - set(glfw_PKG_DEPS "") - set(glfw_PKG_LIBS "-framework Cocoa -framework IOKit -framework CoreFoundation") -endif() - -#-------------------------------------------------------------------- -# Add the Vulkan loader as a dependency if necessary -#-------------------------------------------------------------------- -if (GLFW_VULKAN_STATIC) - if (BUILD_SHARED_LIBS) - # If you absolutely must do this, remove this line and add the Vulkan - # loader static library via the CMAKE_SHARED_LINKER_FLAGS - message(FATAL_ERROR "You are trying to link the Vulkan loader static library into the GLFW shared library") - endif() - list(APPEND glfw_PKG_DEPS "vulkan") -endif() - -#-------------------------------------------------------------------- -# Export GLFW library dependencies -#-------------------------------------------------------------------- -foreach(arg ${glfw_PKG_DEPS}) - string(APPEND deps " ${arg}") -endforeach() -foreach(arg ${glfw_PKG_LIBS}) - string(APPEND libs " ${arg}") -endforeach() - -set(GLFW_PKG_CONFIG_REQUIRES_PRIVATE "${deps}" CACHE INTERNAL - "GLFW pkg-config Requires.private") -set(GLFW_PKG_CONFIG_LIBS_PRIVATE "${libs}" CACHE INTERNAL - "GLFW pkg-config Libs.private") - #-------------------------------------------------------------------- # Create generated files #-------------------------------------------------------------------- @@ -269,8 +126,6 @@ write_basic_package_version_file(src/glfw3ConfigVersion.cmake VERSION ${GLFW_VERSION} COMPATIBILITY SameMajorVersion) -configure_file(CMake/glfw3.pc.in src/glfw3.pc @ONLY) - #-------------------------------------------------------------------- # Add subdirectories #-------------------------------------------------------------------- diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c56793b5..cf358996 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -72,6 +72,8 @@ if (_GLFW_WAYLAND) endif() find_program(WAYLAND_SCANNER_EXECUTABLE NAMES wayland-scanner) + + include(FindPkgConfig) pkg_check_modules(WAYLAND_PROTOCOLS REQUIRED wayland-protocols>=1.15) pkg_get_variable(WAYLAND_PROTOCOLS_BASE wayland-protocols pkgdatadir) pkg_get_variable(WAYLAND_CLIENT_PKGDATADIR wayland-client pkgdatadir) @@ -118,6 +120,13 @@ if (WIN32 AND GLFW_BUILD_SHARED_LIBRARY) target_sources(glfw PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/glfw.rc") endif() +if (UNIX AND GLFW_BUILD_SHARED_LIBRARY) + # On Unix-like systems, shared libraries can use the soname system. + set(GLFW_LIB_NAME glfw) +else() + set(GLFW_LIB_NAME glfw3) +endif() + set_target_properties(glfw PROPERTIES OUTPUT_NAME ${GLFW_LIB_NAME} VERSION ${GLFW_VERSION_MAJOR}.${GLFW_VERSION_MINOR} @@ -133,9 +142,8 @@ target_include_directories(glfw PUBLIC "$") target_include_directories(glfw PRIVATE "${GLFW_SOURCE_DIR}/src" - "${GLFW_BINARY_DIR}/src" - ${glfw_INCLUDE_DIRS}) -target_link_libraries(glfw PRIVATE Threads::Threads ${glfw_LIBRARIES}) + "${GLFW_BINARY_DIR}/src") +target_link_libraries(glfw PRIVATE Threads::Threads) # Workaround for CMake not knowing about .m files before version 3.16 if (CMAKE_VERSION VERSION_LESS "3.16" AND APPLE) @@ -146,6 +154,94 @@ endif() if (GLFW_VULKAN_STATIC) target_compile_definitions(glfw PRIVATE _GLFW_VULKAN_STATIC) + list(APPEND glfw_PKG_DEPS "vulkan") +endif() + +if (_GLFW_WIN32) + list(APPEND glfw_PKG_LIBS "-lgdi32") +endif() + +if (_GLFW_COCOA) + target_link_libraries(glfw PRIVATE "-framework Cocoa" + "-framework IOKit" + "-framework CoreFoundation") + + set(glfw_PKG_DEPS "") + set(glfw_PKG_LIBS "-framework Cocoa -framework IOKit -framework CoreFoundation") +endif() + +if (_GLFW_WAYLAND) + pkg_check_modules(Wayland REQUIRED + wayland-client>=0.2.7 + wayland-cursor>=0.2.7 + wayland-egl>=0.2.7 + xkbcommon) + + target_include_directories(glfw PRIVATE ${Wayland_INCLUDE_DIRS}) + + if (NOT CMAKE_SYSTEM_NAME STREQUAL "Linux") + find_package(EpollShim) + if (EPOLLSHIM_FOUND) + target_include_directories(glfw PRIVATE ${EPOLLSHIM_INCLUDE_DIRS}) + target_link_libraries(glfw PRIVATE ${EPOLLSHIM_LIBRARIES}) + endif() + endif() +endif() + +if (_GLFW_X11) + find_package(X11 REQUIRED) + target_include_directories(glfw PRIVATE "${X11_X11_INCLUDE_PATH}") + + # Check for XRandR (modern resolution switching and gamma control) + if (NOT X11_Xrandr_INCLUDE_PATH) + message(FATAL_ERROR "RandR headers not found; install libxrandr development package") + endif() + + # Check for Xinerama (legacy multi-monitor support) + if (NOT X11_Xinerama_INCLUDE_PATH) + message(FATAL_ERROR "Xinerama headers not found; install libxinerama development package") + endif() + + # Check for Xkb (X keyboard extension) + if (NOT X11_Xkb_INCLUDE_PATH) + message(FATAL_ERROR "XKB headers not found; install X11 development package") + endif() + + # Check for Xcursor (cursor creation from RGBA images) + if (NOT X11_Xcursor_INCLUDE_PATH) + message(FATAL_ERROR "Xcursor headers not found; install libxcursor development package") + endif() + + # Check for XInput (modern HID input) + if (NOT X11_Xi_INCLUDE_PATH) + message(FATAL_ERROR "XInput headers not found; install libxi development package") + endif() + + # Check for X Shape (custom window input shape) + if (NOT X11_Xshape_INCLUDE_PATH) + message(FATAL_ERROR "X Shape headers not found; install libxext development package") + endif() +endif() + +if (UNIX AND NOT APPLE) + find_library(RT_LIBRARY rt) + mark_as_advanced(RT_LIBRARY) + if (RT_LIBRARY) + target_link_libraries(glfw PRIVATE "${RT_LIBRARY}") + list(APPEND glfw_PKG_LIBS "-lrt") + endif() + + find_library(MATH_LIBRARY m) + mark_as_advanced(MATH_LIBRARY) + if (MATH_LIBRARY) + target_link_libraries(glfw PRIVATE "${MATH_LIBRARY}") + list(APPEND glfw_PKG_LIBS "-lm") + endif() + + if (CMAKE_DL_LIBS) + target_link_libraries(glfw PRIVATE "${CMAKE_DL_LIBS}") + list(APPEND glfw_PKG_LIBS "-l${CMAKE_DL_LIBS}") + endif() endif() # Make GCC warn about declarations that VS 2010 and 2012 won't accept for all @@ -279,6 +375,20 @@ if (GLFW_BUILD_SHARED_LIBRARY) endif() endif() +foreach(arg ${glfw_PKG_DEPS}) + string(APPEND deps " ${arg}") +endforeach() +foreach(arg ${glfw_PKG_LIBS}) + string(APPEND libs " ${arg}") +endforeach() + +set(GLFW_PKG_CONFIG_REQUIRES_PRIVATE "${deps}" CACHE INTERNAL + "GLFW pkg-config Requires.private") +set(GLFW_PKG_CONFIG_LIBS_PRIVATE "${libs}" CACHE INTERNAL + "GLFW pkg-config Libs.private") + +configure_file("${GLFW_SOURCE_DIR}/CMake/glfw3.pc.in" glfw3.pc @ONLY) + if (GLFW_INSTALL) install(TARGETS glfw EXPORT glfwTargets From d0776e04a34bbdfcc78c7bbad8fe0425c6380035 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 14 Jul 2021 20:06:22 +0200 Subject: [PATCH 035/208] Null: Add non-functional EGL support This is done in preparation for runtime platform selection, to make sure every platform can build with EGL enabled. It may be possible to add support for things like the ANGLE null platform later. --- src/CMakeLists.txt | 3 ++- src/null_init.c | 3 ++- src/null_window.c | 23 ++++++++++++++++++++--- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index cf358996..2b6e6243 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -48,7 +48,8 @@ elseif (_GLFW_OSMESA) target_sources(glfw PRIVATE null_platform.h null_joystick.h posix_time.h posix_thread.h osmesa_context.h null_init.c null_monitor.c null_window.c null_joystick.c - posix_time.c posix_thread.c osmesa_context.c) + posix_time.c posix_thread.c egl_context.c + osmesa_context.c) endif() if (_GLFW_X11 OR _GLFW_WAYLAND) diff --git a/src/null_init.c b/src/null_init.c index 68599d1f..d72b06bf 100644 --- a/src/null_init.c +++ b/src/null_init.c @@ -48,10 +48,11 @@ void _glfwPlatformTerminate(void) { _glfw_free(_glfw.null.clipboardString); _glfwTerminateOSMesa(); + _glfwTerminateEGL(); } const char* _glfwPlatformGetVersionString(void) { - return _GLFW_VERSION_NUMBER " null OSMesa"; + return _GLFW_VERSION_NUMBER " null OSMesa EGL"; } diff --git a/src/null_window.c b/src/null_window.c index 1f59540e..6a251153 100644 --- a/src/null_window.c +++ b/src/null_window.c @@ -121,10 +121,12 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window, if (!_glfwCreateContextOSMesa(window, ctxconfig, fbconfig)) return GLFW_FALSE; } - else + else if (ctxconfig->source == GLFW_EGL_CONTEXT_API) { - _glfwInputError(GLFW_API_UNAVAILABLE, "Null: EGL not available"); - return GLFW_FALSE; + if (!_glfwInitEGL()) + return GLFW_FALSE; + if (!_glfwCreateContextEGL(window, ctxconfig, fbconfig)) + return GLFW_FALSE; } } @@ -522,6 +524,21 @@ const char* _glfwPlatformGetClipboardString(void) return _glfw.null.clipboardString; } +EGLenum _glfwPlatformGetEGLPlatform(EGLint** attribs) +{ + return 0; +} + +EGLNativeDisplayType _glfwPlatformGetEGLNativeDisplay(void) +{ + return 0; +} + +EGLNativeWindowType _glfwPlatformGetEGLNativeWindow(_GLFWwindow* window) +{ + return 0; +} + const char* _glfwPlatformGetScancodeName(int scancode) { if (scancode < GLFW_KEY_SPACE || scancode > GLFW_KEY_LAST) From 6d51b391060cefc8c633d992817067e32c2e92df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 15 Jul 2021 22:12:21 +0200 Subject: [PATCH 036/208] Select mapping platform name at runtime This is done in preparation for runtime platform selection. --- src/cocoa_joystick.h | 1 - src/cocoa_joystick.m | 5 +++++ src/input.c | 5 +++-- src/internal.h | 1 + src/linux_joystick.c | 5 +++++ src/linux_joystick.h | 1 - src/null_joystick.c | 5 +++++ src/null_joystick.h | 2 -- src/win32_joystick.c | 5 +++++ src/win32_joystick.h | 1 - 10 files changed, 24 insertions(+), 7 deletions(-) diff --git a/src/cocoa_joystick.h b/src/cocoa_joystick.h index 7a121c8b..cfcb7ca3 100644 --- a/src/cocoa_joystick.h +++ b/src/cocoa_joystick.h @@ -32,7 +32,6 @@ #define _GLFW_PLATFORM_JOYSTICK_STATE _GLFWjoystickNS ns #define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE struct { int dummyJoystick; } -#define _GLFW_PLATFORM_MAPPING_NAME "Mac OS X" #define GLFW_BUILD_COCOA_MAPPINGS // Cocoa-specific per-joystick data diff --git a/src/cocoa_joystick.m b/src/cocoa_joystick.m index a8081d2c..5e2666b2 100644 --- a/src/cocoa_joystick.m +++ b/src/cocoa_joystick.m @@ -469,6 +469,11 @@ int _glfwPlatformPollJoystick(_GLFWjoystick* js, int mode) return js->present; } +const char* _glfwPlatformGetMappingName(void) +{ + return "Mac OS X"; +} + void _glfwPlatformUpdateGamepadGUID(char* guid) { if ((strncmp(guid + 4, "000000000000", 12) == 0) && diff --git a/src/input.c b/src/input.c index 83ef6921..920db8de 100644 --- a/src/input.c +++ b/src/input.c @@ -234,8 +234,9 @@ static GLFWbool parseMapping(_GLFWmapping* mapping, const char* string) } else { - length = strlen(_GLFW_PLATFORM_MAPPING_NAME); - if (strncmp(c, _GLFW_PLATFORM_MAPPING_NAME, length) != 0) + const char* name = _glfwPlatformGetMappingName(); + length = strlen(name); + if (strncmp(c, name, length) != 0) return GLFW_FALSE; } diff --git a/src/internal.h b/src/internal.h index f41db3c3..0a9a965a 100644 --- a/src/internal.h +++ b/src/internal.h @@ -642,6 +642,7 @@ GLFWbool _glfwPlatformInitJoysticks(void); void _glfwPlatformTerminateJoysticks(void); int _glfwPlatformPollJoystick(_GLFWjoystick* js, int mode); void _glfwPlatformUpdateGamepadGUID(char* guid); +const char* _glfwPlatformGetMappingName(void); uint64_t _glfwPlatformGetTimerValue(void); uint64_t _glfwPlatformGetTimerFrequency(void); diff --git a/src/linux_joystick.c b/src/linux_joystick.c index 122bc66a..edb53e4c 100644 --- a/src/linux_joystick.c +++ b/src/linux_joystick.c @@ -422,6 +422,11 @@ int _glfwPlatformPollJoystick(_GLFWjoystick* js, int mode) return js->present; } +const char* _glfwPlatformGetMappingName(void) +{ + return "Linux"; +} + void _glfwPlatformUpdateGamepadGUID(char* guid) { } diff --git a/src/linux_joystick.h b/src/linux_joystick.h index 1c3ca751..1766a3bf 100644 --- a/src/linux_joystick.h +++ b/src/linux_joystick.h @@ -31,7 +31,6 @@ #define _GLFW_PLATFORM_JOYSTICK_STATE _GLFWjoystickLinux linjs #define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE _GLFWlibraryLinux linjs -#define _GLFW_PLATFORM_MAPPING_NAME "Linux" #define GLFW_BUILD_LINUX_MAPPINGS // Linux-specific joystick data diff --git a/src/null_joystick.c b/src/null_joystick.c index 27756a61..de5066ca 100644 --- a/src/null_joystick.c +++ b/src/null_joystick.c @@ -47,6 +47,11 @@ int _glfwPlatformPollJoystick(_GLFWjoystick* js, int mode) return GLFW_FALSE; } +const char* _glfwPlatformGetMappingName(void) +{ + return ""; +} + void _glfwPlatformUpdateGamepadGUID(char* guid) { } diff --git a/src/null_joystick.h b/src/null_joystick.h index 5d19a451..a1ff7fcd 100644 --- a/src/null_joystick.h +++ b/src/null_joystick.h @@ -27,5 +27,3 @@ #define _GLFW_PLATFORM_JOYSTICK_STATE struct { int dummyJoystick; } #define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE struct { int dummyLibraryJoystick; } -#define _GLFW_PLATFORM_MAPPING_NAME "" - diff --git a/src/win32_joystick.c b/src/win32_joystick.c index 3ac29d1d..bb5ed1a3 100644 --- a/src/win32_joystick.c +++ b/src/win32_joystick.c @@ -740,6 +740,11 @@ int _glfwPlatformPollJoystick(_GLFWjoystick* js, int mode) return GLFW_TRUE; } +const char* _glfwPlatformGetMappingName(void) +{ + return "Windows"; +} + void _glfwPlatformUpdateGamepadGUID(char* guid) { if (strcmp(guid + 20, "504944564944") == 0) diff --git a/src/win32_joystick.h b/src/win32_joystick.h index c469fcdc..b9bb6779 100644 --- a/src/win32_joystick.h +++ b/src/win32_joystick.h @@ -27,7 +27,6 @@ #define _GLFW_PLATFORM_JOYSTICK_STATE _GLFWjoystickWin32 win32 #define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE struct { int dummyLibraryJoystick; } -#define _GLFW_PLATFORM_MAPPING_NAME "Windows" #define GLFW_BUILD_WIN32_MAPPINGS // Joystick element (axis, button or slider) From e31deedc993f8f396b20c2d8542ecfdad277a879 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 16 Jul 2021 13:53:31 +0200 Subject: [PATCH 037/208] Make timer init part of platform API This is part of runtime platform selection because the null backend needs the timer implementation for the current OS. --- src/cocoa_init.m | 2 -- src/cocoa_platform.h | 2 -- src/cocoa_time.c | 11 ++--------- src/init.c | 4 +++- src/internal.h | 1 + src/null_init.c | 1 - src/posix_time.c | 11 ++--------- src/posix_time.h | 3 --- src/win32_init.c | 2 -- src/win32_platform.h | 2 -- src/win32_time.c | 11 ++--------- src/wl_init.c | 2 -- src/x11_init.c | 2 -- 13 files changed, 10 insertions(+), 44 deletions(-) diff --git a/src/cocoa_init.m b/src/cocoa_init.m index d12f3427..a41667b0 100644 --- a/src/cocoa_init.m +++ b/src/cocoa_init.m @@ -547,8 +547,6 @@ int _glfwPlatformInit(void) if (!initializeTIS()) return GLFW_FALSE; - _glfwInitTimerNS(); - _glfwPollMonitorsNS(); if (![[NSRunningApplication currentApplication] isFinishedLaunching]) diff --git a/src/cocoa_platform.h b/src/cocoa_platform.h index f9e80766..1ebf2c65 100644 --- a/src/cocoa_platform.h +++ b/src/cocoa_platform.h @@ -191,8 +191,6 @@ typedef struct _GLFWtimerNS } _GLFWtimerNS; -void _glfwInitTimerNS(void); - void _glfwPollMonitorsNS(void); void _glfwSetVideoModeNS(_GLFWmonitor* monitor, const GLFWvidmode* desired); void _glfwRestoreVideoModeNS(_GLFWmonitor* monitor); diff --git a/src/cocoa_time.c b/src/cocoa_time.c index 4bf646c8..c2bf8eda 100644 --- a/src/cocoa_time.c +++ b/src/cocoa_time.c @@ -32,12 +32,10 @@ ////////////////////////////////////////////////////////////////////////// -////// GLFW internal API ////// +////// GLFW platform API ////// ////////////////////////////////////////////////////////////////////////// -// Initialise timer -// -void _glfwInitTimerNS(void) +void _glfwPlatformInitTimer(void) { mach_timebase_info_data_t info; mach_timebase_info(&info); @@ -45,11 +43,6 @@ void _glfwInitTimerNS(void) _glfw.timer.ns.frequency = (info.denom * 1e9) / info.numer; } - -////////////////////////////////////////////////////////////////////////// -////// GLFW platform API ////// -////////////////////////////////////////////////////////////////////////// - uint64_t _glfwPlatformGetTimerValue(void) { return mach_absolute_time(); diff --git a/src/init.c b/src/init.c index a9f9a54d..f74b497d 100644 --- a/src/init.c +++ b/src/init.c @@ -340,9 +340,11 @@ GLFWAPI int glfwInit(void) _glfwInitGamepadMappings(); - _glfw.initialized = GLFW_TRUE; + _glfwPlatformInitTimer(); _glfw.timer.offset = _glfwPlatformGetTimerValue(); + _glfw.initialized = GLFW_TRUE; + glfwDefaultWindowHints(); return GLFW_TRUE; } diff --git a/src/internal.h b/src/internal.h index 0a9a965a..47f779e0 100644 --- a/src/internal.h +++ b/src/internal.h @@ -644,6 +644,7 @@ int _glfwPlatformPollJoystick(_GLFWjoystick* js, int mode); void _glfwPlatformUpdateGamepadGUID(char* guid); const char* _glfwPlatformGetMappingName(void); +void _glfwPlatformInitTimer(void); uint64_t _glfwPlatformGetTimerValue(void); uint64_t _glfwPlatformGetTimerFrequency(void); diff --git a/src/null_init.c b/src/null_init.c index d72b06bf..d2968fc1 100644 --- a/src/null_init.c +++ b/src/null_init.c @@ -38,7 +38,6 @@ int _glfwPlatformInit(void) { - _glfwInitTimerPOSIX(); _glfwPollMonitorsNull(); return GLFW_TRUE; diff --git a/src/posix_time.c b/src/posix_time.c index b47a0b13..f134be47 100644 --- a/src/posix_time.c +++ b/src/posix_time.c @@ -34,12 +34,10 @@ ////////////////////////////////////////////////////////////////////////// -////// GLFW internal API ////// +////// GLFW platform API ////// ////////////////////////////////////////////////////////////////////////// -// Initialise timer -// -void _glfwInitTimerPOSIX(void) +void _glfwPlatformInitTimer(void) { _glfw.timer.posix.clock = CLOCK_REALTIME; _glfw.timer.posix.frequency = 1000000000; @@ -51,11 +49,6 @@ void _glfwInitTimerPOSIX(void) #endif } - -////////////////////////////////////////////////////////////////////////// -////// GLFW platform API ////// -////////////////////////////////////////////////////////////////////////// - uint64_t _glfwPlatformGetTimerValue(void) { struct timespec ts; diff --git a/src/posix_time.h b/src/posix_time.h index cc7ba990..6fd15b06 100644 --- a/src/posix_time.h +++ b/src/posix_time.h @@ -39,6 +39,3 @@ typedef struct _GLFWtimerPOSIX uint64_t frequency; } _GLFWtimerPOSIX; - -void _glfwInitTimerPOSIX(void); - diff --git a/src/win32_init.c b/src/win32_init.c index c5370230..b871806e 100644 --- a/src/win32_init.c +++ b/src/win32_init.c @@ -576,8 +576,6 @@ int _glfwPlatformInit(void) if (!createHelperWindow()) return GLFW_FALSE; - _glfwInitTimerWin32(); - _glfwPollMonitorsWin32(); return GLFW_TRUE; } diff --git a/src/win32_platform.h b/src/win32_platform.h index 500da470..715026eb 100644 --- a/src/win32_platform.h +++ b/src/win32_platform.h @@ -445,8 +445,6 @@ BOOL _glfwIsWindows10BuildOrGreaterWin32(WORD build); void _glfwInputErrorWin32(int error, const char* description); void _glfwUpdateKeyNamesWin32(void); -void _glfwInitTimerWin32(void); - void _glfwPollMonitorsWin32(void); void _glfwSetVideoModeWin32(_GLFWmonitor* monitor, const GLFWvidmode* desired); void _glfwRestoreVideoModeWin32(_GLFWmonitor* monitor); diff --git a/src/win32_time.c b/src/win32_time.c index 721b0d0d..2b1cbf0d 100644 --- a/src/win32_time.c +++ b/src/win32_time.c @@ -31,12 +31,10 @@ ////////////////////////////////////////////////////////////////////////// -////// GLFW internal API ////// +////// GLFW platform API ////// ////////////////////////////////////////////////////////////////////////// -// Initialise timer -// -void _glfwInitTimerWin32(void) +void _glfwPlatformInitTimer(void) { uint64_t frequency; @@ -52,11 +50,6 @@ void _glfwInitTimerWin32(void) } } - -////////////////////////////////////////////////////////////////////////// -////// GLFW platform API ////// -////////////////////////////////////////////////////////////////////////// - uint64_t _glfwPlatformGetTimerValue(void) { if (_glfw.timer.win32.hasPC) diff --git a/src/wl_init.c b/src/wl_init.c index 2c73a7a9..5893970a 100644 --- a/src/wl_init.c +++ b/src/wl_init.c @@ -1227,8 +1227,6 @@ int _glfwPlatformInit(void) // Sync so we got all initial output events wl_display_roundtrip(_glfw.wl.display); - _glfwInitTimerPOSIX(); - _glfw.wl.timerfd = -1; if (_glfw.wl.seatVersion >= 4) _glfw.wl.timerfd = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC); diff --git a/src/x11_init.c b/src/x11_init.c index 5a5154cc..e4cb09de 100644 --- a/src/x11_init.c +++ b/src/x11_init.c @@ -1381,8 +1381,6 @@ int _glfwPlatformInit(void) NULL); } - _glfwInitTimerPOSIX(); - _glfwPollMonitorsX11(); return GLFW_TRUE; } From b7d0c6037d5a0860434fb068693eb0973012c31d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 16 Jul 2021 14:57:22 +0200 Subject: [PATCH 038/208] Make dynamic module loading part of platform API This is part of the preparations for runtime platform selection. --- src/CMakeLists.txt | 8 +- src/cocoa_init.m | 2 +- src/cocoa_platform.h | 5 - src/egl_context.c | 44 +++--- src/glx_context.c | 66 ++++----- src/internal.h | 5 + src/null_platform.h | 12 -- src/osmesa_context.c | 18 +-- src/posix_module.c | 51 +++++++ src/vulkan.c | 14 +- src/wgl_context.c | 20 +-- src/win32_init.c | 62 ++++---- src/win32_module.c | 49 +++++++ src/win32_platform.h | 4 - src/wl_init.c | 100 ++++++------- src/wl_platform.h | 5 - src/x11_init.c | 336 +++++++++++++++++++++---------------------- src/x11_platform.h | 5 - 18 files changed, 443 insertions(+), 363 deletions(-) create mode 100644 src/posix_module.c create mode 100644 src/win32_module.c diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2b6e6243..850074c0 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -52,6 +52,12 @@ elseif (_GLFW_OSMESA) osmesa_context.c) endif() +if (WIN32) + target_sources(glfw PRIVATE win32_module.c) +else() + target_sources(glfw PRIVATE posix_module.c) +endif() + if (_GLFW_X11 OR _GLFW_WAYLAND) if (CMAKE_SYSTEM_NAME STREQUAL "Linux") target_sources(glfw PRIVATE linux_joystick.h linux_joystick.c) @@ -250,7 +256,7 @@ endif() if (CMAKE_C_COMPILER_ID STREQUAL "GNU") set_source_files_properties(context.c init.c input.c monitor.c vulkan.c window.c win32_init.c win32_joystick.c - win32_monitor.c win32_time.c win32_thread.c + win32_module.c win32_monitor.c win32_time.c win32_thread.c win32_window.c wgl_context.c egl_context.c osmesa_context.c PROPERTIES COMPILE_FLAGS -Wdeclaration-after-statement) diff --git a/src/cocoa_init.m b/src/cocoa_init.m index a41667b0..701265a5 100644 --- a/src/cocoa_init.m +++ b/src/cocoa_init.m @@ -478,7 +478,7 @@ void* _glfwLoadLocalVulkanLoaderNS(void) void* handle = NULL; if (CFURLGetFileSystemRepresentation(url, true, (UInt8*) path, sizeof(path) - 1)) - handle = _glfw_dlopen(path); + handle = _glfwPlatformLoadModule(path); CFRelease(url); return handle; diff --git a/src/cocoa_platform.h b/src/cocoa_platform.h index 1ebf2c65..ba575ffa 100644 --- a/src/cocoa_platform.h +++ b/src/cocoa_platform.h @@ -25,7 +25,6 @@ //======================================================================== #include -#include #include @@ -88,10 +87,6 @@ typedef VkResult (APIENTRY *PFN_vkCreateMetalSurfaceEXT)(VkInstance,const VkMeta #include "cocoa_joystick.h" #include "nsgl_context.h" -#define _glfw_dlopen(name) dlopen(name, RTLD_LAZY | RTLD_LOCAL) -#define _glfw_dlclose(handle) dlclose(handle) -#define _glfw_dlsym(handle, name) dlsym(handle, name) - #define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowNS ns #define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryNS ns #define _GLFW_PLATFORM_LIBRARY_TIMER_STATE _GLFWtimerNS ns diff --git a/src/egl_context.c b/src/egl_context.c index d25c5bd1..8d4df682 100644 --- a/src/egl_context.c +++ b/src/egl_context.c @@ -256,8 +256,8 @@ static GLFWglproc getProcAddressEGL(const char* procname) if (window->context.egl.client) { - GLFWglproc proc = (GLFWglproc) _glfw_dlsym(window->context.egl.client, - procname); + GLFWglproc proc = (GLFWglproc) + _glfwPlatformGetModuleSymbol(window->context.egl.client, procname); if (proc) return proc; } @@ -275,7 +275,7 @@ static void destroyContextEGL(_GLFWwindow* window) { if (window->context.egl.client) { - _glfw_dlclose(window->context.egl.client); + _glfwPlatformFreeModule(window->context.egl.client); window->context.egl.client = NULL; } } @@ -327,7 +327,7 @@ GLFWbool _glfwInitEGL(void) for (i = 0; sonames[i]; i++) { - _glfw.egl.handle = _glfw_dlopen(sonames[i]); + _glfw.egl.handle = _glfwPlatformLoadModule(sonames[i]); if (_glfw.egl.handle) break; } @@ -341,37 +341,37 @@ GLFWbool _glfwInitEGL(void) _glfw.egl.prefix = (strncmp(sonames[i], "lib", 3) == 0); _glfw.egl.GetConfigAttrib = (PFN_eglGetConfigAttrib) - _glfw_dlsym(_glfw.egl.handle, "eglGetConfigAttrib"); + _glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglGetConfigAttrib"); _glfw.egl.GetConfigs = (PFN_eglGetConfigs) - _glfw_dlsym(_glfw.egl.handle, "eglGetConfigs"); + _glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglGetConfigs"); _glfw.egl.GetDisplay = (PFN_eglGetDisplay) - _glfw_dlsym(_glfw.egl.handle, "eglGetDisplay"); + _glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglGetDisplay"); _glfw.egl.GetError = (PFN_eglGetError) - _glfw_dlsym(_glfw.egl.handle, "eglGetError"); + _glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglGetError"); _glfw.egl.Initialize = (PFN_eglInitialize) - _glfw_dlsym(_glfw.egl.handle, "eglInitialize"); + _glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglInitialize"); _glfw.egl.Terminate = (PFN_eglTerminate) - _glfw_dlsym(_glfw.egl.handle, "eglTerminate"); + _glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglTerminate"); _glfw.egl.BindAPI = (PFN_eglBindAPI) - _glfw_dlsym(_glfw.egl.handle, "eglBindAPI"); + _glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglBindAPI"); _glfw.egl.CreateContext = (PFN_eglCreateContext) - _glfw_dlsym(_glfw.egl.handle, "eglCreateContext"); + _glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglCreateContext"); _glfw.egl.DestroySurface = (PFN_eglDestroySurface) - _glfw_dlsym(_glfw.egl.handle, "eglDestroySurface"); + _glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglDestroySurface"); _glfw.egl.DestroyContext = (PFN_eglDestroyContext) - _glfw_dlsym(_glfw.egl.handle, "eglDestroyContext"); + _glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglDestroyContext"); _glfw.egl.CreateWindowSurface = (PFN_eglCreateWindowSurface) - _glfw_dlsym(_glfw.egl.handle, "eglCreateWindowSurface"); + _glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglCreateWindowSurface"); _glfw.egl.MakeCurrent = (PFN_eglMakeCurrent) - _glfw_dlsym(_glfw.egl.handle, "eglMakeCurrent"); + _glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglMakeCurrent"); _glfw.egl.SwapBuffers = (PFN_eglSwapBuffers) - _glfw_dlsym(_glfw.egl.handle, "eglSwapBuffers"); + _glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglSwapBuffers"); _glfw.egl.SwapInterval = (PFN_eglSwapInterval) - _glfw_dlsym(_glfw.egl.handle, "eglSwapInterval"); + _glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglSwapInterval"); _glfw.egl.QueryString = (PFN_eglQueryString) - _glfw_dlsym(_glfw.egl.handle, "eglQueryString"); + _glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglQueryString"); _glfw.egl.GetProcAddress = (PFN_eglGetProcAddress) - _glfw_dlsym(_glfw.egl.handle, "eglGetProcAddress"); + _glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglGetProcAddress"); if (!_glfw.egl.GetConfigAttrib || !_glfw.egl.GetConfigs || @@ -488,7 +488,7 @@ void _glfwTerminateEGL(void) if (_glfw.egl.handle) { - _glfw_dlclose(_glfw.egl.handle); + _glfwPlatformFreeModule(_glfw.egl.handle); _glfw.egl.handle = NULL; } } @@ -737,7 +737,7 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window, if (_glfw.egl.prefix != (strncmp(sonames[i], "lib", 3) == 0)) continue; - window->context.egl.client = _glfw_dlopen(sonames[i]); + window->context.egl.client = _glfwPlatformLoadModule(sonames[i]); if (window->context.egl.client) break; } diff --git a/src/glx_context.c b/src/glx_context.c index 1abc1797..02c1c5e4 100644 --- a/src/glx_context.c +++ b/src/glx_context.c @@ -226,7 +226,7 @@ static GLFWglproc getProcAddressGLX(const char* procname) else if (_glfw.glx.GetProcAddressARB) return _glfw.glx.GetProcAddressARB((const GLubyte*) procname); else - return _glfw_dlsym(_glfw.glx.handle, procname); + return _glfwPlatformGetModuleSymbol(_glfw.glx.handle, procname); } static void destroyContextGLX(_GLFWwindow* window) @@ -272,7 +272,7 @@ GLFWbool _glfwInitGLX(void) for (i = 0; sonames[i]; i++) { - _glfw.glx.handle = _glfw_dlopen(sonames[i]); + _glfw.glx.handle = _glfwPlatformLoadModule(sonames[i]); if (_glfw.glx.handle) break; } @@ -283,36 +283,36 @@ GLFWbool _glfwInitGLX(void) return GLFW_FALSE; } - _glfw.glx.GetFBConfigs = - _glfw_dlsym(_glfw.glx.handle, "glXGetFBConfigs"); - _glfw.glx.GetFBConfigAttrib = - _glfw_dlsym(_glfw.glx.handle, "glXGetFBConfigAttrib"); - _glfw.glx.GetClientString = - _glfw_dlsym(_glfw.glx.handle, "glXGetClientString"); - _glfw.glx.QueryExtension = - _glfw_dlsym(_glfw.glx.handle, "glXQueryExtension"); - _glfw.glx.QueryVersion = - _glfw_dlsym(_glfw.glx.handle, "glXQueryVersion"); - _glfw.glx.DestroyContext = - _glfw_dlsym(_glfw.glx.handle, "glXDestroyContext"); - _glfw.glx.MakeCurrent = - _glfw_dlsym(_glfw.glx.handle, "glXMakeCurrent"); - _glfw.glx.SwapBuffers = - _glfw_dlsym(_glfw.glx.handle, "glXSwapBuffers"); - _glfw.glx.QueryExtensionsString = - _glfw_dlsym(_glfw.glx.handle, "glXQueryExtensionsString"); - _glfw.glx.CreateNewContext = - _glfw_dlsym(_glfw.glx.handle, "glXCreateNewContext"); - _glfw.glx.CreateWindow = - _glfw_dlsym(_glfw.glx.handle, "glXCreateWindow"); - _glfw.glx.DestroyWindow = - _glfw_dlsym(_glfw.glx.handle, "glXDestroyWindow"); - _glfw.glx.GetProcAddress = - _glfw_dlsym(_glfw.glx.handle, "glXGetProcAddress"); - _glfw.glx.GetProcAddressARB = - _glfw_dlsym(_glfw.glx.handle, "glXGetProcAddressARB"); - _glfw.glx.GetVisualFromFBConfig = - _glfw_dlsym(_glfw.glx.handle, "glXGetVisualFromFBConfig"); + _glfw.glx.GetFBConfigs = (PFNGLXGETFBCONFIGSPROC) + _glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXGetFBConfigs"); + _glfw.glx.GetFBConfigAttrib = (PFNGLXGETFBCONFIGATTRIBPROC) + _glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXGetFBConfigAttrib"); + _glfw.glx.GetClientString = (PFNGLXGETCLIENTSTRINGPROC) + _glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXGetClientString"); + _glfw.glx.QueryExtension = (PFNGLXQUERYEXTENSIONPROC) + _glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXQueryExtension"); + _glfw.glx.QueryVersion = (PFNGLXQUERYVERSIONPROC) + _glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXQueryVersion"); + _glfw.glx.DestroyContext = (PFNGLXDESTROYCONTEXTPROC) + _glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXDestroyContext"); + _glfw.glx.MakeCurrent = (PFNGLXMAKECURRENTPROC) + _glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXMakeCurrent"); + _glfw.glx.SwapBuffers = (PFNGLXSWAPBUFFERSPROC) + _glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXSwapBuffers"); + _glfw.glx.QueryExtensionsString = (PFNGLXQUERYEXTENSIONSSTRINGPROC) + _glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXQueryExtensionsString"); + _glfw.glx.CreateNewContext = (PFNGLXCREATENEWCONTEXTPROC) + _glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXCreateNewContext"); + _glfw.glx.CreateWindow = (PFNGLXCREATEWINDOWPROC) + _glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXCreateWindow"); + _glfw.glx.DestroyWindow = (PFNGLXDESTROYWINDOWPROC) + _glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXDestroyWindow"); + _glfw.glx.GetProcAddress = (PFNGLXGETPROCADDRESSPROC) + _glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXGetProcAddress"); + _glfw.glx.GetProcAddressARB = (PFNGLXGETPROCADDRESSPROC) + _glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXGetProcAddressARB"); + _glfw.glx.GetVisualFromFBConfig = (PFNGLXGETVISUALFROMFBCONFIGPROC) + _glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXGetVisualFromFBConfig"); if (!_glfw.glx.GetFBConfigs || !_glfw.glx.GetFBConfigAttrib || @@ -429,7 +429,7 @@ void _glfwTerminateGLX(void) if (_glfw.glx.handle) { - _glfw_dlclose(_glfw.glx.handle); + _glfwPlatformFreeModule(_glfw.glx.handle); _glfw.glx.handle = NULL; } } diff --git a/src/internal.h b/src/internal.h index 47f779e0..3ffc8d4e 100644 --- a/src/internal.h +++ b/src/internal.h @@ -59,6 +59,7 @@ #define _GLFW_MESSAGE_SIZE 1024 typedef int GLFWbool; +typedef void (*GLFWproc)(void); typedef struct _GLFWerror _GLFWerror; typedef struct _GLFWinitconfig _GLFWinitconfig; @@ -721,6 +722,10 @@ void _glfwPlatformDestroyMutex(_GLFWmutex* mutex); void _glfwPlatformLockMutex(_GLFWmutex* mutex); void _glfwPlatformUnlockMutex(_GLFWmutex* mutex); +void* _glfwPlatformLoadModule(const char* path); +void _glfwPlatformFreeModule(void* module); +GLFWproc _glfwPlatformGetModuleSymbol(void* module, const char* name); + ////////////////////////////////////////////////////////////////////////// ////// GLFW event API ////// diff --git a/src/null_platform.h b/src/null_platform.h index 49436dcc..e0b3f2ce 100644 --- a/src/null_platform.h +++ b/src/null_platform.h @@ -25,8 +25,6 @@ // //======================================================================== -#include - #define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowNull null #define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryNull null #define _GLFW_PLATFORM_MONITOR_STATE _GLFWmonitorNull null @@ -39,16 +37,6 @@ #include "posix_thread.h" #include "null_joystick.h" -#if defined(_GLFW_WIN32) - #define _glfw_dlopen(name) LoadLibraryA(name) - #define _glfw_dlclose(handle) FreeLibrary((HMODULE) handle) - #define _glfw_dlsym(handle, name) GetProcAddress((HMODULE) handle, name) -#else - #define _glfw_dlopen(name) dlopen(name, RTLD_LAZY | RTLD_LOCAL) - #define _glfw_dlclose(handle) dlclose(handle) - #define _glfw_dlsym(handle, name) dlsym(handle, name) -#endif - // Null-specific per-window data // typedef struct _GLFWwindowNull diff --git a/src/osmesa_context.c b/src/osmesa_context.c index da39ffcf..0bae30c9 100644 --- a/src/osmesa_context.c +++ b/src/osmesa_context.c @@ -136,7 +136,7 @@ GLFWbool _glfwInitOSMesa(void) for (i = 0; sonames[i]; i++) { - _glfw.osmesa.handle = _glfw_dlopen(sonames[i]); + _glfw.osmesa.handle = _glfwPlatformLoadModule(sonames[i]); if (_glfw.osmesa.handle) break; } @@ -148,19 +148,19 @@ GLFWbool _glfwInitOSMesa(void) } _glfw.osmesa.CreateContextExt = (PFN_OSMesaCreateContextExt) - _glfw_dlsym(_glfw.osmesa.handle, "OSMesaCreateContextExt"); + _glfwPlatformGetModuleSymbol(_glfw.osmesa.handle, "OSMesaCreateContextExt"); _glfw.osmesa.CreateContextAttribs = (PFN_OSMesaCreateContextAttribs) - _glfw_dlsym(_glfw.osmesa.handle, "OSMesaCreateContextAttribs"); + _glfwPlatformGetModuleSymbol(_glfw.osmesa.handle, "OSMesaCreateContextAttribs"); _glfw.osmesa.DestroyContext = (PFN_OSMesaDestroyContext) - _glfw_dlsym(_glfw.osmesa.handle, "OSMesaDestroyContext"); + _glfwPlatformGetModuleSymbol(_glfw.osmesa.handle, "OSMesaDestroyContext"); _glfw.osmesa.MakeCurrent = (PFN_OSMesaMakeCurrent) - _glfw_dlsym(_glfw.osmesa.handle, "OSMesaMakeCurrent"); + _glfwPlatformGetModuleSymbol(_glfw.osmesa.handle, "OSMesaMakeCurrent"); _glfw.osmesa.GetColorBuffer = (PFN_OSMesaGetColorBuffer) - _glfw_dlsym(_glfw.osmesa.handle, "OSMesaGetColorBuffer"); + _glfwPlatformGetModuleSymbol(_glfw.osmesa.handle, "OSMesaGetColorBuffer"); _glfw.osmesa.GetDepthBuffer = (PFN_OSMesaGetDepthBuffer) - _glfw_dlsym(_glfw.osmesa.handle, "OSMesaGetDepthBuffer"); + _glfwPlatformGetModuleSymbol(_glfw.osmesa.handle, "OSMesaGetDepthBuffer"); _glfw.osmesa.GetProcAddress = (PFN_OSMesaGetProcAddress) - _glfw_dlsym(_glfw.osmesa.handle, "OSMesaGetProcAddress"); + _glfwPlatformGetModuleSymbol(_glfw.osmesa.handle, "OSMesaGetProcAddress"); if (!_glfw.osmesa.CreateContextExt || !_glfw.osmesa.DestroyContext || @@ -183,7 +183,7 @@ void _glfwTerminateOSMesa(void) { if (_glfw.osmesa.handle) { - _glfw_dlclose(_glfw.osmesa.handle); + _glfwPlatformFreeModule(_glfw.osmesa.handle); _glfw.osmesa.handle = NULL; } } diff --git a/src/posix_module.c b/src/posix_module.c new file mode 100644 index 00000000..7079e5b4 --- /dev/null +++ b/src/posix_module.c @@ -0,0 +1,51 @@ +//======================================================================== +// GLFW 3.4 POSIX - www.glfw.org +//------------------------------------------------------------------------ +// Copyright (c) 2021 Camilla Löwy +// +// This software is provided 'as-is', without any express or implied +// warranty. In no event will the authors be held liable for any damages +// arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it +// freely, subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; you must not +// claim that you wrote the original software. If you use this software +// in a product, an acknowledgment in the product documentation would +// be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, and must not +// be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source +// distribution. +// +//======================================================================== +// It is fine to use C99 in this file because it will not be built with VS +//======================================================================== + +#include "internal.h" + +#include + +////////////////////////////////////////////////////////////////////////// +////// GLFW platform API ////// +////////////////////////////////////////////////////////////////////////// + +void* _glfwPlatformLoadModule(const char* path) +{ + return dlopen(path, RTLD_LAZY | RTLD_LOCAL); +} + +void _glfwPlatformFreeModule(void* module) +{ + dlclose(module); +} + +GLFWproc _glfwPlatformGetModuleSymbol(void* module, const char* name) +{ + return dlsym(module, name); +} + diff --git a/src/vulkan.c b/src/vulkan.c index e810ca06..ad299e5e 100644 --- a/src/vulkan.c +++ b/src/vulkan.c @@ -52,15 +52,15 @@ GLFWbool _glfwInitVulkan(int mode) #if !defined(_GLFW_VULKAN_STATIC) #if defined(_GLFW_VULKAN_LIBRARY) - _glfw.vk.handle = _glfw_dlopen(_GLFW_VULKAN_LIBRARY); + _glfw.vk.handle = _glfwPlatformLoadModule(_GLFW_VULKAN_LIBRARY); #elif defined(_GLFW_WIN32) - _glfw.vk.handle = _glfw_dlopen("vulkan-1.dll"); + _glfw.vk.handle = _glfwPlatformLoadModule("vulkan-1.dll"); #elif defined(_GLFW_COCOA) - _glfw.vk.handle = _glfw_dlopen("libvulkan.1.dylib"); + _glfw.vk.handle = _glfwPlatformLoadModule("libvulkan.1.dylib"); if (!_glfw.vk.handle) _glfw.vk.handle = _glfwLoadLocalVulkanLoaderNS(); #else - _glfw.vk.handle = _glfw_dlopen("libvulkan.so.1"); + _glfw.vk.handle = _glfwPlatformLoadModule("libvulkan.so.1"); #endif if (!_glfw.vk.handle) { @@ -71,7 +71,7 @@ GLFWbool _glfwInitVulkan(int mode) } _glfw.vk.GetInstanceProcAddr = (PFN_vkGetInstanceProcAddr) - _glfw_dlsym(_glfw.vk.handle, "vkGetInstanceProcAddr"); + _glfwPlatformGetModuleSymbol(_glfw.vk.handle, "vkGetInstanceProcAddr"); if (!_glfw.vk.GetInstanceProcAddr) { _glfwInputError(GLFW_API_UNAVAILABLE, @@ -158,7 +158,7 @@ void _glfwTerminateVulkan(void) { #if !defined(_GLFW_VULKAN_STATIC) if (_glfw.vk.handle) - _glfw_dlclose(_glfw.vk.handle); + _glfwPlatformFreeModule(_glfw.vk.handle); #endif } @@ -266,7 +266,7 @@ GLFWAPI GLFWvkproc glfwGetInstanceProcAddress(VkInstance instance, } #else if (!proc) - proc = (GLFWvkproc) _glfw_dlsym(_glfw.vk.handle, procname); + proc = (GLFWvkproc) _glfwPlatformGetModuleSymbol(_glfw.vk.handle, procname); #endif return proc; diff --git a/src/wgl_context.c b/src/wgl_context.c index 2c452661..a7b3ec7b 100644 --- a/src/wgl_context.c +++ b/src/wgl_context.c @@ -387,7 +387,7 @@ static GLFWglproc getProcAddressWGL(const char* procname) if (proc) return proc; - return (GLFWglproc) GetProcAddress(_glfw.wgl.instance, procname); + return (GLFWglproc) _glfwPlatformGetModuleSymbol(_glfw.wgl.instance, procname); } static void destroyContextWGL(_GLFWwindow* window) @@ -415,7 +415,7 @@ GLFWbool _glfwInitWGL(void) if (_glfw.wgl.instance) return GLFW_TRUE; - _glfw.wgl.instance = LoadLibraryA("opengl32.dll"); + _glfw.wgl.instance = _glfwPlatformLoadModule("opengl32.dll"); if (!_glfw.wgl.instance) { _glfwInputErrorWin32(GLFW_PLATFORM_ERROR, @@ -424,19 +424,19 @@ GLFWbool _glfwInitWGL(void) } _glfw.wgl.CreateContext = (PFN_wglCreateContext) - GetProcAddress(_glfw.wgl.instance, "wglCreateContext"); + _glfwPlatformGetModuleSymbol(_glfw.wgl.instance, "wglCreateContext"); _glfw.wgl.DeleteContext = (PFN_wglDeleteContext) - GetProcAddress(_glfw.wgl.instance, "wglDeleteContext"); + _glfwPlatformGetModuleSymbol(_glfw.wgl.instance, "wglDeleteContext"); _glfw.wgl.GetProcAddress = (PFN_wglGetProcAddress) - GetProcAddress(_glfw.wgl.instance, "wglGetProcAddress"); + _glfwPlatformGetModuleSymbol(_glfw.wgl.instance, "wglGetProcAddress"); _glfw.wgl.GetCurrentDC = (PFN_wglGetCurrentDC) - GetProcAddress(_glfw.wgl.instance, "wglGetCurrentDC"); + _glfwPlatformGetModuleSymbol(_glfw.wgl.instance, "wglGetCurrentDC"); _glfw.wgl.GetCurrentContext = (PFN_wglGetCurrentContext) - GetProcAddress(_glfw.wgl.instance, "wglGetCurrentContext"); + _glfwPlatformGetModuleSymbol(_glfw.wgl.instance, "wglGetCurrentContext"); _glfw.wgl.MakeCurrent = (PFN_wglMakeCurrent) - GetProcAddress(_glfw.wgl.instance, "wglMakeCurrent"); + _glfwPlatformGetModuleSymbol(_glfw.wgl.instance, "wglMakeCurrent"); _glfw.wgl.ShareLists = (PFN_wglShareLists) - GetProcAddress(_glfw.wgl.instance, "wglShareLists"); + _glfwPlatformGetModuleSymbol(_glfw.wgl.instance, "wglShareLists"); // NOTE: A dummy context has to be created for opengl32.dll to load the // OpenGL ICD, from which we can then query WGL extensions @@ -529,7 +529,7 @@ GLFWbool _glfwInitWGL(void) void _glfwTerminateWGL(void) { if (_glfw.wgl.instance) - FreeLibrary(_glfw.wgl.instance); + _glfwPlatformFreeModule(_glfw.wgl.instance); } #define setAttrib(a, v) \ diff --git a/src/win32_init.c b/src/win32_init.c index b871806e..53acab54 100644 --- a/src/win32_init.c +++ b/src/win32_init.c @@ -71,7 +71,7 @@ BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID reserved) // static GLFWbool loadLibraries(void) { - _glfw.win32.winmm.instance = LoadLibraryA("winmm.dll"); + _glfw.win32.winmm.instance = _glfwPlatformLoadModule("winmm.dll"); if (!_glfw.win32.winmm.instance) { _glfwInputErrorWin32(GLFW_PLATFORM_ERROR, @@ -80,9 +80,9 @@ static GLFWbool loadLibraries(void) } _glfw.win32.winmm.GetTime = (PFN_timeGetTime) - GetProcAddress(_glfw.win32.winmm.instance, "timeGetTime"); + _glfwPlatformGetModuleSymbol(_glfw.win32.winmm.instance, "timeGetTime"); - _glfw.win32.user32.instance = LoadLibraryA("user32.dll"); + _glfw.win32.user32.instance = _glfwPlatformLoadModule("user32.dll"); if (!_glfw.win32.user32.instance) { _glfwInputErrorWin32(GLFW_PLATFORM_ERROR, @@ -91,23 +91,23 @@ static GLFWbool loadLibraries(void) } _glfw.win32.user32.SetProcessDPIAware_ = (PFN_SetProcessDPIAware) - GetProcAddress(_glfw.win32.user32.instance, "SetProcessDPIAware"); + _glfwPlatformGetModuleSymbol(_glfw.win32.user32.instance, "SetProcessDPIAware"); _glfw.win32.user32.ChangeWindowMessageFilterEx_ = (PFN_ChangeWindowMessageFilterEx) - GetProcAddress(_glfw.win32.user32.instance, "ChangeWindowMessageFilterEx"); + _glfwPlatformGetModuleSymbol(_glfw.win32.user32.instance, "ChangeWindowMessageFilterEx"); _glfw.win32.user32.EnableNonClientDpiScaling_ = (PFN_EnableNonClientDpiScaling) - GetProcAddress(_glfw.win32.user32.instance, "EnableNonClientDpiScaling"); + _glfwPlatformGetModuleSymbol(_glfw.win32.user32.instance, "EnableNonClientDpiScaling"); _glfw.win32.user32.SetProcessDpiAwarenessContext_ = (PFN_SetProcessDpiAwarenessContext) - GetProcAddress(_glfw.win32.user32.instance, "SetProcessDpiAwarenessContext"); + _glfwPlatformGetModuleSymbol(_glfw.win32.user32.instance, "SetProcessDpiAwarenessContext"); _glfw.win32.user32.GetDpiForWindow_ = (PFN_GetDpiForWindow) - GetProcAddress(_glfw.win32.user32.instance, "GetDpiForWindow"); + _glfwPlatformGetModuleSymbol(_glfw.win32.user32.instance, "GetDpiForWindow"); _glfw.win32.user32.AdjustWindowRectExForDpi_ = (PFN_AdjustWindowRectExForDpi) - GetProcAddress(_glfw.win32.user32.instance, "AdjustWindowRectExForDpi"); + _glfwPlatformGetModuleSymbol(_glfw.win32.user32.instance, "AdjustWindowRectExForDpi"); - _glfw.win32.dinput8.instance = LoadLibraryA("dinput8.dll"); + _glfw.win32.dinput8.instance = _glfwPlatformLoadModule("dinput8.dll"); if (_glfw.win32.dinput8.instance) { _glfw.win32.dinput8.Create = (PFN_DirectInput8Create) - GetProcAddress(_glfw.win32.dinput8.instance, "DirectInput8Create"); + _glfwPlatformGetModuleSymbol(_glfw.win32.dinput8.instance, "DirectInput8Create"); } { @@ -124,46 +124,46 @@ static GLFWbool loadLibraries(void) for (i = 0; names[i]; i++) { - _glfw.win32.xinput.instance = LoadLibraryA(names[i]); + _glfw.win32.xinput.instance = _glfwPlatformLoadModule(names[i]); if (_glfw.win32.xinput.instance) { _glfw.win32.xinput.GetCapabilities = (PFN_XInputGetCapabilities) - GetProcAddress(_glfw.win32.xinput.instance, "XInputGetCapabilities"); + _glfwPlatformGetModuleSymbol(_glfw.win32.xinput.instance, "XInputGetCapabilities"); _glfw.win32.xinput.GetState = (PFN_XInputGetState) - GetProcAddress(_glfw.win32.xinput.instance, "XInputGetState"); + _glfwPlatformGetModuleSymbol(_glfw.win32.xinput.instance, "XInputGetState"); break; } } } - _glfw.win32.dwmapi.instance = LoadLibraryA("dwmapi.dll"); + _glfw.win32.dwmapi.instance = _glfwPlatformLoadModule("dwmapi.dll"); if (_glfw.win32.dwmapi.instance) { _glfw.win32.dwmapi.IsCompositionEnabled = (PFN_DwmIsCompositionEnabled) - GetProcAddress(_glfw.win32.dwmapi.instance, "DwmIsCompositionEnabled"); + _glfwPlatformGetModuleSymbol(_glfw.win32.dwmapi.instance, "DwmIsCompositionEnabled"); _glfw.win32.dwmapi.Flush = (PFN_DwmFlush) - GetProcAddress(_glfw.win32.dwmapi.instance, "DwmFlush"); + _glfwPlatformGetModuleSymbol(_glfw.win32.dwmapi.instance, "DwmFlush"); _glfw.win32.dwmapi.EnableBlurBehindWindow = (PFN_DwmEnableBlurBehindWindow) - GetProcAddress(_glfw.win32.dwmapi.instance, "DwmEnableBlurBehindWindow"); + _glfwPlatformGetModuleSymbol(_glfw.win32.dwmapi.instance, "DwmEnableBlurBehindWindow"); _glfw.win32.dwmapi.GetColorizationColor = (PFN_DwmGetColorizationColor) - GetProcAddress(_glfw.win32.dwmapi.instance, "DwmGetColorizationColor"); + _glfwPlatformGetModuleSymbol(_glfw.win32.dwmapi.instance, "DwmGetColorizationColor"); } - _glfw.win32.shcore.instance = LoadLibraryA("shcore.dll"); + _glfw.win32.shcore.instance = _glfwPlatformLoadModule("shcore.dll"); if (_glfw.win32.shcore.instance) { _glfw.win32.shcore.SetProcessDpiAwareness_ = (PFN_SetProcessDpiAwareness) - GetProcAddress(_glfw.win32.shcore.instance, "SetProcessDpiAwareness"); + _glfwPlatformGetModuleSymbol(_glfw.win32.shcore.instance, "SetProcessDpiAwareness"); _glfw.win32.shcore.GetDpiForMonitor_ = (PFN_GetDpiForMonitor) - GetProcAddress(_glfw.win32.shcore.instance, "GetDpiForMonitor"); + _glfwPlatformGetModuleSymbol(_glfw.win32.shcore.instance, "GetDpiForMonitor"); } - _glfw.win32.ntdll.instance = LoadLibraryA("ntdll.dll"); + _glfw.win32.ntdll.instance = _glfwPlatformLoadModule("ntdll.dll"); if (_glfw.win32.ntdll.instance) { _glfw.win32.ntdll.RtlVerifyVersionInfo_ = (PFN_RtlVerifyVersionInfo) - GetProcAddress(_glfw.win32.ntdll.instance, "RtlVerifyVersionInfo"); + _glfwPlatformGetModuleSymbol(_glfw.win32.ntdll.instance, "RtlVerifyVersionInfo"); } return GLFW_TRUE; @@ -174,25 +174,25 @@ static GLFWbool loadLibraries(void) static void freeLibraries(void) { if (_glfw.win32.xinput.instance) - FreeLibrary(_glfw.win32.xinput.instance); + _glfwPlatformFreeModule(_glfw.win32.xinput.instance); if (_glfw.win32.dinput8.instance) - FreeLibrary(_glfw.win32.dinput8.instance); + _glfwPlatformFreeModule(_glfw.win32.dinput8.instance); if (_glfw.win32.winmm.instance) - FreeLibrary(_glfw.win32.winmm.instance); + _glfwPlatformFreeModule(_glfw.win32.winmm.instance); if (_glfw.win32.user32.instance) - FreeLibrary(_glfw.win32.user32.instance); + _glfwPlatformFreeModule(_glfw.win32.user32.instance); if (_glfw.win32.dwmapi.instance) - FreeLibrary(_glfw.win32.dwmapi.instance); + _glfwPlatformFreeModule(_glfw.win32.dwmapi.instance); if (_glfw.win32.shcore.instance) - FreeLibrary(_glfw.win32.shcore.instance); + _glfwPlatformFreeModule(_glfw.win32.shcore.instance); if (_glfw.win32.ntdll.instance) - FreeLibrary(_glfw.win32.ntdll.instance); + _glfwPlatformFreeModule(_glfw.win32.ntdll.instance); } // Create key code translation tables diff --git a/src/win32_module.c b/src/win32_module.c new file mode 100644 index 00000000..35bdd71d --- /dev/null +++ b/src/win32_module.c @@ -0,0 +1,49 @@ +//======================================================================== +// GLFW 3.4 Win32 - www.glfw.org +//------------------------------------------------------------------------ +// Copyright (c) 2021 Camilla Löwy +// +// This software is provided 'as-is', without any express or implied +// warranty. In no event will the authors be held liable for any damages +// arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it +// freely, subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; you must not +// claim that you wrote the original software. If you use this software +// in a product, an acknowledgment in the product documentation would +// be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, and must not +// be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source +// distribution. +// +//======================================================================== +// Please use C89 style variable declarations in this file because VS 2010 +//======================================================================== + +#include "internal.h" + +////////////////////////////////////////////////////////////////////////// +////// GLFW platform API ////// +////////////////////////////////////////////////////////////////////////// + +void* _glfwPlatformLoadModule(const char* path) +{ + return LoadLibraryA(path); +} + +void _glfwPlatformFreeModule(void* module) +{ + FreeLibrary((HMODULE) module); +} + +GLFWproc _glfwPlatformGetModuleSymbol(void* module, const char* name) +{ + return (GLFWproc) GetProcAddress((HMODULE) module, name); +} + diff --git a/src/win32_platform.h b/src/win32_platform.h index 715026eb..9008f131 100644 --- a/src/win32_platform.h +++ b/src/win32_platform.h @@ -284,10 +284,6 @@ typedef VkBool32 (APIENTRY *PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR)( #define _GLFW_WNDCLASSNAME L"GLFW30" #endif -#define _glfw_dlopen(name) LoadLibraryA(name) -#define _glfw_dlclose(handle) FreeLibrary((HMODULE) handle) -#define _glfw_dlsym(handle, name) GetProcAddress((HMODULE) handle, name) - #define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowWin32 win32 #define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryWin32 win32 #define _GLFW_PLATFORM_LIBRARY_TIMER_STATE _GLFWtimerWin32 win32 diff --git a/src/wl_init.c b/src/wl_init.c index 5893970a..609283f6 100644 --- a/src/wl_init.c +++ b/src/wl_init.c @@ -1053,7 +1053,7 @@ int _glfwPlatformInit(void) long cursorSizeLong; int cursorSize; - _glfw.wl.client.handle = _glfw_dlopen("libwayland-client.so.0"); + _glfw.wl.client.handle = _glfwPlatformLoadModule("libwayland-client.so.0"); if (!_glfw.wl.client.handle) { _glfwInputError(GLFW_PLATFORM_ERROR, @@ -1062,41 +1062,41 @@ int _glfwPlatformInit(void) } _glfw.wl.client.display_flush = (PFN_wl_display_flush) - _glfw_dlsym(_glfw.wl.client.handle, "wl_display_flush"); + _glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_display_flush"); _glfw.wl.client.display_cancel_read = (PFN_wl_display_cancel_read) - _glfw_dlsym(_glfw.wl.client.handle, "wl_display_cancel_read"); + _glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_display_cancel_read"); _glfw.wl.client.display_dispatch_pending = (PFN_wl_display_dispatch_pending) - _glfw_dlsym(_glfw.wl.client.handle, "wl_display_dispatch_pending"); + _glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_display_dispatch_pending"); _glfw.wl.client.display_read_events = (PFN_wl_display_read_events) - _glfw_dlsym(_glfw.wl.client.handle, "wl_display_read_events"); + _glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_display_read_events"); _glfw.wl.client.display_connect = (PFN_wl_display_connect) - _glfw_dlsym(_glfw.wl.client.handle, "wl_display_connect"); + _glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_display_connect"); _glfw.wl.client.display_disconnect = (PFN_wl_display_disconnect) - _glfw_dlsym(_glfw.wl.client.handle, "wl_display_disconnect"); + _glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_display_disconnect"); _glfw.wl.client.display_roundtrip = (PFN_wl_display_roundtrip) - _glfw_dlsym(_glfw.wl.client.handle, "wl_display_roundtrip"); + _glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_display_roundtrip"); _glfw.wl.client.display_get_fd = (PFN_wl_display_get_fd) - _glfw_dlsym(_glfw.wl.client.handle, "wl_display_get_fd"); + _glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_display_get_fd"); _glfw.wl.client.display_prepare_read = (PFN_wl_display_prepare_read) - _glfw_dlsym(_glfw.wl.client.handle, "wl_display_prepare_read"); + _glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_display_prepare_read"); _glfw.wl.client.proxy_marshal = (PFN_wl_proxy_marshal) - _glfw_dlsym(_glfw.wl.client.handle, "wl_proxy_marshal"); + _glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_proxy_marshal"); _glfw.wl.client.proxy_add_listener = (PFN_wl_proxy_add_listener) - _glfw_dlsym(_glfw.wl.client.handle, "wl_proxy_add_listener"); + _glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_proxy_add_listener"); _glfw.wl.client.proxy_destroy = (PFN_wl_proxy_destroy) - _glfw_dlsym(_glfw.wl.client.handle, "wl_proxy_destroy"); + _glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_proxy_destroy"); _glfw.wl.client.proxy_marshal_constructor = (PFN_wl_proxy_marshal_constructor) - _glfw_dlsym(_glfw.wl.client.handle, "wl_proxy_marshal_constructor"); + _glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_proxy_marshal_constructor"); _glfw.wl.client.proxy_marshal_constructor_versioned = (PFN_wl_proxy_marshal_constructor_versioned) - _glfw_dlsym(_glfw.wl.client.handle, "wl_proxy_marshal_constructor_versioned"); + _glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_proxy_marshal_constructor_versioned"); _glfw.wl.client.proxy_get_user_data = (PFN_wl_proxy_get_user_data) - _glfw_dlsym(_glfw.wl.client.handle, "wl_proxy_get_user_data"); + _glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_proxy_get_user_data"); _glfw.wl.client.proxy_set_user_data = (PFN_wl_proxy_set_user_data) - _glfw_dlsym(_glfw.wl.client.handle, "wl_proxy_set_user_data"); + _glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_proxy_set_user_data"); _glfw.wl.client.proxy_get_version = (PFN_wl_proxy_get_version) - _glfw_dlsym(_glfw.wl.client.handle, "wl_proxy_get_version"); + _glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_proxy_get_version"); _glfw.wl.client.proxy_marshal_flags = (PFN_wl_proxy_marshal_flags) - _glfw_dlsym(_glfw.wl.client.handle, "wl_proxy_marshal_flags"); + _glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_proxy_marshal_flags"); if (!_glfw.wl.client.display_flush || !_glfw.wl.client.display_cancel_read || @@ -1120,7 +1120,7 @@ int _glfwPlatformInit(void) return GLFW_FALSE; } - _glfw.wl.cursor.handle = _glfw_dlopen("libwayland-cursor.so.0"); + _glfw.wl.cursor.handle = _glfwPlatformLoadModule("libwayland-cursor.so.0"); if (!_glfw.wl.cursor.handle) { _glfwInputError(GLFW_PLATFORM_ERROR, @@ -1129,15 +1129,15 @@ int _glfwPlatformInit(void) } _glfw.wl.cursor.theme_load = (PFN_wl_cursor_theme_load) - _glfw_dlsym(_glfw.wl.cursor.handle, "wl_cursor_theme_load"); + _glfwPlatformGetModuleSymbol(_glfw.wl.cursor.handle, "wl_cursor_theme_load"); _glfw.wl.cursor.theme_destroy = (PFN_wl_cursor_theme_destroy) - _glfw_dlsym(_glfw.wl.cursor.handle, "wl_cursor_theme_destroy"); + _glfwPlatformGetModuleSymbol(_glfw.wl.cursor.handle, "wl_cursor_theme_destroy"); _glfw.wl.cursor.theme_get_cursor = (PFN_wl_cursor_theme_get_cursor) - _glfw_dlsym(_glfw.wl.cursor.handle, "wl_cursor_theme_get_cursor"); + _glfwPlatformGetModuleSymbol(_glfw.wl.cursor.handle, "wl_cursor_theme_get_cursor"); _glfw.wl.cursor.image_get_buffer = (PFN_wl_cursor_image_get_buffer) - _glfw_dlsym(_glfw.wl.cursor.handle, "wl_cursor_image_get_buffer"); + _glfwPlatformGetModuleSymbol(_glfw.wl.cursor.handle, "wl_cursor_image_get_buffer"); - _glfw.wl.egl.handle = _glfw_dlopen("libwayland-egl.so.1"); + _glfw.wl.egl.handle = _glfwPlatformLoadModule("libwayland-egl.so.1"); if (!_glfw.wl.egl.handle) { _glfwInputError(GLFW_PLATFORM_ERROR, @@ -1146,13 +1146,13 @@ int _glfwPlatformInit(void) } _glfw.wl.egl.window_create = (PFN_wl_egl_window_create) - _glfw_dlsym(_glfw.wl.egl.handle, "wl_egl_window_create"); + _glfwPlatformGetModuleSymbol(_glfw.wl.egl.handle, "wl_egl_window_create"); _glfw.wl.egl.window_destroy = (PFN_wl_egl_window_destroy) - _glfw_dlsym(_glfw.wl.egl.handle, "wl_egl_window_destroy"); + _glfwPlatformGetModuleSymbol(_glfw.wl.egl.handle, "wl_egl_window_destroy"); _glfw.wl.egl.window_resize = (PFN_wl_egl_window_resize) - _glfw_dlsym(_glfw.wl.egl.handle, "wl_egl_window_resize"); + _glfwPlatformGetModuleSymbol(_glfw.wl.egl.handle, "wl_egl_window_resize"); - _glfw.wl.xkb.handle = _glfw_dlopen("libxkbcommon.so.0"); + _glfw.wl.xkb.handle = _glfwPlatformLoadModule("libxkbcommon.so.0"); if (!_glfw.wl.xkb.handle) { _glfwInputError(GLFW_PLATFORM_ERROR, @@ -1161,43 +1161,43 @@ int _glfwPlatformInit(void) } _glfw.wl.xkb.context_new = (PFN_xkb_context_new) - _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_context_new"); + _glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_context_new"); _glfw.wl.xkb.context_unref = (PFN_xkb_context_unref) - _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_context_unref"); + _glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_context_unref"); _glfw.wl.xkb.keymap_new_from_string = (PFN_xkb_keymap_new_from_string) - _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_keymap_new_from_string"); + _glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_keymap_new_from_string"); _glfw.wl.xkb.keymap_unref = (PFN_xkb_keymap_unref) - _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_keymap_unref"); + _glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_keymap_unref"); _glfw.wl.xkb.keymap_mod_get_index = (PFN_xkb_keymap_mod_get_index) - _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_keymap_mod_get_index"); + _glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_keymap_mod_get_index"); _glfw.wl.xkb.keymap_key_repeats = (PFN_xkb_keymap_key_repeats) - _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_keymap_key_repeats"); + _glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_keymap_key_repeats"); _glfw.wl.xkb.state_new = (PFN_xkb_state_new) - _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_state_new"); + _glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_state_new"); _glfw.wl.xkb.state_unref = (PFN_xkb_state_unref) - _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_state_unref"); + _glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_state_unref"); _glfw.wl.xkb.state_key_get_syms = (PFN_xkb_state_key_get_syms) - _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_state_key_get_syms"); + _glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_state_key_get_syms"); _glfw.wl.xkb.state_update_mask = (PFN_xkb_state_update_mask) - _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_state_update_mask"); + _glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_state_update_mask"); _glfw.wl.xkb.state_serialize_mods = (PFN_xkb_state_serialize_mods) - _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_state_serialize_mods"); + _glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_state_serialize_mods"); #ifdef HAVE_XKBCOMMON_COMPOSE_H _glfw.wl.xkb.compose_table_new_from_locale = (PFN_xkb_compose_table_new_from_locale) - _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_compose_table_new_from_locale"); + _glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_compose_table_new_from_locale"); _glfw.wl.xkb.compose_table_unref = (PFN_xkb_compose_table_unref) - _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_compose_table_unref"); + _glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_compose_table_unref"); _glfw.wl.xkb.compose_state_new = (PFN_xkb_compose_state_new) - _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_compose_state_new"); + _glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_compose_state_new"); _glfw.wl.xkb.compose_state_unref = (PFN_xkb_compose_state_unref) - _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_compose_state_unref"); + _glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_compose_state_unref"); _glfw.wl.xkb.compose_state_feed = (PFN_xkb_compose_state_feed) - _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_compose_state_feed"); + _glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_compose_state_feed"); _glfw.wl.xkb.compose_state_get_status = (PFN_xkb_compose_state_get_status) - _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_compose_state_get_status"); + _glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_compose_state_get_status"); _glfw.wl.xkb.compose_state_get_one_sym = (PFN_xkb_compose_state_get_one_sym) - _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_compose_state_get_one_sym"); + _glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_compose_state_get_one_sym"); #endif _glfw.wl.display = wl_display_connect(NULL); @@ -1290,7 +1290,7 @@ void _glfwPlatformTerminate(void) _glfwTerminateEGL(); if (_glfw.wl.egl.handle) { - _glfw_dlclose(_glfw.wl.egl.handle); + _glfwPlatformFreeModule(_glfw.wl.egl.handle); _glfw.wl.egl.handle = NULL; } @@ -1306,7 +1306,7 @@ void _glfwPlatformTerminate(void) xkb_context_unref(_glfw.wl.xkb.context); if (_glfw.wl.xkb.handle) { - _glfw_dlclose(_glfw.wl.xkb.handle); + _glfwPlatformFreeModule(_glfw.wl.xkb.handle); _glfw.wl.xkb.handle = NULL; } @@ -1316,7 +1316,7 @@ void _glfwPlatformTerminate(void) wl_cursor_theme_destroy(_glfw.wl.cursorThemeHiDPI); if (_glfw.wl.cursor.handle) { - _glfw_dlclose(_glfw.wl.cursor.handle); + _glfwPlatformFreeModule(_glfw.wl.cursor.handle); _glfw.wl.cursor.handle = NULL; } diff --git a/src/wl_platform.h b/src/wl_platform.h index 777ae2e7..71512b59 100644 --- a/src/wl_platform.h +++ b/src/wl_platform.h @@ -29,7 +29,6 @@ #ifdef HAVE_XKBCOMMON_COMPOSE_H #include #endif -#include typedef VkFlags VkWaylandSurfaceCreateFlagsKHR; @@ -133,10 +132,6 @@ struct wl_shm; #define xdg_toplevel_interface _glfw_xdg_toplevel_interface #define xdg_wm_base_interface _glfw_xdg_wm_base_interface -#define _glfw_dlopen(name) dlopen(name, RTLD_LAZY | RTLD_LOCAL) -#define _glfw_dlclose(handle) dlclose(handle) -#define _glfw_dlsym(handle, name) dlsym(handle, name) - #define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowWayland wl #define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryWayland wl #define _GLFW_PLATFORM_MONITOR_STATE _GLFWmonitorWayland wl diff --git a/src/x11_init.c b/src/x11_init.c index e4cb09de..34e52252 100644 --- a/src/x11_init.c +++ b/src/x11_init.c @@ -601,17 +601,17 @@ static void detectEWMH(void) // static GLFWbool initExtensions(void) { - _glfw.x11.vidmode.handle = _glfw_dlopen("libXxf86vm.so.1"); + _glfw.x11.vidmode.handle = _glfwPlatformLoadModule("libXxf86vm.so.1"); if (_glfw.x11.vidmode.handle) { _glfw.x11.vidmode.QueryExtension = (PFN_XF86VidModeQueryExtension) - _glfw_dlsym(_glfw.x11.vidmode.handle, "XF86VidModeQueryExtension"); + _glfwPlatformGetModuleSymbol(_glfw.x11.vidmode.handle, "XF86VidModeQueryExtension"); _glfw.x11.vidmode.GetGammaRamp = (PFN_XF86VidModeGetGammaRamp) - _glfw_dlsym(_glfw.x11.vidmode.handle, "XF86VidModeGetGammaRamp"); + _glfwPlatformGetModuleSymbol(_glfw.x11.vidmode.handle, "XF86VidModeGetGammaRamp"); _glfw.x11.vidmode.SetGammaRamp = (PFN_XF86VidModeSetGammaRamp) - _glfw_dlsym(_glfw.x11.vidmode.handle, "XF86VidModeSetGammaRamp"); + _glfwPlatformGetModuleSymbol(_glfw.x11.vidmode.handle, "XF86VidModeSetGammaRamp"); _glfw.x11.vidmode.GetGammaRampSize = (PFN_XF86VidModeGetGammaRampSize) - _glfw_dlsym(_glfw.x11.vidmode.handle, "XF86VidModeGetGammaRampSize"); + _glfwPlatformGetModuleSymbol(_glfw.x11.vidmode.handle, "XF86VidModeGetGammaRampSize"); _glfw.x11.vidmode.available = XF86VidModeQueryExtension(_glfw.x11.display, @@ -620,16 +620,16 @@ static GLFWbool initExtensions(void) } #if defined(__CYGWIN__) - _glfw.x11.xi.handle = _glfw_dlopen("libXi-6.so"); + _glfw.x11.xi.handle = _glfwPlatformLoadModule("libXi-6.so"); #else - _glfw.x11.xi.handle = _glfw_dlopen("libXi.so.6"); + _glfw.x11.xi.handle = _glfwPlatformLoadModule("libXi.so.6"); #endif if (_glfw.x11.xi.handle) { _glfw.x11.xi.QueryVersion = (PFN_XIQueryVersion) - _glfw_dlsym(_glfw.x11.xi.handle, "XIQueryVersion"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xi.handle, "XIQueryVersion"); _glfw.x11.xi.SelectEvents = (PFN_XISelectEvents) - _glfw_dlsym(_glfw.x11.xi.handle, "XISelectEvents"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xi.handle, "XISelectEvents"); if (XQueryExtension(_glfw.x11.display, "XInputExtension", @@ -650,48 +650,48 @@ static GLFWbool initExtensions(void) } #if defined(__CYGWIN__) - _glfw.x11.randr.handle = _glfw_dlopen("libXrandr-2.so"); + _glfw.x11.randr.handle = _glfwPlatformLoadModule("libXrandr-2.so"); #else - _glfw.x11.randr.handle = _glfw_dlopen("libXrandr.so.2"); + _glfw.x11.randr.handle = _glfwPlatformLoadModule("libXrandr.so.2"); #endif if (_glfw.x11.randr.handle) { _glfw.x11.randr.AllocGamma = (PFN_XRRAllocGamma) - _glfw_dlsym(_glfw.x11.randr.handle, "XRRAllocGamma"); + _glfwPlatformGetModuleSymbol(_glfw.x11.randr.handle, "XRRAllocGamma"); _glfw.x11.randr.FreeGamma = (PFN_XRRFreeGamma) - _glfw_dlsym(_glfw.x11.randr.handle, "XRRFreeGamma"); + _glfwPlatformGetModuleSymbol(_glfw.x11.randr.handle, "XRRFreeGamma"); _glfw.x11.randr.FreeCrtcInfo = (PFN_XRRFreeCrtcInfo) - _glfw_dlsym(_glfw.x11.randr.handle, "XRRFreeCrtcInfo"); + _glfwPlatformGetModuleSymbol(_glfw.x11.randr.handle, "XRRFreeCrtcInfo"); _glfw.x11.randr.FreeGamma = (PFN_XRRFreeGamma) - _glfw_dlsym(_glfw.x11.randr.handle, "XRRFreeGamma"); + _glfwPlatformGetModuleSymbol(_glfw.x11.randr.handle, "XRRFreeGamma"); _glfw.x11.randr.FreeOutputInfo = (PFN_XRRFreeOutputInfo) - _glfw_dlsym(_glfw.x11.randr.handle, "XRRFreeOutputInfo"); + _glfwPlatformGetModuleSymbol(_glfw.x11.randr.handle, "XRRFreeOutputInfo"); _glfw.x11.randr.FreeScreenResources = (PFN_XRRFreeScreenResources) - _glfw_dlsym(_glfw.x11.randr.handle, "XRRFreeScreenResources"); + _glfwPlatformGetModuleSymbol(_glfw.x11.randr.handle, "XRRFreeScreenResources"); _glfw.x11.randr.GetCrtcGamma = (PFN_XRRGetCrtcGamma) - _glfw_dlsym(_glfw.x11.randr.handle, "XRRGetCrtcGamma"); + _glfwPlatformGetModuleSymbol(_glfw.x11.randr.handle, "XRRGetCrtcGamma"); _glfw.x11.randr.GetCrtcGammaSize = (PFN_XRRGetCrtcGammaSize) - _glfw_dlsym(_glfw.x11.randr.handle, "XRRGetCrtcGammaSize"); + _glfwPlatformGetModuleSymbol(_glfw.x11.randr.handle, "XRRGetCrtcGammaSize"); _glfw.x11.randr.GetCrtcInfo = (PFN_XRRGetCrtcInfo) - _glfw_dlsym(_glfw.x11.randr.handle, "XRRGetCrtcInfo"); + _glfwPlatformGetModuleSymbol(_glfw.x11.randr.handle, "XRRGetCrtcInfo"); _glfw.x11.randr.GetOutputInfo = (PFN_XRRGetOutputInfo) - _glfw_dlsym(_glfw.x11.randr.handle, "XRRGetOutputInfo"); + _glfwPlatformGetModuleSymbol(_glfw.x11.randr.handle, "XRRGetOutputInfo"); _glfw.x11.randr.GetOutputPrimary = (PFN_XRRGetOutputPrimary) - _glfw_dlsym(_glfw.x11.randr.handle, "XRRGetOutputPrimary"); + _glfwPlatformGetModuleSymbol(_glfw.x11.randr.handle, "XRRGetOutputPrimary"); _glfw.x11.randr.GetScreenResourcesCurrent = (PFN_XRRGetScreenResourcesCurrent) - _glfw_dlsym(_glfw.x11.randr.handle, "XRRGetScreenResourcesCurrent"); + _glfwPlatformGetModuleSymbol(_glfw.x11.randr.handle, "XRRGetScreenResourcesCurrent"); _glfw.x11.randr.QueryExtension = (PFN_XRRQueryExtension) - _glfw_dlsym(_glfw.x11.randr.handle, "XRRQueryExtension"); + _glfwPlatformGetModuleSymbol(_glfw.x11.randr.handle, "XRRQueryExtension"); _glfw.x11.randr.QueryVersion = (PFN_XRRQueryVersion) - _glfw_dlsym(_glfw.x11.randr.handle, "XRRQueryVersion"); + _glfwPlatformGetModuleSymbol(_glfw.x11.randr.handle, "XRRQueryVersion"); _glfw.x11.randr.SelectInput = (PFN_XRRSelectInput) - _glfw_dlsym(_glfw.x11.randr.handle, "XRRSelectInput"); + _glfwPlatformGetModuleSymbol(_glfw.x11.randr.handle, "XRRSelectInput"); _glfw.x11.randr.SetCrtcConfig = (PFN_XRRSetCrtcConfig) - _glfw_dlsym(_glfw.x11.randr.handle, "XRRSetCrtcConfig"); + _glfwPlatformGetModuleSymbol(_glfw.x11.randr.handle, "XRRSetCrtcConfig"); _glfw.x11.randr.SetCrtcGamma = (PFN_XRRSetCrtcGamma) - _glfw_dlsym(_glfw.x11.randr.handle, "XRRSetCrtcGamma"); + _glfwPlatformGetModuleSymbol(_glfw.x11.randr.handle, "XRRSetCrtcGamma"); _glfw.x11.randr.UpdateConfiguration = (PFN_XRRUpdateConfiguration) - _glfw_dlsym(_glfw.x11.randr.handle, "XRRUpdateConfiguration"); + _glfwPlatformGetModuleSymbol(_glfw.x11.randr.handle, "XRRUpdateConfiguration"); if (XRRQueryExtension(_glfw.x11.display, &_glfw.x11.randr.eventBase, @@ -742,39 +742,39 @@ static GLFWbool initExtensions(void) } #if defined(__CYGWIN__) - _glfw.x11.xcursor.handle = _glfw_dlopen("libXcursor-1.so"); + _glfw.x11.xcursor.handle = _glfwPlatformLoadModule("libXcursor-1.so"); #else - _glfw.x11.xcursor.handle = _glfw_dlopen("libXcursor.so.1"); + _glfw.x11.xcursor.handle = _glfwPlatformLoadModule("libXcursor.so.1"); #endif if (_glfw.x11.xcursor.handle) { _glfw.x11.xcursor.ImageCreate = (PFN_XcursorImageCreate) - _glfw_dlsym(_glfw.x11.xcursor.handle, "XcursorImageCreate"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xcursor.handle, "XcursorImageCreate"); _glfw.x11.xcursor.ImageDestroy = (PFN_XcursorImageDestroy) - _glfw_dlsym(_glfw.x11.xcursor.handle, "XcursorImageDestroy"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xcursor.handle, "XcursorImageDestroy"); _glfw.x11.xcursor.ImageLoadCursor = (PFN_XcursorImageLoadCursor) - _glfw_dlsym(_glfw.x11.xcursor.handle, "XcursorImageLoadCursor"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xcursor.handle, "XcursorImageLoadCursor"); _glfw.x11.xcursor.GetTheme = (PFN_XcursorGetTheme) - _glfw_dlsym(_glfw.x11.xcursor.handle, "XcursorGetTheme"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xcursor.handle, "XcursorGetTheme"); _glfw.x11.xcursor.GetDefaultSize = (PFN_XcursorGetDefaultSize) - _glfw_dlsym(_glfw.x11.xcursor.handle, "XcursorGetDefaultSize"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xcursor.handle, "XcursorGetDefaultSize"); _glfw.x11.xcursor.LibraryLoadImage = (PFN_XcursorLibraryLoadImage) - _glfw_dlsym(_glfw.x11.xcursor.handle, "XcursorLibraryLoadImage"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xcursor.handle, "XcursorLibraryLoadImage"); } #if defined(__CYGWIN__) - _glfw.x11.xinerama.handle = _glfw_dlopen("libXinerama-1.so"); + _glfw.x11.xinerama.handle = _glfwPlatformLoadModule("libXinerama-1.so"); #else - _glfw.x11.xinerama.handle = _glfw_dlopen("libXinerama.so.1"); + _glfw.x11.xinerama.handle = _glfwPlatformLoadModule("libXinerama.so.1"); #endif if (_glfw.x11.xinerama.handle) { _glfw.x11.xinerama.IsActive = (PFN_XineramaIsActive) - _glfw_dlsym(_glfw.x11.xinerama.handle, "XineramaIsActive"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xinerama.handle, "XineramaIsActive"); _glfw.x11.xinerama.QueryExtension = (PFN_XineramaQueryExtension) - _glfw_dlsym(_glfw.x11.xinerama.handle, "XineramaQueryExtension"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xinerama.handle, "XineramaQueryExtension"); _glfw.x11.xinerama.QueryScreens = (PFN_XineramaQueryScreens) - _glfw_dlsym(_glfw.x11.xinerama.handle, "XineramaQueryScreens"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xinerama.handle, "XineramaQueryScreens"); if (XineramaQueryExtension(_glfw.x11.display, &_glfw.x11.xinerama.major, @@ -816,31 +816,31 @@ static GLFWbool initExtensions(void) if (_glfw.hints.init.x11.xcbVulkanSurface) { #if defined(__CYGWIN__) - _glfw.x11.x11xcb.handle = _glfw_dlopen("libX11-xcb-1.so"); + _glfw.x11.x11xcb.handle = _glfwPlatformLoadModule("libX11-xcb-1.so"); #else - _glfw.x11.x11xcb.handle = _glfw_dlopen("libX11-xcb.so.1"); + _glfw.x11.x11xcb.handle = _glfwPlatformLoadModule("libX11-xcb.so.1"); #endif } if (_glfw.x11.x11xcb.handle) { _glfw.x11.x11xcb.GetXCBConnection = (PFN_XGetXCBConnection) - _glfw_dlsym(_glfw.x11.x11xcb.handle, "XGetXCBConnection"); + _glfwPlatformGetModuleSymbol(_glfw.x11.x11xcb.handle, "XGetXCBConnection"); } #if defined(__CYGWIN__) - _glfw.x11.xrender.handle = _glfw_dlopen("libXrender-1.so"); + _glfw.x11.xrender.handle = _glfwPlatformLoadModule("libXrender-1.so"); #else - _glfw.x11.xrender.handle = _glfw_dlopen("libXrender.so.1"); + _glfw.x11.xrender.handle = _glfwPlatformLoadModule("libXrender.so.1"); #endif if (_glfw.x11.xrender.handle) { _glfw.x11.xrender.QueryExtension = (PFN_XRenderQueryExtension) - _glfw_dlsym(_glfw.x11.xrender.handle, "XRenderQueryExtension"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xrender.handle, "XRenderQueryExtension"); _glfw.x11.xrender.QueryVersion = (PFN_XRenderQueryVersion) - _glfw_dlsym(_glfw.x11.xrender.handle, "XRenderQueryVersion"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xrender.handle, "XRenderQueryVersion"); _glfw.x11.xrender.FindVisualFormat = (PFN_XRenderFindVisualFormat) - _glfw_dlsym(_glfw.x11.xrender.handle, "XRenderFindVisualFormat"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xrender.handle, "XRenderFindVisualFormat"); if (XRenderQueryExtension(_glfw.x11.display, &_glfw.x11.xrender.errorBase, @@ -856,20 +856,20 @@ static GLFWbool initExtensions(void) } #if defined(__CYGWIN__) - _glfw.x11.xshape.handle = _glfw_dlopen("libXext-6.so"); + _glfw.x11.xshape.handle = _glfwPlatformLoadModule("libXext-6.so"); #else - _glfw.x11.xshape.handle = _glfw_dlopen("libXext.so.6"); + _glfw.x11.xshape.handle = _glfwPlatformLoadModule("libXext.so.6"); #endif if (_glfw.x11.xshape.handle) { _glfw.x11.xshape.QueryExtension = (PFN_XShapeQueryExtension) - _glfw_dlsym(_glfw.x11.xshape.handle, "XShapeQueryExtension"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xshape.handle, "XShapeQueryExtension"); _glfw.x11.xshape.ShapeCombineRegion = (PFN_XShapeCombineRegion) - _glfw_dlsym(_glfw.x11.xshape.handle, "XShapeCombineRegion"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xshape.handle, "XShapeCombineRegion"); _glfw.x11.xshape.QueryVersion = (PFN_XShapeQueryVersion) - _glfw_dlsym(_glfw.x11.xshape.handle, "XShapeQueryVersion"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xshape.handle, "XShapeQueryVersion"); _glfw.x11.xshape.ShapeCombineMask = (PFN_XShapeCombineMask) - _glfw_dlsym(_glfw.x11.xshape.handle, "XShapeCombineMask"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xshape.handle, "XShapeCombineMask"); if (XShapeQueryExtension(_glfw.x11.display, &_glfw.x11.xshape.errorBase, @@ -1119,9 +1119,9 @@ int _glfwPlatformInit(void) setlocale(LC_CTYPE, ""); #if defined(__CYGWIN__) - _glfw.x11.xlib.handle = _glfw_dlopen("libX11-6.so"); + _glfw.x11.xlib.handle = _glfwPlatformLoadModule("libX11-6.so"); #else - _glfw.x11.xlib.handle = _glfw_dlopen("libX11.so.6"); + _glfw.x11.xlib.handle = _glfwPlatformLoadModule("libX11.so.6"); #endif if (!_glfw.x11.xlib.handle) { @@ -1130,209 +1130,209 @@ int _glfwPlatformInit(void) } _glfw.x11.xlib.AllocClassHint = (PFN_XAllocClassHint) - _glfw_dlsym(_glfw.x11.xlib.handle, "XAllocClassHint"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XAllocClassHint"); _glfw.x11.xlib.AllocSizeHints = (PFN_XAllocSizeHints) - _glfw_dlsym(_glfw.x11.xlib.handle, "XAllocSizeHints"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XAllocSizeHints"); _glfw.x11.xlib.AllocWMHints = (PFN_XAllocWMHints) - _glfw_dlsym(_glfw.x11.xlib.handle, "XAllocWMHints"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XAllocWMHints"); _glfw.x11.xlib.ChangeProperty = (PFN_XChangeProperty) - _glfw_dlsym(_glfw.x11.xlib.handle, "XChangeProperty"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XChangeProperty"); _glfw.x11.xlib.ChangeWindowAttributes = (PFN_XChangeWindowAttributes) - _glfw_dlsym(_glfw.x11.xlib.handle, "XChangeWindowAttributes"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XChangeWindowAttributes"); _glfw.x11.xlib.CheckIfEvent = (PFN_XCheckIfEvent) - _glfw_dlsym(_glfw.x11.xlib.handle, "XCheckIfEvent"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XCheckIfEvent"); _glfw.x11.xlib.CheckTypedWindowEvent = (PFN_XCheckTypedWindowEvent) - _glfw_dlsym(_glfw.x11.xlib.handle, "XCheckTypedWindowEvent"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XCheckTypedWindowEvent"); _glfw.x11.xlib.CloseDisplay = (PFN_XCloseDisplay) - _glfw_dlsym(_glfw.x11.xlib.handle, "XCloseDisplay"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XCloseDisplay"); _glfw.x11.xlib.CloseIM = (PFN_XCloseIM) - _glfw_dlsym(_glfw.x11.xlib.handle, "XCloseIM"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XCloseIM"); _glfw.x11.xlib.ConvertSelection = (PFN_XConvertSelection) - _glfw_dlsym(_glfw.x11.xlib.handle, "XConvertSelection"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XConvertSelection"); _glfw.x11.xlib.CreateColormap = (PFN_XCreateColormap) - _glfw_dlsym(_glfw.x11.xlib.handle, "XCreateColormap"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XCreateColormap"); _glfw.x11.xlib.CreateFontCursor = (PFN_XCreateFontCursor) - _glfw_dlsym(_glfw.x11.xlib.handle, "XCreateFontCursor"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XCreateFontCursor"); _glfw.x11.xlib.CreateIC = (PFN_XCreateIC) - _glfw_dlsym(_glfw.x11.xlib.handle, "XCreateIC"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XCreateIC"); _glfw.x11.xlib.CreateRegion = (PFN_XCreateRegion) - _glfw_dlsym(_glfw.x11.xlib.handle, "XCreateRegion"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XCreateRegion"); _glfw.x11.xlib.CreateWindow = (PFN_XCreateWindow) - _glfw_dlsym(_glfw.x11.xlib.handle, "XCreateWindow"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XCreateWindow"); _glfw.x11.xlib.DefineCursor = (PFN_XDefineCursor) - _glfw_dlsym(_glfw.x11.xlib.handle, "XDefineCursor"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XDefineCursor"); _glfw.x11.xlib.DeleteContext = (PFN_XDeleteContext) - _glfw_dlsym(_glfw.x11.xlib.handle, "XDeleteContext"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XDeleteContext"); _glfw.x11.xlib.DeleteProperty = (PFN_XDeleteProperty) - _glfw_dlsym(_glfw.x11.xlib.handle, "XDeleteProperty"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XDeleteProperty"); _glfw.x11.xlib.DestroyIC = (PFN_XDestroyIC) - _glfw_dlsym(_glfw.x11.xlib.handle, "XDestroyIC"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XDestroyIC"); _glfw.x11.xlib.DestroyRegion = (PFN_XDestroyRegion) - _glfw_dlsym(_glfw.x11.xlib.handle, "XDestroyRegion"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XDestroyRegion"); _glfw.x11.xlib.DestroyWindow = (PFN_XDestroyWindow) - _glfw_dlsym(_glfw.x11.xlib.handle, "XDestroyWindow"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XDestroyWindow"); _glfw.x11.xlib.DisplayKeycodes = (PFN_XDisplayKeycodes) - _glfw_dlsym(_glfw.x11.xlib.handle, "XDisplayKeycodes"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XDisplayKeycodes"); _glfw.x11.xlib.EventsQueued = (PFN_XEventsQueued) - _glfw_dlsym(_glfw.x11.xlib.handle, "XEventsQueued"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XEventsQueued"); _glfw.x11.xlib.FilterEvent = (PFN_XFilterEvent) - _glfw_dlsym(_glfw.x11.xlib.handle, "XFilterEvent"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XFilterEvent"); _glfw.x11.xlib.FindContext = (PFN_XFindContext) - _glfw_dlsym(_glfw.x11.xlib.handle, "XFindContext"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XFindContext"); _glfw.x11.xlib.Flush = (PFN_XFlush) - _glfw_dlsym(_glfw.x11.xlib.handle, "XFlush"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XFlush"); _glfw.x11.xlib.Free = (PFN_XFree) - _glfw_dlsym(_glfw.x11.xlib.handle, "XFree"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XFree"); _glfw.x11.xlib.FreeColormap = (PFN_XFreeColormap) - _glfw_dlsym(_glfw.x11.xlib.handle, "XFreeColormap"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XFreeColormap"); _glfw.x11.xlib.FreeCursor = (PFN_XFreeCursor) - _glfw_dlsym(_glfw.x11.xlib.handle, "XFreeCursor"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XFreeCursor"); _glfw.x11.xlib.FreeEventData = (PFN_XFreeEventData) - _glfw_dlsym(_glfw.x11.xlib.handle, "XFreeEventData"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XFreeEventData"); _glfw.x11.xlib.GetErrorText = (PFN_XGetErrorText) - _glfw_dlsym(_glfw.x11.xlib.handle, "XGetErrorText"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XGetErrorText"); _glfw.x11.xlib.GetEventData = (PFN_XGetEventData) - _glfw_dlsym(_glfw.x11.xlib.handle, "XGetEventData"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XGetEventData"); _glfw.x11.xlib.GetICValues = (PFN_XGetICValues) - _glfw_dlsym(_glfw.x11.xlib.handle, "XGetICValues"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XGetICValues"); _glfw.x11.xlib.GetIMValues = (PFN_XGetIMValues) - _glfw_dlsym(_glfw.x11.xlib.handle, "XGetIMValues"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XGetIMValues"); _glfw.x11.xlib.GetInputFocus = (PFN_XGetInputFocus) - _glfw_dlsym(_glfw.x11.xlib.handle, "XGetInputFocus"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XGetInputFocus"); _glfw.x11.xlib.GetKeyboardMapping = (PFN_XGetKeyboardMapping) - _glfw_dlsym(_glfw.x11.xlib.handle, "XGetKeyboardMapping"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XGetKeyboardMapping"); _glfw.x11.xlib.GetScreenSaver = (PFN_XGetScreenSaver) - _glfw_dlsym(_glfw.x11.xlib.handle, "XGetScreenSaver"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XGetScreenSaver"); _glfw.x11.xlib.GetSelectionOwner = (PFN_XGetSelectionOwner) - _glfw_dlsym(_glfw.x11.xlib.handle, "XGetSelectionOwner"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XGetSelectionOwner"); _glfw.x11.xlib.GetVisualInfo = (PFN_XGetVisualInfo) - _glfw_dlsym(_glfw.x11.xlib.handle, "XGetVisualInfo"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XGetVisualInfo"); _glfw.x11.xlib.GetWMNormalHints = (PFN_XGetWMNormalHints) - _glfw_dlsym(_glfw.x11.xlib.handle, "XGetWMNormalHints"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XGetWMNormalHints"); _glfw.x11.xlib.GetWindowAttributes = (PFN_XGetWindowAttributes) - _glfw_dlsym(_glfw.x11.xlib.handle, "XGetWindowAttributes"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XGetWindowAttributes"); _glfw.x11.xlib.GetWindowProperty = (PFN_XGetWindowProperty) - _glfw_dlsym(_glfw.x11.xlib.handle, "XGetWindowProperty"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XGetWindowProperty"); _glfw.x11.xlib.GrabPointer = (PFN_XGrabPointer) - _glfw_dlsym(_glfw.x11.xlib.handle, "XGrabPointer"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XGrabPointer"); _glfw.x11.xlib.IconifyWindow = (PFN_XIconifyWindow) - _glfw_dlsym(_glfw.x11.xlib.handle, "XIconifyWindow"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XIconifyWindow"); _glfw.x11.xlib.InitThreads = (PFN_XInitThreads) - _glfw_dlsym(_glfw.x11.xlib.handle, "XInitThreads"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XInitThreads"); _glfw.x11.xlib.InternAtom = (PFN_XInternAtom) - _glfw_dlsym(_glfw.x11.xlib.handle, "XInternAtom"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XInternAtom"); _glfw.x11.xlib.LookupString = (PFN_XLookupString) - _glfw_dlsym(_glfw.x11.xlib.handle, "XLookupString"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XLookupString"); _glfw.x11.xlib.MapRaised = (PFN_XMapRaised) - _glfw_dlsym(_glfw.x11.xlib.handle, "XMapRaised"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XMapRaised"); _glfw.x11.xlib.MapWindow = (PFN_XMapWindow) - _glfw_dlsym(_glfw.x11.xlib.handle, "XMapWindow"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XMapWindow"); _glfw.x11.xlib.MoveResizeWindow = (PFN_XMoveResizeWindow) - _glfw_dlsym(_glfw.x11.xlib.handle, "XMoveResizeWindow"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XMoveResizeWindow"); _glfw.x11.xlib.MoveWindow = (PFN_XMoveWindow) - _glfw_dlsym(_glfw.x11.xlib.handle, "XMoveWindow"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XMoveWindow"); _glfw.x11.xlib.NextEvent = (PFN_XNextEvent) - _glfw_dlsym(_glfw.x11.xlib.handle, "XNextEvent"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XNextEvent"); _glfw.x11.xlib.OpenDisplay = (PFN_XOpenDisplay) - _glfw_dlsym(_glfw.x11.xlib.handle, "XOpenDisplay"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XOpenDisplay"); _glfw.x11.xlib.OpenIM = (PFN_XOpenIM) - _glfw_dlsym(_glfw.x11.xlib.handle, "XOpenIM"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XOpenIM"); _glfw.x11.xlib.PeekEvent = (PFN_XPeekEvent) - _glfw_dlsym(_glfw.x11.xlib.handle, "XPeekEvent"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XPeekEvent"); _glfw.x11.xlib.Pending = (PFN_XPending) - _glfw_dlsym(_glfw.x11.xlib.handle, "XPending"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XPending"); _glfw.x11.xlib.QueryExtension = (PFN_XQueryExtension) - _glfw_dlsym(_glfw.x11.xlib.handle, "XQueryExtension"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XQueryExtension"); _glfw.x11.xlib.QueryPointer = (PFN_XQueryPointer) - _glfw_dlsym(_glfw.x11.xlib.handle, "XQueryPointer"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XQueryPointer"); _glfw.x11.xlib.RaiseWindow = (PFN_XRaiseWindow) - _glfw_dlsym(_glfw.x11.xlib.handle, "XRaiseWindow"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XRaiseWindow"); _glfw.x11.xlib.RegisterIMInstantiateCallback = (PFN_XRegisterIMInstantiateCallback) - _glfw_dlsym(_glfw.x11.xlib.handle, "XRegisterIMInstantiateCallback"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XRegisterIMInstantiateCallback"); _glfw.x11.xlib.ResizeWindow = (PFN_XResizeWindow) - _glfw_dlsym(_glfw.x11.xlib.handle, "XResizeWindow"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XResizeWindow"); _glfw.x11.xlib.ResourceManagerString = (PFN_XResourceManagerString) - _glfw_dlsym(_glfw.x11.xlib.handle, "XResourceManagerString"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XResourceManagerString"); _glfw.x11.xlib.SaveContext = (PFN_XSaveContext) - _glfw_dlsym(_glfw.x11.xlib.handle, "XSaveContext"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XSaveContext"); _glfw.x11.xlib.SelectInput = (PFN_XSelectInput) - _glfw_dlsym(_glfw.x11.xlib.handle, "XSelectInput"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XSelectInput"); _glfw.x11.xlib.SendEvent = (PFN_XSendEvent) - _glfw_dlsym(_glfw.x11.xlib.handle, "XSendEvent"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XSendEvent"); _glfw.x11.xlib.SetClassHint = (PFN_XSetClassHint) - _glfw_dlsym(_glfw.x11.xlib.handle, "XSetClassHint"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XSetClassHint"); _glfw.x11.xlib.SetErrorHandler = (PFN_XSetErrorHandler) - _glfw_dlsym(_glfw.x11.xlib.handle, "XSetErrorHandler"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XSetErrorHandler"); _glfw.x11.xlib.SetICFocus = (PFN_XSetICFocus) - _glfw_dlsym(_glfw.x11.xlib.handle, "XSetICFocus"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XSetICFocus"); _glfw.x11.xlib.SetIMValues = (PFN_XSetIMValues) - _glfw_dlsym(_glfw.x11.xlib.handle, "XSetIMValues"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XSetIMValues"); _glfw.x11.xlib.SetInputFocus = (PFN_XSetInputFocus) - _glfw_dlsym(_glfw.x11.xlib.handle, "XSetInputFocus"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XSetInputFocus"); _glfw.x11.xlib.SetLocaleModifiers = (PFN_XSetLocaleModifiers) - _glfw_dlsym(_glfw.x11.xlib.handle, "XSetLocaleModifiers"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XSetLocaleModifiers"); _glfw.x11.xlib.SetScreenSaver = (PFN_XSetScreenSaver) - _glfw_dlsym(_glfw.x11.xlib.handle, "XSetScreenSaver"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XSetScreenSaver"); _glfw.x11.xlib.SetSelectionOwner = (PFN_XSetSelectionOwner) - _glfw_dlsym(_glfw.x11.xlib.handle, "XSetSelectionOwner"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XSetSelectionOwner"); _glfw.x11.xlib.SetWMHints = (PFN_XSetWMHints) - _glfw_dlsym(_glfw.x11.xlib.handle, "XSetWMHints"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XSetWMHints"); _glfw.x11.xlib.SetWMNormalHints = (PFN_XSetWMNormalHints) - _glfw_dlsym(_glfw.x11.xlib.handle, "XSetWMNormalHints"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XSetWMNormalHints"); _glfw.x11.xlib.SetWMProtocols = (PFN_XSetWMProtocols) - _glfw_dlsym(_glfw.x11.xlib.handle, "XSetWMProtocols"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XSetWMProtocols"); _glfw.x11.xlib.SupportsLocale = (PFN_XSupportsLocale) - _glfw_dlsym(_glfw.x11.xlib.handle, "XSupportsLocale"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XSupportsLocale"); _glfw.x11.xlib.Sync = (PFN_XSync) - _glfw_dlsym(_glfw.x11.xlib.handle, "XSync"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XSync"); _glfw.x11.xlib.TranslateCoordinates = (PFN_XTranslateCoordinates) - _glfw_dlsym(_glfw.x11.xlib.handle, "XTranslateCoordinates"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XTranslateCoordinates"); _glfw.x11.xlib.UndefineCursor = (PFN_XUndefineCursor) - _glfw_dlsym(_glfw.x11.xlib.handle, "XUndefineCursor"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XUndefineCursor"); _glfw.x11.xlib.UngrabPointer = (PFN_XUngrabPointer) - _glfw_dlsym(_glfw.x11.xlib.handle, "XUngrabPointer"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XUngrabPointer"); _glfw.x11.xlib.UnmapWindow = (PFN_XUnmapWindow) - _glfw_dlsym(_glfw.x11.xlib.handle, "XUnmapWindow"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XUnmapWindow"); _glfw.x11.xlib.UnsetICFocus = (PFN_XUnsetICFocus) - _glfw_dlsym(_glfw.x11.xlib.handle, "XUnsetICFocus"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XUnsetICFocus"); _glfw.x11.xlib.VisualIDFromVisual = (PFN_XVisualIDFromVisual) - _glfw_dlsym(_glfw.x11.xlib.handle, "XVisualIDFromVisual"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XVisualIDFromVisual"); _glfw.x11.xlib.WarpPointer = (PFN_XWarpPointer) - _glfw_dlsym(_glfw.x11.xlib.handle, "XWarpPointer"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XWarpPointer"); _glfw.x11.xkb.FreeKeyboard = (PFN_XkbFreeKeyboard) - _glfw_dlsym(_glfw.x11.xlib.handle, "XkbFreeKeyboard"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XkbFreeKeyboard"); _glfw.x11.xkb.FreeNames = (PFN_XkbFreeNames) - _glfw_dlsym(_glfw.x11.xlib.handle, "XkbFreeNames"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XkbFreeNames"); _glfw.x11.xkb.GetMap = (PFN_XkbGetMap) - _glfw_dlsym(_glfw.x11.xlib.handle, "XkbGetMap"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XkbGetMap"); _glfw.x11.xkb.GetNames = (PFN_XkbGetNames) - _glfw_dlsym(_glfw.x11.xlib.handle, "XkbGetNames"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XkbGetNames"); _glfw.x11.xkb.GetState = (PFN_XkbGetState) - _glfw_dlsym(_glfw.x11.xlib.handle, "XkbGetState"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XkbGetState"); _glfw.x11.xkb.KeycodeToKeysym = (PFN_XkbKeycodeToKeysym) - _glfw_dlsym(_glfw.x11.xlib.handle, "XkbKeycodeToKeysym"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XkbKeycodeToKeysym"); _glfw.x11.xkb.QueryExtension = (PFN_XkbQueryExtension) - _glfw_dlsym(_glfw.x11.xlib.handle, "XkbQueryExtension"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XkbQueryExtension"); _glfw.x11.xkb.SelectEventDetails = (PFN_XkbSelectEventDetails) - _glfw_dlsym(_glfw.x11.xlib.handle, "XkbSelectEventDetails"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XkbSelectEventDetails"); _glfw.x11.xkb.SetDetectableAutoRepeat = (PFN_XkbSetDetectableAutoRepeat) - _glfw_dlsym(_glfw.x11.xlib.handle, "XkbSetDetectableAutoRepeat"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XkbSetDetectableAutoRepeat"); _glfw.x11.xrm.DestroyDatabase = (PFN_XrmDestroyDatabase) - _glfw_dlsym(_glfw.x11.xlib.handle, "XrmDestroyDatabase"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XrmDestroyDatabase"); _glfw.x11.xrm.GetResource = (PFN_XrmGetResource) - _glfw_dlsym(_glfw.x11.xlib.handle, "XrmGetResource"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XrmGetResource"); _glfw.x11.xrm.GetStringDatabase = (PFN_XrmGetStringDatabase) - _glfw_dlsym(_glfw.x11.xlib.handle, "XrmGetStringDatabase"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XrmGetStringDatabase"); _glfw.x11.xrm.Initialize = (PFN_XrmInitialize) - _glfw_dlsym(_glfw.x11.xlib.handle, "XrmInitialize"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XrmInitialize"); _glfw.x11.xrm.UniqueQuark = (PFN_XrmUniqueQuark) - _glfw_dlsym(_glfw.x11.xlib.handle, "XrmUniqueQuark"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XrmUniqueQuark"); _glfw.x11.xlib.UnregisterIMInstantiateCallback = (PFN_XUnregisterIMInstantiateCallback) - _glfw_dlsym(_glfw.x11.xlib.handle, "XUnregisterIMInstantiateCallback"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XUnregisterIMInstantiateCallback"); _glfw.x11.xlib.utf8LookupString = (PFN_Xutf8LookupString) - _glfw_dlsym(_glfw.x11.xlib.handle, "Xutf8LookupString"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "Xutf8LookupString"); _glfw.x11.xlib.utf8SetWMProperties = (PFN_Xutf8SetWMProperties) - _glfw_dlsym(_glfw.x11.xlib.handle, "Xutf8SetWMProperties"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "Xutf8SetWMProperties"); if (_glfw.x11.xlib.utf8LookupString && _glfw.x11.xlib.utf8SetWMProperties) _glfw.x11.xlib.utf8 = GLFW_TRUE; @@ -1427,43 +1427,43 @@ void _glfwPlatformTerminate(void) if (_glfw.x11.x11xcb.handle) { - _glfw_dlclose(_glfw.x11.x11xcb.handle); + _glfwPlatformFreeModule(_glfw.x11.x11xcb.handle); _glfw.x11.x11xcb.handle = NULL; } if (_glfw.x11.xcursor.handle) { - _glfw_dlclose(_glfw.x11.xcursor.handle); + _glfwPlatformFreeModule(_glfw.x11.xcursor.handle); _glfw.x11.xcursor.handle = NULL; } if (_glfw.x11.randr.handle) { - _glfw_dlclose(_glfw.x11.randr.handle); + _glfwPlatformFreeModule(_glfw.x11.randr.handle); _glfw.x11.randr.handle = NULL; } if (_glfw.x11.xinerama.handle) { - _glfw_dlclose(_glfw.x11.xinerama.handle); + _glfwPlatformFreeModule(_glfw.x11.xinerama.handle); _glfw.x11.xinerama.handle = NULL; } if (_glfw.x11.xrender.handle) { - _glfw_dlclose(_glfw.x11.xrender.handle); + _glfwPlatformFreeModule(_glfw.x11.xrender.handle); _glfw.x11.xrender.handle = NULL; } if (_glfw.x11.vidmode.handle) { - _glfw_dlclose(_glfw.x11.vidmode.handle); + _glfwPlatformFreeModule(_glfw.x11.vidmode.handle); _glfw.x11.vidmode.handle = NULL; } if (_glfw.x11.xi.handle) { - _glfw_dlclose(_glfw.x11.xi.handle); + _glfwPlatformFreeModule(_glfw.x11.xi.handle); _glfw.x11.xi.handle = NULL; } @@ -1474,7 +1474,7 @@ void _glfwPlatformTerminate(void) if (_glfw.x11.xlib.handle) { - _glfw_dlclose(_glfw.x11.xlib.handle); + _glfwPlatformFreeModule(_glfw.x11.xlib.handle); _glfw.x11.xlib.handle = NULL; } } diff --git a/src/x11_platform.h b/src/x11_platform.h index 2db58eea..ac8319de 100644 --- a/src/x11_platform.h +++ b/src/x11_platform.h @@ -28,7 +28,6 @@ #include #include #include -#include #include #include @@ -384,10 +383,6 @@ typedef VkBool32 (APIENTRY *PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR)(Vk #include "null_joystick.h" #endif -#define _glfw_dlopen(name) dlopen(name, RTLD_LAZY | RTLD_LOCAL) -#define _glfw_dlclose(handle) dlclose(handle) -#define _glfw_dlsym(handle, name) dlsym(handle, name) - #define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowX11 x11 #define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryX11 x11 #define _GLFW_PLATFORM_MONITOR_STATE _GLFWmonitorX11 x11 From f5758d75d04a12b24c335b8586c73ee9b2b57398 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Sun, 18 Jul 2021 16:57:53 +0200 Subject: [PATCH 039/208] Remove context creation backend headers These headers come from when GLFW only supported a single context creation API at a time, chosen at compile-time. Since EGL and OSMesa are now always enabled and the platform-specific APIs are tied to their specific window system, there is no reason to keep these declarations separate from the internal.h and *_platform.h header files. --- src/CMakeLists.txt | 27 ++--- src/cocoa_platform.h | 35 +++++- src/egl_context.h | 227 ------------------------------------- src/glx_context.h | 179 ------------------------------ src/internal.h | 258 +++++++++++++++++++++++++++++++++++++++++-- src/nsgl_context.h | 64 ----------- src/osmesa_context.h | 88 --------------- src/wgl_context.h | 158 -------------------------- src/win32_platform.h | 130 +++++++++++++++++++++- src/x11_platform.h | 152 ++++++++++++++++++++++++- 10 files changed, 572 insertions(+), 746 deletions(-) delete mode 100644 src/egl_context.h delete mode 100644 src/glx_context.h delete mode 100644 src/nsgl_context.h delete mode 100644 src/osmesa_context.h delete mode 100644 src/wgl_context.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 850074c0..964bb909 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -17,39 +17,34 @@ set_target_properties(update_mappings PROPERTIES FOLDER "GLFW3") if (_GLFW_COCOA) target_compile_definitions(glfw PRIVATE _GLFW_COCOA) target_sources(glfw PRIVATE cocoa_platform.h cocoa_joystick.h posix_thread.h - nsgl_context.h egl_context.h osmesa_context.h cocoa_init.m cocoa_joystick.m cocoa_monitor.m cocoa_window.m cocoa_time.c posix_thread.c nsgl_context.m egl_context.c osmesa_context.c) elseif (_GLFW_WIN32) target_compile_definitions(glfw PRIVATE _GLFW_WIN32) - target_sources(glfw PRIVATE win32_platform.h win32_joystick.h wgl_context.h - egl_context.h osmesa_context.h win32_init.c - win32_joystick.c win32_monitor.c win32_time.c - win32_thread.c win32_window.c wgl_context.c - egl_context.c osmesa_context.c) + target_sources(glfw PRIVATE win32_platform.h win32_joystick.h + win32_init.c win32_joystick.c win32_monitor.c + win32_time.c win32_thread.c win32_window.c + wgl_context.c egl_context.c osmesa_context.c) elseif (_GLFW_X11) target_compile_definitions(glfw PRIVATE _GLFW_X11) target_sources(glfw PRIVATE x11_platform.h xkb_unicode.h posix_time.h - posix_thread.h glx_context.h egl_context.h - osmesa_context.h x11_init.c x11_monitor.c + posix_thread.h x11_init.c x11_monitor.c x11_window.c xkb_unicode.c posix_time.c posix_thread.c glx_context.c egl_context.c osmesa_context.c) elseif (_GLFW_WAYLAND) target_compile_definitions(glfw PRIVATE _GLFW_WAYLAND) target_sources(glfw PRIVATE wl_platform.h posix_time.h posix_thread.h - xkb_unicode.h egl_context.h osmesa_context.h - wl_init.c wl_monitor.c wl_window.c posix_time.c - posix_thread.c xkb_unicode.c egl_context.c - osmesa_context.c) + xkb_unicode.h wl_init.c wl_monitor.c wl_window.c + posix_time.c posix_thread.c xkb_unicode.c + egl_context.c osmesa_context.c) elseif (_GLFW_OSMESA) target_compile_definitions(glfw PRIVATE _GLFW_OSMESA) target_sources(glfw PRIVATE null_platform.h null_joystick.h posix_time.h - posix_thread.h osmesa_context.h null_init.c - null_monitor.c null_window.c null_joystick.c - posix_time.c posix_thread.c egl_context.c - osmesa_context.c) + posix_thread.h null_init.c null_monitor.c + null_window.c null_joystick.c posix_time.c + posix_thread.c egl_context.c osmesa_context.c) endif() if (WIN32) diff --git a/src/cocoa_platform.h b/src/cocoa_platform.h index ba575ffa..9d3e9fe0 100644 --- a/src/cocoa_platform.h +++ b/src/cocoa_platform.h @@ -40,6 +40,14 @@ typedef void* id; #endif +// NOTE: Many Cocoa enum values have been renamed and we need to build across +// SDK versions where one is unavailable or the other deprecated +// We use the newer names in code and these macros to handle compatibility +#if MAC_OS_X_VERSION_MAX_ALLOWED < 101400 + #define NSOpenGLContextParameterSwapInterval NSOpenGLCPSwapInterval + #define NSOpenGLContextParameterSurfaceOpacity NSOpenGLCPSurfaceOpacity +#endif + // NOTE: Many Cocoa enum values have been renamed and we need to build across // SDK versions where one is unavailable or the other deprecated // We use the newer names in code and these macros to handle compatibility @@ -85,7 +93,6 @@ typedef VkResult (APIENTRY *PFN_vkCreateMetalSurfaceEXT)(VkInstance,const VkMeta #include "posix_thread.h" #include "cocoa_joystick.h" -#include "nsgl_context.h" #define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowNS ns #define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryNS ns @@ -93,6 +100,9 @@ typedef VkResult (APIENTRY *PFN_vkCreateMetalSurfaceEXT)(VkInstance,const VkMeta #define _GLFW_PLATFORM_MONITOR_STATE _GLFWmonitorNS ns #define _GLFW_PLATFORM_CURSOR_STATE _GLFWcursorNS ns +#define _GLFW_PLATFORM_CONTEXT_STATE _GLFWcontextNSGL nsgl +#define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE _GLFWlibraryNSGL nsgl + // HIToolbox.framework pointer typedefs #define kTISPropertyUnicodeKeyLayoutData _glfw.ns.tis.kPropertyUnicodeKeyLayoutData typedef TISInputSourceRef (*PFN_TISCopyCurrentKeyboardLayoutInputSource)(void); @@ -103,6 +113,22 @@ typedef UInt8 (*PFN_LMGetKbdType)(void); #define LMGetKbdType _glfw.ns.tis.GetKbdType +// NSGL-specific per-context data +// +typedef struct _GLFWcontextNSGL +{ + id pixelFormat; + id object; +} _GLFWcontextNSGL; + +// NSGL-specific global data +// +typedef struct _GLFWlibraryNSGL +{ + // dlopen handle for OpenGL.framework (for glfwGetProcAddress) + CFBundleRef framework; +} _GLFWlibraryNSGL; + // Cocoa-specific per-window data // typedef struct _GLFWwindowNS @@ -194,3 +220,10 @@ float _glfwTransformYNS(float y); void* _glfwLoadLocalVulkanLoaderNS(void); +GLFWbool _glfwInitNSGL(void); +void _glfwTerminateNSGL(void); +GLFWbool _glfwCreateContextNSGL(_GLFWwindow* window, + const _GLFWctxconfig* ctxconfig, + const _GLFWfbconfig* fbconfig); +void _glfwDestroyContextNSGL(_GLFWwindow* window); + diff --git a/src/egl_context.h b/src/egl_context.h deleted file mode 100644 index 22928b5d..00000000 --- a/src/egl_context.h +++ /dev/null @@ -1,227 +0,0 @@ -//======================================================================== -// GLFW 3.4 EGL - www.glfw.org -//------------------------------------------------------------------------ -// Copyright (c) 2002-2006 Marcus Geelnard -// Copyright (c) 2006-2017 Camilla Löwy -// -// This software is provided 'as-is', without any express or implied -// warranty. In no event will the authors be held liable for any damages -// arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it -// freely, subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; you must not -// claim that you wrote the original software. If you use this software -// in a product, an acknowledgment in the product documentation would -// be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, and must not -// be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source -// distribution. -// -//======================================================================== - -#if defined(_GLFW_WIN32) - #define EGLAPIENTRY __stdcall -#else - #define EGLAPIENTRY -#endif - -#define EGL_SUCCESS 0x3000 -#define EGL_NOT_INITIALIZED 0x3001 -#define EGL_BAD_ACCESS 0x3002 -#define EGL_BAD_ALLOC 0x3003 -#define EGL_BAD_ATTRIBUTE 0x3004 -#define EGL_BAD_CONFIG 0x3005 -#define EGL_BAD_CONTEXT 0x3006 -#define EGL_BAD_CURRENT_SURFACE 0x3007 -#define EGL_BAD_DISPLAY 0x3008 -#define EGL_BAD_MATCH 0x3009 -#define EGL_BAD_NATIVE_PIXMAP 0x300a -#define EGL_BAD_NATIVE_WINDOW 0x300b -#define EGL_BAD_PARAMETER 0x300c -#define EGL_BAD_SURFACE 0x300d -#define EGL_CONTEXT_LOST 0x300e -#define EGL_COLOR_BUFFER_TYPE 0x303f -#define EGL_RGB_BUFFER 0x308e -#define EGL_SURFACE_TYPE 0x3033 -#define EGL_WINDOW_BIT 0x0004 -#define EGL_RENDERABLE_TYPE 0x3040 -#define EGL_OPENGL_ES_BIT 0x0001 -#define EGL_OPENGL_ES2_BIT 0x0004 -#define EGL_OPENGL_BIT 0x0008 -#define EGL_ALPHA_SIZE 0x3021 -#define EGL_BLUE_SIZE 0x3022 -#define EGL_GREEN_SIZE 0x3023 -#define EGL_RED_SIZE 0x3024 -#define EGL_DEPTH_SIZE 0x3025 -#define EGL_STENCIL_SIZE 0x3026 -#define EGL_SAMPLES 0x3031 -#define EGL_OPENGL_ES_API 0x30a0 -#define EGL_OPENGL_API 0x30a2 -#define EGL_NONE 0x3038 -#define EGL_RENDER_BUFFER 0x3086 -#define EGL_SINGLE_BUFFER 0x3085 -#define EGL_EXTENSIONS 0x3055 -#define EGL_CONTEXT_CLIENT_VERSION 0x3098 -#define EGL_NATIVE_VISUAL_ID 0x302e -#define EGL_NO_SURFACE ((EGLSurface) 0) -#define EGL_NO_DISPLAY ((EGLDisplay) 0) -#define EGL_NO_CONTEXT ((EGLContext) 0) -#define EGL_DEFAULT_DISPLAY ((EGLNativeDisplayType) 0) - -#define EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR 0x00000002 -#define EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR 0x00000001 -#define EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR 0x00000002 -#define EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR 0x00000001 -#define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR 0x31bd -#define EGL_NO_RESET_NOTIFICATION_KHR 0x31be -#define EGL_LOSE_CONTEXT_ON_RESET_KHR 0x31bf -#define EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR 0x00000004 -#define EGL_CONTEXT_MAJOR_VERSION_KHR 0x3098 -#define EGL_CONTEXT_MINOR_VERSION_KHR 0x30fb -#define EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR 0x30fd -#define EGL_CONTEXT_FLAGS_KHR 0x30fc -#define EGL_CONTEXT_OPENGL_NO_ERROR_KHR 0x31b3 -#define EGL_GL_COLORSPACE_KHR 0x309d -#define EGL_GL_COLORSPACE_SRGB_KHR 0x3089 -#define EGL_CONTEXT_RELEASE_BEHAVIOR_KHR 0x2097 -#define EGL_CONTEXT_RELEASE_BEHAVIOR_NONE_KHR 0 -#define EGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_KHR 0x2098 -#define EGL_PLATFORM_X11_EXT 0x31d5 -#define EGL_PLATFORM_WAYLAND_EXT 0x31d8 -#define EGL_PLATFORM_ANGLE_ANGLE 0x3202 -#define EGL_PLATFORM_ANGLE_TYPE_ANGLE 0x3203 -#define EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE 0x320d -#define EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE 0x320e -#define EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE 0x3207 -#define EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE 0x3208 -#define EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE 0x3450 -#define EGL_PLATFORM_ANGLE_TYPE_METAL_ANGLE 0x3489 -#define EGL_PLATFORM_ANGLE_NATIVE_PLATFORM_TYPE_ANGLE 0x348f - -typedef int EGLint; -typedef unsigned int EGLBoolean; -typedef unsigned int EGLenum; -typedef void* EGLConfig; -typedef void* EGLContext; -typedef void* EGLDisplay; -typedef void* EGLSurface; - -typedef void* EGLNativeDisplayType; -typedef void* EGLNativeWindowType; - -// EGL function pointer typedefs -typedef EGLBoolean (EGLAPIENTRY * PFN_eglGetConfigAttrib)(EGLDisplay,EGLConfig,EGLint,EGLint*); -typedef EGLBoolean (EGLAPIENTRY * PFN_eglGetConfigs)(EGLDisplay,EGLConfig*,EGLint,EGLint*); -typedef EGLDisplay (EGLAPIENTRY * PFN_eglGetDisplay)(EGLNativeDisplayType); -typedef EGLint (EGLAPIENTRY * PFN_eglGetError)(void); -typedef EGLBoolean (EGLAPIENTRY * PFN_eglInitialize)(EGLDisplay,EGLint*,EGLint*); -typedef EGLBoolean (EGLAPIENTRY * PFN_eglTerminate)(EGLDisplay); -typedef EGLBoolean (EGLAPIENTRY * PFN_eglBindAPI)(EGLenum); -typedef EGLContext (EGLAPIENTRY * PFN_eglCreateContext)(EGLDisplay,EGLConfig,EGLContext,const EGLint*); -typedef EGLBoolean (EGLAPIENTRY * PFN_eglDestroySurface)(EGLDisplay,EGLSurface); -typedef EGLBoolean (EGLAPIENTRY * PFN_eglDestroyContext)(EGLDisplay,EGLContext); -typedef EGLSurface (EGLAPIENTRY * PFN_eglCreateWindowSurface)(EGLDisplay,EGLConfig,EGLNativeWindowType,const EGLint*); -typedef EGLBoolean (EGLAPIENTRY * PFN_eglMakeCurrent)(EGLDisplay,EGLSurface,EGLSurface,EGLContext); -typedef EGLBoolean (EGLAPIENTRY * PFN_eglSwapBuffers)(EGLDisplay,EGLSurface); -typedef EGLBoolean (EGLAPIENTRY * PFN_eglSwapInterval)(EGLDisplay,EGLint); -typedef const char* (EGLAPIENTRY * PFN_eglQueryString)(EGLDisplay,EGLint); -typedef GLFWglproc (EGLAPIENTRY * PFN_eglGetProcAddress)(const char*); -#define eglGetConfigAttrib _glfw.egl.GetConfigAttrib -#define eglGetConfigs _glfw.egl.GetConfigs -#define eglGetDisplay _glfw.egl.GetDisplay -#define eglGetError _glfw.egl.GetError -#define eglInitialize _glfw.egl.Initialize -#define eglTerminate _glfw.egl.Terminate -#define eglBindAPI _glfw.egl.BindAPI -#define eglCreateContext _glfw.egl.CreateContext -#define eglDestroySurface _glfw.egl.DestroySurface -#define eglDestroyContext _glfw.egl.DestroyContext -#define eglCreateWindowSurface _glfw.egl.CreateWindowSurface -#define eglMakeCurrent _glfw.egl.MakeCurrent -#define eglSwapBuffers _glfw.egl.SwapBuffers -#define eglSwapInterval _glfw.egl.SwapInterval -#define eglQueryString _glfw.egl.QueryString -#define eglGetProcAddress _glfw.egl.GetProcAddress - -typedef EGLDisplay (EGLAPIENTRY * PFNEGLGETPLATFORMDISPLAYEXTPROC)(EGLenum,void*,const EGLint*); -typedef EGLSurface (EGLAPIENTRY * PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC)(EGLDisplay,EGLConfig,void*,const EGLint*); -#define eglGetPlatformDisplayEXT _glfw.egl.GetPlatformDisplayEXT -#define eglCreatePlatformWindowSurfaceEXT _glfw.egl.CreatePlatformWindowSurfaceEXT - -// EGL-specific per-context data -// -typedef struct _GLFWcontextEGL -{ - EGLConfig config; - EGLContext handle; - EGLSurface surface; - - void* client; -} _GLFWcontextEGL; - -// EGL-specific global data -// -typedef struct _GLFWlibraryEGL -{ - EGLenum platform; - EGLDisplay display; - EGLint major, minor; - GLFWbool prefix; - - GLFWbool KHR_create_context; - GLFWbool KHR_create_context_no_error; - GLFWbool KHR_gl_colorspace; - GLFWbool KHR_get_all_proc_addresses; - GLFWbool KHR_context_flush_control; - GLFWbool EXT_client_extensions; - GLFWbool EXT_platform_base; - GLFWbool EXT_platform_x11; - GLFWbool EXT_platform_wayland; - GLFWbool ANGLE_platform_angle; - GLFWbool ANGLE_platform_angle_opengl; - GLFWbool ANGLE_platform_angle_d3d; - GLFWbool ANGLE_platform_angle_vulkan; - GLFWbool ANGLE_platform_angle_metal; - - void* handle; - - PFN_eglGetConfigAttrib GetConfigAttrib; - PFN_eglGetConfigs GetConfigs; - PFN_eglGetDisplay GetDisplay; - PFN_eglGetError GetError; - PFN_eglInitialize Initialize; - PFN_eglTerminate Terminate; - PFN_eglBindAPI BindAPI; - PFN_eglCreateContext CreateContext; - PFN_eglDestroySurface DestroySurface; - PFN_eglDestroyContext DestroyContext; - PFN_eglCreateWindowSurface CreateWindowSurface; - PFN_eglMakeCurrent MakeCurrent; - PFN_eglSwapBuffers SwapBuffers; - PFN_eglSwapInterval SwapInterval; - PFN_eglQueryString QueryString; - PFN_eglGetProcAddress GetProcAddress; - - PFNEGLGETPLATFORMDISPLAYEXTPROC GetPlatformDisplayEXT; - PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC CreatePlatformWindowSurfaceEXT; -} _GLFWlibraryEGL; - - -GLFWbool _glfwInitEGL(void); -void _glfwTerminateEGL(void); -GLFWbool _glfwCreateContextEGL(_GLFWwindow* window, - const _GLFWctxconfig* ctxconfig, - const _GLFWfbconfig* fbconfig); -#if defined(_GLFW_X11) -GLFWbool _glfwChooseVisualEGL(const _GLFWwndconfig* wndconfig, - const _GLFWctxconfig* ctxconfig, - const _GLFWfbconfig* fbconfig, - Visual** visual, int* depth); -#endif /*_GLFW_X11*/ - diff --git a/src/glx_context.h b/src/glx_context.h deleted file mode 100644 index a50f09bc..00000000 --- a/src/glx_context.h +++ /dev/null @@ -1,179 +0,0 @@ -//======================================================================== -// GLFW 3.4 GLX - www.glfw.org -//------------------------------------------------------------------------ -// Copyright (c) 2002-2006 Marcus Geelnard -// Copyright (c) 2006-2017 Camilla Löwy -// -// This software is provided 'as-is', without any express or implied -// warranty. In no event will the authors be held liable for any damages -// arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it -// freely, subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; you must not -// claim that you wrote the original software. If you use this software -// in a product, an acknowledgment in the product documentation would -// be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, and must not -// be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source -// distribution. -// -//======================================================================== - -#define GLX_VENDOR 1 -#define GLX_RGBA_BIT 0x00000001 -#define GLX_WINDOW_BIT 0x00000001 -#define GLX_DRAWABLE_TYPE 0x8010 -#define GLX_RENDER_TYPE 0x8011 -#define GLX_RGBA_TYPE 0x8014 -#define GLX_DOUBLEBUFFER 5 -#define GLX_STEREO 6 -#define GLX_AUX_BUFFERS 7 -#define GLX_RED_SIZE 8 -#define GLX_GREEN_SIZE 9 -#define GLX_BLUE_SIZE 10 -#define GLX_ALPHA_SIZE 11 -#define GLX_DEPTH_SIZE 12 -#define GLX_STENCIL_SIZE 13 -#define GLX_ACCUM_RED_SIZE 14 -#define GLX_ACCUM_GREEN_SIZE 15 -#define GLX_ACCUM_BLUE_SIZE 16 -#define GLX_ACCUM_ALPHA_SIZE 17 -#define GLX_SAMPLES 0x186a1 -#define GLX_VISUAL_ID 0x800b - -#define GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20b2 -#define GLX_CONTEXT_DEBUG_BIT_ARB 0x00000001 -#define GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002 -#define GLX_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001 -#define GLX_CONTEXT_PROFILE_MASK_ARB 0x9126 -#define GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x00000002 -#define GLX_CONTEXT_MAJOR_VERSION_ARB 0x2091 -#define GLX_CONTEXT_MINOR_VERSION_ARB 0x2092 -#define GLX_CONTEXT_FLAGS_ARB 0x2094 -#define GLX_CONTEXT_ES2_PROFILE_BIT_EXT 0x00000004 -#define GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB 0x00000004 -#define GLX_LOSE_CONTEXT_ON_RESET_ARB 0x8252 -#define GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB 0x8256 -#define GLX_NO_RESET_NOTIFICATION_ARB 0x8261 -#define GLX_CONTEXT_RELEASE_BEHAVIOR_ARB 0x2097 -#define GLX_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB 0 -#define GLX_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB 0x2098 -#define GLX_CONTEXT_OPENGL_NO_ERROR_ARB 0x31b3 - -typedef XID GLXWindow; -typedef XID GLXDrawable; -typedef struct __GLXFBConfig* GLXFBConfig; -typedef struct __GLXcontext* GLXContext; -typedef void (*__GLXextproc)(void); - -typedef int (*PFNGLXGETFBCONFIGATTRIBPROC)(Display*,GLXFBConfig,int,int*); -typedef const char* (*PFNGLXGETCLIENTSTRINGPROC)(Display*,int); -typedef Bool (*PFNGLXQUERYEXTENSIONPROC)(Display*,int*,int*); -typedef Bool (*PFNGLXQUERYVERSIONPROC)(Display*,int*,int*); -typedef void (*PFNGLXDESTROYCONTEXTPROC)(Display*,GLXContext); -typedef Bool (*PFNGLXMAKECURRENTPROC)(Display*,GLXDrawable,GLXContext); -typedef void (*PFNGLXSWAPBUFFERSPROC)(Display*,GLXDrawable); -typedef const char* (*PFNGLXQUERYEXTENSIONSSTRINGPROC)(Display*,int); -typedef GLXFBConfig* (*PFNGLXGETFBCONFIGSPROC)(Display*,int,int*); -typedef GLXContext (*PFNGLXCREATENEWCONTEXTPROC)(Display*,GLXFBConfig,int,GLXContext,Bool); -typedef __GLXextproc (* PFNGLXGETPROCADDRESSPROC)(const GLubyte *procName); -typedef void (*PFNGLXSWAPINTERVALEXTPROC)(Display*,GLXDrawable,int); -typedef XVisualInfo* (*PFNGLXGETVISUALFROMFBCONFIGPROC)(Display*,GLXFBConfig); -typedef GLXWindow (*PFNGLXCREATEWINDOWPROC)(Display*,GLXFBConfig,Window,const int*); -typedef void (*PFNGLXDESTROYWINDOWPROC)(Display*,GLXWindow); - -typedef int (*PFNGLXSWAPINTERVALMESAPROC)(int); -typedef int (*PFNGLXSWAPINTERVALSGIPROC)(int); -typedef GLXContext (*PFNGLXCREATECONTEXTATTRIBSARBPROC)(Display*,GLXFBConfig,GLXContext,Bool,const int*); - -// libGL.so function pointer typedefs -#define glXGetFBConfigs _glfw.glx.GetFBConfigs -#define glXGetFBConfigAttrib _glfw.glx.GetFBConfigAttrib -#define glXGetClientString _glfw.glx.GetClientString -#define glXQueryExtension _glfw.glx.QueryExtension -#define glXQueryVersion _glfw.glx.QueryVersion -#define glXDestroyContext _glfw.glx.DestroyContext -#define glXMakeCurrent _glfw.glx.MakeCurrent -#define glXSwapBuffers _glfw.glx.SwapBuffers -#define glXQueryExtensionsString _glfw.glx.QueryExtensionsString -#define glXCreateNewContext _glfw.glx.CreateNewContext -#define glXGetVisualFromFBConfig _glfw.glx.GetVisualFromFBConfig -#define glXCreateWindow _glfw.glx.CreateWindow -#define glXDestroyWindow _glfw.glx.DestroyWindow - -#define _GLFW_PLATFORM_CONTEXT_STATE _GLFWcontextGLX glx -#define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE _GLFWlibraryGLX glx - - -// GLX-specific per-context data -// -typedef struct _GLFWcontextGLX -{ - GLXContext handle; - GLXWindow window; -} _GLFWcontextGLX; - -// GLX-specific global data -// -typedef struct _GLFWlibraryGLX -{ - int major, minor; - int eventBase; - int errorBase; - - // dlopen handle for libGL.so.1 - void* handle; - - // GLX 1.3 functions - PFNGLXGETFBCONFIGSPROC GetFBConfigs; - PFNGLXGETFBCONFIGATTRIBPROC GetFBConfigAttrib; - PFNGLXGETCLIENTSTRINGPROC GetClientString; - PFNGLXQUERYEXTENSIONPROC QueryExtension; - PFNGLXQUERYVERSIONPROC QueryVersion; - PFNGLXDESTROYCONTEXTPROC DestroyContext; - PFNGLXMAKECURRENTPROC MakeCurrent; - PFNGLXSWAPBUFFERSPROC SwapBuffers; - PFNGLXQUERYEXTENSIONSSTRINGPROC QueryExtensionsString; - PFNGLXCREATENEWCONTEXTPROC CreateNewContext; - PFNGLXGETVISUALFROMFBCONFIGPROC GetVisualFromFBConfig; - PFNGLXCREATEWINDOWPROC CreateWindow; - PFNGLXDESTROYWINDOWPROC DestroyWindow; - - // GLX 1.4 and extension functions - PFNGLXGETPROCADDRESSPROC GetProcAddress; - PFNGLXGETPROCADDRESSPROC GetProcAddressARB; - PFNGLXSWAPINTERVALSGIPROC SwapIntervalSGI; - PFNGLXSWAPINTERVALEXTPROC SwapIntervalEXT; - PFNGLXSWAPINTERVALMESAPROC SwapIntervalMESA; - PFNGLXCREATECONTEXTATTRIBSARBPROC CreateContextAttribsARB; - GLFWbool SGI_swap_control; - GLFWbool EXT_swap_control; - GLFWbool MESA_swap_control; - GLFWbool ARB_multisample; - GLFWbool ARB_framebuffer_sRGB; - GLFWbool EXT_framebuffer_sRGB; - GLFWbool ARB_create_context; - GLFWbool ARB_create_context_profile; - GLFWbool ARB_create_context_robustness; - GLFWbool EXT_create_context_es2_profile; - GLFWbool ARB_create_context_no_error; - GLFWbool ARB_context_flush_control; -} _GLFWlibraryGLX; - -GLFWbool _glfwInitGLX(void); -void _glfwTerminateGLX(void); -GLFWbool _glfwCreateContextGLX(_GLFWwindow* window, - const _GLFWctxconfig* ctxconfig, - const _GLFWfbconfig* fbconfig); -void _glfwDestroyContextGLX(_GLFWwindow* window); -GLFWbool _glfwChooseVisualGLX(const _GLFWwndconfig* wndconfig, - const _GLFWctxconfig* ctxconfig, - const _GLFWfbconfig* fbconfig, - Visual** visual, int* depth); - diff --git a/src/internal.h b/src/internal.h index 3ffc8d4e..e724b293 100644 --- a/src/internal.h +++ b/src/internal.h @@ -114,6 +114,164 @@ typedef const GLubyte* (APIENTRY * PFNGLGETSTRINGPROC)(GLenum); typedef void (APIENTRY * PFNGLGETINTEGERVPROC)(GLenum,GLint*); typedef const GLubyte* (APIENTRY * PFNGLGETSTRINGIPROC)(GLenum,GLuint); +#if defined(_GLFW_WIN32) + #define EGLAPIENTRY __stdcall +#else + #define EGLAPIENTRY +#endif + +#define EGL_SUCCESS 0x3000 +#define EGL_NOT_INITIALIZED 0x3001 +#define EGL_BAD_ACCESS 0x3002 +#define EGL_BAD_ALLOC 0x3003 +#define EGL_BAD_ATTRIBUTE 0x3004 +#define EGL_BAD_CONFIG 0x3005 +#define EGL_BAD_CONTEXT 0x3006 +#define EGL_BAD_CURRENT_SURFACE 0x3007 +#define EGL_BAD_DISPLAY 0x3008 +#define EGL_BAD_MATCH 0x3009 +#define EGL_BAD_NATIVE_PIXMAP 0x300a +#define EGL_BAD_NATIVE_WINDOW 0x300b +#define EGL_BAD_PARAMETER 0x300c +#define EGL_BAD_SURFACE 0x300d +#define EGL_CONTEXT_LOST 0x300e +#define EGL_COLOR_BUFFER_TYPE 0x303f +#define EGL_RGB_BUFFER 0x308e +#define EGL_SURFACE_TYPE 0x3033 +#define EGL_WINDOW_BIT 0x0004 +#define EGL_RENDERABLE_TYPE 0x3040 +#define EGL_OPENGL_ES_BIT 0x0001 +#define EGL_OPENGL_ES2_BIT 0x0004 +#define EGL_OPENGL_BIT 0x0008 +#define EGL_ALPHA_SIZE 0x3021 +#define EGL_BLUE_SIZE 0x3022 +#define EGL_GREEN_SIZE 0x3023 +#define EGL_RED_SIZE 0x3024 +#define EGL_DEPTH_SIZE 0x3025 +#define EGL_STENCIL_SIZE 0x3026 +#define EGL_SAMPLES 0x3031 +#define EGL_OPENGL_ES_API 0x30a0 +#define EGL_OPENGL_API 0x30a2 +#define EGL_NONE 0x3038 +#define EGL_RENDER_BUFFER 0x3086 +#define EGL_SINGLE_BUFFER 0x3085 +#define EGL_EXTENSIONS 0x3055 +#define EGL_CONTEXT_CLIENT_VERSION 0x3098 +#define EGL_NATIVE_VISUAL_ID 0x302e +#define EGL_NO_SURFACE ((EGLSurface) 0) +#define EGL_NO_DISPLAY ((EGLDisplay) 0) +#define EGL_NO_CONTEXT ((EGLContext) 0) +#define EGL_DEFAULT_DISPLAY ((EGLNativeDisplayType) 0) + +#define EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR 0x00000002 +#define EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR 0x00000001 +#define EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR 0x00000002 +#define EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR 0x00000001 +#define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR 0x31bd +#define EGL_NO_RESET_NOTIFICATION_KHR 0x31be +#define EGL_LOSE_CONTEXT_ON_RESET_KHR 0x31bf +#define EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR 0x00000004 +#define EGL_CONTEXT_MAJOR_VERSION_KHR 0x3098 +#define EGL_CONTEXT_MINOR_VERSION_KHR 0x30fb +#define EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR 0x30fd +#define EGL_CONTEXT_FLAGS_KHR 0x30fc +#define EGL_CONTEXT_OPENGL_NO_ERROR_KHR 0x31b3 +#define EGL_GL_COLORSPACE_KHR 0x309d +#define EGL_GL_COLORSPACE_SRGB_KHR 0x3089 +#define EGL_CONTEXT_RELEASE_BEHAVIOR_KHR 0x2097 +#define EGL_CONTEXT_RELEASE_BEHAVIOR_NONE_KHR 0 +#define EGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_KHR 0x2098 +#define EGL_PLATFORM_X11_EXT 0x31d5 +#define EGL_PLATFORM_WAYLAND_EXT 0x31d8 +#define EGL_PLATFORM_ANGLE_ANGLE 0x3202 +#define EGL_PLATFORM_ANGLE_TYPE_ANGLE 0x3203 +#define EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE 0x320d +#define EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE 0x320e +#define EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE 0x3207 +#define EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE 0x3208 +#define EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE 0x3450 +#define EGL_PLATFORM_ANGLE_TYPE_METAL_ANGLE 0x3489 +#define EGL_PLATFORM_ANGLE_NATIVE_PLATFORM_TYPE_ANGLE 0x348f + +typedef int EGLint; +typedef unsigned int EGLBoolean; +typedef unsigned int EGLenum; +typedef void* EGLConfig; +typedef void* EGLContext; +typedef void* EGLDisplay; +typedef void* EGLSurface; + +typedef void* EGLNativeDisplayType; +typedef void* EGLNativeWindowType; + +// EGL function pointer typedefs +typedef EGLBoolean (EGLAPIENTRY * PFN_eglGetConfigAttrib)(EGLDisplay,EGLConfig,EGLint,EGLint*); +typedef EGLBoolean (EGLAPIENTRY * PFN_eglGetConfigs)(EGLDisplay,EGLConfig*,EGLint,EGLint*); +typedef EGLDisplay (EGLAPIENTRY * PFN_eglGetDisplay)(EGLNativeDisplayType); +typedef EGLint (EGLAPIENTRY * PFN_eglGetError)(void); +typedef EGLBoolean (EGLAPIENTRY * PFN_eglInitialize)(EGLDisplay,EGLint*,EGLint*); +typedef EGLBoolean (EGLAPIENTRY * PFN_eglTerminate)(EGLDisplay); +typedef EGLBoolean (EGLAPIENTRY * PFN_eglBindAPI)(EGLenum); +typedef EGLContext (EGLAPIENTRY * PFN_eglCreateContext)(EGLDisplay,EGLConfig,EGLContext,const EGLint*); +typedef EGLBoolean (EGLAPIENTRY * PFN_eglDestroySurface)(EGLDisplay,EGLSurface); +typedef EGLBoolean (EGLAPIENTRY * PFN_eglDestroyContext)(EGLDisplay,EGLContext); +typedef EGLSurface (EGLAPIENTRY * PFN_eglCreateWindowSurface)(EGLDisplay,EGLConfig,EGLNativeWindowType,const EGLint*); +typedef EGLBoolean (EGLAPIENTRY * PFN_eglMakeCurrent)(EGLDisplay,EGLSurface,EGLSurface,EGLContext); +typedef EGLBoolean (EGLAPIENTRY * PFN_eglSwapBuffers)(EGLDisplay,EGLSurface); +typedef EGLBoolean (EGLAPIENTRY * PFN_eglSwapInterval)(EGLDisplay,EGLint); +typedef const char* (EGLAPIENTRY * PFN_eglQueryString)(EGLDisplay,EGLint); +typedef GLFWglproc (EGLAPIENTRY * PFN_eglGetProcAddress)(const char*); +#define eglGetConfigAttrib _glfw.egl.GetConfigAttrib +#define eglGetConfigs _glfw.egl.GetConfigs +#define eglGetDisplay _glfw.egl.GetDisplay +#define eglGetError _glfw.egl.GetError +#define eglInitialize _glfw.egl.Initialize +#define eglTerminate _glfw.egl.Terminate +#define eglBindAPI _glfw.egl.BindAPI +#define eglCreateContext _glfw.egl.CreateContext +#define eglDestroySurface _glfw.egl.DestroySurface +#define eglDestroyContext _glfw.egl.DestroyContext +#define eglCreateWindowSurface _glfw.egl.CreateWindowSurface +#define eglMakeCurrent _glfw.egl.MakeCurrent +#define eglSwapBuffers _glfw.egl.SwapBuffers +#define eglSwapInterval _glfw.egl.SwapInterval +#define eglQueryString _glfw.egl.QueryString +#define eglGetProcAddress _glfw.egl.GetProcAddress + +typedef EGLDisplay (EGLAPIENTRY * PFNEGLGETPLATFORMDISPLAYEXTPROC)(EGLenum,void*,const EGLint*); +typedef EGLSurface (EGLAPIENTRY * PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC)(EGLDisplay,EGLConfig,void*,const EGLint*); +#define eglGetPlatformDisplayEXT _glfw.egl.GetPlatformDisplayEXT +#define eglCreatePlatformWindowSurfaceEXT _glfw.egl.CreatePlatformWindowSurfaceEXT + +#define OSMESA_RGBA 0x1908 +#define OSMESA_FORMAT 0x22 +#define OSMESA_DEPTH_BITS 0x30 +#define OSMESA_STENCIL_BITS 0x31 +#define OSMESA_ACCUM_BITS 0x32 +#define OSMESA_PROFILE 0x33 +#define OSMESA_CORE_PROFILE 0x34 +#define OSMESA_COMPAT_PROFILE 0x35 +#define OSMESA_CONTEXT_MAJOR_VERSION 0x36 +#define OSMESA_CONTEXT_MINOR_VERSION 0x37 + +typedef void* OSMesaContext; +typedef void (*OSMESAproc)(void); + +typedef OSMesaContext (GLAPIENTRY * PFN_OSMesaCreateContextExt)(GLenum,GLint,GLint,GLint,OSMesaContext); +typedef OSMesaContext (GLAPIENTRY * PFN_OSMesaCreateContextAttribs)(const int*,OSMesaContext); +typedef void (GLAPIENTRY * PFN_OSMesaDestroyContext)(OSMesaContext); +typedef int (GLAPIENTRY * PFN_OSMesaMakeCurrent)(OSMesaContext,void*,int,int,int); +typedef int (GLAPIENTRY * PFN_OSMesaGetColorBuffer)(OSMesaContext,int*,int*,int*,void**); +typedef int (GLAPIENTRY * PFN_OSMesaGetDepthBuffer)(OSMesaContext,int*,int*,int*,void**); +typedef GLFWglproc (GLAPIENTRY * PFN_OSMesaGetProcAddress)(const char*); +#define OSMesaCreateContextExt _glfw.osmesa.CreateContextExt +#define OSMesaCreateContextAttribs _glfw.osmesa.CreateContextAttribs +#define OSMesaDestroyContext _glfw.osmesa.DestroyContext +#define OSMesaMakeCurrent _glfw.osmesa.MakeCurrent +#define OSMesaGetColorBuffer _glfw.osmesa.GetColorBuffer +#define OSMesaGetDepthBuffer _glfw.osmesa.GetDepthBuffer +#define OSMesaGetProcAddress _glfw.osmesa.GetProcAddress + #define VK_NULL_HANDLE 0 typedef void* VkInstance; @@ -195,9 +353,6 @@ typedef void (APIENTRY * PFN_vkVoidFunction)(void); #error "No supported window creation API selected" #endif -#include "egl_context.h" -#include "osmesa_context.h" - // Constructs a version number string from the public header macros #define _GLFW_CONCAT_VERSION(m, n, r) #m "." #n "." #r #define _GLFW_MAKE_VERSION(m, n, r) _GLFW_CONCAT_VERSION(m, n, r) @@ -365,12 +520,22 @@ struct _GLFWcontext _GLFWgetprocaddressfun getProcAddress; _GLFWdestroycontextfun destroy; + struct { + EGLConfig config; + EGLContext handle; + EGLSurface surface; + void* client; + } egl; + + struct { + OSMesaContext handle; + int width; + int height; + void* buffer; + } osmesa; + // This is defined in the context API's context.h _GLFW_PLATFORM_CONTEXT_STATE; - // This is defined in egl_context.h - _GLFWcontextEGL egl; - // This is defined in osmesa_context.h - _GLFWcontextOSMesa osmesa; }; // Window and context structure @@ -560,6 +725,63 @@ struct _GLFWlibrary _GLFW_PLATFORM_LIBRARY_TIMER_STATE; } timer; + struct { + EGLenum platform; + EGLDisplay display; + EGLint major, minor; + GLFWbool prefix; + + GLFWbool KHR_create_context; + GLFWbool KHR_create_context_no_error; + GLFWbool KHR_gl_colorspace; + GLFWbool KHR_get_all_proc_addresses; + GLFWbool KHR_context_flush_control; + GLFWbool EXT_client_extensions; + GLFWbool EXT_platform_base; + GLFWbool EXT_platform_x11; + GLFWbool EXT_platform_wayland; + GLFWbool ANGLE_platform_angle; + GLFWbool ANGLE_platform_angle_opengl; + GLFWbool ANGLE_platform_angle_d3d; + GLFWbool ANGLE_platform_angle_vulkan; + GLFWbool ANGLE_platform_angle_metal; + + void* handle; + + PFN_eglGetConfigAttrib GetConfigAttrib; + PFN_eglGetConfigs GetConfigs; + PFN_eglGetDisplay GetDisplay; + PFN_eglGetError GetError; + PFN_eglInitialize Initialize; + PFN_eglTerminate Terminate; + PFN_eglBindAPI BindAPI; + PFN_eglCreateContext CreateContext; + PFN_eglDestroySurface DestroySurface; + PFN_eglDestroyContext DestroyContext; + PFN_eglCreateWindowSurface CreateWindowSurface; + PFN_eglMakeCurrent MakeCurrent; + PFN_eglSwapBuffers SwapBuffers; + PFN_eglSwapInterval SwapInterval; + PFN_eglQueryString QueryString; + PFN_eglGetProcAddress GetProcAddress; + + PFNEGLGETPLATFORMDISPLAYEXTPROC GetPlatformDisplayEXT; + PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC CreatePlatformWindowSurfaceEXT; + } egl; + + struct { + void* handle; + + PFN_OSMesaCreateContextExt CreateContextExt; + PFN_OSMesaCreateContextAttribs CreateContextAttribs; + PFN_OSMesaDestroyContext DestroyContext; + PFN_OSMesaMakeCurrent MakeCurrent; + PFN_OSMesaGetColorBuffer GetColorBuffer; + PFN_OSMesaGetDepthBuffer GetDepthBuffer; + PFN_OSMesaGetProcAddress GetProcAddress; + + } osmesa; + struct { GLFWbool available; void* handle; @@ -593,10 +815,6 @@ struct _GLFWlibrary _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE; // This is defined in the platform's joystick.h _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE; - // This is defined in egl_context.h - _GLFWlibraryEGL egl; - // This is defined in osmesa_context.h - _GLFWlibraryOSMesa osmesa; }; // Global state shared between compilation units of GLFW @@ -798,6 +1016,24 @@ _GLFWjoystick* _glfwAllocJoystick(const char* name, void _glfwFreeJoystick(_GLFWjoystick* js); void _glfwCenterCursorInContentArea(_GLFWwindow* window); +GLFWbool _glfwInitEGL(void); +void _glfwTerminateEGL(void); +GLFWbool _glfwCreateContextEGL(_GLFWwindow* window, + const _GLFWctxconfig* ctxconfig, + const _GLFWfbconfig* fbconfig); +#if defined(_GLFW_X11) +GLFWbool _glfwChooseVisualEGL(const _GLFWwndconfig* wndconfig, + const _GLFWctxconfig* ctxconfig, + const _GLFWfbconfig* fbconfig, + Visual** visual, int* depth); +#endif /*_GLFW_X11*/ + +GLFWbool _glfwInitOSMesa(void); +void _glfwTerminateOSMesa(void); +GLFWbool _glfwCreateContextOSMesa(_GLFWwindow* window, + const _GLFWctxconfig* ctxconfig, + const _GLFWfbconfig* fbconfig); + GLFWbool _glfwInitVulkan(int mode); void _glfwTerminateVulkan(void); const char* _glfwGetVulkanResultString(VkResult result); diff --git a/src/nsgl_context.h b/src/nsgl_context.h deleted file mode 100644 index 55b9bf14..00000000 --- a/src/nsgl_context.h +++ /dev/null @@ -1,64 +0,0 @@ -//======================================================================== -// GLFW 3.4 macOS - www.glfw.org -//------------------------------------------------------------------------ -// Copyright (c) 2009-2019 Camilla Löwy -// -// This software is provided 'as-is', without any express or implied -// warranty. In no event will the authors be held liable for any damages -// arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it -// freely, subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; you must not -// claim that you wrote the original software. If you use this software -// in a product, an acknowledgment in the product documentation would -// be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, and must not -// be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source -// distribution. -// -//======================================================================== - -// NOTE: Many Cocoa enum values have been renamed and we need to build across -// SDK versions where one is unavailable or the other deprecated -// We use the newer names in code and these macros to handle compatibility -#if MAC_OS_X_VERSION_MAX_ALLOWED < 101400 - #define NSOpenGLContextParameterSwapInterval NSOpenGLCPSwapInterval - #define NSOpenGLContextParameterSurfaceOpacity NSOpenGLCPSurfaceOpacity -#endif - -#define _GLFW_PLATFORM_CONTEXT_STATE _GLFWcontextNSGL nsgl -#define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE _GLFWlibraryNSGL nsgl - -#include - - -// NSGL-specific per-context data -// -typedef struct _GLFWcontextNSGL -{ - id pixelFormat; - id object; -} _GLFWcontextNSGL; - -// NSGL-specific global data -// -typedef struct _GLFWlibraryNSGL -{ - // dlopen handle for OpenGL.framework (for glfwGetProcAddress) - CFBundleRef framework; -} _GLFWlibraryNSGL; - - -GLFWbool _glfwInitNSGL(void); -void _glfwTerminateNSGL(void); -GLFWbool _glfwCreateContextNSGL(_GLFWwindow* window, - const _GLFWctxconfig* ctxconfig, - const _GLFWfbconfig* fbconfig); -void _glfwDestroyContextNSGL(_GLFWwindow* window); - diff --git a/src/osmesa_context.h b/src/osmesa_context.h deleted file mode 100644 index 74bc2a99..00000000 --- a/src/osmesa_context.h +++ /dev/null @@ -1,88 +0,0 @@ -//======================================================================== -// GLFW 3.4 OSMesa - www.glfw.org -//------------------------------------------------------------------------ -// Copyright (c) 2016 Google Inc. -// Copyright (c) 2016-2017 Camilla Löwy -// -// This software is provided 'as-is', without any express or implied -// warranty. In no event will the authors be held liable for any damages -// arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it -// freely, subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; you must not -// claim that you wrote the original software. If you use this software -// in a product, an acknowledgment in the product documentation would -// be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, and must not -// be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source -// distribution. -// -//======================================================================== - -#define OSMESA_RGBA 0x1908 -#define OSMESA_FORMAT 0x22 -#define OSMESA_DEPTH_BITS 0x30 -#define OSMESA_STENCIL_BITS 0x31 -#define OSMESA_ACCUM_BITS 0x32 -#define OSMESA_PROFILE 0x33 -#define OSMESA_CORE_PROFILE 0x34 -#define OSMESA_COMPAT_PROFILE 0x35 -#define OSMESA_CONTEXT_MAJOR_VERSION 0x36 -#define OSMESA_CONTEXT_MINOR_VERSION 0x37 - -typedef void* OSMesaContext; -typedef void (*OSMESAproc)(void); - -typedef OSMesaContext (GLAPIENTRY * PFN_OSMesaCreateContextExt)(GLenum,GLint,GLint,GLint,OSMesaContext); -typedef OSMesaContext (GLAPIENTRY * PFN_OSMesaCreateContextAttribs)(const int*,OSMesaContext); -typedef void (GLAPIENTRY * PFN_OSMesaDestroyContext)(OSMesaContext); -typedef int (GLAPIENTRY * PFN_OSMesaMakeCurrent)(OSMesaContext,void*,int,int,int); -typedef int (GLAPIENTRY * PFN_OSMesaGetColorBuffer)(OSMesaContext,int*,int*,int*,void**); -typedef int (GLAPIENTRY * PFN_OSMesaGetDepthBuffer)(OSMesaContext,int*,int*,int*,void**); -typedef GLFWglproc (GLAPIENTRY * PFN_OSMesaGetProcAddress)(const char*); -#define OSMesaCreateContextExt _glfw.osmesa.CreateContextExt -#define OSMesaCreateContextAttribs _glfw.osmesa.CreateContextAttribs -#define OSMesaDestroyContext _glfw.osmesa.DestroyContext -#define OSMesaMakeCurrent _glfw.osmesa.MakeCurrent -#define OSMesaGetColorBuffer _glfw.osmesa.GetColorBuffer -#define OSMesaGetDepthBuffer _glfw.osmesa.GetDepthBuffer -#define OSMesaGetProcAddress _glfw.osmesa.GetProcAddress - -// OSMesa-specific per-context data -// -typedef struct _GLFWcontextOSMesa -{ - OSMesaContext handle; - int width; - int height; - void* buffer; -} _GLFWcontextOSMesa; - -// OSMesa-specific global data -// -typedef struct _GLFWlibraryOSMesa -{ - void* handle; - - PFN_OSMesaCreateContextExt CreateContextExt; - PFN_OSMesaCreateContextAttribs CreateContextAttribs; - PFN_OSMesaDestroyContext DestroyContext; - PFN_OSMesaMakeCurrent MakeCurrent; - PFN_OSMesaGetColorBuffer GetColorBuffer; - PFN_OSMesaGetDepthBuffer GetDepthBuffer; - PFN_OSMesaGetProcAddress GetProcAddress; -} _GLFWlibraryOSMesa; - - -GLFWbool _glfwInitOSMesa(void); -void _glfwTerminateOSMesa(void); -GLFWbool _glfwCreateContextOSMesa(_GLFWwindow* window, - const _GLFWctxconfig* ctxconfig, - const _GLFWfbconfig* fbconfig); - diff --git a/src/wgl_context.h b/src/wgl_context.h deleted file mode 100644 index 702eaada..00000000 --- a/src/wgl_context.h +++ /dev/null @@ -1,158 +0,0 @@ -//======================================================================== -// GLFW 3.4 WGL - www.glfw.org -//------------------------------------------------------------------------ -// Copyright (c) 2002-2006 Marcus Geelnard -// Copyright (c) 2006-2018 Camilla Löwy -// -// This software is provided 'as-is', without any express or implied -// warranty. In no event will the authors be held liable for any damages -// arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it -// freely, subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; you must not -// claim that you wrote the original software. If you use this software -// in a product, an acknowledgment in the product documentation would -// be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, and must not -// be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source -// distribution. -// -//======================================================================== - -#define WGL_NUMBER_PIXEL_FORMATS_ARB 0x2000 -#define WGL_SUPPORT_OPENGL_ARB 0x2010 -#define WGL_DRAW_TO_WINDOW_ARB 0x2001 -#define WGL_PIXEL_TYPE_ARB 0x2013 -#define WGL_TYPE_RGBA_ARB 0x202b -#define WGL_ACCELERATION_ARB 0x2003 -#define WGL_NO_ACCELERATION_ARB 0x2025 -#define WGL_RED_BITS_ARB 0x2015 -#define WGL_RED_SHIFT_ARB 0x2016 -#define WGL_GREEN_BITS_ARB 0x2017 -#define WGL_GREEN_SHIFT_ARB 0x2018 -#define WGL_BLUE_BITS_ARB 0x2019 -#define WGL_BLUE_SHIFT_ARB 0x201a -#define WGL_ALPHA_BITS_ARB 0x201b -#define WGL_ALPHA_SHIFT_ARB 0x201c -#define WGL_ACCUM_BITS_ARB 0x201d -#define WGL_ACCUM_RED_BITS_ARB 0x201e -#define WGL_ACCUM_GREEN_BITS_ARB 0x201f -#define WGL_ACCUM_BLUE_BITS_ARB 0x2020 -#define WGL_ACCUM_ALPHA_BITS_ARB 0x2021 -#define WGL_DEPTH_BITS_ARB 0x2022 -#define WGL_STENCIL_BITS_ARB 0x2023 -#define WGL_AUX_BUFFERS_ARB 0x2024 -#define WGL_STEREO_ARB 0x2012 -#define WGL_DOUBLE_BUFFER_ARB 0x2011 -#define WGL_SAMPLES_ARB 0x2042 -#define WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20a9 -#define WGL_CONTEXT_DEBUG_BIT_ARB 0x00000001 -#define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x00000002 -#define WGL_CONTEXT_PROFILE_MASK_ARB 0x9126 -#define WGL_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001 -#define WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002 -#define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091 -#define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092 -#define WGL_CONTEXT_FLAGS_ARB 0x2094 -#define WGL_CONTEXT_ES2_PROFILE_BIT_EXT 0x00000004 -#define WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB 0x00000004 -#define WGL_LOSE_CONTEXT_ON_RESET_ARB 0x8252 -#define WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB 0x8256 -#define WGL_NO_RESET_NOTIFICATION_ARB 0x8261 -#define WGL_CONTEXT_RELEASE_BEHAVIOR_ARB 0x2097 -#define WGL_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB 0 -#define WGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB 0x2098 -#define WGL_CONTEXT_OPENGL_NO_ERROR_ARB 0x31b3 -#define WGL_COLORSPACE_EXT 0x309d -#define WGL_COLORSPACE_SRGB_EXT 0x3089 - -#define ERROR_INVALID_VERSION_ARB 0x2095 -#define ERROR_INVALID_PROFILE_ARB 0x2096 -#define ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB 0x2054 - -// WGL extension pointer typedefs -typedef BOOL (WINAPI * PFNWGLSWAPINTERVALEXTPROC)(int); -typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVARBPROC)(HDC,int,int,UINT,const int*,int*); -typedef const char* (WINAPI * PFNWGLGETEXTENSIONSSTRINGEXTPROC)(void); -typedef const char* (WINAPI * PFNWGLGETEXTENSIONSSTRINGARBPROC)(HDC); -typedef HGLRC (WINAPI * PFNWGLCREATECONTEXTATTRIBSARBPROC)(HDC,HGLRC,const int*); -#define wglSwapIntervalEXT _glfw.wgl.SwapIntervalEXT -#define wglGetPixelFormatAttribivARB _glfw.wgl.GetPixelFormatAttribivARB -#define wglGetExtensionsStringEXT _glfw.wgl.GetExtensionsStringEXT -#define wglGetExtensionsStringARB _glfw.wgl.GetExtensionsStringARB -#define wglCreateContextAttribsARB _glfw.wgl.CreateContextAttribsARB - -// opengl32.dll function pointer typedefs -typedef HGLRC (WINAPI * PFN_wglCreateContext)(HDC); -typedef BOOL (WINAPI * PFN_wglDeleteContext)(HGLRC); -typedef PROC (WINAPI * PFN_wglGetProcAddress)(LPCSTR); -typedef HDC (WINAPI * PFN_wglGetCurrentDC)(void); -typedef HGLRC (WINAPI * PFN_wglGetCurrentContext)(void); -typedef BOOL (WINAPI * PFN_wglMakeCurrent)(HDC,HGLRC); -typedef BOOL (WINAPI * PFN_wglShareLists)(HGLRC,HGLRC); -#define wglCreateContext _glfw.wgl.CreateContext -#define wglDeleteContext _glfw.wgl.DeleteContext -#define wglGetProcAddress _glfw.wgl.GetProcAddress -#define wglGetCurrentDC _glfw.wgl.GetCurrentDC -#define wglGetCurrentContext _glfw.wgl.GetCurrentContext -#define wglMakeCurrent _glfw.wgl.MakeCurrent -#define wglShareLists _glfw.wgl.ShareLists - -#define _GLFW_PLATFORM_CONTEXT_STATE _GLFWcontextWGL wgl -#define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE _GLFWlibraryWGL wgl - - -// WGL-specific per-context data -// -typedef struct _GLFWcontextWGL -{ - HDC dc; - HGLRC handle; - int interval; -} _GLFWcontextWGL; - -// WGL-specific global data -// -typedef struct _GLFWlibraryWGL -{ - HINSTANCE instance; - PFN_wglCreateContext CreateContext; - PFN_wglDeleteContext DeleteContext; - PFN_wglGetProcAddress GetProcAddress; - PFN_wglGetCurrentDC GetCurrentDC; - PFN_wglGetCurrentContext GetCurrentContext; - PFN_wglMakeCurrent MakeCurrent; - PFN_wglShareLists ShareLists; - - PFNWGLSWAPINTERVALEXTPROC SwapIntervalEXT; - PFNWGLGETPIXELFORMATATTRIBIVARBPROC GetPixelFormatAttribivARB; - PFNWGLGETEXTENSIONSSTRINGEXTPROC GetExtensionsStringEXT; - PFNWGLGETEXTENSIONSSTRINGARBPROC GetExtensionsStringARB; - PFNWGLCREATECONTEXTATTRIBSARBPROC CreateContextAttribsARB; - GLFWbool EXT_swap_control; - GLFWbool EXT_colorspace; - GLFWbool ARB_multisample; - GLFWbool ARB_framebuffer_sRGB; - GLFWbool EXT_framebuffer_sRGB; - GLFWbool ARB_pixel_format; - GLFWbool ARB_create_context; - GLFWbool ARB_create_context_profile; - GLFWbool EXT_create_context_es2_profile; - GLFWbool ARB_create_context_robustness; - GLFWbool ARB_create_context_no_error; - GLFWbool ARB_context_flush_control; -} _GLFWlibraryWGL; - - -GLFWbool _glfwInitWGL(void); -void _glfwTerminateWGL(void); -GLFWbool _glfwCreateContextWGL(_GLFWwindow* window, - const _GLFWctxconfig* ctxconfig, - const _GLFWfbconfig* fbconfig); - diff --git a/src/win32_platform.h b/src/win32_platform.h index 9008f131..a258c355 100644 --- a/src/win32_platform.h +++ b/src/win32_platform.h @@ -215,6 +215,57 @@ typedef enum #define DIDFT_OPTIONAL 0x80000000 #endif +#define WGL_NUMBER_PIXEL_FORMATS_ARB 0x2000 +#define WGL_SUPPORT_OPENGL_ARB 0x2010 +#define WGL_DRAW_TO_WINDOW_ARB 0x2001 +#define WGL_PIXEL_TYPE_ARB 0x2013 +#define WGL_TYPE_RGBA_ARB 0x202b +#define WGL_ACCELERATION_ARB 0x2003 +#define WGL_NO_ACCELERATION_ARB 0x2025 +#define WGL_RED_BITS_ARB 0x2015 +#define WGL_RED_SHIFT_ARB 0x2016 +#define WGL_GREEN_BITS_ARB 0x2017 +#define WGL_GREEN_SHIFT_ARB 0x2018 +#define WGL_BLUE_BITS_ARB 0x2019 +#define WGL_BLUE_SHIFT_ARB 0x201a +#define WGL_ALPHA_BITS_ARB 0x201b +#define WGL_ALPHA_SHIFT_ARB 0x201c +#define WGL_ACCUM_BITS_ARB 0x201d +#define WGL_ACCUM_RED_BITS_ARB 0x201e +#define WGL_ACCUM_GREEN_BITS_ARB 0x201f +#define WGL_ACCUM_BLUE_BITS_ARB 0x2020 +#define WGL_ACCUM_ALPHA_BITS_ARB 0x2021 +#define WGL_DEPTH_BITS_ARB 0x2022 +#define WGL_STENCIL_BITS_ARB 0x2023 +#define WGL_AUX_BUFFERS_ARB 0x2024 +#define WGL_STEREO_ARB 0x2012 +#define WGL_DOUBLE_BUFFER_ARB 0x2011 +#define WGL_SAMPLES_ARB 0x2042 +#define WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20a9 +#define WGL_CONTEXT_DEBUG_BIT_ARB 0x00000001 +#define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x00000002 +#define WGL_CONTEXT_PROFILE_MASK_ARB 0x9126 +#define WGL_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001 +#define WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002 +#define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091 +#define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092 +#define WGL_CONTEXT_FLAGS_ARB 0x2094 +#define WGL_CONTEXT_ES2_PROFILE_BIT_EXT 0x00000004 +#define WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB 0x00000004 +#define WGL_LOSE_CONTEXT_ON_RESET_ARB 0x8252 +#define WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB 0x8256 +#define WGL_NO_RESET_NOTIFICATION_ARB 0x8261 +#define WGL_CONTEXT_RELEASE_BEHAVIOR_ARB 0x2097 +#define WGL_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB 0 +#define WGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB 0x2098 +#define WGL_CONTEXT_OPENGL_NO_ERROR_ARB 0x31b3 +#define WGL_COLORSPACE_EXT 0x309d +#define WGL_COLORSPACE_SRGB_EXT 0x3089 + +#define ERROR_INVALID_VERSION_ARB 0x2095 +#define ERROR_INVALID_PROFILE_ARB 0x2096 +#define ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB 0x2054 + // winmm.dll function pointer typedefs typedef DWORD (WINAPI * PFN_timeGetTime)(void); #define timeGetTime _glfw.win32.winmm.GetTime @@ -263,6 +314,34 @@ typedef HRESULT (WINAPI * PFN_GetDpiForMonitor)(HMONITOR,MONITOR_DPI_TYPE,UINT*, typedef LONG (WINAPI * PFN_RtlVerifyVersionInfo)(OSVERSIONINFOEXW*,ULONG,ULONGLONG); #define RtlVerifyVersionInfo _glfw.win32.ntdll.RtlVerifyVersionInfo_ +// WGL extension pointer typedefs +typedef BOOL (WINAPI * PFNWGLSWAPINTERVALEXTPROC)(int); +typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVARBPROC)(HDC,int,int,UINT,const int*,int*); +typedef const char* (WINAPI * PFNWGLGETEXTENSIONSSTRINGEXTPROC)(void); +typedef const char* (WINAPI * PFNWGLGETEXTENSIONSSTRINGARBPROC)(HDC); +typedef HGLRC (WINAPI * PFNWGLCREATECONTEXTATTRIBSARBPROC)(HDC,HGLRC,const int*); +#define wglSwapIntervalEXT _glfw.wgl.SwapIntervalEXT +#define wglGetPixelFormatAttribivARB _glfw.wgl.GetPixelFormatAttribivARB +#define wglGetExtensionsStringEXT _glfw.wgl.GetExtensionsStringEXT +#define wglGetExtensionsStringARB _glfw.wgl.GetExtensionsStringARB +#define wglCreateContextAttribsARB _glfw.wgl.CreateContextAttribsARB + +// opengl32.dll function pointer typedefs +typedef HGLRC (WINAPI * PFN_wglCreateContext)(HDC); +typedef BOOL (WINAPI * PFN_wglDeleteContext)(HGLRC); +typedef PROC (WINAPI * PFN_wglGetProcAddress)(LPCSTR); +typedef HDC (WINAPI * PFN_wglGetCurrentDC)(void); +typedef HGLRC (WINAPI * PFN_wglGetCurrentContext)(void); +typedef BOOL (WINAPI * PFN_wglMakeCurrent)(HDC,HGLRC); +typedef BOOL (WINAPI * PFN_wglShareLists)(HGLRC,HGLRC); +#define wglCreateContext _glfw.wgl.CreateContext +#define wglDeleteContext _glfw.wgl.DeleteContext +#define wglGetProcAddress _glfw.wgl.GetProcAddress +#define wglGetCurrentDC _glfw.wgl.GetCurrentDC +#define wglGetCurrentContext _glfw.wgl.GetCurrentContext +#define wglMakeCurrent _glfw.wgl.MakeCurrent +#define wglShareLists _glfw.wgl.ShareLists + typedef VkFlags VkWin32SurfaceCreateFlagsKHR; typedef struct VkWin32SurfaceCreateInfoKHR @@ -278,7 +357,6 @@ typedef VkResult (APIENTRY *PFN_vkCreateWin32SurfaceKHR)(VkInstance,const VkWin3 typedef VkBool32 (APIENTRY *PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR)(VkPhysicalDevice,uint32_t); #include "win32_joystick.h" -#include "wgl_context.h" #if !defined(_GLFW_WNDCLASSNAME) #define _GLFW_WNDCLASSNAME L"GLFW30" @@ -292,6 +370,50 @@ typedef VkBool32 (APIENTRY *PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR)( #define _GLFW_PLATFORM_TLS_STATE _GLFWtlsWin32 win32 #define _GLFW_PLATFORM_MUTEX_STATE _GLFWmutexWin32 win32 +#define _GLFW_PLATFORM_CONTEXT_STATE _GLFWcontextWGL wgl +#define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE _GLFWlibraryWGL wgl + + +// WGL-specific per-context data +// +typedef struct _GLFWcontextWGL +{ + HDC dc; + HGLRC handle; + int interval; +} _GLFWcontextWGL; + +// WGL-specific global data +// +typedef struct _GLFWlibraryWGL +{ + HINSTANCE instance; + PFN_wglCreateContext CreateContext; + PFN_wglDeleteContext DeleteContext; + PFN_wglGetProcAddress GetProcAddress; + PFN_wglGetCurrentDC GetCurrentDC; + PFN_wglGetCurrentContext GetCurrentContext; + PFN_wglMakeCurrent MakeCurrent; + PFN_wglShareLists ShareLists; + + PFNWGLSWAPINTERVALEXTPROC SwapIntervalEXT; + PFNWGLGETPIXELFORMATATTRIBIVARBPROC GetPixelFormatAttribivARB; + PFNWGLGETEXTENSIONSSTRINGEXTPROC GetExtensionsStringEXT; + PFNWGLGETEXTENSIONSSTRINGARBPROC GetExtensionsStringARB; + PFNWGLCREATECONTEXTATTRIBSARBPROC CreateContextAttribsARB; + GLFWbool EXT_swap_control; + GLFWbool EXT_colorspace; + GLFWbool ARB_multisample; + GLFWbool ARB_framebuffer_sRGB; + GLFWbool EXT_framebuffer_sRGB; + GLFWbool ARB_pixel_format; + GLFWbool ARB_create_context; + GLFWbool ARB_create_context_profile; + GLFWbool EXT_create_context_es2_profile; + GLFWbool ARB_create_context_robustness; + GLFWbool ARB_create_context_no_error; + GLFWbool ARB_context_flush_control; +} _GLFWlibraryWGL; // Win32-specific per-window data // @@ -446,3 +568,9 @@ void _glfwSetVideoModeWin32(_GLFWmonitor* monitor, const GLFWvidmode* desired); void _glfwRestoreVideoModeWin32(_GLFWmonitor* monitor); void _glfwGetMonitorContentScaleWin32(HMONITOR handle, float* xscale, float* yscale); +GLFWbool _glfwInitWGL(void); +void _glfwTerminateWGL(void); +GLFWbool _glfwCreateContextWGL(_GLFWwindow* window, + const _GLFWctxconfig* ctxconfig, + const _GLFWfbconfig* fbconfig); + diff --git a/src/x11_platform.h b/src/x11_platform.h index ac8319de..76444a87 100644 --- a/src/x11_platform.h +++ b/src/x11_platform.h @@ -50,6 +50,53 @@ // The Shape extension provides custom window shapes #include +#define GLX_VENDOR 1 +#define GLX_RGBA_BIT 0x00000001 +#define GLX_WINDOW_BIT 0x00000001 +#define GLX_DRAWABLE_TYPE 0x8010 +#define GLX_RENDER_TYPE 0x8011 +#define GLX_RGBA_TYPE 0x8014 +#define GLX_DOUBLEBUFFER 5 +#define GLX_STEREO 6 +#define GLX_AUX_BUFFERS 7 +#define GLX_RED_SIZE 8 +#define GLX_GREEN_SIZE 9 +#define GLX_BLUE_SIZE 10 +#define GLX_ALPHA_SIZE 11 +#define GLX_DEPTH_SIZE 12 +#define GLX_STENCIL_SIZE 13 +#define GLX_ACCUM_RED_SIZE 14 +#define GLX_ACCUM_GREEN_SIZE 15 +#define GLX_ACCUM_BLUE_SIZE 16 +#define GLX_ACCUM_ALPHA_SIZE 17 +#define GLX_SAMPLES 0x186a1 +#define GLX_VISUAL_ID 0x800b + +#define GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20b2 +#define GLX_CONTEXT_DEBUG_BIT_ARB 0x00000001 +#define GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002 +#define GLX_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001 +#define GLX_CONTEXT_PROFILE_MASK_ARB 0x9126 +#define GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x00000002 +#define GLX_CONTEXT_MAJOR_VERSION_ARB 0x2091 +#define GLX_CONTEXT_MINOR_VERSION_ARB 0x2092 +#define GLX_CONTEXT_FLAGS_ARB 0x2094 +#define GLX_CONTEXT_ES2_PROFILE_BIT_EXT 0x00000004 +#define GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB 0x00000004 +#define GLX_LOSE_CONTEXT_ON_RESET_ARB 0x8252 +#define GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB 0x8256 +#define GLX_NO_RESET_NOTIFICATION_ARB 0x8261 +#define GLX_CONTEXT_RELEASE_BEHAVIOR_ARB 0x2097 +#define GLX_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB 0 +#define GLX_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB 0x2098 +#define GLX_CONTEXT_OPENGL_NO_ERROR_ARB 0x31b3 + +typedef XID GLXWindow; +typedef XID GLXDrawable; +typedef struct __GLXFBConfig* GLXFBConfig; +typedef struct __GLXcontext* GLXContext; +typedef void (*__GLXextproc)(void); + typedef XClassHint* (* PFN_XAllocClassHint)(void); typedef XSizeHints* (* PFN_XAllocSizeHints)(void); typedef XWMHints* (* PFN_XAllocWMHints)(void); @@ -347,6 +394,41 @@ typedef void (* PFN_XShapeCombineMask)(Display*,Window,int,int,int,Pixmap,int); #define XShapeCombineRegion _glfw.x11.xshape.ShapeCombineRegion #define XShapeCombineMask _glfw.x11.xshape.ShapeCombineMask +typedef int (*PFNGLXGETFBCONFIGATTRIBPROC)(Display*,GLXFBConfig,int,int*); +typedef const char* (*PFNGLXGETCLIENTSTRINGPROC)(Display*,int); +typedef Bool (*PFNGLXQUERYEXTENSIONPROC)(Display*,int*,int*); +typedef Bool (*PFNGLXQUERYVERSIONPROC)(Display*,int*,int*); +typedef void (*PFNGLXDESTROYCONTEXTPROC)(Display*,GLXContext); +typedef Bool (*PFNGLXMAKECURRENTPROC)(Display*,GLXDrawable,GLXContext); +typedef void (*PFNGLXSWAPBUFFERSPROC)(Display*,GLXDrawable); +typedef const char* (*PFNGLXQUERYEXTENSIONSSTRINGPROC)(Display*,int); +typedef GLXFBConfig* (*PFNGLXGETFBCONFIGSPROC)(Display*,int,int*); +typedef GLXContext (*PFNGLXCREATENEWCONTEXTPROC)(Display*,GLXFBConfig,int,GLXContext,Bool); +typedef __GLXextproc (* PFNGLXGETPROCADDRESSPROC)(const GLubyte *procName); +typedef void (*PFNGLXSWAPINTERVALEXTPROC)(Display*,GLXDrawable,int); +typedef XVisualInfo* (*PFNGLXGETVISUALFROMFBCONFIGPROC)(Display*,GLXFBConfig); +typedef GLXWindow (*PFNGLXCREATEWINDOWPROC)(Display*,GLXFBConfig,Window,const int*); +typedef void (*PFNGLXDESTROYWINDOWPROC)(Display*,GLXWindow); + +typedef int (*PFNGLXSWAPINTERVALMESAPROC)(int); +typedef int (*PFNGLXSWAPINTERVALSGIPROC)(int); +typedef GLXContext (*PFNGLXCREATECONTEXTATTRIBSARBPROC)(Display*,GLXFBConfig,GLXContext,Bool,const int*); + +// libGL.so function pointer typedefs +#define glXGetFBConfigs _glfw.glx.GetFBConfigs +#define glXGetFBConfigAttrib _glfw.glx.GetFBConfigAttrib +#define glXGetClientString _glfw.glx.GetClientString +#define glXQueryExtension _glfw.glx.QueryExtension +#define glXQueryVersion _glfw.glx.QueryVersion +#define glXDestroyContext _glfw.glx.DestroyContext +#define glXMakeCurrent _glfw.glx.MakeCurrent +#define glXSwapBuffers _glfw.glx.SwapBuffers +#define glXQueryExtensionsString _glfw.glx.QueryExtensionsString +#define glXCreateNewContext _glfw.glx.CreateNewContext +#define glXGetVisualFromFBConfig _glfw.glx.GetVisualFromFBConfig +#define glXCreateWindow _glfw.glx.CreateWindow +#define glXDestroyWindow _glfw.glx.DestroyWindow + typedef VkFlags VkXlibSurfaceCreateFlagsKHR; typedef VkFlags VkXcbSurfaceCreateFlagsKHR; @@ -376,7 +458,6 @@ typedef VkBool32 (APIENTRY *PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR)(Vk #include "posix_thread.h" #include "posix_time.h" #include "xkb_unicode.h" -#include "glx_context.h" #if defined(__linux__) #include "linux_joystick.h" #else @@ -388,6 +469,64 @@ typedef VkBool32 (APIENTRY *PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR)(Vk #define _GLFW_PLATFORM_MONITOR_STATE _GLFWmonitorX11 x11 #define _GLFW_PLATFORM_CURSOR_STATE _GLFWcursorX11 x11 +#define _GLFW_PLATFORM_CONTEXT_STATE _GLFWcontextGLX glx +#define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE _GLFWlibraryGLX glx + + +// GLX-specific per-context data +// +typedef struct _GLFWcontextGLX +{ + GLXContext handle; + GLXWindow window; +} _GLFWcontextGLX; + +// GLX-specific global data +// +typedef struct _GLFWlibraryGLX +{ + int major, minor; + int eventBase; + int errorBase; + + // dlopen handle for libGL.so.1 + void* handle; + + // GLX 1.3 functions + PFNGLXGETFBCONFIGSPROC GetFBConfigs; + PFNGLXGETFBCONFIGATTRIBPROC GetFBConfigAttrib; + PFNGLXGETCLIENTSTRINGPROC GetClientString; + PFNGLXQUERYEXTENSIONPROC QueryExtension; + PFNGLXQUERYVERSIONPROC QueryVersion; + PFNGLXDESTROYCONTEXTPROC DestroyContext; + PFNGLXMAKECURRENTPROC MakeCurrent; + PFNGLXSWAPBUFFERSPROC SwapBuffers; + PFNGLXQUERYEXTENSIONSSTRINGPROC QueryExtensionsString; + PFNGLXCREATENEWCONTEXTPROC CreateNewContext; + PFNGLXGETVISUALFROMFBCONFIGPROC GetVisualFromFBConfig; + PFNGLXCREATEWINDOWPROC CreateWindow; + PFNGLXDESTROYWINDOWPROC DestroyWindow; + + // GLX 1.4 and extension functions + PFNGLXGETPROCADDRESSPROC GetProcAddress; + PFNGLXGETPROCADDRESSPROC GetProcAddressARB; + PFNGLXSWAPINTERVALSGIPROC SwapIntervalSGI; + PFNGLXSWAPINTERVALEXTPROC SwapIntervalEXT; + PFNGLXSWAPINTERVALMESAPROC SwapIntervalMESA; + PFNGLXCREATECONTEXTATTRIBSARBPROC CreateContextAttribsARB; + GLFWbool SGI_swap_control; + GLFWbool EXT_swap_control; + GLFWbool MESA_swap_control; + GLFWbool ARB_multisample; + GLFWbool ARB_framebuffer_sRGB; + GLFWbool EXT_framebuffer_sRGB; + GLFWbool ARB_create_context; + GLFWbool ARB_create_context_profile; + GLFWbool ARB_create_context_robustness; + GLFWbool EXT_create_context_es2_profile; + GLFWbool ARB_create_context_no_error; + GLFWbool ARB_context_flush_control; +} _GLFWlibraryGLX; // X11-specific per-window data // @@ -787,3 +926,14 @@ void _glfwInputErrorX11(int error, const char* message); void _glfwPushSelectionToManagerX11(void); void _glfwCreateInputContextX11(_GLFWwindow* window); +GLFWbool _glfwInitGLX(void); +void _glfwTerminateGLX(void); +GLFWbool _glfwCreateContextGLX(_GLFWwindow* window, + const _GLFWctxconfig* ctxconfig, + const _GLFWfbconfig* fbconfig); +void _glfwDestroyContextGLX(_GLFWwindow* window); +GLFWbool _glfwChooseVisualGLX(const _GLFWwndconfig* wndconfig, + const _GLFWctxconfig* ctxconfig, + const _GLFWfbconfig* fbconfig, + Visual** visual, int* depth); + From 35f3b58c219345e3b42a043609ff2ce33250f77d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Sun, 18 Jul 2021 20:31:26 +0200 Subject: [PATCH 040/208] Win32: Make thread functions backend independent This is work towards allowing the Null backend to build for Windows using the Win32 threading API, without the Win32 backend being enabled. --- src/CMakeLists.txt | 2 +- src/win32_platform.h | 19 +----------------- src/win32_thread.c | 3 +-- src/win32_thread.h | 48 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 51 insertions(+), 21 deletions(-) create mode 100644 src/win32_thread.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 964bb909..035b57a6 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -22,7 +22,7 @@ if (_GLFW_COCOA) nsgl_context.m egl_context.c osmesa_context.c) elseif (_GLFW_WIN32) target_compile_definitions(glfw PRIVATE _GLFW_WIN32) - target_sources(glfw PRIVATE win32_platform.h win32_joystick.h + target_sources(glfw PRIVATE win32_platform.h win32_joystick.h win32_thread.h win32_init.c win32_joystick.c win32_monitor.c win32_time.c win32_thread.c win32_window.c wgl_context.c egl_context.c osmesa_context.c) diff --git a/src/win32_platform.h b/src/win32_platform.h index a258c355..a33e4e4b 100644 --- a/src/win32_platform.h +++ b/src/win32_platform.h @@ -356,6 +356,7 @@ typedef struct VkWin32SurfaceCreateInfoKHR typedef VkResult (APIENTRY *PFN_vkCreateWin32SurfaceKHR)(VkInstance,const VkWin32SurfaceCreateInfoKHR*,const VkAllocationCallbacks*,VkSurfaceKHR*); typedef VkBool32 (APIENTRY *PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR)(VkPhysicalDevice,uint32_t); +#include "win32_thread.h" #include "win32_joystick.h" #if !defined(_GLFW_WNDCLASSNAME) @@ -367,8 +368,6 @@ typedef VkBool32 (APIENTRY *PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR)( #define _GLFW_PLATFORM_LIBRARY_TIMER_STATE _GLFWtimerWin32 win32 #define _GLFW_PLATFORM_MONITOR_STATE _GLFWmonitorWin32 win32 #define _GLFW_PLATFORM_CURSOR_STATE _GLFWcursorWin32 win32 -#define _GLFW_PLATFORM_TLS_STATE _GLFWtlsWin32 win32 -#define _GLFW_PLATFORM_MUTEX_STATE _GLFWmutexWin32 win32 #define _GLFW_PLATFORM_CONTEXT_STATE _GLFWcontextWGL wgl #define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE _GLFWlibraryWGL wgl @@ -536,22 +535,6 @@ typedef struct _GLFWtimerWin32 uint64_t frequency; } _GLFWtimerWin32; -// Win32-specific thread local storage data -// -typedef struct _GLFWtlsWin32 -{ - GLFWbool allocated; - DWORD index; -} _GLFWtlsWin32; - -// Win32-specific mutex data -// -typedef struct _GLFWmutexWin32 -{ - GLFWbool allocated; - CRITICAL_SECTION section; -} _GLFWmutexWin32; - GLFWbool _glfwRegisterWindowClassWin32(void); void _glfwUnregisterWindowClassWin32(void); diff --git a/src/win32_thread.c b/src/win32_thread.c index 53b34af2..35b8f99e 100644 --- a/src/win32_thread.c +++ b/src/win32_thread.c @@ -43,8 +43,7 @@ GLFWbool _glfwPlatformCreateTls(_GLFWtls* tls) tls->win32.index = TlsAlloc(); if (tls->win32.index == TLS_OUT_OF_INDEXES) { - _glfwInputErrorWin32(GLFW_PLATFORM_ERROR, - "Win32: Failed to allocate TLS index"); + _glfwInputError(GLFW_PLATFORM_ERROR, "Win32: Failed to allocate TLS index"); return GLFW_FALSE; } diff --git a/src/win32_thread.h b/src/win32_thread.h new file mode 100644 index 00000000..afc8f546 --- /dev/null +++ b/src/win32_thread.h @@ -0,0 +1,48 @@ +//======================================================================== +// GLFW 3.4 Win32 - www.glfw.org +//------------------------------------------------------------------------ +// Copyright (c) 2002-2006 Marcus Geelnard +// Copyright (c) 2006-2017 Camilla Löwy +// +// This software is provided 'as-is', without any express or implied +// warranty. In no event will the authors be held liable for any damages +// arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it +// freely, subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; you must not +// claim that you wrote the original software. If you use this software +// in a product, an acknowledgment in the product documentation would +// be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, and must not +// be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source +// distribution. +// +//======================================================================== + +#include + +#define _GLFW_PLATFORM_TLS_STATE _GLFWtlsWin32 win32 +#define _GLFW_PLATFORM_MUTEX_STATE _GLFWmutexWin32 win32 + +// Win32-specific thread local storage data +// +typedef struct _GLFWtlsWin32 +{ + GLFWbool allocated; + DWORD index; +} _GLFWtlsWin32; + +// Win32-specific mutex data +// +typedef struct _GLFWmutexWin32 +{ + GLFWbool allocated; + CRITICAL_SECTION section; +} _GLFWmutexWin32; + From b6834bf2a144917e8e82de863d87d6cf5553e6af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Sun, 18 Jul 2021 21:24:15 +0200 Subject: [PATCH 041/208] Win32: Remove timeGetTime fallback for timer The performance counter API is guaranteed to succeed on Windows XP and later so there is no need for a fallback. This removes our last dependency on winmm. --- src/win32_init.c | 14 -------------- src/win32_platform.h | 10 ---------- src/win32_time.c | 24 ++++-------------------- 3 files changed, 4 insertions(+), 44 deletions(-) diff --git a/src/win32_init.c b/src/win32_init.c index 53acab54..3441173f 100644 --- a/src/win32_init.c +++ b/src/win32_init.c @@ -71,17 +71,6 @@ BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID reserved) // static GLFWbool loadLibraries(void) { - _glfw.win32.winmm.instance = _glfwPlatformLoadModule("winmm.dll"); - if (!_glfw.win32.winmm.instance) - { - _glfwInputErrorWin32(GLFW_PLATFORM_ERROR, - "Win32: Failed to load winmm.dll"); - return GLFW_FALSE; - } - - _glfw.win32.winmm.GetTime = (PFN_timeGetTime) - _glfwPlatformGetModuleSymbol(_glfw.win32.winmm.instance, "timeGetTime"); - _glfw.win32.user32.instance = _glfwPlatformLoadModule("user32.dll"); if (!_glfw.win32.user32.instance) { @@ -179,9 +168,6 @@ static void freeLibraries(void) if (_glfw.win32.dinput8.instance) _glfwPlatformFreeModule(_glfw.win32.dinput8.instance); - if (_glfw.win32.winmm.instance) - _glfwPlatformFreeModule(_glfw.win32.winmm.instance); - if (_glfw.win32.user32.instance) _glfwPlatformFreeModule(_glfw.win32.user32.instance); diff --git a/src/win32_platform.h b/src/win32_platform.h index a33e4e4b..465713cb 100644 --- a/src/win32_platform.h +++ b/src/win32_platform.h @@ -266,10 +266,6 @@ typedef enum #define ERROR_INVALID_PROFILE_ARB 0x2096 #define ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB 0x2054 -// winmm.dll function pointer typedefs -typedef DWORD (WINAPI * PFN_timeGetTime)(void); -#define timeGetTime _glfw.win32.winmm.GetTime - // xinput.dll function pointer typedefs typedef DWORD (WINAPI * PFN_XInputGetCapabilities)(DWORD,DWORD,XINPUT_CAPABILITIES*); typedef DWORD (WINAPI * PFN_XInputGetState)(DWORD,XINPUT_STATE*); @@ -459,11 +455,6 @@ typedef struct _GLFWlibraryWin32 int rawInputSize; UINT mouseTrailSize; - struct { - HINSTANCE instance; - PFN_timeGetTime GetTime; - } winmm; - struct { HINSTANCE instance; PFN_DirectInput8Create Create; @@ -531,7 +522,6 @@ typedef struct _GLFWcursorWin32 // typedef struct _GLFWtimerWin32 { - GLFWbool hasPC; uint64_t frequency; } _GLFWtimerWin32; diff --git a/src/win32_time.c b/src/win32_time.c index 2b1cbf0d..a1c64141 100644 --- a/src/win32_time.c +++ b/src/win32_time.c @@ -36,30 +36,14 @@ void _glfwPlatformInitTimer(void) { - uint64_t frequency; - - if (QueryPerformanceFrequency((LARGE_INTEGER*) &frequency)) - { - _glfw.timer.win32.hasPC = GLFW_TRUE; - _glfw.timer.win32.frequency = frequency; - } - else - { - _glfw.timer.win32.hasPC = GLFW_FALSE; - _glfw.timer.win32.frequency = 1000; - } + QueryPerformanceFrequency((LARGE_INTEGER*) &_glfw.timer.win32.frequency); } uint64_t _glfwPlatformGetTimerValue(void) { - if (_glfw.timer.win32.hasPC) - { - uint64_t value; - QueryPerformanceCounter((LARGE_INTEGER*) &value); - return value; - } - else - return (uint64_t) timeGetTime(); + uint64_t value; + QueryPerformanceCounter((LARGE_INTEGER*) &value); + return value; } uint64_t _glfwPlatformGetTimerFrequency(void) From bdfe6b09af959f136ba1605d4bc24cca0e99e1d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Sun, 18 Jul 2021 20:38:53 +0200 Subject: [PATCH 042/208] Win32: Make timer functions backend independent This is work towards allowing the Null backend to build for Windows using the Win32 timer API, without the Win32 backend being enabled. --- src/CMakeLists.txt | 9 +++++---- src/win32_platform.h | 9 +-------- src/win32_time.h | 38 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 12 deletions(-) create mode 100644 src/win32_time.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 035b57a6..a7cacabd 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -22,10 +22,11 @@ if (_GLFW_COCOA) nsgl_context.m egl_context.c osmesa_context.c) elseif (_GLFW_WIN32) target_compile_definitions(glfw PRIVATE _GLFW_WIN32) - target_sources(glfw PRIVATE win32_platform.h win32_joystick.h win32_thread.h - win32_init.c win32_joystick.c win32_monitor.c - win32_time.c win32_thread.c win32_window.c - wgl_context.c egl_context.c osmesa_context.c) + target_sources(glfw PRIVATE win32_platform.h win32_joystick.h win32_time.h + win32_thread.h win32_init.c win32_joystick.c + win32_monitor.c win32_time.c win32_thread.c + win32_window.c wgl_context.c egl_context.c + osmesa_context.c) elseif (_GLFW_X11) target_compile_definitions(glfw PRIVATE _GLFW_X11) target_sources(glfw PRIVATE x11_platform.h xkb_unicode.h posix_time.h diff --git a/src/win32_platform.h b/src/win32_platform.h index 465713cb..cfea35b5 100644 --- a/src/win32_platform.h +++ b/src/win32_platform.h @@ -352,6 +352,7 @@ typedef struct VkWin32SurfaceCreateInfoKHR typedef VkResult (APIENTRY *PFN_vkCreateWin32SurfaceKHR)(VkInstance,const VkWin32SurfaceCreateInfoKHR*,const VkAllocationCallbacks*,VkSurfaceKHR*); typedef VkBool32 (APIENTRY *PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR)(VkPhysicalDevice,uint32_t); +#include "win32_time.h" #include "win32_thread.h" #include "win32_joystick.h" @@ -361,7 +362,6 @@ typedef VkBool32 (APIENTRY *PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR)( #define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowWin32 win32 #define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryWin32 win32 -#define _GLFW_PLATFORM_LIBRARY_TIMER_STATE _GLFWtimerWin32 win32 #define _GLFW_PLATFORM_MONITOR_STATE _GLFWmonitorWin32 win32 #define _GLFW_PLATFORM_CURSOR_STATE _GLFWcursorWin32 win32 @@ -518,13 +518,6 @@ typedef struct _GLFWcursorWin32 HCURSOR handle; } _GLFWcursorWin32; -// Win32-specific global timer data -// -typedef struct _GLFWtimerWin32 -{ - uint64_t frequency; -} _GLFWtimerWin32; - GLFWbool _glfwRegisterWindowClassWin32(void); void _glfwUnregisterWindowClassWin32(void); diff --git a/src/win32_time.h b/src/win32_time.h new file mode 100644 index 00000000..a5a7ee80 --- /dev/null +++ b/src/win32_time.h @@ -0,0 +1,38 @@ +//======================================================================== +// GLFW 3.4 Win32 - www.glfw.org +//------------------------------------------------------------------------ +// Copyright (c) 2002-2006 Marcus Geelnard +// Copyright (c) 2006-2017 Camilla Löwy +// +// This software is provided 'as-is', without any express or implied +// warranty. In no event will the authors be held liable for any damages +// arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it +// freely, subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; you must not +// claim that you wrote the original software. If you use this software +// in a product, an acknowledgment in the product documentation would +// be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, and must not +// be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source +// distribution. +// +//======================================================================== + +#include + +#define _GLFW_PLATFORM_LIBRARY_TIMER_STATE _GLFWtimerWin32 win32 + +// Win32-specific global timer data +// +typedef struct _GLFWtimerWin32 +{ + uint64_t frequency; +} _GLFWtimerWin32; + From 09f9773e6fffd29981f4191fee65f504d66da1d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Sun, 18 Jul 2021 22:54:58 +0200 Subject: [PATCH 043/208] Cocoa: Make timer functions backend independent This is work towards allowing the Null backend to build for macOS using the Darwin timer API, without the Cocoa backend being enabled. --- src/CMakeLists.txt | 9 +++++---- src/cocoa_platform.h | 9 +-------- src/cocoa_time.h | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 12 deletions(-) create mode 100644 src/cocoa_time.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a7cacabd..0dda7386 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -16,10 +16,11 @@ set_target_properties(update_mappings PROPERTIES FOLDER "GLFW3") if (_GLFW_COCOA) target_compile_definitions(glfw PRIVATE _GLFW_COCOA) - target_sources(glfw PRIVATE cocoa_platform.h cocoa_joystick.h posix_thread.h - cocoa_init.m cocoa_joystick.m cocoa_monitor.m - cocoa_window.m cocoa_time.c posix_thread.c - nsgl_context.m egl_context.c osmesa_context.c) + target_sources(glfw PRIVATE cocoa_platform.h cocoa_joystick.h cocoa_time.h + posix_thread.h cocoa_init.m cocoa_joystick.m + cocoa_monitor.m cocoa_window.m cocoa_time.c + posix_thread.c nsgl_context.m egl_context.c + osmesa_context.c) elseif (_GLFW_WIN32) target_compile_definitions(glfw PRIVATE _GLFW_WIN32) target_sources(glfw PRIVATE win32_platform.h win32_joystick.h win32_time.h diff --git a/src/cocoa_platform.h b/src/cocoa_platform.h index 9d3e9fe0..18385727 100644 --- a/src/cocoa_platform.h +++ b/src/cocoa_platform.h @@ -91,12 +91,12 @@ typedef struct VkMetalSurfaceCreateInfoEXT typedef VkResult (APIENTRY *PFN_vkCreateMacOSSurfaceMVK)(VkInstance,const VkMacOSSurfaceCreateInfoMVK*,const VkAllocationCallbacks*,VkSurfaceKHR*); typedef VkResult (APIENTRY *PFN_vkCreateMetalSurfaceEXT)(VkInstance,const VkMetalSurfaceCreateInfoEXT*,const VkAllocationCallbacks*,VkSurfaceKHR*); +#include "cocoa_time.h" #include "posix_thread.h" #include "cocoa_joystick.h" #define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowNS ns #define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryNS ns -#define _GLFW_PLATFORM_LIBRARY_TIMER_STATE _GLFWtimerNS ns #define _GLFW_PLATFORM_MONITOR_STATE _GLFWmonitorNS ns #define _GLFW_PLATFORM_CURSOR_STATE _GLFWcursorNS ns @@ -204,13 +204,6 @@ typedef struct _GLFWcursorNS id object; } _GLFWcursorNS; -// Cocoa-specific global timer data -// -typedef struct _GLFWtimerNS -{ - uint64_t frequency; -} _GLFWtimerNS; - void _glfwPollMonitorsNS(void); void _glfwSetVideoModeNS(_GLFWmonitor* monitor, const GLFWvidmode* desired); diff --git a/src/cocoa_time.h b/src/cocoa_time.h new file mode 100644 index 00000000..6f41ef19 --- /dev/null +++ b/src/cocoa_time.h @@ -0,0 +1,35 @@ +//======================================================================== +// GLFW 3.4 macOS - www.glfw.org +//------------------------------------------------------------------------ +// Copyright (c) 2009-2021 Camilla Löwy +// +// This software is provided 'as-is', without any express or implied +// warranty. In no event will the authors be held liable for any damages +// arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it +// freely, subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; you must not +// claim that you wrote the original software. If you use this software +// in a product, an acknowledgment in the product documentation would +// be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, and must not +// be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source +// distribution. +// +//======================================================================== + +#define _GLFW_PLATFORM_LIBRARY_TIMER_STATE _GLFWtimerNS ns + +// Cocoa-specific global timer data +// +typedef struct _GLFWtimerNS +{ + uint64_t frequency; +} _GLFWtimerNS; + From 36ea36736de2fcca24cdd91f383ec5140e73de81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 25 Aug 2021 23:43:32 +0200 Subject: [PATCH 044/208] Cocoa: Change helper function suffix to Cocoa This makes it clearer which platform a helper function belongs to. --- src/cocoa_init.m | 14 +++++++------- src/cocoa_monitor.m | 8 ++++---- src/cocoa_platform.h | 10 +++++----- src/cocoa_window.m | 18 +++++++++--------- 4 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/cocoa_init.m b/src/cocoa_init.m index 701265a5..9646ca48 100644 --- a/src/cocoa_init.m +++ b/src/cocoa_init.m @@ -307,7 +307,7 @@ static void createKeyTables(void) // Retrieve Unicode data for the current keyboard layout // -static GLFWbool updateUnicodeDataNS(void) +static GLFWbool updateUnicodeData(void) { if (_glfw.ns.inputSource) { @@ -377,7 +377,7 @@ static GLFWbool initializeTIS(void) _glfw.ns.tis.kPropertyUnicodeKeyLayoutData = *kPropertyUnicodeKeyLayoutData; - return updateUnicodeDataNS(); + return updateUnicodeData(); } @interface GLFWHelper : NSObject @@ -387,7 +387,7 @@ static GLFWbool initializeTIS(void) - (void)selectedKeyboardInputSourceChanged:(NSObject* )object { - updateUnicodeDataNS(); + updateUnicodeData(); } - (void)doNothing:(id)object @@ -421,7 +421,7 @@ static GLFWbool initializeTIS(void) [window->context.nsgl.object update]; } - _glfwPollMonitorsNS(); + _glfwPollMonitorsCocoa(); } - (void)applicationWillFinishLaunching:(NSNotification *)notification @@ -453,7 +453,7 @@ static GLFWbool initializeTIS(void) int i; for (i = 0; i < _glfw.monitorCount; i++) - _glfwRestoreVideoModeNS(_glfw.monitors[i]); + _glfwRestoreVideoModeCocoa(_glfw.monitors[i]); } @end // GLFWApplicationDelegate @@ -463,7 +463,7 @@ static GLFWbool initializeTIS(void) ////// GLFW internal API ////// ////////////////////////////////////////////////////////////////////////// -void* _glfwLoadLocalVulkanLoaderNS(void) +void* _glfwLoadLocalVulkanLoaderCocoa(void) { CFBundleRef bundle = CFBundleGetMainBundle(); if (!bundle) @@ -547,7 +547,7 @@ int _glfwPlatformInit(void) if (!initializeTIS()) return GLFW_FALSE; - _glfwPollMonitorsNS(); + _glfwPollMonitorsCocoa(); if (![[NSRunningApplication currentApplication] isFinishedLaunching]) [NSApp run]; diff --git a/src/cocoa_monitor.m b/src/cocoa_monitor.m index 2462beab..5416f5bf 100644 --- a/src/cocoa_monitor.m +++ b/src/cocoa_monitor.m @@ -297,7 +297,7 @@ static double getFallbackRefreshRate(CGDirectDisplayID displayID) // Poll for changes in the set of connected monitors // -void _glfwPollMonitorsNS(void) +void _glfwPollMonitorsCocoa(void) { uint32_t displayCount; CGGetOnlineDisplayList(0, NULL, &displayCount); @@ -385,7 +385,7 @@ void _glfwPollMonitorsNS(void) // Change the current video mode // -void _glfwSetVideoModeNS(_GLFWmonitor* monitor, const GLFWvidmode* desired) +void _glfwSetVideoModeCocoa(_GLFWmonitor* monitor, const GLFWvidmode* desired) { GLFWvidmode current; _glfwPlatformGetVideoMode(monitor, ¤t); @@ -428,7 +428,7 @@ void _glfwSetVideoModeNS(_GLFWmonitor* monitor, const GLFWvidmode* desired) // Restore the previously saved (original) video mode // -void _glfwRestoreVideoModeNS(_GLFWmonitor* monitor) +void _glfwRestoreVideoModeCocoa(_GLFWmonitor* monitor) { if (monitor->ns.previousMode) { @@ -504,7 +504,7 @@ void _glfwPlatformGetMonitorWorkarea(_GLFWmonitor* monitor, if (xpos) *xpos = frameRect.origin.x; if (ypos) - *ypos = _glfwTransformYNS(frameRect.origin.y + frameRect.size.height - 1); + *ypos = _glfwTransformYCocoa(frameRect.origin.y + frameRect.size.height - 1); if (width) *width = frameRect.size.width; if (height) diff --git a/src/cocoa_platform.h b/src/cocoa_platform.h index 18385727..76ddcb28 100644 --- a/src/cocoa_platform.h +++ b/src/cocoa_platform.h @@ -205,13 +205,13 @@ typedef struct _GLFWcursorNS } _GLFWcursorNS; -void _glfwPollMonitorsNS(void); -void _glfwSetVideoModeNS(_GLFWmonitor* monitor, const GLFWvidmode* desired); -void _glfwRestoreVideoModeNS(_GLFWmonitor* monitor); +void _glfwPollMonitorsCocoa(void); +void _glfwSetVideoModeCocoa(_GLFWmonitor* monitor, const GLFWvidmode* desired); +void _glfwRestoreVideoModeCocoa(_GLFWmonitor* monitor); -float _glfwTransformYNS(float y); +float _glfwTransformYCocoa(float y); -void* _glfwLoadLocalVulkanLoaderNS(void); +void* _glfwLoadLocalVulkanLoaderCocoa(void); GLFWbool _glfwInitNSGL(void); void _glfwTerminateNSGL(void); diff --git a/src/cocoa_window.m b/src/cocoa_window.m index 49b50749..ab169d96 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -129,10 +129,10 @@ static void updateCursorMode(_GLFWwindow* window) // static void acquireMonitor(_GLFWwindow* window) { - _glfwSetVideoModeNS(window->monitor, &window->videoMode); + _glfwSetVideoModeCocoa(window->monitor, &window->videoMode); const CGRect bounds = CGDisplayBounds(window->monitor->ns.displayID); const NSRect frame = NSMakeRect(bounds.origin.x, - _glfwTransformYNS(bounds.origin.y + bounds.size.height - 1), + _glfwTransformYCocoa(bounds.origin.y + bounds.size.height - 1), bounds.size.width, bounds.size.height); @@ -149,7 +149,7 @@ static void releaseMonitor(_GLFWwindow* window) return; _glfwInputMonitorWindow(window->monitor, NULL); - _glfwRestoreVideoModeNS(window->monitor); + _glfwRestoreVideoModeCocoa(window->monitor); } // Translates macOS key modifiers into GLFW ones @@ -885,7 +885,7 @@ static GLFWbool createNativeWindow(_GLFWwindow* window, // Transforms a y-coordinate between the CG display and NS screen spaces // -float _glfwTransformYNS(float y) +float _glfwTransformYCocoa(float y) { return CGDisplayBounds(CGMainDisplayID()).size.height - y - 1; } @@ -1006,7 +1006,7 @@ void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos) if (xpos) *xpos = contentRect.origin.x; if (ypos) - *ypos = _glfwTransformYNS(contentRect.origin.y + contentRect.size.height - 1); + *ypos = _glfwTransformYCocoa(contentRect.origin.y + contentRect.size.height - 1); } // autoreleasepool } @@ -1016,7 +1016,7 @@ void _glfwPlatformSetWindowPos(_GLFWwindow* window, int x, int y) @autoreleasepool { const NSRect contentRect = [window->ns.view frame]; - const NSRect dummyRect = NSMakeRect(x, _glfwTransformYNS(y + contentRect.size.height - 1), 0, 0); + const NSRect dummyRect = NSMakeRect(x, _glfwTransformYCocoa(y + contentRect.size.height - 1), 0, 0); const NSRect frameRect = [window->ns.object frameRectForContentRect:dummyRect]; [window->ns.object setFrameOrigin:frameRect.origin]; @@ -1218,7 +1218,7 @@ void _glfwPlatformSetWindowMonitor(_GLFWwindow* window, else { const NSRect contentRect = - NSMakeRect(xpos, _glfwTransformYNS(ypos + height - 1), width, height); + NSMakeRect(xpos, _glfwTransformYCocoa(ypos + height - 1), width, height); const NSRect frameRect = [window->ns.object frameRectForContentRect:contentRect styleMask:getStyleMask(window)]; @@ -1252,7 +1252,7 @@ void _glfwPlatformSetWindowMonitor(_GLFWwindow* window, } else { - NSRect contentRect = NSMakeRect(xpos, _glfwTransformYNS(ypos + height - 1), + NSRect contentRect = NSMakeRect(xpos, _glfwTransformYCocoa(ypos + height - 1), width, height); NSRect frameRect = [window->ns.object frameRectForContentRect:contentRect styleMask:styleMask]; @@ -1516,7 +1516,7 @@ void _glfwPlatformSetCursorPos(_GLFWwindow* window, double x, double y) const NSPoint globalPoint = globalRect.origin; CGWarpMouseCursorPosition(CGPointMake(globalPoint.x, - _glfwTransformYNS(globalPoint.y))); + _glfwTransformYCocoa(globalPoint.y))); } // HACK: Calling this right after setting the cursor position prevents macOS From ff9d9515f616e0f8aa96cbe47d5dbc8dd815026f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 30 Aug 2021 20:40:35 +0200 Subject: [PATCH 045/208] Remove typedefs only used in one place --- src/internal.h | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/src/internal.h b/src/internal.h index e724b293..af882be5 100644 --- a/src/internal.h +++ b/src/internal.h @@ -77,13 +77,6 @@ typedef struct _GLFWjoystick _GLFWjoystick; typedef struct _GLFWtls _GLFWtls; typedef struct _GLFWmutex _GLFWmutex; -typedef void (* _GLFWmakecontextcurrentfun)(_GLFWwindow*); -typedef void (* _GLFWswapbuffersfun)(_GLFWwindow*); -typedef void (* _GLFWswapintervalfun)(int); -typedef int (* _GLFWextensionsupportedfun)(const char*); -typedef GLFWglproc (* _GLFWgetprocaddressfun)(const char*); -typedef void (* _GLFWdestroycontextfun)(_GLFWwindow*); - #define GL_VERSION 0x1f02 #define GL_NONE 0 #define GL_COLOR_BUFFER_BIT 0x00004000 @@ -513,12 +506,12 @@ struct _GLFWcontext PFNGLGETINTEGERVPROC GetIntegerv; PFNGLGETSTRINGPROC GetString; - _GLFWmakecontextcurrentfun makeCurrent; - _GLFWswapbuffersfun swapBuffers; - _GLFWswapintervalfun swapInterval; - _GLFWextensionsupportedfun extensionSupported; - _GLFWgetprocaddressfun getProcAddress; - _GLFWdestroycontextfun destroy; + void (*makeCurrent)(_GLFWwindow*); + void (*swapBuffers)(_GLFWwindow*); + void (*swapInterval)(int); + int (*extensionSupported)(const char*); + GLFWglproc (*getProcAddress)(const char*); + void (*destroy)(_GLFWwindow*); struct { EGLConfig config; From 56a4cb0a3a2c7a44a2fd8ab3335adf915e19d30c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 13 Jul 2021 21:50:09 +0200 Subject: [PATCH 046/208] Add runtime platform selection This adds compile-time support for multiple platforms and runtime detection of them. Window system related platform functions are now called from shared code via the function pointer struct _GLFWplatform. The timer, thread and module loading platform functions are still called directly by name and the implementation chosen at link-time. These functions are the same for any backend on a given OS, including the Null backend. The platforms are now enabled via CMake dependent options following the GLFW_BUILD_ pattern instead of a mix of automagic and ad-hoc option names. There is no longer any option for the Null backend as it is now always enabled. Much of the struct stitching work in platform.h was based on an earlier experimental branch for runtime platform selection by @ronchaine. Every platform function related to windows, contexts, monitors, input, event processing and Vulkan have been renamed so that multiple sets of them can exist without colliding. Calls to these are now routed through the _glfw.platform struct member. These changes makes up most of this commit. For Wayland and X11 the client library loading and display creation is used to detect a running compositor/server. The XDG_SESSION_TYPE environment variable is ignored for now, as X11 is still by far the more complete implementation. Closes #1655 Closes #1958 --- .github/workflows/build.yml | 33 +---- CMakeLists.txt | 52 ++++---- README.md | 14 ++ docs/compile.dox | 91 ++++++++----- docs/internal.dox | 19 ++- docs/intro.dox | 85 +++++++++++- docs/news.dox | 48 ++++++- include/GLFW/glfw3.h | 122 +++++++++++++++-- src/CMakeLists.txt | 103 ++++++++------- src/cocoa_init.m | 97 ++++++++++++-- src/cocoa_joystick.h | 11 +- src/cocoa_joystick.m | 10 +- src/cocoa_monitor.m | 24 ++-- src/cocoa_platform.h | 92 +++++++++++-- src/cocoa_time.h | 2 +- src/cocoa_window.m | 200 ++++++++++++++-------------- src/egl_context.c | 14 +- src/glx_context.c | 14 +- src/init.c | 22 ++-- src/input.c | 68 +++++----- src/internal.h | 252 ++++++++++++++++-------------------- src/linux_joystick.c | 10 +- src/linux_joystick.h | 10 +- src/monitor.c | 26 ++-- src/nsgl_context.m | 7 + src/null_init.c | 94 ++++++++++++-- src/null_joystick.c | 10 +- src/null_joystick.h | 7 +- src/null_monitor.c | 26 ++-- src/null_platform.h | 91 +++++++++++-- src/null_window.c | 184 +++++++++++++------------- src/osmesa_context.c | 2 +- src/platform.c | 184 ++++++++++++++++++++++++++ src/platform.h | 179 +++++++++++++++++++++++++ src/posix_thread.h | 4 +- src/posix_time.h | 2 +- src/vulkan.c | 17 +-- src/wgl_context.c | 35 +++-- src/win32_init.c | 106 +++++++++++---- src/win32_joystick.c | 12 +- src/win32_joystick.h | 4 +- src/win32_monitor.c | 30 ++--- src/win32_platform.h | 99 ++++++++++++-- src/win32_thread.h | 4 +- src/win32_time.h | 2 +- src/win32_window.c | 219 +++++++++++++++---------------- src/window.c | 92 ++++++------- src/wl_init.c | 166 +++++++++++++++++++----- src/wl_monitor.c | 23 ++-- src/wl_platform.h | 94 +++++++++++--- src/wl_window.c | 178 +++++++++++++------------ src/x11_init.c | 193 ++++++++++++++++++++------- src/x11_monitor.c | 24 ++-- src/x11_platform.h | 102 ++++++++++++--- src/x11_window.c | 249 +++++++++++++++++++---------------- tests/glfwinfo.c | 75 ++++++++++- 56 files changed, 2698 insertions(+), 1235 deletions(-) create mode 100644 src/platform.c create mode 100644 src/platform.h diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d87ae8d1..249e8d68 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -31,8 +31,8 @@ jobs: - name: Build shared library run: cmake --build build-shared --parallel - build-linux-wayland-clang: - name: Wayland (Linux, Clang) + build-linux-full-clang: + name: X11+Wayland (Linux, Clang) runs-on: ubuntu-latest env: CC: clang @@ -42,38 +42,15 @@ jobs: - name: Install dependencies run: | sudo apt update - sudo apt install wayland-protocols libwayland-dev libxkbcommon-dev + sudo apt install libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev libxext-dev wayland-protocols libwayland-dev libxkbcommon-dev - name: Configure static library - run: cmake -S . -B build-static -D GLFW_USE_WAYLAND=ON + run: cmake -S . -B build-static -D GLFW_BUILD_WAYLAND=ON - name: Build static library run: cmake --build build-static --parallel - name: Configure shared library - run: cmake -S . -B build-shared -D GLFW_USE_WAYLAND=ON -D BUILD_SHARED_LIBS=ON - - name: Build shared library - run: cmake --build build-shared --parallel - - build-linux-null-clang: - name: Null (Linux, Clang) - runs-on: ubuntu-latest - env: - CC: clang - CFLAGS: -Werror - steps: - - uses: actions/checkout@v2 - - name: Install dependencies - run: | - sudo apt update - sudo apt install libosmesa6-dev - - - name: Configure static library - run: cmake -S . -B build-static -D GLFW_USE_OSMESA=ON - - name: Build static library - run: cmake --build build-static --parallel - - - name: Configure shared library - run: cmake -S . -B build-shared -D GLFW_USE_OSMESA=ON -D BUILD_SHARED_LIBS=ON + run: cmake -S . -B build-shared -D GLFW_BUILD_WAYLAND=ON -D BUILD_SHARED_LIBS=ON - name: Build shared library run: cmake --build build-shared --parallel diff --git a/CMakeLists.txt b/CMakeLists.txt index a1169171..5042ab9c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,12 +32,18 @@ option(GLFW_VULKAN_STATIC "Assume the Vulkan loader is linked with the applicati include(GNUInstallDirs) include(CMakeDependentOption) -cmake_dependent_option(GLFW_USE_OSMESA "Use OSMesa for offscreen context creation" OFF - "UNIX" OFF) +if (GLFW_USE_OSMESA) + message(FATAL_ERROR "GLFW_USE_OSMESA has been removed; set the GLFW_PLATFORM init hint") +endif() + +cmake_dependent_option(GLFW_BUILD_WIN32 "Build support for Win32" ON "WIN32" OFF) +cmake_dependent_option(GLFW_BUILD_COCOA "Build support for Cocoa" ON "APPLE" OFF) +cmake_dependent_option(GLFW_BUILD_X11 "Build support for X11" ON "UNIX;NOT APPLE" OFF) +cmake_dependent_option(GLFW_BUILD_WAYLAND "Build support for Wayland" + "${GLFW_USE_WAYLAND}" "UNIX;NOT APPLE" OFF) + cmake_dependent_option(GLFW_USE_HYBRID_HPG "Force use of high-performance GPU on hybrid systems" OFF "WIN32" OFF) -cmake_dependent_option(GLFW_USE_WAYLAND "Use Wayland for window creation" OFF - "UNIX;NOT APPLE" OFF) cmake_dependent_option(USE_MSVC_RUNTIME_LIBRARY_DLL "Use MSVC runtime library DLL" ON "MSVC" OFF) @@ -63,6 +69,22 @@ if (GLFW_BUILD_DOCS) find_package(Doxygen) endif() +#-------------------------------------------------------------------- +# Report backend selection +#-------------------------------------------------------------------- +if (GLFW_BUILD_WIN32) + message(STATUS "Including Win32 support") +endif() +if (GLFW_BUILD_COCOA) + message(STATUS "Including Cocoa support") +endif() +if (GLFW_BUILD_WAYLAND) + message(STATUS "Including Wayland support") +endif() +if (GLFW_BUILD_X11) + message(STATUS "Including X11 support") +endif() + #-------------------------------------------------------------------- # Apply Microsoft C runtime library option # This is here because it also applies to tests and examples @@ -88,28 +110,6 @@ if (MSVC AND NOT USE_MSVC_RUNTIME_LIBRARY_DLL) endif() endif() -#-------------------------------------------------------------------- -# Detect and select backend APIs -#-------------------------------------------------------------------- -if (GLFW_USE_WAYLAND) - set(_GLFW_WAYLAND 1) - message(STATUS "Using Wayland for window creation") -elseif (GLFW_USE_OSMESA) - set(_GLFW_OSMESA 1) - message(STATUS "Using OSMesa for headless context creation") -elseif (WIN32) - set(_GLFW_WIN32 1) - message(STATUS "Using Win32 for window creation") -elseif (APPLE) - set(_GLFW_COCOA 1) - message(STATUS "Using Cocoa for window creation") -elseif (UNIX) - set(_GLFW_X11 1) - message(STATUS "Using X11 for window creation") -else() - message(FATAL_ERROR "No supported platform was detected") -endif() - #-------------------------------------------------------------------- # Create generated files #-------------------------------------------------------------------- diff --git a/README.md b/README.md index 4c783f7b..d1396af4 100644 --- a/README.md +++ b/README.md @@ -116,6 +116,13 @@ information on what to include when reporting a bug. ## Changelog + - Added `GLFW_PLATFORM` init hint for runtime platform selection (#1958) + - Added `GLFW_ANY_PLATFORM`, `GLFW_PLATFORM_WIN32`, `GLFW_PLATFORM_COCOA`, + `GLFW_PLATFORM_WAYLAND`, `GLFW_PLATFORM_X11` and `GLFW_PLATFORM_NULL` symbols to + specify the desired platform (#1958) + - Added `glfwGetPlatform` function to query what platform was selected (#1655,#1958) + - Added `glfwPlatformSupported` function to query if a platform is supported + (#1655,#1958) - Added `glfwInitAllocator` for setting a custom memory allocator (#544,#1628,#1947) - Added `GLFWallocator` struct and `GLFWallocatefun`, `GLFWreallocatefun` and `GLFWdeallocatefun` types (#544,#1628,#1947) @@ -126,12 +133,16 @@ information on what to include when reporting a bug. - Added `GLFW_POINTING_HAND_CURSOR` alias for `GLFW_HAND_CURSOR` (#427) - Added `GLFW_MOUSE_PASSTHROUGH` window hint for letting mouse input pass through the window (#1236,#1568) + - Added `GLFW_PLATFORM_UNAVAILABLE` error for platform detection failures (#1958) - Added `GLFW_FEATURE_UNAVAILABLE` error for platform limitations (#1692) - Added `GLFW_FEATURE_UNIMPLEMENTED` error for incomplete backends (#1692) - Added `GLFW_ANGLE_PLATFORM_TYPE` init hint and `GLFW_ANGLE_PLATFORM_TYPE_*` values to select ANGLE backend (#1380) - Added `GLFW_X11_XCB_VULKAN_SURFACE` init hint for selecting X11 Vulkan surface extension (#1793) + - Added `GLFW_BUILD_WIN32` CMake option for enabling Win32 support (#1958) + - Added `GLFW_BUILD_COCOA` CMake option for enabling Cocoa support (#1958) + - Added `GLFW_BUILD_X11` CMake option for enabling X11 support (#1958) - Added `GLFW_LIBRARY_TYPE` CMake variable for overriding the library type (#279,#1307,#1497,#1574,#1928) - Added `GLFW_PKG_CONFIG_REQUIRES_PRIVATE` and `GLFW_PKG_CONFIG_LIBS_PRIVATE` CMake @@ -140,6 +151,8 @@ information on what to include when reporting a bug. - Made `GLFW_DOUBLEBUFFER` a read-only window attribute - Updated the minimum required CMake version to 3.1 - Disabled tests and examples by default when built as a CMake subdirectory + - Renamed `GLFW_USE_WAYLAND` CMake option to `GLFW_BUILD_WAYLAND` (#1958) + - Removed `GLFW_USE_OSMESA` CMake option enabling the Null platform (#1958) - Removed CMake generated configuration header - Bugfix: The CMake config-file package used an absolute path and was not relocatable (#1470) @@ -442,6 +455,7 @@ skills. - Eddie Ringle - Max Risuhin - Jorge Rodriguez + - Jari Ronkainen - Luca Rood - Ed Ropple - Aleksey Rybalkin diff --git a/docs/compile.dox b/docs/compile.dox index cc32ea68..8f99472e 100644 --- a/docs/compile.dox +++ b/docs/compile.dox @@ -71,37 +71,42 @@ pkg install xorgproto On Cygwin the `xorgproto` package in the Devel section of the GUI installer will install the headers and other development related files for all of X11. -Once you have the required depdendencies, move on to @ref compile_generate. +Once you have the required dependencies, move on to @ref compile_generate. -@subsubsection compile_deps_wayland Dependencies for Wayland on Unix-like systems +@subsubsection compile_deps_wayland Dependencies for Wayland and X11 on Unix-like systems -To compile GLFW for Wayland, you need to have the Wayland and xkbcommon -development packages installed. They are not needed to build or run programs -that use GLFW. +To compile GLFW for both Wayland and X11, you need to have the X11, Wayland and xkbcommon +development packages installed. They are not needed to build or run programs that use +GLFW. You will also need to set the @ref GLFW_BUILD_WAYLAND CMake option in the next +step when generating build files. -On Debian and derivates like Ubuntu and Linux Mint you will need the -`libwayland-dev`, `libxkbcommon-dev` and `wayland-protocols` packages. +On Debian and derivates like Ubuntu and Linux Mint you will need the `libwayland-dev`, +`libxkbcommon-dev` and `wayland-protocols` packages and the `xorg-dev` meta-package. +These will pull in all other dependencies. @code{.sh} -sudo apt install libwayland-dev libxkbcommon-dev wayland-protocols +sudo apt install libwayland-dev libxkbcommon-dev wayland-protocols xorg-dev @endcode On Fedora and derivatives like Red Hat you will need the `wayland-devel`, -`libxkbcommon-devel` and `wayland-protocols-devel` packages. +`libxkbcommon-devel`, `wayland-protocols-devel`, `libXcursor-devel`, `libXi-devel`, +`libXinerama-devel` and `libXrandr-devel` packages. These will pull in all other +dependencies. @code{.sh} -sudo dnf install wayland-devel libxkbcommon-devel wayland-protocols-devel +sudo dnf install wayland-devel libxkbcommon-devel wayland-protocols-devel libXcursor-devel libXi-devel libXinerama-devel libXrandr-devel @endcode -On FreeBSD you will need the `wayland`, `libxkbcommon` and `wayland-protocols` -packages. +On FreeBSD you will need the `wayland`, `libxkbcommon` and `wayland-protocols` packages. +The X11 headers are installed along the end-user X11 packages, so if you have an X server +running you should have the headers as well. If not, install the `xorgproto` package. @code{.sh} -pkg install wayland libxkbcommon wayland-protocols +pkg install wayland libxkbcommon wayland-protocols xorgproto @endcode -Once you have the required depdendencies, move on to @ref compile_generate. +Once you have the required dependencies, move on to @ref compile_generate. @subsection compile_generate Generating build files with CMake @@ -135,9 +140,9 @@ If you wish change any CMake variables in the list, press _Configure_ and then _Generate_ to have the new values take effect. The variable list will be populated after the first configure step. -By default GLFW will use X11 on Linux and other Unix-like systems other -than macOS. To use Wayland instead, set the `GLFW_USE_WAYLAND` option in the -GLFW section of the variable list, then apply the new value as described above. +By default GLFW will use X11 on Linux and other Unix-like systems other than macOS. To +include support for Wayland as well, set the @ref GLFW_BUILD_WAYLAND option in the GLFW +section of the variable list, then apply the new value as described above. Once you have generated the project files or makefiles for your chosen development environment, move on to @ref compile_compile. @@ -170,10 +175,11 @@ cmake -S path/to/glfw -B path/to/build -G Xcode @endcode By default GLFW will use X11 on Linux and other Unix-like systems other -than macOS. To use Wayland instead, set the `GLFW_USE_WAYLAND` CMake option. +than macOS. To also include support for Wayland, set the @ref GLFW_BUILD_WAYLAND CMake +option. @code{.sh} -cmake -S path/to/glfw -B path/to/build -D GLFW_USE_WAYLAND=1 +cmake -S path/to/glfw -B path/to/build -D GLFW_BUILD_WAYLAND=1 @endcode Once you have generated the project files or makefiles for your chosen @@ -274,6 +280,11 @@ directly with the application. This is disabled by default. @subsection compile_options_win32 Windows specific CMake options +@anchor GLFW_BUILD_WIN32 +__GLFW_BUILD_WIN32__ determines whether to include support for Win32 when compiling the +library. This option is only available when compiling for Windows. This is enabled by +default. + @anchor USE_MSVC_RUNTIME_LIBRARY_DLL __USE_MSVC_RUNTIME_LIBRARY_DLL__ determines whether to use the DLL version or the static library version of the Visual C++ runtime library. When enabled, the @@ -292,12 +303,25 @@ will not work if GLFW is built as a DLL. This is disabled by default, letting the operating system and driver decide. -@subsection compile_options_wayland Wayland specific CMake options +@subsection compile_options_macos macOS specific CMake options -@anchor GLFW_USE_WAYLAND -__GLFW_USE_WAYLAND__ determines whether to compile the library for Wayland. -This option is only available on Linux and other Unix-like systems other than -macOS. This is disabled by default. +@anchor GLFW_BUILD_COCOA +__GLFW_BUILD_COCOA__ determines whether to include support for Cocoa when compiling the +library. This option is only available when compiling for macOS. This is enabled by +default. + + +@subsection compile_options_unix Unix-like system specific CMake options + +@anchor GLFW_BUILD_WAYLAND +__GLFW_BUILD_WAYLAND__ determines whether to include support for Wayland when compiling +the library. This option is only available when compiling for Linux and other Unix-like +systems other than macOS. This is disabled by default. + +@anchor GLFW_BUILD_X11 +__GLFW_BUILD_X11__ determines whether to include support for X11 when compiling the +library. This option is only available when compiling for Linux and other Unix-like +systems other than macOS. This is enabled by default. @section compile_mingw_cross Cross-compilation with CMake and MinGW @@ -335,25 +359,26 @@ For more details see the @section compile_manual Compiling GLFW manually -If you wish to compile GLFW without its CMake build environment then you will -have to do at least some of the platform detection yourself. GLFW needs -a configuration macro to be defined in order to know what window system it is -being compiled for and also has optional, platform-specific ones for various -features. +If you wish to compile GLFW without its CMake build environment then you will have to do +at least some of the platform detection yourself. There are preprocessor macros for +enabling support for the platforms (window systems) available. There are also optional, +platform-specific macros for various features. When building, GLFW will expect the necessary configuration macros to be defined on the command-line. The GLFW CMake files set these as private compile definitions on the GLFW target but if you compile the GLFW sources manually you will need to define them yourself. -The window creation API is used to create windows, handle input, monitors, gamma -ramps and clipboard. The options are: +The window system is used to create windows, handle input, monitors, gamma ramps and +clipboard. The options are: - @b _GLFW_COCOA to use the Cocoa frameworks - @b _GLFW_WIN32 to use the Win32 API - @b _GLFW_X11 to use the X Window System - - @b _GLFW_WAYLAND to use the Wayland API (experimental and incomplete) - - @b _GLFW_OSMESA to use the OSMesa API (headless and non-interactive) + - @b _GLFW_WAYLAND to use the Wayland API (incomplete) + +The @b _GLFW_WAYLAND and @b _GLFW_X11 macros may be combined and produces a library that +attempts to detect the appropriate platform at initialization. If you are building GLFW as a shared library / dynamic library / DLL then you must also define @b _GLFW_BUILD_DLL. Otherwise, you must not define it. diff --git a/docs/internal.dox b/docs/internal.dox index ec2de50f..69227568 100644 --- a/docs/internal.dox +++ b/docs/internal.dox @@ -61,12 +61,21 @@ application-provided callbacks. It is also prohibited from modifying the platform-independent part of the internal structs. Instead, it calls the event interface when events interesting to GLFW are received. -The platform interface mirrors those parts of the public interface that needs to -perform platform-specific operations on some or all platforms. The are also -named the same except that the glfw function prefix is replaced by -_glfwPlatform. +The platform interface mostly mirrors those parts of the public interface that needs to +perform platform-specific operations on some or all platforms. -Examples: `_glfwPlatformCreateWindow` +The window system bits of the platform API is called through the `_GLFWplatform` struct of +function pointers, to allow runtime selection of platform. This includes the window and +context creation, input and event processing, monitor and Vulkan surface creation parts of +GLFW. This is located in the global `_glfw` struct. + +Examples: `_glfw.platform.createWindow` + +The timer, threading and module loading bits of the platform API are plain functions with +a `_glfwPlatform` prefix, as these things are independent of what window system is being +used. + +Examples: `_glfwPlatformGetTimerValue` The platform interface also defines structs that contain platform-specific global and per-object state. Their names mirror those of the internal diff --git a/docs/intro.dox b/docs/intro.dox index 4134c84d..c50a3722 100644 --- a/docs/intro.dox +++ b/docs/intro.dox @@ -30,6 +30,7 @@ successfully initialized, and only from the main thread. - @ref glfwGetVersion - @ref glfwGetVersionString + - @ref glfwPlatformSupported - @ref glfwGetError - @ref glfwSetErrorCallback - @ref glfwInitHint @@ -89,6 +90,15 @@ Setting these hints requires no platform specific headers or functions. @subsubsection init_hints_shared Shared init hints +@anchor GLFW_PLATFORM +__GLFW_PLATFORM__ specifies the platform to use for windowing and input. +Possible values are `GLFW_ANY_PLATFORM`, `GLFW_PLATFORM_WIN32`, +`GLFW_PLATFORM_COCOA`, `GLFW_PLATFORM_X11`, `GLFW_PLATFORM_WAYLAND` and +`GLFW_PLATFORM_NULL`. The default value is `GLFW_ANY_PLATFORM`, which will +choose any platform the library includes support for except for the Null +backend. + + @anchor GLFW_JOYSTICK_HAT_BUTTONS __GLFW_JOYSTICK_HAT_BUTTONS__ specifies whether to also expose joystick hats as buttons, for compatibility with earlier versions of GLFW that did not have @ref @@ -137,6 +147,7 @@ the `VK_KHR_xlib_surface` extension. Possible values are `GLFW_TRUE` and Initialization hint | Default value | Supported values -------------------------------- | ------------------------------- | ---------------- +@ref GLFW_PLATFORM | `GLFW_ANY_PLATFORM` | `GLFW_ANY_PLATFORM`, `GLFW_PLATFORM_WIN32`, `GLFW_PLATFORM_COCOA`, `GLFW_PLATFORM_X11`, `GLFW_PLATFORM_WAYLAND` or `GLFW_PLATFORM_NULL` @ref GLFW_JOYSTICK_HAT_BUTTONS | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE` @ref GLFW_ANGLE_PLATFORM_TYPE | `GLFW_ANGLE_PLATFORM_TYPE_NONE` | `GLFW_ANGLE_PLATFORM_TYPE_NONE`, `GLFW_ANGLE_PLATFORM_TYPE_OPENGL`, `GLFW_ANGLE_PLATFORM_TYPE_OPENGLES`, `GLFW_ANGLE_PLATFORM_TYPE_D3D9`, `GLFW_ANGLE_PLATFORM_TYPE_D3D11`, `GLFW_ANGLE_PLATFORM_TYPE_VULKAN` or `GLFW_ANGLE_PLATFORM_TYPE_METAL` @ref GLFW_COCOA_CHDIR_RESOURCES | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE` @@ -144,6 +155,48 @@ Initialization hint | Default value | Supported v @ref GLFW_X11_XCB_VULKAN_SURFACE | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE` +@subsection platform Runtime platform selection + +GLFW can be compiled for more than one platform (window system) at once. This lets +a single library binary support both X11 and Wayland on Linux and other Unix-like systems. + +You can control platform selection via the @ref GLFW_PLATFORM initialization hint. By +default this is set to @ref GLFW_ANY_PLATFORM, which will look for supported window +systems in order of priority and select the first one it finds. It can also be set to any +specific platform to have GLFW only look for that one. + +@code +glfwInitHint(GLFW_PLATFORM, GLFW_PLATFORM_X11); +@endcode + +This mechanism also provides the Null platform, which is always supported but needs to be +explicitly requested. This platform is effectively a stub, emulating a window system on +a single 1080p monitor, but will not interact with any actual window system. + +@code +glfwInitHint(GLFW_PLATFORM, GLFW_PLATFORM_NULL); +@endcode + +You can test whether a library binary was compiled with support for a specific platform +with @ref glfwPlatformSupported. + +@code +if (glfwPlatformSupported(GLFW_PLATFORM_WAYLAND)) + glfwInitHint(GLFW_PLATFORM, GLFW_PLATFORM_WAYLAND); +@endcode + +Once GLFW has been initialized, you can query which platform was selected with @ref +glfwGetPlatform. + +@code +int platform = glfwGetPlatform(); +@endcode + +If you are using any [native access functions](@ref native), especially on Linux and other +Unix-like systems, then you may need to check that you are calling the ones matching the +selected platform. + + @subsection init_allocator Custom heap memory allocator The heap memory allocator can be customized before initialization with @ref @@ -437,6 +490,11 @@ Library version information may be queried from any thread. - @ref glfwGetVersion - @ref glfwGetVersionString +Platform information may be queried from any thread. + + - @ref glfwPlatformSupported + - @ref glfwGetPlatform + All Vulkan related functions may be called from any thread. - @ref glfwVulkanSupported @@ -529,17 +587,32 @@ __Do not use the version string__ to parse the GLFW library version. The @ref glfwGetVersion function already provides the version of the running library binary. +__Do not use the version string__ to parse what platforms are supported. The @ref +glfwPlatformSupported function lets you query platform support. + +__GLFW 3.4:__ The format of this string was changed to support the addition of +[runtime platform selection](@ref platform). + The format of the string is as follows: - The version of GLFW - - The name of the window system API - - The name of the context creation API - - Any additional options or APIs + - For each supported platform: + - The name of the window system API + - The name of the window system specific context creation API, if applicable + - The names of the always supported context creation APIs EGL and OSMesa + - Any additional compile-time options, APIs and (on Windows) what compiler was used -For example, when compiling GLFW 3.0 with MinGW using the Win32 and WGL -back ends, the version string may look something like this: +For example, GLFW 3.4 compiled as a DLL for Windows with MinGW may have a version string +like this: @code -3.0.0 Win32 WGL MinGW +3.4.0 Win32 WGL Null EGL OSMesa MinGW DLL +@endcode + +While GLFW compiled as as static library for Linux with both Wayland and X11 enabled may +have a version string like this: + +@code +3.4.0 Wayland X11 GLX Null EGL OSMesa monotonic @endcode */ diff --git a/docs/news.dox b/docs/news.dox index 6b1367d5..28affab0 100644 --- a/docs/news.dox +++ b/docs/news.dox @@ -9,6 +9,14 @@ @subsection features_34 New features in version 3.4 +@subsubsection runtime_platform_34 Runtime platform selection + +GLFW now supports being compiled for multiple backends and selecting between +them at runtime with the @ref GLFW_PLATFORM init hint. After initialization the +selected platform can be queried with @ref glfwGetPlatform. You can check if +support for a given platform is compiled in with @ref glfwPlatformSupported. + + @subsubsection standard_cursors_34 More standard cursors GLFW now provides the standard cursor shapes @ref GLFW_RESIZE_NWSE_CURSOR and @@ -63,7 +71,23 @@ Alt-and-then-Space shortcuts. This may be useful for more GUI-oriented applications. -@subsection caveats_34 Caveats for version 3.4 +@subsection caveats Caveats for version 3.4 + +@subsubsection native_34 Multiple sets of native access functions + +Because GLFW now supports runtime selection of platform (window system), a library binary +may export native access functions for multiple platforms. Starting with version 3.4 you +must not assume that GLFW is running on a platform just because it exports native access +functions for it. After initialization you can query the selected platform with @ref +glfwGetPlatform. + + +@subsubsection version_string_34 Version string format has been changed + +Because GLFW now supports runtime selection of platform (window system), the version +string returned by @ref glfwGetVersionString has been expanded. It now contains the names +of all APIs for all the platforms that the library binary supports. + @subsubsection joysticks_34 Joystick support is initialized on demand @@ -118,6 +142,18 @@ GLFW_TRANSPARENT_FRAMEBUFFER on Windows 7 if DWM transparency is off @subsection removals_34 Removals in 3.4 +@subsubsection osmesa_option_34 GLFW_USE_OSMESA CMake option has been removed + +This option was used to compile GLFW for the Null platform. The Null platform is now +always supported. To produce a library binary that only supports this platform, the way +this CMake option used to do, you will instead need to disable the default platform for +the target OS. This means setting the @ref GLFW_BUILD_WIN32, @ref GLFW_BUILD_COCOA or +@ref GLFW_BUILD_X11 CMake option to false. + +You can set all of them to false and the ones that don't apply for the target OS will be +ignored. + + @subsubsection wl_shell_34 Support for the wl_shell protocol has been removed Support for the wl_shell protocol has been removed and GLFW now only supports @@ -130,6 +166,8 @@ then GLFW will fail to initialize. @subsubsection functions_34 New functions in version 3.4 - @ref glfwInitAllocator + - @ref glfwGetPlatform + - @ref glfwPlatformSupported @subsubsection types_34 New types in version 3.4 @@ -142,6 +180,14 @@ then GLFW will fail to initialize. @subsubsection constants_34 New constants in version 3.4 + - @ref GLFW_PLATFORM + - @ref GLFW_ANY_PLATFORM + - @ref GLFW_PLATFORM_WIN32 + - @ref GLFW_PLATFORM_COCOA + - @ref GLFW_PLATFORM_WAYLAND + - @ref GLFW_PLATFORM_X11 + - @ref GLFW_PLATFORM_NULL + - @ref GLFW_PLATFORM_UNAVAILABLE - @ref GLFW_POINTING_HAND_CURSOR - @ref GLFW_RESIZE_EW_CURSOR - @ref GLFW_RESIZE_NS_CURSOR diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index 443af7cd..efd54e0c 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -717,7 +717,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 +786,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 +821,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 @@ -1125,7 +1147,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 +1264,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 +1286,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 @@ -1770,7 +1811,7 @@ typedef void (* GLFWscrollfun)(GLFWwindow* window, double xoffset, double yoffse * * @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 @@ -2047,10 +2088,15 @@ typedef struct GLFWallocator * 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 @@ -2205,15 +2251,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. @@ -2310,6 +2359,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 @@ -2393,7 +2487,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. * @@ -2424,7 +2518,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. @@ -3438,7 +3532,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. * @@ -5677,7 +5771,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. @@ -5888,7 +5982,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. * diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0dda7386..0ab57255 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -2,8 +2,23 @@ add_library(glfw ${GLFW_LIBRARY_TYPE} "${GLFW_SOURCE_DIR}/include/GLFW/glfw3.h" "${GLFW_SOURCE_DIR}/include/GLFW/glfw3native.h" - internal.h mappings.h context.c init.c input.c monitor.c - vulkan.c window.c) + internal.h platform.h mappings.h + context.c init.c input.c monitor.c platform.c vulkan.c window.c + egl_context.c osmesa_context.c null_platform.h null_joystick.h + null_init.c null_monitor.c null_window.c null_joystick.c) + +# The time, thread and module code is shared between all backends on a given OS, +# including the null backend, which still needs those bits to be functional +if (APPLE) + target_sources(glfw PRIVATE cocoa_time.h cocoa_time.c posix_thread.h + posix_module.c posix_thread.c) +elseif (WIN32) + target_sources(glfw PRIVATE win32_time.h win32_thread.h win32_module.c + win32_time.c win32_thread.c) +else() + target_sources(glfw PRIVATE posix_time.h posix_thread.h posix_module.c + posix_time.c posix_thread.c) +endif() add_custom_target(update_mappings COMMAND "${CMAKE_COMMAND}" -P "${GLFW_SOURCE_DIR}/CMake/GenerateMappings.cmake" mappings.h.in mappings.h @@ -14,56 +29,40 @@ add_custom_target(update_mappings set_target_properties(update_mappings PROPERTIES FOLDER "GLFW3") -if (_GLFW_COCOA) +if (GLFW_BUILD_COCOA) target_compile_definitions(glfw PRIVATE _GLFW_COCOA) - target_sources(glfw PRIVATE cocoa_platform.h cocoa_joystick.h cocoa_time.h - posix_thread.h cocoa_init.m cocoa_joystick.m - cocoa_monitor.m cocoa_window.m cocoa_time.c - posix_thread.c nsgl_context.m egl_context.c - osmesa_context.c) -elseif (_GLFW_WIN32) + target_sources(glfw PRIVATE cocoa_platform.h cocoa_joystick.h cocoa_init.m + cocoa_joystick.m cocoa_monitor.m cocoa_window.m + nsgl_context.m) +endif() + +if (GLFW_BUILD_WIN32) target_compile_definitions(glfw PRIVATE _GLFW_WIN32) - target_sources(glfw PRIVATE win32_platform.h win32_joystick.h win32_time.h - win32_thread.h win32_init.c win32_joystick.c - win32_monitor.c win32_time.c win32_thread.c - win32_window.c wgl_context.c egl_context.c - osmesa_context.c) -elseif (_GLFW_X11) + target_sources(glfw PRIVATE win32_platform.h win32_joystick.h win32_init.c + win32_joystick.c win32_monitor.c win32_window.c + wgl_context.c) +endif() + +if (GLFW_BUILD_X11) target_compile_definitions(glfw PRIVATE _GLFW_X11) - target_sources(glfw PRIVATE x11_platform.h xkb_unicode.h posix_time.h - posix_thread.h x11_init.c x11_monitor.c - x11_window.c xkb_unicode.c posix_time.c - posix_thread.c glx_context.c egl_context.c - osmesa_context.c) -elseif (_GLFW_WAYLAND) + target_sources(glfw PRIVATE x11_platform.h xkb_unicode.h x11_init.c + x11_monitor.c x11_window.c xkb_unicode.c + glx_context.c) +endif() + +if (GLFW_BUILD_WAYLAND) target_compile_definitions(glfw PRIVATE _GLFW_WAYLAND) - target_sources(glfw PRIVATE wl_platform.h posix_time.h posix_thread.h - xkb_unicode.h wl_init.c wl_monitor.c wl_window.c - posix_time.c posix_thread.c xkb_unicode.c - egl_context.c osmesa_context.c) -elseif (_GLFW_OSMESA) - target_compile_definitions(glfw PRIVATE _GLFW_OSMESA) - target_sources(glfw PRIVATE null_platform.h null_joystick.h posix_time.h - posix_thread.h null_init.c null_monitor.c - null_window.c null_joystick.c posix_time.c - posix_thread.c egl_context.c osmesa_context.c) + target_sources(glfw PRIVATE wl_platform.h xkb_unicode.h wl_init.c + wl_monitor.c wl_window.c xkb_unicode.c) endif() -if (WIN32) - target_sources(glfw PRIVATE win32_module.c) -else() - target_sources(glfw PRIVATE posix_module.c) -endif() - -if (_GLFW_X11 OR _GLFW_WAYLAND) +if (GLFW_BUILD_X11 OR GLFW_BUILD_WAYLAND) if (CMAKE_SYSTEM_NAME STREQUAL "Linux") target_sources(glfw PRIVATE linux_joystick.h linux_joystick.c) - else() - target_sources(glfw PRIVATE null_joystick.h null_joystick.c) endif() endif() -if (_GLFW_WAYLAND) +if (GLFW_BUILD_WAYLAND) include(CheckIncludeFiles) include(CheckFunctionExists) check_include_files(xkbcommon/xkbcommon-compose.h HAVE_XKBCOMMON_COMPOSE_H) @@ -161,11 +160,11 @@ if (GLFW_VULKAN_STATIC) list(APPEND glfw_PKG_DEPS "vulkan") endif() -if (_GLFW_WIN32) +if (GLFW_BUILD_WIN32) list(APPEND glfw_PKG_LIBS "-lgdi32") endif() -if (_GLFW_COCOA) +if (GLFW_BUILD_COCOA) target_link_libraries(glfw PRIVATE "-framework Cocoa" "-framework IOKit" "-framework CoreFoundation") @@ -174,7 +173,7 @@ if (_GLFW_COCOA) set(glfw_PKG_LIBS "-framework Cocoa -framework IOKit -framework CoreFoundation") endif() -if (_GLFW_WAYLAND) +if (GLFW_BUILD_WAYLAND) pkg_check_modules(Wayland REQUIRED wayland-client>=0.2.7 wayland-cursor>=0.2.7 @@ -192,7 +191,7 @@ if (_GLFW_WAYLAND) endif() endif() -if (_GLFW_X11) +if (GLFW_BUILD_X11) find_package(X11 REQUIRED) target_include_directories(glfw PRIVATE "${X11_X11_INCLUDE_PATH}") @@ -251,11 +250,11 @@ endif() # Make GCC warn about declarations that VS 2010 and 2012 won't accept for all # source files that VS will build (Clang ignores this because we set -std=c99) if (CMAKE_C_COMPILER_ID STREQUAL "GNU") - set_source_files_properties(context.c init.c input.c monitor.c vulkan.c - window.c win32_init.c win32_joystick.c - win32_module.c win32_monitor.c win32_time.c win32_thread.c - win32_window.c wgl_context.c egl_context.c - osmesa_context.c PROPERTIES + set_source_files_properties(context.c init.c input.c monitor.c platform.c vulkan.c + window.c null_init.c null_joystick.c null_monitor.c + null_window.c win32_init.c win32_joystick.c win32_module.c + win32_monitor.c win32_time.c win32_thread.c win32_window.c + wgl_context.c egl_context.c osmesa_context.c PROPERTIES COMPILE_FLAGS -Wdeclaration-after-statement) endif() @@ -276,7 +275,7 @@ elseif (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR target_compile_options(glfw PRIVATE "-Wall") endif() -if (_GLFW_WIN32) +if (GLFW_BUILD_WIN32) target_compile_definitions(glfw PRIVATE UNICODE _UNICODE) endif() @@ -318,7 +317,7 @@ if (MSVC90) endif() # Workaround for -std=c99 on Linux disabling _DEFAULT_SOURCE (POSIX 2008 and more) -if (_GLFW_X11 OR _GLFW_WAYLAND OR _GLFW_OSMESA) +if (GLFW_BUILD_X11 OR GLFW_BUILD_WAYLAND) if (CMAKE_SYSTEM_NAME STREQUAL "Linux") target_compile_definitions(glfw PRIVATE _DEFAULT_SOURCE) endif() diff --git a/src/cocoa_init.m b/src/cocoa_init.m index 9646ca48..e97d9596 100644 --- a/src/cocoa_init.m +++ b/src/cocoa_init.m @@ -444,7 +444,7 @@ static GLFWbool initializeTIS(void) - (void)applicationDidFinishLaunching:(NSNotification *)notification { - _glfwPlatformPostEmptyEvent(); + _glfwPostEmptyEventCocoa(); [NSApp stop:nil]; } @@ -489,7 +489,89 @@ void* _glfwLoadLocalVulkanLoaderCocoa(void) ////// GLFW platform API ////// ////////////////////////////////////////////////////////////////////////// -int _glfwPlatformInit(void) +GLFWbool _glfwConnectCocoa(int platformID, _GLFWplatform* platform) +{ + const _GLFWplatform cocoa = + { + GLFW_PLATFORM_COCOA, + _glfwInitCocoa, + _glfwTerminateCocoa, + _glfwGetCursorPosCocoa, + _glfwSetCursorPosCocoa, + _glfwSetCursorModeCocoa, + _glfwSetRawMouseMotionCocoa, + _glfwRawMouseMotionSupportedCocoa, + _glfwCreateCursorCocoa, + _glfwCreateStandardCursorCocoa, + _glfwDestroyCursorCocoa, + _glfwSetCursorCocoa, + _glfwGetScancodeNameCocoa, + _glfwGetKeyScancodeCocoa, + _glfwSetClipboardStringCocoa, + _glfwGetClipboardStringCocoa, + _glfwInitJoysticksCocoa, + _glfwTerminateJoysticksCocoa, + _glfwPollJoystickCocoa, + _glfwGetMappingNameCocoa, + _glfwUpdateGamepadGUIDCocoa, + _glfwFreeMonitorCocoa, + _glfwGetMonitorPosCocoa, + _glfwGetMonitorContentScaleCocoa, + _glfwGetMonitorWorkareaCocoa, + _glfwGetVideoModesCocoa, + _glfwGetVideoModeCocoa, + _glfwGetGammaRampCocoa, + _glfwSetGammaRampCocoa, + _glfwCreateWindowCocoa, + _glfwDestroyWindowCocoa, + _glfwSetWindowTitleCocoa, + _glfwSetWindowIconCocoa, + _glfwGetWindowPosCocoa, + _glfwSetWindowPosCocoa, + _glfwGetWindowSizeCocoa, + _glfwSetWindowSizeCocoa, + _glfwSetWindowSizeLimitsCocoa, + _glfwSetWindowAspectRatioCocoa, + _glfwGetFramebufferSizeCocoa, + _glfwGetWindowFrameSizeCocoa, + _glfwGetWindowContentScaleCocoa, + _glfwIconifyWindowCocoa, + _glfwRestoreWindowCocoa, + _glfwMaximizeWindowCocoa, + _glfwShowWindowCocoa, + _glfwHideWindowCocoa, + _glfwRequestWindowAttentionCocoa, + _glfwFocusWindowCocoa, + _glfwSetWindowMonitorCocoa, + _glfwWindowFocusedCocoa, + _glfwWindowIconifiedCocoa, + _glfwWindowVisibleCocoa, + _glfwWindowMaximizedCocoa, + _glfwWindowHoveredCocoa, + _glfwFramebufferTransparentCocoa, + _glfwGetWindowOpacityCocoa, + _glfwSetWindowResizableCocoa, + _glfwSetWindowDecoratedCocoa, + _glfwSetWindowFloatingCocoa, + _glfwSetWindowOpacityCocoa, + _glfwSetWindowMousePassthroughCocoa, + _glfwPollEventsCocoa, + _glfwWaitEventsCocoa, + _glfwWaitEventsTimeoutCocoa, + _glfwPostEmptyEventCocoa, + _glfwGetEGLPlatformCocoa, + _glfwGetEGLNativeDisplayCocoa, + _glfwGetEGLNativeWindowCocoa, + _glfwGetRequiredInstanceExtensionsCocoa, + _glfwGetPhysicalDevicePresentationSupportCocoa, + _glfwCreateWindowSurfaceCocoa, + }; + + *platform = cocoa; + return GLFW_TRUE; +} + +int _glfwInitCocoa(void) { @autoreleasepool { @@ -561,7 +643,7 @@ int _glfwPlatformInit(void) } // autoreleasepool } -void _glfwPlatformTerminate(void) +void _glfwTerminateCocoa(void) { @autoreleasepool { @@ -607,12 +689,3 @@ void _glfwPlatformTerminate(void) } // autoreleasepool } -const char* _glfwPlatformGetVersionString(void) -{ - return _GLFW_VERSION_NUMBER " Cocoa NSGL EGL OSMesa" -#if defined(_GLFW_BUILD_DLL) - " dynamic" -#endif - ; -} - diff --git a/src/cocoa_joystick.h b/src/cocoa_joystick.h index cfcb7ca3..756911a2 100644 --- a/src/cocoa_joystick.h +++ b/src/cocoa_joystick.h @@ -26,11 +26,10 @@ #include #include -#include #include -#define _GLFW_PLATFORM_JOYSTICK_STATE _GLFWjoystickNS ns -#define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE struct { int dummyJoystick; } +#define GLFW_COCOA_JOYSTICK_STATE _GLFWjoystickNS ns; +#define GLFW_COCOA_LIBRARY_JOYSTICK_STATE #define GLFW_BUILD_COCOA_MAPPINGS @@ -44,3 +43,9 @@ typedef struct _GLFWjoystickNS CFMutableArrayRef hats; } _GLFWjoystickNS; +GLFWbool _glfwInitJoysticksCocoa(void); +void _glfwTerminateJoysticksCocoa(void); +int _glfwPollJoystickCocoa(_GLFWjoystick* js, int mode); +const char* _glfwGetMappingNameCocoa(void); +void _glfwUpdateGamepadGUIDCocoa(char* guid); + diff --git a/src/cocoa_joystick.m b/src/cocoa_joystick.m index 5e2666b2..74f20d02 100644 --- a/src/cocoa_joystick.m +++ b/src/cocoa_joystick.m @@ -307,7 +307,7 @@ static void removeCallback(void* context, ////// GLFW platform API ////// ////////////////////////////////////////////////////////////////////////// -GLFWbool _glfwPlatformInitJoysticks(void) +GLFWbool _glfwInitJoysticksCocoa(void) { CFMutableArrayRef matching; const long usages[] = @@ -384,7 +384,7 @@ GLFWbool _glfwPlatformInitJoysticks(void) return GLFW_TRUE; } -void _glfwPlatformTerminateJoysticks(void) +void _glfwTerminateJoysticksCocoa(void) { int jid; @@ -399,7 +399,7 @@ void _glfwPlatformTerminateJoysticks(void) } -int _glfwPlatformPollJoystick(_GLFWjoystick* js, int mode) +int _glfwPollJoystickCocoa(_GLFWjoystick* js, int mode) { if (mode & _GLFW_POLL_AXES) { @@ -469,12 +469,12 @@ int _glfwPlatformPollJoystick(_GLFWjoystick* js, int mode) return js->present; } -const char* _glfwPlatformGetMappingName(void) +const char* _glfwGetMappingNameCocoa(void) { return "Mac OS X"; } -void _glfwPlatformUpdateGamepadGUID(char* guid) +void _glfwUpdateGamepadGUIDCocoa(char* guid) { if ((strncmp(guid + 4, "000000000000", 12) == 0) && (strncmp(guid + 20, "000000000000", 12) == 0)) diff --git a/src/cocoa_monitor.m b/src/cocoa_monitor.m index 5416f5bf..2109a7fe 100644 --- a/src/cocoa_monitor.m +++ b/src/cocoa_monitor.m @@ -388,7 +388,7 @@ void _glfwPollMonitorsCocoa(void) void _glfwSetVideoModeCocoa(_GLFWmonitor* monitor, const GLFWvidmode* desired) { GLFWvidmode current; - _glfwPlatformGetVideoMode(monitor, ¤t); + _glfwGetVideoModeCocoa(monitor, ¤t); const GLFWvidmode* best = _glfwChooseVideoMode(monitor, desired); if (_glfwCompareVideoModes(¤t, best) == 0) @@ -447,11 +447,11 @@ void _glfwRestoreVideoModeCocoa(_GLFWmonitor* monitor) ////// GLFW platform API ////// ////////////////////////////////////////////////////////////////////////// -void _glfwPlatformFreeMonitor(_GLFWmonitor* monitor) +void _glfwFreeMonitorCocoa(_GLFWmonitor* monitor) { } -void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos) +void _glfwGetMonitorPosCocoa(_GLFWmonitor* monitor, int* xpos, int* ypos) { @autoreleasepool { @@ -465,8 +465,8 @@ void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos) } // autoreleasepool } -void _glfwPlatformGetMonitorContentScale(_GLFWmonitor* monitor, - float* xscale, float* yscale) +void _glfwGetMonitorContentScaleCocoa(_GLFWmonitor* monitor, + float* xscale, float* yscale) { @autoreleasepool { @@ -487,9 +487,9 @@ void _glfwPlatformGetMonitorContentScale(_GLFWmonitor* monitor, } // autoreleasepool } -void _glfwPlatformGetMonitorWorkarea(_GLFWmonitor* monitor, - int* xpos, int* ypos, - int* width, int* height) +void _glfwGetMonitorWorkareaCocoa(_GLFWmonitor* monitor, + int* xpos, int* ypos, + int* width, int* height) { @autoreleasepool { @@ -513,7 +513,7 @@ void _glfwPlatformGetMonitorWorkarea(_GLFWmonitor* monitor, } // autoreleasepool } -GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* count) +GLFWvidmode* _glfwGetVideoModesCocoa(_GLFWmonitor* monitor, int* count) { @autoreleasepool { @@ -553,7 +553,7 @@ GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* count) } // autoreleasepool } -void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode *mode) +void _glfwGetVideoModeCocoa(_GLFWmonitor* monitor, GLFWvidmode *mode) { @autoreleasepool { @@ -564,7 +564,7 @@ void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode *mode) } // autoreleasepool } -GLFWbool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp) +GLFWbool _glfwGetGammaRampCocoa(_GLFWmonitor* monitor, GLFWgammaramp* ramp) { @autoreleasepool { @@ -593,7 +593,7 @@ GLFWbool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp) } // autoreleasepool } -void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp) +void _glfwSetGammaRampCocoa(_GLFWmonitor* monitor, const GLFWgammaramp* ramp) { @autoreleasepool { diff --git a/src/cocoa_platform.h b/src/cocoa_platform.h index 76ddcb28..67c1a3cc 100644 --- a/src/cocoa_platform.h +++ b/src/cocoa_platform.h @@ -27,6 +27,7 @@ #include #include +#include // NOTE: All of NSGL was deprecated in the 10.14 SDK // This disables the pointless warnings for every symbol we use @@ -91,17 +92,13 @@ typedef struct VkMetalSurfaceCreateInfoEXT typedef VkResult (APIENTRY *PFN_vkCreateMacOSSurfaceMVK)(VkInstance,const VkMacOSSurfaceCreateInfoMVK*,const VkAllocationCallbacks*,VkSurfaceKHR*); typedef VkResult (APIENTRY *PFN_vkCreateMetalSurfaceEXT)(VkInstance,const VkMetalSurfaceCreateInfoEXT*,const VkAllocationCallbacks*,VkSurfaceKHR*); -#include "cocoa_time.h" -#include "posix_thread.h" -#include "cocoa_joystick.h" +#define GLFW_COCOA_WINDOW_STATE _GLFWwindowNS ns; +#define GLFW_COCOA_LIBRARY_WINDOW_STATE _GLFWlibraryNS ns; +#define GLFW_COCOA_MONITOR_STATE _GLFWmonitorNS ns; +#define GLFW_COCOA_CURSOR_STATE _GLFWcursorNS ns; -#define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowNS ns -#define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryNS ns -#define _GLFW_PLATFORM_MONITOR_STATE _GLFWmonitorNS ns -#define _GLFW_PLATFORM_CURSOR_STATE _GLFWcursorNS ns - -#define _GLFW_PLATFORM_CONTEXT_STATE _GLFWcontextNSGL nsgl -#define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE _GLFWlibraryNSGL nsgl +#define GLFW_NSGL_CONTEXT_STATE _GLFWcontextNSGL nsgl; +#define GLFW_NSGL_LIBRARY_CONTEXT_STATE _GLFWlibraryNSGL nsgl; // HIToolbox.framework pointer typedefs #define kTISPropertyUnicodeKeyLayoutData _glfw.ns.tis.kPropertyUnicodeKeyLayoutData @@ -205,6 +202,81 @@ typedef struct _GLFWcursorNS } _GLFWcursorNS; +GLFWbool _glfwConnectCocoa(int platformID, _GLFWplatform* platform); +int _glfwInitCocoa(void); +void _glfwTerminateCocoa(void); + +int _glfwCreateWindowCocoa(_GLFWwindow* window, const _GLFWwndconfig* wndconfig, const _GLFWctxconfig* ctxconfig, const _GLFWfbconfig* fbconfig); +void _glfwDestroyWindowCocoa(_GLFWwindow* window); +void _glfwSetWindowTitleCocoa(_GLFWwindow* window, const char* title); +void _glfwSetWindowIconCocoa(_GLFWwindow* window, int count, const GLFWimage* images); +void _glfwGetWindowPosCocoa(_GLFWwindow* window, int* xpos, int* ypos); +void _glfwSetWindowPosCocoa(_GLFWwindow* window, int xpos, int ypos); +void _glfwGetWindowSizeCocoa(_GLFWwindow* window, int* width, int* height); +void _glfwSetWindowSizeCocoa(_GLFWwindow* window, int width, int height); +void _glfwSetWindowSizeLimitsCocoa(_GLFWwindow* window, int minwidth, int minheight, int maxwidth, int maxheight); +void _glfwSetWindowAspectRatioCocoa(_GLFWwindow* window, int numer, int denom); +void _glfwGetFramebufferSizeCocoa(_GLFWwindow* window, int* width, int* height); +void _glfwGetWindowFrameSizeCocoa(_GLFWwindow* window, int* left, int* top, int* right, int* bottom); +void _glfwGetWindowContentScaleCocoa(_GLFWwindow* window, float* xscale, float* yscale); +void _glfwIconifyWindowCocoa(_GLFWwindow* window); +void _glfwRestoreWindowCocoa(_GLFWwindow* window); +void _glfwMaximizeWindowCocoa(_GLFWwindow* window); +void _glfwShowWindowCocoa(_GLFWwindow* window); +void _glfwHideWindowCocoa(_GLFWwindow* window); +void _glfwRequestWindowAttentionCocoa(_GLFWwindow* window); +void _glfwFocusWindowCocoa(_GLFWwindow* window); +void _glfwSetWindowMonitorCocoa(_GLFWwindow* window, _GLFWmonitor* monitor, int xpos, int ypos, int width, int height, int refreshRate); +int _glfwWindowFocusedCocoa(_GLFWwindow* window); +int _glfwWindowIconifiedCocoa(_GLFWwindow* window); +int _glfwWindowVisibleCocoa(_GLFWwindow* window); +int _glfwWindowMaximizedCocoa(_GLFWwindow* window); +int _glfwWindowHoveredCocoa(_GLFWwindow* window); +int _glfwFramebufferTransparentCocoa(_GLFWwindow* window); +void _glfwSetWindowResizableCocoa(_GLFWwindow* window, GLFWbool enabled); +void _glfwSetWindowDecoratedCocoa(_GLFWwindow* window, GLFWbool enabled); +void _glfwSetWindowFloatingCocoa(_GLFWwindow* window, GLFWbool enabled); +float _glfwGetWindowOpacityCocoa(_GLFWwindow* window); +void _glfwSetWindowOpacityCocoa(_GLFWwindow* window, float opacity); +void _glfwSetWindowMousePassthroughCocoa(_GLFWwindow* window, GLFWbool enabled); + +void _glfwSetRawMouseMotionCocoa(_GLFWwindow *window, GLFWbool enabled); +GLFWbool _glfwRawMouseMotionSupportedCocoa(void); + +void _glfwPollEventsCocoa(void); +void _glfwWaitEventsCocoa(void); +void _glfwWaitEventsTimeoutCocoa(double timeout); +void _glfwPostEmptyEventCocoa(void); + +void _glfwGetCursorPosCocoa(_GLFWwindow* window, double* xpos, double* ypos); +void _glfwSetCursorPosCocoa(_GLFWwindow* window, double xpos, double ypos); +void _glfwSetCursorModeCocoa(_GLFWwindow* window, int mode); +const char* _glfwGetScancodeNameCocoa(int scancode); +int _glfwGetKeyScancodeCocoa(int key); +int _glfwCreateCursorCocoa(_GLFWcursor* cursor, const GLFWimage* image, int xhot, int yhot); +int _glfwCreateStandardCursorCocoa(_GLFWcursor* cursor, int shape); +void _glfwDestroyCursorCocoa(_GLFWcursor* cursor); +void _glfwSetCursorCocoa(_GLFWwindow* window, _GLFWcursor* cursor); +void _glfwSetClipboardStringCocoa(const char* string); +const char* _glfwGetClipboardStringCocoa(void); + +EGLenum _glfwGetEGLPlatformCocoa(EGLint** attribs); +EGLNativeDisplayType _glfwGetEGLNativeDisplayCocoa(void); +EGLNativeWindowType _glfwGetEGLNativeWindowCocoa(_GLFWwindow* window); + +void _glfwGetRequiredInstanceExtensionsCocoa(char** extensions); +int _glfwGetPhysicalDevicePresentationSupportCocoa(VkInstance instance, VkPhysicalDevice device, uint32_t queuefamily); +VkResult _glfwCreateWindowSurfaceCocoa(VkInstance instance, _GLFWwindow* window, const VkAllocationCallbacks* allocator, VkSurfaceKHR* surface); + +void _glfwFreeMonitorCocoa(_GLFWmonitor* monitor); +void _glfwGetMonitorPosCocoa(_GLFWmonitor* monitor, int* xpos, int* ypos); +void _glfwGetMonitorContentScaleCocoa(_GLFWmonitor* monitor, float* xscale, float* yscale); +void _glfwGetMonitorWorkareaCocoa(_GLFWmonitor* monitor, int* xpos, int* ypos, int* width, int* height); +GLFWvidmode* _glfwGetVideoModesCocoa(_GLFWmonitor* monitor, int* count); +void _glfwGetVideoModeCocoa(_GLFWmonitor* monitor, GLFWvidmode* mode); +GLFWbool _glfwGetGammaRampCocoa(_GLFWmonitor* monitor, GLFWgammaramp* ramp); +void _glfwSetGammaRampCocoa(_GLFWmonitor* monitor, const GLFWgammaramp* ramp); + void _glfwPollMonitorsCocoa(void); void _glfwSetVideoModeCocoa(_GLFWmonitor* monitor, const GLFWvidmode* desired); void _glfwRestoreVideoModeCocoa(_GLFWmonitor* monitor); diff --git a/src/cocoa_time.h b/src/cocoa_time.h index 6f41ef19..3512e8b6 100644 --- a/src/cocoa_time.h +++ b/src/cocoa_time.h @@ -24,7 +24,7 @@ // //======================================================================== -#define _GLFW_PLATFORM_LIBRARY_TIMER_STATE _GLFWtimerNS ns +#define GLFW_COCOA_LIBRARY_TIMER_STATE _GLFWtimerNS ns; // Cocoa-specific global timer data // diff --git a/src/cocoa_window.m b/src/cocoa_window.m index ab169d96..660bbd31 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -105,20 +105,20 @@ static void updateCursorMode(_GLFWwindow* window) if (window->cursorMode == GLFW_CURSOR_DISABLED) { _glfw.ns.disabledCursorWindow = window; - _glfwPlatformGetCursorPos(window, - &_glfw.ns.restoreCursorPosX, - &_glfw.ns.restoreCursorPosY); + _glfwGetCursorPosCocoa(window, + &_glfw.ns.restoreCursorPosX, + &_glfw.ns.restoreCursorPosY); _glfwCenterCursorInContentArea(window); CGAssociateMouseAndMouseCursorPosition(false); } else if (_glfw.ns.disabledCursorWindow == window) { _glfw.ns.disabledCursorWindow = NULL; - _glfwPlatformSetCursorPos(window, - _glfw.ns.restoreCursorPosX, - _glfw.ns.restoreCursorPosY); + _glfwSetCursorPosCocoa(window, + _glfw.ns.restoreCursorPosX, + _glfw.ns.restoreCursorPosY); // NOTE: The matching CGAssociateMouseAndMouseCursorPosition call is - // made in _glfwPlatformSetCursorPos as part of a workaround + // made in _glfwSetCursorPosCocoa as part of a workaround } if (cursorInContentArea(window)) @@ -286,7 +286,7 @@ static const NSRange kEmptyRange = { NSNotFound, 0 }; _glfwCenterCursorInContentArea(window); int x, y; - _glfwPlatformGetWindowPos(window, &x, &y); + _glfwGetWindowPosCocoa(window, &x, &y); _glfwInputWindowPos(window, x, y); } @@ -318,7 +318,7 @@ static const NSRange kEmptyRange = { NSNotFound, 0 }; - (void)windowDidResignKey:(NSNotification *)notification { if (window->monitor && window->autoIconify) - _glfwPlatformIconifyWindow(window); + _glfwIconifyWindowCocoa(window); _glfwInputWindowFocus(window, GLFW_FALSE); } @@ -803,8 +803,8 @@ static GLFWbool createNativeWindow(_GLFWwindow* window, GLFWvidmode mode; int xpos, ypos; - _glfwPlatformGetVideoMode(window->monitor, &mode); - _glfwPlatformGetMonitorPos(window->monitor, &xpos, &ypos); + _glfwGetVideoModeCocoa(window->monitor, &mode); + _glfwGetMonitorPosCocoa(window->monitor, &xpos, &ypos); contentRect = NSMakeRect(xpos, ypos, mode.width, mode.height); } @@ -872,8 +872,8 @@ static GLFWbool createNativeWindow(_GLFWwindow* window, [window->ns.object setTabbingMode:NSWindowTabbingModeDisallowed]; #endif - _glfwPlatformGetWindowSize(window, &window->ns.width, &window->ns.height); - _glfwPlatformGetFramebufferSize(window, &window->ns.fbWidth, &window->ns.fbHeight); + _glfwGetWindowSizeCocoa(window, &window->ns.width, &window->ns.height); + _glfwGetFramebufferSizeCocoa(window, &window->ns.fbWidth, &window->ns.fbHeight); return GLFW_TRUE; } @@ -895,10 +895,10 @@ float _glfwTransformYCocoa(float y) ////// GLFW platform API ////// ////////////////////////////////////////////////////////////////////////// -int _glfwPlatformCreateWindow(_GLFWwindow* window, - const _GLFWwndconfig* wndconfig, - const _GLFWctxconfig* ctxconfig, - const _GLFWfbconfig* fbconfig) +int _glfwCreateWindowCocoa(_GLFWwindow* window, + const _GLFWwndconfig* wndconfig, + const _GLFWctxconfig* ctxconfig, + const _GLFWfbconfig* fbconfig) { @autoreleasepool { @@ -937,8 +937,8 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window, if (window->monitor) { - _glfwPlatformShowWindow(window); - _glfwPlatformFocusWindow(window); + _glfwShowWindowCocoa(window); + _glfwFocusWindowCocoa(window); acquireMonitor(window); } @@ -947,7 +947,7 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window, } // autoreleasepool } -void _glfwPlatformDestroyWindow(_GLFWwindow* window) +void _glfwDestroyWindowCocoa(_GLFWwindow* window) { @autoreleasepool { @@ -973,12 +973,12 @@ void _glfwPlatformDestroyWindow(_GLFWwindow* window) window->ns.object = nil; // HACK: Allow Cocoa to catch up before returning - _glfwPlatformPollEvents(); + _glfwPollEventsCocoa(); } // autoreleasepool } -void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title) +void _glfwSetWindowTitleCocoa(_GLFWwindow* window, const char* title) { @autoreleasepool { NSString* string = @(title); @@ -989,14 +989,14 @@ void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title) } // autoreleasepool } -void _glfwPlatformSetWindowIcon(_GLFWwindow* window, - int count, const GLFWimage* images) +void _glfwSetWindowIconCocoa(_GLFWwindow* window, + int count, const GLFWimage* images) { _glfwInputError(GLFW_FEATURE_UNAVAILABLE, "Cocoa: Regular windows do not have icons on macOS"); } -void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos) +void _glfwGetWindowPosCocoa(_GLFWwindow* window, int* xpos, int* ypos) { @autoreleasepool { @@ -1011,7 +1011,7 @@ void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos) } // autoreleasepool } -void _glfwPlatformSetWindowPos(_GLFWwindow* window, int x, int y) +void _glfwSetWindowPosCocoa(_GLFWwindow* window, int x, int y) { @autoreleasepool { @@ -1023,7 +1023,7 @@ void _glfwPlatformSetWindowPos(_GLFWwindow* window, int x, int y) } // autoreleasepool } -void _glfwPlatformGetWindowSize(_GLFWwindow* window, int* width, int* height) +void _glfwGetWindowSizeCocoa(_GLFWwindow* window, int* width, int* height) { @autoreleasepool { @@ -1037,7 +1037,7 @@ void _glfwPlatformGetWindowSize(_GLFWwindow* window, int* width, int* height) } // autoreleasepool } -void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height) +void _glfwSetWindowSizeCocoa(_GLFWwindow* window, int width, int height) { @autoreleasepool { @@ -1059,9 +1059,9 @@ void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height) } // autoreleasepool } -void _glfwPlatformSetWindowSizeLimits(_GLFWwindow* window, - int minwidth, int minheight, - int maxwidth, int maxheight) +void _glfwSetWindowSizeLimitsCocoa(_GLFWwindow* window, + int minwidth, int minheight, + int maxwidth, int maxheight) { @autoreleasepool { @@ -1078,7 +1078,7 @@ void _glfwPlatformSetWindowSizeLimits(_GLFWwindow* window, } // autoreleasepool } -void _glfwPlatformSetWindowAspectRatio(_GLFWwindow* window, int numer, int denom) +void _glfwSetWindowAspectRatioCocoa(_GLFWwindow* window, int numer, int denom) { @autoreleasepool { if (numer == GLFW_DONT_CARE || denom == GLFW_DONT_CARE) @@ -1088,7 +1088,7 @@ void _glfwPlatformSetWindowAspectRatio(_GLFWwindow* window, int numer, int denom } // autoreleasepool } -void _glfwPlatformGetFramebufferSize(_GLFWwindow* window, int* width, int* height) +void _glfwGetFramebufferSizeCocoa(_GLFWwindow* window, int* width, int* height) { @autoreleasepool { @@ -1103,9 +1103,9 @@ void _glfwPlatformGetFramebufferSize(_GLFWwindow* window, int* width, int* heigh } // autoreleasepool } -void _glfwPlatformGetWindowFrameSize(_GLFWwindow* window, - int* left, int* top, - int* right, int* bottom) +void _glfwGetWindowFrameSizeCocoa(_GLFWwindow* window, + int* left, int* top, + int* right, int* bottom) { @autoreleasepool { @@ -1126,8 +1126,8 @@ void _glfwPlatformGetWindowFrameSize(_GLFWwindow* window, } // autoreleasepool } -void _glfwPlatformGetWindowContentScale(_GLFWwindow* window, - float* xscale, float* yscale) +void _glfwGetWindowContentScaleCocoa(_GLFWwindow* window, + float* xscale, float* yscale) { @autoreleasepool { @@ -1142,14 +1142,14 @@ void _glfwPlatformGetWindowContentScale(_GLFWwindow* window, } // autoreleasepool } -void _glfwPlatformIconifyWindow(_GLFWwindow* window) +void _glfwIconifyWindowCocoa(_GLFWwindow* window) { @autoreleasepool { [window->ns.object miniaturize:nil]; } // autoreleasepool } -void _glfwPlatformRestoreWindow(_GLFWwindow* window) +void _glfwRestoreWindowCocoa(_GLFWwindow* window) { @autoreleasepool { if ([window->ns.object isMiniaturized]) @@ -1159,7 +1159,7 @@ void _glfwPlatformRestoreWindow(_GLFWwindow* window) } // autoreleasepool } -void _glfwPlatformMaximizeWindow(_GLFWwindow* window) +void _glfwMaximizeWindowCocoa(_GLFWwindow* window) { @autoreleasepool { if (![window->ns.object isZoomed]) @@ -1167,28 +1167,28 @@ void _glfwPlatformMaximizeWindow(_GLFWwindow* window) } // autoreleasepool } -void _glfwPlatformShowWindow(_GLFWwindow* window) +void _glfwShowWindowCocoa(_GLFWwindow* window) { @autoreleasepool { [window->ns.object orderFront:nil]; } // autoreleasepool } -void _glfwPlatformHideWindow(_GLFWwindow* window) +void _glfwHideWindowCocoa(_GLFWwindow* window) { @autoreleasepool { [window->ns.object orderOut:nil]; } // autoreleasepool } -void _glfwPlatformRequestWindowAttention(_GLFWwindow* window) +void _glfwRequestWindowAttentionCocoa(_GLFWwindow* window) { @autoreleasepool { [NSApp requestUserAttention:NSInformationalRequest]; } // autoreleasepool } -void _glfwPlatformFocusWindow(_GLFWwindow* window) +void _glfwFocusWindowCocoa(_GLFWwindow* window) { @autoreleasepool { // Make us the active application @@ -1200,11 +1200,11 @@ void _glfwPlatformFocusWindow(_GLFWwindow* window) } // autoreleasepool } -void _glfwPlatformSetWindowMonitor(_GLFWwindow* window, - _GLFWmonitor* monitor, - int xpos, int ypos, - int width, int height, - int refreshRate) +void _glfwSetWindowMonitorCocoa(_GLFWwindow* window, + _GLFWmonitor* monitor, + int xpos, int ypos, + int width, int height, + int refreshRate) { @autoreleasepool { @@ -1236,7 +1236,7 @@ void _glfwPlatformSetWindowMonitor(_GLFWwindow* window, // HACK: Allow the state cached in Cocoa to catch up to reality // TODO: Solve this in a less terrible way - _glfwPlatformPollEvents(); + _glfwPollEventsCocoa(); const NSUInteger styleMask = getStyleMask(window); [window->ns.object setStyleMask:styleMask]; @@ -1293,35 +1293,35 @@ void _glfwPlatformSetWindowMonitor(_GLFWwindow* window, } // autoreleasepool } -int _glfwPlatformWindowFocused(_GLFWwindow* window) +int _glfwWindowFocusedCocoa(_GLFWwindow* window) { @autoreleasepool { return [window->ns.object isKeyWindow]; } // autoreleasepool } -int _glfwPlatformWindowIconified(_GLFWwindow* window) +int _glfwWindowIconifiedCocoa(_GLFWwindow* window) { @autoreleasepool { return [window->ns.object isMiniaturized]; } // autoreleasepool } -int _glfwPlatformWindowVisible(_GLFWwindow* window) +int _glfwWindowVisibleCocoa(_GLFWwindow* window) { @autoreleasepool { return [window->ns.object isVisible]; } // autoreleasepool } -int _glfwPlatformWindowMaximized(_GLFWwindow* window) +int _glfwWindowMaximizedCocoa(_GLFWwindow* window) { @autoreleasepool { return [window->ns.object isZoomed]; } // autoreleasepool } -int _glfwPlatformWindowHovered(_GLFWwindow* window) +int _glfwWindowHoveredCocoa(_GLFWwindow* window) { @autoreleasepool { @@ -1339,21 +1339,21 @@ int _glfwPlatformWindowHovered(_GLFWwindow* window) } // autoreleasepool } -int _glfwPlatformFramebufferTransparent(_GLFWwindow* window) +int _glfwFramebufferTransparentCocoa(_GLFWwindow* window) { @autoreleasepool { return ![window->ns.object isOpaque] && ![window->ns.view isOpaque]; } // autoreleasepool } -void _glfwPlatformSetWindowResizable(_GLFWwindow* window, GLFWbool enabled) +void _glfwSetWindowResizableCocoa(_GLFWwindow* window, GLFWbool enabled) { @autoreleasepool { [window->ns.object setStyleMask:getStyleMask(window)]; } // autoreleasepool } -void _glfwPlatformSetWindowDecorated(_GLFWwindow* window, GLFWbool enabled) +void _glfwSetWindowDecoratedCocoa(_GLFWwindow* window, GLFWbool enabled) { @autoreleasepool { [window->ns.object setStyleMask:getStyleMask(window)]; @@ -1361,7 +1361,7 @@ void _glfwPlatformSetWindowDecorated(_GLFWwindow* window, GLFWbool enabled) } // autoreleasepool } -void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled) +void _glfwSetWindowFloatingCocoa(_GLFWwindow* window, GLFWbool enabled) { @autoreleasepool { if (enabled) @@ -1371,39 +1371,39 @@ void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled) } // autoreleasepool } -void _glfwPlatformSetWindowMousePassthrough(_GLFWwindow* window, GLFWbool enabled) +void _glfwSetWindowMousePassthroughCocoa(_GLFWwindow* window, GLFWbool enabled) { @autoreleasepool { [window->ns.object setIgnoresMouseEvents:enabled]; } } -float _glfwPlatformGetWindowOpacity(_GLFWwindow* window) +float _glfwGetWindowOpacityCocoa(_GLFWwindow* window) { @autoreleasepool { return (float) [window->ns.object alphaValue]; } // autoreleasepool } -void _glfwPlatformSetWindowOpacity(_GLFWwindow* window, float opacity) +void _glfwSetWindowOpacityCocoa(_GLFWwindow* window, float opacity) { @autoreleasepool { [window->ns.object setAlphaValue:opacity]; } // autoreleasepool } -void _glfwPlatformSetRawMouseMotion(_GLFWwindow *window, GLFWbool enabled) +void _glfwSetRawMouseMotionCocoa(_GLFWwindow *window, GLFWbool enabled) { _glfwInputError(GLFW_FEATURE_UNIMPLEMENTED, "Cocoa: Raw mouse motion not yet implemented"); } -GLFWbool _glfwPlatformRawMouseMotionSupported(void) +GLFWbool _glfwRawMouseMotionSupportedCocoa(void) { return GLFW_FALSE; } -void _glfwPlatformPollEvents(void) +void _glfwPollEventsCocoa(void) { @autoreleasepool { @@ -1422,7 +1422,7 @@ void _glfwPlatformPollEvents(void) } // autoreleasepool } -void _glfwPlatformWaitEvents(void) +void _glfwWaitEventsCocoa(void) { @autoreleasepool { @@ -1435,12 +1435,12 @@ void _glfwPlatformWaitEvents(void) dequeue:YES]; [NSApp sendEvent:event]; - _glfwPlatformPollEvents(); + _glfwPollEventsCocoa(); } // autoreleasepool } -void _glfwPlatformWaitEventsTimeout(double timeout) +void _glfwWaitEventsTimeoutCocoa(double timeout) { @autoreleasepool { @@ -1452,12 +1452,12 @@ void _glfwPlatformWaitEventsTimeout(double timeout) if (event) [NSApp sendEvent:event]; - _glfwPlatformPollEvents(); + _glfwPollEventsCocoa(); } // autoreleasepool } -void _glfwPlatformPostEmptyEvent(void) +void _glfwPostEmptyEventCocoa(void) { @autoreleasepool { @@ -1475,7 +1475,7 @@ void _glfwPlatformPostEmptyEvent(void) } // autoreleasepool } -void _glfwPlatformGetCursorPos(_GLFWwindow* window, double* xpos, double* ypos) +void _glfwGetCursorPosCocoa(_GLFWwindow* window, double* xpos, double* ypos) { @autoreleasepool { @@ -1491,7 +1491,7 @@ void _glfwPlatformGetCursorPos(_GLFWwindow* window, double* xpos, double* ypos) } // autoreleasepool } -void _glfwPlatformSetCursorPos(_GLFWwindow* window, double x, double y) +void _glfwSetCursorPosCocoa(_GLFWwindow* window, double x, double y) { @autoreleasepool { @@ -1527,15 +1527,15 @@ void _glfwPlatformSetCursorPos(_GLFWwindow* window, double x, double y) } // autoreleasepool } -void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode) +void _glfwSetCursorModeCocoa(_GLFWwindow* window, int mode) { @autoreleasepool { - if (_glfwPlatformWindowFocused(window)) + if (_glfwWindowFocusedCocoa(window)) updateCursorMode(window); } // autoreleasepool } -const char* _glfwPlatformGetScancodeName(int scancode) +const char* _glfwGetScancodeNameCocoa(int scancode) { @autoreleasepool { @@ -1584,14 +1584,14 @@ const char* _glfwPlatformGetScancodeName(int scancode) } // autoreleasepool } -int _glfwPlatformGetKeyScancode(int key) +int _glfwGetKeyScancodeCocoa(int key) { return _glfw.ns.scancodes[key]; } -int _glfwPlatformCreateCursor(_GLFWcursor* cursor, - const GLFWimage* image, - int xhot, int yhot) +int _glfwCreateCursorCocoa(_GLFWcursor* cursor, + const GLFWimage* image, + int xhot, int yhot) { @autoreleasepool { @@ -1633,7 +1633,7 @@ int _glfwPlatformCreateCursor(_GLFWcursor* cursor, } // autoreleasepool } -int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape) +int _glfwCreateStandardCursorCocoa(_GLFWcursor* cursor, int shape) { @autoreleasepool { @@ -1707,7 +1707,7 @@ int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape) } // autoreleasepool } -void _glfwPlatformDestroyCursor(_GLFWcursor* cursor) +void _glfwDestroyCursorCocoa(_GLFWcursor* cursor) { @autoreleasepool { if (cursor->ns.object) @@ -1715,7 +1715,7 @@ void _glfwPlatformDestroyCursor(_GLFWcursor* cursor) } // autoreleasepool } -void _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor) +void _glfwSetCursorCocoa(_GLFWwindow* window, _GLFWcursor* cursor) { @autoreleasepool { if (cursorInContentArea(window)) @@ -1723,7 +1723,7 @@ void _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor) } // autoreleasepool } -void _glfwPlatformSetClipboardString(const char* string) +void _glfwSetClipboardStringCocoa(const char* string) { @autoreleasepool { NSPasteboard* pasteboard = [NSPasteboard generalPasteboard]; @@ -1732,7 +1732,7 @@ void _glfwPlatformSetClipboardString(const char* string) } // autoreleasepool } -const char* _glfwPlatformGetClipboardString(void) +const char* _glfwGetClipboardStringCocoa(void) { @autoreleasepool { @@ -1761,7 +1761,7 @@ const char* _glfwPlatformGetClipboardString(void) } // autoreleasepool } -EGLenum _glfwPlatformGetEGLPlatform(EGLint** attribs) +EGLenum _glfwGetEGLPlatformCocoa(EGLint** attribs) { if (_glfw.egl.ANGLE_platform_angle) { @@ -1792,17 +1792,17 @@ EGLenum _glfwPlatformGetEGLPlatform(EGLint** attribs) return 0; } -EGLNativeDisplayType _glfwPlatformGetEGLNativeDisplay(void) +EGLNativeDisplayType _glfwGetEGLNativeDisplayCocoa(void) { return EGL_DEFAULT_DISPLAY; } -EGLNativeWindowType _glfwPlatformGetEGLNativeWindow(_GLFWwindow* window) +EGLNativeWindowType _glfwGetEGLNativeWindowCocoa(_GLFWwindow* window) { return window->ns.layer; } -void _glfwPlatformGetRequiredInstanceExtensions(char** extensions) +void _glfwGetRequiredInstanceExtensionsCocoa(char** extensions) { if (_glfw.vk.KHR_surface && _glfw.vk.EXT_metal_surface) { @@ -1816,17 +1816,17 @@ void _glfwPlatformGetRequiredInstanceExtensions(char** extensions) } } -int _glfwPlatformGetPhysicalDevicePresentationSupport(VkInstance instance, - VkPhysicalDevice device, - uint32_t queuefamily) +int _glfwGetPhysicalDevicePresentationSupportCocoa(VkInstance instance, + VkPhysicalDevice device, + uint32_t queuefamily) { return GLFW_TRUE; } -VkResult _glfwPlatformCreateWindowSurface(VkInstance instance, - _GLFWwindow* window, - const VkAllocationCallbacks* allocator, - VkSurfaceKHR* surface) +VkResult _glfwCreateWindowSurfaceCocoa(VkInstance instance, + _GLFWwindow* window, + const VkAllocationCallbacks* allocator, + VkSurfaceKHR* surface) { @autoreleasepool { @@ -1923,6 +1923,14 @@ GLFWAPI id glfwGetCocoaWindow(GLFWwindow* handle) { _GLFWwindow* window = (_GLFWwindow*) handle; _GLFW_REQUIRE_INIT_OR_RETURN(nil); + + if (_glfw.platform.platformID != GLFW_PLATFORM_COCOA) + { + _glfwInputError(GLFW_PLATFORM_UNAVAILABLE, + "Cocoa: Platform not initialized"); + return NULL; + } + return window->ns.object; } diff --git a/src/egl_context.c b/src/egl_context.c index 8d4df682..593a153c 100644 --- a/src/egl_context.c +++ b/src/egl_context.c @@ -123,6 +123,7 @@ static GLFWbool chooseEGLConfig(const _GLFWctxconfig* ctxconfig, continue; #if defined(_GLFW_X11) + if (_glfw.platform.platformID == GLFW_PLATFORM_X11) { XVisualInfo vi = {0}; @@ -267,11 +268,10 @@ static GLFWglproc getProcAddressEGL(const char* procname) static void destroyContextEGL(_GLFWwindow* window) { -#if defined(_GLFW_X11) // NOTE: Do not unload libGL.so.1 while the X11 display is still open, // as it will make XCloseDisplay segfault - if (window->context.client != GLFW_OPENGL_API) -#endif // _GLFW_X11 + if (_glfw.platform.platformID != GLFW_PLATFORM_X11 || + window->context.client != GLFW_OPENGL_API) { if (window->context.egl.client) { @@ -429,16 +429,16 @@ GLFWbool _glfwInitEGL(void) eglGetProcAddress("eglCreatePlatformWindowSurfaceEXT"); } - _glfw.egl.platform = _glfwPlatformGetEGLPlatform(&attribs); + _glfw.egl.platform = _glfw.platform.getEGLPlatform(&attribs); if (_glfw.egl.platform) { _glfw.egl.display = eglGetPlatformDisplayEXT(_glfw.egl.platform, - _glfwPlatformGetEGLNativeDisplay(), + _glfw.platform.getEGLNativeDisplay(), attribs); } else - _glfw.egl.display = eglGetDisplay(_glfwPlatformGetEGLNativeDisplay()); + _glfw.egl.display = eglGetDisplay(_glfw.platform.getEGLNativeDisplay()); _glfw_free(attribs); @@ -648,7 +648,7 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window, setAttrib(EGL_NONE, EGL_NONE); - native = _glfwPlatformGetEGLNativeWindow(window); + native = _glfw.platform.getEGLNativeWindow(window); // HACK: ANGLE does not implement eglCreatePlatformWindowSurfaceEXT // despite reporting EGL_EXT_platform_base if (_glfw.egl.platform && _glfw.egl.platform != EGL_PLATFORM_ANGLE_ANGLE) diff --git a/src/glx_context.c b/src/glx_context.c index 02c1c5e4..4a92353c 100644 --- a/src/glx_context.c +++ b/src/glx_context.c @@ -425,7 +425,7 @@ GLFWbool _glfwInitGLX(void) void _glfwTerminateGLX(void) { // NOTE: This function must not call any X11 functions, as it is called - // after XCloseDisplay (see _glfwPlatformTerminate for details) + // after XCloseDisplay (see _glfwTerminateX11 for details) if (_glfw.glx.handle) { @@ -674,6 +674,12 @@ GLFWAPI GLXContext glfwGetGLXContext(GLFWwindow* handle) _GLFWwindow* window = (_GLFWwindow*) handle; _GLFW_REQUIRE_INIT_OR_RETURN(NULL); + if (_glfw.platform.platformID != GLFW_PLATFORM_X11) + { + _glfwInputError(GLFW_PLATFORM_UNAVAILABLE, "GLX: Platform not initialized"); + return NULL; + } + if (window->context.client != GLFW_NATIVE_CONTEXT_API) { _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL); @@ -688,6 +694,12 @@ GLFWAPI GLXWindow glfwGetGLXWindow(GLFWwindow* handle) _GLFWwindow* window = (_GLFWwindow*) handle; _GLFW_REQUIRE_INIT_OR_RETURN(None); + if (_glfw.platform.platformID != GLFW_PLATFORM_X11) + { + _glfwInputError(GLFW_PLATFORM_UNAVAILABLE, "GLX: Platform not initialized"); + return None; + } + if (window->context.client != GLFW_NATIVE_CONTEXT_API) { _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL); diff --git a/src/init.c b/src/init.c index f74b497d..cdb7ae41 100644 --- a/src/init.c +++ b/src/init.c @@ -54,6 +54,7 @@ static _GLFWinitconfig _glfwInitHints = { GLFW_TRUE, // hat buttons GLFW_ANGLE_PLATFORM_TYPE_NONE, // ANGLE backend + GLFW_ANY_PLATFORM, // preferred platform { GLFW_TRUE, // macOS menu bar GLFW_TRUE // macOS bundle chdir @@ -102,7 +103,7 @@ static void terminate(void) { _GLFWmonitor* monitor = _glfw.monitors[i]; if (monitor->originalRamp.size) - _glfwPlatformSetGammaRamp(monitor, &monitor->originalRamp); + _glfw.platform.setGammaRamp(monitor, &monitor->originalRamp); _glfwFreeMonitor(monitor); } @@ -115,8 +116,8 @@ static void terminate(void) _glfw.mappingCount = 0; _glfwTerminateVulkan(); - _glfwPlatformTerminateJoysticks(); - _glfwPlatformTerminate(); + _glfw.platform.terminateJoysticks(); + _glfw.platform.terminate(); _glfw.initialized = GLFW_FALSE; @@ -274,6 +275,8 @@ void _glfwInputError(int code, const char* format, ...) strcpy(description, "The requested feature cannot be implemented for this platform"); else if (code == GLFW_FEATURE_UNIMPLEMENTED) strcpy(description, "The requested feature has not yet been implemented for this platform"); + else if (code == GLFW_PLATFORM_UNAVAILABLE) + strcpy(description, "The requested platform is unavailable"); else strcpy(description, "ERROR: UNKNOWN GLFW ERROR"); } @@ -322,7 +325,10 @@ GLFWAPI int glfwInit(void) _glfw.allocator.deallocate = defaultDeallocate; } - if (!_glfwPlatformInit()) + if (!_glfwSelectPlatform(_glfw.hints.init.platformID, &_glfw.platform)) + return GLFW_FALSE; + + if (!_glfw.platform.init()) { terminate(); return GLFW_FALSE; @@ -367,6 +373,9 @@ GLFWAPI void glfwInitHint(int hint, int value) case GLFW_ANGLE_PLATFORM_TYPE: _glfwInitHints.angleType = value; return; + case GLFW_PLATFORM: + _glfwInitHints.platformID = value; + return; case GLFW_COCOA_CHDIR_RESOURCES: _glfwInitHints.ns.chdir = value; return; @@ -405,11 +414,6 @@ GLFWAPI void glfwGetVersion(int* major, int* minor, int* rev) *rev = GLFW_VERSION_REVISION; } -GLFWAPI const char* glfwGetVersionString(void) -{ - return _glfwPlatformGetVersionString(); -} - GLFWAPI int glfwGetError(const char** description) { _GLFWerror* error; diff --git a/src/input.c b/src/input.c index 920db8de..f2604c86 100644 --- a/src/input.c +++ b/src/input.c @@ -50,9 +50,9 @@ static GLFWbool initJoysticks(void) { if (!_glfw.joysticksInitialized) { - if (!_glfwPlatformInitJoysticks()) + if (!_glfw.platform.initJoysticks()) { - _glfwPlatformTerminateJoysticks(); + _glfw.platform.terminateJoysticks(); return GLFW_FALSE; } } @@ -234,7 +234,7 @@ static GLFWbool parseMapping(_GLFWmapping* mapping, const char* string) } else { - const char* name = _glfwPlatformGetMappingName(); + const char* name = _glfw.platform.getMappingName(); length = strlen(name); if (strncmp(c, name, length) != 0) return GLFW_FALSE; @@ -253,7 +253,7 @@ static GLFWbool parseMapping(_GLFWmapping* mapping, const char* string) mapping->guid[i] += 'a' - 'A'; } - _glfwPlatformUpdateGamepadGUID(mapping->guid); + _glfw.platform.updateGamepadGUID(mapping->guid); return GLFW_TRUE; } @@ -481,8 +481,8 @@ void _glfwCenterCursorInContentArea(_GLFWwindow* window) { int width, height; - _glfwPlatformGetWindowSize(window, &width, &height); - _glfwPlatformSetCursorPos(window, width / 2.0, height / 2.0); + _glfw.platform.getWindowSize(window, &width, &height); + _glfw.platform.setCursorPos(window, width / 2.0, height / 2.0); } @@ -539,10 +539,10 @@ GLFWAPI void glfwSetInputMode(GLFWwindow* handle, int mode, int value) window->cursorMode = value; - _glfwPlatformGetCursorPos(window, - &window->virtualCursorPosX, - &window->virtualCursorPosY); - _glfwPlatformSetCursorMode(window, value); + _glfw.platform.getCursorPos(window, + &window->virtualCursorPosX, + &window->virtualCursorPosY); + _glfw.platform.setCursorMode(window, value); } else if (mode == GLFW_STICKY_KEYS) { @@ -590,7 +590,7 @@ GLFWAPI void glfwSetInputMode(GLFWwindow* handle, int mode, int value) } else if (mode == GLFW_RAW_MOUSE_MOTION) { - if (!_glfwPlatformRawMouseMotionSupported()) + if (!_glfw.platform.rawMouseMotionSupported()) { _glfwInputError(GLFW_PLATFORM_ERROR, "Raw mouse motion is not supported on this system"); @@ -602,7 +602,7 @@ GLFWAPI void glfwSetInputMode(GLFWwindow* handle, int mode, int value) return; window->rawMouseMotion = value; - _glfwPlatformSetRawMouseMotion(window, value); + _glfw.platform.setRawMouseMotion(window, value); } else _glfwInputError(GLFW_INVALID_ENUM, "Invalid input mode 0x%08X", mode); @@ -611,7 +611,7 @@ GLFWAPI void glfwSetInputMode(GLFWwindow* handle, int mode, int value) GLFWAPI int glfwRawMouseMotionSupported(void) { _GLFW_REQUIRE_INIT_OR_RETURN(GLFW_FALSE); - return _glfwPlatformRawMouseMotionSupported(); + return _glfw.platform.rawMouseMotionSupported(); } GLFWAPI const char* glfwGetKeyName(int key, int scancode) @@ -627,10 +627,10 @@ GLFWAPI const char* glfwGetKeyName(int key, int scancode) return NULL; } - scancode = _glfwPlatformGetKeyScancode(key); + scancode = _glfw.platform.getKeyScancode(key); } - return _glfwPlatformGetScancodeName(scancode); + return _glfw.platform.getScancodeName(scancode); } GLFWAPI int glfwGetKeyScancode(int key) @@ -643,7 +643,7 @@ GLFWAPI int glfwGetKeyScancode(int key) return GLFW_RELEASE; } - return _glfwPlatformGetKeyScancode(key); + return _glfw.platform.getKeyScancode(key); } GLFWAPI int glfwGetKey(GLFWwindow* handle, int key) @@ -712,7 +712,7 @@ GLFWAPI void glfwGetCursorPos(GLFWwindow* handle, double* xpos, double* ypos) *ypos = window->virtualCursorPosY; } else - _glfwPlatformGetCursorPos(window, xpos, ypos); + _glfw.platform.getCursorPos(window, xpos, ypos); } GLFWAPI void glfwSetCursorPos(GLFWwindow* handle, double xpos, double ypos) @@ -731,7 +731,7 @@ GLFWAPI void glfwSetCursorPos(GLFWwindow* handle, double xpos, double ypos) return; } - if (!_glfwPlatformWindowFocused(window)) + if (!_glfw.platform.windowFocused(window)) return; if (window->cursorMode == GLFW_CURSOR_DISABLED) @@ -743,7 +743,7 @@ GLFWAPI void glfwSetCursorPos(GLFWwindow* handle, double xpos, double ypos) else { // Update system cursor position - _glfwPlatformSetCursorPos(window, xpos, ypos); + _glfw.platform.setCursorPos(window, xpos, ypos); } } @@ -759,7 +759,7 @@ GLFWAPI GLFWcursor* glfwCreateCursor(const GLFWimage* image, int xhot, int yhot) cursor->next = _glfw.cursorListHead; _glfw.cursorListHead = cursor; - if (!_glfwPlatformCreateCursor(cursor, image, xhot, yhot)) + if (!_glfw.platform.createCursor(cursor, image, xhot, yhot)) { glfwDestroyCursor((GLFWcursor*) cursor); return NULL; @@ -793,7 +793,7 @@ GLFWAPI GLFWcursor* glfwCreateStandardCursor(int shape) cursor->next = _glfw.cursorListHead; _glfw.cursorListHead = cursor; - if (!_glfwPlatformCreateStandardCursor(cursor, shape)) + if (!_glfw.platform.createStandardCursor(cursor, shape)) { glfwDestroyCursor((GLFWcursor*) cursor); return NULL; @@ -822,7 +822,7 @@ GLFWAPI void glfwDestroyCursor(GLFWcursor* handle) } } - _glfwPlatformDestroyCursor(cursor); + _glfw.platform.destroyCursor(cursor); // Unlink cursor from global linked list { @@ -847,7 +847,7 @@ GLFWAPI void glfwSetCursor(GLFWwindow* windowHandle, GLFWcursor* cursorHandle) window->cursor = cursor; - _glfwPlatformSetCursor(window, cursor); + _glfw.platform.setCursor(window, cursor); } GLFWAPI GLFWkeyfun glfwSetKeyCallback(GLFWwindow* handle, GLFWkeyfun cbfun) @@ -956,7 +956,7 @@ GLFWAPI int glfwJoystickPresent(int jid) if (!js->present) return GLFW_FALSE; - return _glfwPlatformPollJoystick(js, _GLFW_POLL_PRESENCE); + return _glfw.platform.pollJoystick(js, _GLFW_POLL_PRESENCE); } GLFWAPI const float* glfwGetJoystickAxes(int jid, int* count) @@ -984,7 +984,7 @@ GLFWAPI const float* glfwGetJoystickAxes(int jid, int* count) if (!js->present) return NULL; - if (!_glfwPlatformPollJoystick(js, _GLFW_POLL_AXES)) + if (!_glfw.platform.pollJoystick(js, _GLFW_POLL_AXES)) return NULL; *count = js->axisCount; @@ -1016,7 +1016,7 @@ GLFWAPI const unsigned char* glfwGetJoystickButtons(int jid, int* count) if (!js->present) return NULL; - if (!_glfwPlatformPollJoystick(js, _GLFW_POLL_BUTTONS)) + if (!_glfw.platform.pollJoystick(js, _GLFW_POLL_BUTTONS)) return NULL; if (_glfw.hints.init.hatButtons) @@ -1052,7 +1052,7 @@ GLFWAPI const unsigned char* glfwGetJoystickHats(int jid, int* count) if (!js->present) return NULL; - if (!_glfwPlatformPollJoystick(js, _GLFW_POLL_BUTTONS)) + if (!_glfw.platform.pollJoystick(js, _GLFW_POLL_BUTTONS)) return NULL; *count = js->hatCount; @@ -1081,7 +1081,7 @@ GLFWAPI const char* glfwGetJoystickName(int jid) if (!js->present) return NULL; - if (!_glfwPlatformPollJoystick(js, _GLFW_POLL_PRESENCE)) + if (!_glfw.platform.pollJoystick(js, _GLFW_POLL_PRESENCE)) return NULL; return js->name; @@ -1109,7 +1109,7 @@ GLFWAPI const char* glfwGetJoystickGUID(int jid) if (!js->present) return NULL; - if (!_glfwPlatformPollJoystick(js, _GLFW_POLL_PRESENCE)) + if (!_glfw.platform.pollJoystick(js, _GLFW_POLL_PRESENCE)) return NULL; return js->guid; @@ -1240,7 +1240,7 @@ GLFWAPI int glfwJoystickIsGamepad(int jid) if (!js->present) return GLFW_FALSE; - if (!_glfwPlatformPollJoystick(js, _GLFW_POLL_PRESENCE)) + if (!_glfw.platform.pollJoystick(js, _GLFW_POLL_PRESENCE)) return GLFW_FALSE; return js->mapping != NULL; @@ -1268,7 +1268,7 @@ GLFWAPI const char* glfwGetGamepadName(int jid) if (!js->present) return NULL; - if (!_glfwPlatformPollJoystick(js, _GLFW_POLL_PRESENCE)) + if (!_glfw.platform.pollJoystick(js, _GLFW_POLL_PRESENCE)) return NULL; if (!js->mapping) @@ -1303,7 +1303,7 @@ GLFWAPI int glfwGetGamepadState(int jid, GLFWgamepadstate* state) if (!js->present) return GLFW_FALSE; - if (!_glfwPlatformPollJoystick(js, _GLFW_POLL_ALL)) + if (!_glfw.platform.pollJoystick(js, _GLFW_POLL_ALL)) return GLFW_FALSE; if (!js->mapping) @@ -1368,13 +1368,13 @@ GLFWAPI void glfwSetClipboardString(GLFWwindow* handle, const char* string) assert(string != NULL); _GLFW_REQUIRE_INIT(); - _glfwPlatformSetClipboardString(string); + _glfw.platform.setClipboardString(string); } GLFWAPI const char* glfwGetClipboardString(GLFWwindow* handle) { _GLFW_REQUIRE_INIT_OR_RETURN(NULL); - return _glfwPlatformGetClipboardString(); + return _glfw.platform.getClipboardString(); } GLFWAPI double glfwGetTime(void) diff --git a/src/internal.h b/src/internal.h index af882be5..45ae45ab 100644 --- a/src/internal.h +++ b/src/internal.h @@ -68,6 +68,7 @@ typedef struct _GLFWctxconfig _GLFWctxconfig; typedef struct _GLFWfbconfig _GLFWfbconfig; typedef struct _GLFWcontext _GLFWcontext; typedef struct _GLFWwindow _GLFWwindow; +typedef struct _GLFWplatform _GLFWplatform; typedef struct _GLFWlibrary _GLFWlibrary; typedef struct _GLFWmonitor _GLFWmonitor; typedef struct _GLFWcursor _GLFWcursor; @@ -332,19 +333,7 @@ typedef void (APIENTRY * PFN_vkVoidFunction)(void); #define vkGetInstanceProcAddr _glfw.vk.GetInstanceProcAddr #endif -#if defined(_GLFW_COCOA) - #include "cocoa_platform.h" -#elif defined(_GLFW_WIN32) - #include "win32_platform.h" -#elif defined(_GLFW_X11) - #include "x11_platform.h" -#elif defined(_GLFW_WAYLAND) - #include "wl_platform.h" -#elif defined(_GLFW_OSMESA) - #include "null_platform.h" -#else - #error "No supported window creation API selected" -#endif +#include "platform.h" // Constructs a version number string from the public header macros #define _GLFW_CONCAT_VERSION(m, n, r) #m "." #n "." #r @@ -393,6 +382,7 @@ struct _GLFWinitconfig { GLFWbool hatButtons; int angleType; + int platformID; struct { GLFWbool menubar; GLFWbool chdir; @@ -527,8 +517,8 @@ struct _GLFWcontext void* buffer; } osmesa; - // This is defined in the context API's context.h - _GLFW_PLATFORM_CONTEXT_STATE; + // This is defined in platform.h + GLFW_PLATFORM_CONTEXT_STATE }; // Window and context structure @@ -587,8 +577,8 @@ struct _GLFWwindow GLFWdropfun drop; } callbacks; - // This is defined in the window API's platform.h - _GLFW_PLATFORM_WINDOW_STATE; + // This is defined in platform.h + GLFW_PLATFORM_WINDOW_STATE }; // Monitor structure @@ -611,8 +601,8 @@ struct _GLFWmonitor GLFWgammaramp originalRamp; GLFWgammaramp currentRamp; - // This is defined in the window API's platform.h - _GLFW_PLATFORM_MONITOR_STATE; + // This is defined in platform.h + GLFW_PLATFORM_MONITOR_STATE }; // Cursor structure @@ -620,9 +610,8 @@ struct _GLFWmonitor struct _GLFWcursor { _GLFWcursor* next; - - // This is defined in the window API's platform.h - _GLFW_PLATFORM_CURSOR_STATE; + // This is defined in platform.h + GLFW_PLATFORM_CURSOR_STATE }; // Gamepad mapping element structure @@ -661,24 +650,108 @@ struct _GLFWjoystick char guid[33]; _GLFWmapping* mapping; - // This is defined in the joystick API's joystick.h - _GLFW_PLATFORM_JOYSTICK_STATE; + // This is defined in platform.h + GLFW_PLATFORM_JOYSTICK_STATE }; // Thread local storage structure // struct _GLFWtls { - // This is defined in the platform's thread.h - _GLFW_PLATFORM_TLS_STATE; + // This is defined in platform.h + GLFW_PLATFORM_TLS_STATE }; // Mutex structure // struct _GLFWmutex { - // This is defined in the platform's thread.h - _GLFW_PLATFORM_MUTEX_STATE; + // This is defined in platform.h + GLFW_PLATFORM_MUTEX_STATE +}; + +// Platform API structure +// +struct _GLFWplatform +{ + int platformID; + // init + GLFWbool (*init)(void); + void (*terminate)(void); + // input + void (*getCursorPos)(_GLFWwindow*,double*,double*); + void (*setCursorPos)(_GLFWwindow*,double,double); + void (*setCursorMode)(_GLFWwindow*,int); + void (*setRawMouseMotion)(_GLFWwindow*,GLFWbool); + GLFWbool (*rawMouseMotionSupported)(void); + int (*createCursor)(_GLFWcursor*,const GLFWimage*,int,int); + int (*createStandardCursor)(_GLFWcursor*,int); + void (*destroyCursor)(_GLFWcursor*); + void (*setCursor)(_GLFWwindow*,_GLFWcursor*); + const char* (*getScancodeName)(int); + int (*getKeyScancode)(int); + void (*setClipboardString)(const char*); + const char* (*getClipboardString)(void); + GLFWbool (*initJoysticks)(void); + void (*terminateJoysticks)(void); + int (*pollJoystick)(_GLFWjoystick*,int); + const char* (*getMappingName)(void); + void (*updateGamepadGUID)(char*); + // monitor + void (*freeMonitor)(_GLFWmonitor*); + void (*getMonitorPos)(_GLFWmonitor*,int*,int*); + void (*getMonitorContentScale)(_GLFWmonitor*,float*,float*); + void (*getMonitorWorkarea)(_GLFWmonitor*,int*,int*,int*,int*); + GLFWvidmode* (*getVideoModes)(_GLFWmonitor*,int*); + void (*getVideoMode)(_GLFWmonitor*,GLFWvidmode*); + GLFWbool (*getGammaRamp)(_GLFWmonitor*,GLFWgammaramp*); + void (*setGammaRamp)(_GLFWmonitor*,const GLFWgammaramp*); + // window + int (*createWindow)(_GLFWwindow*,const _GLFWwndconfig*,const _GLFWctxconfig*,const _GLFWfbconfig*); + void (*destroyWindow)(_GLFWwindow*); + void (*setWindowTitle)(_GLFWwindow*,const char*); + void (*setWindowIcon)(_GLFWwindow*,int,const GLFWimage*); + void (*getWindowPos)(_GLFWwindow*,int*,int*); + void (*setWindowPos)(_GLFWwindow*,int,int); + void (*getWindowSize)(_GLFWwindow*,int*,int*); + void (*setWindowSize)(_GLFWwindow*,int,int); + void (*setWindowSizeLimits)(_GLFWwindow*,int,int,int,int); + void (*setWindowAspectRatio)(_GLFWwindow*,int,int); + void (*getFramebufferSize)(_GLFWwindow*,int*,int*); + void (*getWindowFrameSize)(_GLFWwindow*,int*,int*,int*,int*); + void (*getWindowContentScale)(_GLFWwindow*,float*,float*); + void (*iconifyWindow)(_GLFWwindow*); + void (*restoreWindow)(_GLFWwindow*); + void (*maximizeWindow)(_GLFWwindow*); + void (*showWindow)(_GLFWwindow*); + void (*hideWindow)(_GLFWwindow*); + void (*requestWindowAttention)(_GLFWwindow*); + void (*focusWindow)(_GLFWwindow*); + void (*setWindowMonitor)(_GLFWwindow*,_GLFWmonitor*,int,int,int,int,int); + int (*windowFocused)(_GLFWwindow*); + int (*windowIconified)(_GLFWwindow*); + int (*windowVisible)(_GLFWwindow*); + int (*windowMaximized)(_GLFWwindow*); + int (*windowHovered)(_GLFWwindow*); + int (*framebufferTransparent)(_GLFWwindow*); + float (*getWindowOpacity)(_GLFWwindow*); + void (*setWindowResizable)(_GLFWwindow*,GLFWbool); + void (*setWindowDecorated)(_GLFWwindow*,GLFWbool); + void (*setWindowFloating)(_GLFWwindow*,GLFWbool); + void (*setWindowOpacity)(_GLFWwindow*,float); + void (*setWindowMousePassthrough)(_GLFWwindow*,GLFWbool); + void (*pollEvents)(void); + void (*waitEvents)(void); + void (*waitEventsTimeout)(double); + void (*postEmptyEvent)(void); + // EGL + EGLenum (*getEGLPlatform)(EGLint**); + EGLNativeDisplayType (*getEGLNativeDisplay)(void); + EGLNativeWindowType (*getEGLNativeWindow)(_GLFWwindow*); + // vulkan + void (*getRequiredInstanceExtensions)(char**); + int (*getPhysicalDevicePresentationSupport)(VkInstance,VkPhysicalDevice,uint32_t); + VkResult (*createWindowSurface)(VkInstance,_GLFWwindow*,const VkAllocationCallbacks*,VkSurfaceKHR*); }; // Library global data @@ -688,6 +761,8 @@ struct _GLFWlibrary GLFWbool initialized; GLFWallocator allocator; + _GLFWplatform platform; + struct { _GLFWinitconfig init; _GLFWfbconfig framebuffer; @@ -714,8 +789,8 @@ struct _GLFWlibrary struct { uint64_t offset; - // This is defined in the platform's time.h - _GLFW_PLATFORM_LIBRARY_TIMER_STATE; + // This is defined in platform.h + GLFW_PLATFORM_LIBRARY_TIMER_STATE } timer; struct { @@ -784,17 +859,12 @@ struct _GLFWlibrary PFN_vkGetInstanceProcAddr GetInstanceProcAddr; #endif GLFWbool KHR_surface; -#if defined(_GLFW_WIN32) GLFWbool KHR_win32_surface; -#elif defined(_GLFW_COCOA) GLFWbool MVK_macos_surface; GLFWbool EXT_metal_surface; -#elif defined(_GLFW_X11) GLFWbool KHR_xlib_surface; GLFWbool KHR_xcb_surface; -#elif defined(_GLFW_WAYLAND) GLFWbool KHR_wayland_surface; -#endif } vk; struct { @@ -802,12 +872,10 @@ struct _GLFWlibrary GLFWjoystickfun joystick; } callbacks; - // This is defined in the window API's platform.h - _GLFW_PLATFORM_LIBRARY_WINDOW_STATE; - // This is defined in the context API's context.h - _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE; - // This is defined in the platform's joystick.h - _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE; + // These are defined in platform.h + GLFW_PLATFORM_LIBRARY_WINDOW_STATE + GLFW_PLATFORM_LIBRARY_CONTEXT_STATE + GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE }; // Global state shared between compilation units of GLFW @@ -819,110 +887,10 @@ extern _GLFWlibrary _glfw; ////// GLFW platform API ////// ////////////////////////////////////////////////////////////////////////// -int _glfwPlatformInit(void); -void _glfwPlatformTerminate(void); -const char* _glfwPlatformGetVersionString(void); - -void _glfwPlatformGetCursorPos(_GLFWwindow* window, double* xpos, double* ypos); -void _glfwPlatformSetCursorPos(_GLFWwindow* window, double xpos, double ypos); -void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode); -void _glfwPlatformSetRawMouseMotion(_GLFWwindow *window, GLFWbool enabled); -GLFWbool _glfwPlatformRawMouseMotionSupported(void); -int _glfwPlatformCreateCursor(_GLFWcursor* cursor, - const GLFWimage* image, int xhot, int yhot); -int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape); -void _glfwPlatformDestroyCursor(_GLFWcursor* cursor); -void _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor); - -const char* _glfwPlatformGetScancodeName(int scancode); -int _glfwPlatformGetKeyScancode(int key); - -void _glfwPlatformFreeMonitor(_GLFWmonitor* monitor); -void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos); -void _glfwPlatformGetMonitorContentScale(_GLFWmonitor* monitor, - float* xscale, float* yscale); -void _glfwPlatformGetMonitorWorkarea(_GLFWmonitor* monitor, int* xpos, int* ypos, int *width, int *height); -GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* count); -void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode); -GLFWbool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp); -void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp); - -void _glfwPlatformSetClipboardString(const char* string); -const char* _glfwPlatformGetClipboardString(void); - -GLFWbool _glfwPlatformInitJoysticks(void); -void _glfwPlatformTerminateJoysticks(void); -int _glfwPlatformPollJoystick(_GLFWjoystick* js, int mode); -void _glfwPlatformUpdateGamepadGUID(char* guid); -const char* _glfwPlatformGetMappingName(void); - void _glfwPlatformInitTimer(void); uint64_t _glfwPlatformGetTimerValue(void); uint64_t _glfwPlatformGetTimerFrequency(void); -int _glfwPlatformCreateWindow(_GLFWwindow* window, - const _GLFWwndconfig* wndconfig, - const _GLFWctxconfig* ctxconfig, - const _GLFWfbconfig* fbconfig); -void _glfwPlatformDestroyWindow(_GLFWwindow* window); -void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title); -void _glfwPlatformSetWindowIcon(_GLFWwindow* window, - int count, const GLFWimage* images); -void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos); -void _glfwPlatformSetWindowPos(_GLFWwindow* window, int xpos, int ypos); -void _glfwPlatformGetWindowSize(_GLFWwindow* window, int* width, int* height); -void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height); -void _glfwPlatformSetWindowSizeLimits(_GLFWwindow* window, - int minwidth, int minheight, - int maxwidth, int maxheight); -void _glfwPlatformSetWindowAspectRatio(_GLFWwindow* window, int numer, int denom); -void _glfwPlatformGetFramebufferSize(_GLFWwindow* window, int* width, int* height); -void _glfwPlatformGetWindowFrameSize(_GLFWwindow* window, - int* left, int* top, - int* right, int* bottom); -void _glfwPlatformGetWindowContentScale(_GLFWwindow* window, - float* xscale, float* yscale); -void _glfwPlatformIconifyWindow(_GLFWwindow* window); -void _glfwPlatformRestoreWindow(_GLFWwindow* window); -void _glfwPlatformMaximizeWindow(_GLFWwindow* window); -void _glfwPlatformShowWindow(_GLFWwindow* window); -void _glfwPlatformHideWindow(_GLFWwindow* window); -void _glfwPlatformRequestWindowAttention(_GLFWwindow* window); -void _glfwPlatformFocusWindow(_GLFWwindow* window); -void _glfwPlatformSetWindowMonitor(_GLFWwindow* window, _GLFWmonitor* monitor, - int xpos, int ypos, int width, int height, - int refreshRate); -int _glfwPlatformWindowFocused(_GLFWwindow* window); -int _glfwPlatformWindowIconified(_GLFWwindow* window); -int _glfwPlatformWindowVisible(_GLFWwindow* window); -int _glfwPlatformWindowMaximized(_GLFWwindow* window); -int _glfwPlatformWindowHovered(_GLFWwindow* window); -int _glfwPlatformFramebufferTransparent(_GLFWwindow* window); -float _glfwPlatformGetWindowOpacity(_GLFWwindow* window); -void _glfwPlatformSetWindowResizable(_GLFWwindow* window, GLFWbool enabled); -void _glfwPlatformSetWindowDecorated(_GLFWwindow* window, GLFWbool enabled); -void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled); -void _glfwPlatformSetWindowMousePassthrough(_GLFWwindow* window, GLFWbool enabled); -void _glfwPlatformSetWindowOpacity(_GLFWwindow* window, float opacity); - -void _glfwPlatformPollEvents(void); -void _glfwPlatformWaitEvents(void); -void _glfwPlatformWaitEventsTimeout(double timeout); -void _glfwPlatformPostEmptyEvent(void); - -EGLenum _glfwPlatformGetEGLPlatform(EGLint** attribs); -EGLNativeDisplayType _glfwPlatformGetEGLNativeDisplay(void); -EGLNativeWindowType _glfwPlatformGetEGLNativeWindow(_GLFWwindow* window); - -void _glfwPlatformGetRequiredInstanceExtensions(char** extensions); -int _glfwPlatformGetPhysicalDevicePresentationSupport(VkInstance instance, - VkPhysicalDevice device, - uint32_t queuefamily); -VkResult _glfwPlatformCreateWindowSurface(VkInstance instance, - _GLFWwindow* window, - const VkAllocationCallbacks* allocator, - VkSurfaceKHR* surface); - GLFWbool _glfwPlatformCreateTls(_GLFWtls* tls); void _glfwPlatformDestroyTls(_GLFWtls* tls); void* _glfwPlatformGetTls(_GLFWtls* tls); @@ -983,6 +951,8 @@ void _glfwInputError(int code, const char* format, ...); ////// GLFW internal API ////// ////////////////////////////////////////////////////////////////////////// +GLFWbool _glfwSelectPlatform(int platformID, _GLFWplatform* platform); + GLFWbool _glfwStringInExtensionString(const char* string, const char* extensions); const _GLFWfbconfig* _glfwChooseFBConfig(const _GLFWfbconfig* desired, const _GLFWfbconfig* alternatives, diff --git a/src/linux_joystick.c b/src/linux_joystick.c index edb53e4c..6ea63942 100644 --- a/src/linux_joystick.c +++ b/src/linux_joystick.c @@ -307,7 +307,7 @@ void _glfwDetectJoystickConnectionLinux(void) ////// GLFW platform API ////// ////////////////////////////////////////////////////////////////////////// -GLFWbool _glfwPlatformInitJoysticks(void) +GLFWbool _glfwInitJoysticksLinux(void) { const char* dirname = "/dev/input"; @@ -361,7 +361,7 @@ GLFWbool _glfwPlatformInitJoysticks(void) return GLFW_TRUE; } -void _glfwPlatformTerminateJoysticks(void) +void _glfwTerminateJoysticksLinux(void) { int jid; @@ -382,7 +382,7 @@ void _glfwPlatformTerminateJoysticks(void) } } -int _glfwPlatformPollJoystick(_GLFWjoystick* js, int mode) +int _glfwPollJoystickLinux(_GLFWjoystick* js, int mode) { // Read all queued events (non-blocking) for (;;) @@ -422,12 +422,12 @@ int _glfwPlatformPollJoystick(_GLFWjoystick* js, int mode) return js->present; } -const char* _glfwPlatformGetMappingName(void) +const char* _glfwGetMappingNameLinux(void) { return "Linux"; } -void _glfwPlatformUpdateGamepadGUID(char* guid) +void _glfwUpdateGamepadGUIDLinux(char* guid) { } diff --git a/src/linux_joystick.h b/src/linux_joystick.h index 1766a3bf..37e5d1ae 100644 --- a/src/linux_joystick.h +++ b/src/linux_joystick.h @@ -28,8 +28,8 @@ #include #include -#define _GLFW_PLATFORM_JOYSTICK_STATE _GLFWjoystickLinux linjs -#define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE _GLFWlibraryLinux linjs +#define GLFW_LINUX_JOYSTICK_STATE _GLFWjoystickLinux linjs; +#define GLFW_LINUX_LIBRARY_JOYSTICK_STATE _GLFWlibraryLinux linjs; #define GLFW_BUILD_LINUX_MAPPINGS @@ -57,3 +57,9 @@ typedef struct _GLFWlibraryLinux void _glfwDetectJoystickConnectionLinux(void); +GLFWbool _glfwInitJoysticksLinux(void); +void _glfwTerminateJoysticksLinux(void); +int _glfwPollJoystickLinux(_GLFWjoystick* js, int mode); +const char* _glfwGetMappingNameLinux(void); +void _glfwUpdateGamepadGUIDLinux(char* guid); + diff --git a/src/monitor.c b/src/monitor.c index 938582b2..31921b46 100644 --- a/src/monitor.c +++ b/src/monitor.c @@ -74,7 +74,7 @@ static GLFWbool refreshVideoModes(_GLFWmonitor* monitor) if (monitor->modes) return GLFW_TRUE; - modes = _glfwPlatformGetVideoModes(monitor, &modeCount); + modes = _glfw.platform.getVideoModes(monitor, &modeCount); if (!modes) return GLFW_FALSE; @@ -123,10 +123,10 @@ void _glfwInputMonitor(_GLFWmonitor* monitor, int action, int placement) if (window->monitor == monitor) { int width, height, xoff, yoff; - _glfwPlatformGetWindowSize(window, &width, &height); - _glfwPlatformSetWindowMonitor(window, NULL, 0, 0, width, height, 0); - _glfwPlatformGetWindowFrameSize(window, &xoff, &yoff, NULL, NULL); - _glfwPlatformSetWindowPos(window, xoff, yoff); + _glfw.platform.getWindowSize(window, &width, &height); + _glfw.platform.setWindowMonitor(window, NULL, 0, 0, width, height, 0); + _glfw.platform.getWindowFrameSize(window, &xoff, &yoff, NULL, NULL); + _glfw.platform.setWindowPos(window, xoff, yoff); } } @@ -183,7 +183,7 @@ void _glfwFreeMonitor(_GLFWmonitor* monitor) if (monitor == NULL) return; - _glfwPlatformFreeMonitor(monitor); + _glfw.platform.freeMonitor(monitor); _glfwFreeGammaArrays(&monitor->originalRamp); _glfwFreeGammaArrays(&monitor->currentRamp); @@ -332,7 +332,7 @@ GLFWAPI void glfwGetMonitorPos(GLFWmonitor* handle, int* xpos, int* ypos) _GLFW_REQUIRE_INIT(); - _glfwPlatformGetMonitorPos(monitor, xpos, ypos); + _glfw.platform.getMonitorPos(monitor, xpos, ypos); } GLFWAPI void glfwGetMonitorWorkarea(GLFWmonitor* handle, @@ -353,7 +353,7 @@ GLFWAPI void glfwGetMonitorWorkarea(GLFWmonitor* handle, _GLFW_REQUIRE_INIT(); - _glfwPlatformGetMonitorWorkarea(monitor, xpos, ypos, width, height); + _glfw.platform.getMonitorWorkarea(monitor, xpos, ypos, width, height); } GLFWAPI void glfwGetMonitorPhysicalSize(GLFWmonitor* handle, int* widthMM, int* heightMM) @@ -386,7 +386,7 @@ GLFWAPI void glfwGetMonitorContentScale(GLFWmonitor* handle, *yscale = 0.f; _GLFW_REQUIRE_INIT(); - _glfwPlatformGetMonitorContentScale(monitor, xscale, yscale); + _glfw.platform.getMonitorContentScale(monitor, xscale, yscale); } GLFWAPI const char* glfwGetMonitorName(GLFWmonitor* handle) @@ -447,7 +447,7 @@ GLFWAPI const GLFWvidmode* glfwGetVideoMode(GLFWmonitor* handle) _GLFW_REQUIRE_INIT_OR_RETURN(NULL); - _glfwPlatformGetVideoMode(monitor, &monitor->currentMode); + _glfw.platform.getVideoMode(monitor, &monitor->currentMode); return &monitor->currentMode; } @@ -506,7 +506,7 @@ GLFWAPI const GLFWgammaramp* glfwGetGammaRamp(GLFWmonitor* handle) _GLFW_REQUIRE_INIT_OR_RETURN(NULL); _glfwFreeGammaArrays(&monitor->currentRamp); - if (!_glfwPlatformGetGammaRamp(monitor, &monitor->currentRamp)) + if (!_glfw.platform.getGammaRamp(monitor, &monitor->currentRamp)) return NULL; return &monitor->currentRamp; @@ -534,10 +534,10 @@ GLFWAPI void glfwSetGammaRamp(GLFWmonitor* handle, const GLFWgammaramp* ramp) if (!monitor->originalRamp.size) { - if (!_glfwPlatformGetGammaRamp(monitor, &monitor->originalRamp)) + if (!_glfw.platform.getGammaRamp(monitor, &monitor->originalRamp)) return; } - _glfwPlatformSetGammaRamp(monitor, ramp); + _glfw.platform.setGammaRamp(monitor, ramp); } diff --git a/src/nsgl_context.m b/src/nsgl_context.m index 940ee848..694937c6 100644 --- a/src/nsgl_context.m +++ b/src/nsgl_context.m @@ -358,6 +358,13 @@ GLFWAPI id glfwGetNSGLContext(GLFWwindow* handle) _GLFWwindow* window = (_GLFWwindow*) handle; _GLFW_REQUIRE_INIT_OR_RETURN(nil); + if (_glfw.platform.platformID != GLFW_PLATFORM_COCOA) + { + _glfwInputError(GLFW_PLATFORM_UNAVAILABLE, + "NSGL: Platform not initialized"); + return nil; + } + if (window->context.client != GLFW_NATIVE_CONTEXT_API) { _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL); diff --git a/src/null_init.c b/src/null_init.c index d2968fc1..de4b28f3 100644 --- a/src/null_init.c +++ b/src/null_init.c @@ -36,22 +36,98 @@ ////// GLFW platform API ////// ////////////////////////////////////////////////////////////////////////// -int _glfwPlatformInit(void) +GLFWbool _glfwConnectNull(int platformID, _GLFWplatform* platform) { - _glfwPollMonitorsNull(); + const _GLFWplatform null = + { + GLFW_PLATFORM_NULL, + _glfwInitNull, + _glfwTerminateNull, + _glfwGetCursorPosNull, + _glfwSetCursorPosNull, + _glfwSetCursorModeNull, + _glfwSetRawMouseMotionNull, + _glfwRawMouseMotionSupportedNull, + _glfwCreateCursorNull, + _glfwCreateStandardCursorNull, + _glfwDestroyCursorNull, + _glfwSetCursorNull, + _glfwGetScancodeNameNull, + _glfwGetKeyScancodeNull, + _glfwSetClipboardStringNull, + _glfwGetClipboardStringNull, + _glfwInitJoysticksNull, + _glfwTerminateJoysticksNull, + _glfwPollJoystickNull, + _glfwGetMappingNameNull, + _glfwUpdateGamepadGUIDNull, + _glfwFreeMonitorNull, + _glfwGetMonitorPosNull, + _glfwGetMonitorContentScaleNull, + _glfwGetMonitorWorkareaNull, + _glfwGetVideoModesNull, + _glfwGetVideoModeNull, + _glfwGetGammaRampNull, + _glfwSetGammaRampNull, + _glfwCreateWindowNull, + _glfwDestroyWindowNull, + _glfwSetWindowTitleNull, + _glfwSetWindowIconNull, + _glfwGetWindowPosNull, + _glfwSetWindowPosNull, + _glfwGetWindowSizeNull, + _glfwSetWindowSizeNull, + _glfwSetWindowSizeLimitsNull, + _glfwSetWindowAspectRatioNull, + _glfwGetFramebufferSizeNull, + _glfwGetWindowFrameSizeNull, + _glfwGetWindowContentScaleNull, + _glfwIconifyWindowNull, + _glfwRestoreWindowNull, + _glfwMaximizeWindowNull, + _glfwShowWindowNull, + _glfwHideWindowNull, + _glfwRequestWindowAttentionNull, + _glfwFocusWindowNull, + _glfwSetWindowMonitorNull, + _glfwWindowFocusedNull, + _glfwWindowIconifiedNull, + _glfwWindowVisibleNull, + _glfwWindowMaximizedNull, + _glfwWindowHoveredNull, + _glfwFramebufferTransparentNull, + _glfwGetWindowOpacityNull, + _glfwSetWindowResizableNull, + _glfwSetWindowDecoratedNull, + _glfwSetWindowFloatingNull, + _glfwSetWindowOpacityNull, + _glfwSetWindowMousePassthroughNull, + _glfwPollEventsNull, + _glfwWaitEventsNull, + _glfwWaitEventsTimeoutNull, + _glfwPostEmptyEventNull, + _glfwGetEGLPlatformNull, + _glfwGetEGLNativeDisplayNull, + _glfwGetEGLNativeWindowNull, + _glfwGetRequiredInstanceExtensionsNull, + _glfwGetPhysicalDevicePresentationSupportNull, + _glfwCreateWindowSurfaceNull, + }; + *platform = null; return GLFW_TRUE; } -void _glfwPlatformTerminate(void) +int _glfwInitNull(void) { - _glfw_free(_glfw.null.clipboardString); + _glfwPollMonitorsNull(); + return GLFW_TRUE; +} + +void _glfwTerminateNull(void) +{ + free(_glfw.null.clipboardString); _glfwTerminateOSMesa(); _glfwTerminateEGL(); } -const char* _glfwPlatformGetVersionString(void) -{ - return _GLFW_VERSION_NUMBER " null OSMesa EGL"; -} - diff --git a/src/null_joystick.c b/src/null_joystick.c index de5066ca..e2770dd8 100644 --- a/src/null_joystick.c +++ b/src/null_joystick.c @@ -33,26 +33,26 @@ ////// GLFW platform API ////// ////////////////////////////////////////////////////////////////////////// -GLFWbool _glfwPlatformInitJoysticks(void) +GLFWbool _glfwInitJoysticksNull(void) { return GLFW_TRUE; } -void _glfwPlatformTerminateJoysticks(void) +void _glfwTerminateJoysticksNull(void) { } -int _glfwPlatformPollJoystick(_GLFWjoystick* js, int mode) +int _glfwPollJoystickNull(_GLFWjoystick* js, int mode) { return GLFW_FALSE; } -const char* _glfwPlatformGetMappingName(void) +const char* _glfwGetMappingNameNull(void) { return ""; } -void _glfwPlatformUpdateGamepadGUID(char* guid) +void _glfwUpdateGamepadGUIDNull(char* guid) { } diff --git a/src/null_joystick.h b/src/null_joystick.h index a1ff7fcd..ec223ecd 100644 --- a/src/null_joystick.h +++ b/src/null_joystick.h @@ -24,6 +24,9 @@ // //======================================================================== -#define _GLFW_PLATFORM_JOYSTICK_STATE struct { int dummyJoystick; } -#define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE struct { int dummyLibraryJoystick; } +GLFWbool _glfwInitJoysticksNull(void); +void _glfwTerminateJoysticksNull(void); +int _glfwPollJoystickNull(_GLFWjoystick* js, int mode); +const char* _glfwGetMappingNameNull(void); +void _glfwUpdateGamepadGUIDNull(char* guid); diff --git a/src/null_monitor.c b/src/null_monitor.c index a071e0c4..63a1cd20 100644 --- a/src/null_monitor.c +++ b/src/null_monitor.c @@ -65,12 +65,12 @@ void _glfwPollMonitorsNull(void) ////// GLFW platform API ////// ////////////////////////////////////////////////////////////////////////// -void _glfwPlatformFreeMonitor(_GLFWmonitor* monitor) +void _glfwFreeMonitorNull(_GLFWmonitor* monitor) { _glfwFreeGammaArrays(&monitor->null.ramp); } -void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos) +void _glfwGetMonitorPosNull(_GLFWmonitor* monitor, int* xpos, int* ypos) { if (xpos) *xpos = 0; @@ -78,8 +78,8 @@ void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos) *ypos = 0; } -void _glfwPlatformGetMonitorContentScale(_GLFWmonitor* monitor, - float* xscale, float* yscale) +void _glfwGetMonitorContentScaleNull(_GLFWmonitor* monitor, + float* xscale, float* yscale) { if (xscale) *xscale = 1.f; @@ -87,9 +87,9 @@ void _glfwPlatformGetMonitorContentScale(_GLFWmonitor* monitor, *yscale = 1.f; } -void _glfwPlatformGetMonitorWorkarea(_GLFWmonitor* monitor, - int* xpos, int* ypos, - int* width, int* height) +void _glfwGetMonitorWorkareaNull(_GLFWmonitor* monitor, + int* xpos, int* ypos, + int* width, int* height) { const GLFWvidmode mode = getVideoMode(); @@ -103,7 +103,7 @@ void _glfwPlatformGetMonitorWorkarea(_GLFWmonitor* monitor, *height = mode.height - 10; } -GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* found) +GLFWvidmode* _glfwGetVideoModesNull(_GLFWmonitor* monitor, int* found) { GLFWvidmode* mode = _glfw_calloc(1, sizeof(GLFWvidmode)); *mode = getVideoMode(); @@ -111,18 +111,20 @@ GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* found) return mode; } -void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode) +void _glfwGetVideoModeNull(_GLFWmonitor* monitor, GLFWvidmode* mode) { *mode = getVideoMode(); } -GLFWbool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp) +GLFWbool _glfwGetGammaRampNull(_GLFWmonitor* monitor, GLFWgammaramp* ramp) { if (!monitor->null.ramp.size) { + unsigned int i; + _glfwAllocGammaArrays(&monitor->null.ramp, 256); - for (unsigned int i = 0; i < monitor->null.ramp.size; i++) + for (i = 0; i < monitor->null.ramp.size; i++) { const float gamma = 2.2f; float value; @@ -143,7 +145,7 @@ GLFWbool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp) return GLFW_TRUE; } -void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp) +void _glfwSetGammaRampNull(_GLFWmonitor* monitor, const GLFWgammaramp* ramp) { if (monitor->null.ramp.size != ramp->size) { diff --git a/src/null_platform.h b/src/null_platform.h index e0b3f2ce..30e50a85 100644 --- a/src/null_platform.h +++ b/src/null_platform.h @@ -25,17 +25,14 @@ // //======================================================================== -#define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowNull null -#define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryNull null -#define _GLFW_PLATFORM_MONITOR_STATE _GLFWmonitorNull null +#define GLFW_NULL_WINDOW_STATE _GLFWwindowNull null; +#define GLFW_NULL_LIBRARY_WINDOW_STATE _GLFWlibraryNull null; +#define GLFW_NULL_MONITOR_STATE _GLFWmonitorNull null; -#define _GLFW_PLATFORM_CONTEXT_STATE struct { int dummyContext; } -#define _GLFW_PLATFORM_CURSOR_STATE struct { int dummyCursor; } -#define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE struct { int dummyLibraryContext; } +#define GLFW_NULL_CONTEXT_STATE +#define GLFW_NULL_CURSOR_STATE +#define GLFW_NULL_LIBRARY_CONTEXT_STATE -#include "posix_time.h" -#include "posix_thread.h" -#include "null_joystick.h" // Null-specific per-window data // @@ -75,3 +72,79 @@ typedef struct _GLFWlibraryNull void _glfwPollMonitorsNull(void); +GLFWbool _glfwConnectNull(int platformID, _GLFWplatform* platform); +int _glfwInitNull(void); +void _glfwTerminateNull(void); + +void _glfwFreeMonitorNull(_GLFWmonitor* monitor); +void _glfwGetMonitorPosNull(_GLFWmonitor* monitor, int* xpos, int* ypos); +void _glfwGetMonitorContentScaleNull(_GLFWmonitor* monitor, float* xscale, float* yscale); +void _glfwGetMonitorWorkareaNull(_GLFWmonitor* monitor, int* xpos, int* ypos, int* width, int* height); +GLFWvidmode* _glfwGetVideoModesNull(_GLFWmonitor* monitor, int* found); +void _glfwGetVideoModeNull(_GLFWmonitor* monitor, GLFWvidmode* mode); +GLFWbool _glfwGetGammaRampNull(_GLFWmonitor* monitor, GLFWgammaramp* ramp); +void _glfwSetGammaRampNull(_GLFWmonitor* monitor, const GLFWgammaramp* ramp); + +int _glfwCreateWindowNull(_GLFWwindow* window, const _GLFWwndconfig* wndconfig, const _GLFWctxconfig* ctxconfig, const _GLFWfbconfig* fbconfig); +void _glfwDestroyWindowNull(_GLFWwindow* window); +void _glfwSetWindowTitleNull(_GLFWwindow* window, const char* title); +void _glfwSetWindowIconNull(_GLFWwindow* window, int count, const GLFWimage* images); +void _glfwSetWindowMonitorNull(_GLFWwindow* window, _GLFWmonitor* monitor, int xpos, int ypos, int width, int height, int refreshRate); +void _glfwGetWindowPosNull(_GLFWwindow* window, int* xpos, int* ypos); +void _glfwSetWindowPosNull(_GLFWwindow* window, int xpos, int ypos); +void _glfwGetWindowSizeNull(_GLFWwindow* window, int* width, int* height); +void _glfwSetWindowSizeNull(_GLFWwindow* window, int width, int height); +void _glfwSetWindowSizeLimitsNull(_GLFWwindow* window, int minwidth, int minheight, int maxwidth, int maxheight); +void _glfwSetWindowAspectRatioNull(_GLFWwindow* window, int n, int d); +void _glfwGetFramebufferSizeNull(_GLFWwindow* window, int* width, int* height); +void _glfwGetWindowFrameSizeNull(_GLFWwindow* window, int* left, int* top, int* right, int* bottom); +void _glfwGetWindowContentScaleNull(_GLFWwindow* window, float* xscale, float* yscale); +void _glfwIconifyWindowNull(_GLFWwindow* window); +void _glfwRestoreWindowNull(_GLFWwindow* window); +void _glfwMaximizeWindowNull(_GLFWwindow* window); +int _glfwWindowMaximizedNull(_GLFWwindow* window); +int _glfwWindowHoveredNull(_GLFWwindow* window); +int _glfwFramebufferTransparentNull(_GLFWwindow* window); +void _glfwSetWindowResizableNull(_GLFWwindow* window, GLFWbool enabled); +void _glfwSetWindowDecoratedNull(_GLFWwindow* window, GLFWbool enabled); +void _glfwSetWindowFloatingNull(_GLFWwindow* window, GLFWbool enabled); +void _glfwSetWindowMousePassthroughNull(_GLFWwindow* window, GLFWbool enabled); +float _glfwGetWindowOpacityNull(_GLFWwindow* window); +void _glfwSetWindowOpacityNull(_GLFWwindow* window, float opacity); +void _glfwSetRawMouseMotionNull(_GLFWwindow *window, GLFWbool enabled); +GLFWbool _glfwRawMouseMotionSupportedNull(void); +void _glfwShowWindowNull(_GLFWwindow* window); +void _glfwRequestWindowAttentionNull(_GLFWwindow* window); +void _glfwRequestWindowAttentionNull(_GLFWwindow* window); +void _glfwUnhideWindowNull(_GLFWwindow* window); +void _glfwHideWindowNull(_GLFWwindow* window); +void _glfwFocusWindowNull(_GLFWwindow* window); +int _glfwWindowFocusedNull(_GLFWwindow* window); +int _glfwWindowIconifiedNull(_GLFWwindow* window); +int _glfwWindowVisibleNull(_GLFWwindow* window); +void _glfwPollEventsNull(void); +void _glfwWaitEventsNull(void); +void _glfwWaitEventsTimeoutNull(double timeout); +void _glfwPostEmptyEventNull(void); +void _glfwGetCursorPosNull(_GLFWwindow* window, double* xpos, double* ypos); +void _glfwSetCursorPosNull(_GLFWwindow* window, double x, double y); +void _glfwSetCursorModeNull(_GLFWwindow* window, int mode); +int _glfwCreateCursorNull(_GLFWcursor* cursor, const GLFWimage* image, int xhot, int yhot); +int _glfwCreateStandardCursorNull(_GLFWcursor* cursor, int shape); +void _glfwDestroyCursorNull(_GLFWcursor* cursor); +void _glfwSetCursorNull(_GLFWwindow* window, _GLFWcursor* cursor); +void _glfwSetClipboardStringNull(const char* string); +const char* _glfwGetClipboardStringNull(void); +const char* _glfwGetScancodeNameNull(int scancode); +int _glfwGetKeyScancodeNull(int key); + +EGLenum _glfwGetEGLPlatformNull(EGLint** attribs); +EGLNativeDisplayType _glfwGetEGLNativeDisplayNull(void); +EGLNativeWindowType _glfwGetEGLNativeWindowNull(_GLFWwindow* window); + +void _glfwGetRequiredInstanceExtensionsNull(char** extensions); +int _glfwGetPhysicalDevicePresentationSupportNull(VkInstance instance, VkPhysicalDevice device, uint32_t queuefamily); +VkResult _glfwCreateWindowSurfaceNull(VkInstance instance, _GLFWwindow* window, const VkAllocationCallbacks* allocator, VkSurfaceKHR* surface); + +void _glfwPollMonitorsNull(void); + diff --git a/src/null_window.c b/src/null_window.c index 6a251153..10c5293f 100644 --- a/src/null_window.c +++ b/src/null_window.c @@ -53,10 +53,10 @@ static void applySizeLimits(_GLFWwindow* window, int* width, int* height) static void fitToMonitor(_GLFWwindow* window) { GLFWvidmode mode; - _glfwPlatformGetVideoMode(window->monitor, &mode); - _glfwPlatformGetMonitorPos(window->monitor, - &window->null.xpos, - &window->null.ypos); + _glfwGetVideoModeNull(window->monitor, &mode); + _glfwGetMonitorPosNull(window->monitor, + &window->null.xpos, + &window->null.ypos); window->null.width = mode.width; window->null.height = mode.height; } @@ -103,10 +103,10 @@ static int createNativeWindow(_GLFWwindow* window, ////// GLFW platform API ////// ////////////////////////////////////////////////////////////////////////// -int _glfwPlatformCreateWindow(_GLFWwindow* window, - const _GLFWwndconfig* wndconfig, - const _GLFWctxconfig* ctxconfig, - const _GLFWfbconfig* fbconfig) +int _glfwCreateWindowNull(_GLFWwindow* window, + const _GLFWwndconfig* wndconfig, + const _GLFWctxconfig* ctxconfig, + const _GLFWfbconfig* fbconfig) { if (!createNativeWindow(window, wndconfig, fbconfig)) return GLFW_FALSE; @@ -132,15 +132,15 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window, if (window->monitor) { - _glfwPlatformShowWindow(window); - _glfwPlatformFocusWindow(window); + _glfwShowWindowNull(window); + _glfwFocusWindowNull(window); acquireMonitor(window); } return GLFW_TRUE; } -void _glfwPlatformDestroyWindow(_GLFWwindow* window) +void _glfwDestroyWindowNull(_GLFWwindow* window) { if (window->monitor) releaseMonitor(window); @@ -152,27 +152,26 @@ void _glfwPlatformDestroyWindow(_GLFWwindow* window) window->context.destroy(window); } -void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title) +void _glfwSetWindowTitleNull(_GLFWwindow* window, const char* title) { } -void _glfwPlatformSetWindowIcon(_GLFWwindow* window, int count, - const GLFWimage* images) +void _glfwSetWindowIconNull(_GLFWwindow* window, int count, const GLFWimage* images) { } -void _glfwPlatformSetWindowMonitor(_GLFWwindow* window, - _GLFWmonitor* monitor, - int xpos, int ypos, - int width, int height, - int refreshRate) +void _glfwSetWindowMonitorNull(_GLFWwindow* window, + _GLFWmonitor* monitor, + int xpos, int ypos, + int width, int height, + int refreshRate) { if (window->monitor == monitor) { if (!monitor) { - _glfwPlatformSetWindowPos(window, xpos, ypos); - _glfwPlatformSetWindowSize(window, width, height); + _glfwSetWindowPosNull(window, xpos, ypos); + _glfwSetWindowSizeNull(window, width, height); } return; @@ -191,12 +190,12 @@ void _glfwPlatformSetWindowMonitor(_GLFWwindow* window, } else { - _glfwPlatformSetWindowPos(window, xpos, ypos); - _glfwPlatformSetWindowSize(window, width, height); + _glfwSetWindowPosNull(window, xpos, ypos); + _glfwSetWindowSizeNull(window, width, height); } } -void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos) +void _glfwGetWindowPosNull(_GLFWwindow* window, int* xpos, int* ypos) { if (xpos) *xpos = window->null.xpos; @@ -204,7 +203,7 @@ void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos) *ypos = window->null.ypos; } -void _glfwPlatformSetWindowPos(_GLFWwindow* window, int xpos, int ypos) +void _glfwSetWindowPosNull(_GLFWwindow* window, int xpos, int ypos) { if (window->monitor) return; @@ -217,7 +216,7 @@ void _glfwPlatformSetWindowPos(_GLFWwindow* window, int xpos, int ypos) } } -void _glfwPlatformGetWindowSize(_GLFWwindow* window, int* width, int* height) +void _glfwGetWindowSizeNull(_GLFWwindow* window, int* width, int* height) { if (width) *width = window->null.width; @@ -225,7 +224,7 @@ void _glfwPlatformGetWindowSize(_GLFWwindow* window, int* width, int* height) *height = window->null.height; } -void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height) +void _glfwSetWindowSizeNull(_GLFWwindow* window, int width, int height) { if (window->monitor) return; @@ -239,25 +238,25 @@ void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height) } } -void _glfwPlatformSetWindowSizeLimits(_GLFWwindow* window, - int minwidth, int minheight, - int maxwidth, int maxheight) +void _glfwSetWindowSizeLimitsNull(_GLFWwindow* window, + int minwidth, int minheight, + int maxwidth, int maxheight) { int width = window->null.width; int height = window->null.height; applySizeLimits(window, &width, &height); - _glfwPlatformSetWindowSize(window, width, height); + _glfwSetWindowSizeNull(window, width, height); } -void _glfwPlatformSetWindowAspectRatio(_GLFWwindow* window, int n, int d) +void _glfwSetWindowAspectRatioNull(_GLFWwindow* window, int n, int d) { int width = window->null.width; int height = window->null.height; applySizeLimits(window, &width, &height); - _glfwPlatformSetWindowSize(window, width, height); + _glfwSetWindowSizeNull(window, width, height); } -void _glfwPlatformGetFramebufferSize(_GLFWwindow* window, int* width, int* height) +void _glfwGetFramebufferSizeNull(_GLFWwindow* window, int* width, int* height) { if (width) *width = window->null.width; @@ -265,9 +264,9 @@ void _glfwPlatformGetFramebufferSize(_GLFWwindow* window, int* width, int* heigh *height = window->null.height; } -void _glfwPlatformGetWindowFrameSize(_GLFWwindow* window, - int* left, int* top, - int* right, int* bottom) +void _glfwGetWindowFrameSizeNull(_GLFWwindow* window, + int* left, int* top, + int* right, int* bottom) { if (window->null.decorated && !window->monitor) { @@ -293,8 +292,7 @@ void _glfwPlatformGetWindowFrameSize(_GLFWwindow* window, } } -void _glfwPlatformGetWindowContentScale(_GLFWwindow* window, - float* xscale, float* yscale) +void _glfwGetWindowContentScaleNull(_GLFWwindow* window, float* xscale, float* yscale) { if (xscale) *xscale = 1.f; @@ -302,7 +300,7 @@ void _glfwPlatformGetWindowContentScale(_GLFWwindow* window, *yscale = 1.f; } -void _glfwPlatformIconifyWindow(_GLFWwindow* window) +void _glfwIconifyWindowNull(_GLFWwindow* window) { if (_glfw.null.focusedWindow == window) { @@ -320,7 +318,7 @@ void _glfwPlatformIconifyWindow(_GLFWwindow* window) } } -void _glfwPlatformRestoreWindow(_GLFWwindow* window) +void _glfwRestoreWindowNull(_GLFWwindow* window) { if (window->null.iconified) { @@ -337,7 +335,7 @@ void _glfwPlatformRestoreWindow(_GLFWwindow* window) } } -void _glfwPlatformMaximizeWindow(_GLFWwindow* window) +void _glfwMaximizeWindowNull(_GLFWwindow* window) { if (!window->null.maximized) { @@ -346,12 +344,12 @@ void _glfwPlatformMaximizeWindow(_GLFWwindow* window) } } -int _glfwPlatformWindowMaximized(_GLFWwindow* window) +int _glfwWindowMaximizedNull(_GLFWwindow* window) { return window->null.maximized; } -int _glfwPlatformWindowHovered(_GLFWwindow* window) +int _glfwWindowHoveredNull(_GLFWwindow* window) { return _glfw.null.xcursor >= window->null.xpos && _glfw.null.ycursor >= window->null.ypos && @@ -359,59 +357,63 @@ int _glfwPlatformWindowHovered(_GLFWwindow* window) _glfw.null.ycursor <= window->null.ypos + window->null.height - 1; } -int _glfwPlatformFramebufferTransparent(_GLFWwindow* window) +int _glfwFramebufferTransparentNull(_GLFWwindow* window) { return window->null.transparent; } -void _glfwPlatformSetWindowResizable(_GLFWwindow* window, GLFWbool enabled) +void _glfwSetWindowResizableNull(_GLFWwindow* window, GLFWbool enabled) { window->null.resizable = enabled; } -void _glfwPlatformSetWindowDecorated(_GLFWwindow* window, GLFWbool enabled) +void _glfwSetWindowDecoratedNull(_GLFWwindow* window, GLFWbool enabled) { window->null.decorated = enabled; } -void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled) +void _glfwSetWindowFloatingNull(_GLFWwindow* window, GLFWbool enabled) { window->null.floating = enabled; } -void _glfwPlatformSetWindowMousePassthrough(_GLFWwindow* window, GLFWbool enabled) +void _glfwSetWindowMousePassthroughNull(_GLFWwindow* window, GLFWbool enabled) { } -float _glfwPlatformGetWindowOpacity(_GLFWwindow* window) +float _glfwGetWindowOpacityNull(_GLFWwindow* window) { return window->null.opacity; } -void _glfwPlatformSetWindowOpacity(_GLFWwindow* window, float opacity) +void _glfwSetWindowOpacityNull(_GLFWwindow* window, float opacity) { window->null.opacity = opacity; } -void _glfwPlatformSetRawMouseMotion(_GLFWwindow *window, GLFWbool enabled) +void _glfwSetRawMouseMotionNull(_GLFWwindow *window, GLFWbool enabled) { } -GLFWbool _glfwPlatformRawMouseMotionSupported(void) +GLFWbool _glfwRawMouseMotionSupportedNull(void) { return GLFW_TRUE; } -void _glfwPlatformShowWindow(_GLFWwindow* window) +void _glfwShowWindowNull(_GLFWwindow* window) { window->null.visible = GLFW_TRUE; } -void _glfwPlatformRequestWindowAttention(_GLFWwindow* window) +void _glfwRequestWindowAttentionNull(_GLFWwindow* window) { } -void _glfwPlatformHideWindow(_GLFWwindow* window) +void _glfwUnhideWindowNull(_GLFWwindow* window) +{ +} + +void _glfwHideWindowNull(_GLFWwindow* window) { if (_glfw.null.focusedWindow == window) { @@ -422,59 +424,61 @@ void _glfwPlatformHideWindow(_GLFWwindow* window) window->null.visible = GLFW_FALSE; } -void _glfwPlatformFocusWindow(_GLFWwindow* window) +void _glfwFocusWindowNull(_GLFWwindow* window) { + _GLFWwindow* previous; + if (_glfw.null.focusedWindow == window) return; if (!window->null.visible) return; - _GLFWwindow* previous = _glfw.null.focusedWindow; + previous = _glfw.null.focusedWindow; _glfw.null.focusedWindow = window; if (previous) { _glfwInputWindowFocus(previous, GLFW_FALSE); if (previous->monitor && previous->autoIconify) - _glfwPlatformIconifyWindow(previous); + _glfwIconifyWindowNull(previous); } _glfwInputWindowFocus(window, GLFW_TRUE); } -int _glfwPlatformWindowFocused(_GLFWwindow* window) +int _glfwWindowFocusedNull(_GLFWwindow* window) { return _glfw.null.focusedWindow == window; } -int _glfwPlatformWindowIconified(_GLFWwindow* window) +int _glfwWindowIconifiedNull(_GLFWwindow* window) { return window->null.iconified; } -int _glfwPlatformWindowVisible(_GLFWwindow* window) +int _glfwWindowVisibleNull(_GLFWwindow* window) { return window->null.visible; } -void _glfwPlatformPollEvents(void) +void _glfwPollEventsNull(void) { } -void _glfwPlatformWaitEvents(void) +void _glfwWaitEventsNull(void) { } -void _glfwPlatformWaitEventsTimeout(double timeout) +void _glfwWaitEventsTimeoutNull(double timeout) { } -void _glfwPlatformPostEmptyEvent(void) +void _glfwPostEmptyEventNull(void) { } -void _glfwPlatformGetCursorPos(_GLFWwindow* window, double* xpos, double* ypos) +void _glfwGetCursorPosNull(_GLFWwindow* window, double* xpos, double* ypos) { if (xpos) *xpos = _glfw.null.xcursor - window->null.xpos; @@ -482,64 +486,64 @@ void _glfwPlatformGetCursorPos(_GLFWwindow* window, double* xpos, double* ypos) *ypos = _glfw.null.ycursor - window->null.ypos; } -void _glfwPlatformSetCursorPos(_GLFWwindow* window, double x, double y) +void _glfwSetCursorPosNull(_GLFWwindow* window, double x, double y) { _glfw.null.xcursor = window->null.xpos + (int) x; _glfw.null.ycursor = window->null.ypos + (int) y; } -void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode) +void _glfwSetCursorModeNull(_GLFWwindow* window, int mode) { } -int _glfwPlatformCreateCursor(_GLFWcursor* cursor, - const GLFWimage* image, - int xhot, int yhot) +int _glfwCreateCursorNull(_GLFWcursor* cursor, + const GLFWimage* image, + int xhot, int yhot) { return GLFW_TRUE; } -int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape) +int _glfwCreateStandardCursorNull(_GLFWcursor* cursor, int shape) { return GLFW_TRUE; } -void _glfwPlatformDestroyCursor(_GLFWcursor* cursor) +void _glfwDestroyCursorNull(_GLFWcursor* cursor) { } -void _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor) +void _glfwSetCursorNull(_GLFWwindow* window, _GLFWcursor* cursor) { } -void _glfwPlatformSetClipboardString(const char* string) +void _glfwSetClipboardStringNull(const char* string) { char* copy = _glfw_strdup(string); _glfw_free(_glfw.null.clipboardString); _glfw.null.clipboardString = copy; } -const char* _glfwPlatformGetClipboardString(void) +const char* _glfwGetClipboardStringNull(void) { return _glfw.null.clipboardString; } -EGLenum _glfwPlatformGetEGLPlatform(EGLint** attribs) +EGLenum _glfwGetEGLPlatformNull(EGLint** attribs) { return 0; } -EGLNativeDisplayType _glfwPlatformGetEGLNativeDisplay(void) +EGLNativeDisplayType _glfwGetEGLNativeDisplayNull(void) { return 0; } -EGLNativeWindowType _glfwPlatformGetEGLNativeWindow(_GLFWwindow* window) +EGLNativeWindowType _glfwGetEGLNativeWindowNull(_GLFWwindow* window) { return 0; } -const char* _glfwPlatformGetScancodeName(int scancode) +const char* _glfwGetScancodeNameNull(int scancode) { if (scancode < GLFW_KEY_SPACE || scancode > GLFW_KEY_LAST) { @@ -666,26 +670,26 @@ const char* _glfwPlatformGetScancodeName(int scancode) return NULL; } -int _glfwPlatformGetKeyScancode(int key) +int _glfwGetKeyScancodeNull(int key) { return key; } -void _glfwPlatformGetRequiredInstanceExtensions(char** extensions) +void _glfwGetRequiredInstanceExtensionsNull(char** extensions) { } -int _glfwPlatformGetPhysicalDevicePresentationSupport(VkInstance instance, - VkPhysicalDevice device, - uint32_t queuefamily) +int _glfwGetPhysicalDevicePresentationSupportNull(VkInstance instance, + VkPhysicalDevice device, + uint32_t queuefamily) { return GLFW_FALSE; } -VkResult _glfwPlatformCreateWindowSurface(VkInstance instance, - _GLFWwindow* window, - const VkAllocationCallbacks* allocator, - VkSurfaceKHR* surface) +VkResult _glfwCreateWindowSurfaceNull(VkInstance instance, + _GLFWwindow* window, + const VkAllocationCallbacks* allocator, + VkSurfaceKHR* surface) { // This seems like the most appropriate error to return here return VK_ERROR_EXTENSION_NOT_PRESENT; diff --git a/src/osmesa_context.c b/src/osmesa_context.c index 0bae30c9..cf742f89 100644 --- a/src/osmesa_context.c +++ b/src/osmesa_context.c @@ -39,7 +39,7 @@ static void makeContextCurrentOSMesa(_GLFWwindow* window) if (window) { int width, height; - _glfwPlatformGetFramebufferSize(window, &width, &height); + _glfw.platform.getFramebufferSize(window, &width, &height); // Check to see if we need to allocate a new buffer if ((window->context.osmesa.buffer == NULL) || diff --git a/src/platform.c b/src/platform.c new file mode 100644 index 00000000..34fb7acd --- /dev/null +++ b/src/platform.c @@ -0,0 +1,184 @@ +//======================================================================== +// GLFW 3.4 - www.glfw.org +//------------------------------------------------------------------------ +// Copyright (c) 2002-2006 Marcus Geelnard +// Copyright (c) 2006-2018 Camilla Löwy +// +// This software is provided 'as-is', without any express or implied +// warranty. In no event will the authors be held liable for any damages +// arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it +// freely, subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; you must not +// claim that you wrote the original software. If you use this software +// in a product, an acknowledgment in the product documentation would +// be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, and must not +// be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source +// distribution. +// +//======================================================================== +// Please use C89 style variable declarations in this file because VS 2010 +//======================================================================== + +#include "internal.h" + +////////////////////////////////////////////////////////////////////////// +////// GLFW internal API ////// +////////////////////////////////////////////////////////////////////////// + +static const struct +{ + int ID; + GLFWbool (*connect)(int,_GLFWplatform*); +} supportedPlatforms[] = +{ +#if defined(_GLFW_WIN32) + { GLFW_PLATFORM_WIN32, _glfwConnectWin32 }, +#endif +#if defined(_GLFW_COCOA) + { GLFW_PLATFORM_COCOA, _glfwConnectCocoa }, +#endif +#if defined(_GLFW_X11) + { GLFW_PLATFORM_X11, _glfwConnectX11 }, +#endif +#if defined(_GLFW_WAYLAND) + { GLFW_PLATFORM_WAYLAND, _glfwConnectWayland }, +#endif +}; + +GLFWbool _glfwSelectPlatform(int desiredID, _GLFWplatform* platform) +{ + const size_t count = sizeof(supportedPlatforms) / sizeof(supportedPlatforms[0]); + size_t i; + + if (desiredID != GLFW_ANY_PLATFORM && + desiredID != GLFW_PLATFORM_WIN32 && + desiredID != GLFW_PLATFORM_COCOA && + desiredID != GLFW_PLATFORM_WAYLAND && + desiredID != GLFW_PLATFORM_X11 && + desiredID != GLFW_PLATFORM_NULL) + { + _glfwInputError(GLFW_INVALID_ENUM, "Invalid platform ID 0x%08X", desiredID); + return GLFW_FALSE; + } + + // Only allow the Null platform if specifically requested + if (desiredID == GLFW_PLATFORM_NULL) + return _glfwConnectNull(desiredID, platform); + + // If there is only one platform available for auto-selection, let it emit the error + // on failure as the platform-specific error description may be more helpful + if (desiredID == GLFW_ANY_PLATFORM && count == 1) + return supportedPlatforms[0].connect(supportedPlatforms[0].ID, platform); + + for (i = 0; i < count; i++) + { + if (desiredID == GLFW_ANY_PLATFORM || desiredID == supportedPlatforms[i].ID) + { + if (supportedPlatforms[i].connect(desiredID, platform)) + return GLFW_TRUE; + else if (desiredID == supportedPlatforms[i].ID) + return GLFW_FALSE; + } + } + + if (desiredID == GLFW_ANY_PLATFORM) + { + if (count) + _glfwInputError(GLFW_PLATFORM_UNAVAILABLE, "Failed to detect any supported platform"); + else + _glfwInputError(GLFW_PLATFORM_UNAVAILABLE, "This binary only supports the Null platform"); + } + else + _glfwInputError(GLFW_PLATFORM_UNAVAILABLE, "The requested platform is not supported"); + + return GLFW_FALSE; +} + +////////////////////////////////////////////////////////////////////////// +////// GLFW public API ////// +////////////////////////////////////////////////////////////////////////// + +GLFWAPI int glfwGetPlatform(void) +{ + _GLFW_REQUIRE_INIT_OR_RETURN(0); + return _glfw.platform.platformID; +} + +GLFWAPI int glfwPlatformSupported(int platformID) +{ + const size_t count = sizeof(supportedPlatforms) / sizeof(supportedPlatforms[0]); + size_t i; + + if (platformID != GLFW_PLATFORM_WIN32 && + platformID != GLFW_PLATFORM_COCOA && + platformID != GLFW_PLATFORM_WAYLAND && + platformID != GLFW_PLATFORM_X11 && + platformID != GLFW_PLATFORM_NULL) + { + _glfwInputError(GLFW_INVALID_ENUM, "Invalid platform ID 0x%08X", platformID); + return GLFW_FALSE; + } + + if (platformID == GLFW_PLATFORM_NULL) + return GLFW_TRUE; + + for (i = 0; i < count; i++) + { + if (platformID == supportedPlatforms[i].ID) + return GLFW_TRUE; + } + + return GLFW_FALSE; +} + +GLFWAPI const char* glfwGetVersionString(void) +{ + return _GLFW_VERSION_NUMBER +#if defined(_GLFW_WIN32) + " Win32 WGL" +#endif +#if defined(_GLFW_COCOA) + " Cocoa NSGL" +#endif +#if defined(_GLFW_WAYLAND) + " Wayland" +#endif +#if defined(_GLFW_X11) + " X11 GLX" +#endif + " Null" + " EGL" + " OSMesa" +#if defined(__MINGW64_VERSION_MAJOR) + " MinGW-w64" +#elif defined(__MINGW32__) + " MinGW" +#elif defined(_MSC_VER) + " VisualC" +#endif +#if defined(_GLFW_USE_HYBRID_HPG) || defined(_GLFW_USE_OPTIMUS_HPG) + " hybrid-GPU" +#endif +#if defined(_POSIX_MONOTONIC_CLOCK) + " monotonic" +#endif +#if defined(_GLFW_BUILD_DLL) +#if defined(_WIN32) + " DLL" +#elif defined(__APPLE__) + " dynamic" +#else + " shared" +#endif +#endif + ; +} + diff --git a/src/platform.h b/src/platform.h new file mode 100644 index 00000000..cc842eb8 --- /dev/null +++ b/src/platform.h @@ -0,0 +1,179 @@ +//======================================================================== +// GLFW 3.4 - www.glfw.org +//------------------------------------------------------------------------ +// Copyright (c) 2002-2006 Marcus Geelnard +// Copyright (c) 2006-2018 Camilla Löwy +// +// This software is provided 'as-is', without any express or implied +// warranty. In no event will the authors be held liable for any damages +// arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it +// freely, subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; you must not +// claim that you wrote the original software. If you use this software +// in a product, an acknowledgment in the product documentation would +// be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, and must not +// be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source +// distribution. +// +//======================================================================== + +#include "null_platform.h" + +#if defined(_GLFW_WIN32) + #include "win32_platform.h" +#else + #define GLFW_WIN32_WINDOW_STATE + #define GLFW_WIN32_MONITOR_STATE + #define GLFW_WIN32_CURSOR_STATE + #define GLFW_WIN32_LIBRARY_WINDOW_STATE + #define GLFW_WGL_CONTEXT_STATE + #define GLFW_WGL_LIBRARY_CONTEXT_STATE +#endif + +#if defined(_GLFW_COCOA) + #include "cocoa_platform.h" +#else + #define GLFW_COCOA_WINDOW_STATE + #define GLFW_COCOA_MONITOR_STATE + #define GLFW_COCOA_CURSOR_STATE + #define GLFW_COCOA_LIBRARY_WINDOW_STATE + #define GLFW_NSGL_CONTEXT_STATE + #define GLFW_NSGL_LIBRARY_CONTEXT_STATE +#endif + +#if defined(_GLFW_WAYLAND) + #include "wl_platform.h" +#else + #define GLFW_WAYLAND_WINDOW_STATE + #define GLFW_WAYLAND_MONITOR_STATE + #define GLFW_WAYLAND_CURSOR_STATE + #define GLFW_WAYLAND_LIBRARY_WINDOW_STATE +#endif + +#if defined(_GLFW_X11) + #include "x11_platform.h" +#else + #define GLFW_X11_WINDOW_STATE + #define GLFW_X11_MONITOR_STATE + #define GLFW_X11_CURSOR_STATE + #define GLFW_X11_LIBRARY_WINDOW_STATE + #define GLFW_GLX_CONTEXT_STATE + #define GLFW_GLX_LIBRARY_CONTEXT_STATE +#endif + +#include "null_joystick.h" + +#if defined(_GLFW_WIN32) + #include "win32_joystick.h" +#else + #define GLFW_WIN32_JOYSTICK_STATE + #define GLFW_WIN32_LIBRARY_JOYSTICK_STATE +#endif + +#if defined(_GLFW_COCOA) + #include "cocoa_joystick.h" +#else + #define GLFW_COCOA_JOYSTICK_STATE + #define GLFW_COCOA_LIBRARY_JOYSTICK_STATE +#endif + +#if (defined(_GLFW_X11) || defined(_GLFW_WAYLAND)) && defined(__linux__) + #include "linux_joystick.h" +#else + #define GLFW_LINUX_JOYSTICK_STATE + #define GLFW_LINUX_LIBRARY_JOYSTICK_STATE +#endif + +#if defined(_WIN32) + #include "win32_thread.h" + #define GLFW_POSIX_TLS_STATE + #define GLFW_POSIX_MUTEX_STATE +#else + #include "posix_thread.h" + #define GLFW_WIN32_TLS_STATE + #define GLFW_WIN32_MUTEX_STATE +#endif + +#if defined(_WIN32) + #include "win32_time.h" + #define GLFW_POSIX_LIBRARY_TIMER_STATE + #define GLFW_COCOA_LIBRARY_TIMER_STATE +#elif defined(__APPLE__) + #include "cocoa_time.h" + #define GLFW_WIN32_LIBRARY_TIMER_STATE + #define GLFW_POSIX_LIBRARY_TIMER_STATE +#else + #include "posix_time.h" + #define GLFW_WIN32_LIBRARY_TIMER_STATE + #define GLFW_COCOA_LIBRARY_TIMER_STATE +#endif + +#define GLFW_PLATFORM_WINDOW_STATE \ + GLFW_WIN32_WINDOW_STATE \ + GLFW_COCOA_WINDOW_STATE \ + GLFW_WAYLAND_WINDOW_STATE \ + GLFW_X11_WINDOW_STATE \ + GLFW_NULL_WINDOW_STATE \ + +#define GLFW_PLATFORM_MONITOR_STATE \ + GLFW_WIN32_MONITOR_STATE \ + GLFW_COCOA_MONITOR_STATE \ + GLFW_WAYLAND_MONITOR_STATE \ + GLFW_X11_MONITOR_STATE \ + GLFW_NULL_MONITOR_STATE \ + +#define GLFW_PLATFORM_CURSOR_STATE \ + GLFW_WIN32_CURSOR_STATE \ + GLFW_COCOA_CURSOR_STATE \ + GLFW_WAYLAND_CURSOR_STATE \ + GLFW_X11_CURSOR_STATE \ + GLFW_NULL_CURSOR_STATE \ + +#define GLFW_PLATFORM_JOYSTICK_STATE \ + GLFW_WIN32_JOYSTICK_STATE \ + GLFW_COCOA_JOYSTICK_STATE \ + GLFW_LINUX_JOYSTICK_STATE + +#define GLFW_PLATFORM_TLS_STATE \ + GLFW_WIN32_TLS_STATE \ + GLFW_POSIX_TLS_STATE \ + +#define GLFW_PLATFORM_MUTEX_STATE \ + GLFW_WIN32_MUTEX_STATE \ + GLFW_POSIX_MUTEX_STATE \ + +#define GLFW_PLATFORM_LIBRARY_WINDOW_STATE \ + GLFW_WIN32_LIBRARY_WINDOW_STATE \ + GLFW_COCOA_LIBRARY_WINDOW_STATE \ + GLFW_WAYLAND_LIBRARY_WINDOW_STATE \ + GLFW_X11_LIBRARY_WINDOW_STATE \ + GLFW_NULL_LIBRARY_WINDOW_STATE \ + +#define GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE \ + GLFW_WIN32_LIBRARY_JOYSTICK_STATE \ + GLFW_COCOA_LIBRARY_JOYSTICK_STATE \ + GLFW_LINUX_LIBRARY_JOYSTICK_STATE + +#define GLFW_PLATFORM_LIBRARY_TIMER_STATE \ + GLFW_WIN32_LIBRARY_TIMER_STATE \ + GLFW_COCOA_LIBRARY_TIMER_STATE \ + GLFW_POSIX_LIBRARY_TIMER_STATE \ + +#define GLFW_PLATFORM_CONTEXT_STATE \ + GLFW_WGL_CONTEXT_STATE \ + GLFW_NSGL_CONTEXT_STATE \ + GLFW_GLX_CONTEXT_STATE + +#define GLFW_PLATFORM_LIBRARY_CONTEXT_STATE \ + GLFW_WGL_LIBRARY_CONTEXT_STATE \ + GLFW_NSGL_LIBRARY_CONTEXT_STATE \ + GLFW_GLX_LIBRARY_CONTEXT_STATE + diff --git a/src/posix_thread.h b/src/posix_thread.h index bfb325af..5a5d7b7c 100644 --- a/src/posix_thread.h +++ b/src/posix_thread.h @@ -27,8 +27,8 @@ #include -#define _GLFW_PLATFORM_TLS_STATE _GLFWtlsPOSIX posix -#define _GLFW_PLATFORM_MUTEX_STATE _GLFWmutexPOSIX posix +#define GLFW_POSIX_TLS_STATE _GLFWtlsPOSIX posix; +#define GLFW_POSIX_MUTEX_STATE _GLFWmutexPOSIX posix; // POSIX-specific thread local storage data diff --git a/src/posix_time.h b/src/posix_time.h index 6fd15b06..94374adb 100644 --- a/src/posix_time.h +++ b/src/posix_time.h @@ -25,7 +25,7 @@ // //======================================================================== -#define _GLFW_PLATFORM_LIBRARY_TIMER_STATE _GLFWtimerPOSIX posix +#define GLFW_POSIX_LIBRARY_TIMER_STATE _GLFWtimerPOSIX posix; #include #include diff --git a/src/vulkan.c b/src/vulkan.c index ad299e5e..51789249 100644 --- a/src/vulkan.c +++ b/src/vulkan.c @@ -58,7 +58,7 @@ GLFWbool _glfwInitVulkan(int mode) #elif defined(_GLFW_COCOA) _glfw.vk.handle = _glfwPlatformLoadModule("libvulkan.1.dylib"); if (!_glfw.vk.handle) - _glfw.vk.handle = _glfwLoadLocalVulkanLoaderNS(); + _glfw.vk.handle = _glfwLoadLocalVulkanLoaderCocoa(); #else _glfw.vk.handle = _glfwPlatformLoadModule("libvulkan.so.1"); #endif @@ -126,30 +126,25 @@ GLFWbool _glfwInitVulkan(int mode) { if (strcmp(ep[i].extensionName, "VK_KHR_surface") == 0) _glfw.vk.KHR_surface = GLFW_TRUE; -#if defined(_GLFW_WIN32) else if (strcmp(ep[i].extensionName, "VK_KHR_win32_surface") == 0) _glfw.vk.KHR_win32_surface = GLFW_TRUE; -#elif defined(_GLFW_COCOA) else if (strcmp(ep[i].extensionName, "VK_MVK_macos_surface") == 0) _glfw.vk.MVK_macos_surface = GLFW_TRUE; else if (strcmp(ep[i].extensionName, "VK_EXT_metal_surface") == 0) _glfw.vk.EXT_metal_surface = GLFW_TRUE; -#elif defined(_GLFW_X11) else if (strcmp(ep[i].extensionName, "VK_KHR_xlib_surface") == 0) _glfw.vk.KHR_xlib_surface = GLFW_TRUE; else if (strcmp(ep[i].extensionName, "VK_KHR_xcb_surface") == 0) _glfw.vk.KHR_xcb_surface = GLFW_TRUE; -#elif defined(_GLFW_WAYLAND) else if (strcmp(ep[i].extensionName, "VK_KHR_wayland_surface") == 0) _glfw.vk.KHR_wayland_surface = GLFW_TRUE; -#endif } _glfw_free(ep); _glfw.vk.available = GLFW_TRUE; - _glfwPlatformGetRequiredInstanceExtensions(_glfw.vk.extensions); + _glfw.platform.getRequiredInstanceExtensions(_glfw.vk.extensions); return GLFW_TRUE; } @@ -291,9 +286,9 @@ GLFWAPI int glfwGetPhysicalDevicePresentationSupport(VkInstance instance, return GLFW_FALSE; } - return _glfwPlatformGetPhysicalDevicePresentationSupport(instance, - device, - queuefamily); + return _glfw.platform.getPhysicalDevicePresentationSupport(instance, + device, + queuefamily); } GLFWAPI VkResult glfwCreateWindowSurface(VkInstance instance, @@ -327,6 +322,6 @@ GLFWAPI VkResult glfwCreateWindowSurface(VkInstance instance, return VK_ERROR_NATIVE_WINDOW_IN_USE_KHR; } - return _glfwPlatformCreateWindowSurface(instance, window, allocator, surface); + return _glfw.platform.createWindowSurface(instance, window, allocator, surface); } diff --git a/src/wgl_context.c b/src/wgl_context.c index a7b3ec7b..774f45bd 100644 --- a/src/wgl_context.c +++ b/src/wgl_context.c @@ -34,10 +34,10 @@ // Return the value corresponding to the specified attribute // -static int findPixelFormatAttribValue(const int* attribs, - int attribCount, - const int* values, - int attrib) +static int findPixelFormatAttribValueWGL(const int* attribs, + int attribCount, + const int* values, + int attrib) { int i; @@ -58,13 +58,13 @@ static int findPixelFormatAttribValue(const int* attribs, attribs[attribCount++] = a; \ } #define findAttribValue(a) \ - findPixelFormatAttribValue(attribs, attribCount, values, a) + findPixelFormatAttribValueWGL(attribs, attribCount, values, a) // Return a list of available and usable framebuffer configs // -static int choosePixelFormat(_GLFWwindow* window, - const _GLFWctxconfig* ctxconfig, - const _GLFWfbconfig* fbconfig) +static int choosePixelFormatWGL(_GLFWwindow* window, + const _GLFWctxconfig* ctxconfig, + const _GLFWfbconfig* fbconfig) { _GLFWfbconfig* usableConfigs; const _GLFWfbconfig* closest; @@ -399,11 +399,6 @@ static void destroyContextWGL(_GLFWwindow* window) } } - -////////////////////////////////////////////////////////////////////////// -////// GLFW internal API ////// -////////////////////////////////////////////////////////////////////////// - // Initialize WGL // GLFWbool _glfwInitWGL(void) @@ -561,7 +556,7 @@ GLFWbool _glfwCreateContextWGL(_GLFWwindow* window, return GLFW_FALSE; } - pixelFormat = choosePixelFormat(window, ctxconfig, fbconfig); + pixelFormat = choosePixelFormatWGL(window, ctxconfig, fbconfig); if (!pixelFormat) return GLFW_FALSE; @@ -776,16 +771,18 @@ GLFWbool _glfwCreateContextWGL(_GLFWwindow* window, #undef setAttrib - -////////////////////////////////////////////////////////////////////////// -////// GLFW native API ////// -////////////////////////////////////////////////////////////////////////// - GLFWAPI HGLRC glfwGetWGLContext(GLFWwindow* handle) { _GLFWwindow* window = (_GLFWwindow*) handle; _GLFW_REQUIRE_INIT_OR_RETURN(NULL); + if (_glfw.platform.platformID != GLFW_PLATFORM_WIN32) + { + _glfwInputError(GLFW_PLATFORM_UNAVAILABLE, + "WGL: Platform not initialized"); + return NULL; + } + if (window->context.client != GLFW_NATIVE_CONTEXT_API) { _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL); diff --git a/src/win32_init.c b/src/win32_init.c index 3441173f..e687d770 100644 --- a/src/win32_init.c +++ b/src/win32_init.c @@ -536,12 +536,89 @@ BOOL _glfwIsWindows10BuildOrGreaterWin32(WORD build) return RtlVerifyVersionInfo(&osvi, mask, cond) == 0; } +GLFWbool _glfwConnectWin32(int platformID, _GLFWplatform* platform) +{ + const _GLFWplatform win32 = + { + GLFW_PLATFORM_WIN32, + _glfwInitWin32, + _glfwTerminateWin32, + _glfwGetCursorPosWin32, + _glfwSetCursorPosWin32, + _glfwSetCursorModeWin32, + _glfwSetRawMouseMotionWin32, + _glfwRawMouseMotionSupportedWin32, + _glfwCreateCursorWin32, + _glfwCreateStandardCursorWin32, + _glfwDestroyCursorWin32, + _glfwSetCursorWin32, + _glfwGetScancodeNameWin32, + _glfwGetKeyScancodeWin32, + _glfwSetClipboardStringWin32, + _glfwGetClipboardStringWin32, + _glfwInitJoysticksWin32, + _glfwTerminateJoysticksWin32, + _glfwPollJoystickWin32, + _glfwGetMappingNameWin32, + _glfwUpdateGamepadGUIDWin32, + _glfwFreeMonitorWin32, + _glfwGetMonitorPosWin32, + _glfwGetMonitorContentScaleWin32, + _glfwGetMonitorWorkareaWin32, + _glfwGetVideoModesWin32, + _glfwGetVideoModeWin32, + _glfwGetGammaRampWin32, + _glfwSetGammaRampWin32, + _glfwCreateWindowWin32, + _glfwDestroyWindowWin32, + _glfwSetWindowTitleWin32, + _glfwSetWindowIconWin32, + _glfwGetWindowPosWin32, + _glfwSetWindowPosWin32, + _glfwGetWindowSizeWin32, + _glfwSetWindowSizeWin32, + _glfwSetWindowSizeLimitsWin32, + _glfwSetWindowAspectRatioWin32, + _glfwGetFramebufferSizeWin32, + _glfwGetWindowFrameSizeWin32, + _glfwGetWindowContentScaleWin32, + _glfwIconifyWindowWin32, + _glfwRestoreWindowWin32, + _glfwMaximizeWindowWin32, + _glfwShowWindowWin32, + _glfwHideWindowWin32, + _glfwRequestWindowAttentionWin32, + _glfwFocusWindowWin32, + _glfwSetWindowMonitorWin32, + _glfwWindowFocusedWin32, + _glfwWindowIconifiedWin32, + _glfwWindowVisibleWin32, + _glfwWindowMaximizedWin32, + _glfwWindowHoveredWin32, + _glfwFramebufferTransparentWin32, + _glfwGetWindowOpacityWin32, + _glfwSetWindowResizableWin32, + _glfwSetWindowDecoratedWin32, + _glfwSetWindowFloatingWin32, + _glfwSetWindowOpacityWin32, + _glfwSetWindowMousePassthroughWin32, + _glfwPollEventsWin32, + _glfwWaitEventsWin32, + _glfwWaitEventsTimeoutWin32, + _glfwPostEmptyEventWin32, + _glfwGetEGLPlatformWin32, + _glfwGetEGLNativeDisplayWin32, + _glfwGetEGLNativeWindowWin32, + _glfwGetRequiredInstanceExtensionsWin32, + _glfwGetPhysicalDevicePresentationSupportWin32, + _glfwCreateWindowSurfaceWin32, + }; -////////////////////////////////////////////////////////////////////////// -////// GLFW platform API ////// -////////////////////////////////////////////////////////////////////////// + *platform = win32; + return GLFW_TRUE; +} -int _glfwPlatformInit(void) +int _glfwInitWin32(void) { if (!loadLibraries()) return GLFW_FALSE; @@ -566,7 +643,7 @@ int _glfwPlatformInit(void) return GLFW_TRUE; } -void _glfwPlatformTerminate(void) +void _glfwTerminateWin32(void) { if (_glfw.win32.deviceNotificationHandle) UnregisterDeviceNotification(_glfw.win32.deviceNotificationHandle); @@ -585,22 +662,3 @@ void _glfwPlatformTerminate(void) freeLibraries(); } -const char* _glfwPlatformGetVersionString(void) -{ - return _GLFW_VERSION_NUMBER " Win32 WGL EGL OSMesa" -#if defined(__MINGW64_VERSION_MAJOR) - " MinGW-w64" -#elif defined(__MINGW32__) - " MinGW" -#elif defined(_MSC_VER) - " VisualC" -#endif -#if defined(_GLFW_USE_HYBRID_HPG) || defined(_GLFW_USE_OPTIMUS_HPG) - " hybrid-GPU" -#endif -#if defined(_GLFW_BUILD_DLL) - " DLL" -#endif - ; -} - diff --git a/src/win32_joystick.c b/src/win32_joystick.c index bb5ed1a3..e45e0798 100644 --- a/src/win32_joystick.c +++ b/src/win32_joystick.c @@ -561,7 +561,7 @@ void _glfwDetectJoystickDisconnectionWin32(void) { _GLFWjoystick* js = _glfw.joysticks + jid; if (js->present) - _glfwPlatformPollJoystick(js, _GLFW_POLL_PRESENCE); + _glfwPollJoystickWin32(js, _GLFW_POLL_PRESENCE); } } @@ -570,7 +570,7 @@ void _glfwDetectJoystickDisconnectionWin32(void) ////// GLFW platform API ////// ////////////////////////////////////////////////////////////////////////// -GLFWbool _glfwPlatformInitJoysticks(void) +GLFWbool _glfwInitJoysticksWin32(void) { if (_glfw.win32.dinput8.instance) { @@ -590,7 +590,7 @@ GLFWbool _glfwPlatformInitJoysticks(void) return GLFW_TRUE; } -void _glfwPlatformTerminateJoysticks(void) +void _glfwTerminateJoysticksWin32(void) { int jid; @@ -601,7 +601,7 @@ void _glfwPlatformTerminateJoysticks(void) IDirectInput8_Release(_glfw.win32.dinput8.api); } -int _glfwPlatformPollJoystick(_GLFWjoystick* js, int mode) +int _glfwPollJoystickWin32(_GLFWjoystick* js, int mode) { if (js->win32.device) { @@ -740,12 +740,12 @@ int _glfwPlatformPollJoystick(_GLFWjoystick* js, int mode) return GLFW_TRUE; } -const char* _glfwPlatformGetMappingName(void) +const char* _glfwGetMappingNameWin32(void) { return "Windows"; } -void _glfwPlatformUpdateGamepadGUID(char* guid) +void _glfwUpdateGamepadGUIDWin32(char* guid) { if (strcmp(guid + 20, "504944564944") == 0) { diff --git a/src/win32_joystick.h b/src/win32_joystick.h index b9bb6779..d7c2bb6f 100644 --- a/src/win32_joystick.h +++ b/src/win32_joystick.h @@ -24,8 +24,8 @@ // //======================================================================== -#define _GLFW_PLATFORM_JOYSTICK_STATE _GLFWjoystickWin32 win32 -#define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE struct { int dummyLibraryJoystick; } +#define GLFW_WIN32_JOYSTICK_STATE _GLFWjoystickWin32 win32; +#define GLFW_WIN32_LIBRARY_JOYSTICK_STATE #define GLFW_BUILD_WIN32_MAPPINGS diff --git a/src/win32_monitor.c b/src/win32_monitor.c index 10e3d282..17359a5f 100644 --- a/src/win32_monitor.c +++ b/src/win32_monitor.c @@ -253,7 +253,7 @@ void _glfwSetVideoModeWin32(_GLFWmonitor* monitor, const GLFWvidmode* desired) LONG result; best = _glfwChooseVideoMode(monitor, desired); - _glfwPlatformGetVideoMode(monitor, ¤t); + _glfwGetVideoModeWin32(monitor, ¤t); if (_glfwCompareVideoModes(¤t, best) == 0) return; @@ -313,7 +313,7 @@ void _glfwRestoreVideoModeWin32(_GLFWmonitor* monitor) } } -void _glfwGetMonitorContentScaleWin32(HMONITOR handle, float* xscale, float* yscale) +void _glfwGetHMONITORContentScaleWin32(HMONITOR handle, float* xscale, float* yscale) { UINT xdpi, ydpi; @@ -338,11 +338,11 @@ void _glfwGetMonitorContentScaleWin32(HMONITOR handle, float* xscale, float* ysc ////// GLFW platform API ////// ////////////////////////////////////////////////////////////////////////// -void _glfwPlatformFreeMonitor(_GLFWmonitor* monitor) +void _glfwFreeMonitorWin32(_GLFWmonitor* monitor) { } -void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos) +void _glfwGetMonitorPosWin32(_GLFWmonitor* monitor, int* xpos, int* ypos) { DEVMODEW dm; ZeroMemory(&dm, sizeof(dm)); @@ -359,15 +359,15 @@ void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos) *ypos = dm.dmPosition.y; } -void _glfwPlatformGetMonitorContentScale(_GLFWmonitor* monitor, - float* xscale, float* yscale) +void _glfwGetMonitorContentScaleWin32(_GLFWmonitor* monitor, + float* xscale, float* yscale) { - _glfwGetMonitorContentScaleWin32(monitor->win32.handle, xscale, yscale); + _glfwGetHMONITORContentScaleWin32(monitor->win32.handle, xscale, yscale); } -void _glfwPlatformGetMonitorWorkarea(_GLFWmonitor* monitor, - int* xpos, int* ypos, - int* width, int* height) +void _glfwGetMonitorWorkareaWin32(_GLFWmonitor* monitor, + int* xpos, int* ypos, + int* width, int* height) { MONITORINFO mi = { sizeof(mi) }; GetMonitorInfo(monitor->win32.handle, &mi); @@ -382,7 +382,7 @@ void _glfwPlatformGetMonitorWorkarea(_GLFWmonitor* monitor, *height = mi.rcWork.bottom - mi.rcWork.top; } -GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* count) +GLFWvidmode* _glfwGetVideoModesWin32(_GLFWmonitor* monitor, int* count) { int modeIndex = 0, size = 0; GLFWvidmode* result = NULL; @@ -452,14 +452,14 @@ GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* count) { // HACK: Report the current mode if no valid modes were found result = _glfw_calloc(1, sizeof(GLFWvidmode)); - _glfwPlatformGetVideoMode(monitor, result); + _glfwGetVideoModeWin32(monitor, result); *count = 1; } return result; } -void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode) +void _glfwGetVideoModeWin32(_GLFWmonitor* monitor, GLFWvidmode* mode) { DEVMODEW dm; ZeroMemory(&dm, sizeof(dm)); @@ -476,7 +476,7 @@ void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode) &mode->blueBits); } -GLFWbool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp) +GLFWbool _glfwGetGammaRampWin32(_GLFWmonitor* monitor, GLFWgammaramp* ramp) { HDC dc; WORD values[3][256]; @@ -494,7 +494,7 @@ GLFWbool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp) return GLFW_TRUE; } -void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp) +void _glfwSetGammaRampWin32(_GLFWmonitor* monitor, const GLFWgammaramp* ramp) { HDC dc; WORD values[3][256]; diff --git a/src/win32_platform.h b/src/win32_platform.h index cfea35b5..20e40d74 100644 --- a/src/win32_platform.h +++ b/src/win32_platform.h @@ -352,21 +352,17 @@ typedef struct VkWin32SurfaceCreateInfoKHR typedef VkResult (APIENTRY *PFN_vkCreateWin32SurfaceKHR)(VkInstance,const VkWin32SurfaceCreateInfoKHR*,const VkAllocationCallbacks*,VkSurfaceKHR*); typedef VkBool32 (APIENTRY *PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR)(VkPhysicalDevice,uint32_t); -#include "win32_time.h" -#include "win32_thread.h" -#include "win32_joystick.h" - #if !defined(_GLFW_WNDCLASSNAME) #define _GLFW_WNDCLASSNAME L"GLFW30" #endif -#define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowWin32 win32 -#define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryWin32 win32 -#define _GLFW_PLATFORM_MONITOR_STATE _GLFWmonitorWin32 win32 -#define _GLFW_PLATFORM_CURSOR_STATE _GLFWcursorWin32 win32 +#define GLFW_WIN32_WINDOW_STATE _GLFWwindowWin32 win32; +#define GLFW_WIN32_LIBRARY_WINDOW_STATE _GLFWlibraryWin32 win32; +#define GLFW_WIN32_MONITOR_STATE _GLFWmonitorWin32 win32; +#define GLFW_WIN32_CURSOR_STATE _GLFWcursorWin32 win32; -#define _GLFW_PLATFORM_CONTEXT_STATE _GLFWcontextWGL wgl -#define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE _GLFWlibraryWGL wgl +#define GLFW_WGL_CONTEXT_STATE _GLFWcontextWGL wgl; +#define GLFW_WGL_LIBRARY_CONTEXT_STATE _GLFWlibraryWGL wgl; // WGL-specific per-context data @@ -519,6 +515,10 @@ typedef struct _GLFWcursorWin32 } _GLFWcursorWin32; +GLFWbool _glfwConnectWin32(int platformID, _GLFWplatform* platform); +int _glfwInitWin32(void); +void _glfwTerminateWin32(void); + GLFWbool _glfwRegisterWindowClassWin32(void); void _glfwUnregisterWindowClassWin32(void); @@ -532,7 +532,84 @@ void _glfwUpdateKeyNamesWin32(void); void _glfwPollMonitorsWin32(void); void _glfwSetVideoModeWin32(_GLFWmonitor* monitor, const GLFWvidmode* desired); void _glfwRestoreVideoModeWin32(_GLFWmonitor* monitor); -void _glfwGetMonitorContentScaleWin32(HMONITOR handle, float* xscale, float* yscale); +void _glfwGetHMONITORContentScaleWin32(HMONITOR handle, float* xscale, float* yscale); + +int _glfwCreateWindowWin32(_GLFWwindow* window, const _GLFWwndconfig* wndconfig, const _GLFWctxconfig* ctxconfig, const _GLFWfbconfig* fbconfig); +void _glfwDestroyWindowWin32(_GLFWwindow* window); +void _glfwSetWindowTitleWin32(_GLFWwindow* window, const char* title); +void _glfwSetWindowIconWin32(_GLFWwindow* window, int count, const GLFWimage* images); +void _glfwGetWindowPosWin32(_GLFWwindow* window, int* xpos, int* ypos); +void _glfwSetWindowPosWin32(_GLFWwindow* window, int xpos, int ypos); +void _glfwGetWindowSizeWin32(_GLFWwindow* window, int* width, int* height); +void _glfwSetWindowSizeWin32(_GLFWwindow* window, int width, int height); +void _glfwSetWindowSizeLimitsWin32(_GLFWwindow* window, int minwidth, int minheight, int maxwidth, int maxheight); +void _glfwSetWindowAspectRatioWin32(_GLFWwindow* window, int numer, int denom); +void _glfwGetFramebufferSizeWin32(_GLFWwindow* window, int* width, int* height); +void _glfwGetWindowFrameSizeWin32(_GLFWwindow* window, int* left, int* top, int* right, int* bottom); +void _glfwGetWindowContentScaleWin32(_GLFWwindow* window, float* xscale, float* yscale); +void _glfwIconifyWindowWin32(_GLFWwindow* window); +void _glfwRestoreWindowWin32(_GLFWwindow* window); +void _glfwMaximizeWindowWin32(_GLFWwindow* window); +void _glfwShowWindowWin32(_GLFWwindow* window); +void _glfwHideWindowWin32(_GLFWwindow* window); +void _glfwRequestWindowAttentionWin32(_GLFWwindow* window); +void _glfwFocusWindowWin32(_GLFWwindow* window); +void _glfwSetWindowMonitorWin32(_GLFWwindow* window, _GLFWmonitor* monitor, int xpos, int ypos, int width, int height, int refreshRate); +int _glfwWindowFocusedWin32(_GLFWwindow* window); +int _glfwWindowIconifiedWin32(_GLFWwindow* window); +int _glfwWindowVisibleWin32(_GLFWwindow* window); +int _glfwWindowMaximizedWin32(_GLFWwindow* window); +int _glfwWindowHoveredWin32(_GLFWwindow* window); +int _glfwFramebufferTransparentWin32(_GLFWwindow* window); +void _glfwSetWindowResizableWin32(_GLFWwindow* window, GLFWbool enabled); +void _glfwSetWindowDecoratedWin32(_GLFWwindow* window, GLFWbool enabled); +void _glfwSetWindowFloatingWin32(_GLFWwindow* window, GLFWbool enabled); +void _glfwSetWindowMousePassthroughWin32(_GLFWwindow* window, GLFWbool enabled); +float _glfwGetWindowOpacityWin32(_GLFWwindow* window); +void _glfwSetWindowOpacityWin32(_GLFWwindow* window, float opacity); + +void _glfwSetRawMouseMotionWin32(_GLFWwindow *window, GLFWbool enabled); +GLFWbool _glfwRawMouseMotionSupportedWin32(void); + +void _glfwPollEventsWin32(void); +void _glfwWaitEventsWin32(void); +void _glfwWaitEventsTimeoutWin32(double timeout); +void _glfwPostEmptyEventWin32(void); + +void _glfwGetCursorPosWin32(_GLFWwindow* window, double* xpos, double* ypos); +void _glfwSetCursorPosWin32(_GLFWwindow* window, double xpos, double ypos); +void _glfwSetCursorModeWin32(_GLFWwindow* window, int mode); +const char* _glfwGetScancodeNameWin32(int scancode); +int _glfwGetKeyScancodeWin32(int key); +int _glfwCreateCursorWin32(_GLFWcursor* cursor, const GLFWimage* image, int xhot, int yhot); +int _glfwCreateStandardCursorWin32(_GLFWcursor* cursor, int shape); +void _glfwDestroyCursorWin32(_GLFWcursor* cursor); +void _glfwSetCursorWin32(_GLFWwindow* window, _GLFWcursor* cursor); +void _glfwSetClipboardStringWin32(const char* string); +const char* _glfwGetClipboardStringWin32(void); + +EGLenum _glfwGetEGLPlatformWin32(EGLint** attribs); +EGLNativeDisplayType _glfwGetEGLNativeDisplayWin32(void); +EGLNativeWindowType _glfwGetEGLNativeWindowWin32(_GLFWwindow* window); + +void _glfwGetRequiredInstanceExtensionsWin32(char** extensions); +int _glfwGetPhysicalDevicePresentationSupportWin32(VkInstance instance, VkPhysicalDevice device, uint32_t queuefamily); +VkResult _glfwCreateWindowSurfaceWin32(VkInstance instance, _GLFWwindow* window, const VkAllocationCallbacks* allocator, VkSurfaceKHR* surface); + +void _glfwFreeMonitorWin32(_GLFWmonitor* monitor); +void _glfwGetMonitorPosWin32(_GLFWmonitor* monitor, int* xpos, int* ypos); +void _glfwGetMonitorContentScaleWin32(_GLFWmonitor* monitor, float* xscale, float* yscale); +void _glfwGetMonitorWorkareaWin32(_GLFWmonitor* monitor, int* xpos, int* ypos, int* width, int* height); +GLFWvidmode* _glfwGetVideoModesWin32(_GLFWmonitor* monitor, int* count); +void _glfwGetVideoModeWin32(_GLFWmonitor* monitor, GLFWvidmode* mode); +GLFWbool _glfwGetGammaRampWin32(_GLFWmonitor* monitor, GLFWgammaramp* ramp); +void _glfwSetGammaRampWin32(_GLFWmonitor* monitor, const GLFWgammaramp* ramp); + +GLFWbool _glfwInitJoysticksWin32(void); +void _glfwTerminateJoysticksWin32(void); +int _glfwPollJoystickWin32(_GLFWjoystick* js, int mode); +const char* _glfwGetMappingNameWin32(void); +void _glfwUpdateGamepadGUIDWin32(char* guid); GLFWbool _glfwInitWGL(void); void _glfwTerminateWGL(void); diff --git a/src/win32_thread.h b/src/win32_thread.h index afc8f546..4b5a696f 100644 --- a/src/win32_thread.h +++ b/src/win32_thread.h @@ -27,8 +27,8 @@ #include -#define _GLFW_PLATFORM_TLS_STATE _GLFWtlsWin32 win32 -#define _GLFW_PLATFORM_MUTEX_STATE _GLFWmutexWin32 win32 +#define GLFW_WIN32_TLS_STATE _GLFWtlsWin32 win32; +#define GLFW_WIN32_MUTEX_STATE _GLFWmutexWin32 win32; // Win32-specific thread local storage data // diff --git a/src/win32_time.h b/src/win32_time.h index a5a7ee80..da5afa41 100644 --- a/src/win32_time.h +++ b/src/win32_time.h @@ -27,7 +27,7 @@ #include -#define _GLFW_PLATFORM_LIBRARY_TIMER_STATE _GLFWtimerWin32 win32 +#define GLFW_WIN32_LIBRARY_TIMER_STATE _GLFWtimerWin32 win32; // Win32-specific global timer data // diff --git a/src/win32_window.c b/src/win32_window.c index 80ae7c79..ae7710a2 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -297,9 +297,9 @@ static void disableRawMouseMotion(_GLFWwindow* window) static void disableCursor(_GLFWwindow* window) { _glfw.win32.disabledCursorWindow = window; - _glfwPlatformGetCursorPos(window, - &_glfw.win32.restoreCursorPosX, - &_glfw.win32.restoreCursorPosY); + _glfwGetCursorPosWin32(window, + &_glfw.win32.restoreCursorPosX, + &_glfw.win32.restoreCursorPosY); updateCursorImage(window); _glfwCenterCursorInContentArea(window); updateClipRect(window); @@ -317,9 +317,9 @@ static void enableCursor(_GLFWwindow* window) _glfw.win32.disabledCursorWindow = NULL; updateClipRect(NULL); - _glfwPlatformSetCursorPos(window, - _glfw.win32.restoreCursorPosX, - _glfw.win32.restoreCursorPosY); + _glfwSetCursorPosWin32(window, + _glfw.win32.restoreCursorPosX, + _glfw.win32.restoreCursorPosY); updateCursorImage(window); } @@ -595,7 +595,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, enableCursor(window); if (window->monitor && window->autoIconify) - _glfwPlatformIconifyWindow(window); + _glfwIconifyWindowWin32(window); _glfwInputWindowFocus(window, GLFW_FALSE); return 0; @@ -755,7 +755,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, { // HACK: Release both Shift keys on Shift up event, as when both // are pressed the first release does not emit any event - // NOTE: The other half of this is in _glfwPlatformPollEvents + // NOTE: The other half of this is in _glfwPollEventsWin32 _glfwInputKey(window, GLFW_KEY_LEFT_SHIFT, scancode, action, mods); _glfwInputKey(window, GLFW_KEY_RIGHT_SHIFT, scancode, action, mods); } @@ -1233,8 +1233,8 @@ static int createNativeWindow(_GLFWwindow* window, // NOTE: This window placement is temporary and approximate, as the // correct position and size cannot be known until the monitor // video mode has been picked in _glfwSetVideoModeWin32 - _glfwPlatformGetMonitorPos(window->monitor, &xpos, &ypos); - _glfwPlatformGetVideoMode(window->monitor, &mode); + _glfwGetMonitorPosWin32(window->monitor, &xpos, &ypos); + _glfwGetVideoModeWin32(window->monitor, &mode); fullWidth = mode.width; fullHeight = mode.height; } @@ -1303,7 +1303,7 @@ static int createNativeWindow(_GLFWwindow* window, if (wndconfig->scaleToMonitor) { float xscale, yscale; - _glfwPlatformGetWindowContentScale(window, &xscale, &yscale); + _glfwGetWindowContentScaleWin32(window, &xscale, &yscale); rect.right = (int) (rect.right * xscale); rect.bottom = (int) (rect.bottom * yscale); } @@ -1334,16 +1334,11 @@ static int createNativeWindow(_GLFWwindow* window, window->win32.transparent = GLFW_TRUE; } - _glfwPlatformGetWindowSize(window, &window->win32.width, &window->win32.height); + _glfwGetWindowSizeWin32(window, &window->win32.width, &window->win32.height); return GLFW_TRUE; } - -////////////////////////////////////////////////////////////////////////// -////// GLFW internal API ////// -////////////////////////////////////////////////////////////////////////// - // Registers the GLFW window class // GLFWbool _glfwRegisterWindowClassWin32(void) @@ -1387,15 +1382,10 @@ void _glfwUnregisterWindowClassWin32(void) UnregisterClassW(_GLFW_WNDCLASSNAME, GetModuleHandleW(NULL)); } - -////////////////////////////////////////////////////////////////////////// -////// GLFW platform API ////// -////////////////////////////////////////////////////////////////////////// - -int _glfwPlatformCreateWindow(_GLFWwindow* window, - const _GLFWwndconfig* wndconfig, - const _GLFWctxconfig* ctxconfig, - const _GLFWfbconfig* fbconfig) +int _glfwCreateWindowWin32(_GLFWwindow* window, + const _GLFWwndconfig* wndconfig, + const _GLFWctxconfig* ctxconfig, + const _GLFWfbconfig* fbconfig) { if (!createNativeWindow(window, wndconfig, fbconfig)) return GLFW_FALSE; @@ -1427,8 +1417,8 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window, if (window->monitor) { - _glfwPlatformShowWindow(window); - _glfwPlatformFocusWindow(window); + _glfwShowWindowWin32(window); + _glfwFocusWindowWin32(window); acquireMonitor(window); fitToMonitor(window); } @@ -1436,7 +1426,7 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window, return GLFW_TRUE; } -void _glfwPlatformDestroyWindow(_GLFWwindow* window) +void _glfwDestroyWindowWin32(_GLFWwindow* window) { if (window->monitor) releaseMonitor(window); @@ -1461,7 +1451,7 @@ void _glfwPlatformDestroyWindow(_GLFWwindow* window) DestroyIcon(window->win32.smallIcon); } -void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title) +void _glfwSetWindowTitleWin32(_GLFWwindow* window, const char* title) { WCHAR* wideTitle = _glfwCreateWideStringFromUTF8Win32(title); if (!wideTitle) @@ -1471,8 +1461,8 @@ void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title) _glfw_free(wideTitle); } -void _glfwPlatformSetWindowIcon(_GLFWwindow* window, - int count, const GLFWimage* images) +void _glfwSetWindowIconWin32(_GLFWwindow* window, + int count, const GLFWimage* images) { HICON bigIcon = NULL, smallIcon = NULL; @@ -1510,7 +1500,7 @@ void _glfwPlatformSetWindowIcon(_GLFWwindow* window, } } -void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos) +void _glfwGetWindowPosWin32(_GLFWwindow* window, int* xpos, int* ypos) { POINT pos = { 0, 0 }; ClientToScreen(window->win32.handle, &pos); @@ -1521,7 +1511,7 @@ void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos) *ypos = pos.y; } -void _glfwPlatformSetWindowPos(_GLFWwindow* window, int xpos, int ypos) +void _glfwSetWindowPosWin32(_GLFWwindow* window, int xpos, int ypos) { RECT rect = { xpos, ypos, xpos, ypos }; @@ -1541,7 +1531,7 @@ void _glfwPlatformSetWindowPos(_GLFWwindow* window, int xpos, int ypos) SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOSIZE); } -void _glfwPlatformGetWindowSize(_GLFWwindow* window, int* width, int* height) +void _glfwGetWindowSizeWin32(_GLFWwindow* window, int* width, int* height) { RECT area; GetClientRect(window->win32.handle, &area); @@ -1552,7 +1542,7 @@ void _glfwPlatformGetWindowSize(_GLFWwindow* window, int* width, int* height) *height = area.bottom; } -void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height) +void _glfwSetWindowSizeWin32(_GLFWwindow* window, int width, int height) { if (window->monitor) { @@ -1584,9 +1574,9 @@ void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height) } } -void _glfwPlatformSetWindowSizeLimits(_GLFWwindow* window, - int minwidth, int minheight, - int maxwidth, int maxheight) +void _glfwSetWindowSizeLimitsWin32(_GLFWwindow* window, + int minwidth, int minheight, + int maxwidth, int maxheight) { RECT area; @@ -1603,7 +1593,7 @@ void _glfwPlatformSetWindowSizeLimits(_GLFWwindow* window, area.bottom - area.top, TRUE); } -void _glfwPlatformSetWindowAspectRatio(_GLFWwindow* window, int numer, int denom) +void _glfwSetWindowAspectRatioWin32(_GLFWwindow* window, int numer, int denom) { RECT area; @@ -1618,19 +1608,19 @@ void _glfwPlatformSetWindowAspectRatio(_GLFWwindow* window, int numer, int denom area.bottom - area.top, TRUE); } -void _glfwPlatformGetFramebufferSize(_GLFWwindow* window, int* width, int* height) +void _glfwGetFramebufferSizeWin32(_GLFWwindow* window, int* width, int* height) { - _glfwPlatformGetWindowSize(window, width, height); + _glfwGetWindowSizeWin32(window, width, height); } -void _glfwPlatformGetWindowFrameSize(_GLFWwindow* window, - int* left, int* top, - int* right, int* bottom) +void _glfwGetWindowFrameSizeWin32(_GLFWwindow* window, + int* left, int* top, + int* right, int* bottom) { RECT rect; int width, height; - _glfwPlatformGetWindowSize(window, &width, &height); + _glfwGetWindowSizeWin32(window, &width, &height); SetRect(&rect, 0, 0, width, height); if (_glfwIsWindows10AnniversaryUpdateOrGreaterWin32()) @@ -1655,56 +1645,56 @@ void _glfwPlatformGetWindowFrameSize(_GLFWwindow* window, *bottom = rect.bottom - height; } -void _glfwPlatformGetWindowContentScale(_GLFWwindow* window, - float* xscale, float* yscale) +void _glfwGetWindowContentScaleWin32(_GLFWwindow* window, + float* xscale, float* yscale) { const HANDLE handle = MonitorFromWindow(window->win32.handle, MONITOR_DEFAULTTONEAREST); - _glfwGetMonitorContentScaleWin32(handle, xscale, yscale); + _glfwGetHMONITORContentScaleWin32(handle, xscale, yscale); } -void _glfwPlatformIconifyWindow(_GLFWwindow* window) +void _glfwIconifyWindowWin32(_GLFWwindow* window) { ShowWindow(window->win32.handle, SW_MINIMIZE); } -void _glfwPlatformRestoreWindow(_GLFWwindow* window) +void _glfwRestoreWindowWin32(_GLFWwindow* window) { ShowWindow(window->win32.handle, SW_RESTORE); } -void _glfwPlatformMaximizeWindow(_GLFWwindow* window) +void _glfwMaximizeWindowWin32(_GLFWwindow* window) { ShowWindow(window->win32.handle, SW_MAXIMIZE); } -void _glfwPlatformShowWindow(_GLFWwindow* window) +void _glfwShowWindowWin32(_GLFWwindow* window) { ShowWindow(window->win32.handle, SW_SHOWNA); } -void _glfwPlatformHideWindow(_GLFWwindow* window) +void _glfwHideWindowWin32(_GLFWwindow* window) { ShowWindow(window->win32.handle, SW_HIDE); } -void _glfwPlatformRequestWindowAttention(_GLFWwindow* window) +void _glfwRequestWindowAttentionWin32(_GLFWwindow* window) { FlashWindow(window->win32.handle, TRUE); } -void _glfwPlatformFocusWindow(_GLFWwindow* window) +void _glfwFocusWindowWin32(_GLFWwindow* window) { BringWindowToTop(window->win32.handle); SetForegroundWindow(window->win32.handle); SetFocus(window->win32.handle); } -void _glfwPlatformSetWindowMonitor(_GLFWwindow* window, - _GLFWmonitor* monitor, - int xpos, int ypos, - int width, int height, - int refreshRate) +void _glfwSetWindowMonitorWin32(_GLFWwindow* window, + _GLFWmonitor* monitor, + int xpos, int ypos, + int width, int height, + int refreshRate) { if (window->monitor == monitor) { @@ -1810,32 +1800,32 @@ void _glfwPlatformSetWindowMonitor(_GLFWwindow* window, } } -int _glfwPlatformWindowFocused(_GLFWwindow* window) +int _glfwWindowFocusedWin32(_GLFWwindow* window) { return window->win32.handle == GetActiveWindow(); } -int _glfwPlatformWindowIconified(_GLFWwindow* window) +int _glfwWindowIconifiedWin32(_GLFWwindow* window) { return IsIconic(window->win32.handle); } -int _glfwPlatformWindowVisible(_GLFWwindow* window) +int _glfwWindowVisibleWin32(_GLFWwindow* window) { return IsWindowVisible(window->win32.handle); } -int _glfwPlatformWindowMaximized(_GLFWwindow* window) +int _glfwWindowMaximizedWin32(_GLFWwindow* window) { return IsZoomed(window->win32.handle); } -int _glfwPlatformWindowHovered(_GLFWwindow* window) +int _glfwWindowHoveredWin32(_GLFWwindow* window) { return cursorInContentArea(window); } -int _glfwPlatformFramebufferTransparent(_GLFWwindow* window) +int _glfwFramebufferTransparentWin32(_GLFWwindow* window) { BOOL composition, opaque; DWORD color; @@ -1862,24 +1852,24 @@ int _glfwPlatformFramebufferTransparent(_GLFWwindow* window) return GLFW_TRUE; } -void _glfwPlatformSetWindowResizable(_GLFWwindow* window, GLFWbool enabled) +void _glfwSetWindowResizableWin32(_GLFWwindow* window, GLFWbool enabled) { updateWindowStyles(window); } -void _glfwPlatformSetWindowDecorated(_GLFWwindow* window, GLFWbool enabled) +void _glfwSetWindowDecoratedWin32(_GLFWwindow* window, GLFWbool enabled) { updateWindowStyles(window); } -void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled) +void _glfwSetWindowFloatingWin32(_GLFWwindow* window, GLFWbool enabled) { const HWND after = enabled ? HWND_TOPMOST : HWND_NOTOPMOST; SetWindowPos(window->win32.handle, after, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE); } -void _glfwPlatformSetWindowMousePassthrough(_GLFWwindow* window, GLFWbool enabled) +void _glfwSetWindowMousePassthroughWin32(_GLFWwindow* window, GLFWbool enabled) { COLORREF key = 0; BYTE alpha = 0; @@ -1909,7 +1899,7 @@ void _glfwPlatformSetWindowMousePassthrough(_GLFWwindow* window, GLFWbool enable SetLayeredWindowAttributes(window->win32.handle, key, alpha, flags); } -float _glfwPlatformGetWindowOpacity(_GLFWwindow* window) +float _glfwGetWindowOpacityWin32(_GLFWwindow* window) { BYTE alpha; DWORD flags; @@ -1924,7 +1914,7 @@ float _glfwPlatformGetWindowOpacity(_GLFWwindow* window) return 1.f; } -void _glfwPlatformSetWindowOpacity(_GLFWwindow* window, float opacity) +void _glfwSetWindowOpacityWin32(_GLFWwindow* window, float opacity) { LONG exStyle = GetWindowLongW(window->win32.handle, GWL_EXSTYLE); if (opacity < 1.f || (exStyle & WS_EX_TRANSPARENT)) @@ -1945,7 +1935,7 @@ void _glfwPlatformSetWindowOpacity(_GLFWwindow* window, float opacity) } } -void _glfwPlatformSetRawMouseMotion(_GLFWwindow *window, GLFWbool enabled) +void _glfwSetRawMouseMotionWin32(_GLFWwindow *window, GLFWbool enabled) { if (_glfw.win32.disabledCursorWindow != window) return; @@ -1956,12 +1946,12 @@ void _glfwPlatformSetRawMouseMotion(_GLFWwindow *window, GLFWbool enabled) disableRawMouseMotion(window); } -GLFWbool _glfwPlatformRawMouseMotionSupported(void) +GLFWbool _glfwRawMouseMotionSupportedWin32(void) { return GLFW_TRUE; } -void _glfwPlatformPollEvents(void) +void _glfwPollEventsWin32(void) { MSG msg; HWND handle; @@ -2031,38 +2021,38 @@ void _glfwPlatformPollEvents(void) if (window) { int width, height; - _glfwPlatformGetWindowSize(window, &width, &height); + _glfwGetWindowSizeWin32(window, &width, &height); // NOTE: Re-center the cursor only if it has moved since the last call, // to avoid breaking glfwWaitEvents with WM_MOUSEMOVE if (window->win32.lastCursorPosX != width / 2 || window->win32.lastCursorPosY != height / 2) { - _glfwPlatformSetCursorPos(window, width / 2, height / 2); + _glfwSetCursorPosWin32(window, width / 2, height / 2); } } } -void _glfwPlatformWaitEvents(void) +void _glfwWaitEventsWin32(void) { WaitMessage(); - _glfwPlatformPollEvents(); + _glfwPollEventsWin32(); } -void _glfwPlatformWaitEventsTimeout(double timeout) +void _glfwWaitEventsTimeoutWin32(double timeout) { MsgWaitForMultipleObjects(0, NULL, FALSE, (DWORD) (timeout * 1e3), QS_ALLEVENTS); - _glfwPlatformPollEvents(); + _glfwPollEventsWin32(); } -void _glfwPlatformPostEmptyEvent(void) +void _glfwPostEmptyEventWin32(void) { PostMessage(_glfw.win32.helperWindowHandle, WM_NULL, 0, 0); } -void _glfwPlatformGetCursorPos(_GLFWwindow* window, double* xpos, double* ypos) +void _glfwGetCursorPosWin32(_GLFWwindow* window, double* xpos, double* ypos) { POINT pos; @@ -2077,7 +2067,7 @@ void _glfwPlatformGetCursorPos(_GLFWwindow* window, double* xpos, double* ypos) } } -void _glfwPlatformSetCursorPos(_GLFWwindow* window, double xpos, double ypos) +void _glfwSetCursorPosWin32(_GLFWwindow* window, double xpos, double ypos) { POINT pos = { (int) xpos, (int) ypos }; @@ -2089,11 +2079,11 @@ void _glfwPlatformSetCursorPos(_GLFWwindow* window, double xpos, double ypos) SetCursorPos(pos.x, pos.y); } -void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode) +void _glfwSetCursorModeWin32(_GLFWwindow* window, int mode) { if (mode == GLFW_CURSOR_DISABLED) { - if (_glfwPlatformWindowFocused(window)) + if (_glfwWindowFocusedWin32(window)) disableCursor(window); } else if (_glfw.win32.disabledCursorWindow == window) @@ -2102,7 +2092,7 @@ void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode) updateCursorImage(window); } -const char* _glfwPlatformGetScancodeName(int scancode) +const char* _glfwGetScancodeNameWin32(int scancode) { if (scancode < 0 || scancode > (KF_EXTENDED | 0xff) || _glfw.win32.keycodes[scancode] == GLFW_KEY_UNKNOWN) @@ -2114,14 +2104,14 @@ const char* _glfwPlatformGetScancodeName(int scancode) return _glfw.win32.keynames[_glfw.win32.keycodes[scancode]]; } -int _glfwPlatformGetKeyScancode(int key) +int _glfwGetKeyScancodeWin32(int key) { return _glfw.win32.scancodes[key]; } -int _glfwPlatformCreateCursor(_GLFWcursor* cursor, - const GLFWimage* image, - int xhot, int yhot) +int _glfwCreateCursorWin32(_GLFWcursor* cursor, + const GLFWimage* image, + int xhot, int yhot) { cursor->win32.handle = (HCURSOR) createIcon(image, xhot, yhot, GLFW_FALSE); if (!cursor->win32.handle) @@ -2130,7 +2120,7 @@ int _glfwPlatformCreateCursor(_GLFWcursor* cursor, return GLFW_TRUE; } -int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape) +int _glfwCreateStandardCursorWin32(_GLFWcursor* cursor, int shape) { int id = 0; @@ -2184,19 +2174,19 @@ int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape) return GLFW_TRUE; } -void _glfwPlatformDestroyCursor(_GLFWcursor* cursor) +void _glfwDestroyCursorWin32(_GLFWcursor* cursor) { if (cursor->win32.handle) DestroyIcon((HICON) cursor->win32.handle); } -void _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor) +void _glfwSetCursorWin32(_GLFWwindow* window, _GLFWcursor* cursor) { if (cursorInContentArea(window)) updateCursorImage(window); } -void _glfwPlatformSetClipboardString(const char* string) +void _glfwSetClipboardStringWin32(const char* string) { int characterCount; HANDLE object; @@ -2239,7 +2229,7 @@ void _glfwPlatformSetClipboardString(const char* string) CloseClipboard(); } -const char* _glfwPlatformGetClipboardString(void) +const char* _glfwGetClipboardStringWin32(void) { HANDLE object; WCHAR* buffer; @@ -2278,7 +2268,7 @@ const char* _glfwPlatformGetClipboardString(void) return _glfw.win32.clipboardString; } -EGLenum _glfwPlatformGetEGLPlatform(EGLint** attribs) +EGLenum _glfwGetEGLPlatformWin32(EGLint** attribs) { if (_glfw.egl.ANGLE_platform_angle) { @@ -2319,17 +2309,17 @@ EGLenum _glfwPlatformGetEGLPlatform(EGLint** attribs) return 0; } -EGLNativeDisplayType _glfwPlatformGetEGLNativeDisplay(void) +EGLNativeDisplayType _glfwGetEGLNativeDisplayWin32(void) { return GetDC(_glfw.win32.helperWindowHandle); } -EGLNativeWindowType _glfwPlatformGetEGLNativeWindow(_GLFWwindow* window) +EGLNativeWindowType _glfwGetEGLNativeWindowWin32(_GLFWwindow* window) { return window->win32.handle; } -void _glfwPlatformGetRequiredInstanceExtensions(char** extensions) +void _glfwGetRequiredInstanceExtensionsWin32(char** extensions) { if (!_glfw.vk.KHR_surface || !_glfw.vk.KHR_win32_surface) return; @@ -2338,9 +2328,9 @@ void _glfwPlatformGetRequiredInstanceExtensions(char** extensions) extensions[1] = "VK_KHR_win32_surface"; } -int _glfwPlatformGetPhysicalDevicePresentationSupport(VkInstance instance, - VkPhysicalDevice device, - uint32_t queuefamily) +int _glfwGetPhysicalDevicePresentationSupportWin32(VkInstance instance, + VkPhysicalDevice device, + uint32_t queuefamily) { PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR vkGetPhysicalDeviceWin32PresentationSupportKHR = @@ -2356,10 +2346,10 @@ int _glfwPlatformGetPhysicalDevicePresentationSupport(VkInstance instance, return vkGetPhysicalDeviceWin32PresentationSupportKHR(device, queuefamily); } -VkResult _glfwPlatformCreateWindowSurface(VkInstance instance, - _GLFWwindow* window, - const VkAllocationCallbacks* allocator, - VkSurfaceKHR* surface) +VkResult _glfwCreateWindowSurfaceWin32(VkInstance instance, + _GLFWwindow* window, + const VkAllocationCallbacks* allocator, + VkSurfaceKHR* surface) { VkResult err; VkWin32SurfaceCreateInfoKHR sci; @@ -2390,15 +2380,18 @@ VkResult _glfwPlatformCreateWindowSurface(VkInstance instance, return err; } - -////////////////////////////////////////////////////////////////////////// -////// GLFW native API ////// -////////////////////////////////////////////////////////////////////////// - GLFWAPI HWND glfwGetWin32Window(GLFWwindow* handle) { _GLFWwindow* window = (_GLFWwindow*) handle; _GLFW_REQUIRE_INIT_OR_RETURN(NULL); + + if (_glfw.platform.platformID != GLFW_PLATFORM_WIN32) + { + _glfwInputError(GLFW_PLATFORM_UNAVAILABLE, + "Win32: Platform not initialized"); + return NULL; + } + return window->win32.handle; } diff --git a/src/window.c b/src/window.c index 93d8a14c..c9845eca 100644 --- a/src/window.c +++ b/src/window.c @@ -55,7 +55,7 @@ void _glfwInputWindowFocus(_GLFWwindow* window, GLFWbool focused) { if (window->keys[key] == GLFW_PRESS) { - const int scancode = _glfwPlatformGetKeyScancode(key); + const int scancode = _glfw.platform.getKeyScancode(key); _glfwInputKey(window, key, scancode, GLFW_RELEASE, 0); } } @@ -216,7 +216,7 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height, window->denom = GLFW_DONT_CARE; // Open the actual window and create its context - if (!_glfwPlatformCreateWindow(window, &wndconfig, &ctxconfig, &fbconfig)) + if (!_glfw.platform.createWindow(window, &wndconfig, &ctxconfig, &fbconfig)) { glfwDestroyWindow((GLFWwindow*) window); return NULL; @@ -232,7 +232,7 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height, } if (wndconfig.mousePassthrough) - _glfwPlatformSetWindowMousePassthrough(window, GLFW_TRUE); + _glfw.platform.setWindowMousePassthrough(window, GLFW_TRUE); if (window->monitor) { @@ -243,9 +243,9 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height, { if (wndconfig.visible) { - _glfwPlatformShowWindow(window); + _glfw.platform.showWindow(window); if (wndconfig.focused) - _glfwPlatformFocusWindow(window); + _glfw.platform.focusWindow(window); } } @@ -468,7 +468,7 @@ GLFWAPI void glfwDestroyWindow(GLFWwindow* handle) if (window == _glfwPlatformGetTls(&_glfw.contextSlot)) glfwMakeContextCurrent(NULL); - _glfwPlatformDestroyWindow(window); + _glfw.platform.destroyWindow(window); // Unlink window from global linked list { @@ -508,7 +508,7 @@ GLFWAPI void glfwSetWindowTitle(GLFWwindow* handle, const char* title) assert(title != NULL); _GLFW_REQUIRE_INIT(); - _glfwPlatformSetWindowTitle(window, title); + _glfw.platform.setWindowTitle(window, title); } GLFWAPI void glfwSetWindowIcon(GLFWwindow* handle, @@ -520,7 +520,7 @@ GLFWAPI void glfwSetWindowIcon(GLFWwindow* handle, assert(count == 0 || images != NULL); _GLFW_REQUIRE_INIT(); - _glfwPlatformSetWindowIcon(window, count, images); + _glfw.platform.setWindowIcon(window, count, images); } GLFWAPI void glfwGetWindowPos(GLFWwindow* handle, int* xpos, int* ypos) @@ -534,7 +534,7 @@ GLFWAPI void glfwGetWindowPos(GLFWwindow* handle, int* xpos, int* ypos) *ypos = 0; _GLFW_REQUIRE_INIT(); - _glfwPlatformGetWindowPos(window, xpos, ypos); + _glfw.platform.getWindowPos(window, xpos, ypos); } GLFWAPI void glfwSetWindowPos(GLFWwindow* handle, int xpos, int ypos) @@ -547,7 +547,7 @@ GLFWAPI void glfwSetWindowPos(GLFWwindow* handle, int xpos, int ypos) if (window->monitor) return; - _glfwPlatformSetWindowPos(window, xpos, ypos); + _glfw.platform.setWindowPos(window, xpos, ypos); } GLFWAPI void glfwGetWindowSize(GLFWwindow* handle, int* width, int* height) @@ -561,7 +561,7 @@ GLFWAPI void glfwGetWindowSize(GLFWwindow* handle, int* width, int* height) *height = 0; _GLFW_REQUIRE_INIT(); - _glfwPlatformGetWindowSize(window, width, height); + _glfw.platform.getWindowSize(window, width, height); } GLFWAPI void glfwSetWindowSize(GLFWwindow* handle, int width, int height) @@ -576,7 +576,7 @@ GLFWAPI void glfwSetWindowSize(GLFWwindow* handle, int width, int height) window->videoMode.width = width; window->videoMode.height = height; - _glfwPlatformSetWindowSize(window, width, height); + _glfw.platform.setWindowSize(window, width, height); } GLFWAPI void glfwSetWindowSizeLimits(GLFWwindow* handle, @@ -619,9 +619,9 @@ GLFWAPI void glfwSetWindowSizeLimits(GLFWwindow* handle, if (window->monitor || !window->resizable) return; - _glfwPlatformSetWindowSizeLimits(window, - minwidth, minheight, - maxwidth, maxheight); + _glfw.platform.setWindowSizeLimits(window, + minwidth, minheight, + maxwidth, maxheight); } GLFWAPI void glfwSetWindowAspectRatio(GLFWwindow* handle, int numer, int denom) @@ -650,7 +650,7 @@ GLFWAPI void glfwSetWindowAspectRatio(GLFWwindow* handle, int numer, int denom) if (window->monitor || !window->resizable) return; - _glfwPlatformSetWindowAspectRatio(window, numer, denom); + _glfw.platform.setWindowAspectRatio(window, numer, denom); } GLFWAPI void glfwGetFramebufferSize(GLFWwindow* handle, int* width, int* height) @@ -664,7 +664,7 @@ GLFWAPI void glfwGetFramebufferSize(GLFWwindow* handle, int* width, int* height) *height = 0; _GLFW_REQUIRE_INIT(); - _glfwPlatformGetFramebufferSize(window, width, height); + _glfw.platform.getFramebufferSize(window, width, height); } GLFWAPI void glfwGetWindowFrameSize(GLFWwindow* handle, @@ -684,7 +684,7 @@ GLFWAPI void glfwGetWindowFrameSize(GLFWwindow* handle, *bottom = 0; _GLFW_REQUIRE_INIT(); - _glfwPlatformGetWindowFrameSize(window, left, top, right, bottom); + _glfw.platform.getWindowFrameSize(window, left, top, right, bottom); } GLFWAPI void glfwGetWindowContentScale(GLFWwindow* handle, @@ -699,7 +699,7 @@ GLFWAPI void glfwGetWindowContentScale(GLFWwindow* handle, *yscale = 0.f; _GLFW_REQUIRE_INIT(); - _glfwPlatformGetWindowContentScale(window, xscale, yscale); + _glfw.platform.getWindowContentScale(window, xscale, yscale); } GLFWAPI float glfwGetWindowOpacity(GLFWwindow* handle) @@ -708,7 +708,7 @@ GLFWAPI float glfwGetWindowOpacity(GLFWwindow* handle) assert(window != NULL); _GLFW_REQUIRE_INIT_OR_RETURN(1.f); - return _glfwPlatformGetWindowOpacity(window); + return _glfw.platform.getWindowOpacity(window); } GLFWAPI void glfwSetWindowOpacity(GLFWwindow* handle, float opacity) @@ -727,7 +727,7 @@ GLFWAPI void glfwSetWindowOpacity(GLFWwindow* handle, float opacity) return; } - _glfwPlatformSetWindowOpacity(window, opacity); + _glfw.platform.setWindowOpacity(window, opacity); } GLFWAPI void glfwIconifyWindow(GLFWwindow* handle) @@ -736,7 +736,7 @@ GLFWAPI void glfwIconifyWindow(GLFWwindow* handle) assert(window != NULL); _GLFW_REQUIRE_INIT(); - _glfwPlatformIconifyWindow(window); + _glfw.platform.iconifyWindow(window); } GLFWAPI void glfwRestoreWindow(GLFWwindow* handle) @@ -745,7 +745,7 @@ GLFWAPI void glfwRestoreWindow(GLFWwindow* handle) assert(window != NULL); _GLFW_REQUIRE_INIT(); - _glfwPlatformRestoreWindow(window); + _glfw.platform.restoreWindow(window); } GLFWAPI void glfwMaximizeWindow(GLFWwindow* handle) @@ -758,7 +758,7 @@ GLFWAPI void glfwMaximizeWindow(GLFWwindow* handle) if (window->monitor) return; - _glfwPlatformMaximizeWindow(window); + _glfw.platform.maximizeWindow(window); } GLFWAPI void glfwShowWindow(GLFWwindow* handle) @@ -771,10 +771,10 @@ GLFWAPI void glfwShowWindow(GLFWwindow* handle) if (window->monitor) return; - _glfwPlatformShowWindow(window); + _glfw.platform.showWindow(window); if (window->focusOnShow) - _glfwPlatformFocusWindow(window); + _glfw.platform.focusWindow(window); } GLFWAPI void glfwRequestWindowAttention(GLFWwindow* handle) @@ -784,7 +784,7 @@ GLFWAPI void glfwRequestWindowAttention(GLFWwindow* handle) _GLFW_REQUIRE_INIT(); - _glfwPlatformRequestWindowAttention(window); + _glfw.platform.requestWindowAttention(window); } GLFWAPI void glfwHideWindow(GLFWwindow* handle) @@ -797,7 +797,7 @@ GLFWAPI void glfwHideWindow(GLFWwindow* handle) if (window->monitor) return; - _glfwPlatformHideWindow(window); + _glfw.platform.hideWindow(window); } GLFWAPI void glfwFocusWindow(GLFWwindow* handle) @@ -807,7 +807,7 @@ GLFWAPI void glfwFocusWindow(GLFWwindow* handle) _GLFW_REQUIRE_INIT(); - _glfwPlatformFocusWindow(window); + _glfw.platform.focusWindow(window); } GLFWAPI int glfwGetWindowAttrib(GLFWwindow* handle, int attrib) @@ -820,21 +820,21 @@ GLFWAPI int glfwGetWindowAttrib(GLFWwindow* handle, int attrib) switch (attrib) { case GLFW_FOCUSED: - return _glfwPlatformWindowFocused(window); + return _glfw.platform.windowFocused(window); case GLFW_ICONIFIED: - return _glfwPlatformWindowIconified(window); + return _glfw.platform.windowIconified(window); case GLFW_VISIBLE: - return _glfwPlatformWindowVisible(window); + return _glfw.platform.windowVisible(window); case GLFW_MAXIMIZED: - return _glfwPlatformWindowMaximized(window); + return _glfw.platform.windowMaximized(window); case GLFW_HOVERED: - return _glfwPlatformWindowHovered(window); + return _glfw.platform.windowHovered(window); case GLFW_FOCUS_ON_SHOW: return window->focusOnShow; case GLFW_MOUSE_PASSTHROUGH: return window->mousePassthrough; case GLFW_TRANSPARENT_FRAMEBUFFER: - return _glfwPlatformFramebufferTransparent(window); + return _glfw.platform.framebufferTransparent(window); case GLFW_RESIZABLE: return window->resizable; case GLFW_DECORATED: @@ -888,26 +888,26 @@ GLFWAPI void glfwSetWindowAttrib(GLFWwindow* handle, int attrib, int value) { window->resizable = value; if (!window->monitor) - _glfwPlatformSetWindowResizable(window, value); + _glfw.platform.setWindowResizable(window, value); } else if (attrib == GLFW_DECORATED) { window->decorated = value; if (!window->monitor) - _glfwPlatformSetWindowDecorated(window, value); + _glfw.platform.setWindowDecorated(window, value); } else if (attrib == GLFW_FLOATING) { window->floating = value; if (!window->monitor) - _glfwPlatformSetWindowFloating(window, value); + _glfw.platform.setWindowFloating(window, value); } else if (attrib == GLFW_FOCUS_ON_SHOW) window->focusOnShow = value; else if (attrib == GLFW_MOUSE_PASSTHROUGH) { window->mousePassthrough = value; - _glfwPlatformSetWindowMousePassthrough(window, value); + _glfw.platform.setWindowMousePassthrough(window, value); } else _glfwInputError(GLFW_INVALID_ENUM, "Invalid window attribute 0x%08X", attrib); @@ -956,9 +956,9 @@ GLFWAPI void glfwSetWindowMonitor(GLFWwindow* wh, window->videoMode.height = height; window->videoMode.refreshRate = refreshRate; - _glfwPlatformSetWindowMonitor(window, monitor, - xpos, ypos, width, height, - refreshRate); + _glfw.platform.setWindowMonitor(window, monitor, + xpos, ypos, width, height, + refreshRate); } GLFWAPI void glfwSetWindowUserPointer(GLFWwindow* handle, void* pointer) @@ -1081,13 +1081,13 @@ GLFWAPI GLFWwindowcontentscalefun glfwSetWindowContentScaleCallback(GLFWwindow* GLFWAPI void glfwPollEvents(void) { _GLFW_REQUIRE_INIT(); - _glfwPlatformPollEvents(); + _glfw.platform.pollEvents(); } GLFWAPI void glfwWaitEvents(void) { _GLFW_REQUIRE_INIT(); - _glfwPlatformWaitEvents(); + _glfw.platform.waitEvents(); } GLFWAPI void glfwWaitEventsTimeout(double timeout) @@ -1103,12 +1103,12 @@ GLFWAPI void glfwWaitEventsTimeout(double timeout) return; } - _glfwPlatformWaitEventsTimeout(timeout); + _glfw.platform.waitEventsTimeout(timeout); } GLFWAPI void glfwPostEmptyEvent(void) { _GLFW_REQUIRE_INIT(); - _glfwPlatformPostEmptyEvent(); + _glfw.platform.postEmptyEvent(); } diff --git a/src/wl_init.c b/src/wl_init.c index 609283f6..031e5d52 100644 --- a/src/wl_init.c +++ b/src/wl_init.c @@ -123,7 +123,7 @@ static void pointerHandleEnter(void* data, window->wl.hovered = GLFW_TRUE; - _glfwPlatformSetCursor(window, window->wl.currentCursor); + _glfwSetCursorWayland(window, window->wl.currentCursor); _glfwInputCursorEnter(window, GLFW_TRUE); } @@ -1045,7 +1045,136 @@ static void createKeyTables(void) ////// GLFW platform API ////// ////////////////////////////////////////////////////////////////////////// -int _glfwPlatformInit(void) +GLFWbool _glfwConnectWayland(int platformID, _GLFWplatform* platform) +{ + const _GLFWplatform wayland = + { + GLFW_PLATFORM_WAYLAND, + _glfwInitWayland, + _glfwTerminateWayland, + _glfwGetCursorPosWayland, + _glfwSetCursorPosWayland, + _glfwSetCursorModeWayland, + _glfwSetRawMouseMotionWayland, + _glfwRawMouseMotionSupportedWayland, + _glfwCreateCursorWayland, + _glfwCreateStandardCursorWayland, + _glfwDestroyCursorWayland, + _glfwSetCursorWayland, + _glfwGetScancodeNameWayland, + _glfwGetKeyScancodeWayland, + _glfwSetClipboardStringWayland, + _glfwGetClipboardStringWayland, +#if defined(__linux__) + _glfwInitJoysticksLinux, + _glfwTerminateJoysticksLinux, + _glfwPollJoystickLinux, + _glfwGetMappingNameLinux, + _glfwUpdateGamepadGUIDLinux, +#else + _glfwInitJoysticksNull, + _glfwTerminateJoysticksNull, + _glfwPollJoystickNull, + _glfwGetMappingNameNull, + _glfwUpdateGamepadGUIDNull, +#endif + _glfwFreeMonitorWayland, + _glfwGetMonitorPosWayland, + _glfwGetMonitorContentScaleWayland, + _glfwGetMonitorWorkareaWayland, + _glfwGetVideoModesWayland, + _glfwGetVideoModeWayland, + _glfwGetGammaRampWayland, + _glfwSetGammaRampWayland, + _glfwCreateWindowWayland, + _glfwDestroyWindowWayland, + _glfwSetWindowTitleWayland, + _glfwSetWindowIconWayland, + _glfwGetWindowPosWayland, + _glfwSetWindowPosWayland, + _glfwGetWindowSizeWayland, + _glfwSetWindowSizeWayland, + _glfwSetWindowSizeLimitsWayland, + _glfwSetWindowAspectRatioWayland, + _glfwGetFramebufferSizeWayland, + _glfwGetWindowFrameSizeWayland, + _glfwGetWindowContentScaleWayland, + _glfwIconifyWindowWayland, + _glfwRestoreWindowWayland, + _glfwMaximizeWindowWayland, + _glfwShowWindowWayland, + _glfwHideWindowWayland, + _glfwRequestWindowAttentionWayland, + _glfwFocusWindowWayland, + _glfwSetWindowMonitorWayland, + _glfwWindowFocusedWayland, + _glfwWindowIconifiedWayland, + _glfwWindowVisibleWayland, + _glfwWindowMaximizedWayland, + _glfwWindowHoveredWayland, + _glfwFramebufferTransparentWayland, + _glfwGetWindowOpacityWayland, + _glfwSetWindowResizableWayland, + _glfwSetWindowDecoratedWayland, + _glfwSetWindowFloatingWayland, + _glfwSetWindowOpacityWayland, + _glfwSetWindowMousePassthroughWayland, + _glfwPollEventsWayland, + _glfwWaitEventsWayland, + _glfwWaitEventsTimeoutWayland, + _glfwPostEmptyEventWayland, + _glfwGetEGLPlatformWayland, + _glfwGetEGLNativeDisplayWayland, + _glfwGetEGLNativeWindowWayland, + _glfwGetRequiredInstanceExtensionsWayland, + _glfwGetPhysicalDevicePresentationSupportWayland, + _glfwCreateWindowSurfaceWayland, + }; + + void* module = _glfwPlatformLoadModule("libwayland-client.so.0"); + if (!module) + { + if (platformID == GLFW_PLATFORM_WAYLAND) + { + _glfwInputError(GLFW_PLATFORM_ERROR, + "Wayland: Failed to open libwayland-client"); + } + + return GLFW_FALSE; + } + + PFN_wl_display_connect wl_display_connect = (PFN_wl_display_connect) + _glfwPlatformGetModuleSymbol(module, "wl_display_connect"); + if (!wl_display_connect) + { + if (platformID == GLFW_PLATFORM_WAYLAND) + { + _glfwInputError(GLFW_PLATFORM_ERROR, + "Wayland: Failed to load libwayland-client entry point"); + } + + _glfwPlatformFreeModule(module); + return GLFW_FALSE; + } + + struct wl_display* display = wl_display_connect(NULL); + if (!display) + { + if (platformID == GLFW_PLATFORM_WAYLAND) + _glfwInputError(GLFW_PLATFORM_ERROR, "Wayland: Failed to connect to display"); + + _glfwPlatformFreeModule(module); + return GLFW_FALSE; + } + + _glfw.wl.display = display; + _glfw.wl.client.handle = module; + + *platform = wayland; + return GLFW_TRUE; +} + +int _glfwInitWayland(void) { const char *cursorTheme; const char *cursorSizeStr; @@ -1053,14 +1182,6 @@ int _glfwPlatformInit(void) long cursorSizeLong; int cursorSize; - _glfw.wl.client.handle = _glfwPlatformLoadModule("libwayland-client.so.0"); - if (!_glfw.wl.client.handle) - { - _glfwInputError(GLFW_PLATFORM_ERROR, - "Wayland: Failed to open libwayland-client"); - return GLFW_FALSE; - } - _glfw.wl.client.display_flush = (PFN_wl_display_flush) _glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_display_flush"); _glfw.wl.client.display_cancel_read = (PFN_wl_display_cancel_read) @@ -1069,8 +1190,6 @@ int _glfwPlatformInit(void) _glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_display_dispatch_pending"); _glfw.wl.client.display_read_events = (PFN_wl_display_read_events) _glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_display_read_events"); - _glfw.wl.client.display_connect = (PFN_wl_display_connect) - _glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_display_connect"); _glfw.wl.client.display_disconnect = (PFN_wl_display_disconnect) _glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_display_disconnect"); _glfw.wl.client.display_roundtrip = (PFN_wl_display_roundtrip) @@ -1102,7 +1221,6 @@ int _glfwPlatformInit(void) !_glfw.wl.client.display_cancel_read || !_glfw.wl.client.display_dispatch_pending || !_glfw.wl.client.display_read_events || - !_glfw.wl.client.display_connect || !_glfw.wl.client.display_disconnect || !_glfw.wl.client.display_roundtrip || !_glfw.wl.client.display_get_fd || @@ -1200,14 +1318,6 @@ int _glfwPlatformInit(void) _glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_compose_state_get_one_sym"); #endif - _glfw.wl.display = wl_display_connect(NULL); - if (!_glfw.wl.display) - { - _glfwInputError(GLFW_PLATFORM_ERROR, - "Wayland: Failed to connect to display"); - return GLFW_FALSE; - } - _glfw.wl.registry = wl_display_get_registry(_glfw.wl.display); wl_registry_add_listener(_glfw.wl.registry, ®istryListener, NULL); @@ -1285,7 +1395,7 @@ int _glfwPlatformInit(void) return GLFW_TRUE; } -void _glfwPlatformTerminate(void) +void _glfwTerminateWayland(void) { _glfwTerminateEGL(); if (_glfw.wl.egl.handle) @@ -1373,15 +1483,3 @@ void _glfwPlatformTerminate(void) _glfw_free(_glfw.wl.clipboardSendString); } -const char* _glfwPlatformGetVersionString(void) -{ - return _GLFW_VERSION_NUMBER " Wayland EGL OSMesa" -#if defined(_POSIX_MONOTONIC_CLOCK) - " monotonic" -#endif - " evdev" -#if defined(_GLFW_BUILD_DLL) - " shared" -#endif - ; -} diff --git a/src/wl_monitor.c b/src/wl_monitor.c index 11f586ad..5bdda918 100644 --- a/src/wl_monitor.c +++ b/src/wl_monitor.c @@ -157,13 +157,13 @@ void _glfwAddOutputWayland(uint32_t name, uint32_t version) ////// GLFW platform API ////// ////////////////////////////////////////////////////////////////////////// -void _glfwPlatformFreeMonitor(_GLFWmonitor* monitor) +void _glfwFreeMonitorWayland(_GLFWmonitor* monitor) { if (monitor->wl.output) wl_output_destroy(monitor->wl.output); } -void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos) +void _glfwGetMonitorPosWayland(_GLFWmonitor* monitor, int* xpos, int* ypos) { if (xpos) *xpos = monitor->wl.x; @@ -171,8 +171,8 @@ void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos) *ypos = monitor->wl.y; } -void _glfwPlatformGetMonitorContentScale(_GLFWmonitor* monitor, - float* xscale, float* yscale) +void _glfwGetMonitorContentScaleWayland(_GLFWmonitor* monitor, + float* xscale, float* yscale) { if (xscale) *xscale = (float) monitor->wl.scale; @@ -180,9 +180,9 @@ void _glfwPlatformGetMonitorContentScale(_GLFWmonitor* monitor, *yscale = (float) monitor->wl.scale; } -void _glfwPlatformGetMonitorWorkarea(_GLFWmonitor* monitor, - int* xpos, int* ypos, - int* width, int* height) +void _glfwGetMonitorWorkareaWayland(_GLFWmonitor* monitor, + int* xpos, int* ypos, + int* width, int* height) { if (xpos) *xpos = monitor->wl.x; @@ -194,26 +194,25 @@ void _glfwPlatformGetMonitorWorkarea(_GLFWmonitor* monitor, *height = monitor->modes[monitor->wl.currentMode].height; } -GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* found) +GLFWvidmode* _glfwGetVideoModesWayland(_GLFWmonitor* monitor, int* found) { *found = monitor->modeCount; return monitor->modes; } -void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode) +void _glfwGetVideoModeWayland(_GLFWmonitor* monitor, GLFWvidmode* mode) { *mode = monitor->modes[monitor->wl.currentMode]; } -GLFWbool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp) +GLFWbool _glfwGetGammaRampWayland(_GLFWmonitor* monitor, GLFWgammaramp* ramp) { _glfwInputError(GLFW_FEATURE_UNAVAILABLE, "Wayland: Gamma ramp access is not available"); return GLFW_FALSE; } -void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, - const GLFWgammaramp* ramp) +void _glfwSetGammaRampWayland(_GLFWmonitor* monitor, const GLFWgammaramp* ramp) { _glfwInputError(GLFW_FEATURE_UNAVAILABLE, "Wayland: Gamma ramp access is not available"); diff --git a/src/wl_platform.h b/src/wl_platform.h index 71512b59..1e36a794 100644 --- a/src/wl_platform.h +++ b/src/wl_platform.h @@ -44,13 +44,6 @@ typedef struct VkWaylandSurfaceCreateInfoKHR typedef VkResult (APIENTRY *PFN_vkCreateWaylandSurfaceKHR)(VkInstance,const VkWaylandSurfaceCreateInfoKHR*,const VkAllocationCallbacks*,VkSurfaceKHR*); typedef VkBool32 (APIENTRY *PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR)(VkPhysicalDevice,uint32_t,struct wl_display*); -#include "posix_thread.h" -#include "posix_time.h" -#ifdef __linux__ -#include "linux_joystick.h" -#else -#include "null_joystick.h" -#endif #include "xkb_unicode.h" typedef int (* PFN_wl_display_flush)(struct wl_display *display); @@ -75,7 +68,6 @@ typedef struct wl_proxy* (* PFN_wl_proxy_marshal_flags)(struct wl_proxy*,uint32_ #define wl_display_cancel_read _glfw.wl.client.display_cancel_read #define wl_display_dispatch_pending _glfw.wl.client.display_dispatch_pending #define wl_display_read_events _glfw.wl.client.display_read_events -#define wl_display_connect _glfw.wl.client.display_connect #define wl_display_disconnect _glfw.wl.client.display_disconnect #define wl_display_roundtrip _glfw.wl.client.display_roundtrip #define wl_display_get_fd _glfw.wl.client.display_get_fd @@ -132,13 +124,10 @@ struct wl_shm; #define xdg_toplevel_interface _glfw_xdg_toplevel_interface #define xdg_wm_base_interface _glfw_xdg_wm_base_interface -#define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowWayland wl -#define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryWayland wl -#define _GLFW_PLATFORM_MONITOR_STATE _GLFWmonitorWayland wl -#define _GLFW_PLATFORM_CURSOR_STATE _GLFWcursorWayland wl - -#define _GLFW_PLATFORM_CONTEXT_STATE struct { int dummyContext; } -#define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE struct { int dummyLibraryContext; } +#define GLFW_WAYLAND_WINDOW_STATE _GLFWwindowWayland wl; +#define GLFW_WAYLAND_LIBRARY_WINDOW_STATE _GLFWlibraryWayland wl; +#define GLFW_WAYLAND_MONITOR_STATE _GLFWmonitorWayland wl; +#define GLFW_WAYLAND_CURSOR_STATE _GLFWcursorWayland wl; struct wl_cursor_image { uint32_t width; @@ -373,7 +362,6 @@ typedef struct _GLFWlibraryWayland PFN_wl_display_cancel_read display_cancel_read; PFN_wl_display_dispatch_pending display_dispatch_pending; PFN_wl_display_read_events display_read_events; - PFN_wl_display_connect display_connect; PFN_wl_display_disconnect display_disconnect; PFN_wl_display_roundtrip display_roundtrip; PFN_wl_display_get_fd display_get_fd; @@ -432,6 +420,80 @@ typedef struct _GLFWcursorWayland int currentImage; } _GLFWcursorWayland; +GLFWbool _glfwConnectWayland(int platformID, _GLFWplatform* platform); +int _glfwInitWayland(void); +void _glfwTerminateWayland(void); + +int _glfwCreateWindowWayland(_GLFWwindow* window, const _GLFWwndconfig* wndconfig, const _GLFWctxconfig* ctxconfig, const _GLFWfbconfig* fbconfig); +void _glfwDestroyWindowWayland(_GLFWwindow* window); +void _glfwSetWindowTitleWayland(_GLFWwindow* window, const char* title); +void _glfwSetWindowIconWayland(_GLFWwindow* window, int count, const GLFWimage* images); +void _glfwGetWindowPosWayland(_GLFWwindow* window, int* xpos, int* ypos); +void _glfwSetWindowPosWayland(_GLFWwindow* window, int xpos, int ypos); +void _glfwGetWindowSizeWayland(_GLFWwindow* window, int* width, int* height); +void _glfwSetWindowSizeWayland(_GLFWwindow* window, int width, int height); +void _glfwSetWindowSizeLimitsWayland(_GLFWwindow* window, int minwidth, int minheight, int maxwidth, int maxheight); +void _glfwSetWindowAspectRatioWayland(_GLFWwindow* window, int numer, int denom); +void _glfwGetFramebufferSizeWayland(_GLFWwindow* window, int* width, int* height); +void _glfwGetWindowFrameSizeWayland(_GLFWwindow* window, int* left, int* top, int* right, int* bottom); +void _glfwGetWindowContentScaleWayland(_GLFWwindow* window, float* xscale, float* yscale); +void _glfwIconifyWindowWayland(_GLFWwindow* window); +void _glfwRestoreWindowWayland(_GLFWwindow* window); +void _glfwMaximizeWindowWayland(_GLFWwindow* window); +void _glfwShowWindowWayland(_GLFWwindow* window); +void _glfwHideWindowWayland(_GLFWwindow* window); +void _glfwRequestWindowAttentionWayland(_GLFWwindow* window); +void _glfwFocusWindowWayland(_GLFWwindow* window); +void _glfwSetWindowMonitorWayland(_GLFWwindow* window, _GLFWmonitor* monitor, int xpos, int ypos, int width, int height, int refreshRate); +int _glfwWindowFocusedWayland(_GLFWwindow* window); +int _glfwWindowIconifiedWayland(_GLFWwindow* window); +int _glfwWindowVisibleWayland(_GLFWwindow* window); +int _glfwWindowMaximizedWayland(_GLFWwindow* window); +int _glfwWindowHoveredWayland(_GLFWwindow* window); +int _glfwFramebufferTransparentWayland(_GLFWwindow* window); +void _glfwSetWindowResizableWayland(_GLFWwindow* window, GLFWbool enabled); +void _glfwSetWindowDecoratedWayland(_GLFWwindow* window, GLFWbool enabled); +void _glfwSetWindowFloatingWayland(_GLFWwindow* window, GLFWbool enabled); +float _glfwGetWindowOpacityWayland(_GLFWwindow* window); +void _glfwSetWindowOpacityWayland(_GLFWwindow* window, float opacity); +void _glfwSetWindowMousePassthroughWayland(_GLFWwindow* window, GLFWbool enabled); + +void _glfwSetRawMouseMotionWayland(_GLFWwindow *window, GLFWbool enabled); +GLFWbool _glfwRawMouseMotionSupportedWayland(void); + +void _glfwPollEventsWayland(void); +void _glfwWaitEventsWayland(void); +void _glfwWaitEventsTimeoutWayland(double timeout); +void _glfwPostEmptyEventWayland(void); + +void _glfwGetCursorPosWayland(_GLFWwindow* window, double* xpos, double* ypos); +void _glfwSetCursorPosWayland(_GLFWwindow* window, double xpos, double ypos); +void _glfwSetCursorModeWayland(_GLFWwindow* window, int mode); +const char* _glfwGetScancodeNameWayland(int scancode); +int _glfwGetKeyScancodeWayland(int key); +int _glfwCreateCursorWayland(_GLFWcursor* cursor, const GLFWimage* image, int xhot, int yhot); +int _glfwCreateStandardCursorWayland(_GLFWcursor* cursor, int shape); +void _glfwDestroyCursorWayland(_GLFWcursor* cursor); +void _glfwSetCursorWayland(_GLFWwindow* window, _GLFWcursor* cursor); +void _glfwSetClipboardStringWayland(const char* string); +const char* _glfwGetClipboardStringWayland(void); + +EGLenum _glfwGetEGLPlatformWayland(EGLint** attribs); +EGLNativeDisplayType _glfwGetEGLNativeDisplayWayland(void); +EGLNativeWindowType _glfwGetEGLNativeWindowWayland(_GLFWwindow* window); + +void _glfwGetRequiredInstanceExtensionsWayland(char** extensions); +int _glfwGetPhysicalDevicePresentationSupportWayland(VkInstance instance, VkPhysicalDevice device, uint32_t queuefamily); +VkResult _glfwCreateWindowSurfaceWayland(VkInstance instance, _GLFWwindow* window, const VkAllocationCallbacks* allocator, VkSurfaceKHR* surface); + +void _glfwFreeMonitorWayland(_GLFWmonitor* monitor); +void _glfwGetMonitorPosWayland(_GLFWmonitor* monitor, int* xpos, int* ypos); +void _glfwGetMonitorContentScaleWayland(_GLFWmonitor* monitor, float* xscale, float* yscale); +void _glfwGetMonitorWorkareaWayland(_GLFWmonitor* monitor, int* xpos, int* ypos, int* width, int* height); +GLFWvidmode* _glfwGetVideoModesWayland(_GLFWmonitor* monitor, int* count); +void _glfwGetVideoModeWayland(_GLFWmonitor* monitor, GLFWvidmode* mode); +GLFWbool _glfwGetGammaRampWayland(_GLFWmonitor* monitor, GLFWgammaramp* ramp); +void _glfwSetGammaRampWayland(_GLFWmonitor* monitor, const GLFWgammaramp* ramp); void _glfwAddOutputWayland(uint32_t name, uint32_t version); diff --git a/src/wl_window.c b/src/wl_window.c index 06cd7084..bf57ce53 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -526,7 +526,7 @@ static void xdgToplevelHandleConfigure(void* data, } _glfwInputWindowSize(window, width, height); - _glfwPlatformSetWindowSize(window, width, height); + _glfwSetWindowSizeWayland(window, width, height); _glfwInputWindowDamage(window); } @@ -534,7 +534,7 @@ static void xdgToplevelHandleConfigure(void* data, { if (!activated || !fullscreen) { - _glfwPlatformIconifyWindow(window); + _glfwIconifyWindowWayland(window); window->wl.wasFullscreen = GLFW_FALSE; } } @@ -789,10 +789,10 @@ static void handleEvents(int timeout) ////// GLFW platform API ////// ////////////////////////////////////////////////////////////////////////// -int _glfwPlatformCreateWindow(_GLFWwindow* window, - const _GLFWwndconfig* wndconfig, - const _GLFWctxconfig* ctxconfig, - const _GLFWfbconfig* fbconfig) +int _glfwCreateWindowWayland(_GLFWwindow* window, + const _GLFWwndconfig* wndconfig, + const _GLFWctxconfig* ctxconfig, + const _GLFWfbconfig* fbconfig) { window->wl.transparent = fbconfig->transparent; @@ -844,7 +844,7 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window, return GLFW_TRUE; } -void _glfwPlatformDestroyWindow(_GLFWwindow* window) +void _glfwDestroyWindowWayland(_GLFWwindow* window) { if (window == _glfw.wl.pointerFocus) { @@ -886,7 +886,7 @@ void _glfwPlatformDestroyWindow(_GLFWwindow* window) _glfw_free(window->wl.monitors); } -void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title) +void _glfwSetWindowTitleWayland(_GLFWwindow* window, const char* title) { if (window->wl.title) _glfw_free(window->wl.title); @@ -895,14 +895,14 @@ void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title) xdg_toplevel_set_title(window->wl.xdg.toplevel, title); } -void _glfwPlatformSetWindowIcon(_GLFWwindow* window, - int count, const GLFWimage* images) +void _glfwSetWindowIconWayland(_GLFWwindow* window, + int count, const GLFWimage* images) { _glfwInputError(GLFW_FEATURE_UNAVAILABLE, "Wayland: The platform does not support setting the window icon"); } -void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos) +void _glfwGetWindowPosWayland(_GLFWwindow* window, int* xpos, int* ypos) { // A Wayland client is not aware of its position, so just warn and leave it // as (0, 0) @@ -911,7 +911,7 @@ void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos) "Wayland: The platform does not provide the window position"); } -void _glfwPlatformSetWindowPos(_GLFWwindow* window, int xpos, int ypos) +void _glfwSetWindowPosWayland(_GLFWwindow* window, int xpos, int ypos) { // A Wayland client can not set its position, so just warn @@ -919,7 +919,7 @@ void _glfwPlatformSetWindowPos(_GLFWwindow* window, int xpos, int ypos) "Wayland: The platform does not support setting the window position"); } -void _glfwPlatformGetWindowSize(_GLFWwindow* window, int* width, int* height) +void _glfwGetWindowSizeWayland(_GLFWwindow* window, int* width, int* height) { if (width) *width = window->wl.width; @@ -927,16 +927,16 @@ void _glfwPlatformGetWindowSize(_GLFWwindow* window, int* width, int* height) *height = window->wl.height; } -void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height) +void _glfwSetWindowSizeWayland(_GLFWwindow* window, int width, int height) { window->wl.width = width; window->wl.height = height; resizeWindow(window); } -void _glfwPlatformSetWindowSizeLimits(_GLFWwindow* window, - int minwidth, int minheight, - int maxwidth, int maxheight) +void _glfwSetWindowSizeLimitsWayland(_GLFWwindow* window, + int minwidth, int minheight, + int maxwidth, int maxheight) { if (window->wl.xdg.toplevel) { @@ -950,8 +950,7 @@ void _glfwPlatformSetWindowSizeLimits(_GLFWwindow* window, } } -void _glfwPlatformSetWindowAspectRatio(_GLFWwindow* window, - int numer, int denom) +void _glfwSetWindowAspectRatioWayland(_GLFWwindow* window, int numer, int denom) { // TODO: find out how to trigger a resize. // The actual limits are checked in the xdg_toplevel::configure handler. @@ -959,19 +958,18 @@ void _glfwPlatformSetWindowAspectRatio(_GLFWwindow* window, "Wayland: Window aspect ratio not yet implemented"); } -void _glfwPlatformGetFramebufferSize(_GLFWwindow* window, - int* width, int* height) +void _glfwGetFramebufferSizeWayland(_GLFWwindow* window, int* width, int* height) { - _glfwPlatformGetWindowSize(window, width, height); + _glfwGetWindowSizeWayland(window, width, height); if (width) *width *= window->wl.scale; if (height) *height *= window->wl.scale; } -void _glfwPlatformGetWindowFrameSize(_GLFWwindow* window, - int* left, int* top, - int* right, int* bottom) +void _glfwGetWindowFrameSizeWayland(_GLFWwindow* window, + int* left, int* top, + int* right, int* bottom) { if (window->decorated && !window->monitor && !window->wl.decorations.serverSide) { @@ -986,8 +984,8 @@ void _glfwPlatformGetWindowFrameSize(_GLFWwindow* window, } } -void _glfwPlatformGetWindowContentScale(_GLFWwindow* window, - float* xscale, float* yscale) +void _glfwGetWindowContentScaleWayland(_GLFWwindow* window, + float* xscale, float* yscale) { if (xscale) *xscale = (float) window->wl.scale; @@ -995,13 +993,13 @@ void _glfwPlatformGetWindowContentScale(_GLFWwindow* window, *yscale = (float) window->wl.scale; } -void _glfwPlatformIconifyWindow(_GLFWwindow* window) +void _glfwIconifyWindowWayland(_GLFWwindow* window) { if (window->wl.xdg.toplevel) xdg_toplevel_set_minimized(window->wl.xdg.toplevel); } -void _glfwPlatformRestoreWindow(_GLFWwindow* window) +void _glfwRestoreWindowWayland(_GLFWwindow* window) { if (window->wl.xdg.toplevel) { @@ -1016,7 +1014,7 @@ void _glfwPlatformRestoreWindow(_GLFWwindow* window) window->wl.maximized = GLFW_FALSE; } -void _glfwPlatformMaximizeWindow(_GLFWwindow* window) +void _glfwMaximizeWindowWayland(_GLFWwindow* window) { if (window->wl.xdg.toplevel) { @@ -1025,7 +1023,7 @@ void _glfwPlatformMaximizeWindow(_GLFWwindow* window) window->wl.maximized = GLFW_TRUE; } -void _glfwPlatformShowWindow(_GLFWwindow* window) +void _glfwShowWindowWayland(_GLFWwindow* window) { if (!window->wl.visible) { @@ -1034,7 +1032,7 @@ void _glfwPlatformShowWindow(_GLFWwindow* window) } } -void _glfwPlatformHideWindow(_GLFWwindow* window) +void _glfwHideWindowWayland(_GLFWwindow* window) { if (window->wl.xdg.toplevel) { @@ -1046,24 +1044,24 @@ void _glfwPlatformHideWindow(_GLFWwindow* window) window->wl.visible = GLFW_FALSE; } -void _glfwPlatformRequestWindowAttention(_GLFWwindow* window) +void _glfwRequestWindowAttentionWayland(_GLFWwindow* window) { // TODO _glfwInputError(GLFW_FEATURE_UNIMPLEMENTED, "Wayland: Window attention request not implemented yet"); } -void _glfwPlatformFocusWindow(_GLFWwindow* window) +void _glfwFocusWindowWayland(_GLFWwindow* window) { _glfwInputError(GLFW_FEATURE_UNAVAILABLE, "Wayland: The platform does not support setting the input focus"); } -void _glfwPlatformSetWindowMonitor(_GLFWwindow* window, - _GLFWmonitor* monitor, - int xpos, int ypos, - int width, int height, - int refreshRate) +void _glfwSetWindowMonitorWayland(_GLFWwindow* window, + _GLFWmonitor* monitor, + int xpos, int ypos, + int width, int height, + int refreshRate) { if (monitor) { @@ -1080,46 +1078,46 @@ void _glfwPlatformSetWindowMonitor(_GLFWwindow* window, _glfwInputWindowMonitor(window, monitor); } -int _glfwPlatformWindowFocused(_GLFWwindow* window) +int _glfwWindowFocusedWayland(_GLFWwindow* window) { return _glfw.wl.keyboardFocus == window; } -int _glfwPlatformWindowIconified(_GLFWwindow* window) +int _glfwWindowIconifiedWayland(_GLFWwindow* window) { // xdg-shell doesn’t give any way to request whether a surface is // iconified. return GLFW_FALSE; } -int _glfwPlatformWindowVisible(_GLFWwindow* window) +int _glfwWindowVisibleWayland(_GLFWwindow* window) { return window->wl.visible; } -int _glfwPlatformWindowMaximized(_GLFWwindow* window) +int _glfwWindowMaximizedWayland(_GLFWwindow* window) { return window->wl.maximized; } -int _glfwPlatformWindowHovered(_GLFWwindow* window) +int _glfwWindowHoveredWayland(_GLFWwindow* window) { return window->wl.hovered; } -int _glfwPlatformFramebufferTransparent(_GLFWwindow* window) +int _glfwFramebufferTransparentWayland(_GLFWwindow* window) { return window->wl.transparent; } -void _glfwPlatformSetWindowResizable(_GLFWwindow* window, GLFWbool enabled) +void _glfwSetWindowResizableWayland(_GLFWwindow* window, GLFWbool enabled) { // TODO _glfwInputError(GLFW_FEATURE_UNIMPLEMENTED, "Wayland: Window attribute setting not implemented yet"); } -void _glfwPlatformSetWindowDecorated(_GLFWwindow* window, GLFWbool enabled) +void _glfwSetWindowDecoratedWayland(_GLFWwindow* window, GLFWbool enabled) { if (!window->monitor) { @@ -1130,14 +1128,14 @@ void _glfwPlatformSetWindowDecorated(_GLFWwindow* window, GLFWbool enabled) } } -void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled) +void _glfwSetWindowFloatingWayland(_GLFWwindow* window, GLFWbool enabled) { // TODO _glfwInputError(GLFW_FEATURE_UNIMPLEMENTED, "Wayland: Window attribute setting not implemented yet"); } -void _glfwPlatformSetWindowMousePassthrough(_GLFWwindow* window, GLFWbool enabled) +void _glfwSetWindowMousePassthroughWayland(_GLFWwindow* window, GLFWbool enabled) { if (enabled) { @@ -1150,48 +1148,48 @@ void _glfwPlatformSetWindowMousePassthrough(_GLFWwindow* window, GLFWbool enable wl_surface_commit(window->wl.surface); } -float _glfwPlatformGetWindowOpacity(_GLFWwindow* window) +float _glfwGetWindowOpacityWayland(_GLFWwindow* window) { return 1.f; } -void _glfwPlatformSetWindowOpacity(_GLFWwindow* window, float opacity) +void _glfwSetWindowOpacityWayland(_GLFWwindow* window, float opacity) { _glfwInputError(GLFW_FEATURE_UNAVAILABLE, "Wayland: The platform does not support setting the window opacity"); } -void _glfwPlatformSetRawMouseMotion(_GLFWwindow *window, GLFWbool enabled) +void _glfwSetRawMouseMotionWayland(_GLFWwindow *window, GLFWbool enabled) { // This is handled in relativePointerHandleRelativeMotion } -GLFWbool _glfwPlatformRawMouseMotionSupported(void) +GLFWbool _glfwRawMouseMotionSupportedWayland(void) { return GLFW_TRUE; } -void _glfwPlatformPollEvents(void) +void _glfwPollEventsWayland(void) { handleEvents(0); } -void _glfwPlatformWaitEvents(void) +void _glfwWaitEventsWayland(void) { handleEvents(-1); } -void _glfwPlatformWaitEventsTimeout(double timeout) +void _glfwWaitEventsTimeoutWayland(double timeout) { handleEvents((int) (timeout * 1e3)); } -void _glfwPlatformPostEmptyEvent(void) +void _glfwPostEmptyEventWayland(void) { wl_display_sync(_glfw.wl.display); } -void _glfwPlatformGetCursorPos(_GLFWwindow* window, double* xpos, double* ypos) +void _glfwGetCursorPosWayland(_GLFWwindow* window, double* xpos, double* ypos) { if (xpos) *xpos = window->wl.cursorPosX; @@ -1201,7 +1199,7 @@ void _glfwPlatformGetCursorPos(_GLFWwindow* window, double* xpos, double* ypos) static GLFWbool isPointerLocked(_GLFWwindow* window); -void _glfwPlatformSetCursorPos(_GLFWwindow* window, double x, double y) +void _glfwSetCursorPosWayland(_GLFWwindow* window, double x, double y) { if (isPointerLocked(window)) { @@ -1212,12 +1210,12 @@ void _glfwPlatformSetCursorPos(_GLFWwindow* window, double x, double y) } } -void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode) +void _glfwSetCursorModeWayland(_GLFWwindow* window, int mode) { - _glfwPlatformSetCursor(window, window->wl.currentCursor); + _glfwSetCursorWayland(window, window->wl.currentCursor); } -const char* _glfwPlatformGetScancodeName(int scancode) +const char* _glfwGetScancodeNameWayland(int scancode) { // TODO _glfwInputError(GLFW_FEATURE_UNIMPLEMENTED, @@ -1225,14 +1223,14 @@ const char* _glfwPlatformGetScancodeName(int scancode) return NULL; } -int _glfwPlatformGetKeyScancode(int key) +int _glfwGetKeyScancodeWayland(int key) { return _glfw.wl.scancodes[key]; } -int _glfwPlatformCreateCursor(_GLFWcursor* cursor, - const GLFWimage* image, - int xhot, int yhot) +int _glfwCreateCursorWayland(_GLFWcursor* cursor, + const GLFWimage* image, + int xhot, int yhot) { cursor->wl.buffer = createShmBuffer(image); if (!cursor->wl.buffer) @@ -1245,7 +1243,7 @@ int _glfwPlatformCreateCursor(_GLFWcursor* cursor, return GLFW_TRUE; } -int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape) +int _glfwCreateStandardCursorWayland(_GLFWcursor* cursor, int shape) { const char* name = NULL; @@ -1346,7 +1344,7 @@ int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape) return GLFW_TRUE; } -void _glfwPlatformDestroyCursor(_GLFWcursor* cursor) +void _glfwDestroyCursorWayland(_GLFWcursor* cursor) { // If it's a standard cursor we don't need to do anything here if (cursor->wl.cursor) @@ -1464,7 +1462,7 @@ static GLFWbool isPointerLocked(_GLFWwindow* window) return window->wl.pointerLock.lockedPointer != NULL; } -void _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor) +void _glfwSetCursorWayland(_GLFWwindow* window, _GLFWcursor* cursor) { struct wl_cursor* defaultCursor; struct wl_cursor* defaultCursorHiDPI = NULL; @@ -1605,7 +1603,7 @@ static const struct wl_data_source_listener dataSourceListener = { dataSourceHandleCancelled, }; -void _glfwPlatformSetClipboardString(const char* string) +void _glfwSetClipboardStringWayland(const char* string) { if (_glfw.wl.dataSource) { @@ -1661,7 +1659,7 @@ static GLFWbool growClipboardString(void) return GLFW_TRUE; } -const char* _glfwPlatformGetClipboardString(void) +const char* _glfwGetClipboardStringWayland(void) { int fds[2]; int ret; @@ -1728,7 +1726,7 @@ const char* _glfwPlatformGetClipboardString(void) return _glfw.wl.clipboardString; } -EGLenum _glfwPlatformGetEGLPlatform(EGLint** attribs) +EGLenum _glfwGetEGLPlatformWayland(EGLint** attribs) { if (_glfw.egl.EXT_platform_base && _glfw.egl.EXT_platform_wayland) return EGL_PLATFORM_WAYLAND_EXT; @@ -1736,17 +1734,17 @@ EGLenum _glfwPlatformGetEGLPlatform(EGLint** attribs) return 0; } -EGLNativeDisplayType _glfwPlatformGetEGLNativeDisplay(void) +EGLNativeDisplayType _glfwGetEGLNativeDisplayWayland(void) { return _glfw.wl.display; } -EGLNativeWindowType _glfwPlatformGetEGLNativeWindow(_GLFWwindow* window) +EGLNativeWindowType _glfwGetEGLNativeWindowWayland(_GLFWwindow* window) { return window->wl.native; } -void _glfwPlatformGetRequiredInstanceExtensions(char** extensions) +void _glfwGetRequiredInstanceExtensionsWayland(char** extensions) { if (!_glfw.vk.KHR_surface || !_glfw.vk.KHR_wayland_surface) return; @@ -1755,9 +1753,9 @@ void _glfwPlatformGetRequiredInstanceExtensions(char** extensions) extensions[1] = "VK_KHR_wayland_surface"; } -int _glfwPlatformGetPhysicalDevicePresentationSupport(VkInstance instance, - VkPhysicalDevice device, - uint32_t queuefamily) +int _glfwGetPhysicalDevicePresentationSupportWayland(VkInstance instance, + VkPhysicalDevice device, + uint32_t queuefamily) { PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR vkGetPhysicalDeviceWaylandPresentationSupportKHR = @@ -1775,10 +1773,10 @@ int _glfwPlatformGetPhysicalDevicePresentationSupport(VkInstance instance, _glfw.wl.display); } -VkResult _glfwPlatformCreateWindowSurface(VkInstance instance, - _GLFWwindow* window, - const VkAllocationCallbacks* allocator, - VkSurfaceKHR* surface) +VkResult _glfwCreateWindowSurfaceWayland(VkInstance instance, + _GLFWwindow* window, + const VkAllocationCallbacks* allocator, + VkSurfaceKHR* surface) { VkResult err; VkWaylandSurfaceCreateInfoKHR sci; @@ -1817,6 +1815,14 @@ VkResult _glfwPlatformCreateWindowSurface(VkInstance instance, GLFWAPI struct wl_display* glfwGetWaylandDisplay(void) { _GLFW_REQUIRE_INIT_OR_RETURN(NULL); + + if (_glfw.platform.platformID != GLFW_PLATFORM_WAYLAND) + { + _glfwInputError(GLFW_PLATFORM_UNAVAILABLE, + "Wayland: Platform not initialized"); + return NULL; + } + return _glfw.wl.display; } @@ -1824,6 +1830,14 @@ GLFWAPI struct wl_surface* glfwGetWaylandWindow(GLFWwindow* handle) { _GLFWwindow* window = (_GLFWwindow*) handle; _GLFW_REQUIRE_INIT_OR_RETURN(NULL); + + if (_glfw.platform.platformID != GLFW_PLATFORM_WAYLAND) + { + _glfwInputError(GLFW_PLATFORM_UNAVAILABLE, + "Wayland: Platform not initialized"); + return NULL; + } + return window->wl.surface; } diff --git a/src/x11_init.c b/src/x11_init.c index 34e52252..bedd1bc9 100644 --- a/src/x11_init.c +++ b/src/x11_init.c @@ -1007,7 +1007,7 @@ static Cursor createHiddenCursor(void) { unsigned char pixels[16 * 16 * 4] = { 0 }; GLFWimage image = { 16, 16, pixels }; - return _glfwCreateCursorX11(&image, 0, 0); + return _glfwCreateNativeCursorX11(&image, 0, 0); } // Create a helper window for IPC @@ -1070,7 +1070,7 @@ void _glfwInputErrorX11(int error, const char* message) // Creates a native cursor object from the specified image and hotspot // -Cursor _glfwCreateCursorX11(const GLFWimage* image, int xhot, int yhot) +Cursor _glfwCreateNativeCursorX11(const GLFWimage* image, int xhot, int yhot) { int i; Cursor cursor; @@ -1109,8 +1109,92 @@ Cursor _glfwCreateCursorX11(const GLFWimage* image, int xhot, int yhot) ////// GLFW platform API ////// ////////////////////////////////////////////////////////////////////////// -int _glfwPlatformInit(void) +GLFWbool _glfwConnectX11(int platformID, _GLFWplatform* platform) { + const _GLFWplatform x11 = + { + GLFW_PLATFORM_X11, + _glfwInitX11, + _glfwTerminateX11, + _glfwGetCursorPosX11, + _glfwSetCursorPosX11, + _glfwSetCursorModeX11, + _glfwSetRawMouseMotionX11, + _glfwRawMouseMotionSupportedX11, + _glfwCreateCursorX11, + _glfwCreateStandardCursorX11, + _glfwDestroyCursorX11, + _glfwSetCursorX11, + _glfwGetScancodeNameX11, + _glfwGetKeyScancodeX11, + _glfwSetClipboardStringX11, + _glfwGetClipboardStringX11, +#if defined(__linux__) + _glfwInitJoysticksLinux, + _glfwTerminateJoysticksLinux, + _glfwPollJoystickLinux, + _glfwGetMappingNameLinux, + _glfwUpdateGamepadGUIDLinux, +#else + _glfwInitJoysticksNull, + _glfwTerminateJoysticksNull, + _glfwPollJoystickNull, + _glfwGetMappingNameNull, + _glfwUpdateGamepadGUIDNull, +#endif + _glfwFreeMonitorX11, + _glfwGetMonitorPosX11, + _glfwGetMonitorContentScaleX11, + _glfwGetMonitorWorkareaX11, + _glfwGetVideoModesX11, + _glfwGetVideoModeX11, + _glfwGetGammaRampX11, + _glfwSetGammaRampX11, + _glfwCreateWindowX11, + _glfwDestroyWindowX11, + _glfwSetWindowTitleX11, + _glfwSetWindowIconX11, + _glfwGetWindowPosX11, + _glfwSetWindowPosX11, + _glfwGetWindowSizeX11, + _glfwSetWindowSizeX11, + _glfwSetWindowSizeLimitsX11, + _glfwSetWindowAspectRatioX11, + _glfwGetFramebufferSizeX11, + _glfwGetWindowFrameSizeX11, + _glfwGetWindowContentScaleX11, + _glfwIconifyWindowX11, + _glfwRestoreWindowX11, + _glfwMaximizeWindowX11, + _glfwShowWindowX11, + _glfwHideWindowX11, + _glfwRequestWindowAttentionX11, + _glfwFocusWindowX11, + _glfwSetWindowMonitorX11, + _glfwWindowFocusedX11, + _glfwWindowIconifiedX11, + _glfwWindowVisibleX11, + _glfwWindowMaximizedX11, + _glfwWindowHoveredX11, + _glfwFramebufferTransparentX11, + _glfwGetWindowOpacityX11, + _glfwSetWindowResizableX11, + _glfwSetWindowDecoratedX11, + _glfwSetWindowFloatingX11, + _glfwSetWindowOpacityX11, + _glfwSetWindowMousePassthroughX11, + _glfwPollEventsX11, + _glfwWaitEventsX11, + _glfwWaitEventsTimeoutX11, + _glfwPostEmptyEventX11, + _glfwGetEGLPlatformX11, + _glfwGetEGLNativeDisplayX11, + _glfwGetEGLNativeWindowX11, + _glfwGetRequiredInstanceExtensionsX11, + _glfwGetPhysicalDevicePresentationSupportX11, + _glfwCreateWindowSurfaceX11, + }; + // HACK: If the application has left the locale as "C" then both wide // character text input and explicit UTF-8 input via XIM will break // This sets the CTYPE part of the current locale from the environment @@ -1119,16 +1203,67 @@ int _glfwPlatformInit(void) setlocale(LC_CTYPE, ""); #if defined(__CYGWIN__) - _glfw.x11.xlib.handle = _glfwPlatformLoadModule("libX11-6.so"); + void* module = _glfwPlatformLoadModule("libX11-6.so"); #else - _glfw.x11.xlib.handle = _glfwPlatformLoadModule("libX11.so.6"); + void* module = _glfwPlatformLoadModule("libX11.so.6"); #endif - if (!_glfw.x11.xlib.handle) + if (!module) { - _glfwInputError(GLFW_PLATFORM_ERROR, "X11: Failed to load Xlib"); + if (platformID == GLFW_PLATFORM_X11) + _glfwInputError(GLFW_PLATFORM_ERROR, "X11: Failed to load Xlib"); + return GLFW_FALSE; } + PFN_XInitThreads XInitThreads = (PFN_XInitThreads) + _glfwPlatformGetModuleSymbol(module, "XInitThreads"); + PFN_XrmInitialize XrmInitialize = (PFN_XrmInitialize) + _glfwPlatformGetModuleSymbol(module, "XrmInitialize"); + PFN_XOpenDisplay XOpenDisplay = (PFN_XOpenDisplay) + _glfwPlatformGetModuleSymbol(module, "XOpenDisplay"); + if (!XInitThreads || !XrmInitialize || !XOpenDisplay) + { + if (platformID == GLFW_PLATFORM_X11) + _glfwInputError(GLFW_PLATFORM_ERROR, "X11: Failed to load Xlib entry point"); + + _glfwPlatformFreeModule(module); + return GLFW_FALSE; + } + + XInitThreads(); + XrmInitialize(); + + Display* display = XOpenDisplay(NULL); + if (!display) + { + if (platformID == GLFW_PLATFORM_X11) + { + const char* name = getenv("DISPLAY"); + if (name) + { + _glfwInputError(GLFW_PLATFORM_UNAVAILABLE, + "X11: Failed to open display %s", name); + } + else + { + _glfwInputError(GLFW_PLATFORM_UNAVAILABLE, + "X11: The DISPLAY environment variable is missing"); + } + } + + _glfwPlatformFreeModule(module); + return GLFW_FALSE; + } + + _glfw.x11.display = display; + _glfw.x11.xlib.handle = module; + + *platform = x11; + return GLFW_TRUE; +} + +int _glfwInitX11(void) +{ _glfw.x11.xlib.AllocClassHint = (PFN_XAllocClassHint) _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XAllocClassHint"); _glfw.x11.xlib.AllocSizeHints = (PFN_XAllocSizeHints) @@ -1217,8 +1352,6 @@ int _glfwPlatformInit(void) _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XGrabPointer"); _glfw.x11.xlib.IconifyWindow = (PFN_XIconifyWindow) _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XIconifyWindow"); - _glfw.x11.xlib.InitThreads = (PFN_XInitThreads) - _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XInitThreads"); _glfw.x11.xlib.InternAtom = (PFN_XInternAtom) _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XInternAtom"); _glfw.x11.xlib.LookupString = (PFN_XLookupString) @@ -1233,8 +1366,6 @@ int _glfwPlatformInit(void) _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XMoveWindow"); _glfw.x11.xlib.NextEvent = (PFN_XNextEvent) _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XNextEvent"); - _glfw.x11.xlib.OpenDisplay = (PFN_XOpenDisplay) - _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XOpenDisplay"); _glfw.x11.xlib.OpenIM = (PFN_XOpenIM) _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XOpenIM"); _glfw.x11.xlib.PeekEvent = (PFN_XPeekEvent) @@ -1323,8 +1454,6 @@ int _glfwPlatformInit(void) _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XrmGetResource"); _glfw.x11.xrm.GetStringDatabase = (PFN_XrmGetStringDatabase) _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XrmGetStringDatabase"); - _glfw.x11.xrm.Initialize = (PFN_XrmInitialize) - _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XrmInitialize"); _glfw.x11.xrm.UniqueQuark = (PFN_XrmUniqueQuark) _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XrmUniqueQuark"); _glfw.x11.xlib.UnregisterIMInstantiateCallback = (PFN_XUnregisterIMInstantiateCallback) @@ -1337,27 +1466,6 @@ int _glfwPlatformInit(void) if (_glfw.x11.xlib.utf8LookupString && _glfw.x11.xlib.utf8SetWMProperties) _glfw.x11.xlib.utf8 = GLFW_TRUE; - XInitThreads(); - XrmInitialize(); - - _glfw.x11.display = XOpenDisplay(NULL); - if (!_glfw.x11.display) - { - const char* display = getenv("DISPLAY"); - if (display) - { - _glfwInputError(GLFW_PLATFORM_ERROR, - "X11: Failed to open display %s", display); - } - else - { - _glfwInputError(GLFW_PLATFORM_ERROR, - "X11: The DISPLAY environment variable is missing"); - } - - return GLFW_FALSE; - } - _glfw.x11.screen = DefaultScreen(_glfw.x11.display); _glfw.x11.root = RootWindow(_glfw.x11.display, _glfw.x11.screen); _glfw.x11.context = XUniqueContext(); @@ -1385,7 +1493,7 @@ int _glfwPlatformInit(void) return GLFW_TRUE; } -void _glfwPlatformTerminate(void) +void _glfwTerminateX11(void) { if (_glfw.x11.helperWindowHandle) { @@ -1479,18 +1587,3 @@ void _glfwPlatformTerminate(void) } } -const char* _glfwPlatformGetVersionString(void) -{ - return _GLFW_VERSION_NUMBER " X11 GLX EGL OSMesa" -#if defined(_POSIX_MONOTONIC_CLOCK) - " monotonic" -#endif -#if defined(__linux__) - " evdev" -#endif -#if defined(_GLFW_BUILD_DLL) - " shared" -#endif - ; -} - diff --git a/src/x11_monitor.c b/src/x11_monitor.c index 97da48db..b031c83c 100644 --- a/src/x11_monitor.c +++ b/src/x11_monitor.c @@ -232,7 +232,7 @@ void _glfwSetVideoModeX11(_GLFWmonitor* monitor, const GLFWvidmode* desired) RRMode native = None; const GLFWvidmode* best = _glfwChooseVideoMode(monitor, desired); - _glfwPlatformGetVideoMode(monitor, ¤t); + _glfwGetVideoModeX11(monitor, ¤t); if (_glfwCompareVideoModes(¤t, best) == 0) return; @@ -310,11 +310,11 @@ void _glfwRestoreVideoModeX11(_GLFWmonitor* monitor) ////// GLFW platform API ////// ////////////////////////////////////////////////////////////////////////// -void _glfwPlatformFreeMonitor(_GLFWmonitor* monitor) +void _glfwFreeMonitorX11(_GLFWmonitor* monitor) { } -void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos) +void _glfwGetMonitorPosX11(_GLFWmonitor* monitor, int* xpos, int* ypos) { if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken) { @@ -336,8 +336,8 @@ void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos) } } -void _glfwPlatformGetMonitorContentScale(_GLFWmonitor* monitor, - float* xscale, float* yscale) +void _glfwGetMonitorContentScaleX11(_GLFWmonitor* monitor, + float* xscale, float* yscale) { if (xscale) *xscale = _glfw.x11.contentScaleX; @@ -345,7 +345,9 @@ void _glfwPlatformGetMonitorContentScale(_GLFWmonitor* monitor, *yscale = _glfw.x11.contentScaleY; } -void _glfwPlatformGetMonitorWorkarea(_GLFWmonitor* monitor, int* xpos, int* ypos, int* width, int* height) +void _glfwGetMonitorWorkareaX11(_GLFWmonitor* monitor, + int* xpos, int* ypos, + int* width, int* height) { int areaX = 0, areaY = 0, areaWidth = 0, areaHeight = 0; @@ -437,7 +439,7 @@ void _glfwPlatformGetMonitorWorkarea(_GLFWmonitor* monitor, int* xpos, int* ypos *height = areaHeight; } -GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* count) +GLFWvidmode* _glfwGetVideoModesX11(_GLFWmonitor* monitor, int* count) { GLFWvidmode* result; @@ -483,13 +485,13 @@ GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* count) { *count = 1; result = _glfw_calloc(1, sizeof(GLFWvidmode)); - _glfwPlatformGetVideoMode(monitor, result); + _glfwGetVideoModeX11(monitor, result); } return result; } -void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode) +void _glfwGetVideoModeX11(_GLFWmonitor* monitor, GLFWvidmode* mode) { if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken) { @@ -519,7 +521,7 @@ void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode) } } -GLFWbool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp) +GLFWbool _glfwGetGammaRampX11(_GLFWmonitor* monitor, GLFWgammaramp* ramp) { if (_glfw.x11.randr.available && !_glfw.x11.randr.gammaBroken) { @@ -557,7 +559,7 @@ GLFWbool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp) } } -void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp) +void _glfwSetGammaRampX11(_GLFWmonitor* monitor, const GLFWgammaramp* ramp) { if (_glfw.x11.randr.available && !_glfw.x11.randr.gammaBroken) { diff --git a/src/x11_platform.h b/src/x11_platform.h index 76444a87..61a0b17d 100644 --- a/src/x11_platform.h +++ b/src/x11_platform.h @@ -243,7 +243,6 @@ typedef void (* PFN_Xutf8SetWMProperties)(Display*,Window,const char*,const char #define XGetWindowProperty _glfw.x11.xlib.GetWindowProperty #define XGrabPointer _glfw.x11.xlib.GrabPointer #define XIconifyWindow _glfw.x11.xlib.IconifyWindow -#define XInitThreads _glfw.x11.xlib.InitThreads #define XInternAtom _glfw.x11.xlib.InternAtom #define XLookupString _glfw.x11.xlib.LookupString #define XMapRaised _glfw.x11.xlib.MapRaised @@ -251,7 +250,6 @@ typedef void (* PFN_Xutf8SetWMProperties)(Display*,Window,const char*,const char #define XMoveResizeWindow _glfw.x11.xlib.MoveResizeWindow #define XMoveWindow _glfw.x11.xlib.MoveWindow #define XNextEvent _glfw.x11.xlib.NextEvent -#define XOpenDisplay _glfw.x11.xlib.OpenDisplay #define XOpenIM _glfw.x11.xlib.OpenIM #define XPeekEvent _glfw.x11.xlib.PeekEvent #define XPending _glfw.x11.xlib.Pending @@ -296,7 +294,6 @@ typedef void (* PFN_Xutf8SetWMProperties)(Display*,Window,const char*,const char #define XrmDestroyDatabase _glfw.x11.xrm.DestroyDatabase #define XrmGetResource _glfw.x11.xrm.GetResource #define XrmGetStringDatabase _glfw.x11.xrm.GetStringDatabase -#define XrmInitialize _glfw.x11.xrm.Initialize #define XrmUniqueQuark _glfw.x11.xrm.UniqueQuark #define XUnregisterIMInstantiateCallback _glfw.x11.xlib.UnregisterIMInstantiateCallback #define Xutf8LookupString _glfw.x11.xlib.utf8LookupString @@ -455,22 +452,15 @@ typedef VkBool32 (APIENTRY *PFN_vkGetPhysicalDeviceXlibPresentationSupportKHR)(V typedef VkResult (APIENTRY *PFN_vkCreateXcbSurfaceKHR)(VkInstance,const VkXcbSurfaceCreateInfoKHR*,const VkAllocationCallbacks*,VkSurfaceKHR*); typedef VkBool32 (APIENTRY *PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR)(VkPhysicalDevice,uint32_t,xcb_connection_t*,xcb_visualid_t); -#include "posix_thread.h" -#include "posix_time.h" #include "xkb_unicode.h" -#if defined(__linux__) -#include "linux_joystick.h" -#else -#include "null_joystick.h" -#endif -#define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowX11 x11 -#define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryX11 x11 -#define _GLFW_PLATFORM_MONITOR_STATE _GLFWmonitorX11 x11 -#define _GLFW_PLATFORM_CURSOR_STATE _GLFWcursorX11 x11 +#define GLFW_X11_WINDOW_STATE _GLFWwindowX11 x11; +#define GLFW_X11_LIBRARY_WINDOW_STATE _GLFWlibraryX11 x11; +#define GLFW_X11_MONITOR_STATE _GLFWmonitorX11 x11; +#define GLFW_X11_CURSOR_STATE _GLFWcursorX11 x11; -#define _GLFW_PLATFORM_CONTEXT_STATE _GLFWcontextGLX glx -#define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE _GLFWlibraryGLX glx +#define GLFW_GLX_CONTEXT_STATE _GLFWcontextGLX glx; +#define GLFW_GLX_LIBRARY_CONTEXT_STATE _GLFWlibraryGLX glx; // GLX-specific per-context data @@ -696,7 +686,6 @@ typedef struct _GLFWlibraryX11 PFN_XGetWindowProperty GetWindowProperty; PFN_XGrabPointer GrabPointer; PFN_XIconifyWindow IconifyWindow; - PFN_XInitThreads InitThreads; PFN_XInternAtom InternAtom; PFN_XLookupString LookupString; PFN_XMapRaised MapRaised; @@ -704,7 +693,6 @@ typedef struct _GLFWlibraryX11 PFN_XMoveResizeWindow MoveResizeWindow; PFN_XMoveWindow MoveWindow; PFN_XNextEvent NextEvent; - PFN_XOpenDisplay OpenDisplay; PFN_XOpenIM OpenIM; PFN_XPeekEvent PeekEvent; PFN_XPending Pending; @@ -746,7 +734,6 @@ typedef struct _GLFWlibraryX11 PFN_XrmDestroyDatabase DestroyDatabase; PFN_XrmGetResource GetResource; PFN_XrmGetStringDatabase GetStringDatabase; - PFN_XrmInitialize Initialize; PFN_XrmUniqueQuark UniqueQuark; } xrm; @@ -907,11 +894,86 @@ typedef struct _GLFWcursorX11 } _GLFWcursorX11; +GLFWbool _glfwConnectX11(int platformID, _GLFWplatform* platform); +int _glfwInitX11(void); +void _glfwTerminateX11(void); + +int _glfwCreateWindowX11(_GLFWwindow* window, const _GLFWwndconfig* wndconfig, const _GLFWctxconfig* ctxconfig, const _GLFWfbconfig* fbconfig); +void _glfwDestroyWindowX11(_GLFWwindow* window); +void _glfwSetWindowTitleX11(_GLFWwindow* window, const char* title); +void _glfwSetWindowIconX11(_GLFWwindow* window, int count, const GLFWimage* images); +void _glfwGetWindowPosX11(_GLFWwindow* window, int* xpos, int* ypos); +void _glfwSetWindowPosX11(_GLFWwindow* window, int xpos, int ypos); +void _glfwGetWindowSizeX11(_GLFWwindow* window, int* width, int* height); +void _glfwSetWindowSizeX11(_GLFWwindow* window, int width, int height); +void _glfwSetWindowSizeLimitsX11(_GLFWwindow* window, int minwidth, int minheight, int maxwidth, int maxheight); +void _glfwSetWindowAspectRatioX11(_GLFWwindow* window, int numer, int denom); +void _glfwGetFramebufferSizeX11(_GLFWwindow* window, int* width, int* height); +void _glfwGetWindowFrameSizeX11(_GLFWwindow* window, int* left, int* top, int* right, int* bottom); +void _glfwGetWindowContentScaleX11(_GLFWwindow* window, float* xscale, float* yscale); +void _glfwIconifyWindowX11(_GLFWwindow* window); +void _glfwRestoreWindowX11(_GLFWwindow* window); +void _glfwMaximizeWindowX11(_GLFWwindow* window); +void _glfwShowWindowX11(_GLFWwindow* window); +void _glfwHideWindowX11(_GLFWwindow* window); +void _glfwRequestWindowAttentionX11(_GLFWwindow* window); +void _glfwFocusWindowX11(_GLFWwindow* window); +void _glfwSetWindowMonitorX11(_GLFWwindow* window, _GLFWmonitor* monitor, int xpos, int ypos, int width, int height, int refreshRate); +int _glfwWindowFocusedX11(_GLFWwindow* window); +int _glfwWindowIconifiedX11(_GLFWwindow* window); +int _glfwWindowVisibleX11(_GLFWwindow* window); +int _glfwWindowMaximizedX11(_GLFWwindow* window); +int _glfwWindowHoveredX11(_GLFWwindow* window); +int _glfwFramebufferTransparentX11(_GLFWwindow* window); +void _glfwSetWindowResizableX11(_GLFWwindow* window, GLFWbool enabled); +void _glfwSetWindowDecoratedX11(_GLFWwindow* window, GLFWbool enabled); +void _glfwSetWindowFloatingX11(_GLFWwindow* window, GLFWbool enabled); +float _glfwGetWindowOpacityX11(_GLFWwindow* window); +void _glfwSetWindowOpacityX11(_GLFWwindow* window, float opacity); +void _glfwSetWindowMousePassthroughX11(_GLFWwindow* window, GLFWbool enabled); + +void _glfwSetRawMouseMotionX11(_GLFWwindow *window, GLFWbool enabled); +GLFWbool _glfwRawMouseMotionSupportedX11(void); + +void _glfwPollEventsX11(void); +void _glfwWaitEventsX11(void); +void _glfwWaitEventsTimeoutX11(double timeout); +void _glfwPostEmptyEventX11(void); + +void _glfwGetCursorPosX11(_GLFWwindow* window, double* xpos, double* ypos); +void _glfwSetCursorPosX11(_GLFWwindow* window, double xpos, double ypos); +void _glfwSetCursorModeX11(_GLFWwindow* window, int mode); +const char* _glfwGetScancodeNameX11(int scancode); +int _glfwGetKeyScancodeX11(int key); +int _glfwCreateCursorX11(_GLFWcursor* cursor, const GLFWimage* image, int xhot, int yhot); +int _glfwCreateStandardCursorX11(_GLFWcursor* cursor, int shape); +void _glfwDestroyCursorX11(_GLFWcursor* cursor); +void _glfwSetCursorX11(_GLFWwindow* window, _GLFWcursor* cursor); +void _glfwSetClipboardStringX11(const char* string); +const char* _glfwGetClipboardStringX11(void); + +EGLenum _glfwGetEGLPlatformX11(EGLint** attribs); +EGLNativeDisplayType _glfwGetEGLNativeDisplayX11(void); +EGLNativeWindowType _glfwGetEGLNativeWindowX11(_GLFWwindow* window); + +void _glfwGetRequiredInstanceExtensionsX11(char** extensions); +int _glfwGetPhysicalDevicePresentationSupportX11(VkInstance instance, VkPhysicalDevice device, uint32_t queuefamily); +VkResult _glfwCreateWindowSurfaceX11(VkInstance instance, _GLFWwindow* window, const VkAllocationCallbacks* allocator, VkSurfaceKHR* surface); + +void _glfwFreeMonitorX11(_GLFWmonitor* monitor); +void _glfwGetMonitorPosX11(_GLFWmonitor* monitor, int* xpos, int* ypos); +void _glfwGetMonitorContentScaleX11(_GLFWmonitor* monitor, float* xscale, float* yscale); +void _glfwGetMonitorWorkareaX11(_GLFWmonitor* monitor, int* xpos, int* ypos, int* width, int* height); +GLFWvidmode* _glfwGetVideoModesX11(_GLFWmonitor* monitor, int* count); +void _glfwGetVideoModeX11(_GLFWmonitor* monitor, GLFWvidmode* mode); +GLFWbool _glfwGetGammaRampX11(_GLFWmonitor* monitor, GLFWgammaramp* ramp); +void _glfwSetGammaRampX11(_GLFWmonitor* monitor, const GLFWgammaramp* ramp); + void _glfwPollMonitorsX11(void); void _glfwSetVideoModeX11(_GLFWmonitor* monitor, const GLFWvidmode* desired); void _glfwRestoreVideoModeX11(_GLFWmonitor* monitor); -Cursor _glfwCreateCursorX11(const GLFWimage* image, int xhot, int yhot); +Cursor _glfwCreateNativeCursorX11(const GLFWimage* image, int xhot, int yhot); unsigned long _glfwGetWindowPropertyX11(Window window, Atom property, diff --git a/src/x11_window.c b/src/x11_window.c index 297b975d..3c74a813 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -560,9 +560,9 @@ static void disableCursor(_GLFWwindow* window) enableRawMouseMotion(window); _glfw.x11.disabledCursorWindow = window; - _glfwPlatformGetCursorPos(window, - &_glfw.x11.restoreCursorPosX, - &_glfw.x11.restoreCursorPosY); + _glfwGetCursorPosX11(window, + &_glfw.x11.restoreCursorPosX, + &_glfw.x11.restoreCursorPosY); updateCursorImage(window); _glfwCenterCursorInContentArea(window); XGrabPointer(_glfw.x11.display, window->x11.handle, True, @@ -582,9 +582,9 @@ static void enableCursor(_GLFWwindow* window) _glfw.x11.disabledCursorWindow = NULL; XUngrabPointer(_glfw.x11.display, CurrentTime); - _glfwPlatformSetCursorPos(window, - _glfw.x11.restoreCursorPosX, - _glfw.x11.restoreCursorPosY); + _glfwSetCursorPosX11(window, + _glfw.x11.restoreCursorPosX, + _glfw.x11.restoreCursorPosY); updateCursorImage(window); } @@ -655,7 +655,7 @@ static GLFWbool createNativeWindow(_GLFWwindow* window, (XPointer) window); if (!wndconfig->decorated) - _glfwPlatformSetWindowDecorated(window, GLFW_FALSE); + _glfwSetWindowDecoratedX11(window, GLFW_FALSE); if (_glfw.x11.NET_WM_STATE && !window->monitor) { @@ -777,9 +777,9 @@ static GLFWbool createNativeWindow(_GLFWwindow* window, if (_glfw.x11.im) _glfwCreateInputContextX11(window); - _glfwPlatformSetWindowTitle(window, wndconfig->title); - _glfwPlatformGetWindowPos(window, &window->x11.xpos, &window->x11.ypos); - _glfwPlatformGetWindowSize(window, &window->x11.width, &window->x11.height); + _glfwSetWindowTitleX11(window, wndconfig->title); + _glfwGetWindowPosX11(window, &window->x11.xpos, &window->x11.ypos); + _glfwGetWindowSizeX11(window, &window->x11.width, &window->x11.height); return GLFW_TRUE; } @@ -1118,8 +1118,8 @@ static void acquireMonitor(_GLFWwindow* window) GLFWvidmode mode; // Manually position the window over its monitor - _glfwPlatformGetMonitorPos(window->monitor, &xpos, &ypos); - _glfwPlatformGetVideoMode(window->monitor, &mode); + _glfwGetMonitorPosX11(window->monitor, &xpos, &ypos); + _glfwGetVideoModeX11(window->monitor, &mode); XMoveResizeWindow(_glfw.x11.display, window->x11.handle, xpos, ypos, mode.width, mode.height); @@ -1787,7 +1787,7 @@ static void processEvent(XEvent *event) XUnsetICFocus(window->x11.ic); if (window->monitor && window->autoIconify) - _glfwPlatformIconifyWindow(window); + _glfwIconifyWindowX11(window); _glfwInputWindowFocus(window, GLFW_FALSE); return; @@ -1827,7 +1827,7 @@ static void processEvent(XEvent *event) } else if (event->xproperty.atom == _glfw.x11.NET_WM_STATE) { - const GLFWbool maximized = _glfwPlatformWindowMaximized(window); + const GLFWbool maximized = _glfwWindowMaximizedX11(window); if (window->x11.maximized != maximized) { window->x11.maximized = maximized; @@ -1970,10 +1970,10 @@ void _glfwCreateInputContextX11(_GLFWwindow* window) ////// GLFW platform API ////// ////////////////////////////////////////////////////////////////////////// -int _glfwPlatformCreateWindow(_GLFWwindow* window, - const _GLFWwndconfig* wndconfig, - const _GLFWctxconfig* ctxconfig, - const _GLFWfbconfig* fbconfig) +int _glfwCreateWindowX11(_GLFWwindow* window, + const _GLFWwndconfig* wndconfig, + const _GLFWctxconfig* ctxconfig, + const _GLFWfbconfig* fbconfig) { Visual* visual = NULL; int depth; @@ -2031,7 +2031,7 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window, if (window->monitor) { - _glfwPlatformShowWindow(window); + _glfwShowWindowX11(window); updateWindowMode(window); acquireMonitor(window); } @@ -2040,7 +2040,7 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window, return GLFW_TRUE; } -void _glfwPlatformDestroyWindow(_GLFWwindow* window) +void _glfwDestroyWindowX11(_GLFWwindow* window) { if (_glfw.x11.disabledCursorWindow == window) _glfw.x11.disabledCursorWindow = NULL; @@ -2074,7 +2074,7 @@ void _glfwPlatformDestroyWindow(_GLFWwindow* window) XFlush(_glfw.x11.display); } -void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title) +void _glfwSetWindowTitleX11(_GLFWwindow* window, const char* title) { if (_glfw.x11.xlib.utf8) { @@ -2098,8 +2098,7 @@ void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title) XFlush(_glfw.x11.display); } -void _glfwPlatformSetWindowIcon(_GLFWwindow* window, - int count, const GLFWimage* images) +void _glfwSetWindowIconX11(_GLFWwindow* window, int count, const GLFWimage* images) { if (count) { @@ -2143,7 +2142,7 @@ void _glfwPlatformSetWindowIcon(_GLFWwindow* window, XFlush(_glfw.x11.display); } -void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos) +void _glfwGetWindowPosX11(_GLFWwindow* window, int* xpos, int* ypos) { Window dummy; int x, y; @@ -2157,11 +2156,11 @@ void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos) *ypos = y; } -void _glfwPlatformSetWindowPos(_GLFWwindow* window, int xpos, int ypos) +void _glfwSetWindowPosX11(_GLFWwindow* window, int xpos, int ypos) { // HACK: Explicitly setting PPosition to any value causes some WMs, notably // Compiz and Metacity, to honor the position of unmapped windows - if (!_glfwPlatformWindowVisible(window)) + if (!_glfwWindowVisibleX11(window)) { long supplied; XSizeHints* hints = XAllocSizeHints(); @@ -2181,7 +2180,7 @@ void _glfwPlatformSetWindowPos(_GLFWwindow* window, int xpos, int ypos) XFlush(_glfw.x11.display); } -void _glfwPlatformGetWindowSize(_GLFWwindow* window, int* width, int* height) +void _glfwGetWindowSizeX11(_GLFWwindow* window, int* width, int* height) { XWindowAttributes attribs; XGetWindowAttributes(_glfw.x11.display, window->x11.handle, &attribs); @@ -2192,7 +2191,7 @@ void _glfwPlatformGetWindowSize(_GLFWwindow* window, int* width, int* height) *height = attribs.height; } -void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height) +void _glfwSetWindowSizeX11(_GLFWwindow* window, int width, int height) { if (window->monitor) { @@ -2210,32 +2209,32 @@ void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height) XFlush(_glfw.x11.display); } -void _glfwPlatformSetWindowSizeLimits(_GLFWwindow* window, - int minwidth, int minheight, - int maxwidth, int maxheight) +void _glfwSetWindowSizeLimitsX11(_GLFWwindow* window, + int minwidth, int minheight, + int maxwidth, int maxheight) { int width, height; - _glfwPlatformGetWindowSize(window, &width, &height); + _glfwGetWindowSizeX11(window, &width, &height); updateNormalHints(window, width, height); XFlush(_glfw.x11.display); } -void _glfwPlatformSetWindowAspectRatio(_GLFWwindow* window, int numer, int denom) +void _glfwSetWindowAspectRatioX11(_GLFWwindow* window, int numer, int denom) { int width, height; - _glfwPlatformGetWindowSize(window, &width, &height); + _glfwGetWindowSizeX11(window, &width, &height); updateNormalHints(window, width, height); XFlush(_glfw.x11.display); } -void _glfwPlatformGetFramebufferSize(_GLFWwindow* window, int* width, int* height) +void _glfwGetFramebufferSizeX11(_GLFWwindow* window, int* width, int* height) { - _glfwPlatformGetWindowSize(window, width, height); + _glfwGetWindowSizeX11(window, width, height); } -void _glfwPlatformGetWindowFrameSize(_GLFWwindow* window, - int* left, int* top, - int* right, int* bottom) +void _glfwGetWindowFrameSizeX11(_GLFWwindow* window, + int* left, int* top, + int* right, int* bottom) { long* extents = NULL; @@ -2245,7 +2244,7 @@ void _glfwPlatformGetWindowFrameSize(_GLFWwindow* window, if (_glfw.x11.NET_FRAME_EXTENTS == None) return; - if (!_glfwPlatformWindowVisible(window) && + if (!_glfwWindowVisibleX11(window) && _glfw.x11.NET_REQUEST_FRAME_EXTENTS) { XEvent event; @@ -2294,8 +2293,7 @@ void _glfwPlatformGetWindowFrameSize(_GLFWwindow* window, XFree(extents); } -void _glfwPlatformGetWindowContentScale(_GLFWwindow* window, - float* xscale, float* yscale) +void _glfwGetWindowContentScaleX11(_GLFWwindow* window, float* xscale, float* yscale) { if (xscale) *xscale = _glfw.x11.contentScaleX; @@ -2303,7 +2301,7 @@ void _glfwPlatformGetWindowContentScale(_GLFWwindow* window, *yscale = _glfw.x11.contentScaleY; } -void _glfwPlatformIconifyWindow(_GLFWwindow* window) +void _glfwIconifyWindowX11(_GLFWwindow* window) { if (window->x11.overrideRedirect) { @@ -2318,7 +2316,7 @@ void _glfwPlatformIconifyWindow(_GLFWwindow* window) XFlush(_glfw.x11.display); } -void _glfwPlatformRestoreWindow(_GLFWwindow* window) +void _glfwRestoreWindowX11(_GLFWwindow* window) { if (window->x11.overrideRedirect) { @@ -2329,12 +2327,12 @@ void _glfwPlatformRestoreWindow(_GLFWwindow* window) return; } - if (_glfwPlatformWindowIconified(window)) + if (_glfwWindowIconifiedX11(window)) { XMapWindow(_glfw.x11.display, window->x11.handle); waitForVisibilityNotify(window); } - else if (_glfwPlatformWindowVisible(window)) + else if (_glfwWindowVisibleX11(window)) { if (_glfw.x11.NET_WM_STATE && _glfw.x11.NET_WM_STATE_MAXIMIZED_VERT && @@ -2352,7 +2350,7 @@ void _glfwPlatformRestoreWindow(_GLFWwindow* window) XFlush(_glfw.x11.display); } -void _glfwPlatformMaximizeWindow(_GLFWwindow* window) +void _glfwMaximizeWindowX11(_GLFWwindow* window) { if (!_glfw.x11.NET_WM_STATE || !_glfw.x11.NET_WM_STATE_MAXIMIZED_VERT || @@ -2361,7 +2359,7 @@ void _glfwPlatformMaximizeWindow(_GLFWwindow* window) return; } - if (_glfwPlatformWindowVisible(window)) + if (_glfwWindowVisibleX11(window)) { sendEventToWM(window, _glfw.x11.NET_WM_STATE, @@ -2417,22 +2415,22 @@ void _glfwPlatformMaximizeWindow(_GLFWwindow* window) XFlush(_glfw.x11.display); } -void _glfwPlatformShowWindow(_GLFWwindow* window) +void _glfwShowWindowX11(_GLFWwindow* window) { - if (_glfwPlatformWindowVisible(window)) + if (_glfwWindowVisibleX11(window)) return; XMapWindow(_glfw.x11.display, window->x11.handle); waitForVisibilityNotify(window); } -void _glfwPlatformHideWindow(_GLFWwindow* window) +void _glfwHideWindowX11(_GLFWwindow* window) { XUnmapWindow(_glfw.x11.display, window->x11.handle); XFlush(_glfw.x11.display); } -void _glfwPlatformRequestWindowAttention(_GLFWwindow* window) +void _glfwRequestWindowAttentionX11(_GLFWwindow* window) { if (!_glfw.x11.NET_WM_STATE || !_glfw.x11.NET_WM_STATE_DEMANDS_ATTENTION) return; @@ -2444,11 +2442,11 @@ void _glfwPlatformRequestWindowAttention(_GLFWwindow* window) 0, 1, 0); } -void _glfwPlatformFocusWindow(_GLFWwindow* window) +void _glfwFocusWindowX11(_GLFWwindow* window) { if (_glfw.x11.NET_ACTIVE_WINDOW) sendEventToWM(window, _glfw.x11.NET_ACTIVE_WINDOW, 1, 0, 0, 0, 0); - else if (_glfwPlatformWindowVisible(window)) + else if (_glfwWindowVisibleX11(window)) { XRaiseWindow(_glfw.x11.display, window->x11.handle); XSetInputFocus(_glfw.x11.display, window->x11.handle, @@ -2458,11 +2456,11 @@ void _glfwPlatformFocusWindow(_GLFWwindow* window) XFlush(_glfw.x11.display); } -void _glfwPlatformSetWindowMonitor(_GLFWwindow* window, - _GLFWmonitor* monitor, - int xpos, int ypos, - int width, int height, - int refreshRate) +void _glfwSetWindowMonitorX11(_GLFWwindow* window, + _GLFWmonitor* monitor, + int xpos, int ypos, + int width, int height, + int refreshRate) { if (window->monitor == monitor) { @@ -2486,8 +2484,8 @@ void _glfwPlatformSetWindowMonitor(_GLFWwindow* window, if (window->monitor) { - _glfwPlatformSetWindowDecorated(window, window->decorated); - _glfwPlatformSetWindowFloating(window, window->floating); + _glfwSetWindowDecoratedX11(window, window->decorated); + _glfwSetWindowFloatingX11(window, window->floating); releaseMonitor(window); } @@ -2496,7 +2494,7 @@ void _glfwPlatformSetWindowMonitor(_GLFWwindow* window, if (window->monitor) { - if (!_glfwPlatformWindowVisible(window)) + if (!_glfwWindowVisibleX11(window)) { XMapRaised(_glfw.x11.display, window->x11.handle); waitForVisibilityNotify(window); @@ -2515,7 +2513,7 @@ void _glfwPlatformSetWindowMonitor(_GLFWwindow* window, XFlush(_glfw.x11.display); } -int _glfwPlatformWindowFocused(_GLFWwindow* window) +int _glfwWindowFocusedX11(_GLFWwindow* window) { Window focused; int state; @@ -2524,19 +2522,19 @@ int _glfwPlatformWindowFocused(_GLFWwindow* window) return window->x11.handle == focused; } -int _glfwPlatformWindowIconified(_GLFWwindow* window) +int _glfwWindowIconifiedX11(_GLFWwindow* window) { return getWindowState(window) == IconicState; } -int _glfwPlatformWindowVisible(_GLFWwindow* window) +int _glfwWindowVisibleX11(_GLFWwindow* window) { XWindowAttributes wa; XGetWindowAttributes(_glfw.x11.display, window->x11.handle, &wa); return wa.map_state == IsViewable; } -int _glfwPlatformWindowMaximized(_GLFWwindow* window) +int _glfwWindowMaximizedX11(_GLFWwindow* window) { Atom* states; unsigned long i; @@ -2571,7 +2569,7 @@ int _glfwPlatformWindowMaximized(_GLFWwindow* window) return maximized; } -int _glfwPlatformWindowHovered(_GLFWwindow* window) +int _glfwWindowHoveredX11(_GLFWwindow* window) { Window w = _glfw.x11.root; while (w) @@ -2599,7 +2597,7 @@ int _glfwPlatformWindowHovered(_GLFWwindow* window) return GLFW_FALSE; } -int _glfwPlatformFramebufferTransparent(_GLFWwindow* window) +int _glfwFramebufferTransparentX11(_GLFWwindow* window) { if (!window->x11.transparent) return GLFW_FALSE; @@ -2607,14 +2605,14 @@ int _glfwPlatformFramebufferTransparent(_GLFWwindow* window) return XGetSelectionOwner(_glfw.x11.display, _glfw.x11.NET_WM_CM_Sx) != None; } -void _glfwPlatformSetWindowResizable(_GLFWwindow* window, GLFWbool enabled) +void _glfwSetWindowResizableX11(_GLFWwindow* window, GLFWbool enabled) { int width, height; - _glfwPlatformGetWindowSize(window, &width, &height); + _glfwGetWindowSizeX11(window, &width, &height); updateNormalHints(window, width, height); } -void _glfwPlatformSetWindowDecorated(_GLFWwindow* window, GLFWbool enabled) +void _glfwSetWindowDecoratedX11(_GLFWwindow* window, GLFWbool enabled) { struct { @@ -2636,12 +2634,12 @@ void _glfwPlatformSetWindowDecorated(_GLFWwindow* window, GLFWbool enabled) sizeof(hints) / sizeof(long)); } -void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled) +void _glfwSetWindowFloatingX11(_GLFWwindow* window, GLFWbool enabled) { if (!_glfw.x11.NET_WM_STATE || !_glfw.x11.NET_WM_STATE_ABOVE) return; - if (_glfwPlatformWindowVisible(window)) + if (_glfwWindowVisibleX11(window)) { const long action = enabled ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE; sendEventToWM(window, @@ -2706,7 +2704,7 @@ void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled) XFlush(_glfw.x11.display); } -void _glfwPlatformSetWindowMousePassthrough(_GLFWwindow* window, GLFWbool enabled) +void _glfwSetWindowMousePassthroughX11(_GLFWwindow* window, GLFWbool enabled) { if (!_glfw.x11.xshape.available) return; @@ -2725,7 +2723,7 @@ void _glfwPlatformSetWindowMousePassthrough(_GLFWwindow* window, GLFWbool enable } } -float _glfwPlatformGetWindowOpacity(_GLFWwindow* window) +float _glfwGetWindowOpacityX11(_GLFWwindow* window) { float opacity = 1.f; @@ -2748,7 +2746,7 @@ float _glfwPlatformGetWindowOpacity(_GLFWwindow* window) return opacity; } -void _glfwPlatformSetWindowOpacity(_GLFWwindow* window, float opacity) +void _glfwSetWindowOpacityX11(_GLFWwindow* window, float opacity) { const CARD32 value = (CARD32) (0xffffffffu * (double) opacity); XChangeProperty(_glfw.x11.display, window->x11.handle, @@ -2756,7 +2754,7 @@ void _glfwPlatformSetWindowOpacity(_GLFWwindow* window, float opacity) PropModeReplace, (unsigned char*) &value, 1); } -void _glfwPlatformSetRawMouseMotion(_GLFWwindow *window, GLFWbool enabled) +void _glfwSetRawMouseMotionX11(_GLFWwindow *window, GLFWbool enabled) { if (!_glfw.x11.xi.available) return; @@ -2770,12 +2768,12 @@ void _glfwPlatformSetRawMouseMotion(_GLFWwindow *window, GLFWbool enabled) disableRawMouseMotion(window); } -GLFWbool _glfwPlatformRawMouseMotionSupported(void) +GLFWbool _glfwRawMouseMotionSupportedX11(void) { return _glfw.x11.xi.available; } -void _glfwPlatformPollEvents(void) +void _glfwPollEventsX11(void) { _GLFWwindow* window; @@ -2796,29 +2794,29 @@ void _glfwPlatformPollEvents(void) if (window) { int width, height; - _glfwPlatformGetWindowSize(window, &width, &height); + _glfwGetWindowSizeX11(window, &width, &height); // NOTE: Re-center the cursor only if it has moved since the last call, // to avoid breaking glfwWaitEvents with MotionNotify if (window->x11.lastCursorPosX != width / 2 || window->x11.lastCursorPosY != height / 2) { - _glfwPlatformSetCursorPos(window, width / 2, height / 2); + _glfwSetCursorPosX11(window, width / 2, height / 2); } } XFlush(_glfw.x11.display); } -void _glfwPlatformWaitEvents(void) +void _glfwWaitEventsX11(void) { while (!XPending(_glfw.x11.display)) waitForEvent(NULL); - _glfwPlatformPollEvents(); + _glfwPollEventsX11(); } -void _glfwPlatformWaitEventsTimeout(double timeout) +void _glfwWaitEventsTimeoutX11(double timeout) { while (!XPending(_glfw.x11.display)) { @@ -2826,10 +2824,10 @@ void _glfwPlatformWaitEventsTimeout(double timeout) break; } - _glfwPlatformPollEvents(); + _glfwPollEventsX11(); } -void _glfwPlatformPostEmptyEvent(void) +void _glfwPostEmptyEventX11(void) { XEvent event = { ClientMessage }; event.xclient.window = _glfw.x11.helperWindowHandle; @@ -2840,7 +2838,7 @@ void _glfwPlatformPostEmptyEvent(void) XFlush(_glfw.x11.display); } -void _glfwPlatformGetCursorPos(_GLFWwindow* window, double* xpos, double* ypos) +void _glfwGetCursorPosX11(_GLFWwindow* window, double* xpos, double* ypos) { Window root, child; int rootX, rootY, childX, childY; @@ -2857,7 +2855,7 @@ void _glfwPlatformGetCursorPos(_GLFWwindow* window, double* xpos, double* ypos) *ypos = childY; } -void _glfwPlatformSetCursorPos(_GLFWwindow* window, double x, double y) +void _glfwSetCursorPosX11(_GLFWwindow* window, double x, double y) { // Store the new position so it can be recognized later window->x11.warpCursorPosX = (int) x; @@ -2868,11 +2866,11 @@ void _glfwPlatformSetCursorPos(_GLFWwindow* window, double x, double y) XFlush(_glfw.x11.display); } -void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode) +void _glfwSetCursorModeX11(_GLFWwindow* window, int mode) { if (mode == GLFW_CURSOR_DISABLED) { - if (_glfwPlatformWindowFocused(window)) + if (_glfwWindowFocusedX11(window)) disableCursor(window); } else if (_glfw.x11.disabledCursorWindow == window) @@ -2883,7 +2881,7 @@ void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode) XFlush(_glfw.x11.display); } -const char* _glfwPlatformGetScancodeName(int scancode) +const char* _glfwGetScancodeNameX11(int scancode) { if (!_glfw.x11.xkb.available) return NULL; @@ -2913,23 +2911,23 @@ const char* _glfwPlatformGetScancodeName(int scancode) return _glfw.x11.keynames[key]; } -int _glfwPlatformGetKeyScancode(int key) +int _glfwGetKeyScancodeX11(int key) { return _glfw.x11.scancodes[key]; } -int _glfwPlatformCreateCursor(_GLFWcursor* cursor, - const GLFWimage* image, - int xhot, int yhot) +int _glfwCreateCursorX11(_GLFWcursor* cursor, + const GLFWimage* image, + int xhot, int yhot) { - cursor->x11.handle = _glfwCreateCursorX11(image, xhot, yhot); + cursor->x11.handle = _glfwCreateNativeCursorX11(image, xhot, yhot); if (!cursor->x11.handle) return GLFW_FALSE; return GLFW_TRUE; } -int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape) +int _glfwCreateStandardCursorX11(_GLFWcursor* cursor, int shape) { if (_glfw.x11.xcursor.handle) { @@ -3027,13 +3025,13 @@ int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape) return GLFW_TRUE; } -void _glfwPlatformDestroyCursor(_GLFWcursor* cursor) +void _glfwDestroyCursorX11(_GLFWcursor* cursor) { if (cursor->x11.handle) XFreeCursor(_glfw.x11.display, cursor->x11.handle); } -void _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor) +void _glfwSetCursorX11(_GLFWwindow* window, _GLFWcursor* cursor) { if (window->cursorMode == GLFW_CURSOR_NORMAL) { @@ -3042,7 +3040,7 @@ void _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor) } } -void _glfwPlatformSetClipboardString(const char* string) +void _glfwSetClipboardStringX11(const char* string) { char* copy = _glfw_strdup(string); _glfw_free(_glfw.x11.clipboardString); @@ -3061,12 +3059,12 @@ void _glfwPlatformSetClipboardString(const char* string) } } -const char* _glfwPlatformGetClipboardString(void) +const char* _glfwGetClipboardStringX11(void) { return getSelectionString(_glfw.x11.CLIPBOARD); } -EGLenum _glfwPlatformGetEGLPlatform(EGLint** attribs) +EGLenum _glfwGetEGLPlatformX11(EGLint** attribs) { if (_glfw.egl.ANGLE_platform_angle) { @@ -3102,12 +3100,12 @@ EGLenum _glfwPlatformGetEGLPlatform(EGLint** attribs) return 0; } -EGLNativeDisplayType _glfwPlatformGetEGLNativeDisplay(void) +EGLNativeDisplayType _glfwGetEGLNativeDisplayX11(void) { return _glfw.x11.display; } -EGLNativeWindowType _glfwPlatformGetEGLNativeWindow(_GLFWwindow* window) +EGLNativeWindowType _glfwGetEGLNativeWindowX11(_GLFWwindow* window) { if (_glfw.egl.platform) return &window->x11.handle; @@ -3115,7 +3113,7 @@ EGLNativeWindowType _glfwPlatformGetEGLNativeWindow(_GLFWwindow* window) return (EGLNativeWindowType) window->x11.handle; } -void _glfwPlatformGetRequiredInstanceExtensions(char** extensions) +void _glfwGetRequiredInstanceExtensionsX11(char** extensions) { if (!_glfw.vk.KHR_surface) return; @@ -3136,9 +3134,9 @@ void _glfwPlatformGetRequiredInstanceExtensions(char** extensions) extensions[1] = "VK_KHR_xlib_surface"; } -int _glfwPlatformGetPhysicalDevicePresentationSupport(VkInstance instance, - VkPhysicalDevice device, - uint32_t queuefamily) +int _glfwGetPhysicalDevicePresentationSupportX11(VkInstance instance, + VkPhysicalDevice device, + uint32_t queuefamily) { VisualID visualID = XVisualIDFromVisual(DefaultVisual(_glfw.x11.display, _glfw.x11.screen)); @@ -3189,10 +3187,10 @@ int _glfwPlatformGetPhysicalDevicePresentationSupport(VkInstance instance, } } -VkResult _glfwPlatformCreateWindowSurface(VkInstance instance, - _GLFWwindow* window, - const VkAllocationCallbacks* allocator, - VkSurfaceKHR* surface) +VkResult _glfwCreateWindowSurfaceX11(VkInstance instance, + _GLFWwindow* window, + const VkAllocationCallbacks* allocator, + VkSurfaceKHR* surface) { if (_glfw.vk.KHR_xcb_surface && _glfw.x11.x11xcb.handle) { @@ -3272,6 +3270,13 @@ VkResult _glfwPlatformCreateWindowSurface(VkInstance instance, GLFWAPI Display* glfwGetX11Display(void) { _GLFW_REQUIRE_INIT_OR_RETURN(NULL); + + if (_glfw.platform.platformID != GLFW_PLATFORM_X11) + { + _glfwInputError(GLFW_PLATFORM_UNAVAILABLE, "X11: Platform not initialized"); + return NULL; + } + return _glfw.x11.display; } @@ -3279,6 +3284,13 @@ GLFWAPI Window glfwGetX11Window(GLFWwindow* handle) { _GLFWwindow* window = (_GLFWwindow*) handle; _GLFW_REQUIRE_INIT_OR_RETURN(None); + + if (_glfw.platform.platformID != GLFW_PLATFORM_X11) + { + _glfwInputError(GLFW_PLATFORM_UNAVAILABLE, "X11: Platform not initialized"); + return None; + } + return window->x11.handle; } @@ -3286,6 +3298,12 @@ GLFWAPI void glfwSetX11SelectionString(const char* string) { _GLFW_REQUIRE_INIT(); + if (_glfw.platform.platformID != GLFW_PLATFORM_X11) + { + _glfwInputError(GLFW_PLATFORM_UNAVAILABLE, "X11: Platform not initialized"); + return; + } + _glfw_free(_glfw.x11.primarySelectionString); _glfw.x11.primarySelectionString = _glfw_strdup(string); @@ -3305,6 +3323,13 @@ GLFWAPI void glfwSetX11SelectionString(const char* string) GLFWAPI const char* glfwGetX11SelectionString(void) { _GLFW_REQUIRE_INIT_OR_RETURN(NULL); + + if (_glfw.platform.platformID != GLFW_PLATFORM_X11) + { + _glfwInputError(GLFW_PLATFORM_UNAVAILABLE, "X11: Platform not initialized"); + return NULL; + } + return getSelectionString(_glfw.x11.PRIMARY); } diff --git a/tests/glfwinfo.c b/tests/glfwinfo.c index dea3ac22..a76ca1c2 100644 --- a/tests/glfwinfo.c +++ b/tests/glfwinfo.c @@ -64,10 +64,24 @@ #define ANGLE_TYPE_VULKAN "vk" #define ANGLE_TYPE_METAL "mtl" +#define PLATFORM_NAME_ANY "any" +#define PLATFORM_NAME_WIN32 "win32" +#define PLATFORM_NAME_COCOA "cooca" +#define PLATFORM_NAME_WL "wayland" +#define PLATFORM_NAME_X11 "x11" +#define PLATFORM_NAME_NULL "null" + static void usage(void) { printf("Usage: glfwinfo [OPTION]...\n"); printf("Options:\n"); + printf(" --platform=PLATFORM the platform to use (" + PLATFORM_NAME_ANY " or " + PLATFORM_NAME_WIN32 " or " + PLATFORM_NAME_COCOA " or " + PLATFORM_NAME_X11 " or " + PLATFORM_NAME_WL " or " + PLATFORM_NAME_NULL ")\n"); printf(" -a, --client-api=API the client API to use (" API_NAME_OPENGL " or " API_NAME_OPENGL_ES ")\n"); @@ -126,6 +140,22 @@ static void error_callback(int error, const char* description) fprintf(stderr, "Error: %s\n", description); } +static const char* get_platform_name(int platform) +{ + if (platform == GLFW_PLATFORM_WIN32) + return "Win32"; + else if (platform == GLFW_PLATFORM_COCOA) + return "Cocoa"; + else if (platform == GLFW_PLATFORM_WAYLAND) + return "Wayland"; + else if (platform == GLFW_PLATFORM_X11) + return "X11"; + else if (platform == GLFW_PLATFORM_NULL) + return "Null"; + + return "unknown"; +} + static const char* get_device_type_name(VkPhysicalDeviceType type) { if (type == VK_PHYSICAL_DEVICE_TYPE_OTHER) @@ -325,12 +355,34 @@ static void print_version(void) printf("GLFW library version string: \"%s\"\n", glfwGetVersionString()); } +static void print_platform(void) +{ + const int platforms[] = + { + GLFW_PLATFORM_WIN32, + GLFW_PLATFORM_COCOA, + GLFW_PLATFORM_WAYLAND, + GLFW_PLATFORM_X11, + GLFW_PLATFORM_NULL + }; + + printf("GLFW platform: %s\n", get_platform_name(glfwGetPlatform())); + printf("GLFW supported platforms:\n"); + + for (size_t i = 0; i < sizeof(platforms) / sizeof(platforms[0]); i++) + { + if (glfwPlatformSupported(platforms[i])) + printf(" %s\n", get_platform_name(platforms[i])); + } +} + int main(int argc, char** argv) { int ch; bool list_extensions = false, list_layers = false; // These duplicate the defaults for each hint + int platform = GLFW_ANY_PLATFORM; int client_api = GLFW_OPENGL_API; int context_major = 1; int context_minor = 0; @@ -360,7 +412,7 @@ int main(int argc, char** argv) bool cocoa_graphics_switching = false; bool disable_xcb_surface = false; - enum { CLIENT, CONTEXT, BEHAVIOR, DEBUG_CONTEXT, FORWARD, HELP, + enum { PLATFORM, CLIENT, CONTEXT, BEHAVIOR, DEBUG_CONTEXT, FORWARD, HELP, EXTENSIONS, LAYERS, MAJOR, MINOR, PROFILE, ROBUSTNESS, VERSION, REDBITS, GREENBITS, BLUEBITS, ALPHABITS, DEPTHBITS, STENCILBITS, @@ -369,6 +421,7 @@ int main(int argc, char** argv) ANGLE_TYPE, GRAPHICS_SWITCHING, XCB_SURFACE }; const struct option options[] = { + { "platform", 1, NULL, PLATFORM }, { "behavior", 1, NULL, BEHAVIOR }, { "client-api", 1, NULL, CLIENT }, { "context-api", 1, NULL, CONTEXT }, @@ -408,6 +461,23 @@ int main(int argc, char** argv) { switch (ch) { + case PLATFORM: + if (strcasecmp(optarg, PLATFORM_NAME_WIN32) == 0) + platform = GLFW_PLATFORM_WIN32; + else if (strcasecmp(optarg, PLATFORM_NAME_COCOA) == 0) + platform = GLFW_PLATFORM_COCOA; + else if (strcasecmp(optarg, PLATFORM_NAME_WL) == 0) + platform = GLFW_PLATFORM_WAYLAND; + else if (strcasecmp(optarg, PLATFORM_NAME_X11) == 0) + platform = GLFW_PLATFORM_X11; + else if (strcasecmp(optarg, PLATFORM_NAME_NULL) == 0) + platform = GLFW_PLATFORM_NULL; + else + { + usage(); + exit(EXIT_FAILURE); + } + break; case 'a': case CLIENT: if (strcasecmp(optarg, API_NAME_OPENGL) == 0) @@ -623,6 +693,8 @@ int main(int argc, char** argv) glfwSetErrorCallback(error_callback); + glfwInitHint(GLFW_PLATFORM, platform); + glfwInitHint(GLFW_COCOA_MENUBAR, false); glfwInitHint(GLFW_ANGLE_PLATFORM_TYPE, angle_type); @@ -632,6 +704,7 @@ int main(int argc, char** argv) exit(EXIT_FAILURE); print_version(); + print_platform(); glfwWindowHint(GLFW_VISIBLE, false); From 727db55c3a81951833c2adcd4d06d926185b4099 Mon Sep 17 00:00:00 2001 From: Ioannis Tsakpinis Date: Sat, 23 Oct 2021 16:17:33 +0300 Subject: [PATCH 047/208] Fix context API checks in native access functions --- src/egl_context.c | 4 ++-- src/glx_context.c | 4 ++-- src/nsgl_context.m | 2 +- src/osmesa_context.c | 6 +++--- src/wgl_context.c | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/egl_context.c b/src/egl_context.c index 593a153c..03c72d04 100644 --- a/src/egl_context.c +++ b/src/egl_context.c @@ -821,7 +821,7 @@ GLFWAPI EGLContext glfwGetEGLContext(GLFWwindow* handle) _GLFWwindow* window = (_GLFWwindow*) handle; _GLFW_REQUIRE_INIT_OR_RETURN(EGL_NO_CONTEXT); - if (window->context.client != GLFW_EGL_CONTEXT_API) + if (window->context.source != GLFW_EGL_CONTEXT_API) { _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL); return EGL_NO_CONTEXT; @@ -835,7 +835,7 @@ GLFWAPI EGLSurface glfwGetEGLSurface(GLFWwindow* handle) _GLFWwindow* window = (_GLFWwindow*) handle; _GLFW_REQUIRE_INIT_OR_RETURN(EGL_NO_SURFACE); - if (window->context.client != GLFW_EGL_CONTEXT_API) + if (window->context.source != GLFW_EGL_CONTEXT_API) { _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL); return EGL_NO_SURFACE; diff --git a/src/glx_context.c b/src/glx_context.c index 4a92353c..bbe261a0 100644 --- a/src/glx_context.c +++ b/src/glx_context.c @@ -680,7 +680,7 @@ GLFWAPI GLXContext glfwGetGLXContext(GLFWwindow* handle) return NULL; } - if (window->context.client != GLFW_NATIVE_CONTEXT_API) + if (window->context.source != GLFW_NATIVE_CONTEXT_API) { _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL); return NULL; @@ -700,7 +700,7 @@ GLFWAPI GLXWindow glfwGetGLXWindow(GLFWwindow* handle) return None; } - if (window->context.client != GLFW_NATIVE_CONTEXT_API) + if (window->context.source != GLFW_NATIVE_CONTEXT_API) { _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL); return None; diff --git a/src/nsgl_context.m b/src/nsgl_context.m index 694937c6..f85ef67b 100644 --- a/src/nsgl_context.m +++ b/src/nsgl_context.m @@ -365,7 +365,7 @@ GLFWAPI id glfwGetNSGLContext(GLFWwindow* handle) return nil; } - if (window->context.client != GLFW_NATIVE_CONTEXT_API) + if (window->context.source != GLFW_NATIVE_CONTEXT_API) { _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL); return nil; diff --git a/src/osmesa_context.c b/src/osmesa_context.c index cf742f89..1b28c517 100644 --- a/src/osmesa_context.c +++ b/src/osmesa_context.c @@ -302,7 +302,7 @@ GLFWAPI int glfwGetOSMesaColorBuffer(GLFWwindow* handle, int* width, _GLFW_REQUIRE_INIT_OR_RETURN(GLFW_FALSE); - if (window->context.client != GLFW_OSMESA_CONTEXT_API) + if (window->context.source != GLFW_OSMESA_CONTEXT_API) { _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL); return GLFW_FALSE; @@ -341,7 +341,7 @@ GLFWAPI int glfwGetOSMesaDepthBuffer(GLFWwindow* handle, _GLFW_REQUIRE_INIT_OR_RETURN(GLFW_FALSE); - if (window->context.client != GLFW_OSMESA_CONTEXT_API) + if (window->context.source != GLFW_OSMESA_CONTEXT_API) { _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL); return GLFW_FALSE; @@ -373,7 +373,7 @@ GLFWAPI OSMesaContext glfwGetOSMesaContext(GLFWwindow* handle) _GLFWwindow* window = (_GLFWwindow*) handle; _GLFW_REQUIRE_INIT_OR_RETURN(NULL); - if (window->context.client != GLFW_OSMESA_CONTEXT_API) + if (window->context.source != GLFW_OSMESA_CONTEXT_API) { _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL); return NULL; diff --git a/src/wgl_context.c b/src/wgl_context.c index 774f45bd..952d70de 100644 --- a/src/wgl_context.c +++ b/src/wgl_context.c @@ -783,7 +783,7 @@ GLFWAPI HGLRC glfwGetWGLContext(GLFWwindow* handle) return NULL; } - if (window->context.client != GLFW_NATIVE_CONTEXT_API) + if (window->context.source != GLFW_NATIVE_CONTEXT_API) { _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL); return NULL; From 38dd51552429066e56ba7e69bff5b78d70f89f5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Sun, 29 Aug 2021 21:53:44 +0200 Subject: [PATCH 048/208] Use Win32 instead of Windows in Doxygen headings This was especially bad in the window guide, where the TOC ended up having "Window related hints" and "Windows specific window hints" close to one another. This commit only fixes headings. There are likely issues in the actual text as well. --- docs/compile.dox | 2 +- docs/window.dox | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/compile.dox b/docs/compile.dox index 8f99472e..20b33a91 100644 --- a/docs/compile.dox +++ b/docs/compile.dox @@ -278,7 +278,7 @@ __GLFW_VULKAN_STATIC__ determines whether to use the Vulkan loader linked directly with the application. This is disabled by default. -@subsection compile_options_win32 Windows specific CMake options +@subsection compile_options_win32 Win32 specific CMake options @anchor GLFW_BUILD_WIN32 __GLFW_BUILD_WIN32__ determines whether to include support for Win32 when compiling the diff --git a/docs/window.dox b/docs/window.dox index 5e482431..32271e3a 100644 --- a/docs/window.dox +++ b/docs/window.dox @@ -447,7 +447,7 @@ The no error mode for OpenGL and OpenGL ES is described in detail by the extension. -@subsubsection window_hints_win32 Windows specific window hints +@subsubsection window_hints_win32 Win32 specific hints @anchor GLFW_WIN32_KEYBOARD_MENU_hint __GLFW_WIN32_KEYBOARD_MENU__ specifies whether to allow access to the window @@ -455,7 +455,7 @@ menu via the Alt+Space and Alt-and-then-Space keyboard shortcuts. This is ignored on other platforms. -@subsubsection window_hints_osx macOS specific window hints +@subsubsection window_hints_osx macOS specific hints @anchor GLFW_COCOA_RETINA_FRAMEBUFFER_hint __GLFW_COCOA_RETINA_FRAMEBUFFER__ specifies whether to use full resolution From 6efaaec9ce9f90510ef6e6d5155abb619138344b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Sun, 29 Aug 2021 21:51:00 +0200 Subject: [PATCH 049/208] Improve headings and TOC layout in Doxygen docs This more or less restores the original custom layout where the TOC is on the right side, with a CSS workaround added for portrait orientation. The indentation of sub-lists in the TOC has been decreased. The sizes of HTML headings and the "h0" div generated for each Doxygen page have been adjusted to look better together now that they can meet. A few headings have been shortened to fit better in the narrower TOC. --- docs/compile.dox | 12 ++++++------ docs/extra.css | 3 ++- docs/extra.css.map | 8 +++++++- docs/extra.scss | 27 +++++++++++++++++++++++---- docs/vulkan.dox | 2 +- 5 files changed, 39 insertions(+), 13 deletions(-) diff --git a/docs/compile.dox b/docs/compile.dox index 20b33a91..63479516 100644 --- a/docs/compile.dox +++ b/docs/compile.dox @@ -10,8 +10,8 @@ build applications that use GLFW, see @ref build_guide. @section compile_cmake Using CMake -@note GLFW behaves like most other libraries that use CMake so this guide mostly -describes the basic configure/generate/compile sequence. If you are already +GLFW behaves like most other libraries that use CMake so this guide mostly +describes the standard configure, generate and compile sequence. If you are already familiar with this from other projects, you may want to focus on the @ref compile_deps and @ref compile_options sections for GLFW-specific information. @@ -40,7 +40,7 @@ all necessary dependencies for compiling GLFW, but on Unix-like systems like Linux and FreeBSD you will need a few extra packages. -@subsubsection compile_deps_x11 Dependencies for X11 on Unix-like systems +@subsubsection compile_deps_x11 Dependencies for X11 To compile GLFW for X11, you need to have the X11 development packages installed. They are not needed to build or run programs that use GLFW. @@ -74,7 +74,7 @@ install the headers and other development related files for all of X11. Once you have the required dependencies, move on to @ref compile_generate. -@subsubsection compile_deps_wayland Dependencies for Wayland and X11 on Unix-like systems +@subsubsection compile_deps_wayland Dependencies for Wayland and X11 To compile GLFW for both Wayland and X11, you need to have the X11, Wayland and xkbcommon development packages installed. They are not needed to build or run programs that use @@ -131,7 +131,7 @@ A common pattern when building a single configuration is to have a build directory named `build` in the root of the source tree. -@subsubsection compile_generate_gui Generating files with the CMake GUI +@subsubsection compile_generate_gui Generating with the CMake GUI Start the CMake GUI and set the paths to the source and build directories described above. Then press _Configure_ and _Generate_. @@ -148,7 +148,7 @@ Once you have generated the project files or makefiles for your chosen development environment, move on to @ref compile_compile. -@subsubsection compile_generate_cli Generating files with the CMake command-line tool +@subsubsection compile_generate_cli Generating with command-line CMake To make a build directory, pass the source and build directories to the `cmake` command. These can be relative or absolute paths. The build directory is diff --git a/docs/extra.css b/docs/extra.css index 05c1938c..1a287343 100644 --- a/docs/extra.css +++ b/docs/extra.css @@ -1 +1,2 @@ -.sm-dox,.sm-dox a,.sm-dox a:focus,.sm-dox a:active,.sm-dox a:hover,.sm-dox a.highlighted,.sm-dox ul a:hover{background:none;text-shadow:none}.sm-dox a span.sub-arrow{border-color:#f2f2f2 transparent transparent transparent}.sm-dox a span.sub-arrow:active,.sm-dox a span.sub-arrow:focus,.sm-dox a span.sub-arrow:hover,.sm-dox a:hover span.sub-arrow{border-color:#f60 transparent transparent transparent}.sm-dox ul a span.sub-arrow:active,.sm-dox ul a span.sub-arrow:focus,.sm-dox ul a span.sub-arrow:hover,.sm-dox ul a:hover span.sub-arrow{border-color:transparent transparent transparent #f60}.sm-dox ul a:hover{background:#666;text-shadow:none}.sm-dox ul.sm-nowrap a{color:#4d4d4d;text-shadow:none}#main-nav,#main-menu,#main-menu a,#main-menu a:visited,#main-menu a:hover,#main-menu li,.memdoc,dl.reflist dd,div.toc li,.ah,span.lineno,span.lineno a,span.lineno a:hover,.note code,.pre code,.post code,.invariant code,.warning code,.attention code,.deprecated code,.bug code,.todo code,.test code,.doxtable code,.markdownTable code{background:none}#titlearea,.footer,.contents,div.header,.memdoc,table.doxtable td,table.doxtable th,table.markdownTable td,table.markdownTable th,hr,.memSeparator{border:none}#main-menu a,#main-menu a:visited,#main-menu a:hover,#main-menu li,.reflist dt a.el,.levels span,.directory .levels span{text-shadow:none}.memdoc,dl.reflist dd{box-shadow:none}div.headertitle,.note code,.pre code,.post code,.invariant code,.warning code,.attention code,.deprecated code,.bug code,.todo code,.test code,table.doxtable code,table.markdownTable code{padding:0}#nav-path,.directory .levels,span.lineno{display:none}html,#titlearea,.footer,tr.even,.directory tr.even,.doxtable tr:nth-child(even),tr.markdownTableBody:nth-child(even),.mdescLeft,.mdescRight,.memItemLeft,.memItemRight,code,.markdownTableRowEven{background:#f2f2f2}body{color:#4d4d4d}h1,h2,h2.groupheader,h3,div.toc h3,h4,h5,h6,strong,em{color:#1a1a1a;border-bottom:none}h1{padding-top:.5em;font-size:180%}h2{padding-top:.5em;margin-bottom:0;font-size:140%}h3{padding-top:.5em;margin-bottom:0;font-size:110%}.glfwheader{font-size:16px;min-height:64px;max-width:920px;padding:0 32px;margin:0 auto;display:flex;flex-direction:row;flex-wrap:wrap;justify-content:flex-start;align-items:center;align-content:stretch}#glfwhome{line-height:64px;padding-right:48px;color:#666;font-size:2.5em;background:url("https://www.glfw.org/css/arrow.png") no-repeat right}.glfwnavbar{list-style-type:none;margin:0 0 0 auto;float:right}#glfwhome,.glfwnavbar li{float:left}.glfwnavbar a,.glfwnavbar a:visited{line-height:64px;margin-left:2em;display:block;color:#666}.glfwnavbar{padding-left:0}#glfwhome,.glfwnavbar a,.glfwnavbar a:visited{transition:.35s ease}#titlearea,.footer{color:#666}address.footer{text-align:center;padding:2em;margin-top:3em}#top{background:#666}#main-nav{max-width:960px;margin:0 auto;font-size:13px}#main-menu{max-width:920px;margin:0 auto;font-size:13px}.memtitle{display:none}.memproto,.memname{font-weight:bold;text-shadow:none}#main-menu{min-height:36px;display:flex;flex-direction:row;flex-wrap:wrap;justify-content:flex-start;align-items:center;align-content:stretch}#main-menu a,#main-menu a:visited,#main-menu a:hover,#main-menu li{color:#f2f2f2}#main-menu li ul.sm-nowrap li a{color:#4d4d4d}#main-menu li ul.sm-nowrap li a:hover{color:#f60}#main-menu>li:last-child{margin:0 0 0 auto}.contents{min-height:590px}div.contents,div.header{max-width:920px;margin:0 auto;padding:0 32px;background:#fff none}table.doxtable th,table.markdownTable th,dl.reflist dt{background:linear-gradient(to bottom, #ffa733 0%, #ff6600 100%);box-shadow:inset 0 0 32px #f60;text-shadow:0 -1px 1px #b34700;text-align:left;color:#fff}dl.reflist dt a.el{color:#f60;padding:.2em;border-radius:4px;background-color:#ffe0cc}div.toc{float:none;width:auto}div.toc h3{font-size:1.17em}div.toc ul{padding-left:1.5em}div.toc li{font-size:1em;padding-left:0;list-style-type:disc}div.toc,.memproto,div.qindex,div.ah{background:linear-gradient(to bottom, #f2f2f2 0%, #e6e6e6 100%);box-shadow:inset 0 0 32px #e6e6e6;text-shadow:0 1px 1px #fff;color:#1a1a1a;border:2px solid #e6e6e6;border-radius:4px}.paramname{color:#803300}dl.reflist dt{border:2px solid #f60;border-top-left-radius:4px;border-top-right-radius:4px;border-bottom:none}dl.reflist dd{border:2px solid #f60;border-bottom-right-radius:4px;border-bottom-left-radius:4px;border-top:none}table.doxtable,table.markdownTable{border-collapse:inherit;border-spacing:0;border:2px solid #f60;border-radius:4px}a,a:hover,a:visited,a:visited:hover,.contents a:visited,.el,a.el:visited,#glfwhome:hover,#main-menu a:hover,span.lineno a:hover{color:#f60;text-decoration:none}div.directory{border-collapse:inherit;border-spacing:0;border:2px solid #f60;border-radius:4px}hr,.memSeparator{height:2px;background:linear-gradient(to right, #f2f2f2 0%, #d9d9d9 50%, #f2f2f2 100%)}dl.note,dl.pre,dl.post,dl.invariant{background:linear-gradient(to bottom, #ddfad1 0%, #cbf7ba 100%);box-shadow:inset 0 0 32px #baf5a3;color:#1e5309;border:2px solid #afe699}dl.warning,dl.attention{background:linear-gradient(to bottom, #fae8d1 0%, #f7ddba 100%);box-shadow:inset 0 0 32px #f5d1a3;color:#533309;border:2px solid #e6c499}dl.deprecated,dl.bug{background:linear-gradient(to bottom, #fad1e3 0%, #f7bad6 100%);box-shadow:inset 0 0 32px #f5a3c8;color:#53092a;border:2px solid #e699bb}dl.todo,dl.test{background:linear-gradient(to bottom, #d1ecfa 0%, #bae3f7 100%);box-shadow:inset 0 0 32px #a3daf5;color:#093a53;border:2px solid #99cce6}dl.note,dl.pre,dl.post,dl.invariant,dl.warning,dl.attention,dl.deprecated,dl.bug,dl.todo,dl.test{border-radius:4px;padding:1em;text-shadow:0 1px 1px #fff;margin:1em 0}.note a,.pre a,.post a,.invariant a,.warning a,.attention a,.deprecated a,.bug a,.todo a,.test a,.note a:visited,.pre a:visited,.post a:visited,.invariant a:visited,.warning a:visited,.attention a:visited,.deprecated a:visited,.bug a:visited,.todo a:visited,.test a:visited{color:inherit}div.line{line-height:inherit}div.fragment,pre.fragment{background:#f2f2f2;border-radius:4px;border:none;padding:1em;overflow:auto;border-left:4px solid #ccc;margin:1em 0}.lineno a,.lineno a:visited,.line,pre.fragment{color:#4d4d4d}span.preprocessor,span.comment{color:#007899}a.code,a.code:visited{color:#e64500}span.keyword,span.keywordtype,span.keywordflow{color:#404040;font-weight:bold}span.stringliteral{color:#360099}code{padding:.1em;border-radius:4px}/*# sourceMappingURL=extra.css.map */ +.sm-dox,.sm-dox a,.sm-dox a:focus,.sm-dox a:active,.sm-dox a:hover,.sm-dox a.highlighted,.sm-dox ul a:hover{background:none;text-shadow:none}.sm-dox a span.sub-arrow{border-color:#f2f2f2 transparent transparent transparent}.sm-dox a span.sub-arrow:active,.sm-dox a span.sub-arrow:focus,.sm-dox a span.sub-arrow:hover,.sm-dox a:hover span.sub-arrow{border-color:#f60 transparent transparent transparent}.sm-dox ul a span.sub-arrow:active,.sm-dox ul a span.sub-arrow:focus,.sm-dox ul a span.sub-arrow:hover,.sm-dox ul a:hover span.sub-arrow{border-color:transparent transparent transparent #f60}.sm-dox ul a:hover{background:#666;text-shadow:none}.sm-dox ul.sm-nowrap a{color:#4d4d4d;text-shadow:none}#main-nav,#main-menu,#main-menu a,#main-menu a:visited,#main-menu a:hover,#main-menu li,.memdoc,dl.reflist dd,div.toc li,.ah,span.lineno,span.lineno a,span.lineno a:hover,.note code,.pre code,.post code,.invariant code,.warning code,.attention code,.deprecated code,.bug code,.todo code,.test code,.doxtable code,.markdownTable code{background:none}#titlearea,.footer,.contents,div.header,.memdoc,table.doxtable td,table.doxtable th,table.markdownTable td,table.markdownTable th,hr,.memSeparator{border:none}#main-menu a,#main-menu a:visited,#main-menu a:hover,#main-menu li,.reflist dt a.el,.levels span,.directory .levels span{text-shadow:none}.memdoc,dl.reflist dd{box-shadow:none}div.headertitle,.note code,.pre code,.post code,.invariant code,.warning code,.attention code,.deprecated code,.bug code,.todo code,.test code,table.doxtable code,table.markdownTable code{padding:0}#nav-path,.directory .levels,span.lineno{display:none}html,#titlearea,.footer,tr.even,.directory tr.even,.doxtable tr:nth-child(even),tr.markdownTableBody:nth-child(even),.mdescLeft,.mdescRight,.memItemLeft,.memItemRight,code,.markdownTableRowEven{background:#f2f2f2}body{color:#4d4d4d}div.title{font-size:170%;margin:1em 0 0.5em 0}h1,h2,h2.groupheader,h3,div.toc h3,h4,h5,h6,strong,em{color:#1a1a1a;border-bottom:none}h1{padding-top:0.5em;font-size:150%}h2{padding-top:0.5em;margin-bottom:0;font-size:130%}h3{padding-top:0.5em;margin-bottom:0;font-size:110%}.glfwheader{font-size:16px;min-height:64px;max-width:920px;padding:0 32px;margin:0 auto;display:flex;flex-direction:row;flex-wrap:wrap;justify-content:flex-start;align-items:center;align-content:stretch}#glfwhome{line-height:64px;padding-right:48px;color:#666;font-size:2.5em;background:url("https://www.glfw.org/css/arrow.png") no-repeat right}.glfwnavbar{list-style-type:none;margin:0 0 0 auto;float:right}#glfwhome,.glfwnavbar li{float:left}.glfwnavbar a,.glfwnavbar a:visited{line-height:64px;margin-left:2em;display:block;color:#666}.glfwnavbar{padding-left:0}#glfwhome,.glfwnavbar a,.glfwnavbar a:visited{transition:.35s ease}#titlearea,.footer{color:#666}address.footer{text-align:center;padding:2em;margin-top:3em}#top{background:#666}#main-nav{max-width:960px;margin:0 auto;font-size:13px}#main-menu{max-width:920px;margin:0 auto;font-size:13px}.memtitle{display:none}.memproto,.memname{font-weight:bold;text-shadow:none}#main-menu{min-height:36px;display:flex;flex-direction:row;flex-wrap:wrap;justify-content:flex-start;align-items:center;align-content:stretch}#main-menu a,#main-menu a:visited,#main-menu a:hover,#main-menu li{color:#f2f2f2}#main-menu li ul.sm-nowrap li a{color:#4d4d4d}#main-menu li ul.sm-nowrap li a:hover{color:#f60}#main-menu>li:last-child{margin:0 0 0 auto}.contents{min-height:590px}div.contents,div.header{max-width:920px;margin:0 auto;padding:0 32px;background:#fff none}table.doxtable th,table.markdownTable th,dl.reflist dt{background:linear-gradient(to bottom, #ffa733 0%, #f60 100%);box-shadow:inset 0 0 32px #f60;text-shadow:0 -1px 1px #b34700;text-align:left;color:#fff}dl.reflist dt a.el{color:#f60;padding:.2em;border-radius:4px;background-color:#ffe0cc}div.toc{float:right;width:35%}@media screen and (max-width: 600px){div.toc{float:none;width:inherit;margin:0}}div.toc h3{font-size:1.17em}div.toc ul{padding-left:1.5em}div.toc li{font-size:1em;padding-left:0;list-style-type:disc}div.toc li.level2,div.toc li.level3{margin-left:0.5em}div.toc,.memproto,div.qindex,div.ah{background:linear-gradient(to bottom, #f2f2f2 0%, #e6e6e6 100%);box-shadow:inset 0 0 32px #e6e6e6;text-shadow:0 1px 1px #fff;color:#1a1a1a;border:2px solid #e6e6e6;border-radius:4px}.paramname{color:#803300}dl.reflist dt{border:2px solid #f60;border-top-left-radius:4px;border-top-right-radius:4px;border-bottom:none}dl.reflist dd{border:2px solid #f60;border-bottom-right-radius:4px;border-bottom-left-radius:4px;border-top:none}table.doxtable,table.markdownTable{border-collapse:inherit;border-spacing:0;border:2px solid #f60;border-radius:4px}a,a:hover,a:visited,a:visited:hover,.contents a:visited,.el,a.el:visited,#glfwhome:hover,#main-menu a:hover,span.lineno a:hover{color:#f60;text-decoration:none}div.directory{border-collapse:inherit;border-spacing:0;border:2px solid #f60;border-radius:4px}hr,.memSeparator{height:2px;background:linear-gradient(to right, #f2f2f2 0%, #d9d9d9 50%, #f2f2f2 100%)}dl.note,dl.pre,dl.post,dl.invariant{background:linear-gradient(to bottom, #ddfad1 0%, #cbf7ba 100%);box-shadow:inset 0 0 32px #baf5a3;color:#1e5309;border:2px solid #afe699}dl.warning,dl.attention{background:linear-gradient(to bottom, #fae8d1 0%, #f7ddba 100%);box-shadow:inset 0 0 32px #f5d1a3;color:#533309;border:2px solid #e6c499}dl.deprecated,dl.bug{background:linear-gradient(to bottom, #fad1e3 0%, #f7bad6 100%);box-shadow:inset 0 0 32px #f5a3c8;color:#53092a;border:2px solid #e699bb}dl.todo,dl.test{background:linear-gradient(to bottom, #d1ecfa 0%, #bae3f7 100%);box-shadow:inset 0 0 32px #a3daf5;color:#093a53;border:2px solid #99cce6}dl.note,dl.pre,dl.post,dl.invariant,dl.warning,dl.attention,dl.deprecated,dl.bug,dl.todo,dl.test{border-radius:4px;padding:1em;text-shadow:0 1px 1px #fff;margin:1em 0}.note a,.pre a,.post a,.invariant a,.warning a,.attention a,.deprecated a,.bug a,.todo a,.test a,.note a:visited,.pre a:visited,.post a:visited,.invariant a:visited,.warning a:visited,.attention a:visited,.deprecated a:visited,.bug a:visited,.todo a:visited,.test a:visited{color:inherit}div.line{line-height:inherit}div.fragment,pre.fragment{background:#f2f2f2;border-radius:4px;border:none;padding:1em;overflow:auto;border-left:4px solid #ccc;margin:1em 0}.lineno a,.lineno a:visited,.line,pre.fragment{color:#4d4d4d}span.preprocessor,span.comment{color:#007899}a.code,a.code:visited{color:#e64500}span.keyword,span.keywordtype,span.keywordflow{color:#404040;font-weight:bold}span.stringliteral{color:#360099}code{padding:.1em;border-radius:4px} +/*# sourceMappingURL=extra.css.map */ diff --git a/docs/extra.css.map b/docs/extra.css.map index 7d10c5e2..4d9333c2 100644 --- a/docs/extra.css.map +++ b/docs/extra.css.map @@ -1 +1,7 @@ -{"version":3,"sourceRoot":"","sources":["extra.scss"],"names":[],"mappings":"AA8EA,4GACI,gBACA,iBAGJ,yBACC,yDAGD,6HACC,sDAGD,yIACC,sDAGD,mBACI,WA9EuB,KA+EvB,iBAGJ,uBACC,MAzFoB,QA0FjB,iBAGJ,6UACC,gBAGD,mJACC,YAGD,yHACC,iBAGD,sBACC,gBAGD,4LACC,UAGD,yCACC,aAGD,kMACC,WAnHgC,QAsHjC,KACC,MA1HoB,QA6HrB,sDACC,MA/Ge,QAgHf,mBAGD,GACE,iBACA,eAGF,GACE,iBACA,gBACA,eAGF,GACE,iBACA,gBACA,eAGF,YACC,eACA,gBACA,gBACA,eACA,cAEA,aACA,mBACA,eACA,2BACA,mBACA,sBAGD,UACC,iBACA,mBACA,MA/J0B,KAgK1B,gBACA,qEAGD,YACC,qBACA,kBACA,YAGD,yBACC,WAGD,oCACC,iBACA,gBACA,cACA,MAlL0B,KAqL3B,YACC,eAGD,8CACC,qBAGD,mBACC,MA9L0B,KAiM3B,eACC,kBACA,YACA,eAGD,KACC,WAxM0B,KA2M3B,UACC,gBACA,cACA,eAGD,WACC,gBACA,cACA,eAGD,UACI,aAGJ,mBACI,iBACA,iBAGJ,WACC,gBACA,aACA,mBACA,eACA,2BACA,mBACA,sBAGD,mEACC,MA9OgC,QAiPjC,gCACC,MArPoB,QAwPrB,sCACC,MAjOoB,KAoOrB,yBACC,kBAGD,UACC,iBAGD,wBACC,gBACA,cACA,eACA,qBAGD,uDACC,gEACA,+BACA,+BACA,gBACA,MArPgB,KAwPjB,mBACC,MA5PoB,KA6PpB,aACA,kBACA,yBAGD,QACC,WACA,WAGD,WACC,iBAGD,WACC,mBAGD,WACC,cACA,eACA,qBAGD,oCACC,gEACA,kCACA,2BACA,MAlSe,QAmSf,yBACA,kBAGD,WACC,MA3QuB,QA8QxB,cACC,sBACA,2BACA,4BACA,mBAGD,cACC,sBACA,+BACA,8BACA,gBAGD,mCACC,wBACA,iBACA,sBACA,kBAGD,gIACC,MAxToB,KAyTpB,qBAGD,cACC,wBACA,iBACA,sBACA,kBAGD,iBACC,WACA,4EAGD,oCApSC,gEACA,kCACA,cACA,yBAqSD,wBAxSC,gEACA,kCACA,cACA,yBAySD,qBA5SC,gEACA,kCACA,cACA,yBA6SD,gBAhTC,gEACA,kCACA,cACA,yBAiTD,iGACC,kBACA,YACA,2BACA,aAGD,kRACC,cAGD,SACC,oBAGD,0BACC,mBACA,kBACA,YACA,YACA,cACA,2BACA,aAGD,+CACC,MA1YoB,QA6YrB,+BACC,cAGD,sBACC,cAGD,+CACC,cACA,iBAGD,mBACC,cAGD,KACC,aACA","file":"extra.css"} \ No newline at end of file +{ +"version": 3, +"mappings": "AA8EA,2GAA4G,CAC3G,UAAU,CAAC,IAAI,CACf,WAAW,CAAC,IAAI,CAGjB,wBAAyB,CACxB,YAAY,CAAC,2CAAsD,CAGpE,4HAA6H,CAC5H,YAAY,CAAC,wCAAuD,CAGrE,wIAAyI,CACxI,YAAY,CAAC,wCAAuD,CAGrE,kBAAmB,CAClB,UAAU,CA9EgB,IAAa,CA+EvC,WAAW,CAAC,IAAI,CAGjB,sBAAuB,CACtB,KAAK,CAzFe,OAAa,CA0FjC,WAAW,CAAC,IAAI,CAGjB,4UAA6U,CAC5U,UAAU,CAAC,IAAI,CAGhB,kJAAmJ,CAClJ,MAAM,CAAC,IAAI,CAGZ,wHAAyH,CACxH,WAAW,CAAC,IAAI,CAGjB,qBAAsB,CACrB,UAAU,CAAC,IAAI,CAGhB,2LAA4L,CAC3L,OAAO,CAAC,CAAC,CAGV,wCAAyC,CACxC,OAAO,CAAC,IAAI,CAGb,iMAAkM,CACjM,UAAU,CApGW,OAA+B,CAuGrD,IAAK,CACJ,KAAK,CA1He,OAAa,CA6HlC,SAAU,CACN,SAAS,CAAE,IAAI,CACf,MAAM,CAAE,aAAa,CAGzB,qDAAsD,CACrD,KAAK,CApHU,OAAa,CAqH5B,aAAa,CAAC,IAAI,CAGnB,EAAG,CACF,WAAW,CAAC,KAAK,CACjB,SAAS,CAAC,IAAI,CAGf,EAAG,CACF,WAAW,CAAC,KAAK,CACjB,aAAa,CAAC,CAAC,CACf,SAAS,CAAC,IAAI,CAGf,EAAG,CACF,WAAW,CAAC,KAAK,CACjB,aAAa,CAAC,CAAC,CACf,SAAS,CAAC,IAAI,CAGf,WAAY,CACX,SAAS,CAAC,IAAI,CACd,UAAU,CAAC,IAAI,CACf,SAAS,CAAC,KAAK,CACf,OAAO,CAAC,MAAM,CACd,MAAM,CAAC,MAAM,CAEb,OAAO,CAAE,IAAI,CACb,cAAc,CAAE,GAAG,CACnB,SAAS,CAAE,IAAI,CACf,eAAe,CAAE,UAAU,CAC3B,WAAW,CAAE,MAAM,CACnB,aAAa,CAAE,OAAO,CAGvB,SAAU,CACT,WAAW,CAAC,IAAI,CAChB,aAAa,CAAC,IAAI,CAClB,KAAK,CApKqB,IAAa,CAqKvC,SAAS,CAAC,KAAK,CACf,UAAU,CAAC,yDAAyD,CAGrE,WAAY,CACX,eAAe,CAAC,IAAI,CACpB,MAAM,CAAC,UAAU,CACjB,KAAK,CAAC,KAAK,CAGZ,wBAAyB,CACxB,KAAK,CAAC,IAAI,CAGX,mCAAoC,CACnC,WAAW,CAAC,IAAI,CAChB,WAAW,CAAC,GAAG,CACf,OAAO,CAAC,KAAK,CACb,KAAK,CAvLqB,IAAa,CA0LxC,WAAY,CACX,YAAY,CAAE,CAAC,CAGhB,6CAA8C,CAC7C,UAAU,CAAC,SAAS,CAGrB,kBAAmB,CAClB,KAAK,CAnMqB,IAAa,CAsMxC,cAAe,CACd,UAAU,CAAC,MAAM,CACjB,OAAO,CAAC,GAAG,CACX,UAAU,CAAC,GAAG,CAGf,IAAK,CACJ,UAAU,CA7MgB,IAAa,CAgNxC,SAAU,CACT,SAAS,CAAC,KAAK,CACf,MAAM,CAAC,MAAM,CACb,SAAS,CAAC,IAAI,CAGf,UAAW,CACV,SAAS,CAAC,KAAK,CACf,MAAM,CAAC,MAAM,CACb,SAAS,CAAC,IAAI,CAGf,SAAU,CACT,OAAO,CAAC,IAAI,CAGb,kBAAmB,CAClB,WAAW,CAAC,IAAI,CAChB,WAAW,CAAC,IAAI,CAGjB,UAAW,CACV,UAAU,CAAC,IAAI,CACf,OAAO,CAAE,IAAI,CACb,cAAc,CAAE,GAAG,CACnB,SAAS,CAAE,IAAI,CACf,eAAe,CAAE,UAAU,CAC3B,WAAW,CAAE,MAAM,CACnB,aAAa,CAAE,OAAO,CAGvB,kEAAmE,CAClE,KAAK,CApOgB,OAA+B,CAuOrD,+BAAgC,CAC/B,KAAK,CA1Pe,OAAa,CA6PlC,qCAAsC,CACrC,KAAK,CA1NoB,IAAsB,CA6NhD,wBAA2B,CAC1B,MAAM,CAAE,UAAU,CAGnB,SAAU,CACT,UAAU,CAAC,KAAK,CAGjB,uBAAwB,CACvB,SAAS,CAAC,KAAK,CACf,MAAM,CAAC,MAAM,CACb,OAAO,CAAC,MAAM,CACd,UAAU,CAAC,SAA8B,CAG1C,sDAAuD,CACtD,UAAU,CAAC,iDAAoF,CAC/F,UAAU,CAAC,mBAAuC,CAClD,WAAW,CAAC,kBAAgD,CAC5D,UAAU,CAAC,IAAI,CACf,KAAK,CAlPa,IAAe,CAqPlC,kBAAmB,CAClB,KAAK,CArPoB,IAAsB,CAsP/C,OAAO,CAAC,IAAI,CACZ,aAAa,CAAC,GAAG,CACjB,gBAAgB,CAAC,OAAiC,CAGnD,OAAQ,CACP,KAAK,CAAC,KAAK,CACX,KAAK,CAAC,GAAG,CAGV,oCAAoC,CACnC,OAAQ,CACP,KAAK,CAAC,IAAI,CACV,KAAK,CAAC,OAAO,CACb,MAAM,CAAC,CAAC,EAIV,UAAW,CACV,SAAS,CAAC,MAAM,CAGjB,UAAW,CACV,YAAY,CAAC,KAAK,CAGnB,UAAW,CACV,SAAS,CAAC,GAAG,CACb,YAAY,CAAC,CAAC,CACd,eAAe,CAAC,IAAI,CAIjB,mCAAqB,CACjB,WAAW,CAAC,KAAK,CAIzB,mCAAoC,CACnC,UAAU,CAAC,oDAAgF,CAC3F,UAAU,CAAC,sBAAqC,CAChD,WAAW,CAAC,cAA8C,CAC1D,KAAK,CArTU,OAAa,CAsT5B,MAAM,CAAC,iBAAgC,CACvC,aAAa,CAAC,GAAG,CAGlB,UAAW,CACV,KAAK,CA9RkB,OAAgC,CAiSxD,aAAc,CACb,MAAM,CAAC,cAA+B,CACtC,sBAAsB,CAAC,GAAG,CAC1B,uBAAuB,CAAC,GAAG,CAC3B,aAAa,CAAC,IAAI,CAGnB,aAAc,CACb,MAAM,CAAC,cAA+B,CACtC,0BAA0B,CAAC,GAAG,CAC9B,yBAAyB,CAAC,GAAG,CAC7B,UAAU,CAAC,IAAI,CAGhB,kCAAmC,CAClC,eAAe,CAAC,OAAO,CACvB,cAAc,CAAC,CAAC,CAChB,MAAM,CAAC,cAA+B,CACtC,aAAa,CAAC,GAAG,CAGlB,+HAAgI,CAC/H,KAAK,CA/ToB,IAAsB,CAgU/C,eAAe,CAAC,IAAI,CAGrB,aAAc,CACb,eAAe,CAAC,OAAO,CACvB,cAAc,CAAC,CAAC,CAChB,MAAM,CAAC,cAA+B,CACtC,aAAa,CAAC,GAAG,CAGlB,gBAAiB,CAChB,MAAM,CAAC,GAAG,CACV,UAAU,CAAC,gEAAiH,CAG7H,mCAAoC,CAvTnC,UAAU,CAAC,oDAAuE,CAClF,UAAU,CAAC,sBAAsC,CACjD,KAAK,CAAC,OAAwB,CAC9B,MAAM,CAAC,iBAAmD,CAwT3D,uBAAwB,CA3TvB,UAAU,CAAC,oDAAuE,CAClF,UAAU,CAAC,sBAAsC,CACjD,KAAK,CAAC,OAAwB,CAC9B,MAAM,CAAC,iBAAmD,CA4T3D,oBAAqB,CA/TpB,UAAU,CAAC,oDAAuE,CAClF,UAAU,CAAC,sBAAsC,CACjD,KAAK,CAAC,OAAwB,CAC9B,MAAM,CAAC,iBAAmD,CAgU3D,eAAgB,CAnUf,UAAU,CAAC,oDAAuE,CAClF,UAAU,CAAC,sBAAsC,CACjD,KAAK,CAAC,OAAwB,CAC9B,MAAM,CAAC,iBAAmD,CAoU3D,gGAAiG,CAChG,aAAa,CAAC,GAAG,CACjB,OAAO,CAAC,GAAG,CACX,WAAW,CAAC,cAAwB,CACpC,MAAM,CAAC,KAAK,CAGb,iRAAkR,CACjR,KAAK,CAAC,OAAO,CAGd,QAAS,CACR,WAAW,CAAC,OAAO,CAGpB,yBAA0B,CACzB,UAAU,CAAC,OAAa,CACxB,aAAa,CAAC,GAAG,CACjB,MAAM,CAAC,IAAI,CACX,OAAO,CAAC,GAAG,CACX,QAAQ,CAAC,IAAI,CACb,WAAW,CAAC,cAAuB,CACnC,MAAM,CAAC,KAAK,CAGb,8CAA+C,CAC9C,KAAK,CA7Ze,OAAa,CAgalC,8BAA+B,CAC9B,KAAK,CAAC,OAAiB,CAGxB,qBAAsB,CACrB,KAAK,CAAC,OAAgB,CAGvB,8CAA+C,CAC9C,KAAK,CAAC,OAA+B,CACrC,WAAW,CAAC,IAAI,CAGjB,kBAAmB,CAClB,KAAK,CAAC,OAAiB,CAGxB,IAAK,CACJ,OAAO,CAAC,IAAI,CACZ,aAAa,CAAC,GAAG", +"sources": ["extra.scss"], +"names": [], +"file": "extra.css" +} diff --git a/docs/extra.scss b/docs/extra.scss index 6c5f3c25..43fe9831 100644 --- a/docs/extra.scss +++ b/docs/extra.scss @@ -135,6 +135,11 @@ body { color:$default-text-color; } +div.title { + font-size: 170%; + margin: 1em 0 0.5em 0; +} + h1,h2,h2.groupheader,h3,div.toc h3,h4,h5,h6,strong,em { color:$heading-color; border-bottom:none; @@ -142,13 +147,13 @@ h1,h2,h2.groupheader,h3,div.toc h3,h4,h5,h6,strong,em { h1 { padding-top:0.5em; - font-size:180%; + font-size:150%; } h2 { padding-top:0.5em; margin-bottom:0; - font-size:140%; + font-size:130%; } h3 { @@ -293,8 +298,16 @@ dl.reflist dt a.el { } div.toc { - float:none; - width:auto; + float:right; + width:35%; +} + +@media screen and (max-width:600px) { + div.toc { + float:none; + width:inherit; + margin:0; + } } div.toc h3 { @@ -311,6 +324,12 @@ div.toc li { list-style-type:disc; } +div.toc { + li.level2, li.level3 { + margin-left:0.5em; + } +} + div.toc,.memproto,div.qindex,div.ah { background:linear-gradient(to bottom,$toc-background-color2 0%,$toc-background-color1 100%); box-shadow:inset 0 0 32px $toc-background-color1; diff --git a/docs/vulkan.dox b/docs/vulkan.dox index 68e3d5fe..a40f47a6 100644 --- a/docs/vulkan.dox +++ b/docs/vulkan.dox @@ -48,7 +48,7 @@ documentation. This is explained in more detail in the [SDK documentation for macOS](https://vulkan.lunarg.com/doc/sdk/latest/mac/getting_started.html). -@section vulkan_include Including the Vulkan and GLFW header files +@section vulkan_include Including the Vulkan header file To include the Vulkan header, define @ref GLFW_INCLUDE_VULKAN before including the GLFW header. From 309d79376f31bddb75faed26efd1fe27b9365c06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Sun, 26 Sep 2021 16:28:04 +0200 Subject: [PATCH 050/208] Fix GLFW_INCLUDE_GLEXT being ignored for glcorearb The GLFW_INCLUDE_GLCOREARB branch was left out when GLFW_INCLUDE_GLEXT was originally added, for reasons that are lost to history. The current versions of these headers seem to co-exist just fine. Issue reported on IRC. --- include/GLFW/glfw3.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index efd54e0c..b90f83a7 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -190,6 +190,9 @@ extern "C" { #else /*__APPLE__*/ #include + #if defined(GLFW_INCLUDE_GLEXT) + #include + #endif #endif /*__APPLE__*/ From f4d0365a5a389b8bb049e34c26b8771833bf7f52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 19 Jul 2021 21:02:30 +0200 Subject: [PATCH 051/208] Use switch statement instead of if-else-chain Related to #1739 --- src/input.c | 142 ++++++++++++++++++++++++++++----------------------- src/window.c | 60 ++++++++++++---------- 2 files changed, 110 insertions(+), 92 deletions(-) diff --git a/src/input.c b/src/input.c index f2604c86..f6e03f23 100644 --- a/src/input.c +++ b/src/input.c @@ -522,90 +522,102 @@ GLFWAPI void glfwSetInputMode(GLFWwindow* handle, int mode, int value) _GLFW_REQUIRE_INIT(); - if (mode == GLFW_CURSOR) + switch (mode) { - if (value != GLFW_CURSOR_NORMAL && - value != GLFW_CURSOR_HIDDEN && - value != GLFW_CURSOR_DISABLED) + case GLFW_CURSOR: { - _glfwInputError(GLFW_INVALID_ENUM, - "Invalid cursor mode 0x%08X", - value); - return; - } - - if (window->cursorMode == value) - return; - - window->cursorMode = value; - - _glfw.platform.getCursorPos(window, - &window->virtualCursorPosX, - &window->virtualCursorPosY); - _glfw.platform.setCursorMode(window, value); - } - else if (mode == GLFW_STICKY_KEYS) - { - value = value ? GLFW_TRUE : GLFW_FALSE; - if (window->stickyKeys == value) - return; - - if (!value) - { - int i; - - // Release all sticky keys - for (i = 0; i <= GLFW_KEY_LAST; i++) + if (value != GLFW_CURSOR_NORMAL && + value != GLFW_CURSOR_HIDDEN && + value != GLFW_CURSOR_DISABLED) { - if (window->keys[i] == _GLFW_STICK) - window->keys[i] = GLFW_RELEASE; + _glfwInputError(GLFW_INVALID_ENUM, + "Invalid cursor mode 0x%08X", + value); + return; } + + if (window->cursorMode == value) + return; + + window->cursorMode = value; + + _glfw.platform.getCursorPos(window, + &window->virtualCursorPosX, + &window->virtualCursorPosY); + _glfw.platform.setCursorMode(window, value); + return; } - window->stickyKeys = value; - } - else if (mode == GLFW_STICKY_MOUSE_BUTTONS) - { - value = value ? GLFW_TRUE : GLFW_FALSE; - if (window->stickyMouseButtons == value) - return; - - if (!value) + case GLFW_STICKY_KEYS: { - int i; + value = value ? GLFW_TRUE : GLFW_FALSE; + if (window->stickyKeys == value) + return; - // Release all sticky mouse buttons - for (i = 0; i <= GLFW_MOUSE_BUTTON_LAST; i++) + if (!value) { - if (window->mouseButtons[i] == _GLFW_STICK) - window->mouseButtons[i] = GLFW_RELEASE; + int i; + + // Release all sticky keys + for (i = 0; i <= GLFW_KEY_LAST; i++) + { + if (window->keys[i] == _GLFW_STICK) + window->keys[i] = GLFW_RELEASE; + } } + + window->stickyKeys = value; + return; } - window->stickyMouseButtons = value; - } - else if (mode == GLFW_LOCK_KEY_MODS) - { - window->lockKeyMods = value ? GLFW_TRUE : GLFW_FALSE; - } - else if (mode == GLFW_RAW_MOUSE_MOTION) - { - if (!_glfw.platform.rawMouseMotionSupported()) + case GLFW_STICKY_MOUSE_BUTTONS: { - _glfwInputError(GLFW_PLATFORM_ERROR, - "Raw mouse motion is not supported on this system"); + value = value ? GLFW_TRUE : GLFW_FALSE; + if (window->stickyMouseButtons == value) + return; + + if (!value) + { + int i; + + // Release all sticky mouse buttons + for (i = 0; i <= GLFW_MOUSE_BUTTON_LAST; i++) + { + if (window->mouseButtons[i] == _GLFW_STICK) + window->mouseButtons[i] = GLFW_RELEASE; + } + } + + window->stickyMouseButtons = value; return; } - value = value ? GLFW_TRUE : GLFW_FALSE; - if (window->rawMouseMotion == value) + case GLFW_LOCK_KEY_MODS: + { + window->lockKeyMods = value ? GLFW_TRUE : GLFW_FALSE; return; + } - window->rawMouseMotion = value; - _glfw.platform.setRawMouseMotion(window, value); + case GLFW_RAW_MOUSE_MOTION: + { + if (!_glfw.platform.rawMouseMotionSupported()) + { + _glfwInputError(GLFW_PLATFORM_ERROR, + "Raw mouse motion is not supported on this system"); + return; + } + + value = value ? GLFW_TRUE : GLFW_FALSE; + if (window->rawMouseMotion == value) + return; + + window->rawMouseMotion = value; + _glfw.platform.setRawMouseMotion(window, value); + return; + } } - else - _glfwInputError(GLFW_INVALID_ENUM, "Invalid input mode 0x%08X", mode); + + _glfwInputError(GLFW_INVALID_ENUM, "Invalid input mode 0x%08X", mode); } GLFWAPI int glfwRawMouseMotionSupported(void) diff --git a/src/window.c b/src/window.c index c9845eca..dda96ec8 100644 --- a/src/window.c +++ b/src/window.c @@ -882,35 +882,41 @@ GLFWAPI void glfwSetWindowAttrib(GLFWwindow* handle, int attrib, int value) value = value ? GLFW_TRUE : GLFW_FALSE; - if (attrib == GLFW_AUTO_ICONIFY) - window->autoIconify = value; - else if (attrib == GLFW_RESIZABLE) + switch (attrib) { - window->resizable = value; - if (!window->monitor) - _glfw.platform.setWindowResizable(window, value); + case GLFW_AUTO_ICONIFY: + window->autoIconify = value; + return; + + case GLFW_RESIZABLE: + window->resizable = value; + if (!window->monitor) + _glfw.platform.setWindowResizable(window, value); + return; + + case GLFW_DECORATED: + window->decorated = value; + if (!window->monitor) + _glfw.platform.setWindowDecorated(window, value); + return; + + case GLFW_FLOATING: + window->floating = value; + if (!window->monitor) + _glfw.platform.setWindowFloating(window, value); + return; + + case GLFW_FOCUS_ON_SHOW: + window->focusOnShow = value; + return; + + case GLFW_MOUSE_PASSTHROUGH: + window->mousePassthrough = value; + _glfw.platform.setWindowMousePassthrough(window, value); + return; } - else if (attrib == GLFW_DECORATED) - { - window->decorated = value; - if (!window->monitor) - _glfw.platform.setWindowDecorated(window, value); - } - else if (attrib == GLFW_FLOATING) - { - window->floating = value; - if (!window->monitor) - _glfw.platform.setWindowFloating(window, value); - } - else if (attrib == GLFW_FOCUS_ON_SHOW) - window->focusOnShow = value; - else if (attrib == GLFW_MOUSE_PASSTHROUGH) - { - window->mousePassthrough = value; - _glfw.platform.setWindowMousePassthrough(window, value); - } - else - _glfwInputError(GLFW_INVALID_ENUM, "Invalid window attribute 0x%08X", attrib); + + _glfwInputError(GLFW_INVALID_ENUM, "Invalid window attribute 0x%08X", attrib); } GLFWAPI GLFWmonitor* glfwGetWindowMonitor(GLFWwindow* handle) From 3d52f7e345ea480d15cc6f23bff7366fda9d2a6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 16 Feb 2021 20:12:19 +0100 Subject: [PATCH 052/208] Limit scope of some loop counters in C99 files --- src/cocoa_init.m | 19 ++++--------- src/cocoa_joystick.m | 29 ++++++------------- src/glx_context.c | 7 ++--- src/linux_joystick.c | 4 +-- src/wl_init.c | 7 ++--- src/wl_window.c | 17 +++++------- src/x11_init.c | 9 +++--- src/x11_window.c | 66 ++++++++++++++++++++------------------------ 8 files changed, 61 insertions(+), 97 deletions(-) diff --git a/src/cocoa_init.m b/src/cocoa_init.m index e97d9596..48bc2c29 100644 --- a/src/cocoa_init.m +++ b/src/cocoa_init.m @@ -75,7 +75,6 @@ static void changeToResourcesDirectory(void) // static void createMenuBar(void) { - size_t i; NSString* appName = nil; NSDictionary* bundleInfo = [[NSBundle mainBundle] infoDictionary]; NSString* nameKeys[] = @@ -87,7 +86,7 @@ static void createMenuBar(void) // Try to figure out what the calling application is called - for (i = 0; i < sizeof(nameKeys) / sizeof(nameKeys[0]); i++) + for (size_t i = 0; i < sizeof(nameKeys) / sizeof(nameKeys[0]); i++) { id name = bundleInfo[nameKeys[i]]; if (name && @@ -177,8 +176,6 @@ static void createMenuBar(void) // static void createKeyTables(void) { - int scancode; - memset(_glfw.ns.keycodes, -1, sizeof(_glfw.ns.keycodes)); memset(_glfw.ns.scancodes, -1, sizeof(_glfw.ns.scancodes)); @@ -297,7 +294,7 @@ static void createKeyTables(void) _glfw.ns.keycodes[0x43] = GLFW_KEY_KP_MULTIPLY; _glfw.ns.keycodes[0x4E] = GLFW_KEY_KP_SUBTRACT; - for (scancode = 0; scancode < 256; scancode++) + for (int scancode = 0; scancode < 256; scancode++) { // Store the reverse translation for faster key name lookup if (_glfw.ns.keycodes[scancode] >= 0) @@ -403,9 +400,7 @@ static GLFWbool initializeTIS(void) - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender { - _GLFWwindow* window; - - for (window = _glfw.windowListHead; window; window = window->next) + for (_GLFWwindow* window = _glfw.windowListHead; window; window = window->next) _glfwInputWindowCloseRequest(window); return NSTerminateCancel; @@ -413,9 +408,7 @@ static GLFWbool initializeTIS(void) - (void)applicationDidChangeScreenParameters:(NSNotification *) notification { - _GLFWwindow* window; - - for (window = _glfw.windowListHead; window; window = window->next) + for (_GLFWwindow* window = _glfw.windowListHead; window; window = window->next) { if (window->context.client != GLFW_NO_API) [window->context.nsgl.object update]; @@ -450,9 +443,7 @@ static GLFWbool initializeTIS(void) - (void)applicationDidHide:(NSNotification *)notification { - int i; - - for (i = 0; i < _glfw.monitorCount; i++) + for (int i = 0; i < _glfw.monitorCount; i++) _glfwRestoreVideoModeCocoa(_glfw.monitors[i]); } diff --git a/src/cocoa_joystick.m b/src/cocoa_joystick.m index 74f20d02..e09e1efa 100644 --- a/src/cocoa_joystick.m +++ b/src/cocoa_joystick.m @@ -96,20 +96,18 @@ static CFComparisonResult compareElements(const void* fp, // static void closeJoystick(_GLFWjoystick* js) { - int i; - if (!js->present) return; - for (i = 0; i < CFArrayGetCount(js->ns.axes); i++) + for (int i = 0; i < CFArrayGetCount(js->ns.axes); i++) _glfw_free((void*) CFArrayGetValueAtIndex(js->ns.axes, i)); CFRelease(js->ns.axes); - for (i = 0; i < CFArrayGetCount(js->ns.buttons); i++) + for (int i = 0; i < CFArrayGetCount(js->ns.buttons); i++) _glfw_free((void*) CFArrayGetValueAtIndex(js->ns.buttons, i)); CFRelease(js->ns.buttons); - for (i = 0; i < CFArrayGetCount(js->ns.hats); i++) + for (int i = 0; i < CFArrayGetCount(js->ns.hats); i++) _glfw_free((void*) CFArrayGetValueAtIndex(js->ns.hats, i)); CFRelease(js->ns.hats); @@ -127,7 +125,6 @@ static void matchCallback(void* context, int jid; char name[256]; char guid[33]; - CFIndex i; CFTypeRef property; uint32_t vendor = 0, product = 0, version = 0; _GLFWjoystick* js; @@ -185,7 +182,7 @@ static void matchCallback(void* context, CFArrayRef elements = IOHIDDeviceCopyMatchingElements(device, NULL, kIOHIDOptionsTypeNone); - for (i = 0; i < CFArrayGetCount(elements); i++) + for (CFIndex i = 0; i < CFArrayGetCount(elements); i++) { IOHIDElementRef native = (IOHIDElementRef) CFArrayGetValueAtIndex(elements, i); @@ -290,9 +287,7 @@ static void removeCallback(void* context, void* sender, IOHIDDeviceRef device) { - int jid; - - for (jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++) + for (int jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++) { if (_glfw.joysticks[jid].ns.device == device) { @@ -386,9 +381,7 @@ GLFWbool _glfwInitJoysticksCocoa(void) void _glfwTerminateJoysticksCocoa(void) { - int jid; - - for (jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++) + for (int jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++) closeJoystick(_glfw.joysticks + jid); if (_glfw.ns.hidManager) @@ -403,9 +396,7 @@ int _glfwPollJoystickCocoa(_GLFWjoystick* js, int mode) { if (mode & _GLFW_POLL_AXES) { - CFIndex i; - - for (i = 0; i < CFArrayGetCount(js->ns.axes); i++) + for (CFIndex i = 0; i < CFArrayGetCount(js->ns.axes); i++) { _GLFWjoyelementNS* axis = (_GLFWjoyelementNS*) CFArrayGetValueAtIndex(js->ns.axes, i); @@ -430,9 +421,7 @@ int _glfwPollJoystickCocoa(_GLFWjoystick* js, int mode) if (mode & _GLFW_POLL_BUTTONS) { - CFIndex i; - - for (i = 0; i < CFArrayGetCount(js->ns.buttons); i++) + for (CFIndex i = 0; i < CFArrayGetCount(js->ns.buttons); i++) { _GLFWjoyelementNS* button = (_GLFWjoyelementNS*) CFArrayGetValueAtIndex(js->ns.buttons, i); @@ -441,7 +430,7 @@ int _glfwPollJoystickCocoa(_GLFWjoystick* js, int mode) _glfwInputJoystickButton(js, (int) i, state); } - for (i = 0; i < CFArrayGetCount(js->ns.hats); i++) + for (CFIndex i = 0; i < CFArrayGetCount(js->ns.hats); i++) { const int states[9] = { diff --git a/src/glx_context.c b/src/glx_context.c index bbe261a0..060e487d 100644 --- a/src/glx_context.c +++ b/src/glx_context.c @@ -55,7 +55,7 @@ static GLFWbool chooseGLXFBConfig(const _GLFWfbconfig* desired, GLXFBConfig* nativeConfigs; _GLFWfbconfig* usableConfigs; const _GLFWfbconfig* closest; - int i, nativeCount, usableCount; + int nativeCount, usableCount; const char* vendor; GLFWbool trustWindowBit = GLFW_TRUE; @@ -76,7 +76,7 @@ static GLFWbool chooseGLXFBConfig(const _GLFWfbconfig* desired, usableConfigs = _glfw_calloc(nativeCount, sizeof(_GLFWfbconfig)); usableCount = 0; - for (i = 0; i < nativeCount; i++) + for (int i = 0; i < nativeCount; i++) { const GLXFBConfig n = nativeConfigs[i]; _GLFWfbconfig* u = usableConfigs + usableCount; @@ -253,7 +253,6 @@ static void destroyContextGLX(_GLFWwindow* window) // GLFWbool _glfwInitGLX(void) { - int i; const char* sonames[] = { #if defined(_GLFW_GLX_LIBRARY) @@ -270,7 +269,7 @@ GLFWbool _glfwInitGLX(void) if (_glfw.glx.handle) return GLFW_TRUE; - for (i = 0; sonames[i]; i++) + for (int i = 0; sonames[i]; i++) { _glfw.glx.handle = _glfwPlatformLoadModule(sonames[i]); if (_glfw.glx.handle) diff --git a/src/linux_joystick.c b/src/linux_joystick.c index 6ea63942..da04e9c3 100644 --- a/src/linux_joystick.c +++ b/src/linux_joystick.c @@ -363,9 +363,7 @@ GLFWbool _glfwInitJoysticksLinux(void) void _glfwTerminateJoysticksLinux(void) { - int jid; - - for (jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++) + for (int jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++) { _GLFWjoystick* js = _glfw.joysticks + jid; if (js->present) diff --git a/src/wl_init.c b/src/wl_init.c index 031e5d52..acfe477d 100644 --- a/src/wl_init.c +++ b/src/wl_init.c @@ -886,10 +886,9 @@ static void registryHandleGlobalRemove(void *data, struct wl_registry *registry, uint32_t name) { - int i; _GLFWmonitor* monitor; - for (i = 0; i < _glfw.monitorCount; ++i) + for (int i = 0; i < _glfw.monitorCount; ++i) { monitor = _glfw.monitors[i]; if (monitor->wl.name == name) @@ -910,8 +909,6 @@ static const struct wl_registry_listener registryListener = { // static void createKeyTables(void) { - int scancode; - memset(_glfw.wl.keycodes, -1, sizeof(_glfw.wl.keycodes)); memset(_glfw.wl.scancodes, -1, sizeof(_glfw.wl.scancodes)); @@ -1033,7 +1030,7 @@ static void createKeyTables(void) _glfw.wl.keycodes[KEY_KPEQUAL] = GLFW_KEY_KP_EQUAL; _glfw.wl.keycodes[KEY_KPENTER] = GLFW_KEY_KP_ENTER; - for (scancode = 0; scancode < 256; scancode++) + for (int scancode = 0; scancode < 256; scancode++) { if (_glfw.wl.keycodes[scancode] > 0) _glfw.wl.scancodes[_glfw.wl.keycodes[scancode]] = scancode; diff --git a/src/wl_window.c b/src/wl_window.c index bf57ce53..b4c59d69 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -144,9 +144,8 @@ static struct wl_buffer* createShmBuffer(const GLFWimage* image) int stride = image->width * 4; int length = image->width * image->height * 4; void* data; - int fd, i; - fd = createAnonymousFile(length); + const int fd = createAnonymousFile(length); if (fd < 0) { _glfwInputError(GLFW_PLATFORM_ERROR, @@ -169,7 +168,7 @@ static struct wl_buffer* createShmBuffer(const GLFWimage* image) close(fd); unsigned char* source = (unsigned char*) image->pixels; unsigned char* target = data; - for (i = 0; i < image->width * image->height; i++, source += 4) + for (int i = 0; i < image->width * image->height; i++, source += 4) { unsigned int alpha = source[3]; @@ -347,7 +346,6 @@ static void resizeWindow(_GLFWwindow* window) static void checkScaleChange(_GLFWwindow* window) { int scale = 1; - int i; int monitorScale; // Check if we will be able to set the buffer scale or not. @@ -355,7 +353,7 @@ static void checkScaleChange(_GLFWwindow* window) return; // Get the scale factor from the highest scale monitor. - for (i = 0; i < window->wl.monitorsCount; ++i) + for (int i = 0; i < window->wl.monitorsCount; ++i) { monitorScale = window->wl.monitors[i]->wl.scale; if (scale < monitorScale) @@ -397,10 +395,9 @@ static void surfaceHandleLeave(void *data, { _GLFWwindow* window = data; _GLFWmonitor* monitor = wl_output_get_user_data(output); - GLFWbool found; - int i; + GLFWbool found = GLFW_FALSE; - for (i = 0, found = GLFW_FALSE; i < window->wl.monitorsCount - 1; ++i) + for (int i = 0; i < window->wl.monitorsCount - 1; ++i) { if (monitor == window->wl.monitors[i]) found = GLFW_TRUE; @@ -719,7 +716,7 @@ static void handleEvents(int timeout) { _glfw.wl.cursorTimerfd, POLLIN }, }; ssize_t read_ret; - uint64_t repeats, i; + uint64_t repeats; while (wl_display_prepare_read(display) != 0) wl_display_dispatch_pending(display); @@ -759,7 +756,7 @@ static void handleEvents(int timeout) if (_glfw.wl.keyboardFocus) { - for (i = 0; i < repeats; ++i) + for (uint64_t i = 0; i < repeats; ++i) { _glfwInputKey(_glfw.wl.keyboardFocus, _glfw.wl.keyboardLastKey, diff --git a/src/x11_init.c b/src/x11_init.c index bedd1bc9..68d6a6c4 100644 --- a/src/x11_init.c +++ b/src/x11_init.c @@ -209,7 +209,7 @@ static int translateKeySyms(const KeySym* keysyms, int width) // static void createKeyTables(void) { - int scancode, scancodeMin, scancodeMax; + int scancodeMin, scancodeMax; memset(_glfw.x11.keycodes, -1, sizeof(_glfw.x11.keycodes)); memset(_glfw.x11.scancodes, -1, sizeof(_glfw.x11.scancodes)); @@ -355,7 +355,7 @@ static void createKeyTables(void) }; // Find the X11 key code -> GLFW key code mapping - for (scancode = scancodeMin; scancode <= scancodeMax; scancode++) + for (int scancode = scancodeMin; scancode <= scancodeMax; scancode++) { int key = GLFW_KEY_UNKNOWN; @@ -414,7 +414,7 @@ static void createKeyTables(void) scancodeMax - scancodeMin + 1, &width); - for (scancode = scancodeMin; scancode <= scancodeMax; scancode++) + for (int scancode = scancodeMin; scancode <= scancodeMax; scancode++) { // Translate the un-translated key codes using traditional X11 KeySym // lookups @@ -1072,7 +1072,6 @@ void _glfwInputErrorX11(int error, const char* message) // Cursor _glfwCreateNativeCursorX11(const GLFWimage* image, int xhot, int yhot) { - int i; Cursor cursor; if (!_glfw.x11.xcursor.handle) @@ -1088,7 +1087,7 @@ Cursor _glfwCreateNativeCursorX11(const GLFWimage* image, int xhot, int yhot) unsigned char* source = (unsigned char*) image->pixels; XcursorPixel* target = native->pixels; - for (i = 0; i < image->width * image->height; i++, target++, source += 4) + for (int i = 0; i < image->width * image->height; i++, target++, source += 4) { unsigned int alpha = source[3]; diff --git a/src/x11_window.c b/src/x11_window.c index 3c74a813..616f9fd8 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -788,7 +788,6 @@ static GLFWbool createNativeWindow(_GLFWwindow* window, // static Atom writeTargetToProperty(const XSelectionRequestEvent* request) { - int i; char* selectionString = NULL; const Atom formats[] = { _glfw.x11.UTF8_STRING, XA_STRING }; const int formatCount = sizeof(formats) / sizeof(formats[0]); @@ -831,14 +830,13 @@ static Atom writeTargetToProperty(const XSelectionRequestEvent* request) // Multiple conversions were requested Atom* targets; - unsigned long i, count; + const unsigned long count = + _glfwGetWindowPropertyX11(request->requestor, + request->property, + _glfw.x11.ATOM_PAIR, + (unsigned char**) &targets); - count = _glfwGetWindowPropertyX11(request->requestor, - request->property, - _glfw.x11.ATOM_PAIR, - (unsigned char**) &targets); - - for (i = 0; i < count; i += 2) + for (unsigned long i = 0; i < count; i += 2) { int j; @@ -896,7 +894,7 @@ static Atom writeTargetToProperty(const XSelectionRequestEvent* request) // Conversion to a data target was requested - for (i = 0; i < formatCount; i++) + for (int i = 0; i < formatCount; i++) { if (request->target == formats[i]) { @@ -1588,7 +1586,7 @@ static void processEvent(XEvent *event) else if (event->xclient.message_type == _glfw.x11.XdndEnter) { // A drag operation has entered the window - unsigned long i, count; + unsigned long count; Atom* formats = NULL; const GLFWbool list = event->xclient.data.l[1] & 1; @@ -1612,7 +1610,7 @@ static void processEvent(XEvent *event) formats = (Atom*) event->xclient.data.l + 2; } - for (i = 0; i < count; i++) + for (unsigned int i = 0; i < count; i++) { if (formats[i] == _glfw.x11.text_uri_list) { @@ -1718,12 +1716,12 @@ static void processEvent(XEvent *event) if (result) { - int i, count; + int count; char** paths = parseUriList(data, &count); _glfwInputDrop(window, count, (const char**) paths); - for (i = 0; i < count; i++) + for (int i = 0; i < count; i++) _glfw_free(paths[i]); _glfw_free(paths); } @@ -2102,20 +2100,20 @@ void _glfwSetWindowIconX11(_GLFWwindow* window, int count, const GLFWimage* imag { if (count) { - int i, j, longCount = 0; + int longCount = 0; - for (i = 0; i < count; i++) + for (int i = 0; i < count; i++) longCount += 2 + images[i].width * images[i].height; long* icon = _glfw_calloc(longCount, sizeof(long)); long* target = icon; - for (i = 0; i < count; i++) + for (int i = 0; i < count; i++) { *target++ = images[i].width; *target++ = images[i].height; - for (j = 0; j < images[i].width * images[i].height; j++) + for (int j = 0; j < images[i].width * images[i].height; j++) { *target++ = (images[i].pixels[j * 4 + 0] << 16) | (images[i].pixels[j * 4 + 1] << 8) | @@ -2537,7 +2535,6 @@ int _glfwWindowVisibleX11(_GLFWwindow* window) int _glfwWindowMaximizedX11(_GLFWwindow* window) { Atom* states; - unsigned long i; GLFWbool maximized = GLFW_FALSE; if (!_glfw.x11.NET_WM_STATE || @@ -2553,7 +2550,7 @@ int _glfwWindowMaximizedX11(_GLFWwindow* window) XA_ATOM, (unsigned char**) &states); - for (i = 0; i < count; i++) + for (unsigned long i = 0; i < count; i++) { if (states[i] == _glfw.x11.NET_WM_STATE_MAXIMIZED_VERT || states[i] == _glfw.x11.NET_WM_STATE_MAXIMIZED_HORZ) @@ -2651,18 +2648,19 @@ void _glfwSetWindowFloatingX11(_GLFWwindow* window, GLFWbool enabled) else { Atom* states = NULL; - unsigned long i, count; - - count = _glfwGetWindowPropertyX11(window->x11.handle, - _glfw.x11.NET_WM_STATE, - XA_ATOM, - (unsigned char**) &states); + const unsigned long count = + _glfwGetWindowPropertyX11(window->x11.handle, + _glfw.x11.NET_WM_STATE, + XA_ATOM, + (unsigned char**) &states); // NOTE: We don't check for failure as this property may not exist yet // and that's fine (and we'll create it implicitly with append) if (enabled) { + unsigned long i; + for (i = 0; i < count; i++) { if (states[i] == _glfw.x11.NET_WM_STATE_ABOVE) @@ -2680,20 +2678,16 @@ void _glfwSetWindowFloatingX11(_GLFWwindow* window, GLFWbool enabled) } else if (states) { - for (i = 0; i < count; i++) + for (unsigned long i = 0; i < count; i++) { if (states[i] == _glfw.x11.NET_WM_STATE_ABOVE) + { + states[i] = states[count - 1]; + XChangeProperty(_glfw.x11.display, window->x11.handle, + _glfw.x11.NET_WM_STATE, XA_ATOM, 32, + PropModeReplace, (unsigned char*) states, count - 1); break; - } - - if (i < count) - { - states[i] = states[count - 1]; - count--; - - XChangeProperty(_glfw.x11.display, window->x11.handle, - _glfw.x11.NET_WM_STATE, XA_ATOM, 32, - PropModeReplace, (unsigned char*) states, count); + } } } From 0fe96ec2025557b37d4e2e003cb7115141db4d18 Mon Sep 17 00:00:00 2001 From: luz paz Date: Wed, 15 Sep 2021 08:20:56 -0400 Subject: [PATCH 053/208] Fix various typos Found via `codespell -q 3 -S ./deps -L fo,numer,te,uint,wille` Closes #1965 --- include/GLFW/glfw3.h | 2 +- src/win32_platform.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index b90f83a7..17cb66c2 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -375,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 diff --git a/src/win32_platform.h b/src/win32_platform.h index 20e40d74..a7130377 100644 --- a/src/win32_platform.h +++ b/src/win32_platform.h @@ -428,7 +428,7 @@ typedef struct _GLFWwindowWin32 // The last received cursor position, regardless of source int lastCursorPosX, lastCursorPosY; - // The last recevied high surrogate when decoding pairs of UTF-16 messages + // The last received high surrogate when decoding pairs of UTF-16 messages WCHAR highSurrogate; } _GLFWwindowWin32; From 41ebcf1eed4f74028a218d7dd3c14c663464c030 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Sun, 17 Oct 2021 20:52:31 +0200 Subject: [PATCH 054/208] Add credit Related to #1965 --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index d1396af4..bb24ebe9 100644 --- a/README.md +++ b/README.md @@ -433,6 +433,7 @@ skills. - Denis Ovod - Ozzy - Andri Pálsson + - luz paz - Peoro - Braden Pellett - Christopher Pelloux From 53d7622a3a78757d5297ecafa235fac64a62b0a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 19 Jul 2021 18:25:50 +0200 Subject: [PATCH 055/208] Move list of contributors to separate file Fixes #1839 --- CONTRIBUTORS.md | 226 +++++++++++++++++++++++++++++++++++++++++++++++ README.md | 230 ++---------------------------------------------- 2 files changed, 231 insertions(+), 225 deletions(-) create mode 100644 CONTRIBUTORS.md diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md new file mode 100644 index 00000000..7e79b955 --- /dev/null +++ b/CONTRIBUTORS.md @@ -0,0 +1,226 @@ +# Acknowledgements + +GLFW exists because people around the world donated their time and lent their +skills. This list only includes contributions to the main repository and +excludes other invaluable contributions like language bindings and text and +video tutorials. + + - Bobyshev Alexander + - Laurent Aphecetche + - Matt Arsenault + - ashishgamedev + - David Avedissian + - Keith Bauer + - John Bartholomew + - CoÅŸku BaÅŸ + - Niklas Behrens + - Andrew Belt + - Nevyn Bengtsson + - Niklas Bergström + - Denis Bernard + - Doug Binks + - blanco + - Waris Boonyasiriwat + - Kyle Brenneman + - Rok Breulj + - Kai Burjack + - Martin Capitanio + - Nicolas Caramelli + - David Carlier + - Arturo Castro + - Chi-kwan Chan + - Joseph Chua + - Ian Clarkson + - MichaÅ‚ CichoÅ„ + - Lambert Clara + - Anna Clarke + - Yaron Cohen-Tal + - Omar Cornut + - Andrew Corrigan + - Bailey Cosier + - Noel Cower + - CuriouserThing + - Jason Daly + - Jarrod Davis + - Olivier Delannoy + - Paul R. Deppe + - Michael Dickens + - Роман Донченко + - Mario Dorn + - Wolfgang Draxinger + - Jonathan Dummer + - Ralph Eastwood + - Fredrik Ehnbom + - Robin Eklind + - Siavash Eliasi + - Ahmad Fatoum + - Felipe Ferreira + - Michael Fogleman + - Gerald Franz + - Mário Freitas + - GeO4d + - Marcus Geelnard + - Charles Giessen + - Ryan C. Gordon + - Stephen Gowen + - Kovid Goyal + - Eloi Marín Gratacós + - Stefan Gustavson + - Jonathan Hale + - hdf89shfdfs + - Sylvain Hellegouarch + - Matthew Henry + - heromyth + - Lucas Hinderberger + - Paul Holden + - Warren Hu + - Charles Huber + - IntellectualKitty + - Aaron Jacobs + - Erik S. V. Jansson + - Toni Jovanoski + - Arseny Kapoulkine + - Cem Karan + - Osman Keskin + - Koray Kilinc + - Josh Kilmer + - Byunghoon Kim + - Cameron King + - Peter Knut + - Christoph Kubisch + - Yuri Kunde Schlesner + - Rokas Kupstys + - Konstantin Käfer + - Eric Larson + - Francis Lecavalier + - Jong Won Lee + - Robin Leffmann + - Glenn Lewis + - Shane Liesegang + - Anders Lindqvist + - Leon Linhart + - Marco Lizza + - Eyal Lotem + - Aaron Loucks + - Luflosi + - lukect + - Tristam MacDonald + - Hans Mackowiak + - Дмитри Малышев + - Zbigniew Mandziejewicz + - Adam Marcus + - Célestin Marot + - Kyle McDonald + - David V. McKay + - David Medlock + - Bryce Mehring + - Jonathan Mercier + - Marcel Metz + - Liam Middlebrook + - Ave Milia + - Jonathan Miller + - Kenneth Miller + - Bruce Mitchener + - Jack Moffitt + - Jeff Molofee + - Alexander Monakov + - Pierre Morel + - Jon Morton + - Pierre Moulon + - Martins Mozeiko + - Julian Møller + - ndogxj + - n3rdopolis + - Kristian Nielsen + - Kamil Nowakowski + - onox + - Denis Ovod + - Ozzy + - Andri Pálsson + - luz paz + - Peoro + - Braden Pellett + - Christopher Pelloux + - Arturo J. Pérez + - Vladimir Perminov + - Anthony Pesch + - Orson Peters + - Emmanuel Gil Peyrot + - Cyril Pichard + - Keith Pitt + - Stanislav Podgorskiy + - Konstantin Podsvirov + - Nathan Poirier + - Alexandre Pretyman + - Pablo Prietz + - przemekmirek + - pthom + - Guillaume Racicot + - Philip Rideout + - Eddie Ringle + - Max Risuhin + - Jorge Rodriguez + - Jari Ronkainen + - Luca Rood + - Ed Ropple + - Aleksey Rybalkin + - Mikko Rytkönen + - Riku Salminen + - Brandon Schaefer + - Sebastian Schuberth + - Christian Sdunek + - Matt Sealey + - Steve Sexton + - Arkady Shapkin + - Ali Sherief + - Yoshiki Shibukawa + - Dmitri Shuralyov + - Daniel Skorupski + - Anthony Smith + - Bradley Smith + - Cliff Smolinsky + - Patrick Snape + - Erlend Sogge Heggen + - Julian Squires + - Johannes Stein + - Pontus Stenetorp + - Michael Stocker + - Justin Stoecker + - Elviss Strazdins + - Paul Sultana + - Nathan Sweet + - TTK-Bandit + - Jared Tiala + - Sergey Tikhomirov + - Arthur Tombs + - Ioannis Tsakpinis + - Samuli Tuomola + - Matthew Turner + - urraka + - Elias Vanderstuyft + - Stef Velzel + - Jari Vetoniemi + - Ricardo Vieira + - Nicholas Vitovitch + - Simon Voordouw + - Corentin Wallez + - Torsten Walluhn + - Patrick Walton + - Xo Wang + - Jay Weisskopf + - Frank Wille + - Andy Williams + - Joel Winarske + - Richard A. Wilkes + - Tatsuya Yatagawa + - Ryogo Yoshimura + - Lukas Zanner + - Andrey Zholos + - Aihui Zhu + - Santi Zupancic + - Jonas Ã…dahl + - Lasse Öörni + - Leonard König + - All the unmentioned and anonymous contributors in the GLFW community, for bug + reports, patches, feedback, testing and encouragement + diff --git a/README.md b/README.md index bb24ebe9..d97f2e7e 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,11 @@ you have used GLFW 2 in the past, there is a [transition guide](https://www.glfw.org/docs/latest/moving.html) for moving to the GLFW 3 API. +GLFW exists because of the contributions of [many people](CONTRIBUTORS.md) +around the world, whether by reporting bugs, providing community support, adding +features, reviewing or testing code, debugging, proofreading docs, suggesting +features or fixing bugs. + ## Compiling GLFW @@ -295,228 +300,3 @@ request, please file it in the Finally, if you're interested in helping out with the development of GLFW or porting it to your favorite platform, join us on the forum, GitHub or IRC. - -## Acknowledgements - -GLFW exists because people around the world donated their time and lent their -skills. - - - Bobyshev Alexander - - Laurent Aphecetche - - Matt Arsenault - - ashishgamedev - - David Avedissian - - Keith Bauer - - John Bartholomew - - CoÅŸku BaÅŸ - - Niklas Behrens - - Andrew Belt - - Nevyn Bengtsson - - Niklas Bergström - - Denis Bernard - - Doug Binks - - blanco - - Waris Boonyasiriwat - - Kyle Brenneman - - Rok Breulj - - Kai Burjack - - Martin Capitanio - - Nicolas Caramelli - - David Carlier - - Arturo Castro - - Chi-kwan Chan - - Joseph Chua - - Ian Clarkson - - MichaÅ‚ CichoÅ„ - - Lambert Clara - - Anna Clarke - - Yaron Cohen-Tal - - Omar Cornut - - Andrew Corrigan - - Bailey Cosier - - Noel Cower - - CuriouserThing - - Jason Daly - - Jarrod Davis - - Olivier Delannoy - - Paul R. Deppe - - Michael Dickens - - Роман Донченко - - Mario Dorn - - Wolfgang Draxinger - - Jonathan Dummer - - Ralph Eastwood - - Fredrik Ehnbom - - Robin Eklind - - Siavash Eliasi - - Ahmad Fatoum - - Felipe Ferreira - - Michael Fogleman - - Gerald Franz - - Mário Freitas - - GeO4d - - Marcus Geelnard - - Charles Giessen - - Ryan C. Gordon - - Stephen Gowen - - Kovid Goyal - - Eloi Marín Gratacós - - Stefan Gustavson - - Jonathan Hale - - hdf89shfdfs - - Sylvain Hellegouarch - - Matthew Henry - - heromyth - - Lucas Hinderberger - - Paul Holden - - Warren Hu - - Charles Huber - - IntellectualKitty - - Aaron Jacobs - - Erik S. V. Jansson - - Toni Jovanoski - - Arseny Kapoulkine - - Cem Karan - - Osman Keskin - - Koray Kilinc - - Josh Kilmer - - Byunghoon Kim - - Cameron King - - Peter Knut - - Christoph Kubisch - - Yuri Kunde Schlesner - - Rokas Kupstys - - Konstantin Käfer - - Eric Larson - - Francis Lecavalier - - Jong Won Lee - - Robin Leffmann - - Glenn Lewis - - Shane Liesegang - - Anders Lindqvist - - Leon Linhart - - Marco Lizza - - Eyal Lotem - - Aaron Loucks - - Luflosi - - lukect - - Tristam MacDonald - - Hans Mackowiak - - Дмитри Малышев - - Zbigniew Mandziejewicz - - Adam Marcus - - Célestin Marot - - Kyle McDonald - - David V. McKay - - David Medlock - - Bryce Mehring - - Jonathan Mercier - - Marcel Metz - - Liam Middlebrook - - Ave Milia - - Jonathan Miller - - Kenneth Miller - - Bruce Mitchener - - Jack Moffitt - - Jeff Molofee - - Alexander Monakov - - Pierre Morel - - Jon Morton - - Pierre Moulon - - Martins Mozeiko - - Julian Møller - - ndogxj - - n3rdopolis - - Kristian Nielsen - - Kamil Nowakowski - - onox - - Denis Ovod - - Ozzy - - Andri Pálsson - - luz paz - - Peoro - - Braden Pellett - - Christopher Pelloux - - Arturo J. Pérez - - Vladimir Perminov - - Anthony Pesch - - Orson Peters - - Emmanuel Gil Peyrot - - Cyril Pichard - - Keith Pitt - - Stanislav Podgorskiy - - Konstantin Podsvirov - - Nathan Poirier - - Alexandre Pretyman - - Pablo Prietz - - przemekmirek - - pthom - - Guillaume Racicot - - Philip Rideout - - Eddie Ringle - - Max Risuhin - - Jorge Rodriguez - - Jari Ronkainen - - Luca Rood - - Ed Ropple - - Aleksey Rybalkin - - Mikko Rytkönen - - Riku Salminen - - Brandon Schaefer - - Sebastian Schuberth - - Christian Sdunek - - Matt Sealey - - Steve Sexton - - Arkady Shapkin - - Ali Sherief - - Yoshiki Shibukawa - - Dmitri Shuralyov - - Daniel Skorupski - - Anthony Smith - - Bradley Smith - - Cliff Smolinsky - - Patrick Snape - - Erlend Sogge Heggen - - Julian Squires - - Johannes Stein - - Pontus Stenetorp - - Michael Stocker - - Justin Stoecker - - Elviss Strazdins - - Paul Sultana - - Nathan Sweet - - TTK-Bandit - - Jared Tiala - - Sergey Tikhomirov - - Arthur Tombs - - Ioannis Tsakpinis - - Samuli Tuomola - - Matthew Turner - - urraka - - Elias Vanderstuyft - - Stef Velzel - - Jari Vetoniemi - - Ricardo Vieira - - Nicholas Vitovitch - - Simon Voordouw - - Corentin Wallez - - Torsten Walluhn - - Patrick Walton - - Xo Wang - - Jay Weisskopf - - Frank Wille - - Andy Williams - - Joel Winarske - - Richard A. Wilkes - - Tatsuya Yatagawa - - Ryogo Yoshimura - - Lukas Zanner - - Andrey Zholos - - Aihui Zhu - - Santi Zupancic - - Jonas Ã…dahl - - Lasse Öörni - - Leonard König - - All the unmentioned and anonymous contributors in the GLFW community, for bug - reports, patches, feedback, testing and encouragement - From 4005f70eef41a691b849cd06e085d9005df6b66b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 18 Oct 2021 01:05:09 +0200 Subject: [PATCH 056/208] WGL: Limit DWM swap interval hack to Vista and 7 This hack breaks when switching a window to fullscreen, if the OpenGL ICD detects this and switches its swapchain to exclusive mode. This limits the hack to Windows Vista and 7. This hack was added because of vsync jitter under DWM on Windows 7 and I have been unable to reproduce it on any later version. Is this change causing any problems on any version of Windows? Please open an issue! Fixes #1072 --- README.md | 1 + src/wgl_context.c | 22 +++++++++------------- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index d97f2e7e..e6da3acd 100644 --- a/README.md +++ b/README.md @@ -271,6 +271,7 @@ information on what to include when reporting a bug. - [Wayland] Bugfix: Non-arrow cursors are offset from the hotspot (#1706,#1899) - [POSIX] Removed use of deprecated function `gettimeofday` - [POSIX] Bugfix: `CLOCK_MONOTONIC` was not correctly tested for or enabled + - [WGL] Disabled the DWM swap interval hack for Windows 8 and later (#1072) - [NSGL] Removed enforcement of forward-compatible flag for core contexts - [NSGL] Bugfix: `GLFW_COCOA_RETINA_FRAMEBUFFER` had no effect on newer macOS versions (#1442) diff --git a/src/wgl_context.c b/src/wgl_context.c index 952d70de..6586db10 100644 --- a/src/wgl_context.c +++ b/src/wgl_context.c @@ -322,14 +322,12 @@ static void swapBuffersWGL(_GLFWwindow* window) { if (!window->monitor) { - if (IsWindowsVistaOrGreater()) + // HACK: Use DwmFlush when desktop composition is enabled on Windows Vista and 7 + if (!IsWindows8OrGreater() && IsWindowsVistaOrGreater()) { - // DWM Composition is always enabled on Win8+ - BOOL enabled = IsWindows8OrGreater(); + BOOL enabled = FALSE; - // HACK: Use DwmFlush when desktop composition is enabled - if (enabled || - (SUCCEEDED(DwmIsCompositionEnabled(&enabled)) && enabled)) + if (SUCCEEDED(DwmIsCompositionEnabled(&enabled)) && enabled) { int count = abs(window->context.wgl.interval); while (count--) @@ -349,15 +347,13 @@ static void swapIntervalWGL(int interval) if (!window->monitor) { - if (IsWindowsVistaOrGreater()) + // HACK: Disable WGL swap interval when desktop composition is enabled on Windows + // Vista and 7 to avoid interfering with DWM vsync + if (!IsWindows8OrGreater() && IsWindowsVistaOrGreater()) { - // DWM Composition is always enabled on Win8+ - BOOL enabled = IsWindows8OrGreater(); + BOOL enabled = FALSE; - // HACK: Disable WGL swap interval when desktop composition is enabled to - // avoid interfering with DWM vsync - if (enabled || - (SUCCEEDED(DwmIsCompositionEnabled(&enabled)) && enabled)) + if (SUCCEEDED(DwmIsCompositionEnabled(&enabled)) && enabled) interval = 0; } } From 68534cc2ce43126b0451f7fc771d6c5a2e6e9981 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 19 Oct 2021 15:32:40 +0200 Subject: [PATCH 057/208] Null: Remove unused function --- src/null_platform.h | 1 - src/null_window.c | 4 ---- 2 files changed, 5 deletions(-) diff --git a/src/null_platform.h b/src/null_platform.h index 30e50a85..fca7c11f 100644 --- a/src/null_platform.h +++ b/src/null_platform.h @@ -116,7 +116,6 @@ GLFWbool _glfwRawMouseMotionSupportedNull(void); void _glfwShowWindowNull(_GLFWwindow* window); void _glfwRequestWindowAttentionNull(_GLFWwindow* window); void _glfwRequestWindowAttentionNull(_GLFWwindow* window); -void _glfwUnhideWindowNull(_GLFWwindow* window); void _glfwHideWindowNull(_GLFWwindow* window); void _glfwFocusWindowNull(_GLFWwindow* window); int _glfwWindowFocusedNull(_GLFWwindow* window); diff --git a/src/null_window.c b/src/null_window.c index 10c5293f..710d4c9c 100644 --- a/src/null_window.c +++ b/src/null_window.c @@ -409,10 +409,6 @@ void _glfwRequestWindowAttentionNull(_GLFWwindow* window) { } -void _glfwUnhideWindowNull(_GLFWwindow* window) -{ -} - void _glfwHideWindowNull(_GLFWwindow* window) { if (_glfw.null.focusedWindow == window) From ee6ff939a540544494dc70f00a49af0561282dee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 21 Oct 2021 19:43:01 +0200 Subject: [PATCH 058/208] Fix invalid pointer conversions C does not allow conversions between data pointers and function pointers. Yes, the name of the macro is reserved. That's something for a future commit to fix. Fixes #1703 --- src/init.c | 2 +- src/input.c | 18 +++++++++--------- src/internal.h | 12 ++++++------ src/monitor.c | 2 +- src/window.c | 18 +++++++++--------- 5 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/init.c b/src/init.c index cdb7ae41..65f5de31 100644 --- a/src/init.c +++ b/src/init.c @@ -440,7 +440,7 @@ GLFWAPI int glfwGetError(const char** description) GLFWAPI GLFWerrorfun glfwSetErrorCallback(GLFWerrorfun cbfun) { - _GLFW_SWAP_POINTERS(_glfwErrorCallback, cbfun); + _GLFW_SWAP(GLFWerrorfun, _glfwErrorCallback, cbfun); return cbfun; } diff --git a/src/input.c b/src/input.c index f6e03f23..11716bd5 100644 --- a/src/input.c +++ b/src/input.c @@ -868,7 +868,7 @@ GLFWAPI GLFWkeyfun glfwSetKeyCallback(GLFWwindow* handle, GLFWkeyfun cbfun) assert(window != NULL); _GLFW_REQUIRE_INIT_OR_RETURN(NULL); - _GLFW_SWAP_POINTERS(window->callbacks.key, cbfun); + _GLFW_SWAP(GLFWkeyfun, window->callbacks.key, cbfun); return cbfun; } @@ -878,7 +878,7 @@ GLFWAPI GLFWcharfun glfwSetCharCallback(GLFWwindow* handle, GLFWcharfun cbfun) assert(window != NULL); _GLFW_REQUIRE_INIT_OR_RETURN(NULL); - _GLFW_SWAP_POINTERS(window->callbacks.character, cbfun); + _GLFW_SWAP(GLFWcharfun, window->callbacks.character, cbfun); return cbfun; } @@ -888,7 +888,7 @@ GLFWAPI GLFWcharmodsfun glfwSetCharModsCallback(GLFWwindow* handle, GLFWcharmods assert(window != NULL); _GLFW_REQUIRE_INIT_OR_RETURN(NULL); - _GLFW_SWAP_POINTERS(window->callbacks.charmods, cbfun); + _GLFW_SWAP(GLFWcharmodsfun, window->callbacks.charmods, cbfun); return cbfun; } @@ -899,7 +899,7 @@ GLFWAPI GLFWmousebuttonfun glfwSetMouseButtonCallback(GLFWwindow* handle, assert(window != NULL); _GLFW_REQUIRE_INIT_OR_RETURN(NULL); - _GLFW_SWAP_POINTERS(window->callbacks.mouseButton, cbfun); + _GLFW_SWAP(GLFWmousebuttonfun, window->callbacks.mouseButton, cbfun); return cbfun; } @@ -910,7 +910,7 @@ GLFWAPI GLFWcursorposfun glfwSetCursorPosCallback(GLFWwindow* handle, assert(window != NULL); _GLFW_REQUIRE_INIT_OR_RETURN(NULL); - _GLFW_SWAP_POINTERS(window->callbacks.cursorPos, cbfun); + _GLFW_SWAP(GLFWcursorposfun, window->callbacks.cursorPos, cbfun); return cbfun; } @@ -921,7 +921,7 @@ GLFWAPI GLFWcursorenterfun glfwSetCursorEnterCallback(GLFWwindow* handle, assert(window != NULL); _GLFW_REQUIRE_INIT_OR_RETURN(NULL); - _GLFW_SWAP_POINTERS(window->callbacks.cursorEnter, cbfun); + _GLFW_SWAP(GLFWcursorenterfun, window->callbacks.cursorEnter, cbfun); return cbfun; } @@ -932,7 +932,7 @@ GLFWAPI GLFWscrollfun glfwSetScrollCallback(GLFWwindow* handle, assert(window != NULL); _GLFW_REQUIRE_INIT_OR_RETURN(NULL); - _GLFW_SWAP_POINTERS(window->callbacks.scroll, cbfun); + _GLFW_SWAP(GLFWscrollfun, window->callbacks.scroll, cbfun); return cbfun; } @@ -942,7 +942,7 @@ GLFWAPI GLFWdropfun glfwSetDropCallback(GLFWwindow* handle, GLFWdropfun cbfun) assert(window != NULL); _GLFW_REQUIRE_INIT_OR_RETURN(NULL); - _GLFW_SWAP_POINTERS(window->callbacks.drop, cbfun); + _GLFW_SWAP(GLFWdropfun, window->callbacks.drop, cbfun); return cbfun; } @@ -1166,7 +1166,7 @@ GLFWAPI GLFWjoystickfun glfwSetJoystickCallback(GLFWjoystickfun cbfun) if (!initJoysticks()) return NULL; - _GLFW_SWAP_POINTERS(_glfw.callbacks.joystick, cbfun); + _GLFW_SWAP(GLFWjoystickfun, _glfw.callbacks.joystick, cbfun); return cbfun; } diff --git a/src/internal.h b/src/internal.h index 45ae45ab..4d2a6805 100644 --- a/src/internal.h +++ b/src/internal.h @@ -357,12 +357,12 @@ typedef void (APIENTRY * PFN_vkVoidFunction)(void); } // Swaps the provided pointers -#define _GLFW_SWAP_POINTERS(x, y) \ - { \ - void* t; \ - t = x; \ - x = y; \ - y = t; \ +#define _GLFW_SWAP(type, x, y) \ + { \ + type t; \ + t = x; \ + x = y; \ + y = t; \ } // Per-thread error structure diff --git a/src/monitor.c b/src/monitor.c index 31921b46..e6f47d65 100644 --- a/src/monitor.c +++ b/src/monitor.c @@ -419,7 +419,7 @@ GLFWAPI void* glfwGetMonitorUserPointer(GLFWmonitor* handle) GLFWAPI GLFWmonitorfun glfwSetMonitorCallback(GLFWmonitorfun cbfun) { _GLFW_REQUIRE_INIT_OR_RETURN(NULL); - _GLFW_SWAP_POINTERS(_glfw.callbacks.monitor, cbfun); + _GLFW_SWAP(GLFWmonitorfun, _glfw.callbacks.monitor, cbfun); return cbfun; } diff --git a/src/window.c b/src/window.c index dda96ec8..a65ed760 100644 --- a/src/window.c +++ b/src/window.c @@ -992,7 +992,7 @@ GLFWAPI GLFWwindowposfun glfwSetWindowPosCallback(GLFWwindow* handle, assert(window != NULL); _GLFW_REQUIRE_INIT_OR_RETURN(NULL); - _GLFW_SWAP_POINTERS(window->callbacks.pos, cbfun); + _GLFW_SWAP(GLFWwindowposfun, window->callbacks.pos, cbfun); return cbfun; } @@ -1003,7 +1003,7 @@ GLFWAPI GLFWwindowsizefun glfwSetWindowSizeCallback(GLFWwindow* handle, assert(window != NULL); _GLFW_REQUIRE_INIT_OR_RETURN(NULL); - _GLFW_SWAP_POINTERS(window->callbacks.size, cbfun); + _GLFW_SWAP(GLFWwindowsizefun, window->callbacks.size, cbfun); return cbfun; } @@ -1014,7 +1014,7 @@ GLFWAPI GLFWwindowclosefun glfwSetWindowCloseCallback(GLFWwindow* handle, assert(window != NULL); _GLFW_REQUIRE_INIT_OR_RETURN(NULL); - _GLFW_SWAP_POINTERS(window->callbacks.close, cbfun); + _GLFW_SWAP(GLFWwindowclosefun, window->callbacks.close, cbfun); return cbfun; } @@ -1025,7 +1025,7 @@ GLFWAPI GLFWwindowrefreshfun glfwSetWindowRefreshCallback(GLFWwindow* handle, assert(window != NULL); _GLFW_REQUIRE_INIT_OR_RETURN(NULL); - _GLFW_SWAP_POINTERS(window->callbacks.refresh, cbfun); + _GLFW_SWAP(GLFWwindowrefreshfun, window->callbacks.refresh, cbfun); return cbfun; } @@ -1036,7 +1036,7 @@ GLFWAPI GLFWwindowfocusfun glfwSetWindowFocusCallback(GLFWwindow* handle, assert(window != NULL); _GLFW_REQUIRE_INIT_OR_RETURN(NULL); - _GLFW_SWAP_POINTERS(window->callbacks.focus, cbfun); + _GLFW_SWAP(GLFWwindowfocusfun, window->callbacks.focus, cbfun); return cbfun; } @@ -1047,7 +1047,7 @@ GLFWAPI GLFWwindowiconifyfun glfwSetWindowIconifyCallback(GLFWwindow* handle, assert(window != NULL); _GLFW_REQUIRE_INIT_OR_RETURN(NULL); - _GLFW_SWAP_POINTERS(window->callbacks.iconify, cbfun); + _GLFW_SWAP(GLFWwindowiconifyfun, window->callbacks.iconify, cbfun); return cbfun; } @@ -1058,7 +1058,7 @@ GLFWAPI GLFWwindowmaximizefun glfwSetWindowMaximizeCallback(GLFWwindow* handle, assert(window != NULL); _GLFW_REQUIRE_INIT_OR_RETURN(NULL); - _GLFW_SWAP_POINTERS(window->callbacks.maximize, cbfun); + _GLFW_SWAP(GLFWwindowmaximizefun, window->callbacks.maximize, cbfun); return cbfun; } @@ -1069,7 +1069,7 @@ GLFWAPI GLFWframebuffersizefun glfwSetFramebufferSizeCallback(GLFWwindow* handle assert(window != NULL); _GLFW_REQUIRE_INIT_OR_RETURN(NULL); - _GLFW_SWAP_POINTERS(window->callbacks.fbsize, cbfun); + _GLFW_SWAP(GLFWframebuffersizefun, window->callbacks.fbsize, cbfun); return cbfun; } @@ -1080,7 +1080,7 @@ GLFWAPI GLFWwindowcontentscalefun glfwSetWindowContentScaleCallback(GLFWwindow* assert(window != NULL); _GLFW_REQUIRE_INIT_OR_RETURN(NULL); - _GLFW_SWAP_POINTERS(window->callbacks.scale, cbfun); + _GLFW_SWAP(GLFWwindowcontentscalefun, window->callbacks.scale, cbfun); return cbfun; } From db91507956e2e925aa2027d82d2afee83093fdbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 21 Oct 2021 21:54:50 +0200 Subject: [PATCH 059/208] Remove saving a function pointer only used once This removes the global struct member for vkEnumerateInstanceExtensionProperties, which is only used in the same function that fetches the function from the loader. The pattern is now more in line with how other single uses of Vulkan functions are structures, such as window surface creation. --- src/internal.h | 2 -- src/vulkan.c | 5 +++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/internal.h b/src/internal.h index 4d2a6805..1a38ba7e 100644 --- a/src/internal.h +++ b/src/internal.h @@ -329,7 +329,6 @@ typedef void (APIENTRY * PFN_vkVoidFunction)(void); #else typedef PFN_vkVoidFunction (APIENTRY * PFN_vkGetInstanceProcAddr)(VkInstance,const char*); typedef VkResult (APIENTRY * PFN_vkEnumerateInstanceExtensionProperties)(const char*,uint32_t*,VkExtensionProperties*); - #define vkEnumerateInstanceExtensionProperties _glfw.vk.EnumerateInstanceExtensionProperties #define vkGetInstanceProcAddr _glfw.vk.GetInstanceProcAddr #endif @@ -855,7 +854,6 @@ struct _GLFWlibrary void* handle; char* extensions[2]; #if !defined(_GLFW_VULKAN_STATIC) - PFN_vkEnumerateInstanceExtensionProperties EnumerateInstanceExtensionProperties; PFN_vkGetInstanceProcAddr GetInstanceProcAddr; #endif GLFWbool KHR_surface; diff --git a/src/vulkan.c b/src/vulkan.c index 51789249..b5ca25c0 100644 --- a/src/vulkan.c +++ b/src/vulkan.c @@ -45,6 +45,7 @@ GLFWbool _glfwInitVulkan(int mode) { VkResult err; VkExtensionProperties* ep; + PFN_vkEnumerateInstanceExtensionProperties vkEnumerateInstanceExtensionProperties; uint32_t i, count; if (_glfw.vk.available) @@ -81,9 +82,9 @@ GLFWbool _glfwInitVulkan(int mode) return GLFW_FALSE; } - _glfw.vk.EnumerateInstanceExtensionProperties = (PFN_vkEnumerateInstanceExtensionProperties) + vkEnumerateInstanceExtensionProperties = (PFN_vkEnumerateInstanceExtensionProperties) vkGetInstanceProcAddr(NULL, "vkEnumerateInstanceExtensionProperties"); - if (!_glfw.vk.EnumerateInstanceExtensionProperties) + if (!vkEnumerateInstanceExtensionProperties) { _glfwInputError(GLFW_API_UNAVAILABLE, "Vulkan: Failed to retrieve vkEnumerateInstanceExtensionProperties"); From 393eac458b749d9d4b8b9bb1bb5119705106c960 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 21 Oct 2021 23:49:03 +0200 Subject: [PATCH 060/208] Improve Vulkan guide header section --- docs/vulkan.dox | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/docs/vulkan.dox b/docs/vulkan.dox index a40f47a6..734c630b 100644 --- a/docs/vulkan.dox +++ b/docs/vulkan.dox @@ -50,7 +50,7 @@ documentation. This is explained in more detail in the @section vulkan_include Including the Vulkan header file -To include the Vulkan header, define @ref GLFW_INCLUDE_VULKAN before including +To have GLFW include the Vulkan header, define @ref GLFW_INCLUDE_VULKAN before including the GLFW header. @code @@ -66,8 +66,12 @@ your own custom Vulkan header then do this before the GLFW header. #include @endcode -Unless a Vulkan header is included, either by the GLFW header or above it, any -GLFW functions that take or return Vulkan types will not be declared. +Unless a Vulkan header is included, either by the GLFW header or above it, the following +GLFW functions will not be declared, as depend on Vulkan types. + + - @ref glfwGetInstanceProcAddress + - @ref glfwGetPhysicalDevicePresentationSupport + - @ref glfwCreateWindowSurface The `VK_USE_PLATFORM_*_KHR` macros do not need to be defined for the Vulkan part of GLFW to work. Define them only if you are using these extensions directly. From 76a5f781dbff5366271c021ee763da2a44fdcef0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 21 Oct 2021 20:45:44 +0200 Subject: [PATCH 061/208] Add glfwInitVulkanLoader This removes the GLFW_VULKAN_STATIC CMake option and the _GLFW_VULKAN_STATIC configuration macro and replaces them with the glfwInitVulkanLoader function, allowing a single library binary to provide both behaviors. This is based on the design from PR #1374 by @pmuetschard. Closes #1374 Closes #1890 --- CMakeLists.txt | 1 - CONTRIBUTORS.md | 1 + README.md | 1 + docs/compile.dox | 8 ------ docs/intro.dox | 1 + docs/news.dox | 12 +++++++++ docs/vulkan.dox | 33 +++++++++++++---------- include/GLFW/glfw3.h | 48 ++++++++++++++++++++++++++++++++++ src/CMakeLists.txt | 5 ---- src/init.c | 6 +++++ src/internal.h | 14 +++------- src/vulkan.c | 62 ++++++++++++++++++++++---------------------- 12 files changed, 124 insertions(+), 68 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5042ab9c..f5e538bf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,7 +27,6 @@ option(GLFW_BUILD_EXAMPLES "Build the GLFW example programs" ${GLFW_STANDALONE}) option(GLFW_BUILD_TESTS "Build the GLFW test programs" ${GLFW_STANDALONE}) option(GLFW_BUILD_DOCS "Build the GLFW documentation" ON) option(GLFW_INSTALL "Generate installation target" ON) -option(GLFW_VULKAN_STATIC "Assume the Vulkan loader is linked with the application" OFF) include(GNUInstallDirs) include(CMakeDependentOption) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 7e79b955..84320b17 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -128,6 +128,7 @@ video tutorials. - Jon Morton - Pierre Moulon - Martins Mozeiko + - Pascal Muetschard - Julian Møller - ndogxj - n3rdopolis diff --git a/README.md b/README.md index e6da3acd..6cfb59a5 100644 --- a/README.md +++ b/README.md @@ -131,6 +131,7 @@ information on what to include when reporting a bug. - Added `glfwInitAllocator` for setting a custom memory allocator (#544,#1628,#1947) - Added `GLFWallocator` struct and `GLFWallocatefun`, `GLFWreallocatefun` and `GLFWdeallocatefun` types (#544,#1628,#1947) + - Added `glfwInitVulkanLoader` for using a non-default Vulkan loader (#1374,#1890) - Added `GLFW_RESIZE_NWSE_CURSOR`, `GLFW_RESIZE_NESW_CURSOR`, `GLFW_RESIZE_ALL_CURSOR` and `GLFW_NOT_ALLOWED_CURSOR` cursor shapes (#427) - Added `GLFW_RESIZE_EW_CURSOR` alias for `GLFW_HRESIZE_CURSOR` (#427) diff --git a/docs/compile.dox b/docs/compile.dox index 63479516..05da99cf 100644 --- a/docs/compile.dox +++ b/docs/compile.dox @@ -273,10 +273,6 @@ __GLFW_BUILD_DOCS__ determines whether the GLFW documentation is built along with the library. This is enabled by default if [Doxygen](https://www.doxygen.nl/) is found by CMake during configuration. -@anchor GLFW_VULKAN_STATIC -__GLFW_VULKAN_STATIC__ determines whether to use the Vulkan loader linked -directly with the application. This is disabled by default. - @subsection compile_options_win32 Win32 specific CMake options @@ -383,10 +379,6 @@ attempts to detect the appropriate platform at initialization. If you are building GLFW as a shared library / dynamic library / DLL then you must also define @b _GLFW_BUILD_DLL. Otherwise, you must not define it. -If you are linking the Vulkan loader directly with your application then you -must also define @b _GLFW_VULKAN_STATIC. Otherwise, GLFW will attempt to use the -external version. - If you are using a custom name for the Vulkan, EGL, GLX, OSMesa, OpenGL, GLESv1 or GLESv2 library, you can override the default names by defining those you need of @b _GLFW_VULKAN_LIBRARY, @b _GLFW_EGL_LIBRARY, @b _GLFW_GLX_LIBRARY, @b diff --git a/docs/intro.dox b/docs/intro.dox index c50a3722..5cbd7eb0 100644 --- a/docs/intro.dox +++ b/docs/intro.dox @@ -35,6 +35,7 @@ successfully initialized, and only from the main thread. - @ref glfwSetErrorCallback - @ref glfwInitHint - @ref glfwInitAllocator + - @ref glfwInitVulkanLoader - @ref glfwInit - @ref glfwTerminate diff --git a/docs/news.dox b/docs/news.dox index 28affab0..6c55e65f 100644 --- a/docs/news.dox +++ b/docs/news.dox @@ -142,6 +142,17 @@ GLFW_TRANSPARENT_FRAMEBUFFER on Windows 7 if DWM transparency is off @subsection removals_34 Removals in 3.4 +@subsubsection vulkan_static_34 GLFW_VULKAN_STATIC CMake option has been removed + +This option was used to compile GLFW directly linked with the Vulkan loader, instead of +using dynamic loading to get hold of `vkGetInstanceProcAddr` at initialization. This is +now done by calling the @ref glfwInitVulkanLoader function before initialization. + +If you need backward compatibility, this macro can still be defined for GLFW 3.4 and will +have no effect. The call to @ref glfwInitVulkanLoader can be conditionally enabled in +your code by checking the @ref GLFW_VERSION_MAJOR and @ref GLFW_VERSION_MINOR macros. + + @subsubsection osmesa_option_34 GLFW_USE_OSMESA CMake option has been removed This option was used to compile GLFW for the Null platform. The Null platform is now @@ -168,6 +179,7 @@ then GLFW will fail to initialize. - @ref glfwInitAllocator - @ref glfwGetPlatform - @ref glfwPlatformSupported + - @ref glfwInitVulkanLoader @subsubsection types_34 New types in version 3.4 diff --git a/docs/vulkan.dox b/docs/vulkan.dox index 734c630b..31891036 100644 --- a/docs/vulkan.dox +++ b/docs/vulkan.dox @@ -29,22 +29,28 @@ are also guides for the other areas of the GLFW API. - @ref input_guide -@section vulkan_loader Linking against the Vulkan loader +@section vulkan_loader Finding the Vulkan loader -By default, GLFW will look for the Vulkan loader on demand at runtime via its -standard name (`vulkan-1.dll` on Windows, `libvulkan.so.1` on Linux and other -Unix-like systems and `libvulkan.1.dylib` on macOS). This means that GLFW does -not need to be linked against the loader. However, it also means that if you -are using the static library form of the Vulkan loader GLFW will either fail to -find it or (worse) use the wrong one. +GLFW itself does not ever need to be linked against the Vulkan loader. -The @ref GLFW_VULKAN_STATIC CMake option makes GLFW call the Vulkan loader -directly instead of dynamically loading it at runtime. Not linking against the -Vulkan loader will then be a compile-time error. +By default, GLFW will load the Vulkan loader dynamically at runtime via its standard name: +`vulkan-1.dll` on Windows, `libvulkan.so.1` on Linux and other Unix-like systems and +`libvulkan.1.dylib` on macOS. -@macos Because the Vulkan loader and ICD are not installed globally on macOS, -you need to set up the application bundle according to the LunarG SDK -documentation. This is explained in more detail in the +@macos GLFW will also look up and search the executable subdirectory of your application +bundle. + +If your code is using a Vulkan loader with a different name or in a non-standard location +you will need to direct GLFW to it. Pass your version of `vkGetInstanceProcAddr` to @ref +glfwInitVulkanLoader before initializing GLFW and it will use that function for all Vulkan +entry point retrieval. This prevents GLFW from dynamically loading the Vulkan loader. + +@code +glfwInitVulkanLoader(vkGetInstanceProcAddr); +@endcode + +@macos To make your application be redistributable you will need to set up the application +bundle according to the LunarG SDK documentation. This is explained in more detail in the [SDK documentation for macOS](https://vulkan.lunarg.com/doc/sdk/latest/mac/getting_started.html). @@ -69,6 +75,7 @@ your own custom Vulkan header then do this before the GLFW header. Unless a Vulkan header is included, either by the GLFW header or above it, the following GLFW functions will not be declared, as depend on Vulkan types. + - @ref glfwInitVulkanLoader - @ref glfwGetInstanceProcAddress - @ref glfwGetPhysicalDevicePresentationSupport - @ref glfwCreateWindowSurface diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index 17cb66c2..751615eb 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -2224,6 +2224,54 @@ GLFWAPI void glfwInitHint(int hint, int value); */ 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 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0ab57255..a0be580e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -155,11 +155,6 @@ if (CMAKE_VERSION VERSION_LESS "3.16" AND APPLE) LANGUAGE C) endif() -if (GLFW_VULKAN_STATIC) - target_compile_definitions(glfw PRIVATE _GLFW_VULKAN_STATIC) - list(APPEND glfw_PKG_DEPS "vulkan") -endif() - if (GLFW_BUILD_WIN32) list(APPEND glfw_PKG_LIBS "-lgdi32") endif() diff --git a/src/init.c b/src/init.c index 65f5de31..c4c5e030 100644 --- a/src/init.c +++ b/src/init.c @@ -55,6 +55,7 @@ static _GLFWinitconfig _glfwInitHints = GLFW_TRUE, // hat buttons GLFW_ANGLE_PLATFORM_TYPE_NONE, // ANGLE backend GLFW_ANY_PLATFORM, // preferred platform + NULL, // vkGetInstanceProcAddr function { GLFW_TRUE, // macOS menu bar GLFW_TRUE // macOS bundle chdir @@ -404,6 +405,11 @@ GLFWAPI void glfwInitAllocator(const GLFWallocator* allocator) memset(&_glfwInitAllocator, 0, sizeof(GLFWallocator)); } +GLFWAPI void glfwInitVulkanLoader(PFN_vkGetInstanceProcAddr loader) +{ + _glfwInitHints.vulkanLoader = loader; +} + GLFWAPI void glfwGetVersion(int* major, int* minor, int* rev) { if (major != NULL) diff --git a/src/internal.h b/src/internal.h index 1a38ba7e..c853ad9b 100644 --- a/src/internal.h +++ b/src/internal.h @@ -323,14 +323,9 @@ typedef struct VkExtensionProperties typedef void (APIENTRY * PFN_vkVoidFunction)(void); -#if defined(_GLFW_VULKAN_STATIC) - PFN_vkVoidFunction vkGetInstanceProcAddr(VkInstance,const char*); - VkResult vkEnumerateInstanceExtensionProperties(const char*,uint32_t*,VkExtensionProperties*); -#else - typedef PFN_vkVoidFunction (APIENTRY * PFN_vkGetInstanceProcAddr)(VkInstance,const char*); - typedef VkResult (APIENTRY * PFN_vkEnumerateInstanceExtensionProperties)(const char*,uint32_t*,VkExtensionProperties*); - #define vkGetInstanceProcAddr _glfw.vk.GetInstanceProcAddr -#endif +typedef PFN_vkVoidFunction (APIENTRY * PFN_vkGetInstanceProcAddr)(VkInstance,const char*); +typedef VkResult (APIENTRY * PFN_vkEnumerateInstanceExtensionProperties)(const char*,uint32_t*,VkExtensionProperties*); +#define vkGetInstanceProcAddr _glfw.vk.GetInstanceProcAddr #include "platform.h" @@ -382,6 +377,7 @@ struct _GLFWinitconfig GLFWbool hatButtons; int angleType; int platformID; + PFN_vkGetInstanceProcAddr vulkanLoader; struct { GLFWbool menubar; GLFWbool chdir; @@ -853,9 +849,7 @@ struct _GLFWlibrary GLFWbool available; void* handle; char* extensions[2]; -#if !defined(_GLFW_VULKAN_STATIC) PFN_vkGetInstanceProcAddr GetInstanceProcAddr; -#endif GLFWbool KHR_surface; GLFWbool KHR_win32_surface; GLFWbool MVK_macos_surface; diff --git a/src/vulkan.c b/src/vulkan.c index b5ca25c0..2a64ecb4 100644 --- a/src/vulkan.c +++ b/src/vulkan.c @@ -51,35 +51,39 @@ GLFWbool _glfwInitVulkan(int mode) if (_glfw.vk.available) return GLFW_TRUE; -#if !defined(_GLFW_VULKAN_STATIC) + if (_glfw.hints.init.vulkanLoader) + _glfw.vk.GetInstanceProcAddr = _glfw.hints.init.vulkanLoader; + else + { #if defined(_GLFW_VULKAN_LIBRARY) - _glfw.vk.handle = _glfwPlatformLoadModule(_GLFW_VULKAN_LIBRARY); + _glfw.vk.handle = _glfwPlatformLoadModule(_GLFW_VULKAN_LIBRARY); #elif defined(_GLFW_WIN32) - _glfw.vk.handle = _glfwPlatformLoadModule("vulkan-1.dll"); + _glfw.vk.handle = _glfwPlatformLoadModule("vulkan-1.dll"); #elif defined(_GLFW_COCOA) - _glfw.vk.handle = _glfwPlatformLoadModule("libvulkan.1.dylib"); - if (!_glfw.vk.handle) - _glfw.vk.handle = _glfwLoadLocalVulkanLoaderCocoa(); + _glfw.vk.handle = _glfwPlatformLoadModule("libvulkan.1.dylib"); + if (!_glfw.vk.handle) + _glfw.vk.handle = _glfwLoadLocalVulkanLoaderCocoa(); #else - _glfw.vk.handle = _glfwPlatformLoadModule("libvulkan.so.1"); + _glfw.vk.handle = _glfwPlatformLoadModule("libvulkan.so.1"); #endif - if (!_glfw.vk.handle) - { - if (mode == _GLFW_REQUIRE_LOADER) - _glfwInputError(GLFW_API_UNAVAILABLE, "Vulkan: Loader not found"); + if (!_glfw.vk.handle) + { + if (mode == _GLFW_REQUIRE_LOADER) + _glfwInputError(GLFW_API_UNAVAILABLE, "Vulkan: Loader not found"); - return GLFW_FALSE; - } + return GLFW_FALSE; + } - _glfw.vk.GetInstanceProcAddr = (PFN_vkGetInstanceProcAddr) - _glfwPlatformGetModuleSymbol(_glfw.vk.handle, "vkGetInstanceProcAddr"); - if (!_glfw.vk.GetInstanceProcAddr) - { - _glfwInputError(GLFW_API_UNAVAILABLE, - "Vulkan: Loader does not export vkGetInstanceProcAddr"); + _glfw.vk.GetInstanceProcAddr = (PFN_vkGetInstanceProcAddr) + _glfwPlatformGetModuleSymbol(_glfw.vk.handle, "vkGetInstanceProcAddr"); + if (!_glfw.vk.GetInstanceProcAddr) + { + _glfwInputError(GLFW_API_UNAVAILABLE, + "Vulkan: Loader does not export vkGetInstanceProcAddr"); - _glfwTerminateVulkan(); - return GLFW_FALSE; + _glfwTerminateVulkan(); + return GLFW_FALSE; + } } vkEnumerateInstanceExtensionProperties = (PFN_vkEnumerateInstanceExtensionProperties) @@ -92,7 +96,6 @@ GLFWbool _glfwInitVulkan(int mode) _glfwTerminateVulkan(); return GLFW_FALSE; } -#endif // _GLFW_VULKAN_STATIC err = vkEnumerateInstanceExtensionProperties(NULL, &count, NULL); if (err) @@ -152,10 +155,8 @@ GLFWbool _glfwInitVulkan(int mode) void _glfwTerminateVulkan(void) { -#if !defined(_GLFW_VULKAN_STATIC) if (_glfw.vk.handle) _glfwPlatformFreeModule(_glfw.vk.handle); -#endif } const char* _glfwGetVulkanResultString(VkResult result) @@ -253,17 +254,16 @@ GLFWAPI GLFWvkproc glfwGetInstanceProcAddress(VkInstance instance, if (!_glfwInitVulkan(_GLFW_REQUIRE_LOADER)) return NULL; + // NOTE: Vulkan 1.0 and 1.1 vkGetInstanceProcAddr cannot return itself + if (strcmp(procname, "vkGetInstanceProcAddr") == 0) + return (GLFWvkproc) vkGetInstanceProcAddr; + proc = (GLFWvkproc) vkGetInstanceProcAddr(instance, procname); -#if defined(_GLFW_VULKAN_STATIC) if (!proc) { - if (strcmp(procname, "vkGetInstanceProcAddr") == 0) - return (GLFWvkproc) vkGetInstanceProcAddr; + if (_glfw.vk.handle) + proc = (GLFWvkproc) _glfwPlatformGetModuleSymbol(_glfw.vk.handle, procname); } -#else - if (!proc) - proc = (GLFWvkproc) _glfwPlatformGetModuleSymbol(_glfw.vk.handle, procname); -#endif return proc; } From 2a78a2cf82a95e6d1f3bde0f33a6b8fb64b7be12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 25 Oct 2021 21:11:26 +0200 Subject: [PATCH 062/208] Refactor platform selection for clarity? --- src/platform.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/platform.c b/src/platform.c index 34fb7acd..a692432d 100644 --- a/src/platform.c +++ b/src/platform.c @@ -73,31 +73,34 @@ GLFWbool _glfwSelectPlatform(int desiredID, _GLFWplatform* platform) if (desiredID == GLFW_PLATFORM_NULL) return _glfwConnectNull(desiredID, platform); - // If there is only one platform available for auto-selection, let it emit the error - // on failure as the platform-specific error description may be more helpful - if (desiredID == GLFW_ANY_PLATFORM && count == 1) - return supportedPlatforms[0].connect(supportedPlatforms[0].ID, platform); - - for (i = 0; i < count; i++) + if (desiredID == GLFW_ANY_PLATFORM) { - if (desiredID == GLFW_ANY_PLATFORM || desiredID == supportedPlatforms[i].ID) + // If there is exactly one platform available for auto-selection, let it emit the + // error on failure as the platform-specific error description may be more helpful + if (count == 1) + return supportedPlatforms[0].connect(supportedPlatforms[0].ID, platform); + + for (i = 0; i < count; i++) { if (supportedPlatforms[i].connect(desiredID, platform)) return GLFW_TRUE; - else if (desiredID == supportedPlatforms[i].ID) - return GLFW_FALSE; } - } - if (desiredID == GLFW_ANY_PLATFORM) - { if (count) _glfwInputError(GLFW_PLATFORM_UNAVAILABLE, "Failed to detect any supported platform"); else _glfwInputError(GLFW_PLATFORM_UNAVAILABLE, "This binary only supports the Null platform"); } else + { + for (i = 0; i < count; i++) + { + if (supportedPlatforms[i].ID == desiredID) + return supportedPlatforms[i].connect(desiredID, platform); + } + _glfwInputError(GLFW_PLATFORM_UNAVAILABLE, "The requested platform is not supported"); + } return GLFW_FALSE; } From 575d2971d414ef9f7a47899f44664168537d26c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 25 Oct 2021 21:24:07 +0200 Subject: [PATCH 063/208] Fix glfwinfo not handling --platform=any --- tests/glfwinfo.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/glfwinfo.c b/tests/glfwinfo.c index a76ca1c2..14347e4b 100644 --- a/tests/glfwinfo.c +++ b/tests/glfwinfo.c @@ -462,7 +462,9 @@ int main(int argc, char** argv) switch (ch) { case PLATFORM: - if (strcasecmp(optarg, PLATFORM_NAME_WIN32) == 0) + if (strcasecmp(optarg, PLATFORM_NAME_ANY) == 0) + platform = GLFW_ANY_PLATFORM; + else if (strcasecmp(optarg, PLATFORM_NAME_WIN32) == 0) platform = GLFW_PLATFORM_WIN32; else if (strcasecmp(optarg, PLATFORM_NAME_COCOA) == 0) platform = GLFW_PLATFORM_COCOA; From f75c251deccde745d3d3f313aa81955095369d6f Mon Sep 17 00:00:00 2001 From: Josh Codd Date: Tue, 26 Oct 2021 00:14:30 +0100 Subject: [PATCH 064/208] Cocoa: Fix deprecation of kIOMasterPortDefault This adds a workaround for kIOMasterPortDefault having been deprecated in favor of kIOMainPortDefault in macOS 12.0. Closes #1980 --- src/cocoa_monitor.m | 4 ++-- src/cocoa_platform.h | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/cocoa_monitor.m b/src/cocoa_monitor.m index 2109a7fe..89580bfa 100644 --- a/src/cocoa_monitor.m +++ b/src/cocoa_monitor.m @@ -58,7 +58,7 @@ static char* getMonitorName(CGDirectDisplayID displayID, NSScreen* screen) io_service_t service; CFDictionaryRef info; - if (IOServiceGetMatchingServices(kIOMasterPortDefault, + if (IOServiceGetMatchingServices(kIOMainPortDefault, IOServiceMatching("IODisplayConnect"), &it) != 0) { @@ -231,7 +231,7 @@ static double getFallbackRefreshRate(CGDirectDisplayID displayID) io_iterator_t it; io_service_t service; - if (IOServiceGetMatchingServices(kIOMasterPortDefault, + if (IOServiceGetMatchingServices(kIOMainPortDefault, IOServiceMatching("IOFramebuffer"), &it) != 0) { diff --git a/src/cocoa_platform.h b/src/cocoa_platform.h index 67c1a3cc..ed4ffc12 100644 --- a/src/cocoa_platform.h +++ b/src/cocoa_platform.h @@ -41,6 +41,13 @@ typedef void* id; #endif +// NOTE: Many Cocoa enum values have been renamed and we need to build across +// SDK versions where one is unavailable or the other deprecated +// We use the newer names in code and these macros to handle compatibility +#if MAC_OS_X_VERSION_MAX_ALLOWED < 120000 + #define kIOMainPortDefault kIOMasterPortDefault +#endif + // NOTE: Many Cocoa enum values have been renamed and we need to build across // SDK versions where one is unavailable or the other deprecated // We use the newer names in code and these macros to handle compatibility From 999962bd2f7e642a8f8ad94e643e53392945caa8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 27 Oct 2021 23:14:19 +0200 Subject: [PATCH 065/208] Update changelog and add credit Related to #1980 --- CONTRIBUTORS.md | 1 + README.md | 1 + 2 files changed, 2 insertions(+) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 84320b17..0fe9c8f7 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -34,6 +34,7 @@ video tutorials. - MichaÅ‚ CichoÅ„ - Lambert Clara - Anna Clarke + - Josh Codd - Yaron Cohen-Tal - Omar Cornut - Andrew Corrigan diff --git a/README.md b/README.md index 6cfb59a5..b3c40688 100644 --- a/README.md +++ b/README.md @@ -229,6 +229,7 @@ information on what to include when reporting a bug. related events were emitted - [Cocoa] Bugfix: Moving the cursor programmatically would freeze it for a fraction of a second (#1962) + - [Cocoa] Bugfix: `kIOMasterPortDefault` was depreacted in macOS 12.0 (#1980) - [X11] Bugfix: The CMake files did not check for the XInput headers (#1480) - [X11] Bugfix: Key names were not updated when the keyboard layout changed (#1462,#1528) From 83d3fb08ec3d9048600b12bb6655973804dbb628 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 27 Oct 2021 23:58:59 +0200 Subject: [PATCH 066/208] Fix some spelling errors in changelog --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index b3c40688..a84f73ba 100644 --- a/README.md +++ b/README.md @@ -221,7 +221,7 @@ information on what to include when reporting a bug. could leak memory - [Cocoa] Bugfix: Objective-C files were compiled as C with CMake 3.19 (#1787) - [Cocoa] Bugfix: Duplicate video modes were not filtered out (#1830) - - [Cocoa] Bugfix: Menubar was not clickable on macOS 10.15+ until it lost and + - [Cocoa] Bugfix: Menu bar was not clickable on macOS 10.15+ until it lost and regained focus (#1648,#1802) - [Cocoa] Bugfix: Monitor name query could segfault on macOS 11 (#1809,#1833) - [Cocoa] Bugfix: The install name of the installed dylib was relative (#1504) @@ -229,7 +229,7 @@ information on what to include when reporting a bug. related events were emitted - [Cocoa] Bugfix: Moving the cursor programmatically would freeze it for a fraction of a second (#1962) - - [Cocoa] Bugfix: `kIOMasterPortDefault` was depreacted in macOS 12.0 (#1980) + - [Cocoa] Bugfix: `kIOMasterPortDefault` was deprecated in macOS 12.0 (#1980) - [X11] Bugfix: The CMake files did not check for the XInput headers (#1480) - [X11] Bugfix: Key names were not updated when the keyboard layout changed (#1462,#1528) @@ -252,7 +252,7 @@ information on what to include when reporting a bug. - [X11] Bugfix: XKB path used keysyms instead of physical locations for non-printable keys (#1598) - [X11] Bugfix: Function keys were mapped to `GLFW_KEY_UNKNOWN` for some layout - combinaitons (#1598) + combinations (#1598) - [X11] Bugfix: Keys pressed simultaneously with others were not always reported (#1112,#1415,#1472,#1616) - [X11] Bugfix: Some window attributes were not applied on leaving fullscreen @@ -266,7 +266,7 @@ information on what to include when reporting a bug. - [Wayland] Bugfix: Retrieving partial framebuffer size would segfault - [Wayland] Bugfix: Scrolling offsets were inverted compared to other platforms (#1463) - - [Wayland] Bugfix: Client-Side Decorations were destroyed in the wrong worder + - [Wayland] Bugfix: Client-Side Decorations were destroyed in the wrong order (#1798) - [Wayland] Bugfix: Monitors physical size could report zero (#1784,#1792) - [Wayland] Bugfix: Some keys were not repeating in Wayland (#1908) From fb0f2f92a38c1d6a776ffeb253329f8d1c65694c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 28 Oct 2021 11:48:34 +0200 Subject: [PATCH 067/208] Add missing changelog entries --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index a84f73ba..d9257e58 100644 --- a/README.md +++ b/README.md @@ -156,6 +156,7 @@ information on what to include when reporting a bug. - Made joystick subsystem initialize at first use (#1284,#1646) - Made `GLFW_DOUBLEBUFFER` a read-only window attribute - Updated the minimum required CMake version to 3.1 + - Updated gamepad mappings from upstream - Disabled tests and examples by default when built as a CMake subdirectory - Renamed `GLFW_USE_WAYLAND` CMake option to `GLFW_BUILD_WAYLAND` (#1958) - Removed `GLFW_USE_OSMESA` CMake option enabling the Null platform (#1958) @@ -271,6 +272,7 @@ information on what to include when reporting a bug. - [Wayland] Bugfix: Monitors physical size could report zero (#1784,#1792) - [Wayland] Bugfix: Some keys were not repeating in Wayland (#1908) - [Wayland] Bugfix: Non-arrow cursors are offset from the hotspot (#1706,#1899) + - [Wayland] Bugfix: The `O_CLOEXEC` flag was not defined on FreeBSD - [POSIX] Removed use of deprecated function `gettimeofday` - [POSIX] Bugfix: `CLOCK_MONOTONIC` was not correctly tested for or enabled - [WGL] Disabled the DWM swap interval hack for Windows 8 and later (#1072) From 544790666bb2a9a2dcd3ee6dc8c45716207e65d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Ekstr=C3=B6m?= Date: Thu, 18 Nov 2021 22:59:52 +0200 Subject: [PATCH 068/208] Cocoa: Use MACH_PORT_NULL for default IOKit port Looking into the definition of kIOMainPortDefault, the following description can be found: When specifying a main port to IOKit functions, the NULL argument indicates "use the default". This is a synonym for NULL, if you'd rather use a named constant. Thus, we do not have to utilize an external symbol for the identifier of the default main IOKit port, but MACH_PORT_NULL suffice. This simplifies compatibility between macOS versions as the symbol was renamed with macOS 12.0. Fixes #1985 Closes #1994 --- src/cocoa_monitor.m | 4 ++-- src/cocoa_platform.h | 7 ------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/src/cocoa_monitor.m b/src/cocoa_monitor.m index 89580bfa..70c75aa3 100644 --- a/src/cocoa_monitor.m +++ b/src/cocoa_monitor.m @@ -58,7 +58,7 @@ static char* getMonitorName(CGDirectDisplayID displayID, NSScreen* screen) io_service_t service; CFDictionaryRef info; - if (IOServiceGetMatchingServices(kIOMainPortDefault, + if (IOServiceGetMatchingServices(MACH_PORT_NULL, IOServiceMatching("IODisplayConnect"), &it) != 0) { @@ -231,7 +231,7 @@ static double getFallbackRefreshRate(CGDirectDisplayID displayID) io_iterator_t it; io_service_t service; - if (IOServiceGetMatchingServices(kIOMainPortDefault, + if (IOServiceGetMatchingServices(MACH_PORT_NULL, IOServiceMatching("IOFramebuffer"), &it) != 0) { diff --git a/src/cocoa_platform.h b/src/cocoa_platform.h index ed4ffc12..67c1a3cc 100644 --- a/src/cocoa_platform.h +++ b/src/cocoa_platform.h @@ -41,13 +41,6 @@ typedef void* id; #endif -// NOTE: Many Cocoa enum values have been renamed and we need to build across -// SDK versions where one is unavailable or the other deprecated -// We use the newer names in code and these macros to handle compatibility -#if MAC_OS_X_VERSION_MAX_ALLOWED < 120000 - #define kIOMainPortDefault kIOMasterPortDefault -#endif - // NOTE: Many Cocoa enum values have been renamed and we need to build across // SDK versions where one is unavailable or the other deprecated // We use the newer names in code and these macros to handle compatibility From b55a517ae0c7b5127dffa79a64f5406021bf9076 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 22 Nov 2021 21:32:34 +0100 Subject: [PATCH 069/208] Add credit Related to #1994 --- CONTRIBUTORS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 0fe9c8f7..4190b261 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -53,6 +53,7 @@ video tutorials. - Ralph Eastwood - Fredrik Ehnbom - Robin Eklind + - Jan Ekström - Siavash Eliasi - Ahmad Fatoum - Felipe Ferreira From bb193325cc4e5af7d4e715072a242c1d3cfce26e Mon Sep 17 00:00:00 2001 From: InKryption <59504965+InKryption@users.noreply.github.com> Date: Mon, 22 Nov 2021 23:32:29 +0000 Subject: [PATCH 070/208] Add missing error to glfwGetClipboardString docs Add GLFW_FORMAT_UNAVAILABLE to the list of possible errors in the reference documentation for glfwGetClipboardString. Slightly edited by @elmindreda. Closes #1998 --- include/GLFW/glfw3.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index 751615eb..a1fa6f35 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -5792,8 +5792,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 From a30cd6acef49a4527546fe15d490b705df959c45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 25 Nov 2021 01:22:46 +0100 Subject: [PATCH 071/208] Add credit Related to #1998 --- CONTRIBUTORS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 4190b261..d309e435 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -77,6 +77,7 @@ video tutorials. - Paul Holden - Warren Hu - Charles Huber + - InKryption - IntellectualKitty - Aaron Jacobs - Erik S. V. Jansson From eacc1cafba90fa7b52302841dd47f5f8b1bf777a Mon Sep 17 00:00:00 2001 From: luz paz Date: Thu, 28 Oct 2021 14:35:09 -0400 Subject: [PATCH 072/208] Fix source comment typo Closes #1982 --- examples/splitview.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/splitview.c b/examples/splitview.c index 4f0a8a98..990df12c 100644 --- a/examples/splitview.c +++ b/examples/splitview.c @@ -2,7 +2,7 @@ // This is an example program for the GLFW library // // The program uses a "split window" view, rendering four views of the -// same scene in one window (e.g. uesful for 3D modelling software). This +// same scene in one window (e.g. useful for 3D modelling software). This // demo uses scissors to separate the four different rendering areas from // each other. // From b3a98f855568b1a4f3961cfa30cb7a201fb91a40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 9 Nov 2021 19:40:36 +0100 Subject: [PATCH 073/208] Update comments for global mutable data --- src/init.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/init.c b/src/init.c index c4c5e030..b5c5da9c 100644 --- a/src/init.c +++ b/src/init.c @@ -36,16 +36,15 @@ #include -// The global variables below comprise all mutable global data in GLFW -// -// Any other global variable is a bug +// NOTE: The global variables below comprise all mutable global data in GLFW +// Any other mutable global variable is a bug -// Global state shared between compilation units of GLFW +// This contains all mutable state shared between compilation units of GLFW // _GLFWlibrary _glfw = { GLFW_FALSE }; // These are outside of _glfw so they can be used before initialization and -// after termination +// after termination without special handling when _glfw is cleared to zero // static _GLFWerror _glfwMainThreadError; static GLFWerrorfun _glfwErrorCallback; From 706d1f16535747e7889df26f3d639e9212e9ad5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 16 Nov 2021 01:51:27 +0100 Subject: [PATCH 074/208] Gather Null specific platform selection logic The more specific error description is now used whatever the desired platform is, when a binary only supports the Null platform. --- src/platform.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/platform.c b/src/platform.c index a692432d..d0bbd06d 100644 --- a/src/platform.c +++ b/src/platform.c @@ -72,6 +72,11 @@ GLFWbool _glfwSelectPlatform(int desiredID, _GLFWplatform* platform) // Only allow the Null platform if specifically requested if (desiredID == GLFW_PLATFORM_NULL) return _glfwConnectNull(desiredID, platform); + else if (count == 0) + { + _glfwInputError(GLFW_PLATFORM_UNAVAILABLE, "This binary only supports the Null platform"); + return GLFW_FALSE; + } if (desiredID == GLFW_ANY_PLATFORM) { @@ -86,10 +91,7 @@ GLFWbool _glfwSelectPlatform(int desiredID, _GLFWplatform* platform) return GLFW_TRUE; } - if (count) - _glfwInputError(GLFW_PLATFORM_UNAVAILABLE, "Failed to detect any supported platform"); - else - _glfwInputError(GLFW_PLATFORM_UNAVAILABLE, "This binary only supports the Null platform"); + _glfwInputError(GLFW_PLATFORM_UNAVAILABLE, "Failed to detect any supported platform"); } else { From 37fc28bff6cad7164aa67e828e9317596f8080da Mon Sep 17 00:00:00 2001 From: Stephen Gutekanst Date: Mon, 15 Nov 2021 15:50:37 -0700 Subject: [PATCH 075/208] Fix docs calling GLFW_CONTEXT_REVISION a hint This docstring previously indicated that GLFW_CONTEXT_REVISION was a window hint and attribute, but in fact it is only a window attribute (there is no code which uses this constant in any other context.) We noticed this in https://github.com/hexops/mach/pull/71/files#r749741814 Closes #1992 Signed-off-by: Stephen Gutekanst --- include/GLFW/glfw3.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index a1fa6f35..d76f5c49 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -1028,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). From 9cd4d2fa204fc9fb884b9bb9096cedb7f1484cf7 Mon Sep 17 00:00:00 2001 From: Stephen Gutekanst Date: Sun, 31 Oct 2021 11:22:40 -0700 Subject: [PATCH 076/208] X11: Fix undefined behavior in glfwSetWindowIcon The conversion of window icon image data involves unsigned char color values being promoted to int and then shifted to the left by 24. For 32-bit ints this is just far enough to trigger undefined behavior. It worked by accident because of how current compilers translate this piece of code. This was caught by @slimsag while working on [Zig bindings for GLFW][1], and diagnosed together with @Andoryuuta, as described [in an article][2]. Zig has UBSan enabled by default, which caught this undefined behavior. [1]: https://github.com/hexops/mach-glfw [2]: https://devlog.hexops.com/2021/perfecting-glfw-for-zig-and-finding-undefined-behavior#finding-lurking-undefined-behavior-in-6-year-old-glfw-code Thanks to Maato, martinhath, dcousens, drfuchs and Validark for helping to refine the solution. This commit message was rewritten by @elmindreda to hopefully reflect the conclusions of the pull request thread. Related to hexops/mach#20 Closes #1986 --- src/x11_window.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/x11_window.c b/src/x11_window.c index 616f9fd8..ea775cd4 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -2105,8 +2105,8 @@ void _glfwSetWindowIconX11(_GLFWwindow* window, int count, const GLFWimage* imag for (int i = 0; i < count; i++) longCount += 2 + images[i].width * images[i].height; - long* icon = _glfw_calloc(longCount, sizeof(long)); - long* target = icon; + unsigned long* icon = _glfw_calloc(longCount, sizeof(unsigned long)); + unsigned long* target = icon; for (int i = 0; i < count; i++) { @@ -2115,13 +2115,20 @@ void _glfwSetWindowIconX11(_GLFWwindow* window, int count, const GLFWimage* imag for (int j = 0; j < images[i].width * images[i].height; j++) { - *target++ = (images[i].pixels[j * 4 + 0] << 16) | - (images[i].pixels[j * 4 + 1] << 8) | - (images[i].pixels[j * 4 + 2] << 0) | - (images[i].pixels[j * 4 + 3] << 24); + *target++ = (((unsigned long)images[i].pixels[j * 4 + 0]) << 16) | + (((unsigned long)images[i].pixels[j * 4 + 1]) << 8) | + (((unsigned long)images[i].pixels[j * 4 + 2]) << 0) | + (((unsigned long)images[i].pixels[j * 4 + 3]) << 24); } } + // Important: Despite XChangeProperty docs indicating that `icon` (unsigned char*) would be + // in the format of the icon image, e.g. 32-bit below, the function actually casts the ptr + // (unsigned char*) internally to (long*) and then if long is defined as 64-bits, as on IL64 + // platforms, extracts only 32 bits from the long leaving the other 32 unused. That is, on a + // 64-bit platform XChangeProperty expects 64-bit integers representing 32-bit pixels. + // + // See https://github.com/glfw/glfw/pull/1986#issuecomment-962445299 XChangeProperty(_glfw.x11.display, window->x11.handle, _glfw.x11.NET_WM_ICON, XA_CARDINAL, 32, From e40fa3bb94a9277d7190ec49e197de663eb943bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 2 Nov 2021 23:15:05 +0100 Subject: [PATCH 077/208] Add credits and update changelog --- CONTRIBUTORS.md | 2 ++ README.md | 2 ++ 2 files changed, 4 insertions(+) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index d309e435..959b55eb 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -68,6 +68,8 @@ video tutorials. - Kovid Goyal - Eloi Marín Gratacós - Stefan Gustavson + - Andrew Gutekanst + - Stephen Gutekanst - Jonathan Hale - hdf89shfdfs - Sylvain Hellegouarch diff --git a/README.md b/README.md index d9257e58..b13739f1 100644 --- a/README.md +++ b/README.md @@ -259,6 +259,8 @@ information on what to include when reporting a bug. - [X11] Bugfix: Some window attributes were not applied on leaving fullscreen (#1863) - [X11] Bugfix: Changing `GLFW_FLOATING` could leak memory + - [X11] Bugfix: Icon pixel format conversion worked only by accident, relying on + undefined behavior (#1986) - [Wayland] Added dynamic loading of all Wayland libraries - [Wayland] Removed support for `wl_shell` (#1443) - [Wayland] Bugfix: The `GLFW_HAND_CURSOR` shape used the wrong image (#1432) From 79de08db06d358c4aae243532d2e530e62780687 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 30 Nov 2021 20:34:47 +0100 Subject: [PATCH 078/208] Cleanup --- src/x11_window.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/x11_window.c b/src/x11_window.c index ea775cd4..a5255215 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -2115,20 +2115,19 @@ void _glfwSetWindowIconX11(_GLFWwindow* window, int count, const GLFWimage* imag for (int j = 0; j < images[i].width * images[i].height; j++) { - *target++ = (((unsigned long)images[i].pixels[j * 4 + 0]) << 16) | - (((unsigned long)images[i].pixels[j * 4 + 1]) << 8) | - (((unsigned long)images[i].pixels[j * 4 + 2]) << 0) | - (((unsigned long)images[i].pixels[j * 4 + 3]) << 24); + *target++ = (((unsigned long) images[i].pixels[j * 4 + 0]) << 16) | + (((unsigned long) images[i].pixels[j * 4 + 1]) << 8) | + (((unsigned long) images[i].pixels[j * 4 + 2]) << 0) | + (((unsigned long) images[i].pixels[j * 4 + 3]) << 24); } } - // Important: Despite XChangeProperty docs indicating that `icon` (unsigned char*) would be - // in the format of the icon image, e.g. 32-bit below, the function actually casts the ptr - // (unsigned char*) internally to (long*) and then if long is defined as 64-bits, as on IL64 - // platforms, extracts only 32 bits from the long leaving the other 32 unused. That is, on a - // 64-bit platform XChangeProperty expects 64-bit integers representing 32-bit pixels. - // - // See https://github.com/glfw/glfw/pull/1986#issuecomment-962445299 + // NOTE: XChangeProperty expects 32-bit values like the image data above to be + // placed in the 32 least significant bits of individual longs. This is + // true even if long is 64-bit and a WM protocol calls for "packed" data. + // This is because of a historical mistake that then became part of the Xlib + // ABI. Xlib will pack these values into a regular array of 32-bit values + // before sending it over the wire. XChangeProperty(_glfw.x11.display, window->x11.handle, _glfw.x11.NET_WM_ICON, XA_CARDINAL, 32, From d1efa3298345a36a969f1fbbb2272d97ad5354af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 30 Nov 2021 21:14:44 +0100 Subject: [PATCH 079/208] Formatting --- src/win32_window.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/win32_window.c b/src/win32_window.c index ae7710a2..9fb0baa1 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -1645,8 +1645,7 @@ void _glfwGetWindowFrameSizeWin32(_GLFWwindow* window, *bottom = rect.bottom - height; } -void _glfwGetWindowContentScaleWin32(_GLFWwindow* window, - float* xscale, float* yscale) +void _glfwGetWindowContentScaleWin32(_GLFWwindow* window, float* xscale, float* yscale) { const HANDLE handle = MonitorFromWindow(window->win32.handle, MONITOR_DEFAULTTONEAREST); From fbfd7e65c842c7909b11747f0641364593304f1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 1 Dec 2021 17:55:16 +0100 Subject: [PATCH 080/208] Win32: Fix bad content scale on monitor disconnect The monitor handle could have become invalid just before the call to GetDpiForMonitor. It was possible for both window and monitor content scale queries. This ensures both that an appropriate error is emitted and that the retrieved values are zero on error. Fixes #1615 --- CONTRIBUTORS.md | 1 + README.md | 3 +++ src/win32_monitor.c | 13 ++++++++++++- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 959b55eb..d86fe473 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -62,6 +62,7 @@ video tutorials. - Mário Freitas - GeO4d - Marcus Geelnard + - ghuser404 - Charles Giessen - Ryan C. Gordon - Stephen Gowen diff --git a/README.md b/README.md index b13739f1..e3f7d9e7 100644 --- a/README.md +++ b/README.md @@ -202,6 +202,9 @@ information on what to include when reporting a bug. later (#1783,#1796) - [Win32] Bugfix: Compilation with LLVM for Windows failed (#1807,#1824,#1874) - [Win32] Bugfix: The foreground lock timeout was overridden, ignoring the user + - [Win32] Bugfix: Content scale queries could fail silently (#1615) + - [Win32] Bugfix: Content scales could have garbage values if monitor was recently + disconnected (#1615) - [Cocoa] Added support for `VK_EXT_metal_surface` (#1619) - [Cocoa] Added locating the Vulkan loader at runtime in an application bundle - [Cocoa] Moved main menu creation to GLFW initialization time (#1649) diff --git a/src/win32_monitor.c b/src/win32_monitor.c index 17359a5f..cdee49a9 100644 --- a/src/win32_monitor.c +++ b/src/win32_monitor.c @@ -317,8 +317,19 @@ void _glfwGetHMONITORContentScaleWin32(HMONITOR handle, float* xscale, float* ys { UINT xdpi, ydpi; + if (xscale) + *xscale = 0.f; + if (yscale) + *yscale = 0.f; + if (IsWindows8Point1OrGreater()) - GetDpiForMonitor(handle, MDT_EFFECTIVE_DPI, &xdpi, &ydpi); + { + if (GetDpiForMonitor(handle, MDT_EFFECTIVE_DPI, &xdpi, &ydpi) != S_OK) + { + _glfwInputError(GLFW_PLATFORM_ERROR, "Win32: Failed to query monitor DPI"); + return; + } + } else { const HDC dc = GetDC(NULL); From 53d86c64d709ff52886580d338d9b3b2b1f27266 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 1 Dec 2021 18:09:56 +0100 Subject: [PATCH 081/208] Win32: Handle content scale error on creation Only apply the content scale to the initial size of the window if content scale retrieval succeeded. Related to #1615. --- src/win32_window.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/win32_window.c b/src/win32_window.c index 9fb0baa1..e03b8564 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -1304,8 +1304,12 @@ static int createNativeWindow(_GLFWwindow* window, { float xscale, yscale; _glfwGetWindowContentScaleWin32(window, &xscale, &yscale); - rect.right = (int) (rect.right * xscale); - rect.bottom = (int) (rect.bottom * yscale); + + if (xscale > 0.f && yscale > 0.f) + { + rect.right = (int) (rect.right * xscale); + rect.bottom = (int) (rect.bottom * yscale); + } } ClientToScreen(window->win32.handle, (POINT*) &rect.left); From c19f36b28d255d280d39446f09f36f441318138e Mon Sep 17 00:00:00 2001 From: InKryption <59504965+InKryption@users.noreply.github.com> Date: Sun, 5 Dec 2021 17:51:43 +0100 Subject: [PATCH 082/208] Add missing errors section for glfwGetGamepadName The reference documentation for glfwGetGamepadName lacked the possible errors section. Closes #2007 --- include/GLFW/glfw3.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index d76f5c49..f0b8d5ec 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -5703,6 +5703,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. From cd01187b9d4145a3947f806f113bc777c3aa4c1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 8 Dec 2021 23:09:59 +0100 Subject: [PATCH 083/208] Fix initial windowed mode size for test --- tests/iconify.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/iconify.c b/tests/iconify.c index e5a428a0..32fd44f2 100644 --- a/tests/iconify.c +++ b/tests/iconify.c @@ -38,7 +38,7 @@ #include "getopt.h" -static int windowed_xpos, windowed_ypos, windowed_width, windowed_height; +static int windowed_xpos, windowed_ypos, windowed_width = 640, windowed_height = 480; static void usage(void) { @@ -181,8 +181,8 @@ static GLFWwindow* create_window(GLFWmonitor* monitor) } else { - width = 640; - height = 480; + width = windowed_width; + height = windowed_height; } window = glfwCreateWindow(width, height, "Iconify", monitor, NULL); From 900848ad0ce0c94a5d4cb8e0ac2489ff11973477 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 9 Dec 2021 19:35:15 +0100 Subject: [PATCH 084/208] X11: Add extension header paths to CMake target The way the X11 find module is written, these paths can differ from the base X11 header path, even if they very rarely do. Fixes #1999 --- src/CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a0be580e..16cb1749 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -194,31 +194,37 @@ if (GLFW_BUILD_X11) if (NOT X11_Xrandr_INCLUDE_PATH) message(FATAL_ERROR "RandR headers not found; install libxrandr development package") endif() + target_include_directories(glfw PRIVATE "${X11_Xrandr_INCLUDE_PATH}") # Check for Xinerama (legacy multi-monitor support) if (NOT X11_Xinerama_INCLUDE_PATH) message(FATAL_ERROR "Xinerama headers not found; install libxinerama development package") endif() + target_include_directories(glfw PRIVATE "${X11_Xinerama_INCLUDE_PATH}") # Check for Xkb (X keyboard extension) if (NOT X11_Xkb_INCLUDE_PATH) message(FATAL_ERROR "XKB headers not found; install X11 development package") endif() + target_include_directories(glfw PRIVATE "${X11_Xkb_INCLUDE_PATH}") # Check for Xcursor (cursor creation from RGBA images) if (NOT X11_Xcursor_INCLUDE_PATH) message(FATAL_ERROR "Xcursor headers not found; install libxcursor development package") endif() + target_include_directories(glfw PRIVATE "${X11_Xcursor_INCLUDE_PATH}") # Check for XInput (modern HID input) if (NOT X11_Xi_INCLUDE_PATH) message(FATAL_ERROR "XInput headers not found; install libxi development package") endif() + target_include_directories(glfw PRIVATE "${X11_Xi_INCLUDE_PATH}") # Check for X Shape (custom window input shape) if (NOT X11_Xshape_INCLUDE_PATH) message(FATAL_ERROR "X Shape headers not found; install libxext development package") endif() + target_include_directories(glfw PRIVATE "${X11_Xshape_INCLUDE_PATH}") endif() if (UNIX AND NOT APPLE) From 963e728881d7551aab0b843c79915f2419d4d36e Mon Sep 17 00:00:00 2001 From: Stone Tickle Date: Fri, 5 Jun 2020 12:51:25 +0900 Subject: [PATCH 085/208] Wayland: Set O_NONBLOCK on repeat timerfd Fixes #1710 Fixes #1711 --- src/wl_init.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wl_init.c b/src/wl_init.c index acfe477d..bba908fa 100644 --- a/src/wl_init.c +++ b/src/wl_init.c @@ -1336,7 +1336,7 @@ int _glfwInitWayland(void) _glfw.wl.timerfd = -1; if (_glfw.wl.seatVersion >= 4) - _glfw.wl.timerfd = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC); + _glfw.wl.timerfd = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC | TFD_NONBLOCK); if (!_glfw.wl.wmBase) { @@ -1370,7 +1370,7 @@ int _glfwInitWayland(void) wl_cursor_theme_load(cursorTheme, 2 * cursorSize, _glfw.wl.shm); _glfw.wl.cursorSurface = wl_compositor_create_surface(_glfw.wl.compositor); - _glfw.wl.cursorTimerfd = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC); + _glfw.wl.cursorTimerfd = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC | TFD_NONBLOCK); } if (_glfw.wl.seat && _glfw.wl.dataDeviceManager) From 68879081cb39f50bd65d12e0f1869f5970dc71b9 Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Tue, 14 Dec 2021 09:29:01 +0100 Subject: [PATCH 086/208] =?UTF-8?q?Wayland:=20Continue=20poll()=20if=20tim?= =?UTF-8?q?erfd=20can=E2=80=99t=20be=20read?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In the case the key repeat timerfd was interrupted before read(), the cursor timerfd wasn’t read at all even when it could. Related to #1711 --- README.md | 1 + src/wl_window.c | 11 +++-------- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index e3f7d9e7..57c43a4b 100644 --- a/README.md +++ b/README.md @@ -278,6 +278,7 @@ information on what to include when reporting a bug. - [Wayland] Bugfix: Some keys were not repeating in Wayland (#1908) - [Wayland] Bugfix: Non-arrow cursors are offset from the hotspot (#1706,#1899) - [Wayland] Bugfix: The `O_CLOEXEC` flag was not defined on FreeBSD + - [Wayland] Bugfix: Key repeat could lead to a race condition (#1710) - [POSIX] Removed use of deprecated function `gettimeofday` - [POSIX] Bugfix: `CLOCK_MONOTONIC` was not correctly tested for or enabled - [WGL] Disabled the DWM swap interval hack for Windows 8 and later (#1072) diff --git a/src/wl_window.c b/src/wl_window.c index b4c59d69..8ed803b4 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -751,10 +751,7 @@ static void handleEvents(int timeout) if (fds[1].revents & POLLIN) { read_ret = read(_glfw.wl.timerfd, &repeats, sizeof(repeats)); - if (read_ret != 8) - return; - - if (_glfw.wl.keyboardFocus) + if (read_ret == 8 && _glfw.wl.keyboardFocus) { for (uint64_t i = 0; i < repeats; ++i) { @@ -770,10 +767,8 @@ static void handleEvents(int timeout) if (fds[2].revents & POLLIN) { read_ret = read(_glfw.wl.cursorTimerfd, &repeats, sizeof(repeats)); - if (read_ret != 8) - return; - - incrementCursorImage(_glfw.wl.pointerFocus); + if (read_ret == 8) + incrementCursorImage(_glfw.wl.pointerFocus); } } else From 6281f498c875f49d8ac5c5a02d968fb1792fd9f5 Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Tue, 14 Dec 2021 18:35:30 +0100 Subject: [PATCH 087/208] EGL: Use EGL_EXT_present_opaque when available This extensions allows GLFW to instruct the driver to ignore the alpha bits, even in formats which contain them. This makes it possible to use the alpha bits as extra storage, without it affecting the end result getting displayed to the user. Fixes #1434 Fixes #1803 --- src/egl_context.c | 5 +++++ src/internal.h | 2 ++ 2 files changed, 7 insertions(+) diff --git a/src/egl_context.c b/src/egl_context.c index 03c72d04..edb2fae2 100644 --- a/src/egl_context.c +++ b/src/egl_context.c @@ -472,6 +472,8 @@ GLFWbool _glfwInitEGL(void) extensionSupportedEGL("EGL_KHR_get_all_proc_addresses"); _glfw.egl.KHR_context_flush_control = extensionSupportedEGL("EGL_KHR_context_flush_control"); + _glfw.egl.EXT_present_opaque = + extensionSupportedEGL("EGL_EXT_present_opaque"); return GLFW_TRUE; } @@ -646,6 +648,9 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window, if (!fbconfig->doublebuffer) setAttrib(EGL_RENDER_BUFFER, EGL_SINGLE_BUFFER); + if (_glfw.egl.EXT_present_opaque) + setAttrib(EGL_PRESENT_OPAQUE_EXT, !fbconfig->transparent); + setAttrib(EGL_NONE, EGL_NONE); native = _glfw.platform.getEGLNativeWindow(window); diff --git a/src/internal.h b/src/internal.h index c853ad9b..2a8c8d6d 100644 --- a/src/internal.h +++ b/src/internal.h @@ -177,6 +177,7 @@ typedef const GLubyte* (APIENTRY * PFNGLGETSTRINGIPROC)(GLenum,GLuint); #define EGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_KHR 0x2098 #define EGL_PLATFORM_X11_EXT 0x31d5 #define EGL_PLATFORM_WAYLAND_EXT 0x31d8 +#define EGL_PRESENT_OPAQUE_EXT 0x31df #define EGL_PLATFORM_ANGLE_ANGLE 0x3202 #define EGL_PLATFORM_ANGLE_TYPE_ANGLE 0x3203 #define EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE 0x320d @@ -803,6 +804,7 @@ struct _GLFWlibrary GLFWbool EXT_platform_base; GLFWbool EXT_platform_x11; GLFWbool EXT_platform_wayland; + GLFWbool EXT_present_opaque; GLFWbool ANGLE_platform_angle; GLFWbool ANGLE_platform_angle_opengl; GLFWbool ANGLE_platform_angle_d3d; From c2f0a0ae5990a23d84c3f4529771b1268a34f918 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 22 Dec 2021 14:16:19 +0100 Subject: [PATCH 088/208] Wayland: Fix duplicate focus event on activation --- README.md | 1 + src/wl_window.c | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 57c43a4b..4a0faf35 100644 --- a/README.md +++ b/README.md @@ -279,6 +279,7 @@ information on what to include when reporting a bug. - [Wayland] Bugfix: Non-arrow cursors are offset from the hotspot (#1706,#1899) - [Wayland] Bugfix: The `O_CLOEXEC` flag was not defined on FreeBSD - [Wayland] Bugfix: Key repeat could lead to a race condition (#1710) + - [Wayland] Bugfix: Activating a window would emit two input focus events - [POSIX] Removed use of deprecated function `gettimeofday` - [POSIX] Bugfix: `CLOCK_MONOTONIC` was not correctly tested for or enabled - [WGL] Disabled the DWM swap interval hack for Windows 8 and later (#1072) diff --git a/src/wl_window.c b/src/wl_window.c index 8ed803b4..12af2701 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -537,7 +537,6 @@ static void xdgToplevelHandleConfigure(void* data, } if (fullscreen && activated) window->wl.wasFullscreen = GLFW_TRUE; - _glfwInputWindowFocus(window, activated); } static void xdgToplevelHandleClose(void* data, From e24fe4b189d2cf99e0374992e7fc6650f4c6cf01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 22 Dec 2021 14:19:55 +0100 Subject: [PATCH 089/208] Wayland: Fix key repeat continuing when refocused If a window lost input focus while a key was held down, the key repeat mechanism would resume once the window regained focus. --- README.md | 1 + src/wl_init.c | 3 +++ 2 files changed, 4 insertions(+) diff --git a/README.md b/README.md index 4a0faf35..2f505c00 100644 --- a/README.md +++ b/README.md @@ -280,6 +280,7 @@ information on what to include when reporting a bug. - [Wayland] Bugfix: The `O_CLOEXEC` flag was not defined on FreeBSD - [Wayland] Bugfix: Key repeat could lead to a race condition (#1710) - [Wayland] Bugfix: Activating a window would emit two input focus events + - [Wayland] Bugfix: Disable key repeat mechanism when window loses input focus - [POSIX] Removed use of deprecated function `gettimeofday` - [POSIX] Bugfix: `CLOCK_MONOTONIC` was not correctly tested for or enabled - [WGL] Disabled the DWM swap interval hack for Windows 8 and later (#1072) diff --git a/src/wl_init.c b/src/wl_init.c index bba908fa..fd6efaa8 100644 --- a/src/wl_init.c +++ b/src/wl_init.c @@ -508,6 +508,9 @@ static void keyboardHandleLeave(void* data, _glfw.wl.serial = serial; _glfw.wl.keyboardFocus = NULL; _glfwInputWindowFocus(window, GLFW_FALSE); + + struct itimerspec timer = {}; + timerfd_settime(_glfw.wl.timerfd, 0, &timer, NULL); } static int toGLFWKeyCode(uint32_t key) From 094aa6d3c721397825cb1095c156353463ecafb5 Mon Sep 17 00:00:00 2001 From: Jason Francis Date: Sun, 12 Jul 2020 20:47:50 -0400 Subject: [PATCH 090/208] Wayland: Fix window hiding Corrects the protocol violation when creating an xdg_surface from a wl_surface that already has a buffer due to EGL buffer swaps. This commit is based on PR #1731 by @ghost, but adapted and altered: - The XDG surface and role are now only created when a window is shown to prevent application lists from showing command-line applications with off-screen-only windows - The special case of Wayland+EGL buffer swap is now in the EGL code to mirror how X11 is handled - Adaption to run-time platform selection and separate credits file Fixes #1492 Closes #1731 --- CONTRIBUTORS.md | 1 + README.md | 1 + src/egl_context.c | 9 +++++++++ src/wl_window.c | 30 +++++++++--------------------- 4 files changed, 20 insertions(+), 21 deletions(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index d86fe473..1bfc5bc5 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -58,6 +58,7 @@ video tutorials. - Ahmad Fatoum - Felipe Ferreira - Michael Fogleman + - Jason Francis - Gerald Franz - Mário Freitas - GeO4d diff --git a/README.md b/README.md index 2f505c00..63e9f6bd 100644 --- a/README.md +++ b/README.md @@ -281,6 +281,7 @@ information on what to include when reporting a bug. - [Wayland] Bugfix: Key repeat could lead to a race condition (#1710) - [Wayland] Bugfix: Activating a window would emit two input focus events - [Wayland] Bugfix: Disable key repeat mechanism when window loses input focus + - [Wayland] Bugfix: Window hiding and showing did not work (#1492,#1731) - [POSIX] Removed use of deprecated function `gettimeofday` - [POSIX] Bugfix: `CLOCK_MONOTONIC` was not correctly tested for or enabled - [WGL] Disabled the DWM swap interval hack for Windows 8 and later (#1072) diff --git a/src/egl_context.c b/src/egl_context.c index edb2fae2..319da273 100644 --- a/src/egl_context.c +++ b/src/egl_context.c @@ -231,6 +231,15 @@ static void swapBuffersEGL(_GLFWwindow* window) return; } +#if defined(_GLFW_WAYLAND) + if (_glfw.platform.platformID == GLFW_PLATFORM_WAYLAND) + { + // NOTE: Swapping buffers on a hidden window on Wayland makes it visible + if (!window->wl.visible) + return; + } +#endif + eglSwapBuffers(_glfw.egl.display, window->context.egl.surface); } diff --git a/src/wl_window.c b/src/wl_window.c index 12af2701..10d0e25f 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -812,20 +812,6 @@ int _glfwCreateWindowWayland(_GLFWwindow* window, if (wndconfig->title) window->wl.title = _glfw_strdup(wndconfig->title); - if (wndconfig->visible) - { - if (!createXdgSurface(window)) - return GLFW_FALSE; - - window->wl.visible = GLFW_TRUE; - } - else - { - window->wl.xdg.surface = NULL; - window->wl.xdg.toplevel = NULL; - window->wl.visible = GLFW_FALSE; - } - window->wl.currentCursor = NULL; window->wl.monitors = _glfw_calloc(1, sizeof(_GLFWmonitor*)); @@ -1018,21 +1004,23 @@ void _glfwShowWindowWayland(_GLFWwindow* window) { if (!window->wl.visible) { - createXdgSurface(window); + // NOTE: The XDG surface and role are created here so command-line applications + // with off-screen windows do not appear in for example the Unity dock + if (!window->wl.xdg.toplevel) + createXdgSurface(window); + window->wl.visible = GLFW_TRUE; } } void _glfwHideWindowWayland(_GLFWwindow* window) { - if (window->wl.xdg.toplevel) + if (window->wl.visible) { - xdg_toplevel_destroy(window->wl.xdg.toplevel); - xdg_surface_destroy(window->wl.xdg.surface); - window->wl.xdg.toplevel = NULL; - window->wl.xdg.surface = NULL; + window->wl.visible = GLFW_FALSE; + wl_surface_attach(window->wl.surface, NULL, 0, 0); + wl_surface_commit(window->wl.surface); } - window->wl.visible = GLFW_FALSE; } void _glfwRequestWindowAttentionWayland(_GLFWwindow* window) From f8ef3ca719eba800232eff30f08885d69c564e86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 22 Dec 2021 18:52:30 +0100 Subject: [PATCH 091/208] Add hiding and showing to interactive window test --- tests/window.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tests/window.c b/tests/window.c index 3e2bc671..83baff46 100644 --- a/tests/window.c +++ b/tests/window.c @@ -121,7 +121,7 @@ int main(int argc, char** argv) nk_glfw3_new_frame(); if (nk_begin(nk, "main", area, 0)) { - nk_layout_row_dynamic(nk, 30, 4); + nk_layout_row_dynamic(nk, 30, 5); if (nk_button_label(nk, "Toggle Fullscreen")) { @@ -149,6 +149,16 @@ int main(int argc, char** argv) glfwIconifyWindow(window); if (nk_button_label(nk, "Restore")) glfwRestoreWindow(window); + if (nk_button_label(nk, "Hide (briefly)")) + { + glfwHideWindow(window); + + const double time = glfwGetTime() + 3.0; + while (glfwGetTime() < time) + glfwWaitEventsTimeout(1.0); + + glfwShowWindow(window); + } nk_layout_row_dynamic(nk, 30, 1); From 7d060ba4f1237c87ed53e007db619da8c25df282 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 22 Dec 2021 22:19:25 +0100 Subject: [PATCH 092/208] X11: Fix sonames for loaded libraries on OpenBSD The OpenBSD ports tree assigns its own soname version numbers, so the hardcoded sonames GLFW uses to load libraries on non-macOS Unices are often incorrect. Instead OpenBSD recommends that run-time loading should leave out the version numbers entirely. The OpenBSD ld.so then finds the correct library. This upstreams the ports tree fixes for Xcursor and EGL, and adds the corresponding fix for all other run-time loaded library sonames. Tested on OpenBSD 7.0. This issue was initially reported on IRC. --- README.md | 1 + src/egl_context.c | 8 ++++++++ src/glx_context.c | 2 ++ src/osmesa_context.c | 2 ++ src/vulkan.c | 2 ++ src/x11_init.c | 20 ++++++++++++++++++++ 6 files changed, 35 insertions(+) diff --git a/README.md b/README.md index 63e9f6bd..9641fdf2 100644 --- a/README.md +++ b/README.md @@ -264,6 +264,7 @@ information on what to include when reporting a bug. - [X11] Bugfix: Changing `GLFW_FLOATING` could leak memory - [X11] Bugfix: Icon pixel format conversion worked only by accident, relying on undefined behavior (#1986) + - [X11] Bugfix: Dynamic loading on OpenBSD failed due to soname differences - [Wayland] Added dynamic loading of all Wayland libraries - [Wayland] Removed support for `wl_shell` (#1443) - [Wayland] Bugfix: The `GLFW_HAND_CURSOR` shape used the wrong image (#1432) diff --git a/src/egl_context.c b/src/egl_context.c index 319da273..89ea78fa 100644 --- a/src/egl_context.c +++ b/src/egl_context.c @@ -325,6 +325,8 @@ GLFWbool _glfwInitEGL(void) "libEGL.dylib", #elif defined(__CYGWIN__) "libEGL-1.so", +#elif defined(__OpenBSD__) + "libEGL.so", #else "libEGL.so.1", #endif @@ -700,6 +702,8 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window, "libGLES_CM.dll", #elif defined(_GLFW_COCOA) "libGLESv1_CM.dylib", +#elif defined(__OpenBSD__) + "libGLESv1_CM.so", #else "libGLESv1_CM.so.1", "libGLES_CM.so.1", @@ -717,6 +721,8 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window, "libGLESv2.dylib", #elif defined(__CYGWIN__) "libGLESv2-2.so", +#elif defined(__OpenBSD__) + "libGLESv2.so", #else "libGLESv2.so.2", #endif @@ -728,6 +734,8 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window, _GLFW_OPENGL_LIBRARY, #elif defined(_GLFW_WIN32) #elif defined(_GLFW_COCOA) +#elif defined(__OpenBSD__) + "libGL.so", #else "libGL.so.1", #endif diff --git a/src/glx_context.c b/src/glx_context.c index 060e487d..31cd34dc 100644 --- a/src/glx_context.c +++ b/src/glx_context.c @@ -259,6 +259,8 @@ GLFWbool _glfwInitGLX(void) _GLFW_GLX_LIBRARY, #elif defined(__CYGWIN__) "libGL-1.so", +#elif defined(__OpenBSD__) + "libGL.so", #else "libGL.so.1", "libGL.so", diff --git a/src/osmesa_context.c b/src/osmesa_context.c index 1b28c517..161d9fd8 100644 --- a/src/osmesa_context.c +++ b/src/osmesa_context.c @@ -124,6 +124,8 @@ GLFWbool _glfwInitOSMesa(void) "libOSMesa.8.dylib", #elif defined(__CYGWIN__) "libOSMesa-8.so", +#elif defined(__OpenBSD__) + "libOSMesa.so", #else "libOSMesa.so.8", "libOSMesa.so.6", diff --git a/src/vulkan.c b/src/vulkan.c index 2a64ecb4..f02b1ede 100644 --- a/src/vulkan.c +++ b/src/vulkan.c @@ -63,6 +63,8 @@ GLFWbool _glfwInitVulkan(int mode) _glfw.vk.handle = _glfwPlatformLoadModule("libvulkan.1.dylib"); if (!_glfw.vk.handle) _glfw.vk.handle = _glfwLoadLocalVulkanLoaderCocoa(); +#elif defined(__OpenBSD__) + _glfw.vk.handle = _glfwPlatformLoadModule("libvulkan.so"); #else _glfw.vk.handle = _glfwPlatformLoadModule("libvulkan.so.1"); #endif diff --git a/src/x11_init.c b/src/x11_init.c index 68d6a6c4..acfa7933 100644 --- a/src/x11_init.c +++ b/src/x11_init.c @@ -601,7 +601,11 @@ static void detectEWMH(void) // static GLFWbool initExtensions(void) { +#if defined(__OpenBSD__) + _glfw.x11.vidmode.handle = _glfwPlatformLoadModule("libXxf86vm.so"); +#else _glfw.x11.vidmode.handle = _glfwPlatformLoadModule("libXxf86vm.so.1"); +#endif if (_glfw.x11.vidmode.handle) { _glfw.x11.vidmode.QueryExtension = (PFN_XF86VidModeQueryExtension) @@ -621,6 +625,8 @@ static GLFWbool initExtensions(void) #if defined(__CYGWIN__) _glfw.x11.xi.handle = _glfwPlatformLoadModule("libXi-6.so"); +#elif defined(__OpenBSD__) + _glfw.x11.xi.handle = _glfwPlatformLoadModule("libXi.so"); #else _glfw.x11.xi.handle = _glfwPlatformLoadModule("libXi.so.6"); #endif @@ -651,6 +657,8 @@ static GLFWbool initExtensions(void) #if defined(__CYGWIN__) _glfw.x11.randr.handle = _glfwPlatformLoadModule("libXrandr-2.so"); +#elif defined(__OpenBSD__) + _glfw.x11.randr.handle = _glfwPlatformLoadModule("libXrandr.so"); #else _glfw.x11.randr.handle = _glfwPlatformLoadModule("libXrandr.so.2"); #endif @@ -743,6 +751,8 @@ static GLFWbool initExtensions(void) #if defined(__CYGWIN__) _glfw.x11.xcursor.handle = _glfwPlatformLoadModule("libXcursor-1.so"); +#elif defined(__OpenBSD__) + _glfw.x11.xcursor.handle = _glfwPlatformLoadModule("libXcursor.so"); #else _glfw.x11.xcursor.handle = _glfwPlatformLoadModule("libXcursor.so.1"); #endif @@ -764,6 +774,8 @@ static GLFWbool initExtensions(void) #if defined(__CYGWIN__) _glfw.x11.xinerama.handle = _glfwPlatformLoadModule("libXinerama-1.so"); +#elif defined(__OpenBSD__) + _glfw.x11.xinerama.handle = _glfwPlatformLoadModule("libXinerama.so"); #else _glfw.x11.xinerama.handle = _glfwPlatformLoadModule("libXinerama.so.1"); #endif @@ -817,6 +829,8 @@ static GLFWbool initExtensions(void) { #if defined(__CYGWIN__) _glfw.x11.x11xcb.handle = _glfwPlatformLoadModule("libX11-xcb-1.so"); +#elif defined(__OpenBSD__) + _glfw.x11.x11xcb.handle = _glfwPlatformLoadModule("libX11-xcb.so"); #else _glfw.x11.x11xcb.handle = _glfwPlatformLoadModule("libX11-xcb.so.1"); #endif @@ -830,6 +844,8 @@ static GLFWbool initExtensions(void) #if defined(__CYGWIN__) _glfw.x11.xrender.handle = _glfwPlatformLoadModule("libXrender-1.so"); +#elif defined(__OpenBSD__) + _glfw.x11.xrender.handle = _glfwPlatformLoadModule("libXrender.so"); #else _glfw.x11.xrender.handle = _glfwPlatformLoadModule("libXrender.so.1"); #endif @@ -857,6 +873,8 @@ static GLFWbool initExtensions(void) #if defined(__CYGWIN__) _glfw.x11.xshape.handle = _glfwPlatformLoadModule("libXext-6.so"); +#elif defined(__OpenBSD__) + _glfw.x11.xshape.handle = _glfwPlatformLoadModule("libXext.so"); #else _glfw.x11.xshape.handle = _glfwPlatformLoadModule("libXext.so.6"); #endif @@ -1203,6 +1221,8 @@ GLFWbool _glfwConnectX11(int platformID, _GLFWplatform* platform) #if defined(__CYGWIN__) void* module = _glfwPlatformLoadModule("libX11-6.so"); +#elif defined(__OpenBSD__) + void* module = _glfwPlatformLoadModule("libX11.so"); #else void* module = _glfwPlatformLoadModule("libX11.so.6"); #endif From 05b0e2fab2be38e0c937bf2ba09f6dc892160616 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Sun, 26 Dec 2021 18:02:00 +0100 Subject: [PATCH 093/208] Update docs for specific Vulkan surface extensions Related to #2014 --- include/GLFW/glfw3.h | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index f0b8d5ec..520dc1df 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -6189,9 +6189,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. @@ -6330,17 +6327,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. From 8edbc4971d6c994d84f12f349afdeef41fae527f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 27 Dec 2021 01:31:38 +0100 Subject: [PATCH 094/208] Wayland: Document delayed window showing --- include/GLFW/glfw3.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index 520dc1df..72d5fa71 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -3764,6 +3764,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 From 855d338a6596cef6b88b298ad00b6f2658019877 Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Thu, 30 Dec 2021 19:04:10 +0100 Subject: [PATCH 095/208] Wayland: Use correct action on fallback decoration We were previously storing the pointer position only when on the main window, so when the user clicked on a fallback decoration it would use the last position of the cursor on the main window, instead of the position in the decoration surface. Fixes part of #1991. --- src/wl_init.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/wl_init.c b/src/wl_init.c index fd6efaa8..d26e5f6c 100644 --- a/src/wl_init.c +++ b/src/wl_init.c @@ -207,12 +207,12 @@ static void pointerHandleMotion(void* data, return; x = wl_fixed_to_double(sx); y = wl_fixed_to_double(sy); + window->wl.cursorPosX = x; + window->wl.cursorPosY = y; switch (window->wl.decorations.focus) { case mainWindow: - window->wl.cursorPosX = x; - window->wl.cursorPosY = y; _glfwInputCursorPos(window, x, y); _glfw.wl.cursorPreviousName = NULL; return; @@ -272,9 +272,7 @@ static void pointerHandleButton(void* data, if (window->wl.cursorPosY < _GLFW_DECORATION_WIDTH) edges = XDG_TOPLEVEL_RESIZE_EDGE_TOP; else - { xdg_toplevel_move(window->wl.xdg.toplevel, _glfw.wl.seat, serial); - } break; case leftDecoration: if (window->wl.cursorPosY < _GLFW_DECORATION_WIDTH) @@ -303,6 +301,7 @@ static void pointerHandleButton(void* data, { xdg_toplevel_resize(window->wl.xdg.toplevel, _glfw.wl.seat, serial, edges); + return; } } else if (button == BTN_RIGHT) From 79e7e65c9d6145ded05baf54f82b53f5df451ea9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Sun, 26 Dec 2021 22:01:32 +0100 Subject: [PATCH 096/208] Wayland: Clean up event pump Adapt style to the rest of the project. --- src/wl_window.c | 59 ++++++++++++++++++++++++------------------------- 1 file changed, 29 insertions(+), 30 deletions(-) diff --git a/src/wl_window.c b/src/wl_window.c index 10d0e25f..d51c9309 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -708,22 +708,19 @@ static void incrementCursorImage(_GLFWwindow* window) static void handleEvents(int timeout) { - struct wl_display* display = _glfw.wl.display; - struct pollfd fds[] = { - { wl_display_get_fd(display), POLLIN }, + struct pollfd fds[] = + { + { wl_display_get_fd(_glfw.wl.display), POLLIN }, { _glfw.wl.timerfd, POLLIN }, { _glfw.wl.cursorTimerfd, POLLIN }, }; - ssize_t read_ret; - uint64_t repeats; - while (wl_display_prepare_read(display) != 0) - wl_display_dispatch_pending(display); + while (wl_display_prepare_read(_glfw.wl.display) != 0) + wl_display_dispatch_pending(_glfw.wl.display); - // If an error different from EAGAIN happens, we have likely been - // disconnected from the Wayland session, try to handle that the best we - // can. - if (wl_display_flush(display) < 0 && errno != EAGAIN) + // If an error other than EAGAIN happens, we have likely been disconnected + // from the Wayland session; try to handle that the best we can. + if (wl_display_flush(_glfw.wl.display) < 0 && errno != EAGAIN) { _GLFWwindow* window = _glfw.windowListHead; while (window) @@ -731,7 +728,8 @@ static void handleEvents(int timeout) _glfwInputWindowCloseRequest(window); window = window->next; } - wl_display_cancel_read(display); + + wl_display_cancel_read(_glfw.wl.display); return; } @@ -739,41 +737,42 @@ static void handleEvents(int timeout) { if (fds[0].revents & POLLIN) { - wl_display_read_events(display); - wl_display_dispatch_pending(display); + wl_display_read_events(_glfw.wl.display); + wl_display_dispatch_pending(_glfw.wl.display); } else - { - wl_display_cancel_read(display); - } + wl_display_cancel_read(_glfw.wl.display); if (fds[1].revents & POLLIN) { - read_ret = read(_glfw.wl.timerfd, &repeats, sizeof(repeats)); - if (read_ret == 8 && _glfw.wl.keyboardFocus) + uint64_t repeats; + + if (read(_glfw.wl.timerfd, &repeats, sizeof(repeats)) == 8) { - for (uint64_t i = 0; i < repeats; ++i) + if (_glfw.wl.keyboardFocus) { - _glfwInputKey(_glfw.wl.keyboardFocus, - _glfw.wl.keyboardLastKey, - _glfw.wl.keyboardLastScancode, - GLFW_REPEAT, - _glfw.wl.xkb.modifiers); + for (uint64_t i = 0; i < repeats; i++) + { + _glfwInputKey(_glfw.wl.keyboardFocus, + _glfw.wl.keyboardLastKey, + _glfw.wl.keyboardLastScancode, + GLFW_REPEAT, + _glfw.wl.xkb.modifiers); + } } } } if (fds[2].revents & POLLIN) { - read_ret = read(_glfw.wl.cursorTimerfd, &repeats, sizeof(repeats)); - if (read_ret == 8) + uint64_t repeats; + + if (read(_glfw.wl.cursorTimerfd, &repeats, sizeof(repeats)) == 8) incrementCursorImage(_glfw.wl.pointerFocus); } } else - { - wl_display_cancel_read(display); - } + wl_display_cancel_read(_glfw.wl.display); } ////////////////////////////////////////////////////////////////////////// From 850893a39f1e58ba5d6ff891ee18ca39037f921a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 27 Dec 2021 00:52:24 +0100 Subject: [PATCH 097/208] Wayland: Control key repeat via timerfd state The key repeat logic is now controlled only via the key repeat timerfd. --- src/wl_init.c | 6 +++--- src/wl_window.c | 15 ++++++--------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/wl_init.c b/src/wl_init.c index d26e5f6c..9ccd3530 100644 --- a/src/wl_init.c +++ b/src/wl_init.c @@ -504,12 +504,12 @@ static void keyboardHandleLeave(void* data, if (!window) return; + struct itimerspec timer = {}; + timerfd_settime(_glfw.wl.timerfd, 0, &timer, NULL); + _glfw.wl.serial = serial; _glfw.wl.keyboardFocus = NULL; _glfwInputWindowFocus(window, GLFW_FALSE); - - struct itimerspec timer = {}; - timerfd_settime(_glfw.wl.timerfd, 0, &timer, NULL); } static int toGLFWKeyCode(uint32_t key) diff --git a/src/wl_window.c b/src/wl_window.c index d51c9309..f2e268db 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -749,16 +749,13 @@ static void handleEvents(int timeout) if (read(_glfw.wl.timerfd, &repeats, sizeof(repeats)) == 8) { - if (_glfw.wl.keyboardFocus) + for (uint64_t i = 0; i < repeats; i++) { - for (uint64_t i = 0; i < repeats; i++) - { - _glfwInputKey(_glfw.wl.keyboardFocus, - _glfw.wl.keyboardLastKey, - _glfw.wl.keyboardLastScancode, - GLFW_REPEAT, - _glfw.wl.xkb.modifiers); - } + _glfwInputKey(_glfw.wl.keyboardFocus, + _glfw.wl.keyboardLastKey, + _glfw.wl.keyboardLastScancode, + GLFW_REPEAT, + _glfw.wl.xkb.modifiers); } } } From 3f5dfeaf295f69af006458f589e45c991d460fde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Sun, 26 Dec 2021 22:51:20 +0100 Subject: [PATCH 098/208] Wayland: Fix repeated key not released on defocus Platform code should not generate key events with GLFW_REPEAT. GLFW_PRESS is translated into GLFW_REPEAT by shared code based on the key state cache. This confused the automatic key release logic into not generating an event with GLFW_RELEASE for a key being repeated when the window lost input focus. --- README.md | 1 + src/wl_window.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9641fdf2..393a383d 100644 --- a/README.md +++ b/README.md @@ -283,6 +283,7 @@ information on what to include when reporting a bug. - [Wayland] Bugfix: Activating a window would emit two input focus events - [Wayland] Bugfix: Disable key repeat mechanism when window loses input focus - [Wayland] Bugfix: Window hiding and showing did not work (#1492,#1731) + - [Wayland] Bugfix: A key being repeated was not released when window lost focus - [POSIX] Removed use of deprecated function `gettimeofday` - [POSIX] Bugfix: `CLOCK_MONOTONIC` was not correctly tested for or enabled - [WGL] Disabled the DWM swap interval hack for Windows 8 and later (#1072) diff --git a/src/wl_window.c b/src/wl_window.c index f2e268db..26200363 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -754,7 +754,7 @@ static void handleEvents(int timeout) _glfwInputKey(_glfw.wl.keyboardFocus, _glfw.wl.keyboardLastKey, _glfw.wl.keyboardLastScancode, - GLFW_REPEAT, + GLFW_PRESS, _glfw.wl.xkb.modifiers); } } From a3d1633e1d48c2283da139116d70d5223642a804 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 27 Dec 2021 18:10:52 +0100 Subject: [PATCH 099/208] Wayland: Move surface creation function This needs to be after createXdgSurface, which it will soon be calling. --- src/wl_window.c | 58 ++++++++++++++++++++++++------------------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/src/wl_window.c b/src/wl_window.c index 26200363..e1fd96cb 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -432,35 +432,6 @@ static void setIdleInhibitor(_GLFWwindow* window, GLFWbool enable) } } -static GLFWbool createSurface(_GLFWwindow* window, - const _GLFWwndconfig* wndconfig) -{ - window->wl.surface = wl_compositor_create_surface(_glfw.wl.compositor); - if (!window->wl.surface) - return GLFW_FALSE; - - wl_surface_add_listener(window->wl.surface, - &surfaceListener, - window); - - wl_surface_set_user_data(window->wl.surface, window); - - window->wl.native = wl_egl_window_create(window->wl.surface, - wndconfig->width, - wndconfig->height); - if (!window->wl.native) - return GLFW_FALSE; - - window->wl.width = wndconfig->width; - window->wl.height = wndconfig->height; - window->wl.scale = 1; - - if (!window->wl.transparent) - setOpaqueRegion(window); - - return GLFW_TRUE; -} - static void setFullscreen(_GLFWwindow* window, _GLFWmonitor* monitor, int refreshRate) { @@ -644,6 +615,35 @@ static GLFWbool createXdgSurface(_GLFWwindow* window) return GLFW_TRUE; } +static GLFWbool createSurface(_GLFWwindow* window, + const _GLFWwndconfig* wndconfig) +{ + window->wl.surface = wl_compositor_create_surface(_glfw.wl.compositor); + if (!window->wl.surface) + return GLFW_FALSE; + + wl_surface_add_listener(window->wl.surface, + &surfaceListener, + window); + + wl_surface_set_user_data(window->wl.surface, window); + + window->wl.native = wl_egl_window_create(window->wl.surface, + wndconfig->width, + wndconfig->height); + if (!window->wl.native) + return GLFW_FALSE; + + window->wl.width = wndconfig->width; + window->wl.height = wndconfig->height; + window->wl.scale = 1; + + if (!window->wl.transparent) + setOpaqueRegion(window); + + return GLFW_TRUE; +} + static void setCursorImage(_GLFWwindow* window, _GLFWcursorWayland* cursorWayland) { From 7bede13b1dacb2ccf4d9492d0ec6bc0f7879222e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 27 Dec 2021 18:13:51 +0100 Subject: [PATCH 100/208] Wayland: Gather framebuffer transparency logic --- src/wl_window.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/wl_window.c b/src/wl_window.c index e1fd96cb..28fdcb3d 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -616,7 +616,8 @@ static GLFWbool createXdgSurface(_GLFWwindow* window) } static GLFWbool createSurface(_GLFWwindow* window, - const _GLFWwndconfig* wndconfig) + const _GLFWwndconfig* wndconfig, + const _GLFWfbconfig* fbconfig) { window->wl.surface = wl_compositor_create_surface(_glfw.wl.compositor); if (!window->wl.surface) @@ -638,6 +639,7 @@ static GLFWbool createSurface(_GLFWwindow* window, window->wl.height = wndconfig->height; window->wl.scale = 1; + window->wl.transparent = fbconfig->transparent; if (!window->wl.transparent) setOpaqueRegion(window); @@ -781,9 +783,7 @@ int _glfwCreateWindowWayland(_GLFWwindow* window, const _GLFWctxconfig* ctxconfig, const _GLFWfbconfig* fbconfig) { - window->wl.transparent = fbconfig->transparent; - - if (!createSurface(window, wndconfig)) + if (!createSurface(window, wndconfig, fbconfig)) return GLFW_FALSE; if (ctxconfig->client != GLFW_NO_API) From c1ecd4673eae76d65a8a5e4222c46e20693f4e9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 27 Dec 2021 18:16:37 +0100 Subject: [PATCH 101/208] Wayland: Move window title cloning to creation --- src/wl_window.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/wl_window.c b/src/wl_window.c index 28fdcb3d..2cfdee47 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -638,6 +638,7 @@ static GLFWbool createSurface(_GLFWwindow* window, window->wl.width = wndconfig->width; window->wl.height = wndconfig->height; window->wl.scale = 1; + window->wl.title = _glfw_strdup(wndconfig->title); window->wl.transparent = fbconfig->transparent; if (!window->wl.transparent) @@ -805,9 +806,6 @@ int _glfwCreateWindowWayland(_GLFWwindow* window, } } - if (wndconfig->title) - window->wl.title = _glfw_strdup(wndconfig->title); - window->wl.currentCursor = NULL; window->wl.monitors = _glfw_calloc(1, sizeof(_GLFWmonitor*)); From 216ea3d735e44691a5d06ee5654cd1ca14f685f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 27 Dec 2021 18:20:30 +0100 Subject: [PATCH 102/208] Wayland: Remove superfluous initialize to NULL The whole window struct has already been cleared to zero. --- src/wl_window.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/wl_window.c b/src/wl_window.c index 2cfdee47..dfee3f34 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -806,8 +806,6 @@ int _glfwCreateWindowWayland(_GLFWwindow* window, } } - window->wl.currentCursor = NULL; - window->wl.monitors = _glfw_calloc(1, sizeof(_GLFWmonitor*)); window->wl.monitorsCount = 0; window->wl.monitorsSize = 1; From 12c2ccd609442f835e8f68b27bd903ab716f2531 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 27 Dec 2021 18:22:15 +0100 Subject: [PATCH 103/208] Wayland: Remove window monitor array pre-alloc The array will be allocated by surfaceHandleEnter when needed. --- src/wl_window.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/wl_window.c b/src/wl_window.c index dfee3f34..6ad95f31 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -806,10 +806,6 @@ int _glfwCreateWindowWayland(_GLFWwindow* window, } } - window->wl.monitors = _glfw_calloc(1, sizeof(_GLFWmonitor*)); - window->wl.monitorsCount = 0; - window->wl.monitorsSize = 1; - return GLFW_TRUE; } From c05acf6246eefb08533dc3955db7eac9d2d1c0ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 28 Dec 2021 01:20:19 +0100 Subject: [PATCH 104/208] Wayland: Fix window not visible after initial swap A window created with GLFW_VISIBLE set was not made visible by the initial buffer swap during context attribute refresh. Regression introduced by @elmindreda in 094aa6d3c721397825cb1095c156353463ecafb5. --- src/wl_window.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/wl_window.c b/src/wl_window.c index 6ad95f31..b01d01f0 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -644,6 +644,14 @@ static GLFWbool createSurface(_GLFWwindow* window, if (!window->wl.transparent) setOpaqueRegion(window); + if (wndconfig->visible) + { + if (!createXdgSurface(window)) + return GLFW_FALSE; + + window->wl.visible = GLFW_TRUE; + } + return GLFW_TRUE; } From 25c521cbe5acd58641740db5063d33fb51eeb882 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 28 Dec 2021 01:39:06 +0100 Subject: [PATCH 105/208] Wayland: Fix missing damage event on window show By definition a hidden window on Wayland does not have valid framebuffer contents. This adds a window damage (refresh) event when a window is shown, to request an initial frame for the now visible window. --- README.md | 1 + src/wl_window.c | 1 + 2 files changed, 2 insertions(+) diff --git a/README.md b/README.md index 393a383d..f2769580 100644 --- a/README.md +++ b/README.md @@ -284,6 +284,7 @@ information on what to include when reporting a bug. - [Wayland] Bugfix: Disable key repeat mechanism when window loses input focus - [Wayland] Bugfix: Window hiding and showing did not work (#1492,#1731) - [Wayland] Bugfix: A key being repeated was not released when window lost focus + - [Wayland] Bugfix: Showing a hidden window did not emit a window refresh event - [POSIX] Removed use of deprecated function `gettimeofday` - [POSIX] Bugfix: `CLOCK_MONOTONIC` was not correctly tested for or enabled - [WGL] Disabled the DWM swap interval hack for Windows 8 and later (#1072) diff --git a/src/wl_window.c b/src/wl_window.c index b01d01f0..a3190592 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -1006,6 +1006,7 @@ void _glfwShowWindowWayland(_GLFWwindow* window) createXdgSurface(window); window->wl.visible = GLFW_TRUE; + _glfwInputWindowDamage(window); } } From 8aaea57421cd4e37b439fbce7482a5f351c0c31f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 28 Dec 2021 04:01:32 +0100 Subject: [PATCH 106/208] Fix gamma test not checking for NULL return value --- tests/gamma.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/gamma.c b/tests/gamma.c index 734955cd..d1f6dc27 100644 --- a/tests/gamma.c +++ b/tests/gamma.c @@ -113,6 +113,12 @@ int main(int argc, char** argv) { const GLFWgammaramp* ramp = glfwGetGammaRamp(monitor); + if (!ramp) + { + glfwTerminate(); + exit(EXIT_FAILURE); + } + const size_t array_size = ramp->size * sizeof(short); orig_ramp.size = ramp->size; orig_ramp.red = malloc(array_size); From 715b874db341d7f696a8244e4f3d5d14d07894bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 28 Dec 2021 15:33:58 +0100 Subject: [PATCH 107/208] Wayland: Fix GLFW_VISIBLE affecting full screen Full screen window creation was not ignoring the GLFW_VISIBLE hint. --- README.md | 1 + src/wl_window.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f2769580..abe5ed29 100644 --- a/README.md +++ b/README.md @@ -285,6 +285,7 @@ information on what to include when reporting a bug. - [Wayland] Bugfix: Window hiding and showing did not work (#1492,#1731) - [Wayland] Bugfix: A key being repeated was not released when window lost focus - [Wayland] Bugfix: Showing a hidden window did not emit a window refresh event + - [Wayland] Bugfix: Full screen window creation did not ignore `GLFW_VISIBLE` - [POSIX] Removed use of deprecated function `gettimeofday` - [POSIX] Bugfix: `CLOCK_MONOTONIC` was not correctly tested for or enabled - [WGL] Disabled the DWM swap interval hack for Windows 8 and later (#1072) diff --git a/src/wl_window.c b/src/wl_window.c index a3190592..eab108ee 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -644,7 +644,7 @@ static GLFWbool createSurface(_GLFWwindow* window, if (!window->wl.transparent) setOpaqueRegion(window); - if (wndconfig->visible) + if (window->monitor || wndconfig->visible) { if (!createXdgSurface(window)) return GLFW_FALSE; From 37b7540db9d850e9318fd1948dfb714f75306d50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 30 Dec 2021 02:59:15 +0100 Subject: [PATCH 108/208] Wayland: Fix keys reported as wrong or unknown key --- README.md | 1 + src/wl_init.c | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index abe5ed29..ae36e304 100644 --- a/README.md +++ b/README.md @@ -286,6 +286,7 @@ information on what to include when reporting a bug. - [Wayland] Bugfix: A key being repeated was not released when window lost focus - [Wayland] Bugfix: Showing a hidden window did not emit a window refresh event - [Wayland] Bugfix: Full screen window creation did not ignore `GLFW_VISIBLE` + - [Wayland] Bugfix: Some keys were reported as wrong key or `GLFW_KEY_UNKNOWN` - [POSIX] Removed use of deprecated function `gettimeofday` - [POSIX] Bugfix: `CLOCK_MONOTONIC` was not correctly tested for or enabled - [WGL] Disabled the DWM swap interval hack for Windows 8 and later (#1072) diff --git a/src/wl_init.c b/src/wl_init.c index 9ccd3530..3d28bddc 100644 --- a/src/wl_init.c +++ b/src/wl_init.c @@ -972,7 +972,7 @@ static void createKeyTables(void) _glfw.wl.keycodes[KEY_RIGHTALT] = GLFW_KEY_RIGHT_ALT; _glfw.wl.keycodes[KEY_LEFTMETA] = GLFW_KEY_LEFT_SUPER; _glfw.wl.keycodes[KEY_RIGHTMETA] = GLFW_KEY_RIGHT_SUPER; - _glfw.wl.keycodes[KEY_MENU] = GLFW_KEY_MENU; + _glfw.wl.keycodes[KEY_COMPOSE] = GLFW_KEY_MENU; _glfw.wl.keycodes[KEY_NUMLOCK] = GLFW_KEY_NUM_LOCK; _glfw.wl.keycodes[KEY_CAPSLOCK] = GLFW_KEY_CAPS_LOCK; _glfw.wl.keycodes[KEY_PRINT] = GLFW_KEY_PRINT_SCREEN; @@ -1015,7 +1015,7 @@ static void createKeyTables(void) _glfw.wl.keycodes[KEY_F23] = GLFW_KEY_F23; _glfw.wl.keycodes[KEY_F24] = GLFW_KEY_F24; _glfw.wl.keycodes[KEY_KPSLASH] = GLFW_KEY_KP_DIVIDE; - _glfw.wl.keycodes[KEY_KPDOT] = GLFW_KEY_KP_MULTIPLY; + _glfw.wl.keycodes[KEY_KPASTERISK] = GLFW_KEY_KP_MULTIPLY; _glfw.wl.keycodes[KEY_KPMINUS] = GLFW_KEY_KP_SUBTRACT; _glfw.wl.keycodes[KEY_KPPLUS] = GLFW_KEY_KP_ADD; _glfw.wl.keycodes[KEY_KP0] = GLFW_KEY_KP_0; @@ -1028,9 +1028,10 @@ static void createKeyTables(void) _glfw.wl.keycodes[KEY_KP7] = GLFW_KEY_KP_7; _glfw.wl.keycodes[KEY_KP8] = GLFW_KEY_KP_8; _glfw.wl.keycodes[KEY_KP9] = GLFW_KEY_KP_9; - _glfw.wl.keycodes[KEY_KPCOMMA] = GLFW_KEY_KP_DECIMAL; + _glfw.wl.keycodes[KEY_KPDOT] = GLFW_KEY_KP_DECIMAL; _glfw.wl.keycodes[KEY_KPEQUAL] = GLFW_KEY_KP_EQUAL; _glfw.wl.keycodes[KEY_KPENTER] = GLFW_KEY_KP_ENTER; + _glfw.wl.keycodes[KEY_102ND] = GLFW_KEY_WORLD_2; for (int scancode = 0; scancode < 256; scancode++) { From cb22c5411938c14a3ddef6f0fb4f338a6b4b99a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 30 Dec 2021 18:22:16 +0100 Subject: [PATCH 109/208] Move UTF-8 encoding to shared code This will be used by the Wayland code too. --- src/init.c | 31 +++++++++++++++++++++++++++++++ src/internal.h | 2 ++ src/x11_window.c | 35 ++--------------------------------- 3 files changed, 35 insertions(+), 33 deletions(-) diff --git a/src/init.c b/src/init.c index b5c5da9c..1d4e7804 100644 --- a/src/init.c +++ b/src/init.c @@ -140,6 +140,37 @@ static void terminate(void) ////// GLFW internal API ////// ////////////////////////////////////////////////////////////////////////// +// Encode a Unicode code point to a UTF-8 stream +// Based on cutef8 by Jeff Bezanson (Public Domain) +// +size_t _glfwEncodeUTF8(char* s, unsigned int ch) +{ + size_t count = 0; + + if (ch < 0x80) + s[count++] = (char) ch; + else if (ch < 0x800) + { + s[count++] = (ch >> 6) | 0xc0; + s[count++] = (ch & 0x3f) | 0x80; + } + else if (ch < 0x10000) + { + s[count++] = (ch >> 12) | 0xe0; + s[count++] = ((ch >> 6) & 0x3f) | 0x80; + s[count++] = (ch & 0x3f) | 0x80; + } + else if (ch < 0x110000) + { + s[count++] = (ch >> 18) | 0xf0; + s[count++] = ((ch >> 12) & 0x3f) | 0x80; + s[count++] = ((ch >> 6) & 0x3f) | 0x80; + s[count++] = (ch & 0x3f) | 0x80; + } + + return count; +} + char* _glfw_strdup(const char* source) { const size_t length = strlen(source); diff --git a/src/internal.h b/src/internal.h index 2a8c8d6d..b28d41ab 100644 --- a/src/internal.h +++ b/src/internal.h @@ -995,6 +995,8 @@ GLFWbool _glfwInitVulkan(int mode); void _glfwTerminateVulkan(void); const char* _glfwGetVulkanResultString(VkResult result); +size_t _glfwEncodeUTF8(char* s, unsigned int ch); + char* _glfw_strdup(const char* source); float _glfw_fminf(float a, float b); float _glfw_fmaxf(float a, float b); diff --git a/src/x11_window.c b/src/x11_window.c index a5255215..96514c18 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -429,37 +429,6 @@ static char** parseUriList(char* text, int* count) return paths; } -// Encode a Unicode code point to a UTF-8 stream -// Based on cutef8 by Jeff Bezanson (Public Domain) -// -static size_t encodeUTF8(char* s, unsigned int ch) -{ - size_t count = 0; - - if (ch < 0x80) - s[count++] = (char) ch; - else if (ch < 0x800) - { - s[count++] = (ch >> 6) | 0xc0; - s[count++] = (ch & 0x3f) | 0x80; - } - else if (ch < 0x10000) - { - s[count++] = (ch >> 12) | 0xe0; - s[count++] = ((ch >> 6) & 0x3f) | 0x80; - s[count++] = (ch & 0x3f) | 0x80; - } - else if (ch < 0x110000) - { - s[count++] = (ch >> 18) | 0xf0; - s[count++] = ((ch >> 12) & 0x3f) | 0x80; - s[count++] = ((ch >> 6) & 0x3f) | 0x80; - s[count++] = (ch & 0x3f) | 0x80; - } - - return count; -} - // Decode a Unicode code point from a UTF-8 stream // Based on cutef8 by Jeff Bezanson (Public Domain) // @@ -497,7 +466,7 @@ static char* convertLatin1toUTF8(const char* source) char* tp = target; for (sp = source; *sp; sp++) - tp += encodeUTF8(tp, *sp); + tp += _glfwEncodeUTF8(tp, *sp); return target; } @@ -2903,7 +2872,7 @@ const char* _glfwGetScancodeNameX11(int scancode) if (ch == -1) return NULL; - const size_t count = encodeUTF8(_glfw.x11.keynames[key], (unsigned int) ch); + const size_t count = _glfwEncodeUTF8(_glfw.x11.keynames[key], (unsigned int) ch); if (count == 0) return NULL; From 17a9e34fbc179373dc9bc370164fa4690870b295 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 29 Dec 2021 23:45:06 +0100 Subject: [PATCH 110/208] Wayland: Implement key name support --- README.md | 1 + src/wl_init.c | 4 ++++ src/wl_platform.h | 7 ++++++ src/wl_window.c | 55 +++++++++++++++++++++++++++++++++++++++++++---- 4 files changed, 63 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index ae36e304..06108a86 100644 --- a/README.md +++ b/README.md @@ -266,6 +266,7 @@ information on what to include when reporting a bug. undefined behavior (#1986) - [X11] Bugfix: Dynamic loading on OpenBSD failed due to soname differences - [Wayland] Added dynamic loading of all Wayland libraries + - [Wayland] Added support for key names via xkbcommon - [Wayland] Removed support for `wl_shell` (#1443) - [Wayland] Bugfix: The `GLFW_HAND_CURSOR` shape used the wrong image (#1432) - [Wayland] Bugfix: `CLOCK_MONOTONIC` was not correctly enabled diff --git a/src/wl_init.c b/src/wl_init.c index 3d28bddc..bd365fdf 100644 --- a/src/wl_init.c +++ b/src/wl_init.c @@ -1290,6 +1290,8 @@ int _glfwInitWayland(void) _glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_keymap_mod_get_index"); _glfw.wl.xkb.keymap_key_repeats = (PFN_xkb_keymap_key_repeats) _glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_keymap_key_repeats"); + _glfw.wl.xkb.keymap_key_get_syms_by_level = (PFN_xkb_keymap_key_get_syms_by_level) + _glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_keymap_key_get_syms_by_level"); _glfw.wl.xkb.state_new = (PFN_xkb_state_new) _glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_state_new"); _glfw.wl.xkb.state_unref = (PFN_xkb_state_unref) @@ -1300,6 +1302,8 @@ int _glfwInitWayland(void) _glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_state_update_mask"); _glfw.wl.xkb.state_serialize_mods = (PFN_xkb_state_serialize_mods) _glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_state_serialize_mods"); + _glfw.wl.xkb.state_key_get_layout = (PFN_xkb_state_key_get_layout) + _glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_state_key_get_layout"); #ifdef HAVE_XKBCOMMON_COMPOSE_H _glfw.wl.xkb.compose_table_new_from_locale = (PFN_xkb_compose_table_new_from_locale) diff --git a/src/wl_platform.h b/src/wl_platform.h index 1e36a794..e29f41b4 100644 --- a/src/wl_platform.h +++ b/src/wl_platform.h @@ -163,22 +163,26 @@ typedef struct xkb_keymap* (* PFN_xkb_keymap_new_from_string)(struct xkb_context typedef void (* PFN_xkb_keymap_unref)(struct xkb_keymap*); typedef xkb_mod_index_t (* PFN_xkb_keymap_mod_get_index)(struct xkb_keymap*, const char*); typedef int (* PFN_xkb_keymap_key_repeats)(struct xkb_keymap*, xkb_keycode_t); +typedef int (* PFN_xkb_keymap_key_get_syms_by_level)(struct xkb_keymap*,xkb_keycode_t,xkb_layout_index_t,xkb_level_index_t,const xkb_keysym_t**); typedef struct xkb_state* (* PFN_xkb_state_new)(struct xkb_keymap*); typedef void (* PFN_xkb_state_unref)(struct xkb_state*); typedef int (* PFN_xkb_state_key_get_syms)(struct xkb_state*, xkb_keycode_t, const xkb_keysym_t**); typedef enum xkb_state_component (* PFN_xkb_state_update_mask)(struct xkb_state*, xkb_mod_mask_t, xkb_mod_mask_t, xkb_mod_mask_t, xkb_layout_index_t, xkb_layout_index_t, xkb_layout_index_t); typedef xkb_mod_mask_t (* PFN_xkb_state_serialize_mods)(struct xkb_state*, enum xkb_state_component); +typedef xkb_layout_index_t (* PFN_xkb_state_key_get_layout)(struct xkb_state*,xkb_keycode_t); #define xkb_context_new _glfw.wl.xkb.context_new #define xkb_context_unref _glfw.wl.xkb.context_unref #define xkb_keymap_new_from_string _glfw.wl.xkb.keymap_new_from_string #define xkb_keymap_unref _glfw.wl.xkb.keymap_unref #define xkb_keymap_mod_get_index _glfw.wl.xkb.keymap_mod_get_index #define xkb_keymap_key_repeats _glfw.wl.xkb.keymap_key_repeats +#define xkb_keymap_key_get_syms_by_level _glfw.wl.xkb.keymap_key_get_syms_by_level #define xkb_state_new _glfw.wl.xkb.state_new #define xkb_state_unref _glfw.wl.xkb.state_unref #define xkb_state_key_get_syms _glfw.wl.xkb.state_key_get_syms #define xkb_state_update_mask _glfw.wl.xkb.state_update_mask #define xkb_state_serialize_mods _glfw.wl.xkb.state_serialize_mods +#define xkb_state_key_get_layout _glfw.wl.xkb.state_key_get_layout #ifdef HAVE_XKBCOMMON_COMPOSE_H typedef struct xkb_compose_table* (* PFN_xkb_compose_table_new_from_locale)(struct xkb_context*, const char*, enum xkb_compose_compile_flags); @@ -311,6 +315,7 @@ typedef struct _GLFWlibraryWayland int timerfd; short int keycodes[256]; short int scancodes[GLFW_KEY_LAST + 1]; + char keynames[GLFW_KEY_LAST + 1][5]; struct { void* handle; @@ -336,11 +341,13 @@ typedef struct _GLFWlibraryWayland PFN_xkb_keymap_unref keymap_unref; PFN_xkb_keymap_mod_get_index keymap_mod_get_index; PFN_xkb_keymap_key_repeats keymap_key_repeats; + PFN_xkb_keymap_key_get_syms_by_level keymap_key_get_syms_by_level; PFN_xkb_state_new state_new; PFN_xkb_state_unref state_unref; PFN_xkb_state_key_get_syms state_key_get_syms; PFN_xkb_state_update_mask state_update_mask; PFN_xkb_state_serialize_mods state_serialize_mods; + PFN_xkb_state_key_get_layout state_key_get_layout; #ifdef HAVE_XKBCOMMON_COMPOSE_H PFN_xkb_compose_table_new_from_locale compose_table_new_from_locale; diff --git a/src/wl_window.c b/src/wl_window.c index eab108ee..1ed4b079 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -1193,10 +1193,57 @@ void _glfwSetCursorModeWayland(_GLFWwindow* window, int mode) const char* _glfwGetScancodeNameWayland(int scancode) { - // TODO - _glfwInputError(GLFW_FEATURE_UNIMPLEMENTED, - "Wayland: Key names not yet implemented"); - return NULL; + if (scancode < 0 || scancode > 255 || + _glfw.wl.keycodes[scancode] == GLFW_KEY_UNKNOWN) + { + _glfwInputError(GLFW_INVALID_VALUE, + "Wayland: Invalid scancode %i", + scancode); + return NULL; + } + + const int key = _glfw.wl.keycodes[scancode]; + const xkb_keycode_t keycode = scancode + 8; + const xkb_layout_index_t layout = + xkb_state_key_get_layout(_glfw.wl.xkb.state, keycode); + if (layout == XKB_LAYOUT_INVALID) + { + _glfwInputError(GLFW_PLATFORM_ERROR, + "Wayland: Failed to retrieve layout for key name"); + return NULL; + } + + const xkb_keysym_t* keysyms = NULL; + xkb_keymap_key_get_syms_by_level(_glfw.wl.xkb.keymap, + keycode, + layout, + 0, + &keysyms); + if (keysyms == NULL) + { + _glfwInputError(GLFW_PLATFORM_ERROR, + "Wayland: Failed to retrieve keysym for key name"); + return NULL; + } + + const long codepoint = _glfwKeySym2Unicode(keysyms[0]); + if (codepoint == -1) + { + _glfwInputError(GLFW_PLATFORM_ERROR, + "Wayland: Failed to retrieve codepoint for key name"); + return NULL; + } + + const size_t count = _glfwEncodeUTF8(_glfw.wl.keynames[key], (unsigned int) codepoint); + if (count == 0) + { + _glfwInputError(GLFW_PLATFORM_ERROR, + "Wayland: Failed to encode codepoint for key name"); + return NULL; + } + + _glfw.wl.keynames[key][count] = '\0'; + return _glfw.wl.keynames[key]; } int _glfwGetKeyScancodeWayland(int key) From fe7be39793f993f9bf7480f2389bffad676199f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 30 Dec 2021 19:09:53 +0100 Subject: [PATCH 111/208] Clean up internal Unicode code point handling Call code points by their name and store them as uint32_t. --- src/init.c | 30 +++++++++++++++--------------- src/input.c | 2 +- src/internal.h | 4 ++-- src/win32_window.c | 4 ++-- src/wl_init.c | 9 ++++----- src/wl_window.c | 6 +++--- src/x11_window.c | 22 +++++++++++----------- src/xkb_unicode.c | 4 ++-- src/xkb_unicode.h | 4 +++- 9 files changed, 43 insertions(+), 42 deletions(-) diff --git a/src/init.c b/src/init.c index 1d4e7804..80f424a8 100644 --- a/src/init.c +++ b/src/init.c @@ -143,29 +143,29 @@ static void terminate(void) // Encode a Unicode code point to a UTF-8 stream // Based on cutef8 by Jeff Bezanson (Public Domain) // -size_t _glfwEncodeUTF8(char* s, unsigned int ch) +size_t _glfwEncodeUTF8(char* s, uint32_t codepoint) { size_t count = 0; - if (ch < 0x80) - s[count++] = (char) ch; - else if (ch < 0x800) + if (codepoint < 0x80) + s[count++] = (char) codepoint; + else if (codepoint < 0x800) { - s[count++] = (ch >> 6) | 0xc0; - s[count++] = (ch & 0x3f) | 0x80; + s[count++] = (codepoint >> 6) | 0xc0; + s[count++] = (codepoint & 0x3f) | 0x80; } - else if (ch < 0x10000) + else if (codepoint < 0x10000) { - s[count++] = (ch >> 12) | 0xe0; - s[count++] = ((ch >> 6) & 0x3f) | 0x80; - s[count++] = (ch & 0x3f) | 0x80; + s[count++] = (codepoint >> 12) | 0xe0; + s[count++] = ((codepoint >> 6) & 0x3f) | 0x80; + s[count++] = (codepoint & 0x3f) | 0x80; } - else if (ch < 0x110000) + else if (codepoint < 0x110000) { - s[count++] = (ch >> 18) | 0xf0; - s[count++] = ((ch >> 12) & 0x3f) | 0x80; - s[count++] = ((ch >> 6) & 0x3f) | 0x80; - s[count++] = (ch & 0x3f) | 0x80; + s[count++] = (codepoint >> 18) | 0xf0; + s[count++] = ((codepoint >> 12) & 0x3f) | 0x80; + s[count++] = ((codepoint >> 6) & 0x3f) | 0x80; + s[count++] = (codepoint & 0x3f) | 0x80; } return count; diff --git a/src/input.c b/src/input.c index 11716bd5..6a2c3e1d 100644 --- a/src/input.c +++ b/src/input.c @@ -295,7 +295,7 @@ void _glfwInputKey(_GLFWwindow* window, int key, int scancode, int action, int m // Notifies shared code of a Unicode codepoint input event // The 'plain' parameter determines whether to emit a regular character event // -void _glfwInputChar(_GLFWwindow* window, unsigned int codepoint, int mods, GLFWbool plain) +void _glfwInputChar(_GLFWwindow* window, uint32_t codepoint, int mods, GLFWbool plain) { if (codepoint < 32 || (codepoint > 126 && codepoint < 160)) return; diff --git a/src/internal.h b/src/internal.h index b28d41ab..f8548fa3 100644 --- a/src/internal.h +++ b/src/internal.h @@ -919,7 +919,7 @@ void _glfwInputWindowMonitor(_GLFWwindow* window, _GLFWmonitor* monitor); void _glfwInputKey(_GLFWwindow* window, int key, int scancode, int action, int mods); void _glfwInputChar(_GLFWwindow* window, - unsigned int codepoint, int mods, GLFWbool plain); + uint32_t codepoint, int mods, GLFWbool plain); void _glfwInputScroll(_GLFWwindow* window, double xoffset, double yoffset); void _glfwInputMouseClick(_GLFWwindow* window, int button, int action, int mods); void _glfwInputCursorPos(_GLFWwindow* window, double xpos, double ypos); @@ -995,7 +995,7 @@ GLFWbool _glfwInitVulkan(int mode); void _glfwTerminateVulkan(void); const char* _glfwGetVulkanResultString(VkResult result); -size_t _glfwEncodeUTF8(char* s, unsigned int ch); +size_t _glfwEncodeUTF8(char* s, uint32_t codepoint); char* _glfw_strdup(const char* source); float _glfw_fminf(float a, float b); diff --git a/src/win32_window.c b/src/win32_window.c index e03b8564..b3da6b2a 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -649,7 +649,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, window->win32.highSurrogate = (WCHAR) wParam; else { - unsigned int codepoint = 0; + uint32_t codepoint = 0; if (wParam >= 0xdc00 && wParam <= 0xdfff) { @@ -683,7 +683,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, return TRUE; } - _glfwInputChar(window, (unsigned int) wParam, getKeyMods(), GLFW_TRUE); + _glfwInputChar(window, (uint32_t) wParam, getKeyMods(), GLFW_TRUE); return 0; } diff --git a/src/wl_init.c b/src/wl_init.c index bd365fdf..e2bd2921 100644 --- a/src/wl_init.c +++ b/src/wl_init.c @@ -544,8 +544,7 @@ static xkb_keysym_t composeSymbol(xkb_keysym_t sym) static GLFWbool inputChar(_GLFWwindow* window, uint32_t key) { - uint32_t code, numSyms; - long cp; + uint32_t code, numSyms, codepoint; const xkb_keysym_t *syms; xkb_keysym_t sym; @@ -559,12 +558,12 @@ static GLFWbool inputChar(_GLFWwindow* window, uint32_t key) #else sym = syms[0]; #endif - cp = _glfwKeySym2Unicode(sym); - if (cp != -1) + codepoint = _glfwKeySym2Unicode(sym); + if (codepoint != GLFW_INVALID_CODEPOINT) { const int mods = _glfw.wl.xkb.modifiers; const int plain = !(mods & (GLFW_MOD_CONTROL | GLFW_MOD_ALT)); - _glfwInputChar(window, cp, mods, plain); + _glfwInputChar(window, codepoint, mods, plain); } } diff --git a/src/wl_window.c b/src/wl_window.c index 1ed4b079..48ffb7c2 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -1226,15 +1226,15 @@ const char* _glfwGetScancodeNameWayland(int scancode) return NULL; } - const long codepoint = _glfwKeySym2Unicode(keysyms[0]); - if (codepoint == -1) + const uint32_t codepoint = _glfwKeySym2Unicode(keysyms[0]); + if (codepoint == GLFW_INVALID_CODEPOINT) { _glfwInputError(GLFW_PLATFORM_ERROR, "Wayland: Failed to retrieve codepoint for key name"); return NULL; } - const size_t count = _glfwEncodeUTF8(_glfw.wl.keynames[key], (unsigned int) codepoint); + const size_t count = _glfwEncodeUTF8(_glfw.wl.keynames[key], codepoint); if (count == 0) { _glfwInputError(GLFW_PLATFORM_ERROR, diff --git a/src/x11_window.c b/src/x11_window.c index 96514c18..61e4fd6d 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -432,10 +432,10 @@ static char** parseUriList(char* text, int* count) // Decode a Unicode code point from a UTF-8 stream // Based on cutef8 by Jeff Bezanson (Public Domain) // -static unsigned int decodeUTF8(const char** s) +static uint32_t decodeUTF8(const char** s) { - unsigned int ch = 0, count = 0; - static const unsigned int offsets[] = + uint32_t codepoint = 0, count = 0; + static const uint32_t offsets[] = { 0x00000000u, 0x00003080u, 0x000e2080u, 0x03c82080u, 0xfa082080u, 0x82082080u @@ -443,13 +443,13 @@ static unsigned int decodeUTF8(const char** s) do { - ch = (ch << 6) + (unsigned char) **s; + codepoint = (codepoint << 6) + (unsigned char) **s; (*s)++; count++; } while ((**s & 0xc0) == 0x80); assert(count <= 6); - return ch - offsets[count - 1]; + return codepoint - offsets[count - 1]; } // Convert the specified Latin-1 string to UTF-8 @@ -1286,9 +1286,9 @@ static void processEvent(XEvent *event) _glfwInputKey(window, key, keycode, GLFW_PRESS, mods); - const long character = _glfwKeySym2Unicode(keysym); - if (character != -1) - _glfwInputChar(window, character, mods, plain); + const uint32_t codepoint = _glfwKeySym2Unicode(keysym); + if (codepoint != GLFW_INVALID_CODEPOINT) + _glfwInputChar(window, codepoint, mods, plain); } return; @@ -2868,11 +2868,11 @@ const char* _glfwGetScancodeNameX11(int scancode) if (keysym == NoSymbol) return NULL; - const long ch = _glfwKeySym2Unicode(keysym); - if (ch == -1) + const uint32_t codepoint = _glfwKeySym2Unicode(keysym); + if (codepoint == GLFW_INVALID_CODEPOINT) return NULL; - const size_t count = _glfwEncodeUTF8(_glfw.x11.keynames[key], (unsigned int) ch); + const size_t count = _glfwEncodeUTF8(_glfw.x11.keynames[key], codepoint); if (count == 0) return NULL; diff --git a/src/xkb_unicode.c b/src/xkb_unicode.c index 2772ea09..1b2482cd 100644 --- a/src/xkb_unicode.c +++ b/src/xkb_unicode.c @@ -907,7 +907,7 @@ static const struct codepair { // Convert XKB KeySym to Unicode // -long _glfwKeySym2Unicode(unsigned int keysym) +uint32_t _glfwKeySym2Unicode(unsigned int keysym) { int min = 0; int max = sizeof(keysymtab) / sizeof(struct codepair) - 1; @@ -937,6 +937,6 @@ long _glfwKeySym2Unicode(unsigned int keysym) } // No matching Unicode value found - return -1; + return GLFW_INVALID_CODEPOINT; } diff --git a/src/xkb_unicode.h b/src/xkb_unicode.h index 76d83ffd..b07408f6 100644 --- a/src/xkb_unicode.h +++ b/src/xkb_unicode.h @@ -24,5 +24,7 @@ // //======================================================================== -long _glfwKeySym2Unicode(unsigned int keysym); +#define GLFW_INVALID_CODEPOINT 0xffffffffu + +uint32_t _glfwKeySym2Unicode(unsigned int keysym); From b70259e52df8cf5b1773ae7f0b575a0d6107454e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 30 Dec 2021 19:49:06 +0100 Subject: [PATCH 112/208] Wayland: Clean up text input Adapt style and naming to match the rest of the project. --- src/wl_init.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/wl_init.c b/src/wl_init.c index e2bd2921..b1f98733 100644 --- a/src/wl_init.c +++ b/src/wl_init.c @@ -542,23 +542,19 @@ static xkb_keysym_t composeSymbol(xkb_keysym_t sym) } #endif -static GLFWbool inputChar(_GLFWwindow* window, uint32_t key) +static GLFWbool inputChar(_GLFWwindow* window, uint32_t scancode) { - uint32_t code, numSyms, codepoint; - const xkb_keysym_t *syms; - xkb_keysym_t sym; + const xkb_keysym_t* keysyms; + const xkb_keycode_t keycode = scancode + 8; - code = key + 8; - numSyms = xkb_state_key_get_syms(_glfw.wl.xkb.state, code, &syms); - - if (numSyms == 1) + if (xkb_state_key_get_syms(_glfw.wl.xkb.state, keycode, &keysyms) == 1) { #ifdef HAVE_XKBCOMMON_COMPOSE_H - sym = composeSymbol(syms[0]); + const xkb_keysym_t keysym = composeSymbol(keysyms[0]); #else - sym = syms[0]; + const xkb_keysym_t keysym = keysyms[0]; #endif - codepoint = _glfwKeySym2Unicode(sym); + const uint32_t codepoint = _glfwKeySym2Unicode(keysym); if (codepoint != GLFW_INVALID_CODEPOINT) { const int mods = _glfw.wl.xkb.modifiers; @@ -567,7 +563,7 @@ static GLFWbool inputChar(_GLFWwindow* window, uint32_t key) } } - return xkb_keymap_key_repeats(_glfw.wl.xkb.keymap, code); + return xkb_keymap_key_repeats(_glfw.wl.xkb.keymap, keycode); } static void keyboardHandleKey(void* data, From 293d19a1537e25d6a47c0e8fb080f94061f8d131 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 30 Dec 2021 20:02:45 +0100 Subject: [PATCH 113/208] Wayland: Require xkbcommon 0.5.0 or greater The Wayland backend now requires xkbcommon-compose, which was added in version 0.5.0. xkbcommon 0.5.0 was released in 2014. This removes the non-composing fallback path for text input. --- docs/compat.dox | 5 ++--- src/CMakeLists.txt | 6 +----- src/wl_init.c | 16 ---------------- src/wl_platform.h | 8 -------- 4 files changed, 3 insertions(+), 32 deletions(-) diff --git a/docs/compat.dox b/docs/compat.dox index 5b264b3f..989c4c19 100644 --- a/docs/compat.dox +++ b/docs/compat.dox @@ -104,9 +104,8 @@ integration by libwayland-egl, and keyboard handling by from wayland-protocols to provide additional features if the compositor supports them. -GLFW uses xkbcommon 0.5.0 to provide compose key support. When it has been -built against an older xkbcommon, the compose key will be disabled even if it -has been configured in the compositor. +GLFW uses xkbcommon 0.5.0 to provide key and text input support. Earlier +versions are not supported. GLFW uses the [xdg-shell protocol](https://cgit.freedesktop.org/wayland/wayland-protocols/tree/stable/xdg-shell/xdg-shell.xml) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 16cb1749..a07ca931 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -65,10 +65,6 @@ endif() if (GLFW_BUILD_WAYLAND) include(CheckIncludeFiles) include(CheckFunctionExists) - check_include_files(xkbcommon/xkbcommon-compose.h HAVE_XKBCOMMON_COMPOSE_H) - if (HAVE_XKBCOMMON_COMPOSE_H) - target_compile_definitions(glfw PRIVATE HAVE_XKBCOMMON_COMPOSE_H) - endif() check_function_exists(memfd_create HAVE_MEMFD_CREATE) if (HAVE_MEMFD_CREATE) target_compile_definitions(glfw PRIVATE HAVE_MEMFD_CREATE) @@ -173,7 +169,7 @@ if (GLFW_BUILD_WAYLAND) wayland-client>=0.2.7 wayland-cursor>=0.2.7 wayland-egl>=0.2.7 - xkbcommon) + xkbcommon>=0.5.0) target_include_directories(glfw PRIVATE ${Wayland_INCLUDE_DIRS}) diff --git a/src/wl_init.c b/src/wl_init.c index b1f98733..d9a70287 100644 --- a/src/wl_init.c +++ b/src/wl_init.c @@ -377,11 +377,8 @@ static void keyboardHandleKeymap(void* data, { struct xkb_keymap* keymap; struct xkb_state* state; - -#ifdef HAVE_XKBCOMMON_COMPOSE_H struct xkb_compose_table* composeTable; struct xkb_compose_state* composeState; -#endif char* mapStr; const char* locale; @@ -430,7 +427,6 @@ static void keyboardHandleKeymap(void* data, if (!locale) locale = "C"; -#ifdef HAVE_XKBCOMMON_COMPOSE_H composeTable = xkb_compose_table_new_from_locale(_glfw.wl.xkb.context, locale, XKB_COMPOSE_COMPILE_NO_FLAGS); @@ -450,7 +446,6 @@ static void keyboardHandleKeymap(void* data, _glfwInputError(GLFW_PLATFORM_ERROR, "Wayland: Failed to create XKB compose table"); } -#endif xkb_keymap_unref(_glfw.wl.xkb.keymap); xkb_state_unref(_glfw.wl.xkb.state); @@ -520,7 +515,6 @@ static int toGLFWKeyCode(uint32_t key) return GLFW_KEY_UNKNOWN; } -#ifdef HAVE_XKBCOMMON_COMPOSE_H static xkb_keysym_t composeSymbol(xkb_keysym_t sym) { if (sym == XKB_KEY_NoSymbol || !_glfw.wl.xkb.composeState) @@ -540,7 +534,6 @@ static xkb_keysym_t composeSymbol(xkb_keysym_t sym) return sym; } } -#endif static GLFWbool inputChar(_GLFWwindow* window, uint32_t scancode) { @@ -549,11 +542,7 @@ static GLFWbool inputChar(_GLFWwindow* window, uint32_t scancode) if (xkb_state_key_get_syms(_glfw.wl.xkb.state, keycode, &keysyms) == 1) { -#ifdef HAVE_XKBCOMMON_COMPOSE_H const xkb_keysym_t keysym = composeSymbol(keysyms[0]); -#else - const xkb_keysym_t keysym = keysyms[0]; -#endif const uint32_t codepoint = _glfwKeySym2Unicode(keysym); if (codepoint != GLFW_INVALID_CODEPOINT) { @@ -1299,8 +1288,6 @@ int _glfwInitWayland(void) _glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_state_serialize_mods"); _glfw.wl.xkb.state_key_get_layout = (PFN_xkb_state_key_get_layout) _glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_state_key_get_layout"); - -#ifdef HAVE_XKBCOMMON_COMPOSE_H _glfw.wl.xkb.compose_table_new_from_locale = (PFN_xkb_compose_table_new_from_locale) _glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_compose_table_new_from_locale"); _glfw.wl.xkb.compose_table_unref = (PFN_xkb_compose_table_unref) @@ -1315,7 +1302,6 @@ int _glfwInitWayland(void) _glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_compose_state_get_status"); _glfw.wl.xkb.compose_state_get_one_sym = (PFN_xkb_compose_state_get_one_sym) _glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_compose_state_get_one_sym"); -#endif _glfw.wl.registry = wl_display_get_registry(_glfw.wl.display); wl_registry_add_listener(_glfw.wl.registry, ®istryListener, NULL); @@ -1403,10 +1389,8 @@ void _glfwTerminateWayland(void) _glfw.wl.egl.handle = NULL; } -#ifdef HAVE_XKBCOMMON_COMPOSE_H if (_glfw.wl.xkb.composeState) xkb_compose_state_unref(_glfw.wl.xkb.composeState); -#endif if (_glfw.wl.xkb.keymap) xkb_keymap_unref(_glfw.wl.xkb.keymap); if (_glfw.wl.xkb.state) diff --git a/src/wl_platform.h b/src/wl_platform.h index e29f41b4..a26bd23e 100644 --- a/src/wl_platform.h +++ b/src/wl_platform.h @@ -26,9 +26,7 @@ #include #include -#ifdef HAVE_XKBCOMMON_COMPOSE_H #include -#endif typedef VkFlags VkWaylandSurfaceCreateFlagsKHR; @@ -184,7 +182,6 @@ typedef xkb_layout_index_t (* PFN_xkb_state_key_get_layout)(struct xkb_state*,xk #define xkb_state_serialize_mods _glfw.wl.xkb.state_serialize_mods #define xkb_state_key_get_layout _glfw.wl.xkb.state_key_get_layout -#ifdef HAVE_XKBCOMMON_COMPOSE_H typedef struct xkb_compose_table* (* PFN_xkb_compose_table_new_from_locale)(struct xkb_context*, const char*, enum xkb_compose_compile_flags); typedef void (* PFN_xkb_compose_table_unref)(struct xkb_compose_table*); typedef struct xkb_compose_state* (* PFN_xkb_compose_state_new)(struct xkb_compose_table*, enum xkb_compose_state_flags); @@ -199,7 +196,6 @@ typedef xkb_keysym_t (* PFN_xkb_compose_state_get_one_sym)(struct xkb_compose_st #define xkb_compose_state_feed _glfw.wl.xkb.compose_state_feed #define xkb_compose_state_get_status _glfw.wl.xkb.compose_state_get_status #define xkb_compose_state_get_one_sym _glfw.wl.xkb.compose_state_get_one_sym -#endif #define _GLFW_DECORATION_WIDTH 4 #define _GLFW_DECORATION_TOP 24 @@ -323,9 +319,7 @@ typedef struct _GLFWlibraryWayland struct xkb_keymap* keymap; struct xkb_state* state; -#ifdef HAVE_XKBCOMMON_COMPOSE_H struct xkb_compose_state* composeState; -#endif xkb_mod_mask_t controlMask; xkb_mod_mask_t altMask; @@ -349,7 +343,6 @@ typedef struct _GLFWlibraryWayland PFN_xkb_state_serialize_mods state_serialize_mods; PFN_xkb_state_key_get_layout state_key_get_layout; -#ifdef HAVE_XKBCOMMON_COMPOSE_H PFN_xkb_compose_table_new_from_locale compose_table_new_from_locale; PFN_xkb_compose_table_unref compose_table_unref; PFN_xkb_compose_state_new compose_state_new; @@ -357,7 +350,6 @@ typedef struct _GLFWlibraryWayland PFN_xkb_compose_state_feed compose_state_feed; PFN_xkb_compose_state_get_status compose_state_get_status; PFN_xkb_compose_state_get_one_sym compose_state_get_one_sym; -#endif } xkb; _GLFWwindow* pointerFocus; From bf995870052d5076ce80c4728eb6fd4054dd9742 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 30 Dec 2021 21:06:22 +0100 Subject: [PATCH 114/208] Wayland: Clean up key event handler Adapt style and naming to match the rest of the project. --- src/wl_init.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/src/wl_init.c b/src/wl_init.c index d9a70287..c57a7e73 100644 --- a/src/wl_init.c +++ b/src/wl_init.c @@ -559,42 +559,40 @@ static void keyboardHandleKey(void* data, struct wl_keyboard* keyboard, uint32_t serial, uint32_t time, - uint32_t key, + uint32_t scancode, uint32_t state) { - int keyCode; - int action; _GLFWwindow* window = _glfw.wl.keyboardFocus; - GLFWbool shouldRepeat; - struct itimerspec timer = {}; - if (!window) return; - keyCode = toGLFWKeyCode(key); - action = state == WL_KEYBOARD_KEY_STATE_PRESSED - ? GLFW_PRESS : GLFW_RELEASE; + const int key = toGLFWKeyCode(scancode); + const int action = + state == WL_KEYBOARD_KEY_STATE_PRESSED ? GLFW_PRESS : GLFW_RELEASE; _glfw.wl.serial = serial; - _glfwInputKey(window, keyCode, key, action, - _glfw.wl.xkb.modifiers); + _glfwInputKey(window, key, scancode, action, _glfw.wl.xkb.modifiers); + + struct itimerspec timer = {}; if (action == GLFW_PRESS) { - shouldRepeat = inputChar(window, key); + const GLFWbool shouldRepeat = inputChar(window, scancode); if (shouldRepeat && _glfw.wl.keyboardRepeatRate > 0) { - _glfw.wl.keyboardLastKey = keyCode; - _glfw.wl.keyboardLastScancode = key; + _glfw.wl.keyboardLastKey = key; + _glfw.wl.keyboardLastScancode = scancode; if (_glfw.wl.keyboardRepeatRate > 1) timer.it_interval.tv_nsec = 1000000000 / _glfw.wl.keyboardRepeatRate; else timer.it_interval.tv_sec = 1; + timer.it_value.tv_sec = _glfw.wl.keyboardRepeatDelay / 1000; timer.it_value.tv_nsec = (_glfw.wl.keyboardRepeatDelay % 1000) * 1000000; } } + timerfd_settime(_glfw.wl.timerfd, 0, &timer, NULL); } From 1a7da42e6ebaa4e8eeffb693c32c8d36d54ddf6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 30 Dec 2021 21:09:23 +0100 Subject: [PATCH 115/208] Wayland: Fix text input not following key repeat The manual key repeat implementation did not call text input. --- README.md | 1 + src/wl_init.c | 4 ++-- src/wl_platform.h | 1 + src/wl_window.c | 2 ++ 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 06108a86..4a3fb85c 100644 --- a/README.md +++ b/README.md @@ -288,6 +288,7 @@ information on what to include when reporting a bug. - [Wayland] Bugfix: Showing a hidden window did not emit a window refresh event - [Wayland] Bugfix: Full screen window creation did not ignore `GLFW_VISIBLE` - [Wayland] Bugfix: Some keys were reported as wrong key or `GLFW_KEY_UNKNOWN` + - [Wayland] Bugfix: Text input did not repeat along with key repeat - [POSIX] Removed use of deprecated function `gettimeofday` - [POSIX] Bugfix: `CLOCK_MONOTONIC` was not correctly tested for or enabled - [WGL] Disabled the DWM swap interval hack for Windows 8 and later (#1072) diff --git a/src/wl_init.c b/src/wl_init.c index c57a7e73..83cd7aca 100644 --- a/src/wl_init.c +++ b/src/wl_init.c @@ -535,7 +535,7 @@ static xkb_keysym_t composeSymbol(xkb_keysym_t sym) } } -static GLFWbool inputChar(_GLFWwindow* window, uint32_t scancode) +GLFWbool _glfwInputTextWayland(_GLFWwindow* window, uint32_t scancode) { const xkb_keysym_t* keysyms; const xkb_keycode_t keycode = scancode + 8; @@ -577,7 +577,7 @@ static void keyboardHandleKey(void* data, if (action == GLFW_PRESS) { - const GLFWbool shouldRepeat = inputChar(window, scancode); + const GLFWbool shouldRepeat = _glfwInputTextWayland(window, scancode); if (shouldRepeat && _glfw.wl.keyboardRepeatRate > 0) { diff --git a/src/wl_platform.h b/src/wl_platform.h index a26bd23e..7565411b 100644 --- a/src/wl_platform.h +++ b/src/wl_platform.h @@ -495,4 +495,5 @@ GLFWbool _glfwGetGammaRampWayland(_GLFWmonitor* monitor, GLFWgammaramp* ramp); void _glfwSetGammaRampWayland(_GLFWmonitor* monitor, const GLFWgammaramp* ramp); void _glfwAddOutputWayland(uint32_t name, uint32_t version); +GLFWbool _glfwInputTextWayland(_GLFWwindow* window, uint32_t scancode); diff --git a/src/wl_window.c b/src/wl_window.c index 48ffb7c2..b2aa1800 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -767,6 +767,8 @@ static void handleEvents(int timeout) _glfw.wl.keyboardLastScancode, GLFW_PRESS, _glfw.wl.xkb.modifiers); + _glfwInputTextWayland(_glfw.wl.keyboardFocus, + _glfw.wl.keyboardLastScancode); } } } From 0ce611958ee6fe9ddbd799986711759c9156566a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 31 Dec 2021 00:19:08 +0100 Subject: [PATCH 116/208] Wayland: Clean up key translation Adapt style and naming to match the rest of the project. --- src/wl_init.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/wl_init.c b/src/wl_init.c index 83cd7aca..2f138578 100644 --- a/src/wl_init.c +++ b/src/wl_init.c @@ -507,10 +507,10 @@ static void keyboardHandleLeave(void* data, _glfwInputWindowFocus(window, GLFW_FALSE); } -static int toGLFWKeyCode(uint32_t key) +static int translateKey(uint32_t scancode) { - if (key < sizeof(_glfw.wl.keycodes) / sizeof(_glfw.wl.keycodes[0])) - return _glfw.wl.keycodes[key]; + if (scancode < sizeof(_glfw.wl.keycodes) / sizeof(_glfw.wl.keycodes[0])) + return _glfw.wl.keycodes[scancode]; return GLFW_KEY_UNKNOWN; } @@ -566,7 +566,7 @@ static void keyboardHandleKey(void* data, if (!window) return; - const int key = toGLFWKeyCode(scancode); + const int key = translateKey(scancode); const int action = state == WL_KEYBOARD_KEY_STATE_PRESSED ? GLFW_PRESS : GLFW_RELEASE; From df8d7bc892937a8b0f7c604c92a9f64f383cf48c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 31 Dec 2021 00:19:58 +0100 Subject: [PATCH 117/208] Wayland: Clean up modifier key event handler Adapt style and naming to match the rest of the project. --- src/wl_init.c | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/src/wl_init.c b/src/wl_init.c index 2f138578..e7756385 100644 --- a/src/wl_init.c +++ b/src/wl_init.c @@ -604,9 +604,6 @@ static void keyboardHandleModifiers(void* data, uint32_t modsLocked, uint32_t group) { - xkb_mod_mask_t mask; - unsigned int modifiers = 0; - _glfw.wl.serial = serial; if (!_glfw.wl.xkb.keymap) @@ -620,24 +617,29 @@ static void keyboardHandleModifiers(void* data, 0, group); - mask = xkb_state_serialize_mods(_glfw.wl.xkb.state, - XKB_STATE_MODS_DEPRESSED | - XKB_STATE_LAYOUT_DEPRESSED | - XKB_STATE_MODS_LATCHED | - XKB_STATE_LAYOUT_LATCHED); + const xkb_mod_mask_t mask = + xkb_state_serialize_mods(_glfw.wl.xkb.state, + XKB_STATE_MODS_DEPRESSED | + XKB_STATE_LAYOUT_DEPRESSED | + XKB_STATE_MODS_LATCHED | + XKB_STATE_LAYOUT_LATCHED); + + unsigned int mods = 0; + if (mask & _glfw.wl.xkb.controlMask) - modifiers |= GLFW_MOD_CONTROL; + mods |= GLFW_MOD_CONTROL; if (mask & _glfw.wl.xkb.altMask) - modifiers |= GLFW_MOD_ALT; + mods |= GLFW_MOD_ALT; if (mask & _glfw.wl.xkb.shiftMask) - modifiers |= GLFW_MOD_SHIFT; + mods |= GLFW_MOD_SHIFT; if (mask & _glfw.wl.xkb.superMask) - modifiers |= GLFW_MOD_SUPER; + mods |= GLFW_MOD_SUPER; if (mask & _glfw.wl.xkb.capsLockMask) - modifiers |= GLFW_MOD_CAPS_LOCK; + mods |= GLFW_MOD_CAPS_LOCK; if (mask & _glfw.wl.xkb.numLockMask) - modifiers |= GLFW_MOD_NUM_LOCK; - _glfw.wl.xkb.modifiers = modifiers; + mods |= GLFW_MOD_NUM_LOCK; + + _glfw.wl.xkb.modifiers = mods; } #ifdef WL_KEYBOARD_REPEAT_INFO_SINCE_VERSION From 7f6aa587f8a0640b055133eddf09c9a652c94234 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 2 Feb 2022 19:20:32 +0100 Subject: [PATCH 118/208] Cocoa: Fix deprecation warning for kUTTypeURL We switched to kUTTypeURL when NSURLPboardType was deprecated, as the official replacement symbol NSPasteboardTypeURL was not available on every version of macOS supported by GLFW. kUTTypeURL has now also been deprecated. This commit moves to a compile-time choice between NSURLPboardType and NSPasteboardTypeURL depending on the minimum targeted macOS version. Fixes #2003 --- CONTRIBUTORS.md | 1 + README.md | 1 + src/cocoa_platform.h | 4 ++++ src/cocoa_window.m | 4 +--- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 1bfc5bc5..cb9b0d58 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -183,6 +183,7 @@ video tutorials. - Ali Sherief - Yoshiki Shibukawa - Dmitri Shuralyov + - Daniel Sieger - Daniel Skorupski - Anthony Smith - Bradley Smith diff --git a/README.md b/README.md index 4a3fb85c..7ffd4850 100644 --- a/README.md +++ b/README.md @@ -234,6 +234,7 @@ information on what to include when reporting a bug. - [Cocoa] Bugfix: Moving the cursor programmatically would freeze it for a fraction of a second (#1962) - [Cocoa] Bugfix: `kIOMasterPortDefault` was deprecated in macOS 12.0 (#1980) + - [Cocoa] Bugfix: `kUTTypeURL` was deprecated in macOS 12.0 (#2003) - [X11] Bugfix: The CMake files did not check for the XInput headers (#1480) - [X11] Bugfix: Key names were not updated when the keyboard layout changed (#1462,#1528) diff --git a/src/cocoa_platform.h b/src/cocoa_platform.h index 67c1a3cc..9d88ac4f 100644 --- a/src/cocoa_platform.h +++ b/src/cocoa_platform.h @@ -70,6 +70,10 @@ typedef void* id; #define NSWindowStyleMaskTitled NSTitledWindowMask #endif +#if MAC_OS_X_VERSION_MIN_REQUIRED < 101300 + #define NSPasteboardTypeURL NSURLPboardType +#endif + typedef VkFlags VkMacOSSurfaceCreateFlagsMVK; typedef VkFlags VkMetalSurfaceCreateFlagsEXT; diff --git a/src/cocoa_window.m b/src/cocoa_window.m index 660bbd31..e461b267 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -361,9 +361,7 @@ static const NSRange kEmptyRange = { NSNotFound, 0 }; markedText = [[NSMutableAttributedString alloc] init]; [self updateTrackingAreas]; - // NOTE: kUTTypeURL corresponds to NSPasteboardTypeURL but is available - // on 10.7 without having been deprecated yet - [self registerForDraggedTypes:@[(__bridge NSString*) kUTTypeURL]]; + [self registerForDraggedTypes:@[NSPasteboardTypeURL]]; } return self; From e023618daabd43849cfc7ac4610896dc8e14be57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 2 Feb 2022 21:49:06 +0100 Subject: [PATCH 119/208] Remove Doxyfile tag deprecated by Doxygen 1.9.3 --- docs/Doxyfile.in | 9 --------- 1 file changed, 9 deletions(-) diff --git a/docs/Doxyfile.in b/docs/Doxyfile.in index ef711cd7..812eec5d 100644 --- a/docs/Doxyfile.in +++ b/docs/Doxyfile.in @@ -2167,15 +2167,6 @@ EXTERNAL_PAGES = YES # Configuration options related to the dot tool #--------------------------------------------------------------------------- -# If the CLASS_DIAGRAMS tag is set to YES, doxygen will generate a class diagram -# (in HTML and LaTeX) for classes with base or super classes. Setting the tag to -# NO turns the diagrams off. Note that this option also works with HAVE_DOT -# disabled, but it is recommended to install and use dot, since it yields more -# powerful graphs. -# The default value is: YES. - -CLASS_DIAGRAMS = YES - # You can include diagrams made with dia in doxygen documentation. Doxygen will # then run dia to produce the diagram and insert it in the documentation. The # DIA_PATH tag allows you to specify the directory where the dia binary resides. From 97da62a027794d9ff0f4512268cb9a73a8fb5073 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 2 Feb 2022 22:49:55 +0100 Subject: [PATCH 120/208] Cocoa: Clarify comments on compatibility macros --- src/cocoa_platform.h | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/cocoa_platform.h b/src/cocoa_platform.h index 9d88ac4f..9259b195 100644 --- a/src/cocoa_platform.h +++ b/src/cocoa_platform.h @@ -42,16 +42,15 @@ typedef void* id; #endif // NOTE: Many Cocoa enum values have been renamed and we need to build across -// SDK versions where one is unavailable or the other deprecated -// We use the newer names in code and these macros to handle compatibility +// SDK versions where one is unavailable or deprecated. +// We use the newer names in code and replace them with the older names if +// the base SDK does not provide the newer names. + #if MAC_OS_X_VERSION_MAX_ALLOWED < 101400 #define NSOpenGLContextParameterSwapInterval NSOpenGLCPSwapInterval #define NSOpenGLContextParameterSurfaceOpacity NSOpenGLCPSurfaceOpacity #endif -// NOTE: Many Cocoa enum values have been renamed and we need to build across -// SDK versions where one is unavailable or the other deprecated -// We use the newer names in code and these macros to handle compatibility #if MAC_OS_X_VERSION_MAX_ALLOWED < 101200 #define NSBitmapFormatAlphaNonpremultiplied NSAlphaNonpremultipliedBitmapFormat #define NSEventMaskAny NSAnyEventMask @@ -70,6 +69,11 @@ typedef void* id; #define NSWindowStyleMaskTitled NSTitledWindowMask #endif +// NOTE: Many Cocoa dynamically linked constants have been renamed and we need +// to build across SDK versions where one is unavailable or deprecated. +// We use the newer names in code and replace them with the older names if +// the deployment target is older than the newer names. + #if MAC_OS_X_VERSION_MIN_REQUIRED < 101300 #define NSPasteboardTypeURL NSURLPboardType #endif From a28adba06acc4e5a09e836bd5d4569636c5d3f65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 11 Feb 2022 12:37:38 +0100 Subject: [PATCH 121/208] Wayland: Fix multiple copies of single constant --- src/wl_init.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/wl_init.c b/src/wl_init.c index e7756385..d4a44464 100644 --- a/src/wl_init.c +++ b/src/wl_init.c @@ -1367,14 +1367,15 @@ int _glfwInitWayland(void) wl_data_device_manager_get_data_device(_glfw.wl.dataDeviceManager, _glfw.wl.seat); wl_data_device_add_listener(_glfw.wl.dataDevice, &dataDeviceListener, NULL); - _glfw.wl.clipboardString = _glfw_calloc(4096, 1); + + _glfw.wl.clipboardSize = 4096; + _glfw.wl.clipboardString = _glfw_calloc(_glfw.wl.clipboardSize, 1); if (!_glfw.wl.clipboardString) { _glfwInputError(GLFW_PLATFORM_ERROR, "Wayland: Unable to allocate clipboard memory"); return GLFW_FALSE; } - _glfw.wl.clipboardSize = 4096; } return GLFW_TRUE; From 4a68926bfd999c835009429e6452b2c271252959 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 11 Feb 2022 12:40:21 +0100 Subject: [PATCH 122/208] Wayland: Remove unnecessary NULL checks It is fine to pass NULL to _glfw_free. --- src/wl_init.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/wl_init.c b/src/wl_init.c index d4a44464..769cc084 100644 --- a/src/wl_init.c +++ b/src/wl_init.c @@ -1461,9 +1461,7 @@ void _glfwTerminateWayland(void) if (_glfw.wl.cursorTimerfd >= 0) close(_glfw.wl.cursorTimerfd); - if (_glfw.wl.clipboardString) - _glfw_free(_glfw.wl.clipboardString); - if (_glfw.wl.clipboardSendString) - _glfw_free(_glfw.wl.clipboardSendString); + _glfw_free(_glfw.wl.clipboardString); + _glfw_free(_glfw.wl.clipboardSendString); } From 152f50cd0149ace9242971bf1bae3a5abde24951 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 11 Feb 2022 12:36:35 +0100 Subject: [PATCH 123/208] Wayland: Fix error type for allocation failure --- src/wl_init.c | 2 +- src/wl_window.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wl_init.c b/src/wl_init.c index 769cc084..e4ae6666 100644 --- a/src/wl_init.c +++ b/src/wl_init.c @@ -1372,7 +1372,7 @@ int _glfwInitWayland(void) _glfw.wl.clipboardString = _glfw_calloc(_glfw.wl.clipboardSize, 1); if (!_glfw.wl.clipboardString) { - _glfwInputError(GLFW_PLATFORM_ERROR, + _glfwInputError(GLFW_OUT_OF_MEMORY, "Wayland: Unable to allocate clipboard memory"); return GLFW_FALSE; } diff --git a/src/wl_window.c b/src/wl_window.c index b2aa1800..0def0746 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -1675,7 +1675,7 @@ static GLFWbool growClipboardString(void) clipboard = _glfw_realloc(clipboard, _glfw.wl.clipboardSize * 2); if (!clipboard) { - _glfwInputError(GLFW_PLATFORM_ERROR, + _glfwInputError(GLFW_OUT_OF_MEMORY, "Wayland: Impossible to grow clipboard string"); return GLFW_FALSE; } From 20adc18aa587b75867775942d25356014e11fde9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Sat, 1 Jan 2022 20:18:33 +0100 Subject: [PATCH 124/208] Wayland: Clean up monitor scale update --- src/wl_window.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/wl_window.c b/src/wl_window.c index 0def0746..367acacc 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -345,26 +345,25 @@ static void resizeWindow(_GLFWwindow* window) static void checkScaleChange(_GLFWwindow* window) { - int scale = 1; - int monitorScale; - // Check if we will be able to set the buffer scale or not. if (_glfw.wl.compositorVersion < 3) return; // Get the scale factor from the highest scale monitor. - for (int i = 0; i < window->wl.monitorsCount; ++i) + int maxScale = 1; + + for (int i = 0; i < window->wl.monitorsCount; i++) { - monitorScale = window->wl.monitors[i]->wl.scale; - if (scale < monitorScale) - scale = monitorScale; + const int scale = window->wl.monitors[i]->wl.scale; + if (maxScale < scale) + maxScale = scale; } // Only change the framebuffer size if the scale changed. - if (scale != window->wl.scale) + if (window->wl.scale != maxScale) { - window->wl.scale = scale; - wl_surface_set_buffer_scale(window->wl.surface, scale); + window->wl.scale = maxScale; + wl_surface_set_buffer_scale(window->wl.surface, maxScale); resizeWindow(window); } } From 2e656afc4972827930e845c3124a08c42ac5d564 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 6 Jan 2022 07:07:53 +0100 Subject: [PATCH 125/208] GLX: Fix context creation failing unnecessarily Regression introduced with 3bb5c459d63d7cf9c990213e39303d9ba5eaebcc. --- README.md | 1 + src/glx_context.c | 12 ++++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 7ffd4850..9543919e 100644 --- a/README.md +++ b/README.md @@ -304,6 +304,7 @@ information on what to include when reporting a bug. - [EGL] Added ANGLE backend selection via `EGL_ANGLE_platform_angle` extension (#1380) - [EGL] Bugfix: The `GLFW_DOUBLEBUFFER` context attribute was ignored (#1843) + - [GLX] Bugfix: Context creation failed if GLX 1.4 was not exported by GLX library ## Contact diff --git a/src/glx_context.c b/src/glx_context.c index 31cd34dc..00f38ac3 100644 --- a/src/glx_context.c +++ b/src/glx_context.c @@ -308,10 +308,6 @@ GLFWbool _glfwInitGLX(void) _glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXCreateWindow"); _glfw.glx.DestroyWindow = (PFNGLXDESTROYWINDOWPROC) _glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXDestroyWindow"); - _glfw.glx.GetProcAddress = (PFNGLXGETPROCADDRESSPROC) - _glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXGetProcAddress"); - _glfw.glx.GetProcAddressARB = (PFNGLXGETPROCADDRESSPROC) - _glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXGetProcAddressARB"); _glfw.glx.GetVisualFromFBConfig = (PFNGLXGETVISUALFROMFBCONFIGPROC) _glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXGetVisualFromFBConfig"); @@ -327,8 +323,6 @@ GLFWbool _glfwInitGLX(void) !_glfw.glx.CreateNewContext || !_glfw.glx.CreateWindow || !_glfw.glx.DestroyWindow || - !_glfw.glx.GetProcAddress || - !_glfw.glx.GetProcAddressARB || !_glfw.glx.GetVisualFromFBConfig) { _glfwInputError(GLFW_PLATFORM_ERROR, @@ -336,6 +330,12 @@ GLFWbool _glfwInitGLX(void) return GLFW_FALSE; } + // NOTE: Unlike GLX 1.3 entry points these are not required to be present + _glfw.glx.GetProcAddress = (PFNGLXGETPROCADDRESSPROC) + _glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXGetProcAddress"); + _glfw.glx.GetProcAddressARB = (PFNGLXGETPROCADDRESSPROC) + _glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXGetProcAddressARB"); + if (!glXQueryExtension(_glfw.x11.display, &_glfw.glx.errorBase, &_glfw.glx.eventBase)) From 789d2924c0f865bbba6df3c7097199d1e2f2ecf7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 7 Jan 2022 11:51:12 +0100 Subject: [PATCH 126/208] Formatting Make it clear that context attribute helper macros are macros. --- src/egl_context.c | 42 +++++++------- src/glx_context.c | 32 +++++------ src/nsgl_context.m | 44 +++++++-------- src/osmesa_context.c | 22 ++++---- src/wgl_context.c | 130 +++++++++++++++++++++---------------------- 5 files changed, 135 insertions(+), 135 deletions(-) diff --git a/src/egl_context.c b/src/egl_context.c index 89ea78fa..963a59d6 100644 --- a/src/egl_context.c +++ b/src/egl_context.c @@ -506,7 +506,7 @@ void _glfwTerminateEGL(void) } } -#define setAttrib(a, v) \ +#define SET_ATTRIB(a, v) \ { \ assert(((size_t) index + 1) < sizeof(attribs) / sizeof(attribs[0])); \ attribs[index++] = a; \ @@ -584,13 +584,13 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window, { if (ctxconfig->robustness == GLFW_NO_RESET_NOTIFICATION) { - setAttrib(EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR, - EGL_NO_RESET_NOTIFICATION_KHR); + SET_ATTRIB(EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR, + EGL_NO_RESET_NOTIFICATION_KHR); } else if (ctxconfig->robustness == GLFW_LOSE_CONTEXT_ON_RESET) { - setAttrib(EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR, - EGL_LOSE_CONTEXT_ON_RESET_KHR); + SET_ATTRIB(EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR, + EGL_LOSE_CONTEXT_ON_RESET_KHR); } flags |= EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR; @@ -599,42 +599,42 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window, if (ctxconfig->noerror) { if (_glfw.egl.KHR_create_context_no_error) - setAttrib(EGL_CONTEXT_OPENGL_NO_ERROR_KHR, GLFW_TRUE); + SET_ATTRIB(EGL_CONTEXT_OPENGL_NO_ERROR_KHR, GLFW_TRUE); } if (ctxconfig->major != 1 || ctxconfig->minor != 0) { - setAttrib(EGL_CONTEXT_MAJOR_VERSION_KHR, ctxconfig->major); - setAttrib(EGL_CONTEXT_MINOR_VERSION_KHR, ctxconfig->minor); + SET_ATTRIB(EGL_CONTEXT_MAJOR_VERSION_KHR, ctxconfig->major); + SET_ATTRIB(EGL_CONTEXT_MINOR_VERSION_KHR, ctxconfig->minor); } if (mask) - setAttrib(EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR, mask); + SET_ATTRIB(EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR, mask); if (flags) - setAttrib(EGL_CONTEXT_FLAGS_KHR, flags); + SET_ATTRIB(EGL_CONTEXT_FLAGS_KHR, flags); } else { if (ctxconfig->client == GLFW_OPENGL_ES_API) - setAttrib(EGL_CONTEXT_CLIENT_VERSION, ctxconfig->major); + SET_ATTRIB(EGL_CONTEXT_CLIENT_VERSION, ctxconfig->major); } if (_glfw.egl.KHR_context_flush_control) { if (ctxconfig->release == GLFW_RELEASE_BEHAVIOR_NONE) { - setAttrib(EGL_CONTEXT_RELEASE_BEHAVIOR_KHR, - EGL_CONTEXT_RELEASE_BEHAVIOR_NONE_KHR); + SET_ATTRIB(EGL_CONTEXT_RELEASE_BEHAVIOR_KHR, + EGL_CONTEXT_RELEASE_BEHAVIOR_NONE_KHR); } else if (ctxconfig->release == GLFW_RELEASE_BEHAVIOR_FLUSH) { - setAttrib(EGL_CONTEXT_RELEASE_BEHAVIOR_KHR, - EGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_KHR); + SET_ATTRIB(EGL_CONTEXT_RELEASE_BEHAVIOR_KHR, + EGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_KHR); } } - setAttrib(EGL_NONE, EGL_NONE); + SET_ATTRIB(EGL_NONE, EGL_NONE); window->context.egl.handle = eglCreateContext(_glfw.egl.display, config, share, attribs); @@ -653,16 +653,16 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window, if (fbconfig->sRGB) { if (_glfw.egl.KHR_gl_colorspace) - setAttrib(EGL_GL_COLORSPACE_KHR, EGL_GL_COLORSPACE_SRGB_KHR); + SET_ATTRIB(EGL_GL_COLORSPACE_KHR, EGL_GL_COLORSPACE_SRGB_KHR); } if (!fbconfig->doublebuffer) - setAttrib(EGL_RENDER_BUFFER, EGL_SINGLE_BUFFER); + SET_ATTRIB(EGL_RENDER_BUFFER, EGL_SINGLE_BUFFER); if (_glfw.egl.EXT_present_opaque) - setAttrib(EGL_PRESENT_OPAQUE_EXT, !fbconfig->transparent); + SET_ATTRIB(EGL_PRESENT_OPAQUE_EXT, !fbconfig->transparent); - setAttrib(EGL_NONE, EGL_NONE); + SET_ATTRIB(EGL_NONE, EGL_NONE); native = _glfw.platform.getEGLNativeWindow(window); // HACK: ANGLE does not implement eglCreatePlatformWindowSurfaceEXT @@ -782,7 +782,7 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window, return GLFW_TRUE; } -#undef setAttrib +#undef SET_ATTRIB // Returns the Visual and depth of the chosen EGLConfig // diff --git a/src/glx_context.c b/src/glx_context.c index 00f38ac3..ced9c88f 100644 --- a/src/glx_context.c +++ b/src/glx_context.c @@ -435,7 +435,7 @@ void _glfwTerminateGLX(void) } } -#define setAttrib(a, v) \ +#define SET_ATTRIB(a, v) \ { \ assert(((size_t) index + 1) < sizeof(attribs) / sizeof(attribs[0])); \ attribs[index++] = a; \ @@ -523,13 +523,13 @@ GLFWbool _glfwCreateContextGLX(_GLFWwindow* window, { if (ctxconfig->robustness == GLFW_NO_RESET_NOTIFICATION) { - setAttrib(GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB, - GLX_NO_RESET_NOTIFICATION_ARB); + SET_ATTRIB(GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB, + GLX_NO_RESET_NOTIFICATION_ARB); } else if (ctxconfig->robustness == GLFW_LOSE_CONTEXT_ON_RESET) { - setAttrib(GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB, - GLX_LOSE_CONTEXT_ON_RESET_ARB); + SET_ATTRIB(GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB, + GLX_LOSE_CONTEXT_ON_RESET_ARB); } flags |= GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB; @@ -542,13 +542,13 @@ GLFWbool _glfwCreateContextGLX(_GLFWwindow* window, { if (ctxconfig->release == GLFW_RELEASE_BEHAVIOR_NONE) { - setAttrib(GLX_CONTEXT_RELEASE_BEHAVIOR_ARB, - GLX_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB); + SET_ATTRIB(GLX_CONTEXT_RELEASE_BEHAVIOR_ARB, + GLX_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB); } else if (ctxconfig->release == GLFW_RELEASE_BEHAVIOR_FLUSH) { - setAttrib(GLX_CONTEXT_RELEASE_BEHAVIOR_ARB, - GLX_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB); + SET_ATTRIB(GLX_CONTEXT_RELEASE_BEHAVIOR_ARB, + GLX_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB); } } } @@ -556,7 +556,7 @@ GLFWbool _glfwCreateContextGLX(_GLFWwindow* window, if (ctxconfig->noerror) { if (_glfw.glx.ARB_create_context_no_error) - setAttrib(GLX_CONTEXT_OPENGL_NO_ERROR_ARB, GLFW_TRUE); + SET_ATTRIB(GLX_CONTEXT_OPENGL_NO_ERROR_ARB, GLFW_TRUE); } // NOTE: Only request an explicitly versioned context when necessary, as @@ -564,17 +564,17 @@ GLFWbool _glfwCreateContextGLX(_GLFWwindow* window, // highest version supported by the driver if (ctxconfig->major != 1 || ctxconfig->minor != 0) { - setAttrib(GLX_CONTEXT_MAJOR_VERSION_ARB, ctxconfig->major); - setAttrib(GLX_CONTEXT_MINOR_VERSION_ARB, ctxconfig->minor); + SET_ATTRIB(GLX_CONTEXT_MAJOR_VERSION_ARB, ctxconfig->major); + SET_ATTRIB(GLX_CONTEXT_MINOR_VERSION_ARB, ctxconfig->minor); } if (mask) - setAttrib(GLX_CONTEXT_PROFILE_MASK_ARB, mask); + SET_ATTRIB(GLX_CONTEXT_PROFILE_MASK_ARB, mask); if (flags) - setAttrib(GLX_CONTEXT_FLAGS_ARB, flags); + SET_ATTRIB(GLX_CONTEXT_FLAGS_ARB, flags); - setAttrib(None, None); + SET_ATTRIB(None, None); window->context.glx.handle = _glfw.glx.CreateContextAttribsARB(_glfw.x11.display, @@ -631,7 +631,7 @@ GLFWbool _glfwCreateContextGLX(_GLFWwindow* window, return GLFW_TRUE; } -#undef setAttrib +#undef SET_ATTRIB // Returns the Visual and depth of the chosen GLXFBConfig // diff --git a/src/nsgl_context.m b/src/nsgl_context.m index f85ef67b..fc1f7521 100644 --- a/src/nsgl_context.m +++ b/src/nsgl_context.m @@ -188,45 +188,45 @@ GLFWbool _glfwCreateContextNSGL(_GLFWwindow* window, // No-error contexts (GL_KHR_no_error) are not yet supported by macOS but // are not a hard constraint, so ignore and continue -#define addAttrib(a) \ +#define ADD_ATTRIB(a) \ { \ assert((size_t) index < sizeof(attribs) / sizeof(attribs[0])); \ attribs[index++] = a; \ } -#define setAttrib(a, v) { addAttrib(a); addAttrib(v); } +#define SET_ATTRIB(a, v) { ADD_ATTRIB(a); ADD_ATTRIB(v); } NSOpenGLPixelFormatAttribute attribs[40]; int index = 0; - addAttrib(NSOpenGLPFAAccelerated); - addAttrib(NSOpenGLPFAClosestPolicy); + ADD_ATTRIB(NSOpenGLPFAAccelerated); + ADD_ATTRIB(NSOpenGLPFAClosestPolicy); if (ctxconfig->nsgl.offline) { - addAttrib(NSOpenGLPFAAllowOfflineRenderers); + ADD_ATTRIB(NSOpenGLPFAAllowOfflineRenderers); // NOTE: This replaces the NSSupportsAutomaticGraphicsSwitching key in // Info.plist for unbundled applications // HACK: This assumes that NSOpenGLPixelFormat will remain // a straightforward wrapper of its CGL counterpart - addAttrib(kCGLPFASupportsAutomaticGraphicsSwitching); + ADD_ATTRIB(kCGLPFASupportsAutomaticGraphicsSwitching); } #if MAC_OS_X_VERSION_MAX_ALLOWED >= 101000 if (ctxconfig->major >= 4) { - setAttrib(NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion4_1Core); + SET_ATTRIB(NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion4_1Core); } else #endif /*MAC_OS_X_VERSION_MAX_ALLOWED*/ if (ctxconfig->major >= 3) { - setAttrib(NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion3_2Core); + SET_ATTRIB(NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion3_2Core); } if (ctxconfig->major <= 2) { if (fbconfig->auxBuffers != GLFW_DONT_CARE) - setAttrib(NSOpenGLPFAAuxBuffers, fbconfig->auxBuffers); + SET_ATTRIB(NSOpenGLPFAAuxBuffers, fbconfig->auxBuffers); if (fbconfig->accumRedBits != GLFW_DONT_CARE && fbconfig->accumGreenBits != GLFW_DONT_CARE && @@ -238,7 +238,7 @@ GLFWbool _glfwCreateContextNSGL(_GLFWwindow* window, fbconfig->accumBlueBits + fbconfig->accumAlphaBits; - setAttrib(NSOpenGLPFAAccumSize, accumBits); + SET_ATTRIB(NSOpenGLPFAAccumSize, accumBits); } } @@ -256,17 +256,17 @@ GLFWbool _glfwCreateContextNSGL(_GLFWwindow* window, else if (colorBits < 15) colorBits = 15; - setAttrib(NSOpenGLPFAColorSize, colorBits); + SET_ATTRIB(NSOpenGLPFAColorSize, colorBits); } if (fbconfig->alphaBits != GLFW_DONT_CARE) - setAttrib(NSOpenGLPFAAlphaSize, fbconfig->alphaBits); + SET_ATTRIB(NSOpenGLPFAAlphaSize, fbconfig->alphaBits); if (fbconfig->depthBits != GLFW_DONT_CARE) - setAttrib(NSOpenGLPFADepthSize, fbconfig->depthBits); + SET_ATTRIB(NSOpenGLPFADepthSize, fbconfig->depthBits); if (fbconfig->stencilBits != GLFW_DONT_CARE) - setAttrib(NSOpenGLPFAStencilSize, fbconfig->stencilBits); + SET_ATTRIB(NSOpenGLPFAStencilSize, fbconfig->stencilBits); if (fbconfig->stereo) { @@ -275,33 +275,33 @@ GLFWbool _glfwCreateContextNSGL(_GLFWwindow* window, "NSGL: Stereo rendering is deprecated"); return GLFW_FALSE; #else - addAttrib(NSOpenGLPFAStereo); + ADD_ATTRIB(NSOpenGLPFAStereo); #endif } if (fbconfig->doublebuffer) - addAttrib(NSOpenGLPFADoubleBuffer); + ADD_ATTRIB(NSOpenGLPFADoubleBuffer); if (fbconfig->samples != GLFW_DONT_CARE) { if (fbconfig->samples == 0) { - setAttrib(NSOpenGLPFASampleBuffers, 0); + SET_ATTRIB(NSOpenGLPFASampleBuffers, 0); } else { - setAttrib(NSOpenGLPFASampleBuffers, 1); - setAttrib(NSOpenGLPFASamples, fbconfig->samples); + SET_ATTRIB(NSOpenGLPFASampleBuffers, 1); + SET_ATTRIB(NSOpenGLPFASamples, fbconfig->samples); } } // NOTE: All NSOpenGLPixelFormats on the relevant cards support sRGB // framebuffer, so there's no need (and no way) to request it - addAttrib(0); + ADD_ATTRIB(0); -#undef addAttrib -#undef setAttrib +#undef ADD_ATTRIB +#undef SET_ATTRIB window->context.nsgl.pixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:attribs]; diff --git a/src/osmesa_context.c b/src/osmesa_context.c index 161d9fd8..43ade8dc 100644 --- a/src/osmesa_context.c +++ b/src/osmesa_context.c @@ -190,7 +190,7 @@ void _glfwTerminateOSMesa(void) } } -#define setAttrib(a, v) \ +#define SET_ATTRIB(a, v) \ { \ assert(((size_t) index + 1) < sizeof(attribs) / sizeof(attribs[0])); \ attribs[index++] = a; \ @@ -221,24 +221,24 @@ GLFWbool _glfwCreateContextOSMesa(_GLFWwindow* window, { int index = 0, attribs[40]; - setAttrib(OSMESA_FORMAT, OSMESA_RGBA); - setAttrib(OSMESA_DEPTH_BITS, fbconfig->depthBits); - setAttrib(OSMESA_STENCIL_BITS, fbconfig->stencilBits); - setAttrib(OSMESA_ACCUM_BITS, accumBits); + SET_ATTRIB(OSMESA_FORMAT, OSMESA_RGBA); + SET_ATTRIB(OSMESA_DEPTH_BITS, fbconfig->depthBits); + SET_ATTRIB(OSMESA_STENCIL_BITS, fbconfig->stencilBits); + SET_ATTRIB(OSMESA_ACCUM_BITS, accumBits); if (ctxconfig->profile == GLFW_OPENGL_CORE_PROFILE) { - setAttrib(OSMESA_PROFILE, OSMESA_CORE_PROFILE); + SET_ATTRIB(OSMESA_PROFILE, OSMESA_CORE_PROFILE); } else if (ctxconfig->profile == GLFW_OPENGL_COMPAT_PROFILE) { - setAttrib(OSMESA_PROFILE, OSMESA_COMPAT_PROFILE); + SET_ATTRIB(OSMESA_PROFILE, OSMESA_COMPAT_PROFILE); } if (ctxconfig->major != 1 || ctxconfig->minor != 0) { - setAttrib(OSMESA_CONTEXT_MAJOR_VERSION, ctxconfig->major); - setAttrib(OSMESA_CONTEXT_MINOR_VERSION, ctxconfig->minor); + SET_ATTRIB(OSMESA_CONTEXT_MAJOR_VERSION, ctxconfig->major); + SET_ATTRIB(OSMESA_CONTEXT_MINOR_VERSION, ctxconfig->minor); } if (ctxconfig->forward) @@ -248,7 +248,7 @@ GLFWbool _glfwCreateContextOSMesa(_GLFWwindow* window, return GLFW_FALSE; } - setAttrib(0, 0); + SET_ATTRIB(0, 0); window->context.osmesa.handle = OSMesaCreateContextAttribs(attribs, share); @@ -287,7 +287,7 @@ GLFWbool _glfwCreateContextOSMesa(_GLFWwindow* window, return GLFW_TRUE; } -#undef setAttrib +#undef SET_ATTRIB ////////////////////////////////////////////////////////////////////////// diff --git a/src/wgl_context.c b/src/wgl_context.c index 6586db10..a82c736b 100644 --- a/src/wgl_context.c +++ b/src/wgl_context.c @@ -52,12 +52,12 @@ static int findPixelFormatAttribValueWGL(const int* attribs, return 0; } -#define addAttrib(a) \ +#define ADD_ATTRIB(a) \ { \ assert((size_t) attribCount < sizeof(attribs) / sizeof(attribs[0])); \ attribs[attribCount++] = a; \ } -#define findAttribValue(a) \ +#define FIND_ATTRIB_VALUE(a) \ findPixelFormatAttribValueWGL(attribs, attribCount, values, a) // Return a list of available and usable framebuffer configs @@ -84,41 +84,41 @@ static int choosePixelFormatWGL(_GLFWwindow* window, return 0; } - addAttrib(WGL_SUPPORT_OPENGL_ARB); - addAttrib(WGL_DRAW_TO_WINDOW_ARB); - addAttrib(WGL_PIXEL_TYPE_ARB); - addAttrib(WGL_ACCELERATION_ARB); - addAttrib(WGL_RED_BITS_ARB); - addAttrib(WGL_RED_SHIFT_ARB); - addAttrib(WGL_GREEN_BITS_ARB); - addAttrib(WGL_GREEN_SHIFT_ARB); - addAttrib(WGL_BLUE_BITS_ARB); - addAttrib(WGL_BLUE_SHIFT_ARB); - addAttrib(WGL_ALPHA_BITS_ARB); - addAttrib(WGL_ALPHA_SHIFT_ARB); - addAttrib(WGL_DEPTH_BITS_ARB); - addAttrib(WGL_STENCIL_BITS_ARB); - addAttrib(WGL_ACCUM_BITS_ARB); - addAttrib(WGL_ACCUM_RED_BITS_ARB); - addAttrib(WGL_ACCUM_GREEN_BITS_ARB); - addAttrib(WGL_ACCUM_BLUE_BITS_ARB); - addAttrib(WGL_ACCUM_ALPHA_BITS_ARB); - addAttrib(WGL_AUX_BUFFERS_ARB); - addAttrib(WGL_STEREO_ARB); - addAttrib(WGL_DOUBLE_BUFFER_ARB); + ADD_ATTRIB(WGL_SUPPORT_OPENGL_ARB); + ADD_ATTRIB(WGL_DRAW_TO_WINDOW_ARB); + ADD_ATTRIB(WGL_PIXEL_TYPE_ARB); + ADD_ATTRIB(WGL_ACCELERATION_ARB); + ADD_ATTRIB(WGL_RED_BITS_ARB); + ADD_ATTRIB(WGL_RED_SHIFT_ARB); + ADD_ATTRIB(WGL_GREEN_BITS_ARB); + ADD_ATTRIB(WGL_GREEN_SHIFT_ARB); + ADD_ATTRIB(WGL_BLUE_BITS_ARB); + ADD_ATTRIB(WGL_BLUE_SHIFT_ARB); + ADD_ATTRIB(WGL_ALPHA_BITS_ARB); + ADD_ATTRIB(WGL_ALPHA_SHIFT_ARB); + ADD_ATTRIB(WGL_DEPTH_BITS_ARB); + ADD_ATTRIB(WGL_STENCIL_BITS_ARB); + ADD_ATTRIB(WGL_ACCUM_BITS_ARB); + ADD_ATTRIB(WGL_ACCUM_RED_BITS_ARB); + ADD_ATTRIB(WGL_ACCUM_GREEN_BITS_ARB); + ADD_ATTRIB(WGL_ACCUM_BLUE_BITS_ARB); + ADD_ATTRIB(WGL_ACCUM_ALPHA_BITS_ARB); + ADD_ATTRIB(WGL_AUX_BUFFERS_ARB); + ADD_ATTRIB(WGL_STEREO_ARB); + ADD_ATTRIB(WGL_DOUBLE_BUFFER_ARB); if (_glfw.wgl.ARB_multisample) - addAttrib(WGL_SAMPLES_ARB); + ADD_ATTRIB(WGL_SAMPLES_ARB); if (ctxconfig->client == GLFW_OPENGL_API) { if (_glfw.wgl.ARB_framebuffer_sRGB || _glfw.wgl.EXT_framebuffer_sRGB) - addAttrib(WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB); + ADD_ATTRIB(WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB); } else { if (_glfw.wgl.EXT_colorspace) - addAttrib(WGL_COLORSPACE_EXT); + ADD_ATTRIB(WGL_COLORSPACE_EXT); } } else @@ -152,48 +152,48 @@ static int choosePixelFormatWGL(_GLFWwindow* window, return 0; } - if (!findAttribValue(WGL_SUPPORT_OPENGL_ARB) || - !findAttribValue(WGL_DRAW_TO_WINDOW_ARB)) + if (!FIND_ATTRIB_VALUE(WGL_SUPPORT_OPENGL_ARB) || + !FIND_ATTRIB_VALUE(WGL_DRAW_TO_WINDOW_ARB)) { continue; } - if (findAttribValue(WGL_PIXEL_TYPE_ARB) != WGL_TYPE_RGBA_ARB) + if (FIND_ATTRIB_VALUE(WGL_PIXEL_TYPE_ARB) != WGL_TYPE_RGBA_ARB) continue; - if (findAttribValue(WGL_ACCELERATION_ARB) == WGL_NO_ACCELERATION_ARB) + if (FIND_ATTRIB_VALUE(WGL_ACCELERATION_ARB) == WGL_NO_ACCELERATION_ARB) continue; - if (findAttribValue(WGL_DOUBLE_BUFFER_ARB) != fbconfig->doublebuffer) + if (FIND_ATTRIB_VALUE(WGL_DOUBLE_BUFFER_ARB) != fbconfig->doublebuffer) continue; - u->redBits = findAttribValue(WGL_RED_BITS_ARB); - u->greenBits = findAttribValue(WGL_GREEN_BITS_ARB); - u->blueBits = findAttribValue(WGL_BLUE_BITS_ARB); - u->alphaBits = findAttribValue(WGL_ALPHA_BITS_ARB); + u->redBits = FIND_ATTRIB_VALUE(WGL_RED_BITS_ARB); + u->greenBits = FIND_ATTRIB_VALUE(WGL_GREEN_BITS_ARB); + u->blueBits = FIND_ATTRIB_VALUE(WGL_BLUE_BITS_ARB); + u->alphaBits = FIND_ATTRIB_VALUE(WGL_ALPHA_BITS_ARB); - u->depthBits = findAttribValue(WGL_DEPTH_BITS_ARB); - u->stencilBits = findAttribValue(WGL_STENCIL_BITS_ARB); + u->depthBits = FIND_ATTRIB_VALUE(WGL_DEPTH_BITS_ARB); + u->stencilBits = FIND_ATTRIB_VALUE(WGL_STENCIL_BITS_ARB); - u->accumRedBits = findAttribValue(WGL_ACCUM_RED_BITS_ARB); - u->accumGreenBits = findAttribValue(WGL_ACCUM_GREEN_BITS_ARB); - u->accumBlueBits = findAttribValue(WGL_ACCUM_BLUE_BITS_ARB); - u->accumAlphaBits = findAttribValue(WGL_ACCUM_ALPHA_BITS_ARB); + u->accumRedBits = FIND_ATTRIB_VALUE(WGL_ACCUM_RED_BITS_ARB); + u->accumGreenBits = FIND_ATTRIB_VALUE(WGL_ACCUM_GREEN_BITS_ARB); + u->accumBlueBits = FIND_ATTRIB_VALUE(WGL_ACCUM_BLUE_BITS_ARB); + u->accumAlphaBits = FIND_ATTRIB_VALUE(WGL_ACCUM_ALPHA_BITS_ARB); - u->auxBuffers = findAttribValue(WGL_AUX_BUFFERS_ARB); + u->auxBuffers = FIND_ATTRIB_VALUE(WGL_AUX_BUFFERS_ARB); - if (findAttribValue(WGL_STEREO_ARB)) + if (FIND_ATTRIB_VALUE(WGL_STEREO_ARB)) u->stereo = GLFW_TRUE; if (_glfw.wgl.ARB_multisample) - u->samples = findAttribValue(WGL_SAMPLES_ARB); + u->samples = FIND_ATTRIB_VALUE(WGL_SAMPLES_ARB); if (ctxconfig->client == GLFW_OPENGL_API) { if (_glfw.wgl.ARB_framebuffer_sRGB || _glfw.wgl.EXT_framebuffer_sRGB) { - if (findAttribValue(WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB)) + if (FIND_ATTRIB_VALUE(WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB)) u->sRGB = GLFW_TRUE; } } @@ -201,7 +201,7 @@ static int choosePixelFormatWGL(_GLFWwindow* window, { if (_glfw.wgl.EXT_colorspace) { - if (findAttribValue(WGL_COLORSPACE_EXT) == WGL_COLORSPACE_SRGB_EXT) + if (FIND_ATTRIB_VALUE(WGL_COLORSPACE_EXT) == WGL_COLORSPACE_SRGB_EXT) u->sRGB = GLFW_TRUE; } } @@ -290,8 +290,8 @@ static int choosePixelFormatWGL(_GLFWwindow* window, return pixelFormat; } -#undef addAttrib -#undef findAttribValue +#undef ADD_ATTRIB +#undef FIND_ATTRIB_VALUE static void makeContextCurrentWGL(_GLFWwindow* window) { @@ -523,7 +523,7 @@ void _glfwTerminateWGL(void) _glfwPlatformFreeModule(_glfw.wgl.instance); } -#define setAttrib(a, v) \ +#define SET_ATTRIB(a, v) \ { \ assert(((size_t) index + 1) < sizeof(attribs) / sizeof(attribs[0])); \ attribs[index++] = a; \ @@ -631,13 +631,13 @@ GLFWbool _glfwCreateContextWGL(_GLFWwindow* window, { if (ctxconfig->robustness == GLFW_NO_RESET_NOTIFICATION) { - setAttrib(WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB, - WGL_NO_RESET_NOTIFICATION_ARB); + SET_ATTRIB(WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB, + WGL_NO_RESET_NOTIFICATION_ARB); } else if (ctxconfig->robustness == GLFW_LOSE_CONTEXT_ON_RESET) { - setAttrib(WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB, - WGL_LOSE_CONTEXT_ON_RESET_ARB); + SET_ATTRIB(WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB, + WGL_LOSE_CONTEXT_ON_RESET_ARB); } flags |= WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB; @@ -650,13 +650,13 @@ GLFWbool _glfwCreateContextWGL(_GLFWwindow* window, { if (ctxconfig->release == GLFW_RELEASE_BEHAVIOR_NONE) { - setAttrib(WGL_CONTEXT_RELEASE_BEHAVIOR_ARB, - WGL_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB); + SET_ATTRIB(WGL_CONTEXT_RELEASE_BEHAVIOR_ARB, + WGL_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB); } else if (ctxconfig->release == GLFW_RELEASE_BEHAVIOR_FLUSH) { - setAttrib(WGL_CONTEXT_RELEASE_BEHAVIOR_ARB, - WGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB); + SET_ATTRIB(WGL_CONTEXT_RELEASE_BEHAVIOR_ARB, + WGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB); } } } @@ -664,7 +664,7 @@ GLFWbool _glfwCreateContextWGL(_GLFWwindow* window, if (ctxconfig->noerror) { if (_glfw.wgl.ARB_create_context_no_error) - setAttrib(WGL_CONTEXT_OPENGL_NO_ERROR_ARB, GLFW_TRUE); + SET_ATTRIB(WGL_CONTEXT_OPENGL_NO_ERROR_ARB, GLFW_TRUE); } // NOTE: Only request an explicitly versioned context when necessary, as @@ -672,17 +672,17 @@ GLFWbool _glfwCreateContextWGL(_GLFWwindow* window, // highest version supported by the driver if (ctxconfig->major != 1 || ctxconfig->minor != 0) { - setAttrib(WGL_CONTEXT_MAJOR_VERSION_ARB, ctxconfig->major); - setAttrib(WGL_CONTEXT_MINOR_VERSION_ARB, ctxconfig->minor); + SET_ATTRIB(WGL_CONTEXT_MAJOR_VERSION_ARB, ctxconfig->major); + SET_ATTRIB(WGL_CONTEXT_MINOR_VERSION_ARB, ctxconfig->minor); } if (flags) - setAttrib(WGL_CONTEXT_FLAGS_ARB, flags); + SET_ATTRIB(WGL_CONTEXT_FLAGS_ARB, flags); if (mask) - setAttrib(WGL_CONTEXT_PROFILE_MASK_ARB, mask); + SET_ATTRIB(WGL_CONTEXT_PROFILE_MASK_ARB, mask); - setAttrib(0, 0); + SET_ATTRIB(0, 0); window->context.wgl.handle = wglCreateContextAttribsARB(window->context.wgl.dc, share, attribs); @@ -765,7 +765,7 @@ GLFWbool _glfwCreateContextWGL(_GLFWwindow* window, return GLFW_TRUE; } -#undef setAttrib +#undef SET_ATTRIB GLFWAPI HGLRC glfwGetWGLContext(GLFWwindow* handle) { From ad01c1b614868c3cbc79306aa6a19c9fc06f34a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 20 Jan 2022 19:21:48 +0100 Subject: [PATCH 127/208] Win32: Fix key name code changing global key state This prevents glfwInit from potentially clobbering the dead key state for other applications. Closes #2018 --- CONTRIBUTORS.md | 1 + README.md | 2 ++ src/win32_init.c | 9 +++++++-- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index cb9b0d58..82e91773 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -10,6 +10,7 @@ video tutorials. - Matt Arsenault - ashishgamedev - David Avedissian + - Luca Bacci - Keith Bauer - John Bartholomew - CoÅŸku BaÅŸ diff --git a/README.md b/README.md index 9543919e..0aa309d7 100644 --- a/README.md +++ b/README.md @@ -205,6 +205,8 @@ information on what to include when reporting a bug. - [Win32] Bugfix: Content scale queries could fail silently (#1615) - [Win32] Bugfix: Content scales could have garbage values if monitor was recently disconnected (#1615) + - [Win32] Bugfix: Key name update modified global key state on Windows 10 1607 + and later (#2018) - [Cocoa] Added support for `VK_EXT_metal_surface` (#1619) - [Cocoa] Added locating the Vulkan loader at runtime in an application bundle - [Cocoa] Moved main menu creation to GLFW initialization time (#1649) diff --git a/src/win32_init.c b/src/win32_init.c index e687d770..0479afe5 100644 --- a/src/win32_init.c +++ b/src/win32_init.c @@ -458,6 +458,11 @@ void _glfwUpdateKeyNamesWin32(void) { int key; BYTE state[256] = {0}; + UINT flags = 0; + + // Avoid modifying the global key state if supported + if (_glfwIsWindows10AnniversaryUpdateOrGreaterWin32()) + flags = (1 << 2); memset(_glfw.win32.keynames, 0, sizeof(_glfw.win32.keynames)); @@ -487,13 +492,13 @@ void _glfwUpdateKeyNamesWin32(void) length = ToUnicode(vk, scancode, state, chars, sizeof(chars) / sizeof(WCHAR), - 0); + flags); if (length == -1) { length = ToUnicode(vk, scancode, state, chars, sizeof(chars) / sizeof(WCHAR), - 0); + flags); } if (length < 1) From d3e4fcf8b7608e7b6f6cf1c102b1e28c478f5a6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 1 Feb 2022 22:05:55 +0100 Subject: [PATCH 128/208] X11: Fix event polling when event fd > 1023 This replaces select with poll for checking for data on event file descriptors, as select cannot handle file descriptors larger than 1023. Closes #2024 --- CONTRIBUTORS.md | 1 + README.md | 2 ++ src/x11_window.c | 32 +++++++++++++------------------- 3 files changed, 16 insertions(+), 19 deletions(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 82e91773..34ca624f 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -82,6 +82,7 @@ video tutorials. - Paul Holden - Warren Hu - Charles Huber + - illustris - InKryption - IntellectualKitty - Aaron Jacobs diff --git a/README.md b/README.md index 0aa309d7..7fc32b98 100644 --- a/README.md +++ b/README.md @@ -268,6 +268,8 @@ information on what to include when reporting a bug. - [X11] Bugfix: Icon pixel format conversion worked only by accident, relying on undefined behavior (#1986) - [X11] Bugfix: Dynamic loading on OpenBSD failed due to soname differences + - [X11] Bugfix: Waiting for events would fail if file descriptor was too large + (#2024) - [Wayland] Added dynamic loading of all Wayland libraries - [Wayland] Added support for key names via xkbcommon - [Wayland] Removed support for `wl_shell` (#1443) diff --git a/src/x11_window.c b/src/x11_window.c index 61e4fd6d..08422e5f 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -32,7 +32,7 @@ #include #include -#include +#include #include #include @@ -57,37 +57,31 @@ #define _GLFW_XDND_VERSION 5 -// Wait for data to arrive using select +// Wait for event data to arrive on any relevant file descriptor // This avoids blocking other threads via the per-display Xlib lock that also // covers GLX functions // static GLFWbool waitForEvent(double* timeout) { - fd_set fds; - const int fd = ConnectionNumber(_glfw.x11.display); - int count = fd + 1; - -#if defined(__linux__) - if (_glfw.linjs.inotify > fd) - count = _glfw.linjs.inotify + 1; -#endif for (;;) { - FD_ZERO(&fds); - FD_SET(fd, &fds); + nfds_t count = 1; + struct pollfd fds[2] = + { + { ConnectionNumber(_glfw.x11.display), POLLIN } + }; + #if defined(__linux__) - if (_glfw.linjs.inotify > 0) - FD_SET(_glfw.linjs.inotify, &fds); + if (_glfw.joysticksInitialized) + fds[count++] = (struct pollfd) { _glfw.linjs.inotify, POLLIN }; #endif if (timeout) { - const long seconds = (long) *timeout; - const long microseconds = (long) ((*timeout - seconds) * 1e6); - struct timeval tv = { seconds, microseconds }; + const int milliseconds = (int) (*timeout * 1e3); const uint64_t base = _glfwPlatformGetTimerValue(); - const int result = select(count, &fds, NULL, NULL, &tv); + const int result = poll(fds, count, milliseconds); const int error = errno; *timeout -= (_glfwPlatformGetTimerValue() - base) / @@ -98,7 +92,7 @@ static GLFWbool waitForEvent(double* timeout) if ((result == -1 && error == EINTR) || *timeout <= 0.0) return GLFW_FALSE; } - else if (select(count, &fds, NULL, NULL, NULL) != -1 || errno != EINTR) + else if (poll(fds, count, -1) != -1 || errno != EINTR) return GLFW_TRUE; } } From 92b5c67b50d2bab9401f464d4a40fecfccb09dfb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 18 Feb 2022 15:13:18 +0100 Subject: [PATCH 129/208] X11: Retry poll when failed with EINTR or EAGAIN Both of these errors should just lead to local retry. --- src/x11_window.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/x11_window.c b/src/x11_window.c index 08422e5f..f4adbd3e 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -82,18 +82,26 @@ static GLFWbool waitForEvent(double* timeout) const uint64_t base = _glfwPlatformGetTimerValue(); const int result = poll(fds, count, milliseconds); - const int error = errno; + const int error = errno; // clock_gettime may overwrite our error *timeout -= (_glfwPlatformGetTimerValue() - base) / (double) _glfwPlatformGetTimerFrequency(); if (result > 0) return GLFW_TRUE; - if ((result == -1 && error == EINTR) || *timeout <= 0.0) + else if (result == -1 && error != EINTR && error != EAGAIN) + return GLFW_FALSE; + else if (*timeout <= 0.0) + return GLFW_FALSE; + } + else + { + const int result = poll(fds, count, -1); + if (result > 0) + return GLFW_TRUE; + else if (result == -1 && errno != EINTR && errno != EAGAIN) return GLFW_FALSE; } - else if (poll(fds, count, -1) != -1 || errno != EINTR) - return GLFW_TRUE; } } From 1e987cb92ea646282a2e3f7c085f96ae7eeea425 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 18 Feb 2022 15:19:16 +0100 Subject: [PATCH 130/208] X11: Fix joystick events causing busy waiting On Linux, the inotify descriptor was included in the set used for select, but could not break the outer loop, leading to busy waiting until timeout or the correct X11 event arrived. This commit adds a new function for waiting just on X11 events. Fixes #1872 --- README.md | 1 + src/x11_window.c | 59 +++++++++++++++++++++++++++++------------------- 2 files changed, 37 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 7fc32b98..23cc069a 100644 --- a/README.md +++ b/README.md @@ -270,6 +270,7 @@ information on what to include when reporting a bug. - [X11] Bugfix: Dynamic loading on OpenBSD failed due to soname differences - [X11] Bugfix: Waiting for events would fail if file descriptor was too large (#2024) + - [X11] Bugfix: Joystick events could lead to busy-waiting (#1872) - [Wayland] Added dynamic loading of all Wayland libraries - [Wayland] Added support for key names via xkbcommon - [Wayland] Removed support for `wl_shell` (#1443) diff --git a/src/x11_window.c b/src/x11_window.c index f4adbd3e..122db2ba 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -56,26 +56,12 @@ #define _GLFW_XDND_VERSION 5 - -// Wait for event data to arrive on any relevant file descriptor -// This avoids blocking other threads via the per-display Xlib lock that also -// covers GLX functions +// Wait for data to arrive on any of the specified file descriptors // -static GLFWbool waitForEvent(double* timeout) +static GLFWbool waitForData(struct pollfd* fds, nfds_t count, double* timeout) { for (;;) { - nfds_t count = 1; - struct pollfd fds[2] = - { - { ConnectionNumber(_glfw.x11.display), POLLIN } - }; - -#if defined(__linux__) - if (_glfw.joysticksInitialized) - fds[count++] = (struct pollfd) { _glfw.linjs.inotify, POLLIN }; -#endif - if (timeout) { const int milliseconds = (int) (*timeout * 1e3); @@ -105,6 +91,33 @@ static GLFWbool waitForEvent(double* timeout) } } +// Wait for event data to arrive on the X11 display socket +// This avoids blocking other threads via the per-display Xlib lock that also +// covers GLX functions +// +static GLFWbool waitForX11Event(double* timeout) +{ + struct pollfd fd = { ConnectionNumber(_glfw.x11.display), POLLIN }; + return waitForData(&fd, 1, timeout); +} + +// Wait for event data to arrive on any event file descriptor +// This avoids blocking other threads via the per-display Xlib lock that also +// covers GLX functions +// +static GLFWbool waitForAnyEvent(double* timeout) +{ + nfds_t count = 1; + struct pollfd fds[2] = { { ConnectionNumber(_glfw.x11.display), POLLIN } }; + +#if defined(__linux__) + if (_glfw.joysticksInitialized) + fds[count++] = (struct pollfd) { _glfw.linjs.inotify, POLLIN }; +#endif + + return waitForData(fds, count, timeout); +} + // Waits until a VisibilityNotify event arrives for the specified window or the // timeout period elapses (ICCCM section 4.2.2) // @@ -118,7 +131,7 @@ static GLFWbool waitForVisibilityNotify(_GLFWwindow* window) VisibilityNotify, &dummy)) { - if (!waitForEvent(&timeout)) + if (!waitForX11Event(&timeout)) return GLFW_FALSE; } @@ -960,7 +973,7 @@ static const char* getSelectionString(Atom selection) SelectionNotify, ¬ification)) { - waitForEvent(NULL); + waitForX11Event(NULL); } if (notification.xselection.property == None) @@ -996,7 +1009,7 @@ static const char* getSelectionString(Atom selection) isSelPropNewValueNotify, (XPointer) ¬ification)) { - waitForEvent(NULL); + waitForX11Event(NULL); } XFree(data); @@ -1898,7 +1911,7 @@ void _glfwPushSelectionToManagerX11(void) } } - waitForEvent(NULL); + waitForX11Event(NULL); } } @@ -2240,7 +2253,7 @@ void _glfwGetWindowFrameSizeX11(_GLFWwindow* window, isFrameExtentsEvent, (XPointer) window)) { - if (!waitForEvent(&timeout)) + if (!waitForX11Event(&timeout)) { _glfwInputError(GLFW_PLATFORM_ERROR, "X11: The window manager has a broken _NET_REQUEST_FRAME_EXTENTS implementation; please report this issue"); @@ -2782,7 +2795,7 @@ void _glfwPollEventsX11(void) void _glfwWaitEventsX11(void) { while (!XPending(_glfw.x11.display)) - waitForEvent(NULL); + waitForAnyEvent(NULL); _glfwPollEventsX11(); } @@ -2791,7 +2804,7 @@ void _glfwWaitEventsTimeoutX11(double timeout) { while (!XPending(_glfw.x11.display)) { - if (!waitForEvent(&timeout)) + if (!waitForAnyEvent(&timeout)) break; } From 87970b7f265bbd39595de6428bbd14047affa753 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 18 Feb 2022 15:20:10 +0100 Subject: [PATCH 131/208] X11: Fix glfwWaitEvents* ignoring joystick events The data available on the X11 connection may be a reply or an internal event for an X11 extension. Previously the check for whether an event was available for us was done outside waitForEvent. This prevented data available on other file descriptors from breaking the outer wait loop. This commit moves the check for whether an event is available into the wait functions, where there is enough knowledge to limit the check to the X11 connection. Related to #932 --- README.md | 1 + src/x11_window.c | 34 +++++++++++++++++++++++----------- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 23cc069a..fefaf500 100644 --- a/README.md +++ b/README.md @@ -271,6 +271,7 @@ information on what to include when reporting a bug. - [X11] Bugfix: Waiting for events would fail if file descriptor was too large (#2024) - [X11] Bugfix: Joystick events could lead to busy-waiting (#1872) + - [X11] Bugfix: `glfwWaitEvents*` did not continue for joystick events - [Wayland] Added dynamic loading of all Wayland libraries - [Wayland] Added support for key names via xkbcommon - [Wayland] Removed support for `wl_shell` (#1443) diff --git a/src/x11_window.c b/src/x11_window.c index 122db2ba..c42be084 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -98,7 +98,14 @@ static GLFWbool waitForData(struct pollfd* fds, nfds_t count, double* timeout) static GLFWbool waitForX11Event(double* timeout) { struct pollfd fd = { ConnectionNumber(_glfw.x11.display), POLLIN }; - return waitForData(&fd, 1, timeout); + + while (!XPending(_glfw.x11.display)) + { + if (!waitForData(&fd, 1, timeout)) + return GLFW_FALSE; + } + + return GLFW_TRUE; } // Wait for event data to arrive on any event file descriptor @@ -115,7 +122,19 @@ static GLFWbool waitForAnyEvent(double* timeout) fds[count++] = (struct pollfd) { _glfw.linjs.inotify, POLLIN }; #endif - return waitForData(fds, count, timeout); + while (!XPending(_glfw.x11.display)) + { + if (!waitForData(fds, count, timeout)) + return GLFW_FALSE; + + for (int i = 1; i < count; i++) + { + if (fds[i].revents & POLLIN) + return GLFW_TRUE; + } + } + + return GLFW_TRUE; } // Waits until a VisibilityNotify event arrives for the specified window or the @@ -2794,20 +2813,13 @@ void _glfwPollEventsX11(void) void _glfwWaitEventsX11(void) { - while (!XPending(_glfw.x11.display)) - waitForAnyEvent(NULL); - + waitForAnyEvent(NULL); _glfwPollEventsX11(); } void _glfwWaitEventsTimeoutX11(double timeout) { - while (!XPending(_glfw.x11.display)) - { - if (!waitForAnyEvent(&timeout)) - break; - } - + waitForAnyEvent(&timeout); _glfwPollEventsX11(); } From 363d4714414e53312cd5cb0be230f040580487ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 18 Feb 2022 15:35:09 +0100 Subject: [PATCH 132/208] Cleanup --- src/x11_window.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/x11_window.c b/src/x11_window.c index c42be084..50fba5e8 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -2778,8 +2778,6 @@ GLFWbool _glfwRawMouseMotionSupportedX11(void) void _glfwPollEventsX11(void) { - _GLFWwindow* window; - #if defined(__linux__) if (_glfw.joysticksInitialized) _glfwDetectJoystickConnectionLinux(); @@ -2793,7 +2791,7 @@ void _glfwPollEventsX11(void) processEvent(&event); } - window = _glfw.x11.disabledCursorWindow; + _GLFWwindow* window = _glfw.x11.disabledCursorWindow; if (window) { int width, height; From cd22e2849512a88d0ab77bc7a3458646625f2c50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 18 Feb 2022 14:29:43 +0100 Subject: [PATCH 133/208] X11: Fix empty event race condition with a pipe There is a seemingly unavoidable race condition when waiting for data on the X11 display connection, as long as any other thread is also making Xlib calls. The event data we are waiting for could be read by the other thread as part of looking for the reply to its request, before our poll has begun. This commit replaces the X11 event sent by glfwPostEmptyEvent with writing to an unnamed pipe. The race condition remains if other Xlib calls are made on other threads, but glfwPostEmptyEvent should now be race-free. This commit is based on work by pcwalton, OlivierSohn, kovidgoyal and joaodasilva. Closes #2033 Related to #379 Related to #1281 Related to #1285 --- CONTRIBUTORS.md | 2 ++ README.md | 2 ++ docs/news.dox | 6 ++++++ src/x11_init.c | 42 ++++++++++++++++++++++++++++++++++++++++++ src/x11_platform.h | 1 + src/x11_window.c | 44 +++++++++++++++++++++++++++++++++++--------- 6 files changed, 88 insertions(+), 9 deletions(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 34ca624f..f20422ec 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -185,6 +185,7 @@ video tutorials. - Ali Sherief - Yoshiki Shibukawa - Dmitri Shuralyov + - Joao da Silva - Daniel Sieger - Daniel Skorupski - Anthony Smith @@ -192,6 +193,7 @@ video tutorials. - Cliff Smolinsky - Patrick Snape - Erlend Sogge Heggen + - Olivier Sohn - Julian Squires - Johannes Stein - Pontus Stenetorp diff --git a/README.md b/README.md index fefaf500..d1dcb600 100644 --- a/README.md +++ b/README.md @@ -272,6 +272,8 @@ information on what to include when reporting a bug. (#2024) - [X11] Bugfix: Joystick events could lead to busy-waiting (#1872) - [X11] Bugfix: `glfwWaitEvents*` did not continue for joystick events + - [X11] Bugfix: `glfwPostEmptyEvent` could be ignored due to race condition + (#379,#1281,#1285,#2033) - [Wayland] Added dynamic loading of all Wayland libraries - [Wayland] Added support for key names via xkbcommon - [Wayland] Removed support for `wl_shell` (#1443) diff --git a/docs/news.dox b/docs/news.dox index 6c55e65f..fbf60319 100644 --- a/docs/news.dox +++ b/docs/news.dox @@ -138,6 +138,12 @@ GLFW_TRANSPARENT_FRAMEBUFFER on Windows 7 if DWM transparency is off (the Transparency setting under Personalization > Window Color). +@subsubsection emptyevents_34 Empty events on X11 no longer roundtrip to server + +Events posted with @ref glfwPostEmptyEvent now use a separate unnamed pipe +instead of sending an X11 client event to the helper window. + + @subsection deprecations_34 Deprecations in version 3.4 @subsection removals_34 Removals in 3.4 diff --git a/src/x11_init.c b/src/x11_init.c index acfa7933..203828fc 100644 --- a/src/x11_init.c +++ b/src/x11_init.c @@ -35,6 +35,8 @@ #include #include #include +#include +#include // Translate the X11 KeySyms for a key to a GLFW key code @@ -1042,6 +1044,37 @@ static Window createHelperWindow(void) CWEventMask, &wa); } +// Create the pipe for empty events without assumuing the OS has pipe2(2) +// +static GLFWbool createEmptyEventPipe(void) +{ + if (pipe(_glfw.x11.emptyEventPipe) != 0) + { + _glfwInputError(GLFW_PLATFORM_ERROR, + "X11: Failed to create empty event pipe: %s", + strerror(errno)); + return GLFW_FALSE; + } + + for (int i = 0; i < 2; i++) + { + const int sf = fcntl(_glfw.x11.emptyEventPipe[i], F_GETFL, 0); + const int df = fcntl(_glfw.x11.emptyEventPipe[i], F_GETFD, 0); + + if (sf == -1 || df == -1 || + fcntl(_glfw.x11.emptyEventPipe[i], F_SETFL, sf | O_NONBLOCK) == -1 || + fcntl(_glfw.x11.emptyEventPipe[i], F_SETFD, df | FD_CLOEXEC) == -1) + { + _glfwInputError(GLFW_PLATFORM_ERROR, + "X11: Failed to set flags for empty event pipe: %s", + strerror(errno)); + return GLFW_FALSE; + } + } + + return GLFW_TRUE; +} + // X error handler // static int errorHandler(Display *display, XErrorEvent* event) @@ -1491,6 +1524,9 @@ int _glfwInitX11(void) getSystemContentScale(&_glfw.x11.contentScaleX, &_glfw.x11.contentScaleY); + if (!createEmptyEventPipe()) + return GLFW_FALSE; + if (!initExtensions()) return GLFW_FALSE; @@ -1604,5 +1640,11 @@ void _glfwTerminateX11(void) _glfwPlatformFreeModule(_glfw.x11.xlib.handle); _glfw.x11.xlib.handle = NULL; } + + if (_glfw.x11.emptyEventPipe[0] || _glfw.x11.emptyEventPipe[1]) + { + close(_glfw.x11.emptyEventPipe[0]); + close(_glfw.x11.emptyEventPipe[1]); + } } diff --git a/src/x11_platform.h b/src/x11_platform.h index 61a0b17d..8da3a2e4 100644 --- a/src/x11_platform.h +++ b/src/x11_platform.h @@ -582,6 +582,7 @@ typedef struct _GLFWlibraryX11 double restoreCursorPosX, restoreCursorPosY; // The window whose disabled cursor mode is active _GLFWwindow* disabledCursorWindow; + int emptyEventPipe[2]; // Window manager atoms Atom NET_SUPPORTED; diff --git a/src/x11_window.c b/src/x11_window.c index 50fba5e8..76becd6c 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -114,8 +114,12 @@ static GLFWbool waitForX11Event(double* timeout) // static GLFWbool waitForAnyEvent(double* timeout) { - nfds_t count = 1; - struct pollfd fds[2] = { { ConnectionNumber(_glfw.x11.display), POLLIN } }; + nfds_t count = 2; + struct pollfd fds[3] = + { + { ConnectionNumber(_glfw.x11.display), POLLIN }, + { _glfw.x11.emptyEventPipe[0], POLLIN } + }; #if defined(__linux__) if (_glfw.joysticksInitialized) @@ -137,6 +141,32 @@ static GLFWbool waitForAnyEvent(double* timeout) return GLFW_TRUE; } +// Writes a byte to the empty event pipe +// +static void writeEmptyEvent(void) +{ + for (;;) + { + const char byte = 0; + const int result = write(_glfw.x11.emptyEventPipe[1], &byte, 1); + if (result == 1 || (result == -1 && errno != EINTR)) + break; + } +} + +// Drains available data from the empty event pipe +// +static void drainEmptyEvents(void) +{ + for (;;) + { + char dummy[64]; + const int result = read(_glfw.x11.emptyEventPipe[0], dummy, sizeof(dummy)); + if (result == -1 && errno != EINTR) + break; + } +} + // Waits until a VisibilityNotify event arrives for the specified window or the // timeout period elapses (ICCCM section 4.2.2) // @@ -2778,6 +2808,8 @@ GLFWbool _glfwRawMouseMotionSupportedX11(void) void _glfwPollEventsX11(void) { + drainEmptyEvents(); + #if defined(__linux__) if (_glfw.joysticksInitialized) _glfwDetectJoystickConnectionLinux(); @@ -2823,13 +2855,7 @@ void _glfwWaitEventsTimeoutX11(double timeout) void _glfwPostEmptyEventX11(void) { - XEvent event = { ClientMessage }; - event.xclient.window = _glfw.x11.helperWindowHandle; - event.xclient.format = 32; // Data is 32-bit longs - event.xclient.message_type = _glfw.x11.NULL_; - - XSendEvent(_glfw.x11.display, _glfw.x11.helperWindowHandle, False, 0, &event); - XFlush(_glfw.x11.display); + writeEmptyEvent(); } void _glfwGetCursorPosX11(_GLFWwindow* window, double* xpos, double* ypos) From 84b0923fe61a12bd0bf9241da102053b906265bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 25 Feb 2022 15:05:59 +0100 Subject: [PATCH 134/208] X11: Use lower-latency poll where available This uses ppoll for waiting on file descriptors with a timeout, where that function has been available a while. On NetBSD, which will be getting ppoll in the next release, the equivalent pollts is used. This commit is based on work by OlivierSohn and kovidgoyal. Related to #1281 Related to #1285 --- src/x11_window.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/x11_window.c b/src/x11_window.c index 76becd6c..52cbbcf0 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -27,12 +27,18 @@ // It is fine to use C99 in this file because it will not be built with VS //======================================================================== +#if defined(__linux__) + #define _GNU_SOURCE +#endif + #include "internal.h" #include #include #include +#include +#include #include #include @@ -64,10 +70,22 @@ static GLFWbool waitForData(struct pollfd* fds, nfds_t count, double* timeout) { if (timeout) { - const int milliseconds = (int) (*timeout * 1e3); const uint64_t base = _glfwPlatformGetTimerValue(); +#if defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__CYGWIN__) + const time_t seconds = (time_t) *timeout; + const long nanoseconds = (long) ((*timeout - seconds) * 1e9); + const struct timespec ts = { seconds, nanoseconds }; + const int result = ppoll(fds, count, &ts, NULL); +#elif defined(__NetBSD__) + const time_t seconds = (time_t) *timeout; + const long nanoseconds = (long) ((*timeout - seconds) * 1e9); + const struct timespec ts = { seconds, nanoseconds }; + const int result = pollts(fds, count, &ts, NULL); +#else + const int milliseconds = (int) (*timeout * 1e3); const int result = poll(fds, count, milliseconds); +#endif const int error = errno; // clock_gettime may overwrite our error *timeout -= (_glfwPlatformGetTimerValue() - base) / From 3c2913dcb96eed94742826f4276282f4e4a7b01e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 3 Mar 2022 16:23:00 +0100 Subject: [PATCH 135/208] Wayland: Fix potential incomplete display flushing The flushing of a Wayland display may need to be done in several steps, signalled by it failing with EAGAIN. --- src/wl_window.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/wl_window.c b/src/wl_window.c index 367acacc..1a9f980d 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -716,6 +716,25 @@ static void incrementCursorImage(_GLFWwindow* window) } } +static GLFWbool flushDisplay(void) +{ + while (wl_display_flush(_glfw.wl.display) == -1) + { + if (errno != EAGAIN) + return GLFW_FALSE; + + struct pollfd fd = { wl_display_get_fd(_glfw.wl.display), POLLOUT }; + + while (poll(&fd, 1, -1) == -1) + { + if (errno != EINTR && errno != EAGAIN) + return GLFW_FALSE; + } + } + + return GLFW_TRUE; +} + static void handleEvents(int timeout) { struct pollfd fds[] = @@ -730,7 +749,7 @@ static void handleEvents(int timeout) // If an error other than EAGAIN happens, we have likely been disconnected // from the Wayland session; try to handle that the best we can. - if (wl_display_flush(_glfw.wl.display) < 0 && errno != EAGAIN) + if (!flushDisplay()) { _GLFWwindow* window = _glfw.windowListHead; while (window) From 203a7c59d25058f7dfd0c7a3b5062de0b87a8517 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 3 Mar 2022 16:28:44 +0100 Subject: [PATCH 136/208] Wayland: Cancel display fd read before callbacks Cancel the prepared-to-read state on the calling thread before starting to call back to user code. Emitting close requests here is not a good choice but that is for a future commit to address. --- src/wl_window.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/wl_window.c b/src/wl_window.c index 1a9f980d..c150b188 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -751,6 +751,8 @@ static void handleEvents(int timeout) // from the Wayland session; try to handle that the best we can. if (!flushDisplay()) { + wl_display_cancel_read(_glfw.wl.display); + _GLFWwindow* window = _glfw.windowListHead; while (window) { @@ -758,7 +760,6 @@ static void handleEvents(int timeout) window = window->next; } - wl_display_cancel_read(_glfw.wl.display); return; } From bb9d699ae66b2bdc8718995ba13c57c9c8e59602 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 3 Mar 2022 21:26:11 +0100 Subject: [PATCH 137/208] Share X11 fd polling logic with Wayland This moves the X11 polling implementation to a separate file where it can be used by either the X11 or Wayland backend or both. This code should be POSIX compatible where necessary but will use the lower latency but non-standard polling functions ppoll or pollts where those are available. This commit is based on work by OlivierSohn and kovidgoyal. Fixes #1281 Closes #1285 --- src/CMakeLists.txt | 1 + src/posix_poll.c | 83 ++++++++++++++++++++++++++++++++++++++++++++++ src/posix_poll.h | 32 ++++++++++++++++++ src/wl_platform.h | 1 + src/wl_window.c | 13 ++++---- src/x11_platform.h | 1 + src/x11_window.c | 57 ++----------------------------- 7 files changed, 127 insertions(+), 61 deletions(-) create mode 100644 src/posix_poll.c create mode 100644 src/posix_poll.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a07ca931..01f191c9 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -60,6 +60,7 @@ if (GLFW_BUILD_X11 OR GLFW_BUILD_WAYLAND) if (CMAKE_SYSTEM_NAME STREQUAL "Linux") target_sources(glfw PRIVATE linux_joystick.h linux_joystick.c) endif() + target_sources(glfw PRIVATE posix_poll.h posix_poll.c) endif() if (GLFW_BUILD_WAYLAND) diff --git a/src/posix_poll.c b/src/posix_poll.c new file mode 100644 index 00000000..352d9900 --- /dev/null +++ b/src/posix_poll.c @@ -0,0 +1,83 @@ +//======================================================================== +// GLFW 3.4 POSIX - www.glfw.org +//------------------------------------------------------------------------ +// Copyright (c) 2022 Camilla Löwy +// +// This software is provided 'as-is', without any express or implied +// warranty. In no event will the authors be held liable for any damages +// arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it +// freely, subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; you must not +// claim that you wrote the original software. If you use this software +// in a product, an acknowledgment in the product documentation would +// be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, and must not +// be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source +// distribution. +// +//======================================================================== +// It is fine to use C99 in this file because it will not be built with VS +//======================================================================== + +#if defined(__linux__) + #define _GNU_SOURCE +#endif + +#include "internal.h" + +#include +#include +#include + +GLFWbool _glfwPollPOSIX(struct pollfd* fds, nfds_t count, double* timeout) +{ + for (;;) + { + if (timeout) + { + const uint64_t base = _glfwPlatformGetTimerValue(); + +#if defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__CYGWIN__) + const time_t seconds = (time_t) *timeout; + const long nanoseconds = (long) ((*timeout - seconds) * 1e9); + const struct timespec ts = { seconds, nanoseconds }; + const int result = ppoll(fds, count, &ts, NULL); +#elif defined(__NetBSD__) + const time_t seconds = (time_t) *timeout; + const long nanoseconds = (long) ((*timeout - seconds) * 1e9); + const struct timespec ts = { seconds, nanoseconds }; + const int result = pollts(fds, count, &ts, NULL); +#else + const int milliseconds = (int) (*timeout * 1e3); + const int result = poll(fds, count, milliseconds); +#endif + const int error = errno; // clock_gettime may overwrite our error + + *timeout -= (_glfwPlatformGetTimerValue() - base) / + (double) _glfwPlatformGetTimerFrequency(); + + if (result > 0) + return GLFW_TRUE; + else if (result == -1 && error != EINTR && error != EAGAIN) + return GLFW_FALSE; + else if (*timeout <= 0.0) + return GLFW_FALSE; + } + else + { + const int result = poll(fds, count, -1); + if (result > 0) + return GLFW_TRUE; + else if (result == -1 && errno != EINTR && errno != EAGAIN) + return GLFW_FALSE; + } + } +} + diff --git a/src/posix_poll.h b/src/posix_poll.h new file mode 100644 index 00000000..1effd1cd --- /dev/null +++ b/src/posix_poll.h @@ -0,0 +1,32 @@ +//======================================================================== +// GLFW 3.4 POSIX - www.glfw.org +//------------------------------------------------------------------------ +// Copyright (c) 2022 Camilla Löwy +// +// This software is provided 'as-is', without any express or implied +// warranty. In no event will the authors be held liable for any damages +// arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it +// freely, subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; you must not +// claim that you wrote the original software. If you use this software +// in a product, an acknowledgment in the product documentation would +// be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, and must not +// be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source +// distribution. +// +//======================================================================== +// It is fine to use C99 in this file because it will not be built with VS +//======================================================================== + +#include + +GLFWbool _glfwPollPOSIX(struct pollfd* fds, nfds_t count, double* timeout); + diff --git a/src/wl_platform.h b/src/wl_platform.h index 7565411b..ba405714 100644 --- a/src/wl_platform.h +++ b/src/wl_platform.h @@ -43,6 +43,7 @@ typedef VkResult (APIENTRY *PFN_vkCreateWaylandSurfaceKHR)(VkInstance,const VkWa typedef VkBool32 (APIENTRY *PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR)(VkPhysicalDevice,uint32_t,struct wl_display*); #include "xkb_unicode.h" +#include "posix_poll.h" typedef int (* PFN_wl_display_flush)(struct wl_display *display); typedef void (* PFN_wl_display_cancel_read)(struct wl_display *display); diff --git a/src/wl_window.c b/src/wl_window.c index c150b188..4dfde7af 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -735,7 +735,7 @@ static GLFWbool flushDisplay(void) return GLFW_TRUE; } -static void handleEvents(int timeout) +static void handleEvents(double* timeout) { struct pollfd fds[] = { @@ -763,7 +763,7 @@ static void handleEvents(int timeout) return; } - if (poll(fds, 3, timeout) > 0) + if (_glfwPollPOSIX(fds, 3, timeout)) { if (fds[0].revents & POLLIN) { @@ -1168,17 +1168,18 @@ GLFWbool _glfwRawMouseMotionSupportedWayland(void) void _glfwPollEventsWayland(void) { - handleEvents(0); + double timeout = 0.0; + handleEvents(&timeout); } void _glfwWaitEventsWayland(void) { - handleEvents(-1); + handleEvents(NULL); } void _glfwWaitEventsTimeoutWayland(double timeout) { - handleEvents((int) (timeout * 1e3)); + handleEvents(&timeout); } void _glfwPostEmptyEventWayland(void) @@ -1729,7 +1730,7 @@ const char* _glfwGetClipboardStringWayland(void) close(fds[1]); // XXX: this is a huge hack, this function shouldn’t be synchronous! - handleEvents(-1); + handleEvents(NULL); while (1) { diff --git a/src/x11_platform.h b/src/x11_platform.h index 8da3a2e4..956104fa 100644 --- a/src/x11_platform.h +++ b/src/x11_platform.h @@ -453,6 +453,7 @@ typedef VkResult (APIENTRY *PFN_vkCreateXcbSurfaceKHR)(VkInstance,const VkXcbSur typedef VkBool32 (APIENTRY *PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR)(VkPhysicalDevice,uint32_t,xcb_connection_t*,xcb_visualid_t); #include "xkb_unicode.h" +#include "posix_poll.h" #define GLFW_X11_WINDOW_STATE _GLFWwindowX11 x11; #define GLFW_X11_LIBRARY_WINDOW_STATE _GLFWlibraryX11 x11; diff --git a/src/x11_window.c b/src/x11_window.c index 52cbbcf0..6c329e63 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -27,18 +27,12 @@ // It is fine to use C99 in this file because it will not be built with VS //======================================================================== -#if defined(__linux__) - #define _GNU_SOURCE -#endif - #include "internal.h" #include #include #include -#include -#include #include #include @@ -62,53 +56,6 @@ #define _GLFW_XDND_VERSION 5 -// Wait for data to arrive on any of the specified file descriptors -// -static GLFWbool waitForData(struct pollfd* fds, nfds_t count, double* timeout) -{ - for (;;) - { - if (timeout) - { - const uint64_t base = _glfwPlatformGetTimerValue(); - -#if defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__CYGWIN__) - const time_t seconds = (time_t) *timeout; - const long nanoseconds = (long) ((*timeout - seconds) * 1e9); - const struct timespec ts = { seconds, nanoseconds }; - const int result = ppoll(fds, count, &ts, NULL); -#elif defined(__NetBSD__) - const time_t seconds = (time_t) *timeout; - const long nanoseconds = (long) ((*timeout - seconds) * 1e9); - const struct timespec ts = { seconds, nanoseconds }; - const int result = pollts(fds, count, &ts, NULL); -#else - const int milliseconds = (int) (*timeout * 1e3); - const int result = poll(fds, count, milliseconds); -#endif - const int error = errno; // clock_gettime may overwrite our error - - *timeout -= (_glfwPlatformGetTimerValue() - base) / - (double) _glfwPlatformGetTimerFrequency(); - - if (result > 0) - return GLFW_TRUE; - else if (result == -1 && error != EINTR && error != EAGAIN) - return GLFW_FALSE; - else if (*timeout <= 0.0) - return GLFW_FALSE; - } - else - { - const int result = poll(fds, count, -1); - if (result > 0) - return GLFW_TRUE; - else if (result == -1 && errno != EINTR && errno != EAGAIN) - return GLFW_FALSE; - } - } -} - // Wait for event data to arrive on the X11 display socket // This avoids blocking other threads via the per-display Xlib lock that also // covers GLX functions @@ -119,7 +66,7 @@ static GLFWbool waitForX11Event(double* timeout) while (!XPending(_glfw.x11.display)) { - if (!waitForData(&fd, 1, timeout)) + if (!_glfwPollPOSIX(&fd, 1, timeout)) return GLFW_FALSE; } @@ -146,7 +93,7 @@ static GLFWbool waitForAnyEvent(double* timeout) while (!XPending(_glfw.x11.display)) { - if (!waitForData(fds, count, timeout)) + if (!_glfwPollPOSIX(fds, count, timeout)) return GLFW_FALSE; for (int i = 1; i < count; i++) From 7ce1f3e1cf5eb86a17f0c739cfdbcf4094e8e395 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 3 Mar 2022 21:40:00 +0100 Subject: [PATCH 138/208] Formatting --- src/wl_window.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wl_window.c b/src/wl_window.c index 4dfde7af..8ca6f7b6 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -1732,7 +1732,7 @@ const char* _glfwGetClipboardStringWayland(void) // XXX: this is a huge hack, this function shouldn’t be synchronous! handleEvents(NULL); - while (1) + for (;;) { // Grow the clipboard if we need to paste something bigger, there is no // shrink operation yet. From a32cbf6d4febde6343167f19529b8bde8966670d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 3 Mar 2022 21:46:50 +0100 Subject: [PATCH 139/208] Wayland: Fix glfwPostEmptyEvent not always working The display sync requests in glfwPostEmptyEvent could just accumulate as the display was never flushed on secondary threads. This adds a proper flush after each sync request. Fixes #1520 Closes #1521 --- README.md | 1 + src/wl_window.c | 1 + 2 files changed, 2 insertions(+) diff --git a/README.md b/README.md index d1dcb600..bb9cbf19 100644 --- a/README.md +++ b/README.md @@ -298,6 +298,7 @@ information on what to include when reporting a bug. - [Wayland] Bugfix: Full screen window creation did not ignore `GLFW_VISIBLE` - [Wayland] Bugfix: Some keys were reported as wrong key or `GLFW_KEY_UNKNOWN` - [Wayland] Bugfix: Text input did not repeat along with key repeat + - [Wayland] Bugfix: `glfwPostEmptyEvent` sometimes had no effect (#1520,#1521) - [POSIX] Removed use of deprecated function `gettimeofday` - [POSIX] Bugfix: `CLOCK_MONOTONIC` was not correctly tested for or enabled - [WGL] Disabled the DWM swap interval hack for Windows 8 and later (#1072) diff --git a/src/wl_window.c b/src/wl_window.c index 8ca6f7b6..15cc5e5f 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -1185,6 +1185,7 @@ void _glfwWaitEventsTimeoutWayland(double timeout) void _glfwPostEmptyEventWayland(void) { wl_display_sync(_glfw.wl.display); + flushDisplay(); } void _glfwGetCursorPosWayland(_GLFWwindow* window, double* xpos, double* ypos) From 71742d9a27a88d898ea13fd415fae1650dc2772e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 3 Mar 2022 22:41:36 +0100 Subject: [PATCH 140/208] Wayland: Improve event processing with timeout If the polling was interrupted by a signal or by incomplete or unrelated data on any file descriptor, handleEvents could return before the full timeout had elapsed. This retries the Wayland prepare-to-read and poll until the full timeout has elapsed or until any event was processed. Unfortunately, due to how the Wayland client API is designed, this also includes the delete_id for the frame callback created by eglSwapBuffers. This means glfwWaitEvents* are still not fully functional on Wayland. See #1911 for more details. --- src/wl_window.c | 47 +++++++++++++++++++++++++++++------------------ 1 file changed, 29 insertions(+), 18 deletions(-) diff --git a/src/wl_window.c b/src/wl_window.c index 15cc5e5f..54257b25 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -737,6 +737,7 @@ static GLFWbool flushDisplay(void) static void handleEvents(double* timeout) { + GLFWbool event = GLFW_FALSE; struct pollfd fds[] = { { wl_display_get_fd(_glfw.wl.display), POLLIN }, @@ -744,31 +745,38 @@ static void handleEvents(double* timeout) { _glfw.wl.cursorTimerfd, POLLIN }, }; - while (wl_display_prepare_read(_glfw.wl.display) != 0) - wl_display_dispatch_pending(_glfw.wl.display); - - // If an error other than EAGAIN happens, we have likely been disconnected - // from the Wayland session; try to handle that the best we can. - if (!flushDisplay()) + while (!event) { - wl_display_cancel_read(_glfw.wl.display); + while (wl_display_prepare_read(_glfw.wl.display) != 0) + wl_display_dispatch_pending(_glfw.wl.display); - _GLFWwindow* window = _glfw.windowListHead; - while (window) + // If an error other than EAGAIN happens, we have likely been disconnected + // from the Wayland session; try to handle that the best we can. + if (!flushDisplay()) { - _glfwInputWindowCloseRequest(window); - window = window->next; + wl_display_cancel_read(_glfw.wl.display); + + _GLFWwindow* window = _glfw.windowListHead; + while (window) + { + _glfwInputWindowCloseRequest(window); + window = window->next; + } + + return; } - return; - } + if (!_glfwPollPOSIX(fds, 3, timeout)) + { + wl_display_cancel_read(_glfw.wl.display); + return; + } - if (_glfwPollPOSIX(fds, 3, timeout)) - { if (fds[0].revents & POLLIN) { wl_display_read_events(_glfw.wl.display); - wl_display_dispatch_pending(_glfw.wl.display); + if (wl_display_dispatch_pending(_glfw.wl.display) > 0) + event = GLFW_TRUE; } else wl_display_cancel_read(_glfw.wl.display); @@ -789,6 +797,8 @@ static void handleEvents(double* timeout) _glfwInputTextWayland(_glfw.wl.keyboardFocus, _glfw.wl.keyboardLastScancode); } + + event = GLFW_TRUE; } } @@ -797,11 +807,12 @@ static void handleEvents(double* timeout) uint64_t repeats; if (read(_glfw.wl.cursorTimerfd, &repeats, sizeof(repeats)) == 8) + { incrementCursorImage(_glfw.wl.pointerFocus); + event = GLFW_TRUE; + } } } - else - wl_display_cancel_read(_glfw.wl.display); } ////////////////////////////////////////////////////////////////////////// From 1e0c3bca7f6da896828e00f3da606d5e306c3034 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 3 Mar 2022 23:15:47 +0100 Subject: [PATCH 141/208] Update version of VS used on windows-latest --- .github/workflows/build.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 249e8d68..7f798851 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -73,8 +73,8 @@ jobs: - name: Build shared library run: cmake --build build-shared --parallel - build-windows-win32-vs2019: - name: Win32 (Windows, VS2019) + build-windows-win32-vs2022: + name: Win32 (Windows, VS2022) runs-on: windows-latest env: CFLAGS: /WX @@ -82,12 +82,12 @@ jobs: - uses: actions/checkout@v2 - name: Configure static library - run: cmake -S . -B build-static -G "Visual Studio 16 2019" + run: cmake -S . -B build-static -G "Visual Studio 17 2022" - name: Build static library run: cmake --build build-static --parallel - name: Configure shared library - run: cmake -S . -B build-shared -G "Visual Studio 16 2019" -D BUILD_SHARED_LIBS=ON + run: cmake -S . -B build-shared -G "Visual Studio 17 2022" -D BUILD_SHARED_LIBS=ON - name: Build shared library run: cmake --build build-shared --parallel From d78b0a4ead17e30182761b38dbbdfb88b037287b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 23 Feb 2022 18:47:30 +0100 Subject: [PATCH 142/208] X11: Fix sonames for loaded libraries on NetBSD The NetBSD sonames for X11 and related libraries is more stable than on OpenBSD but the version numbers are still bumped more often than their Linux counterparts, even excluding the one-time version bump across all X11 related libraries. This commit moves to using version-less sonames for X11 and related libraries on NetBSD, which will hopefully be more forward-compatible than hard-coding NetBSD-specific sonames. This may not be the correct long-term solution but it runs now. Binaries also appear to need an LD_LIBRARY_PATH or rpath entry of /usr/X11R7/lib in order for the libraries to be found by dlopen. Tested on NetBSD 9.2. --- README.md | 1 + src/egl_context.c | 8 ++++---- src/glx_context.c | 2 +- src/osmesa_context.c | 2 +- src/vulkan.c | 2 +- src/x11_init.c | 18 +++++++++--------- 6 files changed, 17 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index bb9cbf19..8c597048 100644 --- a/README.md +++ b/README.md @@ -274,6 +274,7 @@ information on what to include when reporting a bug. - [X11] Bugfix: `glfwWaitEvents*` did not continue for joystick events - [X11] Bugfix: `glfwPostEmptyEvent` could be ignored due to race condition (#379,#1281,#1285,#2033) + - [X11] Bugfix: Dynamic loading on NetBSD failed due to soname differences - [Wayland] Added dynamic loading of all Wayland libraries - [Wayland] Added support for key names via xkbcommon - [Wayland] Removed support for `wl_shell` (#1443) diff --git a/src/egl_context.c b/src/egl_context.c index 963a59d6..f8850fa2 100644 --- a/src/egl_context.c +++ b/src/egl_context.c @@ -325,7 +325,7 @@ GLFWbool _glfwInitEGL(void) "libEGL.dylib", #elif defined(__CYGWIN__) "libEGL-1.so", -#elif defined(__OpenBSD__) +#elif defined(__OpenBSD__) || defined(__NetBSD__) "libEGL.so", #else "libEGL.so.1", @@ -702,7 +702,7 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window, "libGLES_CM.dll", #elif defined(_GLFW_COCOA) "libGLESv1_CM.dylib", -#elif defined(__OpenBSD__) +#elif defined(__OpenBSD__) || defined(__NetBSD__) "libGLESv1_CM.so", #else "libGLESv1_CM.so.1", @@ -721,7 +721,7 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window, "libGLESv2.dylib", #elif defined(__CYGWIN__) "libGLESv2-2.so", -#elif defined(__OpenBSD__) +#elif defined(__OpenBSD__) || defined(__NetBSD__) "libGLESv2.so", #else "libGLESv2.so.2", @@ -734,7 +734,7 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window, _GLFW_OPENGL_LIBRARY, #elif defined(_GLFW_WIN32) #elif defined(_GLFW_COCOA) -#elif defined(__OpenBSD__) +#elif defined(__OpenBSD__) || defined(__NetBSD__) "libGL.so", #else "libGL.so.1", diff --git a/src/glx_context.c b/src/glx_context.c index ced9c88f..872612d1 100644 --- a/src/glx_context.c +++ b/src/glx_context.c @@ -259,7 +259,7 @@ GLFWbool _glfwInitGLX(void) _GLFW_GLX_LIBRARY, #elif defined(__CYGWIN__) "libGL-1.so", -#elif defined(__OpenBSD__) +#elif defined(__OpenBSD__) || defined(__NetBSD__) "libGL.so", #else "libGL.so.1", diff --git a/src/osmesa_context.c b/src/osmesa_context.c index 43ade8dc..38adabbc 100644 --- a/src/osmesa_context.c +++ b/src/osmesa_context.c @@ -124,7 +124,7 @@ GLFWbool _glfwInitOSMesa(void) "libOSMesa.8.dylib", #elif defined(__CYGWIN__) "libOSMesa-8.so", -#elif defined(__OpenBSD__) +#elif defined(__OpenBSD__) || defined(__NetBSD__) "libOSMesa.so", #else "libOSMesa.so.8", diff --git a/src/vulkan.c b/src/vulkan.c index f02b1ede..64a4650f 100644 --- a/src/vulkan.c +++ b/src/vulkan.c @@ -63,7 +63,7 @@ GLFWbool _glfwInitVulkan(int mode) _glfw.vk.handle = _glfwPlatformLoadModule("libvulkan.1.dylib"); if (!_glfw.vk.handle) _glfw.vk.handle = _glfwLoadLocalVulkanLoaderCocoa(); -#elif defined(__OpenBSD__) +#elif defined(__OpenBSD__) || defined(__NetBSD__) _glfw.vk.handle = _glfwPlatformLoadModule("libvulkan.so"); #else _glfw.vk.handle = _glfwPlatformLoadModule("libvulkan.so.1"); diff --git a/src/x11_init.c b/src/x11_init.c index 203828fc..78735d69 100644 --- a/src/x11_init.c +++ b/src/x11_init.c @@ -603,7 +603,7 @@ static void detectEWMH(void) // static GLFWbool initExtensions(void) { -#if defined(__OpenBSD__) +#if defined(__OpenBSD__) || defined(__NetBSD__) _glfw.x11.vidmode.handle = _glfwPlatformLoadModule("libXxf86vm.so"); #else _glfw.x11.vidmode.handle = _glfwPlatformLoadModule("libXxf86vm.so.1"); @@ -627,7 +627,7 @@ static GLFWbool initExtensions(void) #if defined(__CYGWIN__) _glfw.x11.xi.handle = _glfwPlatformLoadModule("libXi-6.so"); -#elif defined(__OpenBSD__) +#elif defined(__OpenBSD__) || defined(__NetBSD__) _glfw.x11.xi.handle = _glfwPlatformLoadModule("libXi.so"); #else _glfw.x11.xi.handle = _glfwPlatformLoadModule("libXi.so.6"); @@ -659,7 +659,7 @@ static GLFWbool initExtensions(void) #if defined(__CYGWIN__) _glfw.x11.randr.handle = _glfwPlatformLoadModule("libXrandr-2.so"); -#elif defined(__OpenBSD__) +#elif defined(__OpenBSD__) || defined(__NetBSD__) _glfw.x11.randr.handle = _glfwPlatformLoadModule("libXrandr.so"); #else _glfw.x11.randr.handle = _glfwPlatformLoadModule("libXrandr.so.2"); @@ -753,7 +753,7 @@ static GLFWbool initExtensions(void) #if defined(__CYGWIN__) _glfw.x11.xcursor.handle = _glfwPlatformLoadModule("libXcursor-1.so"); -#elif defined(__OpenBSD__) +#elif defined(__OpenBSD__) || defined(__NetBSD__) _glfw.x11.xcursor.handle = _glfwPlatformLoadModule("libXcursor.so"); #else _glfw.x11.xcursor.handle = _glfwPlatformLoadModule("libXcursor.so.1"); @@ -776,7 +776,7 @@ static GLFWbool initExtensions(void) #if defined(__CYGWIN__) _glfw.x11.xinerama.handle = _glfwPlatformLoadModule("libXinerama-1.so"); -#elif defined(__OpenBSD__) +#elif defined(__OpenBSD__) || defined(__NetBSD__) _glfw.x11.xinerama.handle = _glfwPlatformLoadModule("libXinerama.so"); #else _glfw.x11.xinerama.handle = _glfwPlatformLoadModule("libXinerama.so.1"); @@ -831,7 +831,7 @@ static GLFWbool initExtensions(void) { #if defined(__CYGWIN__) _glfw.x11.x11xcb.handle = _glfwPlatformLoadModule("libX11-xcb-1.so"); -#elif defined(__OpenBSD__) +#elif defined(__OpenBSD__) || defined(__NetBSD__) _glfw.x11.x11xcb.handle = _glfwPlatformLoadModule("libX11-xcb.so"); #else _glfw.x11.x11xcb.handle = _glfwPlatformLoadModule("libX11-xcb.so.1"); @@ -846,7 +846,7 @@ static GLFWbool initExtensions(void) #if defined(__CYGWIN__) _glfw.x11.xrender.handle = _glfwPlatformLoadModule("libXrender-1.so"); -#elif defined(__OpenBSD__) +#elif defined(__OpenBSD__) || defined(__NetBSD__) _glfw.x11.xrender.handle = _glfwPlatformLoadModule("libXrender.so"); #else _glfw.x11.xrender.handle = _glfwPlatformLoadModule("libXrender.so.1"); @@ -875,7 +875,7 @@ static GLFWbool initExtensions(void) #if defined(__CYGWIN__) _glfw.x11.xshape.handle = _glfwPlatformLoadModule("libXext-6.so"); -#elif defined(__OpenBSD__) +#elif defined(__OpenBSD__) || defined(__NetBSD__) _glfw.x11.xshape.handle = _glfwPlatformLoadModule("libXext.so"); #else _glfw.x11.xshape.handle = _glfwPlatformLoadModule("libXext.so.6"); @@ -1254,7 +1254,7 @@ GLFWbool _glfwConnectX11(int platformID, _GLFWplatform* platform) #if defined(__CYGWIN__) void* module = _glfwPlatformLoadModule("libX11-6.so"); -#elif defined(__OpenBSD__) +#elif defined(__OpenBSD__) || defined(__NetBSD__) void* module = _glfwPlatformLoadModule("libX11.so"); #else void* module = _glfwPlatformLoadModule("libX11.so.6"); From adc202d2c3182ca6ad8344624941e56d8e0bc493 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 4 Mar 2022 13:37:38 +0100 Subject: [PATCH 143/208] POSIX: Fix undeclared function warning on Cygwin --- src/posix_poll.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/posix_poll.c b/src/posix_poll.c index 352d9900..676a8a51 100644 --- a/src/posix_poll.c +++ b/src/posix_poll.c @@ -26,9 +26,7 @@ // It is fine to use C99 in this file because it will not be built with VS //======================================================================== -#if defined(__linux__) - #define _GNU_SOURCE -#endif +#define _GNU_SOURCE #include "internal.h" From a730acf8e50e7efa70e79e42c511a97f27c97e4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 7 Mar 2022 18:14:16 +0100 Subject: [PATCH 144/208] Win32: Fix rect of undecorated maximized windows A window created maximized and undecorated would cover the whole monitor Windows placed it on instead of just that monitor's workarea. This commit adjusts the maximized rect to cover just the workarea, similar to how undecorated windows that become maximized are handled during WM_GETMINMAXINFO. Fixes #1806 --- README.md | 2 ++ src/win32_window.c | 29 ++++++++++++++++++++++++----- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 8c597048..f4ef3791 100644 --- a/README.md +++ b/README.md @@ -207,6 +207,8 @@ information on what to include when reporting a bug. disconnected (#1615) - [Win32] Bugfix: Key name update modified global key state on Windows 10 1607 and later (#2018) + - [Win32] Bugfix: A window created maximized and undecorated would cover the whole + monitor (#1806) - [Cocoa] Added support for `VK_EXT_metal_surface` (#1619) - [Cocoa] Added locating the Vulkan loader at runtime in an application bundle - [Cocoa] Moved main menu creation to GLFW initialization time (#1649) diff --git a/src/win32_window.c b/src/win32_window.c index b3da6b2a..c8f7782e 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -1292,18 +1292,22 @@ static int createNativeWindow(_GLFWwindow* window, window->win32.scaleToMonitor = wndconfig->scaleToMonitor; window->win32.keymenu = wndconfig->win32.keymenu; - // Adjust window rect to account for DPI scaling of the window frame and - // (if enabled) DPI scaling of the content area - // This cannot be done until we know what monitor the window was placed on if (!window->monitor) { RECT rect = { 0, 0, wndconfig->width, wndconfig->height }; WINDOWPLACEMENT wp = { sizeof(wp) }; + const HMONITOR mh = MonitorFromWindow(window->win32.handle, + MONITOR_DEFAULTTONEAREST); + + // Adjust window rect to account for DPI scaling of the window frame and + // (if enabled) DPI scaling of the content area + // This cannot be done until we know what monitor the window was placed on + // Only update the restored window rect as the window may be maximized if (wndconfig->scaleToMonitor) { float xscale, yscale; - _glfwGetWindowContentScaleWin32(window, &xscale, &yscale); + _glfwGetHMONITORContentScaleWin32(mh, &xscale, &yscale); if (xscale > 0.f && yscale > 0.f) { @@ -1323,11 +1327,26 @@ static int createNativeWindow(_GLFWwindow* window, else AdjustWindowRectEx(&rect, style, FALSE, exStyle); - // Only update the restored window rect as the window may be maximized GetWindowPlacement(window->win32.handle, &wp); wp.rcNormalPosition = rect; wp.showCmd = SW_HIDE; SetWindowPlacement(window->win32.handle, &wp); + + // Adjust rect of maximized undecorated window, because by default Windows will + // make such a window cover the whole monitor instead of its workarea + + if (wndconfig->maximized && !wndconfig->decorated) + { + MONITORINFO mi = { sizeof(mi) }; + GetMonitorInfo(mh, &mi); + + SetWindowPos(window->win32.handle, HWND_TOP, + mi.rcWork.left, + mi.rcWork.top, + mi.rcWork.right - mi.rcWork.left, + mi.rcWork.bottom - mi.rcWork.top, + SWP_NOACTIVATE | SWP_NOZORDER); + } } DragAcceptFiles(window->win32.handle, TRUE); From 367d06deafb00057850796abc02489756a7c6c18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 7 Mar 2022 19:19:31 +0100 Subject: [PATCH 145/208] Win32: Fix scale fixup losing initial position The window content scale correction at creation overwrote the inital, more pleasant placement of the window by CW_USEDEFAULT, if the window was created with GLFW_MAXIMIZED set. This is because the translation to screen coordinates was done using the current position, not the position from the restored window rect. --- README.md | 2 ++ src/win32_window.c | 7 ++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f4ef3791..cc3e3ccc 100644 --- a/README.md +++ b/README.md @@ -209,6 +209,8 @@ information on what to include when reporting a bug. and later (#2018) - [Win32] Bugfix: A window created maximized and undecorated would cover the whole monitor (#1806) + - [Win32] Bugfix: The default restored window position was lost when creating a maximized + window - [Cocoa] Added support for `VK_EXT_metal_surface` (#1619) - [Cocoa] Added locating the Vulkan loader at runtime in an application bundle - [Cocoa] Moved main menu creation to GLFW initialization time (#1649) diff --git a/src/win32_window.c b/src/win32_window.c index c8f7782e..0f76cf56 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -1316,9 +1316,6 @@ static int createNativeWindow(_GLFWwindow* window, } } - ClientToScreen(window->win32.handle, (POINT*) &rect.left); - ClientToScreen(window->win32.handle, (POINT*) &rect.right); - if (_glfwIsWindows10AnniversaryUpdateOrGreaterWin32()) { AdjustWindowRectExForDpi(&rect, style, FALSE, exStyle, @@ -1328,6 +1325,10 @@ static int createNativeWindow(_GLFWwindow* window, AdjustWindowRectEx(&rect, style, FALSE, exStyle); GetWindowPlacement(window->win32.handle, &wp); + OffsetRect(&rect, + wp.rcNormalPosition.left - rect.left, + wp.rcNormalPosition.top - rect.top); + wp.rcNormalPosition = rect; wp.showCmd = SW_HIDE; SetWindowPlacement(window->win32.handle, &wp); From 1eef3a363e2f64718c82122c5d48bff44c4b2e5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 10 Mar 2022 19:14:49 +0100 Subject: [PATCH 146/208] Fix dependency list for X11 on Cygwin --- docs/compile.dox | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/compile.dox b/docs/compile.dox index 05da99cf..925ab1ab 100644 --- a/docs/compile.dox +++ b/docs/compile.dox @@ -68,8 +68,10 @@ install the `xorgproto` package. pkg install xorgproto @endcode -On Cygwin the `xorgproto` package in the Devel section of the GUI installer will -install the headers and other development related files for all of X11. +On Cygwin the `libXcursor-devel`, `libXi-devel`, `libXinerama-devel`, +`libXrandr-devel` and `libXrender-devel` packages in the Libs section of the GUI +installer will install all the headers and other development related files GLFW +requires for X11. Once you have the required dependencies, move on to @ref compile_generate. From 723f3eb40db27a26c846f0d38ee24af3365ffa96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 8 Mar 2022 23:00:47 +0100 Subject: [PATCH 147/208] Win32: Fix maximization showing a hidden window The normal way of maximizing a window also makes it visible. This implements window maximization manually for when the window passed to glfwMaximizeWindow is hidden. This will very likely not be forward-compatible and should be replaced. --- README.md | 1 + src/win32_init.c | 2 ++ src/win32_platform.h | 3 +++ src/win32_window.c | 58 +++++++++++++++++++++++++++++++++++++++++++- 4 files changed, 63 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index cc3e3ccc..f3bff91d 100644 --- a/README.md +++ b/README.md @@ -211,6 +211,7 @@ information on what to include when reporting a bug. monitor (#1806) - [Win32] Bugfix: The default restored window position was lost when creating a maximized window + - [Win32] Bugfix: `glfwMaximizeWindow` would make a hidden window visible - [Cocoa] Added support for `VK_EXT_metal_surface` (#1619) - [Cocoa] Added locating the Vulkan loader at runtime in an application bundle - [Cocoa] Moved main menu creation to GLFW initialization time (#1649) diff --git a/src/win32_init.c b/src/win32_init.c index 0479afe5..dfaf3d64 100644 --- a/src/win32_init.c +++ b/src/win32_init.c @@ -91,6 +91,8 @@ static GLFWbool loadLibraries(void) _glfwPlatformGetModuleSymbol(_glfw.win32.user32.instance, "GetDpiForWindow"); _glfw.win32.user32.AdjustWindowRectExForDpi_ = (PFN_AdjustWindowRectExForDpi) _glfwPlatformGetModuleSymbol(_glfw.win32.user32.instance, "AdjustWindowRectExForDpi"); + _glfw.win32.user32.GetSystemMetricsForDpi_ = (PFN_GetSystemMetricsForDpi) + _glfwPlatformGetModuleSymbol(_glfw.win32.user32.instance, "GetSystemMetricsForDpi"); _glfw.win32.dinput8.instance = _glfwPlatformLoadModule("dinput8.dll"); if (_glfw.win32.dinput8.instance) diff --git a/src/win32_platform.h b/src/win32_platform.h index a7130377..2e84937a 100644 --- a/src/win32_platform.h +++ b/src/win32_platform.h @@ -283,12 +283,14 @@ typedef BOOL (WINAPI * PFN_EnableNonClientDpiScaling)(HWND); typedef BOOL (WINAPI * PFN_SetProcessDpiAwarenessContext)(HANDLE); typedef UINT (WINAPI * PFN_GetDpiForWindow)(HWND); typedef BOOL (WINAPI * PFN_AdjustWindowRectExForDpi)(LPRECT,DWORD,BOOL,DWORD,UINT); +typedef int (WINAPI * PFN_GetSystemMetricsForDpi)(int,UINT); #define SetProcessDPIAware _glfw.win32.user32.SetProcessDPIAware_ #define ChangeWindowMessageFilterEx _glfw.win32.user32.ChangeWindowMessageFilterEx_ #define EnableNonClientDpiScaling _glfw.win32.user32.EnableNonClientDpiScaling_ #define SetProcessDpiAwarenessContext _glfw.win32.user32.SetProcessDpiAwarenessContext_ #define GetDpiForWindow _glfw.win32.user32.GetDpiForWindow_ #define AdjustWindowRectExForDpi _glfw.win32.user32.AdjustWindowRectExForDpi_ +#define GetSystemMetricsForDpi _glfw.win32.user32.GetSystemMetricsForDpi_ // dwmapi.dll function pointer typedefs typedef HRESULT (WINAPI * PFN_DwmIsCompositionEnabled)(BOOL*); @@ -471,6 +473,7 @@ typedef struct _GLFWlibraryWin32 PFN_SetProcessDpiAwarenessContext SetProcessDpiAwarenessContext_; PFN_GetDpiForWindow GetDpiForWindow_; PFN_AdjustWindowRectExForDpi AdjustWindowRectExForDpi_; + PFN_GetSystemMetricsForDpi GetSystemMetricsForDpi_; } user32; struct { diff --git a/src/win32_window.c b/src/win32_window.c index 0f76cf56..400c50c0 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -484,6 +484,59 @@ static void releaseMonitor(_GLFWwindow* window) _glfwRestoreVideoModeWin32(window->monitor); } +// Manually maximize the window, for when SW_MAXIMIZE cannot be used +// +static void maximizeWindowManually(_GLFWwindow* window) +{ + RECT rect; + DWORD style; + MONITORINFO mi = { sizeof(mi) }; + + GetMonitorInfo(MonitorFromWindow(window->win32.handle, + MONITOR_DEFAULTTONEAREST), &mi); + + rect = mi.rcWork; + + if (window->maxwidth != GLFW_DONT_CARE && window->maxheight != GLFW_DONT_CARE) + { + if (rect.right - rect.left > window->maxwidth) + rect.right = rect.left + window->maxwidth; + if (rect.bottom - rect.top > window->maxheight) + rect.bottom = rect.top + window->maxheight; + } + + style = GetWindowLongW(window->win32.handle, GWL_STYLE); + style |= WS_MAXIMIZE; + SetWindowLongW(window->win32.handle, GWL_STYLE, style); + + if (window->decorated) + { + const DWORD exStyle = GetWindowLongW(window->win32.handle, GWL_EXSTYLE); + + if (_glfwIsWindows10AnniversaryUpdateOrGreaterWin32()) + { + const UINT dpi = GetDpiForWindow(window->win32.handle); + AdjustWindowRectExForDpi(&rect, style, FALSE, exStyle, dpi); + OffsetRect(&rect, 0, GetSystemMetricsForDpi(SM_CYCAPTION, dpi)); + } + else + { + AdjustWindowRectEx(&rect, style, FALSE, exStyle); + OffsetRect(&rect, 0, GetSystemMetrics(SM_CYCAPTION)); + } + + if (rect.bottom > mi.rcWork.bottom) + rect.bottom = mi.rcWork.bottom; + } + + SetWindowPos(window->win32.handle, HWND_TOP, + rect.left, + rect.top, + rect.right - rect.left, + rect.bottom - rect.top, + SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED); +} + // Window callback function (handles window messages) // static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, @@ -1688,7 +1741,10 @@ void _glfwRestoreWindowWin32(_GLFWwindow* window) void _glfwMaximizeWindowWin32(_GLFWwindow* window) { - ShowWindow(window->win32.handle, SW_MAXIMIZE); + if (IsWindowVisible(window->win32.handle)) + ShowWindow(window->win32.handle, SW_MAXIMIZE); + else + maximizeWindowManually(window); } void _glfwShowWindowWin32(_GLFWwindow* window) From 8ff9ed92b446831e76b434c601b3d1b0d4220c82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 8 Mar 2022 23:45:53 +0100 Subject: [PATCH 148/208] Win32: Fix calls to encoding compatibility macros Calls to Unicode specific functions should be made explicit. --- src/win32_init.c | 2 +- src/win32_joystick.c | 2 +- src/win32_monitor.c | 2 +- src/win32_window.c | 26 +++++++++++++------------- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/win32_init.c b/src/win32_init.c index dfaf3d64..dce4e682 100644 --- a/src/win32_init.c +++ b/src/win32_init.c @@ -490,7 +490,7 @@ void _glfwUpdateKeyNamesWin32(void) vk = vks[key - GLFW_KEY_KP_0]; } else - vk = MapVirtualKey(scancode, MAPVK_VSC_TO_VK); + vk = MapVirtualKeyW(scancode, MAPVK_VSC_TO_VK); length = ToUnicode(vk, scancode, state, chars, sizeof(chars) / sizeof(WCHAR), diff --git a/src/win32_joystick.c b/src/win32_joystick.c index e45e0798..929a19cf 100644 --- a/src/win32_joystick.c +++ b/src/win32_joystick.c @@ -574,7 +574,7 @@ GLFWbool _glfwInitJoysticksWin32(void) { if (_glfw.win32.dinput8.instance) { - if (FAILED(DirectInput8Create(GetModuleHandle(NULL), + if (FAILED(DirectInput8Create(GetModuleHandleW(NULL), DIRECTINPUT_VERSION, &IID_IDirectInput8W, (void**) &_glfw.win32.dinput8.api, diff --git a/src/win32_monitor.c b/src/win32_monitor.c index cdee49a9..57b44af3 100644 --- a/src/win32_monitor.c +++ b/src/win32_monitor.c @@ -381,7 +381,7 @@ void _glfwGetMonitorWorkareaWin32(_GLFWmonitor* monitor, int* width, int* height) { MONITORINFO mi = { sizeof(mi) }; - GetMonitorInfo(monitor->win32.handle, &mi); + GetMonitorInfoW(monitor->win32.handle, &mi); if (xpos) *xpos = mi.rcWork.left; diff --git a/src/win32_window.c b/src/win32_window.c index 400c50c0..42518934 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -434,7 +434,7 @@ static int getKeyMods(void) static void fitToMonitor(_GLFWwindow* window) { MONITORINFO mi = { sizeof(mi) }; - GetMonitorInfo(window->monitor->win32.handle, &mi); + GetMonitorInfoW(window->monitor->win32.handle, &mi); SetWindowPos(window->win32.handle, HWND_TOPMOST, mi.rcMonitor.left, mi.rcMonitor.top, @@ -453,8 +453,8 @@ static void acquireMonitor(_GLFWwindow* window) // HACK: When mouse trails are enabled the cursor becomes invisible when // the OpenGL ICD switches to page flipping - SystemParametersInfo(SPI_GETMOUSETRAILS, 0, &_glfw.win32.mouseTrailSize, 0); - SystemParametersInfo(SPI_SETMOUSETRAILS, 0, 0, 0); + SystemParametersInfoW(SPI_GETMOUSETRAILS, 0, &_glfw.win32.mouseTrailSize, 0); + SystemParametersInfoW(SPI_SETMOUSETRAILS, 0, 0, 0); } if (!window->monitor->window) @@ -477,7 +477,7 @@ static void releaseMonitor(_GLFWwindow* window) SetThreadExecutionState(ES_CONTINUOUS); // HACK: Restore mouse trail length saved in acquireMonitor - SystemParametersInfo(SPI_SETMOUSETRAILS, _glfw.win32.mouseTrailSize, 0, 0); + SystemParametersInfoW(SPI_SETMOUSETRAILS, _glfw.win32.mouseTrailSize, 0, 0); } _glfwInputMonitorWindow(window->monitor, NULL); @@ -492,8 +492,8 @@ static void maximizeWindowManually(_GLFWwindow* window) DWORD style; MONITORINFO mi = { sizeof(mi) }; - GetMonitorInfo(MonitorFromWindow(window->win32.handle, - MONITOR_DEFAULTTONEAREST), &mi); + GetMonitorInfoW(MonitorFromWindow(window->win32.handle, + MONITOR_DEFAULTTONEAREST), &mi); rect = mi.rcWork; @@ -1126,7 +1126,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, ZeroMemory(&mi, sizeof(mi)); mi.cbSize = sizeof(mi); - GetMonitorInfo(mh, &mi); + GetMonitorInfoW(mh, &mi); mmi->ptMaxPosition.x = mi.rcWork.left - mi.rcMonitor.left; mmi->ptMaxPosition.y = mi.rcWork.top - mi.rcMonitor.top; @@ -1392,7 +1392,7 @@ static int createNativeWindow(_GLFWwindow* window, if (wndconfig->maximized && !wndconfig->decorated) { MONITORINFO mi = { sizeof(mi) }; - GetMonitorInfo(mh, &mi); + GetMonitorInfoW(mh, &mi); SetWindowPos(window->win32.handle, HWND_TOP, mi.rcWork.left, @@ -1561,8 +1561,8 @@ void _glfwSetWindowIconWin32(_GLFWwindow* window, smallIcon = (HICON) GetClassLongPtrW(window->win32.handle, GCLP_HICONSM); } - SendMessage(window->win32.handle, WM_SETICON, ICON_BIG, (LPARAM) bigIcon); - SendMessage(window->win32.handle, WM_SETICON, ICON_SMALL, (LPARAM) smallIcon); + SendMessageW(window->win32.handle, WM_SETICON, ICON_BIG, (LPARAM) bigIcon); + SendMessageW(window->win32.handle, WM_SETICON, ICON_SMALL, (LPARAM) smallIcon); if (window->win32.bigIcon) DestroyIcon(window->win32.bigIcon); @@ -1831,7 +1831,7 @@ void _glfwSetWindowMonitorWin32(_GLFWwindow* window, acquireMonitor(window); - GetMonitorInfo(window->monitor->win32.handle, &mi); + GetMonitorInfoW(window->monitor->win32.handle, &mi); SetWindowPos(window->win32.handle, HWND_TOPMOST, mi.rcMonitor.left, mi.rcMonitor.top, @@ -2128,7 +2128,7 @@ void _glfwWaitEventsTimeoutWin32(double timeout) void _glfwPostEmptyEventWin32(void) { - PostMessage(_glfw.win32.helperWindowHandle, WM_NULL, 0, 0); + PostMessageW(_glfw.win32.helperWindowHandle, WM_NULL, 0, 0); } void _glfwGetCursorPosWin32(_GLFWwindow* window, double* xpos, double* ypos) @@ -2445,7 +2445,7 @@ VkResult _glfwCreateWindowSurfaceWin32(VkInstance instance, memset(&sci, 0, sizeof(sci)); sci.sType = VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR; - sci.hinstance = GetModuleHandle(NULL); + sci.hinstance = GetModuleHandleW(NULL); sci.hwnd = window->win32.handle; err = vkCreateWin32SurfaceKHR(instance, &sci, allocator, surface); From 34573798f4dbbce4bc169ccbfaf9cd189c76ed10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 9 Mar 2022 17:30:06 +0100 Subject: [PATCH 149/208] Win32: Rename Windows 10 macros for clarity This switches the Windows 10 version helper macros to include the version numbers listed in MSDN requirements sections. --- src/win32_init.c | 4 ++-- src/win32_platform.h | 6 ++++-- src/win32_window.c | 28 ++++++++++++++-------------- 3 files changed, 20 insertions(+), 18 deletions(-) diff --git a/src/win32_init.c b/src/win32_init.c index dce4e682..27527dd1 100644 --- a/src/win32_init.c +++ b/src/win32_init.c @@ -463,7 +463,7 @@ void _glfwUpdateKeyNamesWin32(void) UINT flags = 0; // Avoid modifying the global key state if supported - if (_glfwIsWindows10AnniversaryUpdateOrGreaterWin32()) + if (_glfwIsWindows10Version1607OrGreaterWin32()) flags = (1 << 2); memset(_glfw.win32.keynames, 0, sizeof(_glfw.win32.keynames)); @@ -633,7 +633,7 @@ int _glfwInitWin32(void) createKeyTables(); _glfwUpdateKeyNamesWin32(); - if (_glfwIsWindows10CreatorsUpdateOrGreaterWin32()) + if (_glfwIsWindows10Version1703OrGreaterWin32()) SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2); else if (IsWindows8Point1OrGreater()) SetProcessDpiAwareness(PROCESS_PER_MONITOR_DPI_AWARE); diff --git a/src/win32_platform.h b/src/win32_platform.h index 2e84937a..841cf6a0 100644 --- a/src/win32_platform.h +++ b/src/win32_platform.h @@ -176,9 +176,11 @@ typedef enum _glfwIsWindowsVersionOrGreaterWin32(HIBYTE(_WIN32_WINNT_WINBLUE), \ LOBYTE(_WIN32_WINNT_WINBLUE), 0) -#define _glfwIsWindows10AnniversaryUpdateOrGreaterWin32() \ +// Windows 10 Anniversary Update +#define _glfwIsWindows10Version1607OrGreaterWin32() \ _glfwIsWindows10BuildOrGreaterWin32(14393) -#define _glfwIsWindows10CreatorsUpdateOrGreaterWin32() \ +// Windows 10 Creators Update +#define _glfwIsWindows10Version1703OrGreaterWin32() \ _glfwIsWindows10BuildOrGreaterWin32(15063) // HACK: Define macros that some xinput.h variants don't diff --git a/src/win32_window.c b/src/win32_window.c index 42518934..4a3bc2e0 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -194,7 +194,7 @@ static void getFullWindowSize(DWORD style, DWORD exStyle, { RECT rect = { 0, 0, contentWidth, contentHeight }; - if (_glfwIsWindows10AnniversaryUpdateOrGreaterWin32()) + if (_glfwIsWindows10Version1607OrGreaterWin32()) AdjustWindowRectExForDpi(&rect, style, FALSE, exStyle, dpi); else AdjustWindowRectEx(&rect, style, FALSE, exStyle); @@ -211,7 +211,7 @@ static void applyAspectRatio(_GLFWwindow* window, int edge, RECT* area) UINT dpi = USER_DEFAULT_SCREEN_DPI; const float ratio = (float) window->numer / (float) window->denom; - if (_glfwIsWindows10AnniversaryUpdateOrGreaterWin32()) + if (_glfwIsWindows10Version1607OrGreaterWin32()) dpi = GetDpiForWindow(window->win32.handle); getFullWindowSize(getWindowStyle(window), getWindowExStyle(window), @@ -354,7 +354,7 @@ static void updateWindowStyles(const _GLFWwindow* window) GetClientRect(window->win32.handle, &rect); - if (_glfwIsWindows10AnniversaryUpdateOrGreaterWin32()) + if (_glfwIsWindows10Version1607OrGreaterWin32()) { AdjustWindowRectExForDpi(&rect, style, FALSE, getWindowExStyle(window), @@ -513,7 +513,7 @@ static void maximizeWindowManually(_GLFWwindow* window) { const DWORD exStyle = GetWindowLongW(window->win32.handle, GWL_EXSTYLE); - if (_glfwIsWindows10AnniversaryUpdateOrGreaterWin32()) + if (_glfwIsWindows10Version1607OrGreaterWin32()) { const UINT dpi = GetDpiForWindow(window->win32.handle); AdjustWindowRectExForDpi(&rect, style, FALSE, exStyle, dpi); @@ -552,7 +552,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, { case WM_NCCREATE: { - if (_glfwIsWindows10AnniversaryUpdateOrGreaterWin32()) + if (_glfwIsWindows10Version1607OrGreaterWin32()) { const CREATESTRUCTW* cs = (const CREATESTRUCTW*) lParam; const _GLFWwndconfig* wndconfig = cs->lpCreateParams; @@ -1098,7 +1098,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, if (window->monitor) break; - if (_glfwIsWindows10AnniversaryUpdateOrGreaterWin32()) + if (_glfwIsWindows10Version1607OrGreaterWin32()) dpi = GetDpiForWindow(window->win32.handle); getFullWindowSize(getWindowStyle(window), getWindowExStyle(window), @@ -1173,7 +1173,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, break; // Adjust the window size to keep the content area size constant - if (_glfwIsWindows10CreatorsUpdateOrGreaterWin32()) + if (_glfwIsWindows10Version1703OrGreaterWin32()) { RECT source = {0}, target = {0}; SIZE* size = (SIZE*) lParam; @@ -1204,7 +1204,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, // need it to compensate for non-client area scaling if (!window->monitor && (window->win32.scaleToMonitor || - _glfwIsWindows10CreatorsUpdateOrGreaterWin32())) + _glfwIsWindows10Version1703OrGreaterWin32())) { RECT* suggested = (RECT*) lParam; SetWindowPos(window->win32.handle, HWND_TOP, @@ -1369,7 +1369,7 @@ static int createNativeWindow(_GLFWwindow* window, } } - if (_glfwIsWindows10AnniversaryUpdateOrGreaterWin32()) + if (_glfwIsWindows10Version1607OrGreaterWin32()) { AdjustWindowRectExForDpi(&rect, style, FALSE, exStyle, GetDpiForWindow(window->win32.handle)); @@ -1592,7 +1592,7 @@ void _glfwSetWindowPosWin32(_GLFWwindow* window, int xpos, int ypos) { RECT rect = { xpos, ypos, xpos, ypos }; - if (_glfwIsWindows10AnniversaryUpdateOrGreaterWin32()) + if (_glfwIsWindows10Version1607OrGreaterWin32()) { AdjustWindowRectExForDpi(&rect, getWindowStyle(window), FALSE, getWindowExStyle(window), @@ -1633,7 +1633,7 @@ void _glfwSetWindowSizeWin32(_GLFWwindow* window, int width, int height) { RECT rect = { 0, 0, width, height }; - if (_glfwIsWindows10AnniversaryUpdateOrGreaterWin32()) + if (_glfwIsWindows10Version1607OrGreaterWin32()) { AdjustWindowRectExForDpi(&rect, getWindowStyle(window), FALSE, getWindowExStyle(window), @@ -1700,7 +1700,7 @@ void _glfwGetWindowFrameSizeWin32(_GLFWwindow* window, _glfwGetWindowSizeWin32(window, &width, &height); SetRect(&rect, 0, 0, width, height); - if (_glfwIsWindows10AnniversaryUpdateOrGreaterWin32()) + if (_glfwIsWindows10Version1607OrGreaterWin32()) { AdjustWindowRectExForDpi(&rect, getWindowStyle(window), FALSE, getWindowExStyle(window), @@ -1789,7 +1789,7 @@ void _glfwSetWindowMonitorWin32(_GLFWwindow* window, { RECT rect = { xpos, ypos, xpos + width, ypos + height }; - if (_glfwIsWindows10AnniversaryUpdateOrGreaterWin32()) + if (_glfwIsWindows10Version1607OrGreaterWin32()) { AdjustWindowRectExForDpi(&rect, getWindowStyle(window), FALSE, getWindowExStyle(window), @@ -1860,7 +1860,7 @@ void _glfwSetWindowMonitorWin32(_GLFWwindow* window, else after = HWND_NOTOPMOST; - if (_glfwIsWindows10AnniversaryUpdateOrGreaterWin32()) + if (_glfwIsWindows10Version1607OrGreaterWin32()) { AdjustWindowRectExForDpi(&rect, getWindowStyle(window), FALSE, getWindowExStyle(window), From aa803f7de5cc086b1c335161a50016f23c49882a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 9 Mar 2022 18:18:04 +0100 Subject: [PATCH 150/208] Win32: Update rationale for reimplementation It is true that plain MinGW lacks this header, but that is not the main reason for reimplementing IsWindowsVersionOrGreater. --- src/win32_init.c | 3 ++- src/win32_platform.h | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/win32_init.c b/src/win32_init.c index 27527dd1..7b468841 100644 --- a/src/win32_init.c +++ b/src/win32_init.c @@ -513,7 +513,8 @@ void _glfwUpdateKeyNamesWin32(void) } } -// Replacement for IsWindowsVersionOrGreater as MinGW lacks versionhelpers.h +// Replacement for IsWindowsVersionOrGreater, as we cannot rely on the +// application having a correct embedded manifest // BOOL _glfwIsWindowsVersionOrGreaterWin32(WORD major, WORD minor, WORD sp) { diff --git a/src/win32_platform.h b/src/win32_platform.h index 841cf6a0..0958b076 100644 --- a/src/win32_platform.h +++ b/src/win32_platform.h @@ -162,7 +162,9 @@ typedef enum #define DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 ((HANDLE) -4) #endif /*DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2*/ -// HACK: Define versionhelpers.h functions manually as MinGW lacks the header +// Replacement for versionhelpers.h macros, as we cannot rely on the +// application having a correct embedded manifest +// #define IsWindowsVistaOrGreater() \ _glfwIsWindowsVersionOrGreaterWin32(HIBYTE(_WIN32_WINNT_VISTA), \ LOBYTE(_WIN32_WINNT_VISTA), 0) From 8f9ff8503e0a3dc143c1bdb19327dd29c3ee2d57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 9 Mar 2022 23:06:13 +0100 Subject: [PATCH 151/208] Formatting --- src/win32_window.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/win32_window.c b/src/win32_window.c index 4a3bc2e0..c6351a91 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -97,8 +97,7 @@ static const GLFWimage* chooseImage(int count, const GLFWimage* images, // Creates an RGBA icon or cursor // -static HICON createIcon(const GLFWimage* image, - int xhot, int yhot, GLFWbool icon) +static HICON createIcon(const GLFWimage* image, int xhot, int yhot, GLFWbool icon) { int i; HDC dc; @@ -539,8 +538,7 @@ static void maximizeWindowManually(_GLFWwindow* window) // Window callback function (handles window messages) // -static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, - WPARAM wParam, LPARAM lParam) +static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { _GLFWwindow* window = GetPropW(hWnd, L"GLFW"); if (!window) @@ -1538,8 +1536,7 @@ void _glfwSetWindowTitleWin32(_GLFWwindow* window, const char* title) _glfw_free(wideTitle); } -void _glfwSetWindowIconWin32(_GLFWwindow* window, - int count, const GLFWimage* images) +void _glfwSetWindowIconWin32(_GLFWwindow* window, int count, const GLFWimage* images) { HICON bigIcon = NULL, smallIcon = NULL; @@ -1652,8 +1649,8 @@ void _glfwSetWindowSizeWin32(_GLFWwindow* window, int width, int height) } void _glfwSetWindowSizeLimitsWin32(_GLFWwindow* window, - int minwidth, int minheight, - int maxwidth, int maxheight) + int minwidth, int minheight, + int maxwidth, int maxheight) { RECT area; @@ -1691,8 +1688,8 @@ void _glfwGetFramebufferSizeWin32(_GLFWwindow* window, int* width, int* height) } void _glfwGetWindowFrameSizeWin32(_GLFWwindow* window, - int* left, int* top, - int* right, int* bottom) + int* left, int* top, + int* right, int* bottom) { RECT rect; int width, height; @@ -2189,8 +2186,8 @@ int _glfwGetKeyScancodeWin32(int key) } int _glfwCreateCursorWin32(_GLFWcursor* cursor, - const GLFWimage* image, - int xhot, int yhot) + const GLFWimage* image, + int xhot, int yhot) { cursor->win32.handle = (HCURSOR) createIcon(image, xhot, yhot, GLFW_FALSE); if (!cursor->win32.handle) From b54fb0af10bb0167df67fece984350e66bf569ce Mon Sep 17 00:00:00 2001 From: Slemmie Date: Fri, 20 Aug 2021 06:41:59 +0200 Subject: [PATCH 152/208] X11: Fix undefined behavior in bit shift of int Closes #1951 --- src/x11_window.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/x11_window.c b/src/x11_window.c index 6c329e63..dcde3443 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -1267,7 +1267,7 @@ static void processEvent(XEvent *event) // (the server never sends a timestamp of zero) // NOTE: Timestamp difference is compared to handle wrap-around Time diff = event->xkey.time - window->x11.keyPressTimes[keycode]; - if (diff == event->xkey.time || (diff > 0 && diff < (1 << 31))) + if (diff == event->xkey.time || (diff > 0 && diff < ((Time)1 << 31))) { if (keycode) _glfwInputKey(window, key, keycode, GLFW_PRESS, mods); From 1461c59aa2426b25503102e62bc8f4b65e079c5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 10 Mar 2022 20:04:56 +0100 Subject: [PATCH 153/208] Update changelog and add credit Related to #1951 --- CONTRIBUTORS.md | 1 + README.md | 1 + 2 files changed, 2 insertions(+) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index f20422ec..406ebd02 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -188,6 +188,7 @@ video tutorials. - Joao da Silva - Daniel Sieger - Daniel Skorupski + - Slemmie - Anthony Smith - Bradley Smith - Cliff Smolinsky diff --git a/README.md b/README.md index f3bff91d..7560284d 100644 --- a/README.md +++ b/README.md @@ -280,6 +280,7 @@ information on what to include when reporting a bug. - [X11] Bugfix: `glfwPostEmptyEvent` could be ignored due to race condition (#379,#1281,#1285,#2033) - [X11] Bugfix: Dynamic loading on NetBSD failed due to soname differences + - [X11] Bugfix: Left shift of int constant relied on undefined behavior (#1951) - [Wayland] Added dynamic loading of all Wayland libraries - [Wayland] Added support for key names via xkbcommon - [Wayland] Removed support for `wl_shell` (#1443) From 46950a5e61ae6febb6dd554aea212f9130927b98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Sun, 13 Mar 2022 15:18:39 +0100 Subject: [PATCH 154/208] Fix button field names in input guide Fixes #2056 --- CONTRIBUTORS.md | 1 + docs/input.dox | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 406ebd02..88645126 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -30,6 +30,7 @@ video tutorials. - David Carlier - Arturo Castro - Chi-kwan Chan + - TheChocolateOre - Joseph Chua - Ian Clarkson - MichaÅ‚ CichoÅ„ diff --git a/docs/input.dox b/docs/input.dox index dcd8f670..faa94cd4 100644 --- a/docs/input.dox +++ b/docs/input.dox @@ -821,7 +821,7 @@ The second value is always the human-readable name of the gamepad. All subsequent values are in the form `:` and describe the layout of the mapping. These fields may not all be present and may occur in any order. -The button fields are `a`, `b`, `c`, `d`, `back`, `start`, `guide`, `dpup`, +The button fields are `a`, `b`, `x`, `y`, `back`, `start`, `guide`, `dpup`, `dpright`, `dpdown`, `dpleft`, `leftshoulder`, `rightshoulder`, `leftstick` and `rightstick`. From 9cc252a406b79c31ab82648a21b715e2d3fc7ece Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Sun, 13 Mar 2022 15:57:56 +0100 Subject: [PATCH 155/208] Revert ad01c1b614868c3cbc79306aa6a19c9fc06f34a6 This change broke key names for dead keys, because that depends on the effect on the global state of simulating two key presses. Issue found by CTest tests. Reverts #2018 --- README.md | 2 -- src/win32_init.c | 9 ++------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 7560284d..715a5248 100644 --- a/README.md +++ b/README.md @@ -205,8 +205,6 @@ information on what to include when reporting a bug. - [Win32] Bugfix: Content scale queries could fail silently (#1615) - [Win32] Bugfix: Content scales could have garbage values if monitor was recently disconnected (#1615) - - [Win32] Bugfix: Key name update modified global key state on Windows 10 1607 - and later (#2018) - [Win32] Bugfix: A window created maximized and undecorated would cover the whole monitor (#1806) - [Win32] Bugfix: The default restored window position was lost when creating a maximized diff --git a/src/win32_init.c b/src/win32_init.c index 7b468841..ee3dad54 100644 --- a/src/win32_init.c +++ b/src/win32_init.c @@ -460,11 +460,6 @@ void _glfwUpdateKeyNamesWin32(void) { int key; BYTE state[256] = {0}; - UINT flags = 0; - - // Avoid modifying the global key state if supported - if (_glfwIsWindows10Version1607OrGreaterWin32()) - flags = (1 << 2); memset(_glfw.win32.keynames, 0, sizeof(_glfw.win32.keynames)); @@ -494,13 +489,13 @@ void _glfwUpdateKeyNamesWin32(void) length = ToUnicode(vk, scancode, state, chars, sizeof(chars) / sizeof(WCHAR), - flags); + 0); if (length == -1) { length = ToUnicode(vk, scancode, state, chars, sizeof(chars) / sizeof(WCHAR), - flags); + 0); } if (length < 1) From 3ee5031fd7dcac5ecb7387d3dd73195f03e87398 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 14 Mar 2022 16:01:34 +0100 Subject: [PATCH 156/208] Add shared min and max functions for int --- src/init.c | 10 ++++++++++ src/internal.h | 2 ++ src/null_window.c | 16 ++++++++-------- src/win32_window.c | 9 +++------ src/wl_init.c | 9 ++------- src/wl_window.c | 6 +----- 6 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/init.c b/src/init.c index 80f424a8..9f0316ac 100644 --- a/src/init.c +++ b/src/init.c @@ -179,6 +179,16 @@ char* _glfw_strdup(const char* source) return result; } +int _glfw_min(int a, int b) +{ + return a < b ? a : b; +} + +int _glfw_max(int a, int b) +{ + return a > b ? a : b; +} + float _glfw_fminf(float a, float b) { if (a != a) diff --git a/src/internal.h b/src/internal.h index f8548fa3..b7dc13a0 100644 --- a/src/internal.h +++ b/src/internal.h @@ -998,6 +998,8 @@ const char* _glfwGetVulkanResultString(VkResult result); size_t _glfwEncodeUTF8(char* s, uint32_t codepoint); char* _glfw_strdup(const char* source); +int _glfw_min(int a, int b); +int _glfw_max(int a, int b); float _glfw_fminf(float a, float b); float _glfw_fmaxf(float a, float b); diff --git a/src/null_window.c b/src/null_window.c index 710d4c9c..7e87b9da 100644 --- a/src/null_window.c +++ b/src/null_window.c @@ -39,15 +39,15 @@ static void applySizeLimits(_GLFWwindow* window, int* width, int* height) *height = (int) (*width / ratio); } - if (window->minwidth != GLFW_DONT_CARE && *width < window->minwidth) - *width = window->minwidth; - else if (window->maxwidth != GLFW_DONT_CARE && *width > window->maxwidth) - *width = window->maxwidth; + if (window->minwidth != GLFW_DONT_CARE) + *width = _glfw_max(*width, window->minwidth); + else if (window->maxwidth != GLFW_DONT_CARE) + *width = _glfw_min(*width, window->maxwidth); - if (window->minheight != GLFW_DONT_CARE && *height < window->minheight) - *height = window->minheight; - else if (window->maxheight != GLFW_DONT_CARE && *height > window->maxheight) - *height = window->maxheight; + if (window->minheight != GLFW_DONT_CARE) + *height = _glfw_min(*height, window->minheight); + else if (window->maxheight != GLFW_DONT_CARE) + *height = _glfw_max(*height, window->maxheight); } static void fitToMonitor(_GLFWwindow* window) diff --git a/src/win32_window.c b/src/win32_window.c index c6351a91..5448eddc 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -498,10 +498,8 @@ static void maximizeWindowManually(_GLFWwindow* window) if (window->maxwidth != GLFW_DONT_CARE && window->maxheight != GLFW_DONT_CARE) { - if (rect.right - rect.left > window->maxwidth) - rect.right = rect.left + window->maxwidth; - if (rect.bottom - rect.top > window->maxheight) - rect.bottom = rect.top + window->maxheight; + rect.right = _glfw_min(rect.right, rect.left + window->maxwidth); + rect.bottom = _glfw_min(rect.bottom, rect.top + window->maxheight); } style = GetWindowLongW(window->win32.handle, GWL_STYLE); @@ -524,8 +522,7 @@ static void maximizeWindowManually(_GLFWwindow* window) OffsetRect(&rect, 0, GetSystemMetrics(SM_CYCAPTION)); } - if (rect.bottom > mi.rcWork.bottom) - rect.bottom = mi.rcWork.bottom; + rect.bottom = _glfw_min(rect.bottom, mi.rcWork.bottom); } SetWindowPos(window->win32.handle, HWND_TOP, diff --git a/src/wl_init.c b/src/wl_init.c index e4ae6666..f02c6320 100644 --- a/src/wl_init.c +++ b/src/wl_init.c @@ -57,11 +57,6 @@ #include "wayland-idle-inhibit-unstable-v1-client-protocol-code.h" -static inline int min(int n1, int n2) -{ - return n1 < n2 ? n1 : n2; -} - static _GLFWwindow* findWindowFromDecorationSurface(struct wl_surface* surface, int* which) { @@ -788,7 +783,7 @@ static void registryHandleGlobal(void* data, { if (strcmp(interface, "wl_compositor") == 0) { - _glfw.wl.compositorVersion = min(3, version); + _glfw.wl.compositorVersion = _glfw_min(3, version); _glfw.wl.compositor = wl_registry_bind(registry, name, &wl_compositor_interface, _glfw.wl.compositorVersion); @@ -811,7 +806,7 @@ static void registryHandleGlobal(void* data, { if (!_glfw.wl.seat) { - _glfw.wl.seatVersion = min(4, version); + _glfw.wl.seatVersion = _glfw_min(4, version); _glfw.wl.seat = wl_registry_bind(registry, name, &wl_seat_interface, _glfw.wl.seatVersion); diff --git a/src/wl_window.c b/src/wl_window.c index 54257b25..8c47d710 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -353,11 +353,7 @@ static void checkScaleChange(_GLFWwindow* window) int maxScale = 1; for (int i = 0; i < window->wl.monitorsCount; i++) - { - const int scale = window->wl.monitors[i]->wl.scale; - if (maxScale < scale) - maxScale = scale; - } + maxScale = _glfw_max(window->wl.monitors[i]->wl.scale, maxScale); // Only change the framebuffer size if the scale changed. if (window->wl.scale != maxScale) From 535c3ce63240ee91f998219b35dc82abef545c3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 15 Mar 2022 17:51:57 +0100 Subject: [PATCH 157/208] Fix GLAPIENTRY redefinition warning On a Unix system, if you define GLFW_INCLUDE_NONE and GLFW_EXPOSE_NATIVE_GLX, then include glfw3.h and glfw3native.h, you will get a redefinition warning for GLAPIENTRY. The glfw3.h header defines GLAPIENTRY as a service for OpenGL related headers that assume it's already defined. However, glx.h includes gl.h, which defines GLAPIENTRY unconditionally. If not for Hyrum's law, the better solution would have been not to define GLAPIENTRY if GLFW_INCLUDE_NONE is defined. Fixes #2010 --- include/GLFW/glfw3native.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/include/GLFW/glfw3native.h b/include/GLFW/glfw3native.h index 41b2f86b..da4b7572 100644 --- a/include/GLFW/glfw3native.h +++ b/include/GLFW/glfw3native.h @@ -111,12 +111,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 #endif #if defined(GLFW_EXPOSE_NATIVE_EGL) #include #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 #endif From add0521efb1fc0e95082716748b7aad837753fba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 15 Mar 2022 17:59:57 +0100 Subject: [PATCH 158/208] Fix accidental C99 in C89 header --- include/GLFW/glfw3native.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/include/GLFW/glfw3native.h b/include/GLFW/glfw3native.h index da4b7572..11fee09d 100644 --- a/include/GLFW/glfw3native.h +++ b/include/GLFW/glfw3native.h @@ -82,9 +82,10 @@ 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 From 03cfe957e739e41cdfd66b554c076b5b31f48c1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 15 Mar 2022 19:12:29 +0100 Subject: [PATCH 159/208] Win32: Fix scancode and key for Alt+PrtSc events Alt+PrtSc emits a different scancode than just PrtSc. Since the GLFW API assumes each key corresponds to only one scancode, this cannot be added to the keycodes array. Instead we replace the scancode at the point of entry. Fixes #1993 --- CONTRIBUTORS.md | 1 + README.md | 2 ++ src/win32_window.c | 4 ++++ 3 files changed, 7 insertions(+) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 88645126..bb70c1f5 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -70,6 +70,7 @@ video tutorials. - Ryan C. Gordon - Stephen Gowen - Kovid Goyal + - Kevin Grandemange - Eloi Marín Gratacós - Stefan Gustavson - Andrew Gutekanst diff --git a/README.md b/README.md index 715a5248..e81997ba 100644 --- a/README.md +++ b/README.md @@ -210,6 +210,8 @@ information on what to include when reporting a bug. - [Win32] Bugfix: The default restored window position was lost when creating a maximized window - [Win32] Bugfix: `glfwMaximizeWindow` would make a hidden window visible + - [Win32] Bugfix: `Alt+PrtSc` would emit `GLFW_KEY_UNKNOWN` and a different + scancode than `PrtSc` (#1993) - [Cocoa] Added support for `VK_EXT_metal_surface` (#1619) - [Cocoa] Added locating the Vulkan loader at runtime in an application bundle - [Cocoa] Moved main menu creation to GLFW initialization time (#1649) diff --git a/src/win32_window.c b/src/win32_window.c index 5448eddc..1d207d8b 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -752,6 +752,10 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM l scancode = MapVirtualKeyW((UINT) wParam, MAPVK_VK_TO_VSC); } + // HACK: Alt+PrtSc has a different scancode than just PrtSc + if (scancode == 0x54) + scancode = 0x137; + key = _glfw.win32.keycodes[scancode]; // The Ctrl keys require special handling From 8d9231fe5ec82c3a0a7bddfcd3a409759a7a45d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 15 Mar 2022 19:22:21 +0100 Subject: [PATCH 160/208] Win32: Fix glfwGetKeyScancode for GLFW_KEY_PAUSE The bug described in 03cfe957e739e41cdfd66b554c076b5b31f48c1e was already present for another key where modifiers changes its scancode. Related to #1993 --- README.md | 2 ++ src/win32_init.c | 1 - src/win32_window.c | 4 ++++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e81997ba..d931de54 100644 --- a/README.md +++ b/README.md @@ -212,6 +212,8 @@ information on what to include when reporting a bug. - [Win32] Bugfix: `glfwMaximizeWindow` would make a hidden window visible - [Win32] Bugfix: `Alt+PrtSc` would emit `GLFW_KEY_UNKNOWN` and a different scancode than `PrtSc` (#1993) + - [Win32] Bugfix: `GLFW_KEY_PAUSE` scancode from `glfwGetKeyScancode` did not + match event scancode (#1993) - [Cocoa] Added support for `VK_EXT_metal_surface` (#1619) - [Cocoa] Added locating the Vulkan loader at runtime in an application bundle - [Cocoa] Moved main menu creation to GLFW initialization time (#1649) diff --git a/src/win32_init.c b/src/win32_init.c index ee3dad54..31406401 100644 --- a/src/win32_init.c +++ b/src/win32_init.c @@ -253,7 +253,6 @@ static void createKeyTables(void) _glfw.win32.keycodes[0x151] = GLFW_KEY_PAGE_DOWN; _glfw.win32.keycodes[0x149] = GLFW_KEY_PAGE_UP; _glfw.win32.keycodes[0x045] = GLFW_KEY_PAUSE; - _glfw.win32.keycodes[0x146] = GLFW_KEY_PAUSE; _glfw.win32.keycodes[0x039] = GLFW_KEY_SPACE; _glfw.win32.keycodes[0x00F] = GLFW_KEY_TAB; _glfw.win32.keycodes[0x03A] = GLFW_KEY_CAPS_LOCK; diff --git a/src/win32_window.c b/src/win32_window.c index 1d207d8b..37e42c3d 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -756,6 +756,10 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM l if (scancode == 0x54) scancode = 0x137; + // HACK: Ctrl+Pause has a different scancode than just Pause + if (scancode == 0x146) + scancode = 0x45; + key = _glfw.win32.keycodes[scancode]; // The Ctrl keys require special handling From 66a4882eb14344115e9cda9f8c0f0c5d0362ca6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 15 Mar 2022 21:22:49 +0100 Subject: [PATCH 161/208] Add checks for some invalid values to public API There were no checks for invalid values or asserts for all invalid NULL pointers to glfwSetWindowIcon or glfwCreateCursor. Fixes #1862 --- CONTRIBUTORS.md | 1 + include/GLFW/glfw3.h | 7 ++++--- src/input.c | 7 +++++++ src/window.c | 21 +++++++++++++++++++++ 4 files changed, 33 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index bb70c1f5..577da149 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -84,6 +84,7 @@ video tutorials. - Paul Holden - Warren Hu - Charles Huber + - Brent Huisman - illustris - InKryption - IntellectualKitty diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index 72d5fa71..3f320065 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -3258,7 +3258,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. @@ -4892,8 +4893,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. diff --git a/src/input.c b/src/input.c index 6a2c3e1d..90ee5273 100644 --- a/src/input.c +++ b/src/input.c @@ -764,9 +764,16 @@ GLFWAPI GLFWcursor* glfwCreateCursor(const GLFWimage* image, int xhot, int yhot) _GLFWcursor* cursor; assert(image != NULL); + assert(image->pixels != NULL); _GLFW_REQUIRE_INIT_OR_RETURN(NULL); + if (image->width <= 0 || image->height <= 0) + { + _glfwInputError(GLFW_INVALID_VALUE, "Invalid image dimensions for cursor"); + return NULL; + } + cursor = _glfw_calloc(1, sizeof(_GLFWcursor)); cursor->next = _glfw.cursorListHead; _glfw.cursorListHead = cursor; diff --git a/src/window.c b/src/window.c index a65ed760..a24feb60 100644 --- a/src/window.c +++ b/src/window.c @@ -514,12 +514,33 @@ GLFWAPI void glfwSetWindowTitle(GLFWwindow* handle, const char* title) GLFWAPI void glfwSetWindowIcon(GLFWwindow* handle, int count, const GLFWimage* images) { + int i; _GLFWwindow* window = (_GLFWwindow*) handle; + assert(window != NULL); assert(count >= 0); assert(count == 0 || images != NULL); _GLFW_REQUIRE_INIT(); + + if (count < 0) + { + _glfwInputError(GLFW_INVALID_VALUE, "Invalid image count for window icon"); + return; + } + + for (i = 0; i < count; i++) + { + assert(images[i].pixels != NULL); + + if (images[i].width <= 0 || images[i].height <= 0) + { + _glfwInputError(GLFW_INVALID_VALUE, + "Invalid image dimensions for window icon"); + return; + } + } + _glfw.platform.setWindowIcon(window, count, images); } From 07a5518c3e42f4412a5d9fa8620950d8f5041e28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 17 Mar 2022 23:54:39 +0100 Subject: [PATCH 162/208] Win32: Fix using executable instance and not ours Operations that take an instance handle should be passed the handle of whatever module we are inside instead of blindly passing the handle of the executable. This commit makes GLFW retrieve its own instance on initialization. This makes the most difference for window classes, which are per-instance. Using the executable instance led to name conflicts if there were several copies of GLFW in a single process. Note that having this is still a bad idea unless you know what things to avoid, and those things are mostly platform-specific. This is partly because the library wasn't designed for it and partly because it needs to save, update and restore various per-process and per-session settings like current context and video mode. However, multiple simultaneous copies of GLFW in a single Win32 process should now at least initialize, like is already the case on other platforms. Fixes #469 Fixes #1296 Fixes #1395 Related to #927 Related to #1885 --- CONTRIBUTORS.md | 2 ++ README.md | 1 + src/win32_init.c | 12 +++++++++++- src/win32_joystick.c | 2 +- src/win32_platform.h | 1 + src/win32_window.c | 8 ++++---- 6 files changed, 20 insertions(+), 6 deletions(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 577da149..4011336f 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -90,6 +90,7 @@ video tutorials. - IntellectualKitty - Aaron Jacobs - Erik S. V. Jansson + - jjYBdx4IL - Toni Jovanoski - Arseny Kapoulkine - Cem Karan @@ -210,6 +211,7 @@ video tutorials. - Jared Tiala - Sergey Tikhomirov - Arthur Tombs + - TronicLabs - Ioannis Tsakpinis - Samuli Tuomola - Matthew Turner diff --git a/README.md b/README.md index d931de54..d2499596 100644 --- a/README.md +++ b/README.md @@ -214,6 +214,7 @@ information on what to include when reporting a bug. scancode than `PrtSc` (#1993) - [Win32] Bugfix: `GLFW_KEY_PAUSE` scancode from `glfwGetKeyScancode` did not match event scancode (#1993) + - [Win32] Bugfix: Instance-local operations used executable instance (#469,#1296,#1395) - [Cocoa] Added support for `VK_EXT_metal_surface` (#1619) - [Cocoa] Added locating the Vulkan loader at runtime in an application bundle - [Cocoa] Moved main menu creation to GLFW initialization time (#1649) diff --git a/src/win32_init.c b/src/win32_init.c index 31406401..7aefc78a 100644 --- a/src/win32_init.c +++ b/src/win32_init.c @@ -71,6 +71,16 @@ BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID reserved) // static GLFWbool loadLibraries(void) { + if (!GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | + GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, + (const WCHAR*) &_glfw, + (HMODULE*) &_glfw.win32.instance)) + { + _glfwInputErrorWin32(GLFW_PLATFORM_ERROR, + "Win32: Failed to retrieve own module handle"); + return GLFW_FALSE; + } + _glfw.win32.user32.instance = _glfwPlatformLoadModule("user32.dll"); if (!_glfw.win32.user32.instance) { @@ -334,7 +344,7 @@ static GLFWbool createHelperWindow(void) WS_CLIPSIBLINGS | WS_CLIPCHILDREN, 0, 0, 1, 1, NULL, NULL, - GetModuleHandleW(NULL), + _glfw.win32.instance, NULL); if (!_glfw.win32.helperWindowHandle) diff --git a/src/win32_joystick.c b/src/win32_joystick.c index 929a19cf..a6fe8e8d 100644 --- a/src/win32_joystick.c +++ b/src/win32_joystick.c @@ -574,7 +574,7 @@ GLFWbool _glfwInitJoysticksWin32(void) { if (_glfw.win32.dinput8.instance) { - if (FAILED(DirectInput8Create(GetModuleHandleW(NULL), + if (FAILED(DirectInput8Create(_glfw.win32.instance, DIRECTINPUT_VERSION, &IID_IDirectInput8W, (void**) &_glfw.win32.dinput8.api, diff --git a/src/win32_platform.h b/src/win32_platform.h index 0958b076..c3dc262f 100644 --- a/src/win32_platform.h +++ b/src/win32_platform.h @@ -442,6 +442,7 @@ typedef struct _GLFWwindowWin32 // typedef struct _GLFWlibraryWin32 { + HINSTANCE instance; HWND helperWindowHandle; HDEVNOTIFY deviceNotificationHandle; int acquiredMonitorCount; diff --git a/src/win32_window.c b/src/win32_window.c index 37e42c3d..5f4dd7d2 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -1321,7 +1321,7 @@ static int createNativeWindow(_GLFWwindow* window, fullWidth, fullHeight, NULL, // No parent window NULL, // No window menu - GetModuleHandleW(NULL), + _glfw.win32.instance, (LPVOID) wndconfig); _glfw_free(wideTitle); @@ -1429,7 +1429,7 @@ GLFWbool _glfwRegisterWindowClassWin32(void) wc.cbSize = sizeof(wc); wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; wc.lpfnWndProc = (WNDPROC) windowProc; - wc.hInstance = GetModuleHandleW(NULL); + wc.hInstance = _glfw.win32.instance; wc.hCursor = LoadCursorW(NULL, IDC_ARROW); wc.lpszClassName = _GLFW_WNDCLASSNAME; @@ -1459,7 +1459,7 @@ GLFWbool _glfwRegisterWindowClassWin32(void) // void _glfwUnregisterWindowClassWin32(void) { - UnregisterClassW(_GLFW_WNDCLASSNAME, GetModuleHandleW(NULL)); + UnregisterClassW(_GLFW_WNDCLASSNAME, _glfw.win32.instance); } int _glfwCreateWindowWin32(_GLFWwindow* window, @@ -2447,7 +2447,7 @@ VkResult _glfwCreateWindowSurfaceWin32(VkInstance instance, memset(&sci, 0, sizeof(sci)); sci.sType = VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR; - sci.hinstance = GetModuleHandleW(NULL); + sci.hinstance = _glfw.win32.instance; sci.hwnd = window->win32.handle; err = vkCreateWin32SurfaceKHR(instance, &sci, allocator, surface); From 955fbd9d265fa95adf9cb94896eb9a516aa50420 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 18 Mar 2022 00:31:34 +0100 Subject: [PATCH 163/208] Cocoa: Fix AirPlay causing harmless init error Emitting an error for one specific type of failure in retrieving the correct name for a display is not very useful, especially when initialization is otherwise unaffected. There should be a path for information like that but this isn't it. Fixes #1791 --- CONTRIBUTORS.md | 1 + README.md | 1 + src/cocoa_monitor.m | 4 ---- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 4011336f..cc77ff13 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -89,6 +89,7 @@ video tutorials. - InKryption - IntellectualKitty - Aaron Jacobs + - JannikGM - Erik S. V. Jansson - jjYBdx4IL - Toni Jovanoski diff --git a/README.md b/README.md index d2499596..13e3e087 100644 --- a/README.md +++ b/README.md @@ -245,6 +245,7 @@ information on what to include when reporting a bug. a fraction of a second (#1962) - [Cocoa] Bugfix: `kIOMasterPortDefault` was deprecated in macOS 12.0 (#1980) - [Cocoa] Bugfix: `kUTTypeURL` was deprecated in macOS 12.0 (#2003) + - [Cocoa] Bugfix: A connected Apple AirPlay would emit a useless error (#1791) - [X11] Bugfix: The CMake files did not check for the XInput headers (#1480) - [X11] Bugfix: Key names were not updated when the keyboard layout changed (#1462,#1528) diff --git a/src/cocoa_monitor.m b/src/cocoa_monitor.m index 70c75aa3..64d9eb2c 100644 --- a/src/cocoa_monitor.m +++ b/src/cocoa_monitor.m @@ -98,11 +98,7 @@ static char* getMonitorName(CGDirectDisplayID displayID, NSScreen* screen) IOObjectRelease(it); if (!service) - { - _glfwInputError(GLFW_PLATFORM_ERROR, - "Cocoa: Failed to find service port for display"); return _glfw_strdup("Display"); - } CFDictionaryRef names = CFDictionaryGetValue(info, CFSTR(kDisplayProductName)); From 554cbdb205d71ab09873f887bb75a8a7d3731a0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 22 Mar 2022 20:11:42 +0100 Subject: [PATCH 164/208] POSIX: Fix data type of return values --- src/x11_window.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/x11_window.c b/src/x11_window.c index dcde3443..38f579fe 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -113,7 +113,7 @@ static void writeEmptyEvent(void) for (;;) { const char byte = 0; - const int result = write(_glfw.x11.emptyEventPipe[1], &byte, 1); + const ssize_t result = write(_glfw.x11.emptyEventPipe[1], &byte, 1); if (result == 1 || (result == -1 && errno != EINTR)) break; } @@ -126,7 +126,7 @@ static void drainEmptyEvents(void) for (;;) { char dummy[64]; - const int result = read(_glfw.x11.emptyEventPipe[0], dummy, sizeof(dummy)); + const ssize_t result = read(_glfw.x11.emptyEventPipe[0], dummy, sizeof(dummy)); if (result == -1 && errno != EINTR) break; } From 920d110b6c7de21bc1ff60fab62350cbc80bd76f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 21 Mar 2022 23:19:06 +0100 Subject: [PATCH 165/208] Fix missing newline --- src/input.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/input.c b/src/input.c index 90ee5273..e0a12cce 100644 --- a/src/input.c +++ b/src/input.c @@ -1428,3 +1428,4 @@ GLFWAPI uint64_t glfwGetTimerFrequency(void) _GLFW_REQUIRE_INIT_OR_RETURN(0); return _glfwPlatformGetTimerFrequency(); } + From 9c95cfb9f1cdf073856e5b479447f5fca6492cd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 22 Mar 2022 18:46:57 +0100 Subject: [PATCH 166/208] Wayland: Fix handling of clipboard set to self Passing any part of the result of glfwGetClipboardString to glfwSetClipboardString would result in, at best, a use-after-free error. --- README.md | 2 ++ src/wl_window.c | 20 +++++++++----------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 13e3e087..c0e319bf 100644 --- a/README.md +++ b/README.md @@ -310,6 +310,8 @@ information on what to include when reporting a bug. - [Wayland] Bugfix: Some keys were reported as wrong key or `GLFW_KEY_UNKNOWN` - [Wayland] Bugfix: Text input did not repeat along with key repeat - [Wayland] Bugfix: `glfwPostEmptyEvent` sometimes had no effect (#1520,#1521) + - [Wayland] Bugfix: `glfwSetClipboardString` would fail if set to result of + `glfwGetClipboardString` - [POSIX] Removed use of deprecated function `gettimeofday` - [POSIX] Bugfix: `CLOCK_MONOTONIC` was not correctly tested for or enabled - [WGL] Disabled the DWM swap interval hack for Windows 8 and later (#1072) diff --git a/src/wl_window.c b/src/wl_window.c index 8c47d710..a1b717ee 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -1664,20 +1664,18 @@ void _glfwSetClipboardStringWayland(const char* string) _glfw.wl.dataSource = NULL; } - if (_glfw.wl.clipboardSendString) + char* copy = _glfw_strdup(string); + if (!copy) { - _glfw_free(_glfw.wl.clipboardSendString); - _glfw.wl.clipboardSendString = NULL; - } - - _glfw.wl.clipboardSendString = _glfw_strdup(string); - if (!_glfw.wl.clipboardSendString) - { - _glfwInputError(GLFW_PLATFORM_ERROR, - "Wayland: Impossible to allocate clipboard string"); + _glfwInputError(GLFW_OUT_OF_MEMORY, + "Wayland: Failed to allocate clipboard string"); return; } - _glfw.wl.clipboardSendSize = strlen(string); + + _glfw_free(_glfw.wl.clipboardSendString); + _glfw.wl.clipboardSendString = copy; + + _glfw.wl.clipboardSendSize = strlen(_glfw.wl.clipboardSendString); _glfw.wl.dataSource = wl_data_device_manager_create_data_source(_glfw.wl.dataDeviceManager); if (!_glfw.wl.dataSource) From b386371f57ba45e6ef15d16e994c6fbe71437427 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 22 Mar 2022 18:55:31 +0100 Subject: [PATCH 167/208] Wayland: Fix double free on data source error If data source creation fails, the string containing the data for it would be freed a second time during termination. --- README.md | 1 + src/wl_window.c | 1 + 2 files changed, 2 insertions(+) diff --git a/README.md b/README.md index c0e319bf..210edf82 100644 --- a/README.md +++ b/README.md @@ -312,6 +312,7 @@ information on what to include when reporting a bug. - [Wayland] Bugfix: `glfwPostEmptyEvent` sometimes had no effect (#1520,#1521) - [Wayland] Bugfix: `glfwSetClipboardString` would fail if set to result of `glfwGetClipboardString` + - [Wayland] Bugfix: Data source creation error would cause double free at termination - [POSIX] Removed use of deprecated function `gettimeofday` - [POSIX] Bugfix: `CLOCK_MONOTONIC` was not correctly tested for or enabled - [WGL] Disabled the DWM swap interval hack for Windows 8 and later (#1072) diff --git a/src/wl_window.c b/src/wl_window.c index a1b717ee..c2a88f5b 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -1683,6 +1683,7 @@ void _glfwSetClipboardStringWayland(const char* string) _glfwInputError(GLFW_PLATFORM_ERROR, "Wayland: Impossible to create clipboard source"); _glfw_free(_glfw.wl.clipboardSendString); + _glfw.wl.clipboardSendString = NULL; return; } wl_data_source_add_listener(_glfw.wl.dataSource, From 738b1c73b5433c0a3c76f2b14728a5c0ba515643 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 22 Mar 2022 19:04:29 +0100 Subject: [PATCH 168/208] Wayland: Remove superfluous global struct member It seems unlikely that strlen will be a bottleneck when sending clipboard contents. --- src/wl_platform.h | 1 - src/wl_window.c | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/wl_platform.h b/src/wl_platform.h index ba405714..9e7202bd 100644 --- a/src/wl_platform.h +++ b/src/wl_platform.h @@ -308,7 +308,6 @@ typedef struct _GLFWlibraryWayland char* clipboardString; size_t clipboardSize; char* clipboardSendString; - size_t clipboardSendSize; int timerfd; short int keycodes[256]; short int scancodes[GLFW_KEY_LAST + 1]; diff --git a/src/wl_window.c b/src/wl_window.c index c2a88f5b..01002061 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -1592,7 +1592,7 @@ static void dataSourceHandleSend(void* data, int fd) { const char* string = _glfw.wl.clipboardSendString; - size_t len = _glfw.wl.clipboardSendSize; + size_t len = strlen(string); int ret; if (_glfw.wl.dataSource != dataSource) @@ -1675,7 +1675,6 @@ void _glfwSetClipboardStringWayland(const char* string) _glfw_free(_glfw.wl.clipboardSendString); _glfw.wl.clipboardSendString = copy; - _glfw.wl.clipboardSendSize = strlen(_glfw.wl.clipboardSendString); _glfw.wl.dataSource = wl_data_device_manager_create_data_source(_glfw.wl.dataDeviceManager); if (!_glfw.wl.dataSource) From 4c110bba41b0df8a3b295fdd5e4e95aed6615001 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 22 Mar 2022 19:23:25 +0100 Subject: [PATCH 169/208] Wayland: Fix partial writes of clipboard string The string pointer used to write the contents of our clipboard data offer was never updated, causing it to repeat parts of the beginning of the string until the correct number of bytes had been written. --- README.md | 1 + src/wl_window.c | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 210edf82..ca1bfa88 100644 --- a/README.md +++ b/README.md @@ -313,6 +313,7 @@ information on what to include when reporting a bug. - [Wayland] Bugfix: `glfwSetClipboardString` would fail if set to result of `glfwGetClipboardString` - [Wayland] Bugfix: Data source creation error would cause double free at termination + - [Wayland] Bugfix: Partial writes of clipboard string would cause beginning to repeat - [POSIX] Removed use of deprecated function `gettimeofday` - [POSIX] Bugfix: `CLOCK_MONOTONIC` was not correctly tested for or enabled - [WGL] Disabled the DWM swap interval hack for Windows 8 and later (#1072) diff --git a/src/wl_window.c b/src/wl_window.c index 01002061..6e7f282b 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -1591,7 +1591,7 @@ static void dataSourceHandleSend(void* data, const char* mimeType, int fd) { - const char* string = _glfw.wl.clipboardSendString; + char* string = _glfw.wl.clipboardSendString; size_t len = strlen(string); int ret; @@ -1631,6 +1631,7 @@ static void dataSourceHandleSend(void* data, return; } len -= ret; + string += ret; } close(fd); } From 2d45681bc354a50e616082ea37c765c062a1fc09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 22 Mar 2022 19:30:43 +0100 Subject: [PATCH 170/208] Wayland: Fix phrasing and type of error messages --- src/wl_init.c | 16 ++++++++-------- src/wl_window.c | 22 +++++++++++----------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/wl_init.c b/src/wl_init.c index f02c6320..fd1132ab 100644 --- a/src/wl_init.c +++ b/src/wl_init.c @@ -160,8 +160,8 @@ static void setCursor(_GLFWwindow* window, const char* name) cursor = wl_cursor_theme_get_cursor(theme, name); if (!cursor) { - _glfwInputError(GLFW_PLATFORM_ERROR, - "Wayland: Standard cursor not found"); + _glfwInputError(GLFW_CURSOR_UNAVAILABLE, + "Wayland: Standard cursor shape unavailable"); return; } // TODO: handle animated cursors too. @@ -1116,7 +1116,7 @@ GLFWbool _glfwConnectWayland(int platformID, _GLFWplatform* platform) if (platformID == GLFW_PLATFORM_WAYLAND) { _glfwInputError(GLFW_PLATFORM_ERROR, - "Wayland: Failed to open libwayland-client"); + "Wayland: Failed to load libwayland-client"); } return GLFW_FALSE; @@ -1221,7 +1221,7 @@ int _glfwInitWayland(void) if (!_glfw.wl.cursor.handle) { _glfwInputError(GLFW_PLATFORM_ERROR, - "Wayland: Failed to open libwayland-cursor"); + "Wayland: Failed to load libwayland-cursor"); return GLFW_FALSE; } @@ -1238,7 +1238,7 @@ int _glfwInitWayland(void) if (!_glfw.wl.egl.handle) { _glfwInputError(GLFW_PLATFORM_ERROR, - "Wayland: Failed to open libwayland-egl"); + "Wayland: Failed to load libwayland-egl"); return GLFW_FALSE; } @@ -1253,7 +1253,7 @@ int _glfwInitWayland(void) if (!_glfw.wl.xkb.handle) { _glfwInputError(GLFW_PLATFORM_ERROR, - "Wayland: Failed to open libxkbcommon"); + "Wayland: Failed to load libxkbcommon"); return GLFW_FALSE; } @@ -1345,7 +1345,7 @@ int _glfwInitWayland(void) if (!_glfw.wl.cursorTheme) { _glfwInputError(GLFW_PLATFORM_ERROR, - "Wayland: Unable to load default cursor theme"); + "Wayland: Failed to load default cursor theme"); return GLFW_FALSE; } // If this happens to be NULL, we just fallback to the scale=1 version. @@ -1368,7 +1368,7 @@ int _glfwInitWayland(void) if (!_glfw.wl.clipboardString) { _glfwInputError(GLFW_OUT_OF_MEMORY, - "Wayland: Unable to allocate clipboard memory"); + "Wayland: Failed to allocate clipboard memory"); return GLFW_FALSE; } } diff --git a/src/wl_window.c b/src/wl_window.c index 6e7f282b..ef457ac2 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -149,7 +149,7 @@ static struct wl_buffer* createShmBuffer(const GLFWimage* image) if (fd < 0) { _glfwInputError(GLFW_PLATFORM_ERROR, - "Wayland: Creating a buffer file for %d B failed: %s", + "Wayland: Failed to create buffer file of size %d: %s", length, strerror(errno)); return NULL; } @@ -158,7 +158,7 @@ static struct wl_buffer* createShmBuffer(const GLFWimage* image) if (data == MAP_FAILED) { _glfwInputError(GLFW_PLATFORM_ERROR, - "Wayland: mmap failed: %s", strerror(errno)); + "Wayland: Failed to map file: %s", strerror(errno)); close(fd); return NULL; } @@ -418,7 +418,7 @@ static void setIdleInhibitor(_GLFWwindow* window, GLFWbool enable) _glfw.wl.idleInhibitManager, window->wl.surface); if (!window->wl.idleInhibitor) _glfwInputError(GLFW_PLATFORM_ERROR, - "Wayland: Idle inhibitor creation failed"); + "Wayland: Failed to create idle inhibitor"); } else if (!enable && window->wl.idleInhibitor) { @@ -556,7 +556,7 @@ static GLFWbool createXdgSurface(_GLFWwindow* window) if (!window->wl.xdg.surface) { _glfwInputError(GLFW_PLATFORM_ERROR, - "Wayland: xdg-surface creation failed"); + "Wayland: Failed to create xdg-surface for window"); return GLFW_FALSE; } @@ -568,7 +568,7 @@ static GLFWbool createXdgSurface(_GLFWwindow* window) if (!window->wl.xdg.toplevel) { _glfwInputError(GLFW_PLATFORM_ERROR, - "Wayland: xdg-toplevel creation failed"); + "Wayland: Failed to create xdg-toplevel for window"); return GLFW_FALSE; } @@ -1378,7 +1378,7 @@ int _glfwCreateStandardCursorWayland(_GLFWcursor* cursor, int shape) cursor->wl.cursor = wl_cursor_theme_get_cursor(_glfw.wl.cursorTheme, name); if (!cursor->wl.cursor) { - _glfwInputError(GLFW_PLATFORM_ERROR, + _glfwInputError(GLFW_CURSOR_UNAVAILABLE, "Wayland: Failed to create standard cursor \"%s\"", name); return GLFW_FALSE; @@ -1681,7 +1681,7 @@ void _glfwSetClipboardStringWayland(const char* string) if (!_glfw.wl.dataSource) { _glfwInputError(GLFW_PLATFORM_ERROR, - "Wayland: Impossible to create clipboard source"); + "Wayland: Failed to create clipboard data source"); _glfw_free(_glfw.wl.clipboardSendString); _glfw.wl.clipboardSendString = NULL; return; @@ -1703,7 +1703,7 @@ static GLFWbool growClipboardString(void) if (!clipboard) { _glfwInputError(GLFW_OUT_OF_MEMORY, - "Wayland: Impossible to grow clipboard string"); + "Wayland: Failed to grow clipboard string"); return GLFW_FALSE; } _glfw.wl.clipboardString = clipboard; @@ -1720,7 +1720,7 @@ const char* _glfwGetClipboardStringWayland(void) if (!_glfw.wl.dataOffer) { _glfwInputError(GLFW_FORMAT_UNAVAILABLE, - "No clipboard data has been sent yet"); + "Wayland: No clipboard data available"); return NULL; } @@ -1729,7 +1729,7 @@ const char* _glfwGetClipboardStringWayland(void) { // TODO: also report errno maybe? _glfwInputError(GLFW_PLATFORM_ERROR, - "Wayland: Impossible to create clipboard pipe fds"); + "Wayland: Failed to create clipboard pipe fds"); return NULL; } @@ -1762,7 +1762,7 @@ const char* _glfwGetClipboardStringWayland(void) { // TODO: also report errno maybe. _glfwInputError(GLFW_PLATFORM_ERROR, - "Wayland: Impossible to read from clipboard fd"); + "Wayland: Failed to read from clipboard fd"); close(fds[0]); return NULL; } From ba11e60859c22132cb6c11f570f5341fa38ef856 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 23 Mar 2022 18:52:06 +0100 Subject: [PATCH 171/208] Wayland: Rename data transfer parameters No rationale beyond personal preference. --- src/wl_init.c | 22 +++++++++++----------- src/wl_window.c | 14 +++++++------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/wl_init.c b/src/wl_init.c index fd1132ab..720ac53e 100644 --- a/src/wl_init.c +++ b/src/wl_init.c @@ -701,7 +701,7 @@ static const struct wl_seat_listener seatListener = { }; static void dataOfferHandleOffer(void* data, - struct wl_data_offer* dataOffer, + struct wl_data_offer* offer, const char* mimeType) { } @@ -711,33 +711,33 @@ static const struct wl_data_offer_listener dataOfferListener = { }; static void dataDeviceHandleDataOffer(void* data, - struct wl_data_device* dataDevice, - struct wl_data_offer* id) + struct wl_data_device* device, + struct wl_data_offer* offer) { if (_glfw.wl.dataOffer) wl_data_offer_destroy(_glfw.wl.dataOffer); - _glfw.wl.dataOffer = id; + _glfw.wl.dataOffer = offer; wl_data_offer_add_listener(_glfw.wl.dataOffer, &dataOfferListener, NULL); } static void dataDeviceHandleEnter(void* data, - struct wl_data_device* dataDevice, + struct wl_data_device* device, uint32_t serial, struct wl_surface *surface, wl_fixed_t x, wl_fixed_t y, - struct wl_data_offer *id) + struct wl_data_offer *offer) { } static void dataDeviceHandleLeave(void* data, - struct wl_data_device* dataDevice) + struct wl_data_device* device) { } static void dataDeviceHandleMotion(void* data, - struct wl_data_device* dataDevice, + struct wl_data_device* device, uint32_t time, wl_fixed_t x, wl_fixed_t y) @@ -745,13 +745,13 @@ static void dataDeviceHandleMotion(void* data, } static void dataDeviceHandleDrop(void* data, - struct wl_data_device* dataDevice) + struct wl_data_device* device) { } static void dataDeviceHandleSelection(void* data, - struct wl_data_device* dataDevice, - struct wl_data_offer* id) + struct wl_data_device* device, + struct wl_data_offer* offer) { } diff --git a/src/wl_window.c b/src/wl_window.c index ef457ac2..0222b925 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -1575,10 +1575,10 @@ void _glfwSetCursorWayland(_GLFWwindow* window, _GLFWcursor* cursor) } static void dataSourceHandleTarget(void* data, - struct wl_data_source* dataSource, + struct wl_data_source* source, const char* mimeType) { - if (_glfw.wl.dataSource != dataSource) + if (_glfw.wl.dataSource != source) { _glfwInputError(GLFW_PLATFORM_ERROR, "Wayland: Unknown clipboard data source"); @@ -1587,7 +1587,7 @@ static void dataSourceHandleTarget(void* data, } static void dataSourceHandleSend(void* data, - struct wl_data_source* dataSource, + struct wl_data_source* source, const char* mimeType, int fd) { @@ -1595,7 +1595,7 @@ static void dataSourceHandleSend(void* data, size_t len = strlen(string); int ret; - if (_glfw.wl.dataSource != dataSource) + if (_glfw.wl.dataSource != source) { _glfwInputError(GLFW_PLATFORM_ERROR, "Wayland: Unknown clipboard data source"); @@ -1637,11 +1637,11 @@ static void dataSourceHandleSend(void* data, } static void dataSourceHandleCancelled(void* data, - struct wl_data_source* dataSource) + struct wl_data_source* source) { - wl_data_source_destroy(dataSource); + wl_data_source_destroy(source); - if (_glfw.wl.dataSource != dataSource) + if (_glfw.wl.dataSource != source) { _glfwInputError(GLFW_PLATFORM_ERROR, "Wayland: Unknown clipboard data source"); From 45061750236007f8eaa782a9a8d12ff44733b68a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 23 Mar 2022 18:55:22 +0100 Subject: [PATCH 172/208] Wayland: Clean up pointer declarations Adapt style to match the rest of the project. --- src/wl_init.c | 14 +++++++------- src/wl_monitor.c | 12 ++++++------ src/wl_platform.h | 10 +++++----- src/wl_window.c | 14 +++++++------- 4 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/wl_init.c b/src/wl_init.c index 720ac53e..061d2726 100644 --- a/src/wl_init.c +++ b/src/wl_init.c @@ -724,10 +724,10 @@ static void dataDeviceHandleDataOffer(void* data, static void dataDeviceHandleEnter(void* data, struct wl_data_device* device, uint32_t serial, - struct wl_surface *surface, + struct wl_surface* surface, wl_fixed_t x, wl_fixed_t y, - struct wl_data_offer *offer) + struct wl_data_offer* offer) { } @@ -863,8 +863,8 @@ static void registryHandleGlobal(void* data, } } -static void registryHandleGlobalRemove(void *data, - struct wl_registry *registry, +static void registryHandleGlobalRemove(void* data, + struct wl_registry* registry, uint32_t name) { _GLFWmonitor* monitor; @@ -1155,9 +1155,9 @@ GLFWbool _glfwConnectWayland(int platformID, _GLFWplatform* platform) int _glfwInitWayland(void) { - const char *cursorTheme; - const char *cursorSizeStr; - char *cursorSizeEnd; + const char* cursorTheme; + const char* cursorSizeStr; + char* cursorSizeEnd; long cursorSizeLong; int cursorSize; diff --git a/src/wl_monitor.c b/src/wl_monitor.c index 5bdda918..44d9f0e1 100644 --- a/src/wl_monitor.c +++ b/src/wl_monitor.c @@ -48,7 +48,7 @@ static void outputHandleGeometry(void* data, const char* model, int32_t transform) { - struct _GLFWmonitor *monitor = data; + struct _GLFWmonitor* monitor = data; monitor->wl.x = x; monitor->wl.y = y; @@ -65,7 +65,7 @@ static void outputHandleMode(void* data, int32_t height, int32_t refresh) { - struct _GLFWmonitor *monitor = data; + struct _GLFWmonitor* monitor = data; GLFWvidmode mode; mode.width = width; @@ -86,7 +86,7 @@ static void outputHandleMode(void* data, static void outputHandleDone(void* data, struct wl_output* output) { - struct _GLFWmonitor *monitor = data; + struct _GLFWmonitor* monitor = data; if (monitor->widthMM <= 0 || monitor->heightMM <= 0) { @@ -103,7 +103,7 @@ static void outputHandleScale(void* data, struct wl_output* output, int32_t factor) { - struct _GLFWmonitor *monitor = data; + struct _GLFWmonitor* monitor = data; monitor->wl.scale = factor; } @@ -122,8 +122,8 @@ static const struct wl_output_listener outputListener = { void _glfwAddOutputWayland(uint32_t name, uint32_t version) { - _GLFWmonitor *monitor; - struct wl_output *output; + _GLFWmonitor* monitor; + struct wl_output* output; if (version < 2) { diff --git a/src/wl_platform.h b/src/wl_platform.h index 9e7202bd..405f00b3 100644 --- a/src/wl_platform.h +++ b/src/wl_platform.h @@ -45,10 +45,10 @@ typedef VkBool32 (APIENTRY *PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR #include "xkb_unicode.h" #include "posix_poll.h" -typedef int (* PFN_wl_display_flush)(struct wl_display *display); -typedef void (* PFN_wl_display_cancel_read)(struct wl_display *display); -typedef int (* PFN_wl_display_dispatch_pending)(struct wl_display *display); -typedef int (* PFN_wl_display_read_events)(struct wl_display *display); +typedef int (* PFN_wl_display_flush)(struct wl_display* display); +typedef void (* PFN_wl_display_cancel_read)(struct wl_display* display); +typedef int (* PFN_wl_display_dispatch_pending)(struct wl_display* display); +typedef int (* PFN_wl_display_read_events)(struct wl_display* display); typedef struct wl_display* (* PFN_wl_display_connect)(const char*); typedef void (* PFN_wl_display_disconnect)(struct wl_display*); typedef int (* PFN_wl_display_roundtrip)(struct wl_display*); @@ -457,7 +457,7 @@ float _glfwGetWindowOpacityWayland(_GLFWwindow* window); void _glfwSetWindowOpacityWayland(_GLFWwindow* window, float opacity); void _glfwSetWindowMousePassthroughWayland(_GLFWwindow* window, GLFWbool enabled); -void _glfwSetRawMouseMotionWayland(_GLFWwindow *window, GLFWbool enabled); +void _glfwSetRawMouseMotionWayland(_GLFWwindow* window, GLFWbool enabled); GLFWbool _glfwRawMouseMotionSupportedWayland(void); void _glfwPollEventsWayland(void); diff --git a/src/wl_window.c b/src/wl_window.c index 0222b925..1e743132 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -364,9 +364,9 @@ static void checkScaleChange(_GLFWwindow* window) } } -static void surfaceHandleEnter(void *data, - struct wl_surface *surface, - struct wl_output *output) +static void surfaceHandleEnter(void* data, + struct wl_surface* surface, + struct wl_output* output) { _GLFWwindow* window = data; _GLFWmonitor* monitor = wl_output_get_user_data(output); @@ -384,9 +384,9 @@ static void surfaceHandleEnter(void *data, checkScaleChange(window); } -static void surfaceHandleLeave(void *data, - struct wl_surface *surface, - struct wl_output *output) +static void surfaceHandleLeave(void* data, + struct wl_surface* surface, + struct wl_output* output) { _GLFWwindow* window = data; _GLFWmonitor* monitor = wl_output_get_user_data(output); @@ -1163,7 +1163,7 @@ void _glfwSetWindowOpacityWayland(_GLFWwindow* window, float opacity) "Wayland: The platform does not support setting the window opacity"); } -void _glfwSetRawMouseMotionWayland(_GLFWwindow *window, GLFWbool enabled) +void _glfwSetRawMouseMotionWayland(_GLFWwindow* window, GLFWbool enabled) { // This is handled in relativePointerHandleRelativeMotion } From a4460b694e512e6f4b485055832792d3c22ccbe1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 23 Mar 2022 18:58:08 +0100 Subject: [PATCH 173/208] Wayland: Rename listener user data parameters --- src/wl_init.c | 46 +++++++++++++++++++++++----------------------- src/wl_monitor.c | 16 ++++++++-------- src/wl_window.c | 36 ++++++++++++++++++------------------ 3 files changed, 49 insertions(+), 49 deletions(-) diff --git a/src/wl_init.c b/src/wl_init.c index 061d2726..ba34c1db 100644 --- a/src/wl_init.c +++ b/src/wl_init.c @@ -91,7 +91,7 @@ static _GLFWwindow* findWindowFromDecorationSurface(struct wl_surface* surface, return window; } -static void pointerHandleEnter(void* data, +static void pointerHandleEnter(void* userData, struct wl_pointer* pointer, uint32_t serial, struct wl_surface* surface, @@ -122,7 +122,7 @@ static void pointerHandleEnter(void* data, _glfwInputCursorEnter(window, GLFW_TRUE); } -static void pointerHandleLeave(void* data, +static void pointerHandleLeave(void* userData, struct wl_pointer* pointer, uint32_t serial, struct wl_surface* surface) @@ -185,7 +185,7 @@ static void setCursor(_GLFWwindow* window, const char* name) _glfw.wl.cursorPreviousName = name; } -static void pointerHandleMotion(void* data, +static void pointerHandleMotion(void* userData, struct wl_pointer* pointer, uint32_t time, wl_fixed_t sx, @@ -244,7 +244,7 @@ static void pointerHandleMotion(void* data, setCursor(window, cursorName); } -static void pointerHandleButton(void* data, +static void pointerHandleButton(void* userData, struct wl_pointer* pointer, uint32_t serial, uint32_t time, @@ -329,7 +329,7 @@ static void pointerHandleButton(void* data, _glfw.wl.xkb.modifiers); } -static void pointerHandleAxis(void* data, +static void pointerHandleAxis(void* userData, struct wl_pointer* pointer, uint32_t time, uint32_t axis, @@ -364,7 +364,7 @@ static const struct wl_pointer_listener pointerListener = { pointerHandleAxis, }; -static void keyboardHandleKeymap(void* data, +static void keyboardHandleKeymap(void* userData, struct wl_keyboard* keyboard, uint32_t format, int fd, @@ -461,7 +461,7 @@ static void keyboardHandleKeymap(void* data, 1 << xkb_keymap_mod_get_index(_glfw.wl.xkb.keymap, "Mod2"); } -static void keyboardHandleEnter(void* data, +static void keyboardHandleEnter(void* userData, struct wl_keyboard* keyboard, uint32_t serial, struct wl_surface* surface, @@ -484,7 +484,7 @@ static void keyboardHandleEnter(void* data, _glfwInputWindowFocus(window, GLFW_TRUE); } -static void keyboardHandleLeave(void* data, +static void keyboardHandleLeave(void* userData, struct wl_keyboard* keyboard, uint32_t serial, struct wl_surface* surface) @@ -550,7 +550,7 @@ GLFWbool _glfwInputTextWayland(_GLFWwindow* window, uint32_t scancode) return xkb_keymap_key_repeats(_glfw.wl.xkb.keymap, keycode); } -static void keyboardHandleKey(void* data, +static void keyboardHandleKey(void* userData, struct wl_keyboard* keyboard, uint32_t serial, uint32_t time, @@ -591,7 +591,7 @@ static void keyboardHandleKey(void* data, timerfd_settime(_glfw.wl.timerfd, 0, &timer, NULL); } -static void keyboardHandleModifiers(void* data, +static void keyboardHandleModifiers(void* userData, struct wl_keyboard* keyboard, uint32_t serial, uint32_t modsDepressed, @@ -638,7 +638,7 @@ static void keyboardHandleModifiers(void* data, } #ifdef WL_KEYBOARD_REPEAT_INFO_SINCE_VERSION -static void keyboardHandleRepeatInfo(void* data, +static void keyboardHandleRepeatInfo(void* userData, struct wl_keyboard* keyboard, int32_t rate, int32_t delay) @@ -662,7 +662,7 @@ static const struct wl_keyboard_listener keyboardListener = { #endif }; -static void seatHandleCapabilities(void* data, +static void seatHandleCapabilities(void* userData, struct wl_seat* seat, enum wl_seat_capability caps) { @@ -689,7 +689,7 @@ static void seatHandleCapabilities(void* data, } } -static void seatHandleName(void* data, +static void seatHandleName(void* userData, struct wl_seat* seat, const char* name) { @@ -700,7 +700,7 @@ static const struct wl_seat_listener seatListener = { seatHandleName, }; -static void dataOfferHandleOffer(void* data, +static void dataOfferHandleOffer(void* userData, struct wl_data_offer* offer, const char* mimeType) { @@ -710,7 +710,7 @@ static const struct wl_data_offer_listener dataOfferListener = { dataOfferHandleOffer, }; -static void dataDeviceHandleDataOffer(void* data, +static void dataDeviceHandleDataOffer(void* userData, struct wl_data_device* device, struct wl_data_offer* offer) { @@ -721,7 +721,7 @@ static void dataDeviceHandleDataOffer(void* data, wl_data_offer_add_listener(_glfw.wl.dataOffer, &dataOfferListener, NULL); } -static void dataDeviceHandleEnter(void* data, +static void dataDeviceHandleEnter(void* userData, struct wl_data_device* device, uint32_t serial, struct wl_surface* surface, @@ -731,12 +731,12 @@ static void dataDeviceHandleEnter(void* data, { } -static void dataDeviceHandleLeave(void* data, +static void dataDeviceHandleLeave(void* userData, struct wl_data_device* device) { } -static void dataDeviceHandleMotion(void* data, +static void dataDeviceHandleMotion(void* userData, struct wl_data_device* device, uint32_t time, wl_fixed_t x, @@ -744,12 +744,12 @@ static void dataDeviceHandleMotion(void* data, { } -static void dataDeviceHandleDrop(void* data, +static void dataDeviceHandleDrop(void* userData, struct wl_data_device* device) { } -static void dataDeviceHandleSelection(void* data, +static void dataDeviceHandleSelection(void* userData, struct wl_data_device* device, struct wl_data_offer* offer) { @@ -764,7 +764,7 @@ static const struct wl_data_device_listener dataDeviceListener = { dataDeviceHandleSelection, }; -static void wmBaseHandlePing(void* data, +static void wmBaseHandlePing(void* userData, struct xdg_wm_base* wmBase, uint32_t serial) { @@ -775,7 +775,7 @@ static const struct xdg_wm_base_listener wmBaseListener = { wmBaseHandlePing }; -static void registryHandleGlobal(void* data, +static void registryHandleGlobal(void* userData, struct wl_registry* registry, uint32_t name, const char* interface, @@ -863,7 +863,7 @@ static void registryHandleGlobal(void* data, } } -static void registryHandleGlobalRemove(void* data, +static void registryHandleGlobalRemove(void* userData, struct wl_registry* registry, uint32_t name) { diff --git a/src/wl_monitor.c b/src/wl_monitor.c index 44d9f0e1..07adaa39 100644 --- a/src/wl_monitor.c +++ b/src/wl_monitor.c @@ -37,7 +37,7 @@ #include "wayland-client-protocol.h" -static void outputHandleGeometry(void* data, +static void outputHandleGeometry(void* userData, struct wl_output* output, int32_t x, int32_t y, @@ -48,7 +48,7 @@ static void outputHandleGeometry(void* data, const char* model, int32_t transform) { - struct _GLFWmonitor* monitor = data; + struct _GLFWmonitor* monitor = userData; monitor->wl.x = x; monitor->wl.y = y; @@ -58,14 +58,14 @@ static void outputHandleGeometry(void* data, snprintf(monitor->name, sizeof(monitor->name), "%s %s", make, model); } -static void outputHandleMode(void* data, +static void outputHandleMode(void* userData, struct wl_output* output, uint32_t flags, int32_t width, int32_t height, int32_t refresh) { - struct _GLFWmonitor* monitor = data; + struct _GLFWmonitor* monitor = userData; GLFWvidmode mode; mode.width = width; @@ -84,9 +84,9 @@ static void outputHandleMode(void* data, monitor->wl.currentMode = monitor->modeCount - 1; } -static void outputHandleDone(void* data, struct wl_output* output) +static void outputHandleDone(void* userData, struct wl_output* output) { - struct _GLFWmonitor* monitor = data; + struct _GLFWmonitor* monitor = userData; if (monitor->widthMM <= 0 || monitor->heightMM <= 0) { @@ -99,11 +99,11 @@ static void outputHandleDone(void* data, struct wl_output* output) _glfwInputMonitor(monitor, GLFW_CONNECTED, _GLFW_INSERT_LAST); } -static void outputHandleScale(void* data, +static void outputHandleScale(void* userData, struct wl_output* output, int32_t factor) { - struct _GLFWmonitor* monitor = data; + struct _GLFWmonitor* monitor = userData; monitor->wl.scale = factor; } diff --git a/src/wl_window.c b/src/wl_window.c index 1e743132..78cdaed8 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -272,11 +272,11 @@ static void destroyDecorations(_GLFWwindow* window) destroyDecoration(&window->wl.decorations.bottom); } -static void xdgDecorationHandleConfigure(void* data, +static void xdgDecorationHandleConfigure(void* userData, struct zxdg_toplevel_decoration_v1* decoration, uint32_t mode) { - _GLFWwindow* window = data; + _GLFWwindow* window = userData; window->wl.decorations.serverSide = (mode == ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE); @@ -364,11 +364,11 @@ static void checkScaleChange(_GLFWwindow* window) } } -static void surfaceHandleEnter(void* data, +static void surfaceHandleEnter(void* userData, struct wl_surface* surface, struct wl_output* output) { - _GLFWwindow* window = data; + _GLFWwindow* window = userData; _GLFWmonitor* monitor = wl_output_get_user_data(output); if (window->wl.monitorsCount + 1 > window->wl.monitorsSize) @@ -384,11 +384,11 @@ static void surfaceHandleEnter(void* data, checkScaleChange(window); } -static void surfaceHandleLeave(void* data, +static void surfaceHandleLeave(void* userData, struct wl_surface* surface, struct wl_output* output) { - _GLFWwindow* window = data; + _GLFWwindow* window = userData; _GLFWmonitor* monitor = wl_output_get_user_data(output); GLFWbool found = GLFW_FALSE; @@ -441,13 +441,13 @@ static void setFullscreen(_GLFWwindow* window, _GLFWmonitor* monitor, destroyDecorations(window); } -static void xdgToplevelHandleConfigure(void* data, +static void xdgToplevelHandleConfigure(void* userData, struct xdg_toplevel* toplevel, int32_t width, int32_t height, struct wl_array* states) { - _GLFWwindow* window = data; + _GLFWwindow* window = userData; float aspectRatio; float targetRatio; uint32_t* state; @@ -505,10 +505,10 @@ static void xdgToplevelHandleConfigure(void* data, window->wl.wasFullscreen = GLFW_TRUE; } -static void xdgToplevelHandleClose(void* data, +static void xdgToplevelHandleClose(void* userData, struct xdg_toplevel* toplevel) { - _GLFWwindow* window = data; + _GLFWwindow* window = userData; _glfwInputWindowCloseRequest(window); } @@ -517,7 +517,7 @@ static const struct xdg_toplevel_listener xdgToplevelListener = { xdgToplevelHandleClose }; -static void xdgSurfaceHandleConfigure(void* data, +static void xdgSurfaceHandleConfigure(void* userData, struct xdg_surface* surface, uint32_t serial) { @@ -1407,7 +1407,7 @@ void _glfwDestroyCursorWayland(_GLFWcursor* cursor) wl_buffer_destroy(cursor->wl.buffer); } -static void relativePointerHandleRelativeMotion(void* data, +static void relativePointerHandleRelativeMotion(void* userData, struct zwp_relative_pointer_v1* pointer, uint32_t timeHi, uint32_t timeLo, @@ -1416,7 +1416,7 @@ static void relativePointerHandleRelativeMotion(void* data, wl_fixed_t dxUnaccel, wl_fixed_t dyUnaccel) { - _GLFWwindow* window = data; + _GLFWwindow* window = userData; double xpos = window->virtualCursorPosX; double ypos = window->virtualCursorPosY; @@ -1441,7 +1441,7 @@ static const struct zwp_relative_pointer_v1_listener relativePointerListener = { relativePointerHandleRelativeMotion }; -static void lockedPointerHandleLocked(void* data, +static void lockedPointerHandleLocked(void* userData, struct zwp_locked_pointer_v1* lockedPointer) { } @@ -1462,7 +1462,7 @@ static void unlockPointer(_GLFWwindow* window) static void lockPointer(_GLFWwindow* window); -static void lockedPointerHandleUnlocked(void* data, +static void lockedPointerHandleUnlocked(void* userData, struct zwp_locked_pointer_v1* lockedPointer) { } @@ -1574,7 +1574,7 @@ void _glfwSetCursorWayland(_GLFWwindow* window, _GLFWcursor* cursor) } } -static void dataSourceHandleTarget(void* data, +static void dataSourceHandleTarget(void* userData, struct wl_data_source* source, const char* mimeType) { @@ -1586,7 +1586,7 @@ static void dataSourceHandleTarget(void* data, } } -static void dataSourceHandleSend(void* data, +static void dataSourceHandleSend(void* userData, struct wl_data_source* source, const char* mimeType, int fd) @@ -1636,7 +1636,7 @@ static void dataSourceHandleSend(void* data, close(fd); } -static void dataSourceHandleCancelled(void* data, +static void dataSourceHandleCancelled(void* userData, struct wl_data_source* source) { wl_data_source_destroy(source); From 990dc4b3888bbaffdc7c3da65ab6c2f8d24285d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 23 Mar 2022 20:08:12 +0100 Subject: [PATCH 174/208] Wayland: Fix error paths not closing sending fd Whatever error happens on our end, we should still close the fd so the other end can move on. --- README.md | 1 + src/wl_window.c | 2 ++ 2 files changed, 3 insertions(+) diff --git a/README.md b/README.md index ca1bfa88..182a23c2 100644 --- a/README.md +++ b/README.md @@ -314,6 +314,7 @@ information on what to include when reporting a bug. `glfwGetClipboardString` - [Wayland] Bugfix: Data source creation error would cause double free at termination - [Wayland] Bugfix: Partial writes of clipboard string would cause beginning to repeat + - [Wayland] Bugfix: Some errors would cause clipboard string transfer to hang - [POSIX] Removed use of deprecated function `gettimeofday` - [POSIX] Bugfix: `CLOCK_MONOTONIC` was not correctly tested for or enabled - [WGL] Disabled the DWM swap interval hack for Windows 8 and later (#1072) diff --git a/src/wl_window.c b/src/wl_window.c index 78cdaed8..e887a4d0 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -1599,6 +1599,7 @@ static void dataSourceHandleSend(void* userData, { _glfwInputError(GLFW_PLATFORM_ERROR, "Wayland: Unknown clipboard data source"); + close(fd); return; } @@ -1606,6 +1607,7 @@ static void dataSourceHandleSend(void* userData, { _glfwInputError(GLFW_PLATFORM_ERROR, "Wayland: Copy requested from an invalid string"); + close(fd); return; } From 89d3ea8d691016306ca23f26d1dc11e9f51baea2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 24 Mar 2022 14:51:24 +0100 Subject: [PATCH 175/208] Wayland: Return our clipboard without roundtrips --- src/wl_window.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/wl_window.c b/src/wl_window.c index e887a4d0..647234e3 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -1726,6 +1726,9 @@ const char* _glfwGetClipboardStringWayland(void) return NULL; } + if (_glfw.wl.dataSource) + return _glfw.wl.clipboardSendString; + ret = pipe2(fds, O_CLOEXEC); if (ret < 0) { @@ -1736,10 +1739,9 @@ const char* _glfwGetClipboardStringWayland(void) } wl_data_offer_receive(_glfw.wl.dataOffer, "text/plain;charset=utf-8", fds[1]); - close(fds[1]); - // XXX: this is a huge hack, this function shouldn’t be synchronous! - handleEvents(NULL); + flushDisplay(); + close(fds[1]); for (;;) { From 8d87be1268869af69d59400a1b0403e9ecbc5c0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 23 Mar 2022 19:58:33 +0100 Subject: [PATCH 176/208] Wayland: Improve handling of pending data offers The code assumed that all data offers were selections that supported plaintext UTF-8. The initial data offer events are now handled almost tolerably. Only selection data offers are used for clipboard string and only if they provide plaintext UTF-8. Drag and drop data offers are now rejected as soon as they enter a surface. Related to #2040 --- README.md | 2 ++ src/wl_init.c | 72 +++++++++++++++++++++++++++++++++++++++++------ src/wl_platform.h | 14 +++++++-- src/wl_window.c | 30 ++++++++++---------- 4 files changed, 93 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index 182a23c2..7b6873f1 100644 --- a/README.md +++ b/README.md @@ -315,6 +315,8 @@ information on what to include when reporting a bug. - [Wayland] Bugfix: Data source creation error would cause double free at termination - [Wayland] Bugfix: Partial writes of clipboard string would cause beginning to repeat - [Wayland] Bugfix: Some errors would cause clipboard string transfer to hang + - [Wayland] Bugfix: Drag and drop data was misinterpreted as clipboard string + - [Wayland] Bugfix: MIME type matching was not performed for clipboard string - [POSIX] Removed use of deprecated function `gettimeofday` - [POSIX] Bugfix: `CLOCK_MONOTONIC` was not correctly tested for or enabled - [WGL] Disabled the DWM swap interval hack for Windows 8 and later (#1072) diff --git a/src/wl_init.c b/src/wl_init.c index ba34c1db..4368f3fa 100644 --- a/src/wl_init.c +++ b/src/wl_init.c @@ -704,6 +704,16 @@ static void dataOfferHandleOffer(void* userData, struct wl_data_offer* offer, const char* mimeType) { + for (unsigned int i = 0; i < _glfw.wl.offerCount; i++) + { + if (_glfw.wl.offers[i].offer == offer) + { + if (strcmp(mimeType, "text/plain;charset=utf-8") == 0) + _glfw.wl.offers[i].text_plain_utf8 = GLFW_TRUE; + + break; + } + } } static const struct wl_data_offer_listener dataOfferListener = { @@ -714,11 +724,19 @@ static void dataDeviceHandleDataOffer(void* userData, struct wl_data_device* device, struct wl_data_offer* offer) { - if (_glfw.wl.dataOffer) - wl_data_offer_destroy(_glfw.wl.dataOffer); + _GLFWofferWayland* offers = + _glfw_realloc(_glfw.wl.offers, _glfw.wl.offerCount + 1); + if (!offers) + { + _glfwInputError(GLFW_OUT_OF_MEMORY, NULL); + return; + } - _glfw.wl.dataOffer = offer; - wl_data_offer_add_listener(_glfw.wl.dataOffer, &dataOfferListener, NULL); + _glfw.wl.offers = offers; + _glfw.wl.offerCount++; + + _glfw.wl.offers[_glfw.wl.offerCount - 1] = (_GLFWofferWayland) { offer }; + wl_data_offer_add_listener(offer, &dataOfferListener, NULL); } static void dataDeviceHandleEnter(void* userData, @@ -729,6 +747,19 @@ static void dataDeviceHandleEnter(void* userData, wl_fixed_t y, struct wl_data_offer* offer) { + for (unsigned int i = 0; i < _glfw.wl.offerCount; i++) + { + if (_glfw.wl.offers[i].offer == offer) + { + _glfw.wl.offers[i] = _glfw.wl.offers[_glfw.wl.offerCount - 1]; + _glfw.wl.offerCount--; + + // We don't yet handle drag and drop + wl_data_offer_accept(offer, serial, NULL); + wl_data_offer_destroy(offer); + break; + } + } } static void dataDeviceHandleLeave(void* userData, @@ -753,6 +784,26 @@ static void dataDeviceHandleSelection(void* userData, struct wl_data_device* device, struct wl_data_offer* offer) { + if (_glfw.wl.selectionOffer) + { + wl_data_offer_destroy(_glfw.wl.selectionOffer); + _glfw.wl.selectionOffer = NULL; + } + + for (unsigned int i = 0; i < _glfw.wl.offerCount; i++) + { + if (_glfw.wl.offers[i].offer == offer) + { + if (_glfw.wl.offers[i].text_plain_utf8) + _glfw.wl.selectionOffer = offer; + else + wl_data_offer_destroy(offer); + + _glfw.wl.offers[i] = _glfw.wl.offers[_glfw.wl.offerCount - 1]; + _glfw.wl.offerCount--; + break; + } + } } static const struct wl_data_device_listener dataDeviceListener = { @@ -1409,6 +1460,11 @@ void _glfwTerminateWayland(void) _glfw.wl.cursor.handle = NULL; } + for (unsigned int i = 0; i < _glfw.wl.offerCount; i++) + wl_data_offer_destroy(_glfw.wl.offers[i].offer); + + _glfw_free(_glfw.wl.offers); + if (_glfw.wl.cursorSurface) wl_surface_destroy(_glfw.wl.cursorSurface); if (_glfw.wl.subcompositor) @@ -1423,12 +1479,12 @@ void _glfwTerminateWayland(void) zxdg_decoration_manager_v1_destroy(_glfw.wl.decorationManager); if (_glfw.wl.wmBase) xdg_wm_base_destroy(_glfw.wl.wmBase); - if (_glfw.wl.dataSource) - wl_data_source_destroy(_glfw.wl.dataSource); + if (_glfw.wl.selectionOffer) + wl_data_offer_destroy(_glfw.wl.selectionOffer); + if (_glfw.wl.selectionSource) + wl_data_source_destroy(_glfw.wl.selectionSource); if (_glfw.wl.dataDevice) wl_data_device_destroy(_glfw.wl.dataDevice); - if (_glfw.wl.dataOffer) - wl_data_offer_destroy(_glfw.wl.dataOffer); if (_glfw.wl.dataDeviceManager) wl_data_device_manager_destroy(_glfw.wl.dataDeviceManager); if (_glfw.wl.pointer) diff --git a/src/wl_platform.h b/src/wl_platform.h index 405f00b3..7bec2919 100644 --- a/src/wl_platform.h +++ b/src/wl_platform.h @@ -219,6 +219,12 @@ typedef struct _GLFWdecorationWayland struct wp_viewport* viewport; } _GLFWdecorationWayland; +typedef struct _GLFWofferWayland +{ + struct wl_data_offer* offer; + GLFWbool text_plain_utf8; +} _GLFWofferWayland; + // Wayland-specific per-window data // typedef struct _GLFWwindowWayland @@ -281,8 +287,6 @@ typedef struct _GLFWlibraryWayland struct wl_keyboard* keyboard; struct wl_data_device_manager* dataDeviceManager; struct wl_data_device* dataDevice; - struct wl_data_offer* dataOffer; - struct wl_data_source* dataSource; struct xdg_wm_base* wmBase; struct zxdg_decoration_manager_v1* decorationManager; struct wp_viewporter* viewporter; @@ -290,6 +294,12 @@ typedef struct _GLFWlibraryWayland struct zwp_pointer_constraints_v1* pointerConstraints; struct zwp_idle_inhibit_manager_v1* idleInhibitManager; + _GLFWofferWayland* offers; + unsigned int offerCount; + + struct wl_data_offer* selectionOffer; + struct wl_data_source* selectionSource; + int compositorVersion; int seatVersion; diff --git a/src/wl_window.c b/src/wl_window.c index 647234e3..e1c83fc2 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -1578,7 +1578,7 @@ static void dataSourceHandleTarget(void* userData, struct wl_data_source* source, const char* mimeType) { - if (_glfw.wl.dataSource != source) + if (_glfw.wl.selectionSource != source) { _glfwInputError(GLFW_PLATFORM_ERROR, "Wayland: Unknown clipboard data source"); @@ -1595,7 +1595,7 @@ static void dataSourceHandleSend(void* userData, size_t len = strlen(string); int ret; - if (_glfw.wl.dataSource != source) + if (_glfw.wl.selectionSource != source) { _glfwInputError(GLFW_PLATFORM_ERROR, "Wayland: Unknown clipboard data source"); @@ -1643,14 +1643,14 @@ static void dataSourceHandleCancelled(void* userData, { wl_data_source_destroy(source); - if (_glfw.wl.dataSource != source) + if (_glfw.wl.selectionSource != source) { _glfwInputError(GLFW_PLATFORM_ERROR, "Wayland: Unknown clipboard data source"); return; } - _glfw.wl.dataSource = NULL; + _glfw.wl.selectionSource = NULL; } static const struct wl_data_source_listener dataSourceListener = { @@ -1661,10 +1661,10 @@ static const struct wl_data_source_listener dataSourceListener = { void _glfwSetClipboardStringWayland(const char* string) { - if (_glfw.wl.dataSource) + if (_glfw.wl.selectionSource) { - wl_data_source_destroy(_glfw.wl.dataSource); - _glfw.wl.dataSource = NULL; + wl_data_source_destroy(_glfw.wl.selectionSource); + _glfw.wl.selectionSource = NULL; } char* copy = _glfw_strdup(string); @@ -1678,9 +1678,9 @@ void _glfwSetClipboardStringWayland(const char* string) _glfw_free(_glfw.wl.clipboardSendString); _glfw.wl.clipboardSendString = copy; - _glfw.wl.dataSource = + _glfw.wl.selectionSource = wl_data_device_manager_create_data_source(_glfw.wl.dataDeviceManager); - if (!_glfw.wl.dataSource) + if (!_glfw.wl.selectionSource) { _glfwInputError(GLFW_PLATFORM_ERROR, "Wayland: Failed to create clipboard data source"); @@ -1688,12 +1688,12 @@ void _glfwSetClipboardStringWayland(const char* string) _glfw.wl.clipboardSendString = NULL; return; } - wl_data_source_add_listener(_glfw.wl.dataSource, + wl_data_source_add_listener(_glfw.wl.selectionSource, &dataSourceListener, NULL); - wl_data_source_offer(_glfw.wl.dataSource, "text/plain;charset=utf-8"); + wl_data_source_offer(_glfw.wl.selectionSource, "text/plain;charset=utf-8"); wl_data_device_set_selection(_glfw.wl.dataDevice, - _glfw.wl.dataSource, + _glfw.wl.selectionSource, _glfw.wl.serial); } @@ -1719,14 +1719,14 @@ const char* _glfwGetClipboardStringWayland(void) int ret; size_t len = 0; - if (!_glfw.wl.dataOffer) + if (!_glfw.wl.selectionOffer) { _glfwInputError(GLFW_FORMAT_UNAVAILABLE, "Wayland: No clipboard data available"); return NULL; } - if (_glfw.wl.dataSource) + if (_glfw.wl.selectionSource) return _glfw.wl.clipboardSendString; ret = pipe2(fds, O_CLOEXEC); @@ -1738,7 +1738,7 @@ const char* _glfwGetClipboardStringWayland(void) return NULL; } - wl_data_offer_receive(_glfw.wl.dataOffer, "text/plain;charset=utf-8", fds[1]); + wl_data_offer_receive(_glfw.wl.selectionOffer, "text/plain;charset=utf-8", fds[1]); flushDisplay(); close(fds[1]); From 46511652726afdaf3d92173f8f14d900f1f75994 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 24 Mar 2022 18:02:48 +0100 Subject: [PATCH 177/208] Wayland: Simplify clipboard string allocation --- src/wl_init.c | 10 -------- src/wl_platform.h | 1 - src/wl_window.c | 59 ++++++++++++++++++++--------------------------- 3 files changed, 25 insertions(+), 45 deletions(-) diff --git a/src/wl_init.c b/src/wl_init.c index 4368f3fa..972c38f6 100644 --- a/src/wl_init.c +++ b/src/wl_init.c @@ -1413,15 +1413,6 @@ int _glfwInitWayland(void) wl_data_device_manager_get_data_device(_glfw.wl.dataDeviceManager, _glfw.wl.seat); wl_data_device_add_listener(_glfw.wl.dataDevice, &dataDeviceListener, NULL); - - _glfw.wl.clipboardSize = 4096; - _glfw.wl.clipboardString = _glfw_calloc(_glfw.wl.clipboardSize, 1); - if (!_glfw.wl.clipboardString) - { - _glfwInputError(GLFW_OUT_OF_MEMORY, - "Wayland: Failed to allocate clipboard memory"); - return GLFW_FALSE; - } } return GLFW_TRUE; @@ -1513,6 +1504,5 @@ void _glfwTerminateWayland(void) close(_glfw.wl.cursorTimerfd); _glfw_free(_glfw.wl.clipboardString); - _glfw_free(_glfw.wl.clipboardSendString); } diff --git a/src/wl_platform.h b/src/wl_platform.h index 7bec2919..861f7cfe 100644 --- a/src/wl_platform.h +++ b/src/wl_platform.h @@ -317,7 +317,6 @@ typedef struct _GLFWlibraryWayland int keyboardLastScancode; char* clipboardString; size_t clipboardSize; - char* clipboardSendString; int timerfd; short int keycodes[256]; short int scancodes[GLFW_KEY_LAST + 1]; diff --git a/src/wl_window.c b/src/wl_window.c index e1c83fc2..f5ca406e 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -1591,7 +1591,7 @@ static void dataSourceHandleSend(void* userData, const char* mimeType, int fd) { - char* string = _glfw.wl.clipboardSendString; + char* string = _glfw.wl.clipboardString; size_t len = strlen(string); int ret; @@ -1667,16 +1667,23 @@ void _glfwSetClipboardStringWayland(const char* string) _glfw.wl.selectionSource = NULL; } - char* copy = _glfw_strdup(string); - if (!copy) + const size_t requiredSize = strlen(string) + 1; + if (requiredSize > _glfw.wl.clipboardSize) { - _glfwInputError(GLFW_OUT_OF_MEMORY, - "Wayland: Failed to allocate clipboard string"); - return; + _glfw_free(_glfw.wl.clipboardString); + _glfw.wl.clipboardString = _glfw_calloc(requiredSize, 1); + if (!_glfw.wl.clipboardString) + { + _glfwInputError(GLFW_OUT_OF_MEMORY, + "Wayland: Failed to allocate clipboard string"); + return; + } + + _glfw.wl.clipboardSize = requiredSize; } - _glfw_free(_glfw.wl.clipboardSendString); - _glfw.wl.clipboardSendString = copy; + // The argument may be a substring of the clipboard string + memmove(_glfw.wl.clipboardString, string, requiredSize); _glfw.wl.selectionSource = wl_data_device_manager_create_data_source(_glfw.wl.dataDeviceManager); @@ -1684,8 +1691,6 @@ void _glfwSetClipboardStringWayland(const char* string) { _glfwInputError(GLFW_PLATFORM_ERROR, "Wayland: Failed to create clipboard data source"); - _glfw_free(_glfw.wl.clipboardSendString); - _glfw.wl.clipboardSendString = NULL; return; } wl_data_source_add_listener(_glfw.wl.selectionSource, @@ -1697,22 +1702,6 @@ void _glfwSetClipboardStringWayland(const char* string) _glfw.wl.serial); } -static GLFWbool growClipboardString(void) -{ - char* clipboard = _glfw.wl.clipboardString; - - clipboard = _glfw_realloc(clipboard, _glfw.wl.clipboardSize * 2); - if (!clipboard) - { - _glfwInputError(GLFW_OUT_OF_MEMORY, - "Wayland: Failed to grow clipboard string"); - return GLFW_FALSE; - } - _glfw.wl.clipboardString = clipboard; - _glfw.wl.clipboardSize = _glfw.wl.clipboardSize * 2; - return GLFW_TRUE; -} - const char* _glfwGetClipboardStringWayland(void) { int fds[2]; @@ -1727,7 +1716,7 @@ const char* _glfwGetClipboardStringWayland(void) } if (_glfw.wl.selectionSource) - return _glfw.wl.clipboardSendString; + return _glfw.wl.clipboardString; ret = pipe2(fds, O_CLOEXEC); if (ret < 0) @@ -1747,13 +1736,20 @@ const char* _glfwGetClipboardStringWayland(void) { // Grow the clipboard if we need to paste something bigger, there is no // shrink operation yet. - if (len + 4096 > _glfw.wl.clipboardSize) + const size_t requiredSize = len + 4096 + 1; + if (requiredSize > _glfw.wl.clipboardSize) { - if (!growClipboardString()) + char* string = _glfw_realloc(_glfw.wl.clipboardString, requiredSize); + if (!string) { + _glfwInputError(GLFW_OUT_OF_MEMORY, + "Wayland: Failed to grow clipboard string"); close(fds[0]); return NULL; } + + _glfw.wl.clipboardString = string; + _glfw.wl.clipboardSize = requiredSize; } // Then read from the fd to the clipboard, handling all known errors. @@ -1773,11 +1769,6 @@ const char* _glfwGetClipboardStringWayland(void) len += ret; } close(fds[0]); - if (len + 1 > _glfw.wl.clipboardSize) - { - if (!growClipboardString()) - return NULL; - } _glfw.wl.clipboardString[len] = '\0'; return _glfw.wl.clipboardString; } From c13213533241d7bbf53da89641a8fe6c71d53c0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 24 Mar 2022 19:04:15 +0100 Subject: [PATCH 178/208] Wayland: Clean up clipboard reading --- src/wl_window.c | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/src/wl_window.c b/src/wl_window.c index f5ca406e..5f9c7200 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -1704,10 +1704,6 @@ void _glfwSetClipboardStringWayland(const char* string) const char* _glfwGetClipboardStringWayland(void) { - int fds[2]; - int ret; - size_t len = 0; - if (!_glfw.wl.selectionOffer) { _glfwInputError(GLFW_FORMAT_UNAVAILABLE, @@ -1718,8 +1714,9 @@ const char* _glfwGetClipboardStringWayland(void) if (_glfw.wl.selectionSource) return _glfw.wl.clipboardString; - ret = pipe2(fds, O_CLOEXEC); - if (ret < 0) + int fds[2]; + + if (pipe2(fds, O_CLOEXEC) == -1) { // TODO: also report errno maybe? _glfwInputError(GLFW_PLATFORM_ERROR, @@ -1732,11 +1729,14 @@ const char* _glfwGetClipboardStringWayland(void) flushDisplay(); close(fds[1]); + size_t length = 0; + for (;;) { // Grow the clipboard if we need to paste something bigger, there is no // shrink operation yet. - const size_t requiredSize = len + 4096 + 1; + const size_t readSize = 4096; + const size_t requiredSize = length + readSize + 1; if (requiredSize > _glfw.wl.clipboardSize) { char* string = _glfw_realloc(_glfw.wl.clipboardString, requiredSize); @@ -1753,23 +1753,27 @@ const char* _glfwGetClipboardStringWayland(void) } // Then read from the fd to the clipboard, handling all known errors. - ret = read(fds[0], _glfw.wl.clipboardString + len, 4096); - if (ret == 0) + const ssize_t result = read(fds[0], _glfw.wl.clipboardString + length, readSize); + if (result == 0) break; - if (ret == -1 && errno == EINTR) - continue; - if (ret == -1) + else if (result == -1) { + if (errno == EINTR) + continue; + // TODO: also report errno maybe. _glfwInputError(GLFW_PLATFORM_ERROR, "Wayland: Failed to read from clipboard fd"); close(fds[0]); return NULL; } - len += ret; + + length += result; } + close(fds[0]); - _glfw.wl.clipboardString[len] = '\0'; + + _glfw.wl.clipboardString[length] = '\0'; return _glfw.wl.clipboardString; } From e0889736fd603d163d87eef9426e4e4ebc68b60d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 24 Mar 2022 19:04:58 +0100 Subject: [PATCH 179/208] Wayland: Add strerror output to error descriptions --- src/wl_window.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/wl_window.c b/src/wl_window.c index 5f9c7200..2ad57378 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -1626,9 +1626,9 @@ static void dataSourceHandleSend(void* userData, continue; if (ret == -1) { - // TODO: also report errno maybe. _glfwInputError(GLFW_PLATFORM_ERROR, - "Wayland: Error while writing the clipboard"); + "Wayland: Error while writing the clipboard: %s", + strerror(errno)); close(fd); return; } @@ -1718,9 +1718,9 @@ const char* _glfwGetClipboardStringWayland(void) if (pipe2(fds, O_CLOEXEC) == -1) { - // TODO: also report errno maybe? _glfwInputError(GLFW_PLATFORM_ERROR, - "Wayland: Failed to create clipboard pipe fds"); + "Wayland: Failed to create clipboard pipe: %s", + strerror(errno)); return NULL; } @@ -1761,9 +1761,9 @@ const char* _glfwGetClipboardStringWayland(void) if (errno == EINTR) continue; - // TODO: also report errno maybe. _glfwInputError(GLFW_PLATFORM_ERROR, - "Wayland: Failed to read from clipboard fd"); + "Wayland: Failed to read from clipboard pipe: %s", + strerror(errno)); close(fds[0]); return NULL; } From ad4a9e42f0b43994149d590bc08bb4845ba2b86f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 24 Mar 2022 20:17:32 +0100 Subject: [PATCH 180/208] Move URI list parsing to shared code This will soon be used by the Wayland backend. --- src/init.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++ src/internal.h | 1 + src/x11_window.c | 53 +----------------------------------------------- 3 files changed, 55 insertions(+), 52 deletions(-) diff --git a/src/init.c b/src/init.c index 9f0316ac..d07a492e 100644 --- a/src/init.c +++ b/src/init.c @@ -171,6 +171,59 @@ size_t _glfwEncodeUTF8(char* s, uint32_t codepoint) return count; } +// Splits and translates a text/uri-list into separate file paths +// NOTE: This function destroys the provided string +// +char** _glfwParseUriList(char* text, int* count) +{ + const char* prefix = "file://"; + char** paths = NULL; + char* line; + + *count = 0; + + while ((line = strtok(text, "\r\n"))) + { + char* path; + + text = NULL; + + if (line[0] == '#') + continue; + + if (strncmp(line, prefix, strlen(prefix)) == 0) + { + line += strlen(prefix); + // TODO: Validate hostname + while (*line != '/') + line++; + } + + (*count)++; + + path = _glfw_calloc(strlen(line) + 1, 1); + paths = _glfw_realloc(paths, *count * sizeof(char*)); + paths[*count - 1] = path; + + while (*line) + { + if (line[0] == '%' && line[1] && line[2]) + { + const char digits[3] = { line[1], line[2], '\0' }; + *path = (char) strtol(digits, NULL, 16); + line += 2; + } + else + *path = *line; + + path++; + line++; + } + } + + return paths; +} + char* _glfw_strdup(const char* source) { const size_t length = strlen(source); diff --git a/src/internal.h b/src/internal.h index b7dc13a0..7babe7e8 100644 --- a/src/internal.h +++ b/src/internal.h @@ -996,6 +996,7 @@ void _glfwTerminateVulkan(void); const char* _glfwGetVulkanResultString(VkResult result); size_t _glfwEncodeUTF8(char* s, uint32_t codepoint); +char** _glfwParseUriList(char* text, int* count); char* _glfw_strdup(const char* source); int _glfw_min(int a, int b); diff --git a/src/x11_window.c b/src/x11_window.c index 38f579fe..e021dfd7 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -407,57 +407,6 @@ static void updateWindowMode(_GLFWwindow* window) } } -// Splits and translates a text/uri-list into separate file paths -// NOTE: This function destroys the provided string -// -static char** parseUriList(char* text, int* count) -{ - const char* prefix = "file://"; - char** paths = NULL; - char* line; - - *count = 0; - - while ((line = strtok(text, "\r\n"))) - { - text = NULL; - - if (line[0] == '#') - continue; - - if (strncmp(line, prefix, strlen(prefix)) == 0) - { - line += strlen(prefix); - // TODO: Validate hostname - while (*line != '/') - line++; - } - - (*count)++; - - char* path = _glfw_calloc(strlen(line) + 1, 1); - paths = _glfw_realloc(paths, *count * sizeof(char*)); - paths[*count - 1] = path; - - while (*line) - { - if (line[0] == '%' && line[1] && line[2]) - { - const char digits[3] = { line[1], line[2], '\0' }; - *path = strtol(digits, NULL, 16); - line += 2; - } - else - *path = *line; - - path++; - line++; - } - } - - return paths; -} - // Decode a Unicode code point from a UTF-8 stream // Based on cutef8 by Jeff Bezanson (Public Domain) // @@ -1715,7 +1664,7 @@ static void processEvent(XEvent *event) if (result) { int count; - char** paths = parseUriList(data, &count); + char** paths = _glfwParseUriList(data, &count); _glfwInputDrop(window, count, (const char**) paths); From 34418951ccc3eeb3380cd3c93b5d4cf357151cbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 24 Mar 2022 20:34:04 +0100 Subject: [PATCH 181/208] Wayland: Clean up clipboard writing --- src/wl_window.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/wl_window.c b/src/wl_window.c index 2ad57378..4c4bb0db 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -1591,10 +1591,6 @@ static void dataSourceHandleSend(void* userData, const char* mimeType, int fd) { - char* string = _glfw.wl.clipboardString; - size_t len = strlen(string); - int ret; - if (_glfw.wl.selectionSource != source) { _glfwInputError(GLFW_PLATFORM_ERROR, @@ -1603,6 +1599,7 @@ static void dataSourceHandleSend(void* userData, return; } + char* string = _glfw.wl.clipboardString; if (!string) { _glfwInputError(GLFW_PLATFORM_ERROR, @@ -1619,22 +1616,26 @@ static void dataSourceHandleSend(void* userData, return; } - while (len > 0) + size_t length = strlen(string); + + while (length > 0) { - ret = write(fd, string, len); - if (ret == -1 && errno == EINTR) - continue; - if (ret == -1) + const ssize_t result = write(fd, string, length); + if (result == -1) { + if (errno == EINTR) + continue; + _glfwInputError(GLFW_PLATFORM_ERROR, "Wayland: Error while writing the clipboard: %s", strerror(errno)); - close(fd); - return; + break; } - len -= ret; - string += ret; + + length -= result; + string += result; } + close(fd); } From 8d216054ad89ecd1030fe066a42d80a9d2765216 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 24 Mar 2022 20:45:00 +0100 Subject: [PATCH 182/208] Wayland: Remove error reporting of external bugs Not sure that GLFW should be reporting that another client has made an invalid receive request. --- src/wl_window.c | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/src/wl_window.c b/src/wl_window.c index 4c4bb0db..12bda386 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -1591,10 +1591,10 @@ static void dataSourceHandleSend(void* userData, const char* mimeType, int fd) { - if (_glfw.wl.selectionSource != source) + // Ignore it if this is an outdated or invalid request + if (_glfw.wl.selectionSource != source || + strcmp(mimeType, "text/plain;charset=utf-8") != 0) { - _glfwInputError(GLFW_PLATFORM_ERROR, - "Wayland: Unknown clipboard data source"); close(fd); return; } @@ -1608,14 +1608,6 @@ static void dataSourceHandleSend(void* userData, return; } - if (strcmp(mimeType, "text/plain;charset=utf-8") != 0) - { - _glfwInputError(GLFW_PLATFORM_ERROR, - "Wayland: Wrong MIME type asked from clipboard"); - close(fd); - return; - } - size_t length = strlen(string); while (length > 0) @@ -1645,11 +1637,7 @@ static void dataSourceHandleCancelled(void* userData, wl_data_source_destroy(source); if (_glfw.wl.selectionSource != source) - { - _glfwInputError(GLFW_PLATFORM_ERROR, - "Wayland: Unknown clipboard data source"); return; - } _glfw.wl.selectionSource = NULL; } From 967282c2e664ccaaa074590491108d9100b51123 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 24 Mar 2022 21:24:34 +0100 Subject: [PATCH 183/208] Wayland: Remove check for error that cannot happen Famous last words. --- src/wl_window.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/wl_window.c b/src/wl_window.c index 12bda386..e21755a8 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -1600,14 +1600,6 @@ static void dataSourceHandleSend(void* userData, } char* string = _glfw.wl.clipboardString; - if (!string) - { - _glfwInputError(GLFW_PLATFORM_ERROR, - "Wayland: Copy requested from an invalid string"); - close(fd); - return; - } - size_t length = strlen(string); while (length > 0) From b7a3af9b795912d80f9efc57bbaa0977acaee4a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 29 Mar 2022 18:32:05 +0200 Subject: [PATCH 184/208] Wayland: Move window related code to window module The Wayland backend was the only one where half the window and input related code was in the init module. As those bits want to share more utility code with the window module, the interface between them grows. To prevent that, this gathers nearly all window and input related code into the window module. --- src/wl_init.c | 764 +-------------------------------------------- src/wl_platform.h | 3 + src/wl_window.c | 770 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 775 insertions(+), 762 deletions(-) diff --git a/src/wl_init.c b/src/wl_init.c index 972c38f6..4ea5e1e4 100644 --- a/src/wl_init.c +++ b/src/wl_init.c @@ -28,7 +28,6 @@ #include "internal.h" -#include #include #include #include @@ -56,765 +55,6 @@ #include "wayland-pointer-constraints-unstable-v1-client-protocol-code.h" #include "wayland-idle-inhibit-unstable-v1-client-protocol-code.h" - -static _GLFWwindow* findWindowFromDecorationSurface(struct wl_surface* surface, - int* which) -{ - int focus; - _GLFWwindow* window = _glfw.windowListHead; - if (!which) - which = &focus; - while (window) - { - if (surface == window->wl.decorations.top.surface) - { - *which = topDecoration; - break; - } - if (surface == window->wl.decorations.left.surface) - { - *which = leftDecoration; - break; - } - if (surface == window->wl.decorations.right.surface) - { - *which = rightDecoration; - break; - } - if (surface == window->wl.decorations.bottom.surface) - { - *which = bottomDecoration; - break; - } - window = window->next; - } - return window; -} - -static void pointerHandleEnter(void* userData, - struct wl_pointer* pointer, - uint32_t serial, - struct wl_surface* surface, - wl_fixed_t sx, - wl_fixed_t sy) -{ - // Happens in the case we just destroyed the surface. - if (!surface) - return; - - int focus = 0; - _GLFWwindow* window = wl_surface_get_user_data(surface); - if (!window) - { - window = findWindowFromDecorationSurface(surface, &focus); - if (!window) - return; - } - - window->wl.decorations.focus = focus; - _glfw.wl.serial = serial; - _glfw.wl.pointerEnterSerial = serial; - _glfw.wl.pointerFocus = window; - - window->wl.hovered = GLFW_TRUE; - - _glfwSetCursorWayland(window, window->wl.currentCursor); - _glfwInputCursorEnter(window, GLFW_TRUE); -} - -static void pointerHandleLeave(void* userData, - struct wl_pointer* pointer, - uint32_t serial, - struct wl_surface* surface) -{ - _GLFWwindow* window = _glfw.wl.pointerFocus; - - if (!window) - return; - - window->wl.hovered = GLFW_FALSE; - - _glfw.wl.serial = serial; - _glfw.wl.pointerFocus = NULL; - _glfwInputCursorEnter(window, GLFW_FALSE); - _glfw.wl.cursorPreviousName = NULL; -} - -static void setCursor(_GLFWwindow* window, const char* name) -{ - struct wl_buffer* buffer; - struct wl_cursor* cursor; - struct wl_cursor_image* image; - struct wl_surface* surface = _glfw.wl.cursorSurface; - struct wl_cursor_theme* theme = _glfw.wl.cursorTheme; - int scale = 1; - - if (window->wl.scale > 1 && _glfw.wl.cursorThemeHiDPI) - { - // We only support up to scale=2 for now, since libwayland-cursor - // requires us to load a different theme for each size. - scale = 2; - theme = _glfw.wl.cursorThemeHiDPI; - } - - cursor = wl_cursor_theme_get_cursor(theme, name); - if (!cursor) - { - _glfwInputError(GLFW_CURSOR_UNAVAILABLE, - "Wayland: Standard cursor shape unavailable"); - return; - } - // TODO: handle animated cursors too. - image = cursor->images[0]; - - if (!image) - return; - - buffer = wl_cursor_image_get_buffer(image); - if (!buffer) - return; - wl_pointer_set_cursor(_glfw.wl.pointer, _glfw.wl.pointerEnterSerial, - surface, - image->hotspot_x / scale, - image->hotspot_y / scale); - wl_surface_set_buffer_scale(surface, scale); - wl_surface_attach(surface, buffer, 0, 0); - wl_surface_damage(surface, 0, 0, - image->width, image->height); - wl_surface_commit(surface); - _glfw.wl.cursorPreviousName = name; -} - -static void pointerHandleMotion(void* userData, - struct wl_pointer* pointer, - uint32_t time, - wl_fixed_t sx, - wl_fixed_t sy) -{ - _GLFWwindow* window = _glfw.wl.pointerFocus; - const char* cursorName = NULL; - double x, y; - - if (!window) - return; - - if (window->cursorMode == GLFW_CURSOR_DISABLED) - return; - x = wl_fixed_to_double(sx); - y = wl_fixed_to_double(sy); - window->wl.cursorPosX = x; - window->wl.cursorPosY = y; - - switch (window->wl.decorations.focus) - { - case mainWindow: - _glfwInputCursorPos(window, x, y); - _glfw.wl.cursorPreviousName = NULL; - return; - case topDecoration: - if (y < _GLFW_DECORATION_WIDTH) - cursorName = "n-resize"; - else - cursorName = "left_ptr"; - break; - case leftDecoration: - if (y < _GLFW_DECORATION_WIDTH) - cursorName = "nw-resize"; - else - cursorName = "w-resize"; - break; - case rightDecoration: - if (y < _GLFW_DECORATION_WIDTH) - cursorName = "ne-resize"; - else - cursorName = "e-resize"; - break; - case bottomDecoration: - if (x < _GLFW_DECORATION_WIDTH) - cursorName = "sw-resize"; - else if (x > window->wl.width + _GLFW_DECORATION_WIDTH) - cursorName = "se-resize"; - else - cursorName = "s-resize"; - break; - default: - assert(0); - } - if (_glfw.wl.cursorPreviousName != cursorName) - setCursor(window, cursorName); -} - -static void pointerHandleButton(void* userData, - struct wl_pointer* pointer, - uint32_t serial, - uint32_t time, - uint32_t button, - uint32_t state) -{ - _GLFWwindow* window = _glfw.wl.pointerFocus; - int glfwButton; - uint32_t edges = XDG_TOPLEVEL_RESIZE_EDGE_NONE; - - if (!window) - return; - if (button == BTN_LEFT) - { - switch (window->wl.decorations.focus) - { - case mainWindow: - break; - case topDecoration: - if (window->wl.cursorPosY < _GLFW_DECORATION_WIDTH) - edges = XDG_TOPLEVEL_RESIZE_EDGE_TOP; - else - xdg_toplevel_move(window->wl.xdg.toplevel, _glfw.wl.seat, serial); - break; - case leftDecoration: - if (window->wl.cursorPosY < _GLFW_DECORATION_WIDTH) - edges = XDG_TOPLEVEL_RESIZE_EDGE_TOP_LEFT; - else - edges = XDG_TOPLEVEL_RESIZE_EDGE_LEFT; - break; - case rightDecoration: - if (window->wl.cursorPosY < _GLFW_DECORATION_WIDTH) - edges = XDG_TOPLEVEL_RESIZE_EDGE_TOP_RIGHT; - else - edges = XDG_TOPLEVEL_RESIZE_EDGE_RIGHT; - break; - case bottomDecoration: - if (window->wl.cursorPosX < _GLFW_DECORATION_WIDTH) - edges = XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM_LEFT; - else if (window->wl.cursorPosX > window->wl.width + _GLFW_DECORATION_WIDTH) - edges = XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM_RIGHT; - else - edges = XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM; - break; - default: - assert(0); - } - if (edges != XDG_TOPLEVEL_RESIZE_EDGE_NONE) - { - xdg_toplevel_resize(window->wl.xdg.toplevel, _glfw.wl.seat, - serial, edges); - return; - } - } - else if (button == BTN_RIGHT) - { - if (window->wl.decorations.focus != mainWindow && window->wl.xdg.toplevel) - { - xdg_toplevel_show_window_menu(window->wl.xdg.toplevel, - _glfw.wl.seat, serial, - window->wl.cursorPosX, - window->wl.cursorPosY); - return; - } - } - - // Don’t pass the button to the user if it was related to a decoration. - if (window->wl.decorations.focus != mainWindow) - return; - - _glfw.wl.serial = serial; - - /* Makes left, right and middle 0, 1 and 2. Overall order follows evdev - * codes. */ - glfwButton = button - BTN_LEFT; - - _glfwInputMouseClick(window, - glfwButton, - state == WL_POINTER_BUTTON_STATE_PRESSED - ? GLFW_PRESS - : GLFW_RELEASE, - _glfw.wl.xkb.modifiers); -} - -static void pointerHandleAxis(void* userData, - struct wl_pointer* pointer, - uint32_t time, - uint32_t axis, - wl_fixed_t value) -{ - _GLFWwindow* window = _glfw.wl.pointerFocus; - double x = 0.0, y = 0.0; - // Wayland scroll events are in pointer motion coordinate space (think two - // finger scroll). The factor 10 is commonly used to convert to "scroll - // step means 1.0. - const double scrollFactor = 1.0 / 10.0; - - if (!window) - return; - - assert(axis == WL_POINTER_AXIS_HORIZONTAL_SCROLL || - axis == WL_POINTER_AXIS_VERTICAL_SCROLL); - - if (axis == WL_POINTER_AXIS_HORIZONTAL_SCROLL) - x = -wl_fixed_to_double(value) * scrollFactor; - else if (axis == WL_POINTER_AXIS_VERTICAL_SCROLL) - y = -wl_fixed_to_double(value) * scrollFactor; - - _glfwInputScroll(window, x, y); -} - -static const struct wl_pointer_listener pointerListener = { - pointerHandleEnter, - pointerHandleLeave, - pointerHandleMotion, - pointerHandleButton, - pointerHandleAxis, -}; - -static void keyboardHandleKeymap(void* userData, - struct wl_keyboard* keyboard, - uint32_t format, - int fd, - uint32_t size) -{ - struct xkb_keymap* keymap; - struct xkb_state* state; - struct xkb_compose_table* composeTable; - struct xkb_compose_state* composeState; - - char* mapStr; - const char* locale; - - if (format != WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1) - { - close(fd); - return; - } - - mapStr = mmap(NULL, size, PROT_READ, MAP_SHARED, fd, 0); - if (mapStr == MAP_FAILED) { - close(fd); - return; - } - - keymap = xkb_keymap_new_from_string(_glfw.wl.xkb.context, - mapStr, - XKB_KEYMAP_FORMAT_TEXT_V1, - 0); - munmap(mapStr, size); - close(fd); - - if (!keymap) - { - _glfwInputError(GLFW_PLATFORM_ERROR, - "Wayland: Failed to compile keymap"); - return; - } - - state = xkb_state_new(keymap); - if (!state) - { - _glfwInputError(GLFW_PLATFORM_ERROR, - "Wayland: Failed to create XKB state"); - xkb_keymap_unref(keymap); - return; - } - - // Look up the preferred locale, falling back to "C" as default. - locale = getenv("LC_ALL"); - if (!locale) - locale = getenv("LC_CTYPE"); - if (!locale) - locale = getenv("LANG"); - if (!locale) - locale = "C"; - - composeTable = - xkb_compose_table_new_from_locale(_glfw.wl.xkb.context, locale, - XKB_COMPOSE_COMPILE_NO_FLAGS); - if (composeTable) - { - composeState = - xkb_compose_state_new(composeTable, XKB_COMPOSE_STATE_NO_FLAGS); - xkb_compose_table_unref(composeTable); - if (composeState) - _glfw.wl.xkb.composeState = composeState; - else - _glfwInputError(GLFW_PLATFORM_ERROR, - "Wayland: Failed to create XKB compose state"); - } - else - { - _glfwInputError(GLFW_PLATFORM_ERROR, - "Wayland: Failed to create XKB compose table"); - } - - xkb_keymap_unref(_glfw.wl.xkb.keymap); - xkb_state_unref(_glfw.wl.xkb.state); - _glfw.wl.xkb.keymap = keymap; - _glfw.wl.xkb.state = state; - - _glfw.wl.xkb.controlMask = - 1 << xkb_keymap_mod_get_index(_glfw.wl.xkb.keymap, "Control"); - _glfw.wl.xkb.altMask = - 1 << xkb_keymap_mod_get_index(_glfw.wl.xkb.keymap, "Mod1"); - _glfw.wl.xkb.shiftMask = - 1 << xkb_keymap_mod_get_index(_glfw.wl.xkb.keymap, "Shift"); - _glfw.wl.xkb.superMask = - 1 << xkb_keymap_mod_get_index(_glfw.wl.xkb.keymap, "Mod4"); - _glfw.wl.xkb.capsLockMask = - 1 << xkb_keymap_mod_get_index(_glfw.wl.xkb.keymap, "Lock"); - _glfw.wl.xkb.numLockMask = - 1 << xkb_keymap_mod_get_index(_glfw.wl.xkb.keymap, "Mod2"); -} - -static void keyboardHandleEnter(void* userData, - struct wl_keyboard* keyboard, - uint32_t serial, - struct wl_surface* surface, - struct wl_array* keys) -{ - // Happens in the case we just destroyed the surface. - if (!surface) - return; - - _GLFWwindow* window = wl_surface_get_user_data(surface); - if (!window) - { - window = findWindowFromDecorationSurface(surface, NULL); - if (!window) - return; - } - - _glfw.wl.serial = serial; - _glfw.wl.keyboardFocus = window; - _glfwInputWindowFocus(window, GLFW_TRUE); -} - -static void keyboardHandleLeave(void* userData, - struct wl_keyboard* keyboard, - uint32_t serial, - struct wl_surface* surface) -{ - _GLFWwindow* window = _glfw.wl.keyboardFocus; - - if (!window) - return; - - struct itimerspec timer = {}; - timerfd_settime(_glfw.wl.timerfd, 0, &timer, NULL); - - _glfw.wl.serial = serial; - _glfw.wl.keyboardFocus = NULL; - _glfwInputWindowFocus(window, GLFW_FALSE); -} - -static int translateKey(uint32_t scancode) -{ - if (scancode < sizeof(_glfw.wl.keycodes) / sizeof(_glfw.wl.keycodes[0])) - return _glfw.wl.keycodes[scancode]; - - return GLFW_KEY_UNKNOWN; -} - -static xkb_keysym_t composeSymbol(xkb_keysym_t sym) -{ - if (sym == XKB_KEY_NoSymbol || !_glfw.wl.xkb.composeState) - return sym; - if (xkb_compose_state_feed(_glfw.wl.xkb.composeState, sym) - != XKB_COMPOSE_FEED_ACCEPTED) - return sym; - switch (xkb_compose_state_get_status(_glfw.wl.xkb.composeState)) - { - case XKB_COMPOSE_COMPOSED: - return xkb_compose_state_get_one_sym(_glfw.wl.xkb.composeState); - case XKB_COMPOSE_COMPOSING: - case XKB_COMPOSE_CANCELLED: - return XKB_KEY_NoSymbol; - case XKB_COMPOSE_NOTHING: - default: - return sym; - } -} - -GLFWbool _glfwInputTextWayland(_GLFWwindow* window, uint32_t scancode) -{ - const xkb_keysym_t* keysyms; - const xkb_keycode_t keycode = scancode + 8; - - if (xkb_state_key_get_syms(_glfw.wl.xkb.state, keycode, &keysyms) == 1) - { - const xkb_keysym_t keysym = composeSymbol(keysyms[0]); - const uint32_t codepoint = _glfwKeySym2Unicode(keysym); - if (codepoint != GLFW_INVALID_CODEPOINT) - { - const int mods = _glfw.wl.xkb.modifiers; - const int plain = !(mods & (GLFW_MOD_CONTROL | GLFW_MOD_ALT)); - _glfwInputChar(window, codepoint, mods, plain); - } - } - - return xkb_keymap_key_repeats(_glfw.wl.xkb.keymap, keycode); -} - -static void keyboardHandleKey(void* userData, - struct wl_keyboard* keyboard, - uint32_t serial, - uint32_t time, - uint32_t scancode, - uint32_t state) -{ - _GLFWwindow* window = _glfw.wl.keyboardFocus; - if (!window) - return; - - const int key = translateKey(scancode); - const int action = - state == WL_KEYBOARD_KEY_STATE_PRESSED ? GLFW_PRESS : GLFW_RELEASE; - - _glfw.wl.serial = serial; - _glfwInputKey(window, key, scancode, action, _glfw.wl.xkb.modifiers); - - struct itimerspec timer = {}; - - if (action == GLFW_PRESS) - { - const GLFWbool shouldRepeat = _glfwInputTextWayland(window, scancode); - - if (shouldRepeat && _glfw.wl.keyboardRepeatRate > 0) - { - _glfw.wl.keyboardLastKey = key; - _glfw.wl.keyboardLastScancode = scancode; - if (_glfw.wl.keyboardRepeatRate > 1) - timer.it_interval.tv_nsec = 1000000000 / _glfw.wl.keyboardRepeatRate; - else - timer.it_interval.tv_sec = 1; - - timer.it_value.tv_sec = _glfw.wl.keyboardRepeatDelay / 1000; - timer.it_value.tv_nsec = (_glfw.wl.keyboardRepeatDelay % 1000) * 1000000; - } - } - - timerfd_settime(_glfw.wl.timerfd, 0, &timer, NULL); -} - -static void keyboardHandleModifiers(void* userData, - struct wl_keyboard* keyboard, - uint32_t serial, - uint32_t modsDepressed, - uint32_t modsLatched, - uint32_t modsLocked, - uint32_t group) -{ - _glfw.wl.serial = serial; - - if (!_glfw.wl.xkb.keymap) - return; - - xkb_state_update_mask(_glfw.wl.xkb.state, - modsDepressed, - modsLatched, - modsLocked, - 0, - 0, - group); - - const xkb_mod_mask_t mask = - xkb_state_serialize_mods(_glfw.wl.xkb.state, - XKB_STATE_MODS_DEPRESSED | - XKB_STATE_LAYOUT_DEPRESSED | - XKB_STATE_MODS_LATCHED | - XKB_STATE_LAYOUT_LATCHED); - - unsigned int mods = 0; - - if (mask & _glfw.wl.xkb.controlMask) - mods |= GLFW_MOD_CONTROL; - if (mask & _glfw.wl.xkb.altMask) - mods |= GLFW_MOD_ALT; - if (mask & _glfw.wl.xkb.shiftMask) - mods |= GLFW_MOD_SHIFT; - if (mask & _glfw.wl.xkb.superMask) - mods |= GLFW_MOD_SUPER; - if (mask & _glfw.wl.xkb.capsLockMask) - mods |= GLFW_MOD_CAPS_LOCK; - if (mask & _glfw.wl.xkb.numLockMask) - mods |= GLFW_MOD_NUM_LOCK; - - _glfw.wl.xkb.modifiers = mods; -} - -#ifdef WL_KEYBOARD_REPEAT_INFO_SINCE_VERSION -static void keyboardHandleRepeatInfo(void* userData, - struct wl_keyboard* keyboard, - int32_t rate, - int32_t delay) -{ - if (keyboard != _glfw.wl.keyboard) - return; - - _glfw.wl.keyboardRepeatRate = rate; - _glfw.wl.keyboardRepeatDelay = delay; -} -#endif - -static const struct wl_keyboard_listener keyboardListener = { - keyboardHandleKeymap, - keyboardHandleEnter, - keyboardHandleLeave, - keyboardHandleKey, - keyboardHandleModifiers, -#ifdef WL_KEYBOARD_REPEAT_INFO_SINCE_VERSION - keyboardHandleRepeatInfo, -#endif -}; - -static void seatHandleCapabilities(void* userData, - struct wl_seat* seat, - enum wl_seat_capability caps) -{ - if ((caps & WL_SEAT_CAPABILITY_POINTER) && !_glfw.wl.pointer) - { - _glfw.wl.pointer = wl_seat_get_pointer(seat); - wl_pointer_add_listener(_glfw.wl.pointer, &pointerListener, NULL); - } - else if (!(caps & WL_SEAT_CAPABILITY_POINTER) && _glfw.wl.pointer) - { - wl_pointer_destroy(_glfw.wl.pointer); - _glfw.wl.pointer = NULL; - } - - if ((caps & WL_SEAT_CAPABILITY_KEYBOARD) && !_glfw.wl.keyboard) - { - _glfw.wl.keyboard = wl_seat_get_keyboard(seat); - wl_keyboard_add_listener(_glfw.wl.keyboard, &keyboardListener, NULL); - } - else if (!(caps & WL_SEAT_CAPABILITY_KEYBOARD) && _glfw.wl.keyboard) - { - wl_keyboard_destroy(_glfw.wl.keyboard); - _glfw.wl.keyboard = NULL; - } -} - -static void seatHandleName(void* userData, - struct wl_seat* seat, - const char* name) -{ -} - -static const struct wl_seat_listener seatListener = { - seatHandleCapabilities, - seatHandleName, -}; - -static void dataOfferHandleOffer(void* userData, - struct wl_data_offer* offer, - const char* mimeType) -{ - for (unsigned int i = 0; i < _glfw.wl.offerCount; i++) - { - if (_glfw.wl.offers[i].offer == offer) - { - if (strcmp(mimeType, "text/plain;charset=utf-8") == 0) - _glfw.wl.offers[i].text_plain_utf8 = GLFW_TRUE; - - break; - } - } -} - -static const struct wl_data_offer_listener dataOfferListener = { - dataOfferHandleOffer, -}; - -static void dataDeviceHandleDataOffer(void* userData, - struct wl_data_device* device, - struct wl_data_offer* offer) -{ - _GLFWofferWayland* offers = - _glfw_realloc(_glfw.wl.offers, _glfw.wl.offerCount + 1); - if (!offers) - { - _glfwInputError(GLFW_OUT_OF_MEMORY, NULL); - return; - } - - _glfw.wl.offers = offers; - _glfw.wl.offerCount++; - - _glfw.wl.offers[_glfw.wl.offerCount - 1] = (_GLFWofferWayland) { offer }; - wl_data_offer_add_listener(offer, &dataOfferListener, NULL); -} - -static void dataDeviceHandleEnter(void* userData, - struct wl_data_device* device, - uint32_t serial, - struct wl_surface* surface, - wl_fixed_t x, - wl_fixed_t y, - struct wl_data_offer* offer) -{ - for (unsigned int i = 0; i < _glfw.wl.offerCount; i++) - { - if (_glfw.wl.offers[i].offer == offer) - { - _glfw.wl.offers[i] = _glfw.wl.offers[_glfw.wl.offerCount - 1]; - _glfw.wl.offerCount--; - - // We don't yet handle drag and drop - wl_data_offer_accept(offer, serial, NULL); - wl_data_offer_destroy(offer); - break; - } - } -} - -static void dataDeviceHandleLeave(void* userData, - struct wl_data_device* device) -{ -} - -static void dataDeviceHandleMotion(void* userData, - struct wl_data_device* device, - uint32_t time, - wl_fixed_t x, - wl_fixed_t y) -{ -} - -static void dataDeviceHandleDrop(void* userData, - struct wl_data_device* device) -{ -} - -static void dataDeviceHandleSelection(void* userData, - struct wl_data_device* device, - struct wl_data_offer* offer) -{ - if (_glfw.wl.selectionOffer) - { - wl_data_offer_destroy(_glfw.wl.selectionOffer); - _glfw.wl.selectionOffer = NULL; - } - - for (unsigned int i = 0; i < _glfw.wl.offerCount; i++) - { - if (_glfw.wl.offers[i].offer == offer) - { - if (_glfw.wl.offers[i].text_plain_utf8) - _glfw.wl.selectionOffer = offer; - else - wl_data_offer_destroy(offer); - - _glfw.wl.offers[i] = _glfw.wl.offers[_glfw.wl.offerCount - 1]; - _glfw.wl.offerCount--; - break; - } - } -} - -static const struct wl_data_device_listener dataDeviceListener = { - dataDeviceHandleDataOffer, - dataDeviceHandleEnter, - dataDeviceHandleLeave, - dataDeviceHandleMotion, - dataDeviceHandleDrop, - dataDeviceHandleSelection, -}; - static void wmBaseHandlePing(void* userData, struct xdg_wm_base* wmBase, uint32_t serial) @@ -861,7 +101,7 @@ static void registryHandleGlobal(void* userData, _glfw.wl.seat = wl_registry_bind(registry, name, &wl_seat_interface, _glfw.wl.seatVersion); - wl_seat_add_listener(_glfw.wl.seat, &seatListener, NULL); + _glfwAddSeatListenerWayland(_glfw.wl.seat); } } else if (strcmp(interface, "wl_data_device_manager") == 0) @@ -1412,7 +652,7 @@ int _glfwInitWayland(void) _glfw.wl.dataDevice = wl_data_device_manager_get_data_device(_glfw.wl.dataDeviceManager, _glfw.wl.seat); - wl_data_device_add_listener(_glfw.wl.dataDevice, &dataDeviceListener, NULL); + _glfwAddDataDeviceListenerWayland(_glfw.wl.dataDevice); } return GLFW_TRUE; diff --git a/src/wl_platform.h b/src/wl_platform.h index 861f7cfe..e6d1579f 100644 --- a/src/wl_platform.h +++ b/src/wl_platform.h @@ -506,3 +506,6 @@ void _glfwSetGammaRampWayland(_GLFWmonitor* monitor, const GLFWgammaramp* ramp); void _glfwAddOutputWayland(uint32_t name, uint32_t version); GLFWbool _glfwInputTextWayland(_GLFWwindow* window, uint32_t scancode); +void _glfwAddSeatListenerWayland(struct wl_seat* seat); +void _glfwAddDataDeviceListenerWayland(struct wl_data_device* device); + diff --git a/src/wl_window.c b/src/wl_window.c index e21755a8..d32ef86a 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -811,6 +812,775 @@ static void handleEvents(double* timeout) } } +static _GLFWwindow* findWindowFromDecorationSurface(struct wl_surface* surface, + int* which) +{ + int focus; + _GLFWwindow* window = _glfw.windowListHead; + if (!which) + which = &focus; + while (window) + { + if (surface == window->wl.decorations.top.surface) + { + *which = topDecoration; + break; + } + if (surface == window->wl.decorations.left.surface) + { + *which = leftDecoration; + break; + } + if (surface == window->wl.decorations.right.surface) + { + *which = rightDecoration; + break; + } + if (surface == window->wl.decorations.bottom.surface) + { + *which = bottomDecoration; + break; + } + window = window->next; + } + return window; +} + +static void pointerHandleEnter(void* userData, + struct wl_pointer* pointer, + uint32_t serial, + struct wl_surface* surface, + wl_fixed_t sx, + wl_fixed_t sy) +{ + // Happens in the case we just destroyed the surface. + if (!surface) + return; + + int focus = 0; + _GLFWwindow* window = wl_surface_get_user_data(surface); + if (!window) + { + window = findWindowFromDecorationSurface(surface, &focus); + if (!window) + return; + } + + window->wl.decorations.focus = focus; + _glfw.wl.serial = serial; + _glfw.wl.pointerEnterSerial = serial; + _glfw.wl.pointerFocus = window; + + window->wl.hovered = GLFW_TRUE; + + _glfwSetCursorWayland(window, window->wl.currentCursor); + _glfwInputCursorEnter(window, GLFW_TRUE); +} + +static void pointerHandleLeave(void* userData, + struct wl_pointer* pointer, + uint32_t serial, + struct wl_surface* surface) +{ + _GLFWwindow* window = _glfw.wl.pointerFocus; + + if (!window) + return; + + window->wl.hovered = GLFW_FALSE; + + _glfw.wl.serial = serial; + _glfw.wl.pointerFocus = NULL; + _glfwInputCursorEnter(window, GLFW_FALSE); + _glfw.wl.cursorPreviousName = NULL; +} + +static void setCursor(_GLFWwindow* window, const char* name) +{ + struct wl_buffer* buffer; + struct wl_cursor* cursor; + struct wl_cursor_image* image; + struct wl_surface* surface = _glfw.wl.cursorSurface; + struct wl_cursor_theme* theme = _glfw.wl.cursorTheme; + int scale = 1; + + if (window->wl.scale > 1 && _glfw.wl.cursorThemeHiDPI) + { + // We only support up to scale=2 for now, since libwayland-cursor + // requires us to load a different theme for each size. + scale = 2; + theme = _glfw.wl.cursorThemeHiDPI; + } + + cursor = wl_cursor_theme_get_cursor(theme, name); + if (!cursor) + { + _glfwInputError(GLFW_CURSOR_UNAVAILABLE, + "Wayland: Standard cursor shape unavailable"); + return; + } + // TODO: handle animated cursors too. + image = cursor->images[0]; + + if (!image) + return; + + buffer = wl_cursor_image_get_buffer(image); + if (!buffer) + return; + wl_pointer_set_cursor(_glfw.wl.pointer, _glfw.wl.pointerEnterSerial, + surface, + image->hotspot_x / scale, + image->hotspot_y / scale); + wl_surface_set_buffer_scale(surface, scale); + wl_surface_attach(surface, buffer, 0, 0); + wl_surface_damage(surface, 0, 0, + image->width, image->height); + wl_surface_commit(surface); + _glfw.wl.cursorPreviousName = name; +} + +static void pointerHandleMotion(void* userData, + struct wl_pointer* pointer, + uint32_t time, + wl_fixed_t sx, + wl_fixed_t sy) +{ + _GLFWwindow* window = _glfw.wl.pointerFocus; + const char* cursorName = NULL; + double x, y; + + if (!window) + return; + + if (window->cursorMode == GLFW_CURSOR_DISABLED) + return; + x = wl_fixed_to_double(sx); + y = wl_fixed_to_double(sy); + window->wl.cursorPosX = x; + window->wl.cursorPosY = y; + + switch (window->wl.decorations.focus) + { + case mainWindow: + _glfwInputCursorPos(window, x, y); + _glfw.wl.cursorPreviousName = NULL; + return; + case topDecoration: + if (y < _GLFW_DECORATION_WIDTH) + cursorName = "n-resize"; + else + cursorName = "left_ptr"; + break; + case leftDecoration: + if (y < _GLFW_DECORATION_WIDTH) + cursorName = "nw-resize"; + else + cursorName = "w-resize"; + break; + case rightDecoration: + if (y < _GLFW_DECORATION_WIDTH) + cursorName = "ne-resize"; + else + cursorName = "e-resize"; + break; + case bottomDecoration: + if (x < _GLFW_DECORATION_WIDTH) + cursorName = "sw-resize"; + else if (x > window->wl.width + _GLFW_DECORATION_WIDTH) + cursorName = "se-resize"; + else + cursorName = "s-resize"; + break; + default: + assert(0); + } + if (_glfw.wl.cursorPreviousName != cursorName) + setCursor(window, cursorName); +} + +static void pointerHandleButton(void* userData, + struct wl_pointer* pointer, + uint32_t serial, + uint32_t time, + uint32_t button, + uint32_t state) +{ + _GLFWwindow* window = _glfw.wl.pointerFocus; + int glfwButton; + uint32_t edges = XDG_TOPLEVEL_RESIZE_EDGE_NONE; + + if (!window) + return; + if (button == BTN_LEFT) + { + switch (window->wl.decorations.focus) + { + case mainWindow: + break; + case topDecoration: + if (window->wl.cursorPosY < _GLFW_DECORATION_WIDTH) + edges = XDG_TOPLEVEL_RESIZE_EDGE_TOP; + else + xdg_toplevel_move(window->wl.xdg.toplevel, _glfw.wl.seat, serial); + break; + case leftDecoration: + if (window->wl.cursorPosY < _GLFW_DECORATION_WIDTH) + edges = XDG_TOPLEVEL_RESIZE_EDGE_TOP_LEFT; + else + edges = XDG_TOPLEVEL_RESIZE_EDGE_LEFT; + break; + case rightDecoration: + if (window->wl.cursorPosY < _GLFW_DECORATION_WIDTH) + edges = XDG_TOPLEVEL_RESIZE_EDGE_TOP_RIGHT; + else + edges = XDG_TOPLEVEL_RESIZE_EDGE_RIGHT; + break; + case bottomDecoration: + if (window->wl.cursorPosX < _GLFW_DECORATION_WIDTH) + edges = XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM_LEFT; + else if (window->wl.cursorPosX > window->wl.width + _GLFW_DECORATION_WIDTH) + edges = XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM_RIGHT; + else + edges = XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM; + break; + default: + assert(0); + } + if (edges != XDG_TOPLEVEL_RESIZE_EDGE_NONE) + { + xdg_toplevel_resize(window->wl.xdg.toplevel, _glfw.wl.seat, + serial, edges); + return; + } + } + else if (button == BTN_RIGHT) + { + if (window->wl.decorations.focus != mainWindow && window->wl.xdg.toplevel) + { + xdg_toplevel_show_window_menu(window->wl.xdg.toplevel, + _glfw.wl.seat, serial, + window->wl.cursorPosX, + window->wl.cursorPosY); + return; + } + } + + // Don’t pass the button to the user if it was related to a decoration. + if (window->wl.decorations.focus != mainWindow) + return; + + _glfw.wl.serial = serial; + + /* Makes left, right and middle 0, 1 and 2. Overall order follows evdev + * codes. */ + glfwButton = button - BTN_LEFT; + + _glfwInputMouseClick(window, + glfwButton, + state == WL_POINTER_BUTTON_STATE_PRESSED + ? GLFW_PRESS + : GLFW_RELEASE, + _glfw.wl.xkb.modifiers); +} + +static void pointerHandleAxis(void* userData, + struct wl_pointer* pointer, + uint32_t time, + uint32_t axis, + wl_fixed_t value) +{ + _GLFWwindow* window = _glfw.wl.pointerFocus; + double x = 0.0, y = 0.0; + // Wayland scroll events are in pointer motion coordinate space (think two + // finger scroll). The factor 10 is commonly used to convert to "scroll + // step means 1.0. + const double scrollFactor = 1.0 / 10.0; + + if (!window) + return; + + assert(axis == WL_POINTER_AXIS_HORIZONTAL_SCROLL || + axis == WL_POINTER_AXIS_VERTICAL_SCROLL); + + if (axis == WL_POINTER_AXIS_HORIZONTAL_SCROLL) + x = -wl_fixed_to_double(value) * scrollFactor; + else if (axis == WL_POINTER_AXIS_VERTICAL_SCROLL) + y = -wl_fixed_to_double(value) * scrollFactor; + + _glfwInputScroll(window, x, y); +} + +static const struct wl_pointer_listener pointerListener = { + pointerHandleEnter, + pointerHandleLeave, + pointerHandleMotion, + pointerHandleButton, + pointerHandleAxis, +}; + +static void keyboardHandleKeymap(void* userData, + struct wl_keyboard* keyboard, + uint32_t format, + int fd, + uint32_t size) +{ + struct xkb_keymap* keymap; + struct xkb_state* state; + struct xkb_compose_table* composeTable; + struct xkb_compose_state* composeState; + + char* mapStr; + const char* locale; + + if (format != WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1) + { + close(fd); + return; + } + + mapStr = mmap(NULL, size, PROT_READ, MAP_SHARED, fd, 0); + if (mapStr == MAP_FAILED) { + close(fd); + return; + } + + keymap = xkb_keymap_new_from_string(_glfw.wl.xkb.context, + mapStr, + XKB_KEYMAP_FORMAT_TEXT_V1, + 0); + munmap(mapStr, size); + close(fd); + + if (!keymap) + { + _glfwInputError(GLFW_PLATFORM_ERROR, + "Wayland: Failed to compile keymap"); + return; + } + + state = xkb_state_new(keymap); + if (!state) + { + _glfwInputError(GLFW_PLATFORM_ERROR, + "Wayland: Failed to create XKB state"); + xkb_keymap_unref(keymap); + return; + } + + // Look up the preferred locale, falling back to "C" as default. + locale = getenv("LC_ALL"); + if (!locale) + locale = getenv("LC_CTYPE"); + if (!locale) + locale = getenv("LANG"); + if (!locale) + locale = "C"; + + composeTable = + xkb_compose_table_new_from_locale(_glfw.wl.xkb.context, locale, + XKB_COMPOSE_COMPILE_NO_FLAGS); + if (composeTable) + { + composeState = + xkb_compose_state_new(composeTable, XKB_COMPOSE_STATE_NO_FLAGS); + xkb_compose_table_unref(composeTable); + if (composeState) + _glfw.wl.xkb.composeState = composeState; + else + _glfwInputError(GLFW_PLATFORM_ERROR, + "Wayland: Failed to create XKB compose state"); + } + else + { + _glfwInputError(GLFW_PLATFORM_ERROR, + "Wayland: Failed to create XKB compose table"); + } + + xkb_keymap_unref(_glfw.wl.xkb.keymap); + xkb_state_unref(_glfw.wl.xkb.state); + _glfw.wl.xkb.keymap = keymap; + _glfw.wl.xkb.state = state; + + _glfw.wl.xkb.controlMask = + 1 << xkb_keymap_mod_get_index(_glfw.wl.xkb.keymap, "Control"); + _glfw.wl.xkb.altMask = + 1 << xkb_keymap_mod_get_index(_glfw.wl.xkb.keymap, "Mod1"); + _glfw.wl.xkb.shiftMask = + 1 << xkb_keymap_mod_get_index(_glfw.wl.xkb.keymap, "Shift"); + _glfw.wl.xkb.superMask = + 1 << xkb_keymap_mod_get_index(_glfw.wl.xkb.keymap, "Mod4"); + _glfw.wl.xkb.capsLockMask = + 1 << xkb_keymap_mod_get_index(_glfw.wl.xkb.keymap, "Lock"); + _glfw.wl.xkb.numLockMask = + 1 << xkb_keymap_mod_get_index(_glfw.wl.xkb.keymap, "Mod2"); +} + +static void keyboardHandleEnter(void* userData, + struct wl_keyboard* keyboard, + uint32_t serial, + struct wl_surface* surface, + struct wl_array* keys) +{ + // Happens in the case we just destroyed the surface. + if (!surface) + return; + + _GLFWwindow* window = wl_surface_get_user_data(surface); + if (!window) + { + window = findWindowFromDecorationSurface(surface, NULL); + if (!window) + return; + } + + _glfw.wl.serial = serial; + _glfw.wl.keyboardFocus = window; + _glfwInputWindowFocus(window, GLFW_TRUE); +} + +static void keyboardHandleLeave(void* userData, + struct wl_keyboard* keyboard, + uint32_t serial, + struct wl_surface* surface) +{ + _GLFWwindow* window = _glfw.wl.keyboardFocus; + + if (!window) + return; + + struct itimerspec timer = {}; + timerfd_settime(_glfw.wl.timerfd, 0, &timer, NULL); + + _glfw.wl.serial = serial; + _glfw.wl.keyboardFocus = NULL; + _glfwInputWindowFocus(window, GLFW_FALSE); +} + +static int translateKey(uint32_t scancode) +{ + if (scancode < sizeof(_glfw.wl.keycodes) / sizeof(_glfw.wl.keycodes[0])) + return _glfw.wl.keycodes[scancode]; + + return GLFW_KEY_UNKNOWN; +} + +static xkb_keysym_t composeSymbol(xkb_keysym_t sym) +{ + if (sym == XKB_KEY_NoSymbol || !_glfw.wl.xkb.composeState) + return sym; + if (xkb_compose_state_feed(_glfw.wl.xkb.composeState, sym) + != XKB_COMPOSE_FEED_ACCEPTED) + return sym; + switch (xkb_compose_state_get_status(_glfw.wl.xkb.composeState)) + { + case XKB_COMPOSE_COMPOSED: + return xkb_compose_state_get_one_sym(_glfw.wl.xkb.composeState); + case XKB_COMPOSE_COMPOSING: + case XKB_COMPOSE_CANCELLED: + return XKB_KEY_NoSymbol; + case XKB_COMPOSE_NOTHING: + default: + return sym; + } +} + +GLFWbool _glfwInputTextWayland(_GLFWwindow* window, uint32_t scancode) +{ + const xkb_keysym_t* keysyms; + const xkb_keycode_t keycode = scancode + 8; + + if (xkb_state_key_get_syms(_glfw.wl.xkb.state, keycode, &keysyms) == 1) + { + const xkb_keysym_t keysym = composeSymbol(keysyms[0]); + const uint32_t codepoint = _glfwKeySym2Unicode(keysym); + if (codepoint != GLFW_INVALID_CODEPOINT) + { + const int mods = _glfw.wl.xkb.modifiers; + const int plain = !(mods & (GLFW_MOD_CONTROL | GLFW_MOD_ALT)); + _glfwInputChar(window, codepoint, mods, plain); + } + } + + return xkb_keymap_key_repeats(_glfw.wl.xkb.keymap, keycode); +} + +static void keyboardHandleKey(void* userData, + struct wl_keyboard* keyboard, + uint32_t serial, + uint32_t time, + uint32_t scancode, + uint32_t state) +{ + _GLFWwindow* window = _glfw.wl.keyboardFocus; + if (!window) + return; + + const int key = translateKey(scancode); + const int action = + state == WL_KEYBOARD_KEY_STATE_PRESSED ? GLFW_PRESS : GLFW_RELEASE; + + _glfw.wl.serial = serial; + _glfwInputKey(window, key, scancode, action, _glfw.wl.xkb.modifiers); + + struct itimerspec timer = {}; + + if (action == GLFW_PRESS) + { + const GLFWbool shouldRepeat = _glfwInputTextWayland(window, scancode); + + if (shouldRepeat && _glfw.wl.keyboardRepeatRate > 0) + { + _glfw.wl.keyboardLastKey = key; + _glfw.wl.keyboardLastScancode = scancode; + if (_glfw.wl.keyboardRepeatRate > 1) + timer.it_interval.tv_nsec = 1000000000 / _glfw.wl.keyboardRepeatRate; + else + timer.it_interval.tv_sec = 1; + + timer.it_value.tv_sec = _glfw.wl.keyboardRepeatDelay / 1000; + timer.it_value.tv_nsec = (_glfw.wl.keyboardRepeatDelay % 1000) * 1000000; + } + } + + timerfd_settime(_glfw.wl.timerfd, 0, &timer, NULL); +} + +static void keyboardHandleModifiers(void* userData, + struct wl_keyboard* keyboard, + uint32_t serial, + uint32_t modsDepressed, + uint32_t modsLatched, + uint32_t modsLocked, + uint32_t group) +{ + _glfw.wl.serial = serial; + + if (!_glfw.wl.xkb.keymap) + return; + + xkb_state_update_mask(_glfw.wl.xkb.state, + modsDepressed, + modsLatched, + modsLocked, + 0, + 0, + group); + + const xkb_mod_mask_t mask = + xkb_state_serialize_mods(_glfw.wl.xkb.state, + XKB_STATE_MODS_DEPRESSED | + XKB_STATE_LAYOUT_DEPRESSED | + XKB_STATE_MODS_LATCHED | + XKB_STATE_LAYOUT_LATCHED); + + unsigned int mods = 0; + + if (mask & _glfw.wl.xkb.controlMask) + mods |= GLFW_MOD_CONTROL; + if (mask & _glfw.wl.xkb.altMask) + mods |= GLFW_MOD_ALT; + if (mask & _glfw.wl.xkb.shiftMask) + mods |= GLFW_MOD_SHIFT; + if (mask & _glfw.wl.xkb.superMask) + mods |= GLFW_MOD_SUPER; + if (mask & _glfw.wl.xkb.capsLockMask) + mods |= GLFW_MOD_CAPS_LOCK; + if (mask & _glfw.wl.xkb.numLockMask) + mods |= GLFW_MOD_NUM_LOCK; + + _glfw.wl.xkb.modifiers = mods; +} + +#ifdef WL_KEYBOARD_REPEAT_INFO_SINCE_VERSION +static void keyboardHandleRepeatInfo(void* userData, + struct wl_keyboard* keyboard, + int32_t rate, + int32_t delay) +{ + if (keyboard != _glfw.wl.keyboard) + return; + + _glfw.wl.keyboardRepeatRate = rate; + _glfw.wl.keyboardRepeatDelay = delay; +} +#endif + +static const struct wl_keyboard_listener keyboardListener = { + keyboardHandleKeymap, + keyboardHandleEnter, + keyboardHandleLeave, + keyboardHandleKey, + keyboardHandleModifiers, +#ifdef WL_KEYBOARD_REPEAT_INFO_SINCE_VERSION + keyboardHandleRepeatInfo, +#endif +}; + +static void seatHandleCapabilities(void* userData, + struct wl_seat* seat, + enum wl_seat_capability caps) +{ + if ((caps & WL_SEAT_CAPABILITY_POINTER) && !_glfw.wl.pointer) + { + _glfw.wl.pointer = wl_seat_get_pointer(seat); + wl_pointer_add_listener(_glfw.wl.pointer, &pointerListener, NULL); + } + else if (!(caps & WL_SEAT_CAPABILITY_POINTER) && _glfw.wl.pointer) + { + wl_pointer_destroy(_glfw.wl.pointer); + _glfw.wl.pointer = NULL; + } + + if ((caps & WL_SEAT_CAPABILITY_KEYBOARD) && !_glfw.wl.keyboard) + { + _glfw.wl.keyboard = wl_seat_get_keyboard(seat); + wl_keyboard_add_listener(_glfw.wl.keyboard, &keyboardListener, NULL); + } + else if (!(caps & WL_SEAT_CAPABILITY_KEYBOARD) && _glfw.wl.keyboard) + { + wl_keyboard_destroy(_glfw.wl.keyboard); + _glfw.wl.keyboard = NULL; + } +} + +static void seatHandleName(void* userData, + struct wl_seat* seat, + const char* name) +{ +} + +static const struct wl_seat_listener seatListener = { + seatHandleCapabilities, + seatHandleName, +}; + +static void dataOfferHandleOffer(void* userData, + struct wl_data_offer* offer, + const char* mimeType) +{ + for (unsigned int i = 0; i < _glfw.wl.offerCount; i++) + { + if (_glfw.wl.offers[i].offer == offer) + { + if (strcmp(mimeType, "text/plain;charset=utf-8") == 0) + _glfw.wl.offers[i].text_plain_utf8 = GLFW_TRUE; + + break; + } + } +} + +static const struct wl_data_offer_listener dataOfferListener = { + dataOfferHandleOffer +}; + +static void dataDeviceHandleDataOffer(void* userData, + struct wl_data_device* device, + struct wl_data_offer* offer) +{ + _GLFWofferWayland* offers = + _glfw_realloc(_glfw.wl.offers, _glfw.wl.offerCount + 1); + if (!offers) + { + _glfwInputError(GLFW_OUT_OF_MEMORY, NULL); + return; + } + + _glfw.wl.offers = offers; + _glfw.wl.offerCount++; + + _glfw.wl.offers[_glfw.wl.offerCount - 1] = (_GLFWofferWayland) { offer }; + wl_data_offer_add_listener(offer, &dataOfferListener, NULL); +} + +static void dataDeviceHandleEnter(void* userData, + struct wl_data_device* device, + uint32_t serial, + struct wl_surface* surface, + wl_fixed_t x, + wl_fixed_t y, + struct wl_data_offer* offer) +{ + for (unsigned int i = 0; i < _glfw.wl.offerCount; i++) + { + if (_glfw.wl.offers[i].offer == offer) + { + _glfw.wl.offers[i] = _glfw.wl.offers[_glfw.wl.offerCount - 1]; + _glfw.wl.offerCount--; + + // We don't yet handle drag and drop + wl_data_offer_accept(offer, serial, NULL); + wl_data_offer_destroy(offer); + break; + } + } +} + +static void dataDeviceHandleLeave(void* userData, + struct wl_data_device* device) +{ +} + +static void dataDeviceHandleMotion(void* userData, + struct wl_data_device* device, + uint32_t time, + wl_fixed_t x, + wl_fixed_t y) +{ +} + +static void dataDeviceHandleDrop(void* userData, + struct wl_data_device* device) +{ +} + +static void dataDeviceHandleSelection(void* userData, + struct wl_data_device* device, + struct wl_data_offer* offer) +{ + if (_glfw.wl.selectionOffer) + { + wl_data_offer_destroy(_glfw.wl.selectionOffer); + _glfw.wl.selectionOffer = NULL; + } + + for (unsigned int i = 0; i < _glfw.wl.offerCount; i++) + { + if (_glfw.wl.offers[i].offer == offer) + { + if (_glfw.wl.offers[i].text_plain_utf8) + _glfw.wl.selectionOffer = offer; + else + wl_data_offer_destroy(offer); + + _glfw.wl.offers[i] = _glfw.wl.offers[_glfw.wl.offerCount - 1]; + _glfw.wl.offerCount--; + break; + } + } +} + +const struct wl_data_device_listener dataDeviceListener = { + dataDeviceHandleDataOffer, + dataDeviceHandleEnter, + dataDeviceHandleLeave, + dataDeviceHandleMotion, + dataDeviceHandleDrop, + dataDeviceHandleSelection, +}; + +void _glfwAddSeatListenerWayland(struct wl_seat* seat) +{ + wl_seat_add_listener(seat, &seatListener, NULL); +} + +void _glfwAddDataDeviceListenerWayland(struct wl_data_device* device) +{ + wl_data_device_add_listener(device, &dataDeviceListener, NULL); +} + + ////////////////////////////////////////////////////////////////////////// ////// GLFW platform API ////// ////////////////////////////////////////////////////////////////////////// From f010335b8cad7937397fcbfd252033899327b551 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 29 Mar 2022 19:00:18 +0200 Subject: [PATCH 185/208] Wayland: Make data offer reading a generic utility This will be needed for drag and drop reception as well. --- src/wl_platform.h | 1 - src/wl_window.c | 147 +++++++++++++++++++++++----------------------- 2 files changed, 73 insertions(+), 75 deletions(-) diff --git a/src/wl_platform.h b/src/wl_platform.h index e6d1579f..5ad9fa07 100644 --- a/src/wl_platform.h +++ b/src/wl_platform.h @@ -316,7 +316,6 @@ typedef struct _GLFWlibraryWayland int keyboardLastKey; int keyboardLastScancode; char* clipboardString; - size_t clipboardSize; int timerfd; short int keycodes[256]; short int scancodes[GLFW_KEY_LAST + 1]; diff --git a/src/wl_window.c b/src/wl_window.c index d32ef86a..57c75cec 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -812,6 +812,70 @@ static void handleEvents(double* timeout) } } +// Reads the specified data offer as the specified MIME type +// +static char* readDataOfferAsString(struct wl_data_offer* offer, const char* mimeType) +{ + int fds[2]; + + if (pipe2(fds, O_CLOEXEC) == -1) + { + _glfwInputError(GLFW_PLATFORM_ERROR, + "Wayland: Failed to create pipe for data offer: %s", + strerror(errno)); + return NULL; + } + + wl_data_offer_receive(offer, mimeType, fds[1]); + flushDisplay(); + close(fds[1]); + + char* string = NULL; + size_t size = 0; + size_t length = 0; + + for (;;) + { + const size_t readSize = 4096; + const size_t requiredSize = length + readSize + 1; + if (requiredSize > size) + { + char* longer = _glfw_realloc(string, requiredSize); + if (!longer) + { + _glfwInputError(GLFW_OUT_OF_MEMORY, NULL); + close(fds[0]); + return NULL; + } + + string = longer; + size = requiredSize; + } + + const ssize_t result = read(fds[0], string + length, readSize); + if (result == 0) + break; + else if (result == -1) + { + if (errno == EINTR) + continue; + + _glfwInputError(GLFW_PLATFORM_ERROR, + "Wayland: Failed to read from data offer pipe: %s", + strerror(errno)); + close(fds[0]); + return NULL; + } + + length += result; + } + + close(fds[0]); + + string[length] = '\0'; + return string; +} + static _GLFWwindow* findWindowFromDecorationSurface(struct wl_surface* surface, int* which) { @@ -2418,23 +2482,15 @@ void _glfwSetClipboardStringWayland(const char* string) _glfw.wl.selectionSource = NULL; } - const size_t requiredSize = strlen(string) + 1; - if (requiredSize > _glfw.wl.clipboardSize) + char* copy = _glfw_strdup(string); + if (!copy) { - _glfw_free(_glfw.wl.clipboardString); - _glfw.wl.clipboardString = _glfw_calloc(requiredSize, 1); - if (!_glfw.wl.clipboardString) - { - _glfwInputError(GLFW_OUT_OF_MEMORY, - "Wayland: Failed to allocate clipboard string"); - return; - } - - _glfw.wl.clipboardSize = requiredSize; + _glfwInputError(GLFW_OUT_OF_MEMORY, NULL); + return; } - // The argument may be a substring of the clipboard string - memmove(_glfw.wl.clipboardString, string, requiredSize); + _glfw_free(_glfw.wl.clipboardString); + _glfw.wl.clipboardString = copy; _glfw.wl.selectionSource = wl_data_device_manager_create_data_source(_glfw.wl.dataDeviceManager); @@ -2465,66 +2521,9 @@ const char* _glfwGetClipboardStringWayland(void) if (_glfw.wl.selectionSource) return _glfw.wl.clipboardString; - int fds[2]; - - if (pipe2(fds, O_CLOEXEC) == -1) - { - _glfwInputError(GLFW_PLATFORM_ERROR, - "Wayland: Failed to create clipboard pipe: %s", - strerror(errno)); - return NULL; - } - - wl_data_offer_receive(_glfw.wl.selectionOffer, "text/plain;charset=utf-8", fds[1]); - - flushDisplay(); - close(fds[1]); - - size_t length = 0; - - for (;;) - { - // Grow the clipboard if we need to paste something bigger, there is no - // shrink operation yet. - const size_t readSize = 4096; - const size_t requiredSize = length + readSize + 1; - if (requiredSize > _glfw.wl.clipboardSize) - { - char* string = _glfw_realloc(_glfw.wl.clipboardString, requiredSize); - if (!string) - { - _glfwInputError(GLFW_OUT_OF_MEMORY, - "Wayland: Failed to grow clipboard string"); - close(fds[0]); - return NULL; - } - - _glfw.wl.clipboardString = string; - _glfw.wl.clipboardSize = requiredSize; - } - - // Then read from the fd to the clipboard, handling all known errors. - const ssize_t result = read(fds[0], _glfw.wl.clipboardString + length, readSize); - if (result == 0) - break; - else if (result == -1) - { - if (errno == EINTR) - continue; - - _glfwInputError(GLFW_PLATFORM_ERROR, - "Wayland: Failed to read from clipboard pipe: %s", - strerror(errno)); - close(fds[0]); - return NULL; - } - - length += result; - } - - close(fds[0]); - - _glfw.wl.clipboardString[length] = '\0'; + _glfw_free(_glfw.wl.clipboardString); + _glfw.wl.clipboardString = + readDataOfferAsString(_glfw.wl.selectionOffer, "text/plain;charset=utf-8"); return _glfw.wl.clipboardString; } From 0f38382e25f484a8da2660f606c30b32a51b600e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 31 Mar 2022 22:17:08 +0200 Subject: [PATCH 186/208] Wayland: Clean up listener struct initialization Adapt style to match the rest of the project. --- src/wl_init.c | 6 ++++-- src/wl_monitor.c | 3 ++- src/wl_window.c | 30 ++++++++++++++++++++---------- 3 files changed, 26 insertions(+), 13 deletions(-) diff --git a/src/wl_init.c b/src/wl_init.c index 4ea5e1e4..6545c41e 100644 --- a/src/wl_init.c +++ b/src/wl_init.c @@ -62,7 +62,8 @@ static void wmBaseHandlePing(void* userData, xdg_wm_base_pong(wmBase, serial); } -static const struct xdg_wm_base_listener wmBaseListener = { +static const struct xdg_wm_base_listener wmBaseListener = +{ wmBaseHandlePing }; @@ -172,7 +173,8 @@ static void registryHandleGlobalRemove(void* userData, } -static const struct wl_registry_listener registryListener = { +static const struct wl_registry_listener registryListener = +{ registryHandleGlobal, registryHandleGlobalRemove }; diff --git a/src/wl_monitor.c b/src/wl_monitor.c index 07adaa39..568bdc5f 100644 --- a/src/wl_monitor.c +++ b/src/wl_monitor.c @@ -108,7 +108,8 @@ static void outputHandleScale(void* userData, monitor->wl.scale = factor; } -static const struct wl_output_listener outputListener = { +static const struct wl_output_listener outputListener = +{ outputHandleGeometry, outputHandleMode, outputHandleDone, diff --git a/src/wl_window.c b/src/wl_window.c index 57c75cec..3fd4a87b 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -285,7 +285,8 @@ static void xdgDecorationHandleConfigure(void* userData, createDecorations(window); } -static const struct zxdg_toplevel_decoration_v1_listener xdgDecorationListener = { +static const struct zxdg_toplevel_decoration_v1_listener xdgDecorationListener = +{ xdgDecorationHandleConfigure, }; @@ -513,7 +514,8 @@ static void xdgToplevelHandleClose(void* userData, _glfwInputWindowCloseRequest(window); } -static const struct xdg_toplevel_listener xdgToplevelListener = { +static const struct xdg_toplevel_listener xdgToplevelListener = +{ xdgToplevelHandleConfigure, xdgToplevelHandleClose }; @@ -1175,7 +1177,8 @@ static void pointerHandleAxis(void* userData, _glfwInputScroll(window, x, y); } -static const struct wl_pointer_listener pointerListener = { +static const struct wl_pointer_listener pointerListener = +{ pointerHandleEnter, pointerHandleLeave, pointerHandleMotion, @@ -1470,7 +1473,8 @@ static void keyboardHandleRepeatInfo(void* userData, } #endif -static const struct wl_keyboard_listener keyboardListener = { +static const struct wl_keyboard_listener keyboardListener = +{ keyboardHandleKeymap, keyboardHandleEnter, keyboardHandleLeave, @@ -1514,7 +1518,8 @@ static void seatHandleName(void* userData, { } -static const struct wl_seat_listener seatListener = { +static const struct wl_seat_listener seatListener = +{ seatHandleCapabilities, seatHandleName, }; @@ -1535,7 +1540,8 @@ static void dataOfferHandleOffer(void* userData, } } -static const struct wl_data_offer_listener dataOfferListener = { +static const struct wl_data_offer_listener dataOfferListener = +{ dataOfferHandleOffer }; @@ -1625,7 +1631,8 @@ static void dataDeviceHandleSelection(void* userData, } } -const struct wl_data_device_listener dataDeviceListener = { +const struct wl_data_device_listener dataDeviceListener = +{ dataDeviceHandleDataOffer, dataDeviceHandleEnter, dataDeviceHandleLeave, @@ -2271,7 +2278,8 @@ static void relativePointerHandleRelativeMotion(void* userData, _glfwInputCursorPos(window, xpos, ypos); } -static const struct zwp_relative_pointer_v1_listener relativePointerListener = { +static const struct zwp_relative_pointer_v1_listener relativePointerListener = +{ relativePointerHandleRelativeMotion }; @@ -2301,7 +2309,8 @@ static void lockedPointerHandleUnlocked(void* userData, { } -static const struct zwp_locked_pointer_v1_listener lockedPointerListener = { +static const struct zwp_locked_pointer_v1_listener lockedPointerListener = +{ lockedPointerHandleLocked, lockedPointerHandleUnlocked }; @@ -2468,7 +2477,8 @@ static void dataSourceHandleCancelled(void* userData, _glfw.wl.selectionSource = NULL; } -static const struct wl_data_source_listener dataSourceListener = { +static const struct wl_data_source_listener dataSourceListener = +{ dataSourceHandleTarget, dataSourceHandleSend, dataSourceHandleCancelled, From 4cb36872a5fe448c205d0b46f0e8c8b57530cfe0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 31 Mar 2022 19:56:48 +0200 Subject: [PATCH 187/208] Wayland: Add support for file drop events This adds support for file path drop events in text/uri-list format. It is based on work by Pilzschaf in #2040. Closes #2040 --- CONTRIBUTORS.md | 1 + README.md | 1 + src/wl_init.c | 2 ++ src/wl_platform.h | 5 +++++ src/wl_window.c | 57 +++++++++++++++++++++++++++++++++++++++++++---- 5 files changed, 62 insertions(+), 4 deletions(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index cc77ff13..c93c187e 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -162,6 +162,7 @@ video tutorials. - Orson Peters - Emmanuel Gil Peyrot - Cyril Pichard + - Pilzschaf - Keith Pitt - Stanislav Podgorskiy - Konstantin Podsvirov diff --git a/README.md b/README.md index 7b6873f1..334277ed 100644 --- a/README.md +++ b/README.md @@ -287,6 +287,7 @@ information on what to include when reporting a bug. - [X11] Bugfix: Left shift of int constant relied on undefined behavior (#1951) - [Wayland] Added dynamic loading of all Wayland libraries - [Wayland] Added support for key names via xkbcommon + - [Wayland] Added support for file path drop events (#2040) - [Wayland] Removed support for `wl_shell` (#1443) - [Wayland] Bugfix: The `GLFW_HAND_CURSOR` shape used the wrong image (#1432) - [Wayland] Bugfix: `CLOCK_MONOTONIC` was not correctly enabled diff --git a/src/wl_init.c b/src/wl_init.c index 6545c41e..3c0dac47 100644 --- a/src/wl_init.c +++ b/src/wl_init.c @@ -714,6 +714,8 @@ void _glfwTerminateWayland(void) xdg_wm_base_destroy(_glfw.wl.wmBase); if (_glfw.wl.selectionOffer) wl_data_offer_destroy(_glfw.wl.selectionOffer); + if (_glfw.wl.dragOffer) + wl_data_offer_destroy(_glfw.wl.dragOffer); if (_glfw.wl.selectionSource) wl_data_source_destroy(_glfw.wl.selectionSource); if (_glfw.wl.dataDevice) diff --git a/src/wl_platform.h b/src/wl_platform.h index 5ad9fa07..d6c8c4da 100644 --- a/src/wl_platform.h +++ b/src/wl_platform.h @@ -223,6 +223,7 @@ typedef struct _GLFWofferWayland { struct wl_data_offer* offer; GLFWbool text_plain_utf8; + GLFWbool text_uri_list; } _GLFWofferWayland; // Wayland-specific per-window data @@ -300,6 +301,10 @@ typedef struct _GLFWlibraryWayland struct wl_data_offer* selectionOffer; struct wl_data_source* selectionSource; + struct wl_data_offer* dragOffer; + _GLFWwindow* dragFocus; + uint32_t dragSerial; + int compositorVersion; int seatVersion; diff --git a/src/wl_window.c b/src/wl_window.c index 3fd4a87b..047b9eb6 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -1534,6 +1534,8 @@ static void dataOfferHandleOffer(void* userData, { if (strcmp(mimeType, "text/plain;charset=utf-8") == 0) _glfw.wl.offers[i].text_plain_utf8 = GLFW_TRUE; + else if (strcmp(mimeType, "text/uri-list") == 0) + _glfw.wl.offers[i].text_uri_list = GLFW_TRUE; break; } @@ -1572,24 +1574,53 @@ static void dataDeviceHandleEnter(void* userData, wl_fixed_t y, struct wl_data_offer* offer) { + if (_glfw.wl.dragOffer) + { + wl_data_offer_destroy(_glfw.wl.dragOffer); + _glfw.wl.dragOffer = NULL; + _glfw.wl.dragFocus = NULL; + } + for (unsigned int i = 0; i < _glfw.wl.offerCount; i++) { if (_glfw.wl.offers[i].offer == offer) { + _GLFWwindow* window = NULL; + + if (surface) + window = wl_surface_get_user_data(surface); + + if (window && _glfw.wl.offers[i].text_uri_list) + { + _glfw.wl.dragOffer = offer; + _glfw.wl.dragFocus = window; + _glfw.wl.dragSerial = serial; + } + _glfw.wl.offers[i] = _glfw.wl.offers[_glfw.wl.offerCount - 1]; _glfw.wl.offerCount--; - - // We don't yet handle drag and drop - wl_data_offer_accept(offer, serial, NULL); - wl_data_offer_destroy(offer); break; } } + + if (_glfw.wl.dragOffer) + wl_data_offer_accept(offer, serial, "text/uri-list"); + else + { + wl_data_offer_accept(offer, serial, NULL); + wl_data_offer_destroy(offer); + } } static void dataDeviceHandleLeave(void* userData, struct wl_data_device* device) { + if (_glfw.wl.dragOffer) + { + wl_data_offer_destroy(_glfw.wl.dragOffer); + _glfw.wl.dragOffer = NULL; + _glfw.wl.dragFocus = NULL; + } } static void dataDeviceHandleMotion(void* userData, @@ -1603,6 +1634,24 @@ static void dataDeviceHandleMotion(void* userData, static void dataDeviceHandleDrop(void* userData, struct wl_data_device* device) { + if (!_glfw.wl.dragOffer) + return; + + char* string = readDataOfferAsString(_glfw.wl.dragOffer, "text/uri-list"); + if (string) + { + int count; + char** paths = _glfwParseUriList(string, &count); + if (paths) + _glfwInputDrop(_glfw.wl.dragFocus, count, (const char**) paths); + + for (int i = 0; i < count; i++) + _glfw_free(paths[i]); + + _glfw_free(paths); + } + + _glfw_free(string); } static void dataDeviceHandleSelection(void* userData, From f843d533335db275e0b014311cd7163a2a003b03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 8 Apr 2022 18:22:39 +0200 Subject: [PATCH 188/208] Fix glfwMakeContextCurrent using uninitialized TLS Issue reported by danhambleton on the GLFW forum: https://discourse.glfw.org/t/posix-thread-local-storage-tls-error-when-making-context-current/2034 --- CONTRIBUTORS.md | 1 + README.md | 1 + src/context.c | 4 +++- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index c93c187e..030abf7c 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -44,6 +44,7 @@ video tutorials. - Noel Cower - CuriouserThing - Jason Daly + - danhambleton - Jarrod Davis - Olivier Delannoy - Paul R. Deppe diff --git a/README.md b/README.md index 334277ed..b49a8a0d 100644 --- a/README.md +++ b/README.md @@ -172,6 +172,7 @@ information on what to include when reporting a bug. - Bugfix: Gamepad mapping updates could spam `GLFW_INVALID_VALUE` due to incompatible controllers sharing hardware ID (#1763) - Bugfix: Native access functions for context handles did not check that the API matched + - Bugfix: `glfwMakeContextCurrent` would access TLS slot before initialization - [Win32] Added the `GLFW_WIN32_KEYBOARD_MENU` window hint for enabling access to the window menu - [Win32] Added a version info resource to the GLFW DLL diff --git a/src/context.c b/src/context.c index f6629f55..7e0449b4 100644 --- a/src/context.c +++ b/src/context.c @@ -609,10 +609,12 @@ GLFWbool _glfwStringInExtensionString(const char* string, const char* extensions GLFWAPI void glfwMakeContextCurrent(GLFWwindow* handle) { _GLFWwindow* window = (_GLFWwindow*) handle; - _GLFWwindow* previous = _glfwPlatformGetTls(&_glfw.contextSlot); + _GLFWwindow* previous; _GLFW_REQUIRE_INIT(); + previous = _glfwPlatformGetTls(&_glfw.contextSlot); + if (window && window->context.client == GLFW_NO_API) { _glfwInputError(GLFW_NO_WINDOW_CONTEXT, From 29523dbfbfe097bec9ae3a5ec08b08915e1e4a59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 21 Apr 2022 15:37:31 +0200 Subject: [PATCH 189/208] Fix order of error checks in glfwSetGammaRamp Initialization should be checked before arguments. --- README.md | 1 + src/monitor.c | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b49a8a0d..89e28723 100644 --- a/README.md +++ b/README.md @@ -173,6 +173,7 @@ information on what to include when reporting a bug. incompatible controllers sharing hardware ID (#1763) - Bugfix: Native access functions for context handles did not check that the API matched - Bugfix: `glfwMakeContextCurrent` would access TLS slot before initialization + - Bugfix: `glfwSetGammaRamp` could emit `GLFW_INVALID_VALUE` before initialization - [Win32] Added the `GLFW_WIN32_KEYBOARD_MENU` window hint for enabling access to the window menu - [Win32] Added a version info resource to the GLFW DLL diff --git a/src/monitor.c b/src/monitor.c index e6f47d65..082140ad 100644 --- a/src/monitor.c +++ b/src/monitor.c @@ -522,6 +522,8 @@ GLFWAPI void glfwSetGammaRamp(GLFWmonitor* handle, const GLFWgammaramp* ramp) assert(ramp->green != NULL); assert(ramp->blue != NULL); + _GLFW_REQUIRE_INIT(); + if (ramp->size <= 0) { _glfwInputError(GLFW_INVALID_VALUE, @@ -530,8 +532,6 @@ GLFWAPI void glfwSetGammaRamp(GLFWmonitor* handle, const GLFWgammaramp* ramp) return; } - _GLFW_REQUIRE_INIT(); - if (!monitor->originalRamp.size) { if (!_glfw.platform.getGammaRamp(monitor, &monitor->originalRamp)) From 10e9033a29ba088275da4363cd2d821ca577416a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 28 Apr 2022 21:12:36 +0200 Subject: [PATCH 190/208] Win32: Fix OSMesa library not being unloaded --- README.md | 1 + src/win32_init.c | 1 + 2 files changed, 2 insertions(+) diff --git a/README.md b/README.md index 89e28723..a8b38fbd 100644 --- a/README.md +++ b/README.md @@ -217,6 +217,7 @@ information on what to include when reporting a bug. - [Win32] Bugfix: `GLFW_KEY_PAUSE` scancode from `glfwGetKeyScancode` did not match event scancode (#1993) - [Win32] Bugfix: Instance-local operations used executable instance (#469,#1296,#1395) + - [Win32] Bugfix: The OSMesa library was not unloaded on termination - [Cocoa] Added support for `VK_EXT_metal_surface` (#1619) - [Cocoa] Added locating the Vulkan loader at runtime in an application bundle - [Cocoa] Moved main menu creation to GLFW initialization time (#1649) diff --git a/src/win32_init.c b/src/win32_init.c index 7aefc78a..9465c951 100644 --- a/src/win32_init.c +++ b/src/win32_init.c @@ -670,6 +670,7 @@ void _glfwTerminateWin32(void) _glfwTerminateWGL(); _glfwTerminateEGL(); + _glfwTerminateOSMesa(); freeLibraries(); } From 89514cf0fc33aed4db1310a57cc7436999492d14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 28 Apr 2022 21:14:11 +0200 Subject: [PATCH 191/208] Cocoa: Fix EGL and OSMesa not being unloaded --- README.md | 1 + src/cocoa_init.m | 2 ++ 2 files changed, 3 insertions(+) diff --git a/README.md b/README.md index a8b38fbd..934eb331 100644 --- a/README.md +++ b/README.md @@ -249,6 +249,7 @@ information on what to include when reporting a bug. - [Cocoa] Bugfix: `kIOMasterPortDefault` was deprecated in macOS 12.0 (#1980) - [Cocoa] Bugfix: `kUTTypeURL` was deprecated in macOS 12.0 (#2003) - [Cocoa] Bugfix: A connected Apple AirPlay would emit a useless error (#1791) + - [Cocoa] Bugfix: The EGL and OSMesa libraries were not unloaded on termination - [X11] Bugfix: The CMake files did not check for the XInput headers (#1480) - [X11] Bugfix: Key names were not updated when the keyboard layout changed (#1462,#1528) diff --git a/src/cocoa_init.m b/src/cocoa_init.m index 48bc2c29..6bc6496a 100644 --- a/src/cocoa_init.m +++ b/src/cocoa_init.m @@ -676,6 +676,8 @@ void _glfwTerminateCocoa(void) _glfw_free(_glfw.ns.clipboardString); _glfwTerminateNSGL(); + _glfwTerminateEGL(); + _glfwTerminateOSMesa(); } // autoreleasepool } From 2d281d7928552c15ea2bc6dd185f7d7a780b1917 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 28 Apr 2022 21:16:06 +0200 Subject: [PATCH 192/208] Wayland: Fix OSMesa library not being unloaded --- README.md | 1 + src/wl_init.c | 2 ++ 2 files changed, 3 insertions(+) diff --git a/README.md b/README.md index 934eb331..3bf56e07 100644 --- a/README.md +++ b/README.md @@ -322,6 +322,7 @@ information on what to include when reporting a bug. - [Wayland] Bugfix: Some errors would cause clipboard string transfer to hang - [Wayland] Bugfix: Drag and drop data was misinterpreted as clipboard string - [Wayland] Bugfix: MIME type matching was not performed for clipboard string + - [Wayland] Bugfix: The OSMesa library was not unloaded on termination - [POSIX] Removed use of deprecated function `gettimeofday` - [POSIX] Bugfix: `CLOCK_MONOTONIC` was not correctly tested for or enabled - [WGL] Disabled the DWM swap interval hack for Windows 8 and later (#1072) diff --git a/src/wl_init.c b/src/wl_init.c index 3c0dac47..c4e47e99 100644 --- a/src/wl_init.c +++ b/src/wl_init.c @@ -663,6 +663,8 @@ int _glfwInitWayland(void) void _glfwTerminateWayland(void) { _glfwTerminateEGL(); + _glfwTerminateOSMesa(); + if (_glfw.wl.egl.handle) { _glfwPlatformFreeModule(_glfw.wl.egl.handle); From a8d8b760fb6bffb9c7f65297a0bc3d6bf6b54262 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 28 Apr 2022 21:17:39 +0200 Subject: [PATCH 193/208] X11: Fix OSMesa library not being unloaded --- README.md | 1 + src/x11_init.c | 1 + 2 files changed, 2 insertions(+) diff --git a/README.md b/README.md index 3bf56e07..3b57f9b5 100644 --- a/README.md +++ b/README.md @@ -289,6 +289,7 @@ information on what to include when reporting a bug. (#379,#1281,#1285,#2033) - [X11] Bugfix: Dynamic loading on NetBSD failed due to soname differences - [X11] Bugfix: Left shift of int constant relied on undefined behavior (#1951) + - [X11] Bugfix: The OSMesa libray was not unloaded on termination - [Wayland] Added dynamic loading of all Wayland libraries - [Wayland] Added support for key names via xkbcommon - [Wayland] Added support for file path drop events (#2040) diff --git a/src/x11_init.c b/src/x11_init.c index 78735d69..aefa82db 100644 --- a/src/x11_init.c +++ b/src/x11_init.c @@ -1630,6 +1630,7 @@ void _glfwTerminateX11(void) _glfw.x11.xi.handle = NULL; } + _glfwTerminateOSMesa(); // NOTE: These need to be unloaded after XCloseDisplay, as they register // cleanup callbacks that get called by that function _glfwTerminateEGL(); From 82ccbb3ef02201498cbf5952083de47989e05978 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 18 Apr 2022 23:09:00 +0200 Subject: [PATCH 194/208] Update stb_image_write.h to version 1.16 --- deps/stb_image_write.h | 930 +++++++++++++++++++++++++++++++++++------ 1 file changed, 803 insertions(+), 127 deletions(-) diff --git a/deps/stb_image_write.h b/deps/stb_image_write.h index 4319c0de..e4b32ed1 100644 --- a/deps/stb_image_write.h +++ b/deps/stb_image_write.h @@ -1,5 +1,5 @@ -/* stb_image_write - v1.02 - public domain - http://nothings.org/stb/stb_image_write.h - writes out PNG/BMP/TGA images to C stdio - Sean Barrett 2010-2015 +/* stb_image_write - v1.16 - public domain - http://nothings.org/stb + writes out PNG/BMP/TGA/JPEG/HDR images to C stdio - Sean Barrett 2010-2015 no warranty implied; use at your own risk Before #including, @@ -12,41 +12,64 @@ ABOUT: - This header file is a library for writing images to C stdio. It could be - adapted to write to memory or a general streaming interface; let me know. + This header file is a library for writing images to C stdio or a callback. The PNG output is not optimal; it is 20-50% larger than the file - written by a decent optimizing implementation. This library is designed - for source code compactness and simplicity, not optimal image file size - or run-time performance. + written by a decent optimizing implementation; though providing a custom + zlib compress function (see STBIW_ZLIB_COMPRESS) can mitigate that. + This library is designed for source code compactness and simplicity, + not optimal image file size or run-time performance. BUILDING: You can #define STBIW_ASSERT(x) before the #include to avoid using assert.h. You can #define STBIW_MALLOC(), STBIW_REALLOC(), and STBIW_FREE() to replace malloc,realloc,free. - You can define STBIW_MEMMOVE() to replace memmove() + You can #define STBIW_MEMMOVE() to replace memmove() + You can #define STBIW_ZLIB_COMPRESS to use a custom zlib-style compress function + for PNG compression (instead of the builtin one), it must have the following signature: + unsigned char * my_compress(unsigned char *data, int data_len, int *out_len, int quality); + The returned data will be freed with STBIW_FREE() (free() by default), + so it must be heap allocated with STBIW_MALLOC() (malloc() by default), + +UNICODE: + + If compiling for Windows and you wish to use Unicode filenames, compile + with + #define STBIW_WINDOWS_UTF8 + and pass utf8-encoded filenames. Call stbiw_convert_wchar_to_utf8 to convert + Windows wchar_t filenames to utf8. USAGE: - There are four functions, one for each image file format: + There are five functions, one for each image file format: int stbi_write_png(char const *filename, int w, int h, int comp, const void *data, int stride_in_bytes); int stbi_write_bmp(char const *filename, int w, int h, int comp, const void *data); int stbi_write_tga(char const *filename, int w, int h, int comp, const void *data); + int stbi_write_jpg(char const *filename, int w, int h, int comp, const void *data, int quality); int stbi_write_hdr(char const *filename, int w, int h, int comp, const float *data); - There are also four equivalent functions that use an arbitrary write function. You are + void stbi_flip_vertically_on_write(int flag); // flag is non-zero to flip data vertically + + There are also five equivalent functions that use an arbitrary write function. You are expected to open/close your file-equivalent before and after calling these: int stbi_write_png_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const void *data, int stride_in_bytes); int stbi_write_bmp_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const void *data); int stbi_write_tga_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const void *data); int stbi_write_hdr_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const float *data); + int stbi_write_jpg_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data, int quality); where the callback is: void stbi_write_func(void *context, void *data, int size); + You can configure it with these global variables: + int stbi_write_tga_with_rle; // defaults to true; set to 0 to disable RLE + int stbi_write_png_compression_level; // defaults to 8; set to higher for more compression + int stbi_write_force_png_filter; // defaults to -1; set to 0..5 to force a filter mode + + You can define STBI_WRITE_NO_STDIO to disable the file variant of these functions, so the library will not use stdio.h at all. However, this will also disable HDR writing, because it requires stdio for formatted output. @@ -73,6 +96,9 @@ USAGE: writer, both because it is in BGR order and because it may have padding at the end of the line.) + PNG allows you to set the deflate compression level by setting the global + variable 'stbi_write_png_compression_level' (it defaults to 8). + HDR expects linear float data. Since the format is always 32-bit rgb(e) data, alpha (if provided) is discarded, and for monochrome data it is replicated across all three channels. @@ -80,20 +106,23 @@ USAGE: TGA supports RLE or non-RLE compressed data. To use non-RLE-compressed data, set the global variable 'stbi_write_tga_with_rle' to 0. + JPEG does ignore alpha channels in input data; quality is between 1 and 100. + Higher quality looks better but results in a bigger image. + JPEG baseline (no JPEG progressive). + CREDITS: - PNG/BMP/TGA - Sean Barrett - HDR - Baldur Karlsson - TGA monochrome: - Jean-Sebastien Guay - misc enhancements: - Tim Kelsey - TGA RLE - Alan Hickman - initial file IO callback implementation - Emmanuel Julien + + Sean Barrett - PNG/BMP/TGA + Baldur Karlsson - HDR + Jean-Sebastien Guay - TGA monochrome + Tim Kelsey - misc enhancements + Alan Hickman - TGA RLE + Emmanuel Julien - initial file IO callback implementation + Jon Olick - original jo_jpeg.cpp code + Daniel Gibson - integrate JPEG, allow external zlib + Aarni Koskela - allow choosing PNG filter + bugfixes: github:Chribba Guillaume Chereau @@ -103,27 +132,44 @@ CREDITS: Jonas Karlsson Filip Wasil Thatcher Ulrich - + github:poppolopoppo + Patrick Boettcher + github:xeekworx + Cap Petschulat + Simon Rodriguez + Ivan Tikhonov + github:ignotion + Adam Schackart + Andrew Kensler + LICENSE -This software is dual-licensed to the public domain and under the following -license: you are granted a perpetual, irrevocable license to copy, modify, -publish, and distribute this file as you see fit. + See end of file for license information. */ #ifndef INCLUDE_STB_IMAGE_WRITE_H #define INCLUDE_STB_IMAGE_WRITE_H +#include + +// if STB_IMAGE_WRITE_STATIC causes problems, try defining STBIWDEF to 'inline' or 'static inline' +#ifndef STBIWDEF +#ifdef STB_IMAGE_WRITE_STATIC +#define STBIWDEF static +#else #ifdef __cplusplus -extern "C" { +#define STBIWDEF extern "C" +#else +#define STBIWDEF extern +#endif +#endif #endif -#ifdef STB_IMAGE_WRITE_STATIC -#define STBIWDEF static -#else -#define STBIWDEF extern -extern int stbi_write_tga_with_rle; +#ifndef STB_IMAGE_WRITE_STATIC // C++ forbids static forward declarations +STBIWDEF int stbi_write_tga_with_rle; +STBIWDEF int stbi_write_png_compression_level; +STBIWDEF int stbi_write_force_png_filter; #endif #ifndef STBI_WRITE_NO_STDIO @@ -131,6 +177,11 @@ STBIWDEF int stbi_write_png(char const *filename, int w, int h, int comp, const STBIWDEF int stbi_write_bmp(char const *filename, int w, int h, int comp, const void *data); STBIWDEF int stbi_write_tga(char const *filename, int w, int h, int comp, const void *data); STBIWDEF int stbi_write_hdr(char const *filename, int w, int h, int comp, const float *data); +STBIWDEF int stbi_write_jpg(char const *filename, int x, int y, int comp, const void *data, int quality); + +#ifdef STBIW_WINDOWS_UTF8 +STBIWDEF int stbiw_convert_wchar_to_utf8(char *buffer, size_t bufferlen, const wchar_t* input); +#endif #endif typedef void stbi_write_func(void *context, void *data, int size); @@ -139,10 +190,9 @@ STBIWDEF int stbi_write_png_to_func(stbi_write_func *func, void *context, int w, STBIWDEF int stbi_write_bmp_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const void *data); STBIWDEF int stbi_write_tga_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const void *data); STBIWDEF int stbi_write_hdr_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const float *data); +STBIWDEF int stbi_write_jpg_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data, int quality); -#ifdef __cplusplus -} -#endif +STBIWDEF void stbi_flip_vertically_on_write(int flip_boolean); #endif//INCLUDE_STB_IMAGE_WRITE_H @@ -197,10 +247,29 @@ STBIWDEF int stbi_write_hdr_to_func(stbi_write_func *func, void *context, int w, #define STBIW_UCHAR(x) (unsigned char) ((x) & 0xff) +#ifdef STB_IMAGE_WRITE_STATIC +static int stbi_write_png_compression_level = 8; +static int stbi_write_tga_with_rle = 1; +static int stbi_write_force_png_filter = -1; +#else +int stbi_write_png_compression_level = 8; +int stbi_write_tga_with_rle = 1; +int stbi_write_force_png_filter = -1; +#endif + +static int stbi__flip_vertically_on_write = 0; + +STBIWDEF void stbi_flip_vertically_on_write(int flag) +{ + stbi__flip_vertically_on_write = flag; +} + typedef struct { stbi_write_func *func; void *context; + unsigned char buffer[64]; + int buf_used; } stbi__write_context; // initialize a callback-based context @@ -217,9 +286,52 @@ static void stbi__stdio_write(void *context, void *data, int size) fwrite(data,1,size,(FILE*) context); } +#if defined(_WIN32) && defined(STBIW_WINDOWS_UTF8) +#ifdef __cplusplus +#define STBIW_EXTERN extern "C" +#else +#define STBIW_EXTERN extern +#endif +STBIW_EXTERN __declspec(dllimport) int __stdcall MultiByteToWideChar(unsigned int cp, unsigned long flags, const char *str, int cbmb, wchar_t *widestr, int cchwide); +STBIW_EXTERN __declspec(dllimport) int __stdcall WideCharToMultiByte(unsigned int cp, unsigned long flags, const wchar_t *widestr, int cchwide, char *str, int cbmb, const char *defchar, int *used_default); + +STBIWDEF int stbiw_convert_wchar_to_utf8(char *buffer, size_t bufferlen, const wchar_t* input) +{ + return WideCharToMultiByte(65001 /* UTF8 */, 0, input, -1, buffer, (int) bufferlen, NULL, NULL); +} +#endif + +static FILE *stbiw__fopen(char const *filename, char const *mode) +{ + FILE *f; +#if defined(_WIN32) && defined(STBIW_WINDOWS_UTF8) + wchar_t wMode[64]; + wchar_t wFilename[1024]; + if (0 == MultiByteToWideChar(65001 /* UTF8 */, 0, filename, -1, wFilename, sizeof(wFilename)/sizeof(*wFilename))) + return 0; + + if (0 == MultiByteToWideChar(65001 /* UTF8 */, 0, mode, -1, wMode, sizeof(wMode)/sizeof(*wMode))) + return 0; + +#if defined(_MSC_VER) && _MSC_VER >= 1400 + if (0 != _wfopen_s(&f, wFilename, wMode)) + f = 0; +#else + f = _wfopen(wFilename, wMode); +#endif + +#elif defined(_MSC_VER) && _MSC_VER >= 1400 + if (0 != fopen_s(&f, filename, mode)) + f=0; +#else + f = fopen(filename, mode); +#endif + return f; +} + static int stbi__start_write_file(stbi__write_context *s, const char *filename) { - FILE *f = fopen(filename, "wb"); + FILE *f = stbiw__fopen(filename, "wb"); stbi__start_write_callbacks(s, stbi__stdio_write, (void *) f); return f != NULL; } @@ -234,12 +346,6 @@ static void stbi__end_write_file(stbi__write_context *s) typedef unsigned int stbiw_uint32; typedef int stb_image_write_test[sizeof(stbiw_uint32)==4 ? 1 : -1]; -#ifdef STB_IMAGE_WRITE_STATIC -static int stbi_write_tga_with_rle = 1; -#else -int stbi_write_tga_with_rle = 1; -#endif - static void stbiw__writefv(stbi__write_context *s, const char *fmt, va_list v) { while (*fmt) { @@ -277,11 +383,36 @@ static void stbiw__writef(stbi__write_context *s, const char *fmt, ...) va_end(v); } +static void stbiw__write_flush(stbi__write_context *s) +{ + if (s->buf_used) { + s->func(s->context, &s->buffer, s->buf_used); + s->buf_used = 0; + } +} + +static void stbiw__putc(stbi__write_context *s, unsigned char c) +{ + s->func(s->context, &c, 1); +} + +static void stbiw__write1(stbi__write_context *s, unsigned char a) +{ + if ((size_t)s->buf_used + 1 > sizeof(s->buffer)) + stbiw__write_flush(s); + s->buffer[s->buf_used++] = a; +} + static void stbiw__write3(stbi__write_context *s, unsigned char a, unsigned char b, unsigned char c) { - unsigned char arr[3]; - arr[0] = a, arr[1] = b, arr[2] = c; - s->func(s->context, arr, 3); + int n; + if ((size_t)s->buf_used + 3 > sizeof(s->buffer)) + stbiw__write_flush(s); + n = s->buf_used; + s->buf_used = n+3; + s->buffer[n+0] = a; + s->buffer[n+1] = b; + s->buffer[n+2] = c; } static void stbiw__write_pixel(stbi__write_context *s, int rgb_dir, int comp, int write_alpha, int expand_mono, unsigned char *d) @@ -290,17 +421,15 @@ static void stbiw__write_pixel(stbi__write_context *s, int rgb_dir, int comp, in int k; if (write_alpha < 0) - s->func(s->context, &d[comp - 1], 1); + stbiw__write1(s, d[comp - 1]); switch (comp) { + case 2: // 2 pixels = mono + alpha, alpha is written separately, so same as 1-channel case case 1: - s->func(s->context,d,1); - break; - case 2: if (expand_mono) stbiw__write3(s, d[0], d[0], d[0]); // monochrome bmp else - s->func(s->context, d, 1); // monochrome TGA + stbiw__write1(s, d[0]); // monochrome TGA break; case 4: if (!write_alpha) { @@ -316,7 +445,7 @@ static void stbiw__write_pixel(stbi__write_context *s, int rgb_dir, int comp, in break; } if (write_alpha > 0) - s->func(s->context, &d[comp - 1], 1); + stbiw__write1(s, d[comp - 1]); } static void stbiw__write_pixels(stbi__write_context *s, int rgb_dir, int vdir, int x, int y, int comp, void *data, int write_alpha, int scanline_pad, int expand_mono) @@ -327,16 +456,21 @@ static void stbiw__write_pixels(stbi__write_context *s, int rgb_dir, int vdir, i if (y <= 0) return; - if (vdir < 0) - j_end = -1, j = y-1; - else - j_end = y, j = 0; + if (stbi__flip_vertically_on_write) + vdir *= -1; + + if (vdir < 0) { + j_end = -1; j = y-1; + } else { + j_end = y; j = 0; + } for (; j != j_end; j += vdir) { for (i=0; i < x; ++i) { unsigned char *d = (unsigned char *) data + (j*x+i)*comp; stbiw__write_pixel(s, rgb_dir, comp, write_alpha, expand_mono, d); } + stbiw__write_flush(s); s->func(s->context, &zero, scanline_pad); } } @@ -357,16 +491,27 @@ static int stbiw__outfile(stbi__write_context *s, int rgb_dir, int vdir, int x, static int stbi_write_bmp_core(stbi__write_context *s, int x, int y, int comp, const void *data) { - int pad = (-x*3) & 3; - return stbiw__outfile(s,-1,-1,x,y,comp,1,(void *) data,0,pad, - "11 4 22 4" "4 44 22 444444", - 'B', 'M', 14+40+(x*3+pad)*y, 0,0, 14+40, // file header - 40, x,y, 1,24, 0,0,0,0,0,0); // bitmap header + if (comp != 4) { + // write RGB bitmap + int pad = (-x*3) & 3; + return stbiw__outfile(s,-1,-1,x,y,comp,1,(void *) data,0,pad, + "11 4 22 4" "4 44 22 444444", + 'B', 'M', 14+40+(x*3+pad)*y, 0,0, 14+40, // file header + 40, x,y, 1,24, 0,0,0,0,0,0); // bitmap header + } else { + // RGBA bitmaps need a v4 header + // use BI_BITFIELDS mode with 32bpp and alpha mask + // (straight BI_RGB with alpha mask doesn't work in most readers) + return stbiw__outfile(s,-1,-1,x,y,comp,1,(void *)data,1,0, + "11 4 22 4" "4 44 22 444444 4444 4 444 444 444 444", + 'B', 'M', 14+108+x*y*4, 0, 0, 14+108, // file header + 108, x,y, 1,32, 3,0,0,0,0,0, 0xff0000,0xff00,0xff,0xff000000u, 0, 0,0,0, 0,0,0, 0,0,0, 0,0,0); // bitmap V4 header + } } STBIWDEF int stbi_write_bmp_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data) { - stbi__write_context s; + stbi__write_context s = { 0 }; stbi__start_write_callbacks(&s, func, context); return stbi_write_bmp_core(&s, x, y, comp, data); } @@ -374,7 +519,7 @@ STBIWDEF int stbi_write_bmp_to_func(stbi_write_func *func, void *context, int x, #ifndef STBI_WRITE_NO_STDIO STBIWDEF int stbi_write_bmp(char const *filename, int x, int y, int comp, const void *data) { - stbi__write_context s; + stbi__write_context s = { 0 }; if (stbi__start_write_file(&s,filename)) { int r = stbi_write_bmp_core(&s, x, y, comp, data); stbi__end_write_file(&s); @@ -398,11 +543,21 @@ static int stbi_write_tga_core(stbi__write_context *s, int x, int y, int comp, v "111 221 2222 11", 0, 0, format, 0, 0, 0, 0, 0, x, y, (colorbytes + has_alpha) * 8, has_alpha * 8); } else { int i,j,k; + int jend, jdir; stbiw__writef(s, "111 221 2222 11", 0,0,format+8, 0,0,0, 0,0,x,y, (colorbytes + has_alpha) * 8, has_alpha * 8); - for (j = y - 1; j >= 0; --j) { - unsigned char *row = (unsigned char *) data + j * x * comp; + if (stbi__flip_vertically_on_write) { + j = 0; + jend = y; + jdir = 1; + } else { + j = y-1; + jend = -1; + jdir = -1; + } + for (; j != jend; j += jdir) { + unsigned char *row = (unsigned char *) data + j * x * comp; int len; for (i = 0; i < x; i += len) { @@ -437,32 +592,33 @@ static int stbi_write_tga_core(stbi__write_context *s, int x, int y, int comp, v if (diff) { unsigned char header = STBIW_UCHAR(len - 1); - s->func(s->context, &header, 1); + stbiw__write1(s, header); for (k = 0; k < len; ++k) { stbiw__write_pixel(s, -1, comp, has_alpha, 0, begin + k * comp); } } else { unsigned char header = STBIW_UCHAR(len - 129); - s->func(s->context, &header, 1); + stbiw__write1(s, header); stbiw__write_pixel(s, -1, comp, has_alpha, 0, begin); } } } + stbiw__write_flush(s); } return 1; } -int stbi_write_tga_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data) +STBIWDEF int stbi_write_tga_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data) { - stbi__write_context s; + stbi__write_context s = { 0 }; stbi__start_write_callbacks(&s, func, context); return stbi_write_tga_core(&s, x, y, comp, (void *) data); } #ifndef STBI_WRITE_NO_STDIO -int stbi_write_tga(char const *filename, int x, int y, int comp, const void *data) +STBIWDEF int stbi_write_tga(char const *filename, int x, int y, int comp, const void *data) { - stbi__write_context s; + stbi__write_context s = { 0 }; if (stbi__start_write_file(&s,filename)) { int r = stbi_write_tga_core(&s, x, y, comp, (void *) data); stbi__end_write_file(&s); @@ -475,11 +631,12 @@ int stbi_write_tga(char const *filename, int x, int y, int comp, const void *dat // ************************************************************************************************* // Radiance RGBE HDR writer // by Baldur Karlsson -#ifndef STBI_WRITE_NO_STDIO #define stbiw__max(a, b) ((a) > (b) ? (a) : (b)) -void stbiw__linear_to_rgbe(unsigned char *rgbe, float *linear) +#ifndef STBI_WRITE_NO_STDIO + +static void stbiw__linear_to_rgbe(unsigned char *rgbe, float *linear) { int exponent; float maxcomp = stbiw__max(linear[0], stbiw__max(linear[1], linear[2])); @@ -496,7 +653,7 @@ void stbiw__linear_to_rgbe(unsigned char *rgbe, float *linear) } } -void stbiw__write_run_data(stbi__write_context *s, int length, unsigned char databyte) +static void stbiw__write_run_data(stbi__write_context *s, int length, unsigned char databyte) { unsigned char lengthbyte = STBIW_UCHAR(length+128); STBIW_ASSERT(length+128 <= 255); @@ -504,7 +661,7 @@ void stbiw__write_run_data(stbi__write_context *s, int length, unsigned char dat s->func(s->context, &databyte, 1); } -void stbiw__write_dump_data(stbi__write_context *s, int length, unsigned char *data) +static void stbiw__write_dump_data(stbi__write_context *s, int length, unsigned char *data) { unsigned char lengthbyte = STBIW_UCHAR(length); STBIW_ASSERT(length <= 128); // inconsistent with spec but consistent with official code @@ -512,7 +669,7 @@ void stbiw__write_dump_data(stbi__write_context *s, int length, unsigned char *d s->func(s->context, data, length); } -void stbiw__write_hdr_scanline(stbi__write_context *s, int width, int ncomp, unsigned char *scratch, float *scanline) +static void stbiw__write_hdr_scanline(stbi__write_context *s, int width, int ncomp, unsigned char *scratch, float *scanline) { unsigned char scanlineheader[4] = { 2, 2, 0, 0 }; unsigned char rgbe[4]; @@ -613,26 +770,30 @@ static int stbi_write_hdr_core(stbi__write_context *s, int x, int y, int comp, f char header[] = "#?RADIANCE\n# Written by stb_image_write.h\nFORMAT=32-bit_rle_rgbe\n"; s->func(s->context, header, sizeof(header)-1); +#ifdef __STDC_LIB_EXT1__ + len = sprintf_s(buffer, sizeof(buffer), "EXPOSURE= 1.0000000000000\n\n-Y %d +X %d\n", y, x); +#else len = sprintf(buffer, "EXPOSURE= 1.0000000000000\n\n-Y %d +X %d\n", y, x); +#endif s->func(s->context, buffer, len); for(i=0; i < y; i++) - stbiw__write_hdr_scanline(s, x, comp, scratch, data + comp*i*x); + stbiw__write_hdr_scanline(s, x, comp, scratch, data + comp*x*(stbi__flip_vertically_on_write ? y-1-i : i)); STBIW_FREE(scratch); return 1; } } -int stbi_write_hdr_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const float *data) +STBIWDEF int stbi_write_hdr_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const float *data) { - stbi__write_context s; + stbi__write_context s = { 0 }; stbi__start_write_callbacks(&s, func, context); return stbi_write_hdr_core(&s, x, y, comp, (float *) data); } -int stbi_write_hdr(char const *filename, int x, int y, int comp, const float *data) +STBIWDEF int stbi_write_hdr(char const *filename, int x, int y, int comp, const float *data) { - stbi__write_context s; + stbi__write_context s = { 0 }; if (stbi__start_write_file(&s,filename)) { int r = stbi_write_hdr_core(&s, x, y, comp, (float *) data); stbi__end_write_file(&s); @@ -648,8 +809,9 @@ int stbi_write_hdr(char const *filename, int x, int y, int comp, const float *da // PNG writer // +#ifndef STBIW_ZLIB_COMPRESS // stretchy buffer; stbiw__sbpush() == vector<>::push_back() -- stbiw__sbcount() == vector<>::size() -#define stbiw__sbraw(a) ((int *) (a) - 2) +#define stbiw__sbraw(a) ((int *) (void *) (a) - 2) #define stbiw__sbm(a) stbiw__sbraw(a)[0] #define stbiw__sbn(a) stbiw__sbraw(a)[1] @@ -728,8 +890,14 @@ static unsigned int stbiw__zhash(unsigned char *data) #define stbiw__ZHASH 16384 -unsigned char * stbi_zlib_compress(unsigned char *data, int data_len, int *out_len, int quality) +#endif // STBIW_ZLIB_COMPRESS + +STBIWDEF unsigned char * stbi_zlib_compress(unsigned char *data, int data_len, int *out_len, int quality) { +#ifdef STBIW_ZLIB_COMPRESS + // user provided a zlib compress implementation, use that + return STBIW_ZLIB_COMPRESS(data, data_len, out_len, quality); +#else // use builtin static unsigned short lengthc[] = { 3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258, 259 }; static unsigned char lengtheb[]= { 0,0,0,0,0,0,0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0 }; static unsigned short distc[] = { 1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577, 32768 }; @@ -737,7 +905,9 @@ unsigned char * stbi_zlib_compress(unsigned char *data, int data_len, int *out_l unsigned int bitbuf=0; int i,j, bitcount=0; unsigned char *out = NULL; - unsigned char ***hash_table = (unsigned char***) STBIW_MALLOC(stbiw__ZHASH * sizeof(char**)); + unsigned char ***hash_table = (unsigned char***) STBIW_MALLOC(stbiw__ZHASH * sizeof(unsigned char**)); + if (hash_table == NULL) + return NULL; if (quality < 5) quality = 5; stbiw__sbpush(out, 0x78); // DEFLATE 32K window @@ -758,7 +928,7 @@ unsigned char * stbi_zlib_compress(unsigned char *data, int data_len, int *out_l for (j=0; j < n; ++j) { if (hlist[j]-data > i-32768) { // if entry lies within window int d = stbiw__zlib_countm(hlist[j], data+i, data_len-i); - if (d >= best) best=d,bestloc=hlist[j]; + if (d >= best) { best=d; bestloc=hlist[j]; } } } // when hash table entry is too long, delete half the entries @@ -811,14 +981,31 @@ unsigned char * stbi_zlib_compress(unsigned char *data, int data_len, int *out_l (void) stbiw__sbfree(hash_table[i]); STBIW_FREE(hash_table); + // store uncompressed instead if compression was worse + if (stbiw__sbn(out) > data_len + 2 + ((data_len+32766)/32767)*5) { + stbiw__sbn(out) = 2; // truncate to DEFLATE 32K window and FLEVEL = 1 + for (j = 0; j < data_len;) { + int blocklen = data_len - j; + if (blocklen > 32767) blocklen = 32767; + stbiw__sbpush(out, data_len - j == blocklen); // BFINAL = ?, BTYPE = 0 -- no compression + stbiw__sbpush(out, STBIW_UCHAR(blocklen)); // LEN + stbiw__sbpush(out, STBIW_UCHAR(blocklen >> 8)); + stbiw__sbpush(out, STBIW_UCHAR(~blocklen)); // NLEN + stbiw__sbpush(out, STBIW_UCHAR(~blocklen >> 8)); + memcpy(out+stbiw__sbn(out), data+j, blocklen); + stbiw__sbn(out) += blocklen; + j += blocklen; + } + } + { // compute adler32 on input unsigned int s1=1, s2=0; int blocklen = (int) (data_len % 5552); j=0; while (j < data_len) { - for (i=0; i < blocklen; ++i) s1 += data[j+i], s2 += s1; - s1 %= 65521, s2 %= 65521; + for (i=0; i < blocklen; ++i) { s1 += data[j+i]; s2 += s1; } + s1 %= 65521; s2 %= 65521; j += blocklen; blocklen = 5552; } @@ -831,10 +1018,14 @@ unsigned char * stbi_zlib_compress(unsigned char *data, int data_len, int *out_l // make returned pointer freeable STBIW_MEMMOVE(stbiw__sbraw(out), out, *out_len); return (unsigned char *) stbiw__sbraw(out); +#endif // STBIW_ZLIB_COMPRESS } static unsigned int stbiw__crc32(unsigned char *buffer, int len) { +#ifdef STBIW_CRC32 + return STBIW_CRC32(buffer, len); +#else static unsigned int crc_table[256] = { 0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3, @@ -876,6 +1067,7 @@ static unsigned int stbiw__crc32(unsigned char *buffer, int len) for (i=0; i < len; ++i) crc = (crc >> 8) ^ crc_table[buffer[i] ^ (crc & 0xff)]; return ~crc; +#endif } #define stbiw__wpng4(o,a,b,c,d) ((o)[0]=STBIW_UCHAR(a),(o)[1]=STBIW_UCHAR(b),(o)[2]=STBIW_UCHAR(c),(o)[3]=STBIW_UCHAR(d),(o)+=4) @@ -896,61 +1088,92 @@ static unsigned char stbiw__paeth(int a, int b, int c) return STBIW_UCHAR(c); } -unsigned char *stbi_write_png_to_mem(unsigned char *pixels, int stride_bytes, int x, int y, int n, int *out_len) +// @OPTIMIZE: provide an option that always forces left-predict or paeth predict +static void stbiw__encode_png_line(unsigned char *pixels, int stride_bytes, int width, int height, int y, int n, int filter_type, signed char *line_buffer) { + static int mapping[] = { 0,1,2,3,4 }; + static int firstmap[] = { 0,1,0,5,6 }; + int *mymap = (y != 0) ? mapping : firstmap; + int i; + int type = mymap[filter_type]; + unsigned char *z = pixels + stride_bytes * (stbi__flip_vertically_on_write ? height-1-y : y); + int signed_stride = stbi__flip_vertically_on_write ? -stride_bytes : stride_bytes; + + if (type==0) { + memcpy(line_buffer, z, width*n); + return; + } + + // first loop isn't optimized since it's just one pixel + for (i = 0; i < n; ++i) { + switch (type) { + case 1: line_buffer[i] = z[i]; break; + case 2: line_buffer[i] = z[i] - z[i-signed_stride]; break; + case 3: line_buffer[i] = z[i] - (z[i-signed_stride]>>1); break; + case 4: line_buffer[i] = (signed char) (z[i] - stbiw__paeth(0,z[i-signed_stride],0)); break; + case 5: line_buffer[i] = z[i]; break; + case 6: line_buffer[i] = z[i]; break; + } + } + switch (type) { + case 1: for (i=n; i < width*n; ++i) line_buffer[i] = z[i] - z[i-n]; break; + case 2: for (i=n; i < width*n; ++i) line_buffer[i] = z[i] - z[i-signed_stride]; break; + case 3: for (i=n; i < width*n; ++i) line_buffer[i] = z[i] - ((z[i-n] + z[i-signed_stride])>>1); break; + case 4: for (i=n; i < width*n; ++i) line_buffer[i] = z[i] - stbiw__paeth(z[i-n], z[i-signed_stride], z[i-signed_stride-n]); break; + case 5: for (i=n; i < width*n; ++i) line_buffer[i] = z[i] - (z[i-n]>>1); break; + case 6: for (i=n; i < width*n; ++i) line_buffer[i] = z[i] - stbiw__paeth(z[i-n], 0,0); break; + } +} + +STBIWDEF unsigned char *stbi_write_png_to_mem(const unsigned char *pixels, int stride_bytes, int x, int y, int n, int *out_len) +{ + int force_filter = stbi_write_force_png_filter; int ctype[5] = { -1, 0, 4, 2, 6 }; unsigned char sig[8] = { 137,80,78,71,13,10,26,10 }; unsigned char *out,*o, *filt, *zlib; signed char *line_buffer; - int i,j,k,p,zlen; + int j,zlen; if (stride_bytes == 0) stride_bytes = x * n; + if (force_filter >= 5) { + force_filter = -1; + } + filt = (unsigned char *) STBIW_MALLOC((x*n+1) * y); if (!filt) return 0; line_buffer = (signed char *) STBIW_MALLOC(x * n); if (!line_buffer) { STBIW_FREE(filt); return 0; } for (j=0; j < y; ++j) { - static int mapping[] = { 0,1,2,3,4 }; - static int firstmap[] = { 0,1,0,5,6 }; - int *mymap = j ? mapping : firstmap; - int best = 0, bestval = 0x7fffffff; - for (p=0; p < 2; ++p) { - for (k= p?best:0; k < 5; ++k) { - int type = mymap[k],est=0; - unsigned char *z = pixels + stride_bytes*j; - for (i=0; i < n; ++i) - switch (type) { - case 0: line_buffer[i] = z[i]; break; - case 1: line_buffer[i] = z[i]; break; - case 2: line_buffer[i] = z[i] - z[i-stride_bytes]; break; - case 3: line_buffer[i] = z[i] - (z[i-stride_bytes]>>1); break; - case 4: line_buffer[i] = (signed char) (z[i] - stbiw__paeth(0,z[i-stride_bytes],0)); break; - case 5: line_buffer[i] = z[i]; break; - case 6: line_buffer[i] = z[i]; break; - } - for (i=n; i < x*n; ++i) { - switch (type) { - case 0: line_buffer[i] = z[i]; break; - case 1: line_buffer[i] = z[i] - z[i-n]; break; - case 2: line_buffer[i] = z[i] - z[i-stride_bytes]; break; - case 3: line_buffer[i] = z[i] - ((z[i-n] + z[i-stride_bytes])>>1); break; - case 4: line_buffer[i] = z[i] - stbiw__paeth(z[i-n], z[i-stride_bytes], z[i-stride_bytes-n]); break; - case 5: line_buffer[i] = z[i] - (z[i-n]>>1); break; - case 6: line_buffer[i] = z[i] - stbiw__paeth(z[i-n], 0,0); break; - } - } - if (p) break; - for (i=0; i < x*n; ++i) + int filter_type; + if (force_filter > -1) { + filter_type = force_filter; + stbiw__encode_png_line((unsigned char*)(pixels), stride_bytes, x, y, j, n, force_filter, line_buffer); + } else { // Estimate the best filter by running through all of them: + int best_filter = 0, best_filter_val = 0x7fffffff, est, i; + for (filter_type = 0; filter_type < 5; filter_type++) { + stbiw__encode_png_line((unsigned char*)(pixels), stride_bytes, x, y, j, n, filter_type, line_buffer); + + // Estimate the entropy of the line using this filter; the less, the better. + est = 0; + for (i = 0; i < x*n; ++i) { est += abs((signed char) line_buffer[i]); - if (est < bestval) { bestval = est; best = k; } + } + if (est < best_filter_val) { + best_filter_val = est; + best_filter = filter_type; + } + } + if (filter_type != best_filter) { // If the last iteration already got us the best filter, don't redo it + stbiw__encode_png_line((unsigned char*)(pixels), stride_bytes, x, y, j, n, best_filter, line_buffer); + filter_type = best_filter; } } - // when we get here, best contains the filter type, and line_buffer contains the data - filt[j*(x*n+1)] = (unsigned char) best; + // when we get here, filter_type contains the filter type, and line_buffer contains the data + filt[j*(x*n+1)] = (unsigned char) filter_type; STBIW_MEMMOVE(filt+j*(x*n+1)+1, line_buffer, x*n); } STBIW_FREE(line_buffer); - zlib = stbi_zlib_compress(filt, y*( x*n+1), &zlen, 8); // increase 8 to get smaller but use more memory + zlib = stbi_zlib_compress(filt, y*( x*n+1), &zlen, stbi_write_png_compression_level); STBIW_FREE(filt); if (!zlib) return 0; @@ -993,9 +1216,10 @@ STBIWDEF int stbi_write_png(char const *filename, int x, int y, int comp, const { FILE *f; int len; - unsigned char *png = stbi_write_png_to_mem((unsigned char *) data, stride_bytes, x, y, comp, &len); + unsigned char *png = stbi_write_png_to_mem((const unsigned char *) data, stride_bytes, x, y, comp, &len); if (png == NULL) return 0; - f = fopen(filename, "wb"); + + f = stbiw__fopen(filename, "wb"); if (!f) { STBIW_FREE(png); return 0; } fwrite(png, 1, len, f); fclose(f); @@ -1007,16 +1231,426 @@ STBIWDEF int stbi_write_png(char const *filename, int x, int y, int comp, const STBIWDEF int stbi_write_png_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data, int stride_bytes) { int len; - unsigned char *png = stbi_write_png_to_mem((unsigned char *) data, stride_bytes, x, y, comp, &len); + unsigned char *png = stbi_write_png_to_mem((const unsigned char *) data, stride_bytes, x, y, comp, &len); if (png == NULL) return 0; func(context, png, len); STBIW_FREE(png); return 1; } + +/* *************************************************************************** + * + * JPEG writer + * + * This is based on Jon Olick's jo_jpeg.cpp: + * public domain Simple, Minimalistic JPEG writer - http://www.jonolick.com/code.html + */ + +static const unsigned char stbiw__jpg_ZigZag[] = { 0,1,5,6,14,15,27,28,2,4,7,13,16,26,29,42,3,8,12,17,25,30,41,43,9,11,18, + 24,31,40,44,53,10,19,23,32,39,45,52,54,20,22,33,38,46,51,55,60,21,34,37,47,50,56,59,61,35,36,48,49,57,58,62,63 }; + +static void stbiw__jpg_writeBits(stbi__write_context *s, int *bitBufP, int *bitCntP, const unsigned short *bs) { + int bitBuf = *bitBufP, bitCnt = *bitCntP; + bitCnt += bs[1]; + bitBuf |= bs[0] << (24 - bitCnt); + while(bitCnt >= 8) { + unsigned char c = (bitBuf >> 16) & 255; + stbiw__putc(s, c); + if(c == 255) { + stbiw__putc(s, 0); + } + bitBuf <<= 8; + bitCnt -= 8; + } + *bitBufP = bitBuf; + *bitCntP = bitCnt; +} + +static void stbiw__jpg_DCT(float *d0p, float *d1p, float *d2p, float *d3p, float *d4p, float *d5p, float *d6p, float *d7p) { + float d0 = *d0p, d1 = *d1p, d2 = *d2p, d3 = *d3p, d4 = *d4p, d5 = *d5p, d6 = *d6p, d7 = *d7p; + float z1, z2, z3, z4, z5, z11, z13; + + float tmp0 = d0 + d7; + float tmp7 = d0 - d7; + float tmp1 = d1 + d6; + float tmp6 = d1 - d6; + float tmp2 = d2 + d5; + float tmp5 = d2 - d5; + float tmp3 = d3 + d4; + float tmp4 = d3 - d4; + + // Even part + float tmp10 = tmp0 + tmp3; // phase 2 + float tmp13 = tmp0 - tmp3; + float tmp11 = tmp1 + tmp2; + float tmp12 = tmp1 - tmp2; + + d0 = tmp10 + tmp11; // phase 3 + d4 = tmp10 - tmp11; + + z1 = (tmp12 + tmp13) * 0.707106781f; // c4 + d2 = tmp13 + z1; // phase 5 + d6 = tmp13 - z1; + + // Odd part + tmp10 = tmp4 + tmp5; // phase 2 + tmp11 = tmp5 + tmp6; + tmp12 = tmp6 + tmp7; + + // The rotator is modified from fig 4-8 to avoid extra negations. + z5 = (tmp10 - tmp12) * 0.382683433f; // c6 + z2 = tmp10 * 0.541196100f + z5; // c2-c6 + z4 = tmp12 * 1.306562965f + z5; // c2+c6 + z3 = tmp11 * 0.707106781f; // c4 + + z11 = tmp7 + z3; // phase 5 + z13 = tmp7 - z3; + + *d5p = z13 + z2; // phase 6 + *d3p = z13 - z2; + *d1p = z11 + z4; + *d7p = z11 - z4; + + *d0p = d0; *d2p = d2; *d4p = d4; *d6p = d6; +} + +static void stbiw__jpg_calcBits(int val, unsigned short bits[2]) { + int tmp1 = val < 0 ? -val : val; + val = val < 0 ? val-1 : val; + bits[1] = 1; + while(tmp1 >>= 1) { + ++bits[1]; + } + bits[0] = val & ((1<0)&&(DU[end0pos]==0); --end0pos) { + } + // end0pos = first element in reverse order !=0 + if(end0pos == 0) { + stbiw__jpg_writeBits(s, bitBuf, bitCnt, EOB); + return DU[0]; + } + for(i = 1; i <= end0pos; ++i) { + int startpos = i; + int nrzeroes; + unsigned short bits[2]; + for (; DU[i]==0 && i<=end0pos; ++i) { + } + nrzeroes = i-startpos; + if ( nrzeroes >= 16 ) { + int lng = nrzeroes>>4; + int nrmarker; + for (nrmarker=1; nrmarker <= lng; ++nrmarker) + stbiw__jpg_writeBits(s, bitBuf, bitCnt, M16zeroes); + nrzeroes &= 15; + } + stbiw__jpg_calcBits(DU[i], bits); + stbiw__jpg_writeBits(s, bitBuf, bitCnt, HTAC[(nrzeroes<<4)+bits[1]]); + stbiw__jpg_writeBits(s, bitBuf, bitCnt, bits); + } + if(end0pos != 63) { + stbiw__jpg_writeBits(s, bitBuf, bitCnt, EOB); + } + return DU[0]; +} + +static int stbi_write_jpg_core(stbi__write_context *s, int width, int height, int comp, const void* data, int quality) { + // Constants that don't pollute global namespace + static const unsigned char std_dc_luminance_nrcodes[] = {0,0,1,5,1,1,1,1,1,1,0,0,0,0,0,0,0}; + static const unsigned char std_dc_luminance_values[] = {0,1,2,3,4,5,6,7,8,9,10,11}; + static const unsigned char std_ac_luminance_nrcodes[] = {0,0,2,1,3,3,2,4,3,5,5,4,4,0,0,1,0x7d}; + static const unsigned char std_ac_luminance_values[] = { + 0x01,0x02,0x03,0x00,0x04,0x11,0x05,0x12,0x21,0x31,0x41,0x06,0x13,0x51,0x61,0x07,0x22,0x71,0x14,0x32,0x81,0x91,0xa1,0x08, + 0x23,0x42,0xb1,0xc1,0x15,0x52,0xd1,0xf0,0x24,0x33,0x62,0x72,0x82,0x09,0x0a,0x16,0x17,0x18,0x19,0x1a,0x25,0x26,0x27,0x28, + 0x29,0x2a,0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x53,0x54,0x55,0x56,0x57,0x58,0x59, + 0x5a,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x83,0x84,0x85,0x86,0x87,0x88,0x89, + 0x8a,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9a,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa9,0xaa,0xb2,0xb3,0xb4,0xb5,0xb6, + 0xb7,0xb8,0xb9,0xba,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xd2,0xd3,0xd4,0xd5,0xd6,0xd7,0xd8,0xd9,0xda,0xe1,0xe2, + 0xe3,0xe4,0xe5,0xe6,0xe7,0xe8,0xe9,0xea,0xf1,0xf2,0xf3,0xf4,0xf5,0xf6,0xf7,0xf8,0xf9,0xfa + }; + static const unsigned char std_dc_chrominance_nrcodes[] = {0,0,3,1,1,1,1,1,1,1,1,1,0,0,0,0,0}; + static const unsigned char std_dc_chrominance_values[] = {0,1,2,3,4,5,6,7,8,9,10,11}; + static const unsigned char std_ac_chrominance_nrcodes[] = {0,0,2,1,2,4,4,3,4,7,5,4,4,0,1,2,0x77}; + static const unsigned char std_ac_chrominance_values[] = { + 0x00,0x01,0x02,0x03,0x11,0x04,0x05,0x21,0x31,0x06,0x12,0x41,0x51,0x07,0x61,0x71,0x13,0x22,0x32,0x81,0x08,0x14,0x42,0x91, + 0xa1,0xb1,0xc1,0x09,0x23,0x33,0x52,0xf0,0x15,0x62,0x72,0xd1,0x0a,0x16,0x24,0x34,0xe1,0x25,0xf1,0x17,0x18,0x19,0x1a,0x26, + 0x27,0x28,0x29,0x2a,0x35,0x36,0x37,0x38,0x39,0x3a,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x53,0x54,0x55,0x56,0x57,0x58, + 0x59,0x5a,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x82,0x83,0x84,0x85,0x86,0x87, + 0x88,0x89,0x8a,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9a,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa9,0xaa,0xb2,0xb3,0xb4, + 0xb5,0xb6,0xb7,0xb8,0xb9,0xba,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xd2,0xd3,0xd4,0xd5,0xd6,0xd7,0xd8,0xd9,0xda, + 0xe2,0xe3,0xe4,0xe5,0xe6,0xe7,0xe8,0xe9,0xea,0xf2,0xf3,0xf4,0xf5,0xf6,0xf7,0xf8,0xf9,0xfa + }; + // Huffman tables + static const unsigned short YDC_HT[256][2] = { {0,2},{2,3},{3,3},{4,3},{5,3},{6,3},{14,4},{30,5},{62,6},{126,7},{254,8},{510,9}}; + static const unsigned short UVDC_HT[256][2] = { {0,2},{1,2},{2,2},{6,3},{14,4},{30,5},{62,6},{126,7},{254,8},{510,9},{1022,10},{2046,11}}; + static const unsigned short YAC_HT[256][2] = { + {10,4},{0,2},{1,2},{4,3},{11,4},{26,5},{120,7},{248,8},{1014,10},{65410,16},{65411,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {12,4},{27,5},{121,7},{502,9},{2038,11},{65412,16},{65413,16},{65414,16},{65415,16},{65416,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {28,5},{249,8},{1015,10},{4084,12},{65417,16},{65418,16},{65419,16},{65420,16},{65421,16},{65422,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {58,6},{503,9},{4085,12},{65423,16},{65424,16},{65425,16},{65426,16},{65427,16},{65428,16},{65429,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {59,6},{1016,10},{65430,16},{65431,16},{65432,16},{65433,16},{65434,16},{65435,16},{65436,16},{65437,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {122,7},{2039,11},{65438,16},{65439,16},{65440,16},{65441,16},{65442,16},{65443,16},{65444,16},{65445,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {123,7},{4086,12},{65446,16},{65447,16},{65448,16},{65449,16},{65450,16},{65451,16},{65452,16},{65453,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {250,8},{4087,12},{65454,16},{65455,16},{65456,16},{65457,16},{65458,16},{65459,16},{65460,16},{65461,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {504,9},{32704,15},{65462,16},{65463,16},{65464,16},{65465,16},{65466,16},{65467,16},{65468,16},{65469,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {505,9},{65470,16},{65471,16},{65472,16},{65473,16},{65474,16},{65475,16},{65476,16},{65477,16},{65478,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {506,9},{65479,16},{65480,16},{65481,16},{65482,16},{65483,16},{65484,16},{65485,16},{65486,16},{65487,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {1017,10},{65488,16},{65489,16},{65490,16},{65491,16},{65492,16},{65493,16},{65494,16},{65495,16},{65496,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {1018,10},{65497,16},{65498,16},{65499,16},{65500,16},{65501,16},{65502,16},{65503,16},{65504,16},{65505,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {2040,11},{65506,16},{65507,16},{65508,16},{65509,16},{65510,16},{65511,16},{65512,16},{65513,16},{65514,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {65515,16},{65516,16},{65517,16},{65518,16},{65519,16},{65520,16},{65521,16},{65522,16},{65523,16},{65524,16},{0,0},{0,0},{0,0},{0,0},{0,0}, + {2041,11},{65525,16},{65526,16},{65527,16},{65528,16},{65529,16},{65530,16},{65531,16},{65532,16},{65533,16},{65534,16},{0,0},{0,0},{0,0},{0,0},{0,0} + }; + static const unsigned short UVAC_HT[256][2] = { + {0,2},{1,2},{4,3},{10,4},{24,5},{25,5},{56,6},{120,7},{500,9},{1014,10},{4084,12},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {11,4},{57,6},{246,8},{501,9},{2038,11},{4085,12},{65416,16},{65417,16},{65418,16},{65419,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {26,5},{247,8},{1015,10},{4086,12},{32706,15},{65420,16},{65421,16},{65422,16},{65423,16},{65424,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {27,5},{248,8},{1016,10},{4087,12},{65425,16},{65426,16},{65427,16},{65428,16},{65429,16},{65430,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {58,6},{502,9},{65431,16},{65432,16},{65433,16},{65434,16},{65435,16},{65436,16},{65437,16},{65438,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {59,6},{1017,10},{65439,16},{65440,16},{65441,16},{65442,16},{65443,16},{65444,16},{65445,16},{65446,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {121,7},{2039,11},{65447,16},{65448,16},{65449,16},{65450,16},{65451,16},{65452,16},{65453,16},{65454,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {122,7},{2040,11},{65455,16},{65456,16},{65457,16},{65458,16},{65459,16},{65460,16},{65461,16},{65462,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {249,8},{65463,16},{65464,16},{65465,16},{65466,16},{65467,16},{65468,16},{65469,16},{65470,16},{65471,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {503,9},{65472,16},{65473,16},{65474,16},{65475,16},{65476,16},{65477,16},{65478,16},{65479,16},{65480,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {504,9},{65481,16},{65482,16},{65483,16},{65484,16},{65485,16},{65486,16},{65487,16},{65488,16},{65489,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {505,9},{65490,16},{65491,16},{65492,16},{65493,16},{65494,16},{65495,16},{65496,16},{65497,16},{65498,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {506,9},{65499,16},{65500,16},{65501,16},{65502,16},{65503,16},{65504,16},{65505,16},{65506,16},{65507,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {2041,11},{65508,16},{65509,16},{65510,16},{65511,16},{65512,16},{65513,16},{65514,16},{65515,16},{65516,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {16352,14},{65517,16},{65518,16},{65519,16},{65520,16},{65521,16},{65522,16},{65523,16},{65524,16},{65525,16},{0,0},{0,0},{0,0},{0,0},{0,0}, + {1018,10},{32707,15},{65526,16},{65527,16},{65528,16},{65529,16},{65530,16},{65531,16},{65532,16},{65533,16},{65534,16},{0,0},{0,0},{0,0},{0,0},{0,0} + }; + static const int YQT[] = {16,11,10,16,24,40,51,61,12,12,14,19,26,58,60,55,14,13,16,24,40,57,69,56,14,17,22,29,51,87,80,62,18,22, + 37,56,68,109,103,77,24,35,55,64,81,104,113,92,49,64,78,87,103,121,120,101,72,92,95,98,112,100,103,99}; + static const int UVQT[] = {17,18,24,47,99,99,99,99,18,21,26,66,99,99,99,99,24,26,56,99,99,99,99,99,47,66,99,99,99,99,99,99, + 99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99}; + static const float aasf[] = { 1.0f * 2.828427125f, 1.387039845f * 2.828427125f, 1.306562965f * 2.828427125f, 1.175875602f * 2.828427125f, + 1.0f * 2.828427125f, 0.785694958f * 2.828427125f, 0.541196100f * 2.828427125f, 0.275899379f * 2.828427125f }; + + int row, col, i, k, subsample; + float fdtbl_Y[64], fdtbl_UV[64]; + unsigned char YTable[64], UVTable[64]; + + if(!data || !width || !height || comp > 4 || comp < 1) { + return 0; + } + + quality = quality ? quality : 90; + subsample = quality <= 90 ? 1 : 0; + quality = quality < 1 ? 1 : quality > 100 ? 100 : quality; + quality = quality < 50 ? 5000 / quality : 200 - quality * 2; + + for(i = 0; i < 64; ++i) { + int uvti, yti = (YQT[i]*quality+50)/100; + YTable[stbiw__jpg_ZigZag[i]] = (unsigned char) (yti < 1 ? 1 : yti > 255 ? 255 : yti); + uvti = (UVQT[i]*quality+50)/100; + UVTable[stbiw__jpg_ZigZag[i]] = (unsigned char) (uvti < 1 ? 1 : uvti > 255 ? 255 : uvti); + } + + for(row = 0, k = 0; row < 8; ++row) { + for(col = 0; col < 8; ++col, ++k) { + fdtbl_Y[k] = 1 / (YTable [stbiw__jpg_ZigZag[k]] * aasf[row] * aasf[col]); + fdtbl_UV[k] = 1 / (UVTable[stbiw__jpg_ZigZag[k]] * aasf[row] * aasf[col]); + } + } + + // Write Headers + { + static const unsigned char head0[] = { 0xFF,0xD8,0xFF,0xE0,0,0x10,'J','F','I','F',0,1,1,0,0,1,0,1,0,0,0xFF,0xDB,0,0x84,0 }; + static const unsigned char head2[] = { 0xFF,0xDA,0,0xC,3,1,0,2,0x11,3,0x11,0,0x3F,0 }; + const unsigned char head1[] = { 0xFF,0xC0,0,0x11,8,(unsigned char)(height>>8),STBIW_UCHAR(height),(unsigned char)(width>>8),STBIW_UCHAR(width), + 3,1,(unsigned char)(subsample?0x22:0x11),0,2,0x11,1,3,0x11,1,0xFF,0xC4,0x01,0xA2,0 }; + s->func(s->context, (void*)head0, sizeof(head0)); + s->func(s->context, (void*)YTable, sizeof(YTable)); + stbiw__putc(s, 1); + s->func(s->context, UVTable, sizeof(UVTable)); + s->func(s->context, (void*)head1, sizeof(head1)); + s->func(s->context, (void*)(std_dc_luminance_nrcodes+1), sizeof(std_dc_luminance_nrcodes)-1); + s->func(s->context, (void*)std_dc_luminance_values, sizeof(std_dc_luminance_values)); + stbiw__putc(s, 0x10); // HTYACinfo + s->func(s->context, (void*)(std_ac_luminance_nrcodes+1), sizeof(std_ac_luminance_nrcodes)-1); + s->func(s->context, (void*)std_ac_luminance_values, sizeof(std_ac_luminance_values)); + stbiw__putc(s, 1); // HTUDCinfo + s->func(s->context, (void*)(std_dc_chrominance_nrcodes+1), sizeof(std_dc_chrominance_nrcodes)-1); + s->func(s->context, (void*)std_dc_chrominance_values, sizeof(std_dc_chrominance_values)); + stbiw__putc(s, 0x11); // HTUACinfo + s->func(s->context, (void*)(std_ac_chrominance_nrcodes+1), sizeof(std_ac_chrominance_nrcodes)-1); + s->func(s->context, (void*)std_ac_chrominance_values, sizeof(std_ac_chrominance_values)); + s->func(s->context, (void*)head2, sizeof(head2)); + } + + // Encode 8x8 macroblocks + { + static const unsigned short fillBits[] = {0x7F, 7}; + int DCY=0, DCU=0, DCV=0; + int bitBuf=0, bitCnt=0; + // comp == 2 is grey+alpha (alpha is ignored) + int ofsG = comp > 2 ? 1 : 0, ofsB = comp > 2 ? 2 : 0; + const unsigned char *dataR = (const unsigned char *)data; + const unsigned char *dataG = dataR + ofsG; + const unsigned char *dataB = dataR + ofsB; + int x, y, pos; + if(subsample) { + for(y = 0; y < height; y += 16) { + for(x = 0; x < width; x += 16) { + float Y[256], U[256], V[256]; + for(row = y, pos = 0; row < y+16; ++row) { + // row >= height => use last input row + int clamped_row = (row < height) ? row : height - 1; + int base_p = (stbi__flip_vertically_on_write ? (height-1-clamped_row) : clamped_row)*width*comp; + for(col = x; col < x+16; ++col, ++pos) { + // if col >= width => use pixel from last input column + int p = base_p + ((col < width) ? col : (width-1))*comp; + float r = dataR[p], g = dataG[p], b = dataB[p]; + Y[pos]= +0.29900f*r + 0.58700f*g + 0.11400f*b - 128; + U[pos]= -0.16874f*r - 0.33126f*g + 0.50000f*b; + V[pos]= +0.50000f*r - 0.41869f*g - 0.08131f*b; + } + } + DCY = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, Y+0, 16, fdtbl_Y, DCY, YDC_HT, YAC_HT); + DCY = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, Y+8, 16, fdtbl_Y, DCY, YDC_HT, YAC_HT); + DCY = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, Y+128, 16, fdtbl_Y, DCY, YDC_HT, YAC_HT); + DCY = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, Y+136, 16, fdtbl_Y, DCY, YDC_HT, YAC_HT); + + // subsample U,V + { + float subU[64], subV[64]; + int yy, xx; + for(yy = 0, pos = 0; yy < 8; ++yy) { + for(xx = 0; xx < 8; ++xx, ++pos) { + int j = yy*32+xx*2; + subU[pos] = (U[j+0] + U[j+1] + U[j+16] + U[j+17]) * 0.25f; + subV[pos] = (V[j+0] + V[j+1] + V[j+16] + V[j+17]) * 0.25f; + } + } + DCU = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, subU, 8, fdtbl_UV, DCU, UVDC_HT, UVAC_HT); + DCV = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, subV, 8, fdtbl_UV, DCV, UVDC_HT, UVAC_HT); + } + } + } + } else { + for(y = 0; y < height; y += 8) { + for(x = 0; x < width; x += 8) { + float Y[64], U[64], V[64]; + for(row = y, pos = 0; row < y+8; ++row) { + // row >= height => use last input row + int clamped_row = (row < height) ? row : height - 1; + int base_p = (stbi__flip_vertically_on_write ? (height-1-clamped_row) : clamped_row)*width*comp; + for(col = x; col < x+8; ++col, ++pos) { + // if col >= width => use pixel from last input column + int p = base_p + ((col < width) ? col : (width-1))*comp; + float r = dataR[p], g = dataG[p], b = dataB[p]; + Y[pos]= +0.29900f*r + 0.58700f*g + 0.11400f*b - 128; + U[pos]= -0.16874f*r - 0.33126f*g + 0.50000f*b; + V[pos]= +0.50000f*r - 0.41869f*g - 0.08131f*b; + } + } + + DCY = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, Y, 8, fdtbl_Y, DCY, YDC_HT, YAC_HT); + DCU = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, U, 8, fdtbl_UV, DCU, UVDC_HT, UVAC_HT); + DCV = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, V, 8, fdtbl_UV, DCV, UVDC_HT, UVAC_HT); + } + } + } + + // Do the bit alignment of the EOI marker + stbiw__jpg_writeBits(s, &bitBuf, &bitCnt, fillBits); + } + + // EOI + stbiw__putc(s, 0xFF); + stbiw__putc(s, 0xD9); + + return 1; +} + +STBIWDEF int stbi_write_jpg_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data, int quality) +{ + stbi__write_context s = { 0 }; + stbi__start_write_callbacks(&s, func, context); + return stbi_write_jpg_core(&s, x, y, comp, (void *) data, quality); +} + + +#ifndef STBI_WRITE_NO_STDIO +STBIWDEF int stbi_write_jpg(char const *filename, int x, int y, int comp, const void *data, int quality) +{ + stbi__write_context s = { 0 }; + if (stbi__start_write_file(&s,filename)) { + int r = stbi_write_jpg_core(&s, x, y, comp, data, quality); + stbi__end_write_file(&s); + return r; + } else + return 0; +} +#endif + #endif // STB_IMAGE_WRITE_IMPLEMENTATION /* Revision history + 1.16 (2021-07-11) + make Deflate code emit uncompressed blocks when it would otherwise expand + support writing BMPs with alpha channel + 1.15 (2020-07-13) unknown + 1.14 (2020-02-02) updated JPEG writer to downsample chroma channels + 1.13 + 1.12 + 1.11 (2019-08-11) + + 1.10 (2019-02-07) + support utf8 filenames in Windows; fix warnings and platform ifdefs + 1.09 (2018-02-11) + fix typo in zlib quality API, improve STB_I_W_STATIC in C++ + 1.08 (2018-01-29) + add stbi__flip_vertically_on_write, external zlib, zlib quality, choose PNG filter + 1.07 (2017-07-24) + doc fix + 1.06 (2017-07-23) + writing JPEG (using Jon Olick's code) + 1.05 ??? + 1.04 (2017-03-03) + monochrome BMP expansion + 1.03 ??? 1.02 (2016-04-02) avoid allocating large structures on the stack 1.01 (2016-01-16) @@ -1035,7 +1669,7 @@ STBIWDEF int stbi_write_png_to_func(stbi_write_func *func, void *context, int x, add HDR output fix monochrome BMP 0.95 (2014-08-17) - add monochrome TGA output + add monochrome TGA output 0.94 (2014-05-31) rename private functions to avoid conflicts with stb_image.h 0.93 (2014-05-27) @@ -1046,3 +1680,45 @@ STBIWDEF int stbi_write_png_to_func(stbi_write_func *func, void *context, int x, first public release 0.90 first internal release */ + +/* +------------------------------------------------------------------------------ +This software is available under 2 licenses -- choose whichever you prefer. +------------------------------------------------------------------------------ +ALTERNATIVE A - MIT License +Copyright (c) 2017 Sean Barrett +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +------------------------------------------------------------------------------ +ALTERNATIVE B - Public Domain (www.unlicense.org) +This is free and unencumbered software released into the public domain. +Anyone is free to copy, modify, publish, use, compile, sell, or distribute this +software, either in source code form or as a compiled binary, for any purpose, +commercial or non-commercial, and by any means. +In jurisdictions that recognize copyright laws, the author or authors of this +software dedicate any and all copyright interest in the software to the public +domain. We make this dedication for the benefit of the public at large and to +the detriment of our heirs and successors. We intend this dedication to be an +overt act of relinquishment in perpetuity of all present and future rights to +this software under copyright law. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +------------------------------------------------------------------------------ +*/ From 06089a91a644b1f1c44465c95ff6cc002792556b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 18 Apr 2022 23:10:04 +0200 Subject: [PATCH 195/208] Document delayed initialization of EGL display --- include/GLFW/glfw3native.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/GLFW/glfw3native.h b/include/GLFW/glfw3native.h index 11fee09d..7f5bf9e4 100644 --- a/include/GLFW/glfw3native.h +++ b/include/GLFW/glfw3native.h @@ -486,6 +486,9 @@ GLFWAPI struct wl_surface* glfwGetWaylandWindow(GLFWwindow* window); * * @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. * From f60547ac80602955fe0af1ab05fd3f6ed5941e6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 18 Apr 2022 23:21:40 +0200 Subject: [PATCH 196/208] X11: Fix returned clipboard string freed too early The clipboard string should not be freed on SelectionClear. The user may have received it from glfwGetClipboardString and it should remain valid until the next call to a public clipboard string function. --- src/x11_window.c | 25 +------------------------ 1 file changed, 1 insertion(+), 24 deletions(-) diff --git a/src/x11_window.c b/src/x11_window.c index e021dfd7..b77162b5 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -865,20 +865,6 @@ static Atom writeTargetToProperty(const XSelectionRequestEvent* request) return None; } -static void handleSelectionClear(XEvent* event) -{ - if (event->xselectionclear.selection == _glfw.x11.PRIMARY) - { - _glfw_free(_glfw.x11.primarySelectionString); - _glfw.x11.primarySelectionString = NULL; - } - else - { - _glfw_free(_glfw.x11.clipboardString); - _glfw.x11.clipboardString = NULL; - } -} - static void handleSelectionRequest(XEvent* event) { const XSelectionRequestEvent* request = &event->xselectionrequest; @@ -1171,12 +1157,7 @@ static void processEvent(XEvent *event) return; } - if (event->type == SelectionClear) - { - handleSelectionClear(event); - return; - } - else if (event->type == SelectionRequest) + if (event->type == SelectionRequest) { handleSelectionRequest(event); return; @@ -1853,10 +1834,6 @@ void _glfwPushSelectionToManagerX11(void) handleSelectionRequest(&event); break; - case SelectionClear: - handleSelectionClear(&event); - break; - case SelectionNotify: { if (event.xselection.target == _glfw.x11.SAVE_TARGETS) From 23e6e8e4b7ffe8f7604bd4f6ad1b183d0927bfe2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 18 Apr 2022 23:22:25 +0200 Subject: [PATCH 197/208] X11: Fix segfault on malformed INCR response The code assumed that at least some data would be received via the INCR mechanism and that, as a result, the string buffer would be allocated. Bug found by Clang static analysis. --- README.md | 1 + src/x11_window.c | 13 ++++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 3b57f9b5..67d57a2f 100644 --- a/README.md +++ b/README.md @@ -290,6 +290,7 @@ information on what to include when reporting a bug. - [X11] Bugfix: Dynamic loading on NetBSD failed due to soname differences - [X11] Bugfix: Left shift of int constant relied on undefined behavior (#1951) - [X11] Bugfix: The OSMesa libray was not unloaded on termination + - [X11] Bugfix: A malformed response during selection transfer could cause a segfault - [Wayland] Added dynamic loading of all Wayland libraries - [Wayland] Added support for key names via xkbcommon - [Wayland] Added support for file path drop events (#2040) diff --git a/src/x11_window.c b/src/x11_window.c index b77162b5..85b844a1 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -985,13 +985,16 @@ static const char* getSelectionString(Atom selection) if (!itemCount) { - if (targets[i] == XA_STRING) + if (string) { - *selectionString = convertLatin1toUTF8(string); - _glfw_free(string); + if (targets[i] == XA_STRING) + { + *selectionString = convertLatin1toUTF8(string); + _glfw_free(string); + } + else + *selectionString = string; } - else - *selectionString = string; break; } From d3c2121221f7bcd9cce2e164acfbdee8820aec06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 18 Apr 2022 23:35:08 +0200 Subject: [PATCH 198/208] Move CODEOWNERS to .github directory This slightly de-clutters a directory mostly intended for human-readable documentation. --- {docs => .github}/CODEOWNERS | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {docs => .github}/CODEOWNERS (100%) diff --git a/docs/CODEOWNERS b/.github/CODEOWNERS similarity index 100% rename from docs/CODEOWNERS rename to .github/CODEOWNERS From 80e31ce9e1e75f51f9cf0af61c9163474675439a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 6 Apr 2022 19:02:52 +0200 Subject: [PATCH 199/208] Win32: Remove superfluous cast --- src/win32_window.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/win32_window.c b/src/win32_window.c index 5f4dd7d2..14f2fe5b 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -1428,7 +1428,7 @@ GLFWbool _glfwRegisterWindowClassWin32(void) ZeroMemory(&wc, sizeof(wc)); wc.cbSize = sizeof(wc); wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; - wc.lpfnWndProc = (WNDPROC) windowProc; + wc.lpfnWndProc = windowProc; wc.hInstance = _glfw.win32.instance; wc.hCursor = LoadCursorW(NULL, IDC_ARROW); wc.lpszClassName = _GLFW_WNDCLASSNAME; From acf0c10e7aa946b8f1555c78d812528e22e39dc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 6 Apr 2022 23:21:28 +0200 Subject: [PATCH 200/208] Win32: Fix message reported by VS 2022 --- src/win32_joystick.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/win32_joystick.c b/src/win32_joystick.c index a6fe8e8d..7eb9b203 100644 --- a/src/win32_joystick.c +++ b/src/win32_joystick.c @@ -607,7 +607,7 @@ int _glfwPollJoystickWin32(_GLFWjoystick* js, int mode) { int i, ai = 0, bi = 0, pi = 0; HRESULT result; - DIJOYSTATE state; + DIJOYSTATE state = {0}; IDirectInputDevice8_Poll(js->win32.device); result = IDirectInputDevice8_GetDeviceState(js->win32.device, From 8f050b56559910641895b5cc4f5d374879dd249d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 8 Apr 2022 17:09:04 +0200 Subject: [PATCH 201/208] Wayland: Add support for older wayland-scanner Versions of wayland-scanner prior to 1.17.91 named every global array of wl_interface pointers 'types', making it impossible to combine several unmodified private-code files into a single compilation unit. This overrides that name with a macro for each file, allowing them to coexist. Fixes #2016 Closes #2032 --- src/wl_init.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/wl_init.c b/src/wl_init.c index c4e47e99..c232ce79 100644 --- a/src/wl_init.c +++ b/src/wl_init.c @@ -47,13 +47,38 @@ #include "wayland-pointer-constraints-unstable-v1-client-protocol.h" #include "wayland-idle-inhibit-unstable-v1-client-protocol.h" +// NOTE: Versions of wayland-scanner prior to 1.17.91 named every global array of +// wl_interface pointers 'types', making it impossible to combine several unmodified +// private-code files into a single compilation unit +// HACK: We override this name with a macro for each file, allowing them to coexist + +#define types _glfw_wayland_types #include "wayland-client-protocol-code.h" +#undef types + +#define types _glfw_xdg_shell_types #include "wayland-xdg-shell-client-protocol-code.h" +#undef types + +#define types _glfw_xdg_decoration_types #include "wayland-xdg-decoration-client-protocol-code.h" +#undef types + +#define types _glfw_viewporter_types #include "wayland-viewporter-client-protocol-code.h" +#undef types + +#define types _glfw_relative_pointer_types #include "wayland-relative-pointer-unstable-v1-client-protocol-code.h" +#undef types + +#define types _glfw_pointer_constraints_types #include "wayland-pointer-constraints-unstable-v1-client-protocol-code.h" +#undef types + +#define types _glfw_idle_inhibit_types #include "wayland-idle-inhibit-unstable-v1-client-protocol-code.h" +#undef types static void wmBaseHandlePing(void* userData, struct xdg_wm_base* wmBase, From 72642ea0d1f3ad75f503bd90b9ba740a274e0422 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 9 Nov 2021 19:41:34 +0100 Subject: [PATCH 202/208] Simplify struct stitching for sync primitives There will not currently be more than one set of threading or timer APIs selected regardless of how many window systems are enabled, so there is no need for this extra complexity. --- src/platform.h | 58 ++++++++++++++++++-------------------------------- 1 file changed, 21 insertions(+), 37 deletions(-) diff --git a/src/platform.h b/src/platform.h index cc842eb8..0c593676 100644 --- a/src/platform.h +++ b/src/platform.h @@ -92,30 +92,6 @@ #define GLFW_LINUX_LIBRARY_JOYSTICK_STATE #endif -#if defined(_WIN32) - #include "win32_thread.h" - #define GLFW_POSIX_TLS_STATE - #define GLFW_POSIX_MUTEX_STATE -#else - #include "posix_thread.h" - #define GLFW_WIN32_TLS_STATE - #define GLFW_WIN32_MUTEX_STATE -#endif - -#if defined(_WIN32) - #include "win32_time.h" - #define GLFW_POSIX_LIBRARY_TIMER_STATE - #define GLFW_COCOA_LIBRARY_TIMER_STATE -#elif defined(__APPLE__) - #include "cocoa_time.h" - #define GLFW_WIN32_LIBRARY_TIMER_STATE - #define GLFW_POSIX_LIBRARY_TIMER_STATE -#else - #include "posix_time.h" - #define GLFW_WIN32_LIBRARY_TIMER_STATE - #define GLFW_COCOA_LIBRARY_TIMER_STATE -#endif - #define GLFW_PLATFORM_WINDOW_STATE \ GLFW_WIN32_WINDOW_STATE \ GLFW_COCOA_WINDOW_STATE \ @@ -142,14 +118,6 @@ GLFW_COCOA_JOYSTICK_STATE \ GLFW_LINUX_JOYSTICK_STATE -#define GLFW_PLATFORM_TLS_STATE \ - GLFW_WIN32_TLS_STATE \ - GLFW_POSIX_TLS_STATE \ - -#define GLFW_PLATFORM_MUTEX_STATE \ - GLFW_WIN32_MUTEX_STATE \ - GLFW_POSIX_MUTEX_STATE \ - #define GLFW_PLATFORM_LIBRARY_WINDOW_STATE \ GLFW_WIN32_LIBRARY_WINDOW_STATE \ GLFW_COCOA_LIBRARY_WINDOW_STATE \ @@ -162,11 +130,6 @@ GLFW_COCOA_LIBRARY_JOYSTICK_STATE \ GLFW_LINUX_LIBRARY_JOYSTICK_STATE -#define GLFW_PLATFORM_LIBRARY_TIMER_STATE \ - GLFW_WIN32_LIBRARY_TIMER_STATE \ - GLFW_COCOA_LIBRARY_TIMER_STATE \ - GLFW_POSIX_LIBRARY_TIMER_STATE \ - #define GLFW_PLATFORM_CONTEXT_STATE \ GLFW_WGL_CONTEXT_STATE \ GLFW_NSGL_CONTEXT_STATE \ @@ -177,3 +140,24 @@ GLFW_NSGL_LIBRARY_CONTEXT_STATE \ GLFW_GLX_LIBRARY_CONTEXT_STATE +#if defined(_WIN32) + #include "win32_thread.h" + #define GLFW_PLATFORM_TLS_STATE GLFW_WIN32_TLS_STATE + #define GLFW_PLATFORM_MUTEX_STATE GLFW_WIN32_MUTEX_STATE +#else + #include "posix_thread.h" + #define GLFW_PLATFORM_TLS_STATE GLFW_POSIX_TLS_STATE + #define GLFW_PLATFORM_MUTEX_STATE GLFW_POSIX_MUTEX_STATE +#endif + +#if defined(_WIN32) + #include "win32_time.h" + #define GLFW_PLATFORM_LIBRARY_TIMER_STATE GLFW_WIN32_LIBRARY_TIMER_STATE +#elif defined(__APPLE__) + #include "cocoa_time.h" + #define GLFW_PLATFORM_LIBRARY_TIMER_STATE GLFW_COCOA_LIBRARY_TIMER_STATE +#else + #include "posix_time.h" + #define GLFW_PLATFORM_LIBRARY_TIMER_STATE GLFW_POSIX_LIBRARY_TIMER_STATE +#endif + From 09653b8c5490ebb605933537e897587c9129f159 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 6 Apr 2022 21:13:48 +0200 Subject: [PATCH 203/208] Move last bits of window setup to platform code This avoids glfwCreateWindow emitting GLFW_FEATURE_UNAVAILABLE or GLFW_FEATURE_UNIMPLEMENTED on Wayland because shared code was calling unimplemented or unavailable platform functions during final setup. It also makes it consistent with the final setup of full screen windows. --- README.md | 1 + src/cocoa_window.m | 18 ++++++++++++++++++ src/null_window.c | 18 ++++++++++++++++++ src/win32_window.c | 18 ++++++++++++++++++ src/window.c | 28 ---------------------------- src/wl_window.c | 6 ++++++ src/x11_window.c | 18 ++++++++++++++++++ 7 files changed, 79 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index 67d57a2f..72cbef36 100644 --- a/README.md +++ b/README.md @@ -325,6 +325,7 @@ information on what to include when reporting a bug. - [Wayland] Bugfix: Drag and drop data was misinterpreted as clipboard string - [Wayland] Bugfix: MIME type matching was not performed for clipboard string - [Wayland] Bugfix: The OSMesa library was not unloaded on termination + - [Wayland] Bugfix: `glfwCreateWindow` could emit `GLFW_FEATURE_UNAVAILABLE` - [POSIX] Removed use of deprecated function `gettimeofday` - [POSIX] Bugfix: `CLOCK_MONOTONIC` was not correctly tested for or enabled - [WGL] Disabled the DWM swap interval hack for Windows 8 and later (#1072) diff --git a/src/cocoa_window.m b/src/cocoa_window.m index e461b267..444bd563 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -931,13 +931,31 @@ int _glfwCreateWindowCocoa(_GLFWwindow* window, if (!_glfwCreateContextOSMesa(window, ctxconfig, fbconfig)) return GLFW_FALSE; } + + if (!_glfwRefreshContextAttribs(window, ctxconfig)) + return GLFW_FALSE; } + if (wndconfig->mousePassthrough) + _glfwSetWindowMousePassthroughCocoa(window, GLFW_TRUE); + if (window->monitor) { _glfwShowWindowCocoa(window); _glfwFocusWindowCocoa(window); acquireMonitor(window); + + if (wndconfig->centerCursor) + _glfwCenterCursorInContentArea(window); + } + else + { + if (wndconfig->visible) + { + _glfwShowWindowCocoa(window); + if (wndconfig->focused) + _glfwFocusWindowCocoa(window); + } } return GLFW_TRUE; diff --git a/src/null_window.c b/src/null_window.c index 7e87b9da..b40110b8 100644 --- a/src/null_window.c +++ b/src/null_window.c @@ -128,13 +128,31 @@ int _glfwCreateWindowNull(_GLFWwindow* window, if (!_glfwCreateContextEGL(window, ctxconfig, fbconfig)) return GLFW_FALSE; } + + if (!_glfwRefreshContextAttribs(window, ctxconfig)) + return GLFW_FALSE; } + if (wndconfig->mousePassthrough) + _glfwSetWindowMousePassthroughNull(window, GLFW_TRUE); + if (window->monitor) { _glfwShowWindowNull(window); _glfwFocusWindowNull(window); acquireMonitor(window); + + if (wndconfig->centerCursor) + _glfwCenterCursorInContentArea(window); + } + else + { + if (wndconfig->visible) + { + _glfwShowWindowNull(window); + if (wndconfig->focused) + _glfwFocusWindowNull(window); + } } return GLFW_TRUE; diff --git a/src/win32_window.c b/src/win32_window.c index 14f2fe5b..87c2b4a1 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -1493,14 +1493,32 @@ int _glfwCreateWindowWin32(_GLFWwindow* window, if (!_glfwCreateContextOSMesa(window, ctxconfig, fbconfig)) return GLFW_FALSE; } + + if (!_glfwRefreshContextAttribs(window, ctxconfig)) + return GLFW_FALSE; } + if (wndconfig->mousePassthrough) + _glfwSetWindowMousePassthroughWin32(window, GLFW_TRUE); + if (window->monitor) { _glfwShowWindowWin32(window); _glfwFocusWindowWin32(window); acquireMonitor(window); fitToMonitor(window); + + if (wndconfig->centerCursor) + _glfwCenterCursorInContentArea(window); + } + else + { + if (wndconfig->visible) + { + _glfwShowWindowWin32(window); + if (wndconfig->focused) + _glfwFocusWindowWin32(window); + } } return GLFW_TRUE; diff --git a/src/window.c b/src/window.c index a24feb60..621e2e64 100644 --- a/src/window.c +++ b/src/window.c @@ -215,40 +215,12 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height, window->numer = GLFW_DONT_CARE; window->denom = GLFW_DONT_CARE; - // Open the actual window and create its context if (!_glfw.platform.createWindow(window, &wndconfig, &ctxconfig, &fbconfig)) { glfwDestroyWindow((GLFWwindow*) window); return NULL; } - if (ctxconfig.client != GLFW_NO_API) - { - if (!_glfwRefreshContextAttribs(window, &ctxconfig)) - { - glfwDestroyWindow((GLFWwindow*) window); - return NULL; - } - } - - if (wndconfig.mousePassthrough) - _glfw.platform.setWindowMousePassthrough(window, GLFW_TRUE); - - if (window->monitor) - { - if (wndconfig.centerCursor) - _glfwCenterCursorInContentArea(window); - } - else - { - if (wndconfig.visible) - { - _glfw.platform.showWindow(window); - if (wndconfig.focused) - _glfw.platform.focusWindow(window); - } - } - return (GLFWwindow*) window; } diff --git a/src/wl_window.c b/src/wl_window.c index 047b9eb6..a1f93185 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -1730,8 +1730,14 @@ int _glfwCreateWindowWayland(_GLFWwindow* window, if (!_glfwCreateContextOSMesa(window, ctxconfig, fbconfig)) return GLFW_FALSE; } + + if (!_glfwRefreshContextAttribs(window, ctxconfig)) + return GLFW_FALSE; } + if (wndconfig->mousePassthrough) + _glfwSetWindowMousePassthroughWayland(window, GLFW_TRUE); + return GLFW_TRUE; } diff --git a/src/x11_window.c b/src/x11_window.c index 85b844a1..280dc986 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -1952,13 +1952,31 @@ int _glfwCreateWindowX11(_GLFWwindow* window, if (!_glfwCreateContextOSMesa(window, ctxconfig, fbconfig)) return GLFW_FALSE; } + + if (!_glfwRefreshContextAttribs(window, ctxconfig)) + return GLFW_FALSE; } + if (wndconfig->mousePassthrough) + _glfwSetWindowMousePassthroughX11(window, GLFW_TRUE); + if (window->monitor) { _glfwShowWindowX11(window); updateWindowMode(window); acquireMonitor(window); + + if (wndconfig->centerCursor) + _glfwCenterCursorInContentArea(window); + } + else + { + if (wndconfig->visible) + { + _glfwShowWindowX11(window); + if (wndconfig->focused) + _glfwFocusWindowX11(window); + } } XFlush(_glfw.x11.display); From 685de9089f13dab9e284d00aaca24e68947f5bed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 21 Apr 2022 17:35:50 +0200 Subject: [PATCH 204/208] Fix and clarify comments for GLFWAPI --- include/GLFW/glfw3.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index 3f320065..6f189274 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -262,13 +262,12 @@ extern "C" { /* We are building GLFW as a Win32 DLL */ #define GLFWAPI __declspec(dllexport) #elif defined(_WIN32) && defined(GLFW_DLL) - /* We are calling GLFW as a Win32 DLL */ + /* We are calling a GLFW Win32 DLL */ #define GLFWAPI __declspec(dllimport) #elif defined(__GNUC__) && defined(_GLFW_BUILD_DLL) - /* We are building GLFW as a shared / dynamic library */ + /* We are building GLFW as a Unix shared library */ #define GLFWAPI __attribute__((visibility("default"))) #else - /* We are building or calling GLFW as a static library */ #define GLFWAPI #endif From 7dfd84c458dfa12b351c932b8281b13faf7b50b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 21 Apr 2022 21:22:24 +0200 Subject: [PATCH 205/208] Win32: Make monitor area retrieval more consistent The rest of this file uses GetMonitorInfoW to retrieve this information. --- src/win32_window.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/win32_window.c b/src/win32_window.c index 87c2b4a1..333cef1b 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -1284,15 +1284,16 @@ static int createNativeWindow(_GLFWwindow* window, if (window->monitor) { - GLFWvidmode mode; + MONITORINFO mi = { sizeof(mi) }; + GetMonitorInfoW(window->monitor->win32.handle, &mi); // NOTE: This window placement is temporary and approximate, as the // correct position and size cannot be known until the monitor // video mode has been picked in _glfwSetVideoModeWin32 - _glfwGetMonitorPosWin32(window->monitor, &xpos, &ypos); - _glfwGetVideoModeWin32(window->monitor, &mode); - fullWidth = mode.width; - fullHeight = mode.height; + xpos = mi.rcMonitor.left; + ypos = mi.rcMonitor.top; + fullWidth = mi.rcMonitor.right - mi.rcMonitor.left; + fullHeight = mi.rcMonitor.bottom - mi.rcMonitor.top; } else { From 5c3ebfb9ccba331433620d3ed44a1fe1d9bf879e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 3 May 2022 19:50:28 +0200 Subject: [PATCH 206/208] Remove OSMesa specific code from offscreen example The OSMesa specific path is more appropriate for a test than an example. --- examples/CMakeLists.txt | 5 ----- examples/offscreen.c | 13 ------------- 2 files changed, 18 deletions(-) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index be8927db..e7a03797 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -50,11 +50,6 @@ set_target_properties(${GUI_ONLY_BINARIES} ${CONSOLE_BINARIES} PROPERTIES C_STANDARD 99 FOLDER "GLFW3/Examples") -if (GLFW_USE_OSMESA) - find_package(OSMesa REQUIRED) - target_compile_definitions(offscreen PRIVATE USE_NATIVE_OSMESA) -endif() - if (MSVC) # Tell MSVC to use main instead of WinMain set_target_properties(${GUI_ONLY_BINARIES} PROPERTIES diff --git a/examples/offscreen.c b/examples/offscreen.c index b7cd2fd7..e2852860 100644 --- a/examples/offscreen.c +++ b/examples/offscreen.c @@ -28,11 +28,6 @@ #define GLFW_INCLUDE_NONE #include -#if USE_NATIVE_OSMESA - #define GLFW_EXPOSE_NATIVE_OSMESA - #include -#endif - #include "linmath.h" #include @@ -151,12 +146,8 @@ int main(void) glDrawArrays(GL_TRIANGLES, 0, 3); glFinish(); -#if USE_NATIVE_OSMESA - glfwGetOSMesaColorBuffer(window, &width, &height, NULL, (void**) &buffer); -#else buffer = calloc(4, width * height); glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, buffer); -#endif // Write image Y-flipped because OpenGL stbi_write_png("offscreen.png", @@ -164,11 +155,7 @@ int main(void) buffer + (width * 4 * (height - 1)), -width * 4); -#if USE_NATIVE_OSMESA - // Here is where there's nothing -#else free(buffer); -#endif glfwDestroyWindow(window); From ce85c7dcaf48be96870f2d8fec1d78b0b7d744c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 3 May 2022 19:54:08 +0200 Subject: [PATCH 207/208] Fix GLAPIENTRY not being defined for native access This is a follow-up to 535c3ce63240ee91f998219b35dc82abef545c3d. That commit made glfw3native.h undefine GLAPIENTRY whenever GLFW_EXPOSE_NATIVE_GLX or GLFW_EXPOSE_NATIVE_OSMESA was defined, on the assumption that it was glfw3.h that had defined GLAPIENTRY. If gl.h or an extension loader header has been included before glfw3.h, then it has defined inclusion guards preventing GLAPIENTRY from being defined later when the GLX or OSMesa header includes gl.h. This commit ensures GLAPIENTRY is only undefined if glfw3.h defined it. Related to #2010 --- include/GLFW/glfw3.h | 1 + include/GLFW/glfw3native.h | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index 6f189274..52225c74 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -6383,6 +6383,7 @@ GLFWAPI VkResult glfwCreateWindowSurface(VkInstance instance, GLFWwindow* window */ #ifndef GLAPIENTRY #define GLAPIENTRY APIENTRY + #define GLFW_GLAPIENTRY_DEFINED #endif /* -------------------- END SYSTEM/COMPILER SPECIFIC --------------------- */ diff --git a/include/GLFW/glfw3native.h b/include/GLFW/glfw3native.h index 7f5bf9e4..6d090778 100644 --- a/include/GLFW/glfw3native.h +++ b/include/GLFW/glfw3native.h @@ -116,7 +116,10 @@ extern "C" { * default it also acts as an OpenGL header * However, glx.h will include gl.h, which will define it unconditionally */ - #undef GLAPIENTRY + #if defined(GLFW_GLAPIENTRY_DEFINED) + #undef GLAPIENTRY + #undef GLFW_GLAPIENTRY_DEFINED + #endif #include #endif #if defined(GLFW_EXPOSE_NATIVE_EGL) @@ -127,7 +130,10 @@ extern "C" { * default it also acts as an OpenGL header * However, osmesa.h will include gl.h, which will define it unconditionally */ - #undef GLAPIENTRY + #if defined(GLFW_GLAPIENTRY_DEFINED) + #undef GLAPIENTRY + #undef GLFW_GLAPIENTRY_DEFINED + #endif #include #endif From 62e175ef9fae75335575964c845a302447c012c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 5 May 2022 21:47:34 +0200 Subject: [PATCH 208/208] Win32: Add comment clarifying use of ToUnicode Fixes #2100 --- src/win32_init.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/win32_init.c b/src/win32_init.c index 9465c951..1cdc5b98 100644 --- a/src/win32_init.c +++ b/src/win32_init.c @@ -502,6 +502,8 @@ void _glfwUpdateKeyNamesWin32(void) if (length == -1) { + // This is a dead key, so we need a second simulated key press + // to make it output its own character (usually a diacritic) length = ToUnicode(vk, scancode, state, chars, sizeof(chars) / sizeof(WCHAR), 0);