Compare commits

..

1 Commits

Author SHA1 Message Date
Camilla Löwy 761d7e7c4e Add keyboard layout support
This adds a keyboard layout switch callback and a query for the
human-readable name of the current layout.

Fixes #1201.
2020-05-18 21:15:38 +02:00
68 changed files with 2765 additions and 5078 deletions
+4 -1
View File
@@ -52,6 +52,10 @@ src/glfw_config.h
src/glfw3.pc src/glfw3.pc
src/glfw3Config.cmake src/glfw3Config.cmake
src/glfw3ConfigVersion.cmake src/glfw3ConfigVersion.cmake
src/wayland-pointer-constraints-unstable-v1-client-protocol.h
src/wayland-pointer-constraints-unstable-v1-protocol.c
src/wayland-relative-pointer-unstable-v1-client-protocol.h
src/wayland-relative-pointer-unstable-v1-protocol.c
# Compiled binaries # Compiled binaries
src/libglfw.so src/libglfw.so
@@ -96,6 +100,5 @@ tests/threads
tests/timeout tests/timeout
tests/title tests/title
tests/triangle-vulkan tests/triangle-vulkan
tests/window
tests/windows tests/windows
+21 -29
View File
@@ -9,6 +9,7 @@ matrix:
include: include:
- os: linux - os: linux
dist: xenial dist: xenial
sudo: false
name: "X11 shared library" name: "X11 shared library"
addons: addons:
apt: apt:
@@ -17,12 +18,12 @@ matrix:
- libxinerama-dev - libxinerama-dev
- libxcursor-dev - libxcursor-dev
- libxi-dev - libxi-dev
- libxext-dev
env: env:
- BUILD_SHARED_LIBS=ON - BUILD_SHARED_LIBS=ON
- CFLAGS=-Werror - CFLAGS=-Werror
- os: linux - os: linux
dist: xenial dist: xenial
sudo: false
name: "X11 static library" name: "X11 static library"
addons: addons:
apt: apt:
@@ -31,17 +32,19 @@ matrix:
- libxinerama-dev - libxinerama-dev
- libxcursor-dev - libxcursor-dev
- libxi-dev - libxi-dev
- libxext-dev
env: env:
- BUILD_SHARED_LIBS=OFF - BUILD_SHARED_LIBS=OFF
- CFLAGS=-Werror - CFLAGS=-Werror
- os: linux - os: linux
dist: focal dist: xenial
sudo: required
name: "Wayland shared library" name: "Wayland shared library"
addons: addons:
apt: apt:
sources:
- ppa:kubuntu-ppa/backports
packages: packages:
- wayland-protocols - extra-cmake-modules
- libwayland-dev - libwayland-dev
- libxkbcommon-dev - libxkbcommon-dev
- libegl1-mesa-dev - libegl1-mesa-dev
@@ -50,12 +53,15 @@ matrix:
- BUILD_SHARED_LIBS=ON - BUILD_SHARED_LIBS=ON
- CFLAGS=-Werror - CFLAGS=-Werror
- os: linux - os: linux
dist: focal dist: xenial
sudo: required
name: "Wayland static library" name: "Wayland static library"
addons: addons:
apt: apt:
sources:
- ppa:kubuntu-ppa/backports
packages: packages:
- wayland-protocols - extra-cmake-modules
- libwayland-dev - libwayland-dev
- libxkbcommon-dev - libxkbcommon-dev
- libegl1-mesa-dev - libegl1-mesa-dev
@@ -63,35 +69,15 @@ matrix:
- USE_WAYLAND=ON - USE_WAYLAND=ON
- BUILD_SHARED_LIBS=OFF - BUILD_SHARED_LIBS=OFF
- CFLAGS=-Werror - CFLAGS=-Werror
- os: linux
dist: bionic
name: "Null shared library"
addons:
apt:
packages:
- libosmesa6-dev
env:
- BUILD_SHARED_LIBS=ON
- USE_OSMESA=ON
- CFLAGS=-Werror
- os: linux
dist: bionic
name: "Null static library"
addons:
apt:
packages:
- libosmesa6-dev
env:
- BUILD_SHARED_LIBS=OFF
- USE_OSMESA=ON
- CFLAGS=-Werror
- os: osx - os: osx
sudo: false
name: "Cocoa shared library" name: "Cocoa shared library"
env: env:
- BUILD_SHARED_LIBS=ON - BUILD_SHARED_LIBS=ON
- CFLAGS=-Werror - CFLAGS=-Werror
- MACOSX_DEPLOYMENT_TARGET=10.8 - MACOSX_DEPLOYMENT_TARGET=10.8
- os: osx - os: osx
sudo: false
name: "Cocoa static library" name: "Cocoa static library"
env: env:
- BUILD_SHARED_LIBS=OFF - BUILD_SHARED_LIBS=OFF
@@ -104,7 +90,13 @@ script:
fi fi
- mkdir build - mkdir build
- cd build - cd build
- cmake -DCMAKE_VERBOSE_MAKEFILE=ON -DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS} -DGLFW_USE_WAYLAND=${USE_WAYLAND} -DGLFW_USE_OSMESA=${USE_OSMESA} .. - if test -n "${USE_WAYLAND}"; then
git clone git://anongit.freedesktop.org/wayland/wayland-protocols;
pushd wayland-protocols;
git checkout 1.15 && ./autogen.sh --prefix=/usr && make && sudo make install;
popd;
fi
- cmake -DCMAKE_VERBOSE_MAKEFILE=ON -DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS} -DGLFW_USE_WAYLAND=${USE_WAYLAND} ..
- cmake --build . - cmake --build .
notifications: notifications:
email: email:
+26
View File
@@ -0,0 +1,26 @@
find_package(PkgConfig)
pkg_check_modules(WaylandProtocols QUIET wayland-protocols>=${WaylandProtocols_FIND_VERSION})
execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE} --variable=pkgdatadir wayland-protocols
OUTPUT_VARIABLE WaylandProtocols_PKGDATADIR
RESULT_VARIABLE _pkgconfig_failed)
if (_pkgconfig_failed)
message(FATAL_ERROR "Missing wayland-protocols pkgdatadir")
endif()
string(REGEX REPLACE "[\r\n]" "" WaylandProtocols_PKGDATADIR "${WaylandProtocols_PKGDATADIR}")
find_package_handle_standard_args(WaylandProtocols
FOUND_VAR
WaylandProtocols_FOUND
REQUIRED_VARS
WaylandProtocols_PKGDATADIR
VERSION_VAR
WaylandProtocols_VERSION
HANDLE_COMPONENTS
)
set(WAYLAND_PROTOCOLS_FOUND ${WaylandProtocols_FOUND})
set(WAYLAND_PROTOCOLS_PKGDATADIR ${WaylandProtocols_PKGDATADIR})
set(WAYLAND_PROTOCOLS_VERSION ${WaylandProtocols_VERSION})
+34
View File
@@ -0,0 +1,34 @@
# - Try to find XKBCommon
# Once done, this will define
#
# XKBCOMMON_FOUND - System has XKBCommon
# XKBCOMMON_INCLUDE_DIRS - The XKBCommon include directories
# XKBCOMMON_LIBRARIES - The libraries needed to use XKBCommon
# XKBCOMMON_DEFINITIONS - Compiler switches required for using XKBCommon
find_package(PkgConfig)
pkg_check_modules(PC_XKBCOMMON QUIET xkbcommon)
set(XKBCOMMON_DEFINITIONS ${PC_XKBCOMMON_CFLAGS_OTHER})
find_path(XKBCOMMON_INCLUDE_DIR
NAMES xkbcommon/xkbcommon.h
HINTS ${PC_XKBCOMMON_INCLUDE_DIR} ${PC_XKBCOMMON_INCLUDE_DIRS}
)
find_library(XKBCOMMON_LIBRARY
NAMES xkbcommon
HINTS ${PC_XKBCOMMON_LIBRARY} ${PC_XKBCOMMON_LIBRARY_DIRS}
)
set(XKBCOMMON_LIBRARIES ${XKBCOMMON_LIBRARY})
set(XKBCOMMON_LIBRARY_DIRS ${XKBCOMMON_LIBRARY_DIRS})
set(XKBCOMMON_INCLUDE_DIRS ${XKBCOMMON_INCLUDE_DIR})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(XKBCommon DEFAULT_MSG
XKBCOMMON_LIBRARY
XKBCOMMON_INCLUDE_DIR
)
mark_as_advanced(XKBCOMMON_LIBRARY XKBCOMMON_INCLUDE_DIR)
+63 -17
View File
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.1...3.17 FATAL_ERROR) cmake_minimum_required(VERSION 3.1)
project(GLFW VERSION 3.4.0 LANGUAGES C) project(GLFW VERSION 3.4.0 LANGUAGES C)
@@ -8,10 +8,6 @@ if (POLICY CMP0054)
cmake_policy(SET CMP0054 NEW) cmake_policy(SET CMP0054 NEW)
endif() endif()
if (POLICY CMP0069)
cmake_policy(SET CMP0069 NEW)
endif()
if (POLICY CMP0077) if (POLICY CMP0077)
cmake_policy(SET CMP0077 NEW) cmake_policy(SET CMP0077 NEW)
endif() endif()
@@ -70,6 +66,17 @@ endif()
# Set compiler specific flags # Set compiler specific flags
#-------------------------------------------------------------------- #--------------------------------------------------------------------
if (MSVC) if (MSVC)
if (MSVC90)
# Workaround for VS 2008 not shipping with the DirectX 9 SDK
include(CheckIncludeFile)
check_include_file(dinput.h DINPUT_H_FOUND)
if (NOT DINPUT_H_FOUND)
message(FATAL_ERROR "DirectX 9 headers not found; install DirectX 9 SDK")
endif()
# Workaround for VS 2008 not shipping with stdint.h
list(APPEND glfw_INCLUDE_DIRS "${GLFW_SOURCE_DIR}/deps/vs2008")
endif()
if (NOT USE_MSVC_RUNTIME_LIBRARY_DLL) if (NOT USE_MSVC_RUNTIME_LIBRARY_DLL)
foreach (flag CMAKE_C_FLAGS foreach (flag CMAKE_C_FLAGS
CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_DEBUG
@@ -88,6 +95,41 @@ if (MSVC)
endif() endif()
endif() endif()
if (MINGW)
# Workaround for legacy MinGW not providing XInput and DirectInput
include(CheckIncludeFile)
check_include_file(dinput.h DINPUT_H_FOUND)
check_include_file(xinput.h XINPUT_H_FOUND)
if (NOT DINPUT_H_FOUND OR NOT XINPUT_H_FOUND)
list(APPEND glfw_INCLUDE_DIRS "${GLFW_SOURCE_DIR}/deps/mingw")
endif()
# Enable link-time exploit mitigation features enabled by default on MSVC
include(CheckCCompilerFlag)
# Compatibility with data execution prevention (DEP)
set(CMAKE_REQUIRED_FLAGS "-Wl,--nxcompat")
check_c_compiler_flag("" _GLFW_HAS_DEP)
if (_GLFW_HAS_DEP)
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--nxcompat ${CMAKE_SHARED_LINKER_FLAGS}")
endif()
# Compatibility with address space layout randomization (ASLR)
set(CMAKE_REQUIRED_FLAGS "-Wl,--dynamicbase")
check_c_compiler_flag("" _GLFW_HAS_ASLR)
if (_GLFW_HAS_ASLR)
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--dynamicbase ${CMAKE_SHARED_LINKER_FLAGS}")
endif()
# Compatibility with 64-bit address space layout randomization (ASLR)
set(CMAKE_REQUIRED_FLAGS "-Wl,--high-entropy-va")
check_c_compiler_flag("" _GLFW_HAS_64ASLR)
if (_GLFW_HAS_64ASLR)
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--high-entropy-va ${CMAKE_SHARED_LINKER_FLAGS}")
endif()
endif()
#-------------------------------------------------------------------- #--------------------------------------------------------------------
# Detect and select backend APIs # Detect and select backend APIs
#-------------------------------------------------------------------- #--------------------------------------------------------------------
@@ -180,29 +222,26 @@ if (_GLFW_X11)
if (NOT X11_Xi_INCLUDE_PATH) if (NOT X11_Xi_INCLUDE_PATH)
message(FATAL_ERROR "XInput headers not found; install libxi development package") message(FATAL_ERROR "XInput headers not found; install libxi development package")
endif() 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() endif()
#-------------------------------------------------------------------- #--------------------------------------------------------------------
# Use Wayland for window creation # Use Wayland for window creation
#-------------------------------------------------------------------- #--------------------------------------------------------------------
if (_GLFW_WAYLAND) if (_GLFW_WAYLAND)
find_package(ECM REQUIRED NO_MODULE)
list(APPEND CMAKE_MODULE_PATH "${ECM_MODULE_PATH}")
include(FindPkgConfig) find_package(Wayland REQUIRED Client Cursor Egl)
pkg_check_modules(Wayland REQUIRED find_package(WaylandScanner REQUIRED)
wayland-client>=0.2.7 find_package(WaylandProtocols 1.15 REQUIRED)
wayland-cursor>=0.2.7
wayland-egl>=0.2.7
xkbcommon)
list(APPEND glfw_PKG_DEPS "wayland-client") list(APPEND glfw_PKG_DEPS "wayland-client")
list(APPEND glfw_INCLUDE_DIRS "${Wayland_INCLUDE_DIRS}") list(APPEND glfw_INCLUDE_DIRS "${Wayland_INCLUDE_DIRS}")
list(APPEND glfw_LIBRARIES "${Wayland_LINK_LIBRARIES}") list(APPEND glfw_LIBRARIES "${Wayland_LIBRARIES}")
find_package(XKBCommon REQUIRED)
list(APPEND glfw_INCLUDE_DIRS "${XKBCOMMON_INCLUDE_DIRS}")
include(CheckIncludeFiles) include(CheckIncludeFiles)
include(CheckFunctionExists) include(CheckFunctionExists)
@@ -218,6 +257,13 @@ if (_GLFW_WAYLAND)
endif() endif()
endif() endif()
#--------------------------------------------------------------------
# Use OSMesa for offscreen context creation
#--------------------------------------------------------------------
if (_GLFW_OSMESA)
find_package(OSMesa REQUIRED)
endif()
#-------------------------------------------------------------------- #--------------------------------------------------------------------
# Use Cocoa for window creation and NSOpenGL for context creation # Use Cocoa for window creation and NSOpenGL for context creation
#-------------------------------------------------------------------- #--------------------------------------------------------------------
+7 -38
View File
@@ -88,6 +88,9 @@ in the documentation for more information.
GLFW itself needs only CMake 3.1 or later and the headers and libraries for your GLFW itself needs only CMake 3.1 or later and the headers and libraries for your
OS and window system. OS and window system.
The (experimental) Wayland backend also depends on the `extra-cmake-modules`
package, which is used to generate Wayland protocol headers.
The examples and test programs depend on a number of tiny libraries. These are The examples and test programs depend on a number of tiny libraries. These are
located in the `deps/` directory. located in the `deps/` directory.
@@ -116,18 +119,15 @@ information on what to include when reporting a bug.
## Changelog ## Changelog
- Added `glfwGetKeyboardLayoutName` for querying the name of the current
keyboard layout (#1201)
- Added `glfwSetKeyboardLayoutCallback` and `GLFWkeyboardlayoutfun` for
receiving keyboard layout events (#1201)
- Added `GLFW_RESIZE_NWSE_CURSOR`, `GLFW_RESIZE_NESW_CURSOR`, - Added `GLFW_RESIZE_NWSE_CURSOR`, `GLFW_RESIZE_NESW_CURSOR`,
`GLFW_RESIZE_ALL_CURSOR` and `GLFW_NOT_ALLOWED_CURSOR` cursor shapes (#427) `GLFW_RESIZE_ALL_CURSOR` and `GLFW_NOT_ALLOWED_CURSOR` cursor shapes (#427)
- Added `GLFW_RESIZE_EW_CURSOR` alias for `GLFW_HRESIZE_CURSOR` (#427) - Added `GLFW_RESIZE_EW_CURSOR` alias for `GLFW_HRESIZE_CURSOR` (#427)
- Added `GLFW_RESIZE_NS_CURSOR` alias for `GLFW_VRESIZE_CURSOR` (#427) - Added `GLFW_RESIZE_NS_CURSOR` alias for `GLFW_VRESIZE_CURSOR` (#427)
- Added `GLFW_POINTING_HAND_CURSOR` alias for `GLFW_HAND_CURSOR` (#427) - 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_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)
- Made joystick subsystem initialize at first use (#1284,#1646)
- Updated the minimum required CMake version to 3.1 - Updated the minimum required CMake version to 3.1
- Disabled tests and examples by default when built as a CMake subdirectory - Disabled tests and examples by default when built as a CMake subdirectory
- Bugfix: The CMake config-file package used an absolute path and was not - Bugfix: The CMake config-file package used an absolute path and was not
@@ -135,13 +135,9 @@ information on what to include when reporting a bug.
- Bugfix: Video modes with a duplicate screen area were discarded (#1555,#1556) - Bugfix: Video modes with a duplicate screen area were discarded (#1555,#1556)
- Bugfix: Compiling with -Wextra-semi caused warnings (#1440) - Bugfix: Compiling with -Wextra-semi caused warnings (#1440)
- Bugfix: Built-in mappings failed because some OEMs re-used VID/PID (#1583) - Bugfix: Built-in mappings failed because some OEMs re-used VID/PID (#1583)
- Bugfix: Some extension loader headers did not prevent default OpenGL header
inclusion (#1695)
- [Win32] Added the `GLFW_WIN32_KEYBOARD_MENU` window hint for enabling access - [Win32] Added the `GLFW_WIN32_KEYBOARD_MENU` window hint for enabling access
to the window menu to the window menu
- [Win32] Added a version info resource to the GLFW DLL - [Win32] Added a version info resource to the GLFW DLL
- [Win32] Disabled framebuffer transparency on Windows 7 when DWM windows are
opaque (#1512)
- [Win32] Bugfix: `GLFW_INCLUDE_VULKAN` plus `VK_USE_PLATFORM_WIN32_KHR` caused - [Win32] Bugfix: `GLFW_INCLUDE_VULKAN` plus `VK_USE_PLATFORM_WIN32_KHR` caused
symbol redefinition (#1524) symbol redefinition (#1524)
- [Win32] Bugfix: The cursor position event was emitted before its cursor enter - [Win32] Bugfix: The cursor position event was emitted before its cursor enter
@@ -154,14 +150,9 @@ information on what to include when reporting a bug.
invalid pointer invalid pointer
- [Win32] Bugfix: Some synthetic key events were reported as `GLFW_KEY_UNKNOWN` - [Win32] Bugfix: Some synthetic key events were reported as `GLFW_KEY_UNKNOWN`
(#1623) (#1623)
- [Win32] Bugfix: Non-BMP Unicode codepoint input was reported as UTF-16
- [Win32] Bugfix: Monitor functions could return invalid values after
configuration change (#1761)
- [Win32] Bugfix: Initialization would segfault on Windows 8 (not 8.1) (#1775)
- [Cocoa] Added support for `VK_EXT_metal_surface` (#1619) - [Cocoa] Added support for `VK_EXT_metal_surface` (#1619)
- [Cocoa] Added locating the Vulkan loader at runtime in an application bundle - [Cocoa] Added locating the Vulkan loader at runtime in an application bundle
- [Cocoa] Moved main menu creation to GLFW initialization time (#1649) - [Cocoa] Moved main menu creation to GLFW initialization time (#1649)
- [Cocoa] Changed `EGLNativeWindowType` from `NSView` to `CALayer` (#1169)
- [Cocoa] Removed dependency on the CoreVideo framework - [Cocoa] Removed dependency on the CoreVideo framework
- [Cocoa] Bugfix: `glfwSetWindowSize` used a bottom-left anchor point (#1553) - [Cocoa] Bugfix: `glfwSetWindowSize` used a bottom-left anchor point (#1553)
- [Cocoa] Bugfix: Window remained on screen after destruction until event poll - [Cocoa] Bugfix: Window remained on screen after destruction until event poll
@@ -170,10 +161,6 @@ information on what to include when reporting a bug.
- [Cocoa] Bugfix: Undecorated windows could not be iconified on recent macOS - [Cocoa] Bugfix: Undecorated windows could not be iconified on recent macOS
- [Cocoa] Bugfix: Touching event queue from secondary thread before main thread - [Cocoa] Bugfix: Touching event queue from secondary thread before main thread
would abort (#1649) would abort (#1649)
- [Cocoa] Bugfix: Non-BMP Unicode codepoint input was reported as UTF-16
(#1635)
- [Cocoa] Bugfix: Failing to retrieve the refresh rate of built-in displays
could leak memory
- [X11] Bugfix: The CMake files did not check for the XInput headers (#1480) - [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 - [X11] Bugfix: Key names were not updated when the keyboard layout changed
(#1462,#1528) (#1462,#1528)
@@ -197,24 +184,14 @@ information on what to include when reporting a bug.
non-printable keys (#1598) non-printable keys (#1598)
- [X11] Bugfix: Function keys were mapped to `GLFW_KEY_UNKNOWN` for some layout - [X11] Bugfix: Function keys were mapped to `GLFW_KEY_UNKNOWN` for some layout
combinaitons (#1598) combinaitons (#1598)
- [X11] Bugfix: Keys pressed simultaneously with others were not always
reported (#1112,#1415,#1472,#1616)
- [Wayland] Removed support for `wl_shell` (#1443) - [Wayland] Removed support for `wl_shell` (#1443)
- [Wayland] Bugfix: The `GLFW_HAND_CURSOR` shape used the wrong image (#1432) - [Wayland] Bugfix: The `GLFW_HAND_CURSOR` shape used the wrong image (#1432)
- [Wayland] Bugfix: `CLOCK_MONOTONIC` was not correctly enabled - [Wayland] Bugfix: `CLOCK_MONOTONIC` was not correctly enabled
- [Wayland] Bugfix: Repeated keys could be reported with `NULL` window (#1704)
- [Wayland] Bugfix: Retrieving partial framebuffer size would segfault
- [Wayland] Bugfix: Scrolling offsets were inverted compared to other platforms
(#1463)
- [POSIX] Bugfix: `CLOCK_MONOTONIC` was not correctly tested for or enabled - [POSIX] Bugfix: `CLOCK_MONOTONIC` was not correctly tested for or enabled
- [NSGL] Removed enforcement of forward-compatible flag for core contexts - [NSGL] Removed enforcement of forward-compatible flag for core contexts
- [NSGL] Bugfix: `GLFW_COCOA_RETINA_FRAMEBUFFER` had no effect on newer - [NSGL] Bugfix: `GLFW_COCOA_RETINA_FRAMEBUFFER` had no effect on newer
macOS versions (#1442) macOS versions (#1442)
- [NSGL] Bugfix: Workaround for swap interval on 10.14 broke on 10.12 (#1483) - [NSGL] Bugfix: Workaround for swap interval on 10.14 broke on 10.12 (#1483)
- [EGL] Added platform selection via the `EGL_EXT_platform_base` extension
(#442)
- [EGL] Added ANGLE backend selection via `EGL_ANGLE_platform_angle` extension
(#1380)
## Contact ## Contact
@@ -255,7 +232,6 @@ skills.
- Rok Breulj - Rok Breulj
- Kai Burjack - Kai Burjack
- Martin Capitanio - Martin Capitanio
- Nicolas Caramelli
- David Carlier - David Carlier
- Arturo Castro - Arturo Castro
- Chi-kwan Chan - Chi-kwan Chan
@@ -354,7 +330,6 @@ skills.
- ndogxj - ndogxj
- Kristian Nielsen - Kristian Nielsen
- Kamil Nowakowski - Kamil Nowakowski
- onox
- Denis Ovod - Denis Ovod
- Ozzy - Ozzy
- Andri Pálsson - Andri Pálsson
@@ -362,7 +337,6 @@ skills.
- Braden Pellett - Braden Pellett
- Christopher Pelloux - Christopher Pelloux
- Arturo J. Pérez - Arturo J. Pérez
- Vladimir Perminov
- Anthony Pesch - Anthony Pesch
- Orson Peters - Orson Peters
- Emmanuel Gil Peyrot - Emmanuel Gil Peyrot
@@ -380,10 +354,8 @@ skills.
- Eddie Ringle - Eddie Ringle
- Max Risuhin - Max Risuhin
- Jorge Rodriguez - Jorge Rodriguez
- Luca Rood
- Ed Ropple - Ed Ropple
- Aleksey Rybalkin - Aleksey Rybalkin
- Mikko Rytkönen
- Riku Salminen - Riku Salminen
- Brandon Schaefer - Brandon Schaefer
- Sebastian Schuberth - Sebastian Schuberth
@@ -425,14 +397,11 @@ skills.
- Torsten Walluhn - Torsten Walluhn
- Patrick Walton - Patrick Walton
- Xo Wang - Xo Wang
- Waris
- Jay Weisskopf - Jay Weisskopf
- Frank Wille - Frank Wille
- Tatsuya Yatagawa
- Ryogo Yoshimura - Ryogo Yoshimura
- Lukas Zanner - Lukas Zanner
- Andrey Zholos - Andrey Zholos
- Aihui Zhu
- Santi Zupancic - Santi Zupancic
- Jonas Ådahl - Jonas Ådahl
- Lasse Öörni - Lasse Öörni
+2 -2
View File
@@ -257,9 +257,9 @@ LINMATH_H_FUNC void mat4x4_rotate_Y(mat4x4 Q, mat4x4 M, float angle)
float s = sinf(angle); float s = sinf(angle);
float c = cosf(angle); float c = cosf(angle);
mat4x4 R = { mat4x4 R = {
{ c, 0.f, -s, 0.f}, { c, 0.f, s, 0.f},
{ 0.f, 1.f, 0.f, 0.f}, { 0.f, 1.f, 0.f, 0.f},
{ s, 0.f, c, 0.f}, { -s, 0.f, c, 0.f},
{ 0.f, 0.f, 0.f, 1.f} { 0.f, 0.f, 0.f, 1.f}
}; };
mat4x4_mul(Q, M, R); mat4x4_mul(Q, M, R);
+161 -400
View File
@@ -105,8 +105,6 @@
/// NK_INCLUDE_COMMAND_USERDATA | Defining this adds a userdata pointer into each command. Can be useful for example if you want to provide custom shaders depending on the used widget. Can be combined with the style structures. /// NK_INCLUDE_COMMAND_USERDATA | Defining this adds a userdata pointer into each command. Can be useful for example if you want to provide custom shaders depending on the used widget. Can be combined with the style structures.
/// NK_BUTTON_TRIGGER_ON_RELEASE | Different platforms require button clicks occurring either on buttons being pressed (up to down) or released (down to up). By default this library will react on buttons being pressed, but if you define this it will only trigger if a button is released. /// NK_BUTTON_TRIGGER_ON_RELEASE | Different platforms require button clicks occurring either on buttons being pressed (up to down) or released (down to up). By default this library will react on buttons being pressed, but if you define this it will only trigger if a button is released.
/// NK_ZERO_COMMAND_MEMORY | Defining this will zero out memory for each drawing command added to a drawing queue (inside nk_command_buffer_push). Zeroing command memory is very useful for fast checking (using memcmp) if command buffers are equal and avoid drawing frames when nothing on screen has changed since previous frame. /// NK_ZERO_COMMAND_MEMORY | Defining this will zero out memory for each drawing command added to a drawing queue (inside nk_command_buffer_push). Zeroing command memory is very useful for fast checking (using memcmp) if command buffers are equal and avoid drawing frames when nothing on screen has changed since previous frame.
/// NK_UINT_DRAW_INDEX | Defining this will set the size of vertex index elements when using NK_VERTEX_BUFFER_OUTPUT to 32bit instead of the default of 16bit
/// NK_KEYSTATE_BASED_INPUT | Define this if your backend uses key state for each frame rather than key press/release events
/// ///
/// !!! WARNING /// !!! WARNING
/// The following flags will pull in the standard C library: /// The following flags will pull in the standard C library:
@@ -124,7 +122,6 @@
/// - NK_INCLUDE_DEFAULT_FONT /// - NK_INCLUDE_DEFAULT_FONT
/// - NK_INCLUDE_STANDARD_VARARGS /// - NK_INCLUDE_STANDARD_VARARGS
/// - NK_INCLUDE_COMMAND_USERDATA /// - NK_INCLUDE_COMMAND_USERDATA
/// - NK_UINT_DRAW_INDEX
/// ///
/// ### Constants /// ### Constants
/// Define | Description /// Define | Description
@@ -304,7 +301,6 @@ extern "C" {
#define NK_CLAMP(i,v,x) (NK_MAX(NK_MIN(v,x), i)) #define NK_CLAMP(i,v,x) (NK_MAX(NK_MIN(v,x), i))
#ifdef NK_INCLUDE_STANDARD_VARARGS #ifdef NK_INCLUDE_STANDARD_VARARGS
#include <stdarg.h> /* valist, va_start, va_end, ... */
#if defined(_MSC_VER) && (_MSC_VER >= 1600) /* VS 2010 and above */ #if defined(_MSC_VER) && (_MSC_VER >= 1600) /* VS 2010 and above */
#include <sal.h> #include <sal.h>
#define NK_PRINTF_FORMAT_STRING _Printf_format_string_ #define NK_PRINTF_FORMAT_STRING _Printf_format_string_
@@ -318,6 +314,7 @@ extern "C" {
#define NK_PRINTF_VARARG_FUNC(fmtargnumber) #define NK_PRINTF_VARARG_FUNC(fmtargnumber)
#define NK_PRINTF_VALIST_FUNC(fmtargnumber) #define NK_PRINTF_VALIST_FUNC(fmtargnumber)
#endif #endif
#include <stdarg.h> /* valist, va_start, va_end, ... */
#endif #endif
/* /*
@@ -339,7 +336,7 @@ extern "C" {
#define NK_POINTER_TYPE uintptr_t #define NK_POINTER_TYPE uintptr_t
#else #else
#ifndef NK_INT8 #ifndef NK_INT8
#define NK_INT8 signed char #define NK_INT8 char
#endif #endif
#ifndef NK_UINT8 #ifndef NK_UINT8
#define NK_UINT8 unsigned char #define NK_UINT8 unsigned char
@@ -1087,12 +1084,6 @@ NK_API void nk_input_end(struct nk_context*);
/// ///
/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c /// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
/// // fill configuration /// // fill configuration
/// struct your_vertex
/// {
/// float pos[2]; // important to keep it to 2 floats
/// float uv[2];
/// unsigned char col[4];
/// };
/// struct nk_convert_config cfg = {}; /// struct nk_convert_config cfg = {};
/// static const struct nk_draw_vertex_layout_element vertex_layout[] = { /// static const struct nk_draw_vertex_layout_element vertex_layout[] = {
/// {NK_VERTEX_POSITION, NK_FORMAT_FLOAT, NK_OFFSETOF(struct your_vertex, pos)}, /// {NK_VERTEX_POSITION, NK_FORMAT_FLOAT, NK_OFFSETOF(struct your_vertex, pos)},
@@ -1218,7 +1209,7 @@ NK_API const struct nk_command* nk__next(struct nk_context*, const struct nk_com
/// ///
/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c /// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
/// nk_flags nk_convert(struct nk_context *ctx, struct nk_buffer *cmds, /// nk_flags nk_convert(struct nk_context *ctx, struct nk_buffer *cmds,
/// struct nk_buffer *vertices, struct nk_buffer *elements, const struct nk_convert_config*); // struct nk_buffer *vertices, struct nk_buffer *elements, const struct nk_convert_config*);
/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/// ///
/// Parameter | Description /// Parameter | Description
@@ -1403,7 +1394,6 @@ NK_API const struct nk_draw_command* nk__draw_next(const struct nk_draw_command*
/// nk_window_get_content_region_max | Returns the upper rectangle position of the currently visible and non-clipped space inside the currently processed window /// nk_window_get_content_region_max | Returns the upper rectangle position of the currently visible and non-clipped space inside the currently processed window
/// nk_window_get_content_region_size | Returns the size of the currently visible and non-clipped space inside the currently processed window /// nk_window_get_content_region_size | Returns the size of the currently visible and non-clipped space inside the currently processed window
/// nk_window_get_canvas | Returns the draw command buffer. Can be used to draw custom widgets /// nk_window_get_canvas | Returns the draw command buffer. Can be used to draw custom widgets
/// nk_window_get_scroll | Gets the scroll offset of the current window
/// nk_window_has_focus | Returns if the currently processed window is currently active /// nk_window_has_focus | Returns if the currently processed window is currently active
/// nk_window_is_collapsed | Returns if the window with given name is currently minimized/collapsed /// nk_window_is_collapsed | Returns if the window with given name is currently minimized/collapsed
/// nk_window_is_closed | Returns if the currently processed window was closed /// nk_window_is_closed | Returns if the currently processed window was closed
@@ -1417,7 +1407,6 @@ NK_API const struct nk_draw_command* nk__draw_next(const struct nk_draw_command*
/// nk_window_set_position | Updates position of the currently process window /// nk_window_set_position | Updates position of the currently process window
/// nk_window_set_size | Updates the size of the currently processed window /// nk_window_set_size | Updates the size of the currently processed window
/// nk_window_set_focus | Set the currently processed window as active window /// nk_window_set_focus | Set the currently processed window as active window
/// nk_window_set_scroll | Sets the scroll offset of the current window
// //
/// nk_window_close | Closes the window with given window name which deletes the window at the end of the frame /// nk_window_close | Closes the window with given window name which deletes the window at the end of the frame
/// nk_window_collapse | Collapses the window with given window name /// nk_window_collapse | Collapses the window with given window name
@@ -1438,7 +1427,7 @@ NK_API const struct nk_draw_command* nk__draw_next(const struct nk_draw_command*
/// NK_WINDOW_TITLE | Forces a header at the top at the window showing the title /// NK_WINDOW_TITLE | Forces a header at the top at the window showing the title
/// NK_WINDOW_SCROLL_AUTO_HIDE | Automatically hides the window scrollbar if no user interaction: also requires delta time in `nk_context` to be set each frame /// NK_WINDOW_SCROLL_AUTO_HIDE | Automatically hides the window scrollbar if no user interaction: also requires delta time in `nk_context` to be set each frame
/// NK_WINDOW_BACKGROUND | Always keep window in the background /// NK_WINDOW_BACKGROUND | Always keep window in the background
/// NK_WINDOW_SCALE_LEFT | Puts window scaler in the left-bottom corner instead right-bottom /// NK_WINDOW_SCALE_LEFT | Puts window scaler in the left-ottom corner instead right-bottom
/// NK_WINDOW_NO_INPUT | Prevents window of scaling, moving or getting focus /// NK_WINDOW_NO_INPUT | Prevents window of scaling, moving or getting focus
/// ///
/// #### nk_collapse_states /// #### nk_collapse_states
@@ -1517,7 +1506,7 @@ NK_API void nk_end(struct nk_context *ctx);
/// Finds and returns a window from passed name /// Finds and returns a window from passed name
/// ///
/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c /// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
/// struct nk_window *nk_window_find(struct nk_context *ctx, const char *name); /// void nk_end(struct nk_context *ctx);
/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/// ///
/// Parameter | Description /// Parameter | Description
@@ -1721,22 +1710,6 @@ NK_API struct nk_vec2 nk_window_get_content_region_size(struct nk_context*);
/// drawing canvas. Can be used to do custom drawing. /// drawing canvas. Can be used to do custom drawing.
*/ */
NK_API struct nk_command_buffer* nk_window_get_canvas(struct nk_context*); NK_API struct nk_command_buffer* nk_window_get_canvas(struct nk_context*);
/*/// #### nk_window_get_scroll
/// Gets the scroll offset for the current window
/// !!! WARNING
/// Only call this function between calls `nk_begin_xxx` and `nk_end`
///
/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
/// void nk_window_get_scroll(struct nk_context *ctx, nk_uint *offset_x, nk_uint *offset_y);
/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
///
/// Parameter | Description
/// -------------|-----------------------------------------------------------
/// __ctx__ | Must point to an previously initialized `nk_context` struct
/// __offset_x__ | A pointer to the x offset output (or NULL to ignore)
/// __offset_y__ | A pointer to the y offset output (or NULL to ignore)
*/
NK_API void nk_window_get_scroll(struct nk_context*, nk_uint *offset_x, nk_uint *offset_y);
/*/// #### nk_window_has_focus /*/// #### nk_window_has_focus
/// Returns if the currently processed window is currently active /// Returns if the currently processed window is currently active
/// !!! WARNING /// !!! WARNING
@@ -1903,22 +1876,6 @@ NK_API void nk_window_set_size(struct nk_context*, const char *name, struct nk_v
/// __name__ | Identifier of the window to set focus on /// __name__ | Identifier of the window to set focus on
*/ */
NK_API void nk_window_set_focus(struct nk_context*, const char *name); NK_API void nk_window_set_focus(struct nk_context*, const char *name);
/*/// #### nk_window_set_scroll
/// Sets the scroll offset for the current window
/// !!! WARNING
/// Only call this function between calls `nk_begin_xxx` and `nk_end`
///
/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
/// void nk_window_set_scroll(struct nk_context *ctx, nk_uint offset_x, nk_uint offset_y);
/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
///
/// Parameter | Description
/// -------------|-----------------------------------------------------------
/// __ctx__ | Must point to an previously initialized `nk_context` struct
/// __offset_x__ | The x offset to scroll to
/// __offset_y__ | The y offset to scroll to
*/
NK_API void nk_window_set_scroll(struct nk_context*, nk_uint offset_x, nk_uint offset_y);
/*/// #### nk_window_close /*/// #### nk_window_close
/// Closes a window and marks it for being freed at the end of the frame /// Closes a window and marks it for being freed at the end of the frame
/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c /// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
@@ -2631,7 +2588,7 @@ NK_API struct nk_rect nk_layout_space_rect_to_local(struct nk_context*, struct n
/// case ...: /// case ...:
/// // [...] /// // [...]
/// } /// }
/// nk_clear(&ctx); // nk_clear(&ctx);
/// } /// }
/// nk_free(&ctx); /// nk_free(&ctx);
/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -2644,8 +2601,6 @@ NK_API struct nk_rect nk_layout_space_rect_to_local(struct nk_context*, struct n
/// nk_group_scrolled_offset_begin | Start a new group with manual separated handling of scrollbar x- and y-offset /// nk_group_scrolled_offset_begin | Start a new group with manual separated handling of scrollbar x- and y-offset
/// nk_group_scrolled_begin | Start a new group with manual scrollbar handling /// nk_group_scrolled_begin | Start a new group with manual scrollbar handling
/// nk_group_scrolled_end | Ends a group with manual scrollbar handling. Should only be called if nk_group_begin returned non-zero /// nk_group_scrolled_end | Ends a group with manual scrollbar handling. Should only be called if nk_group_begin returned non-zero
/// nk_group_get_scroll | Gets the scroll offset for the given group
/// nk_group_set_scroll | Sets the scroll offset for the given group
*/ */
/*/// #### nk_group_begin /*/// #### nk_group_begin
/// Starts a new widget group. Requires a previous layouting function to specify a pos/size. /// Starts a new widget group. Requires a previous layouting function to specify a pos/size.
@@ -2735,34 +2690,6 @@ NK_API int nk_group_scrolled_begin(struct nk_context*, struct nk_scroll *off, co
/// __ctx__ | Must point to an previously initialized `nk_context` struct /// __ctx__ | Must point to an previously initialized `nk_context` struct
*/ */
NK_API void nk_group_scrolled_end(struct nk_context*); NK_API void nk_group_scrolled_end(struct nk_context*);
/*/// #### nk_group_get_scroll
/// Gets the scroll position of the given group.
/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
/// void nk_group_get_scroll(struct nk_context*, const char *id, nk_uint *x_offset, nk_uint *y_offset);
/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
///
/// Parameter | Description
/// -------------|-----------------------------------------------------------
/// __ctx__ | Must point to an previously initialized `nk_context` struct
/// __id__ | The id of the group to get the scroll position of
/// __x_offset__ | A pointer to the x offset output (or NULL to ignore)
/// __y_offset__ | A pointer to the y offset output (or NULL to ignore)
*/
NK_API void nk_group_get_scroll(struct nk_context*, const char *id, nk_uint *x_offset, nk_uint *y_offset);
/*/// #### nk_group_set_scroll
/// Sets the scroll position of the given group.
/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
/// void nk_group_set_scroll(struct nk_context*, const char *id, nk_uint x_offset, nk_uint y_offset);
/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
///
/// Parameter | Description
/// -------------|-----------------------------------------------------------
/// __ctx__ | Must point to an previously initialized `nk_context` struct
/// __id__ | The id of the group to scroll
/// __x_offset__ | The x offset to scroll to
/// __y_offset__ | The y offset to scroll to
*/
NK_API void nk_group_set_scroll(struct nk_context*, const char *id, nk_uint x_offset, nk_uint y_offset);
/* ============================================================================= /* =============================================================================
* *
* TREE * TREE
@@ -3260,7 +3187,7 @@ NK_API int nk_color_pick(struct nk_context*, struct nk_colorf*, enum nk_color_fo
/// case ...: /// case ...:
/// // [...] /// // [...]
/// } /// }
/// nk_clear(&ctx); // nk_clear(&ctx);
/// } /// }
/// nk_free(&ctx); /// nk_free(&ctx);
/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -3468,8 +3395,6 @@ NK_API void nk_plot_function(struct nk_context*, enum nk_chart_type, void *userd
NK_API int nk_popup_begin(struct nk_context*, enum nk_popup_type, const char*, nk_flags, struct nk_rect bounds); NK_API int nk_popup_begin(struct nk_context*, enum nk_popup_type, const char*, nk_flags, struct nk_rect bounds);
NK_API void nk_popup_close(struct nk_context*); NK_API void nk_popup_close(struct nk_context*);
NK_API void nk_popup_end(struct nk_context*); NK_API void nk_popup_end(struct nk_context*);
NK_API void nk_popup_get_scroll(struct nk_context*, nk_uint *offset_x, nk_uint *offset_y);
NK_API void nk_popup_set_scroll(struct nk_context*, nk_uint offset_x, nk_uint offset_y);
/* ============================================================================= /* =============================================================================
* *
* COMBOBOX * COMBOBOX
@@ -4663,11 +4588,7 @@ NK_API int nk_input_is_key_down(const struct nk_input*, enum nk_keys);
In fact it is probably more powerful than needed but allows even more crazy In fact it is probably more powerful than needed but allows even more crazy
things than this library provides by default. things than this library provides by default.
*/ */
#ifdef NK_UINT_DRAW_INDEX
typedef nk_uint nk_draw_index;
#else
typedef nk_ushort nk_draw_index; typedef nk_ushort nk_draw_index;
#endif
enum nk_draw_list_stroke { enum nk_draw_list_stroke {
NK_STROKE_OPEN = nk_false, NK_STROKE_OPEN = nk_false,
/* build up path has no connection back to the beginning */ /* build up path has no connection back to the beginning */
@@ -5682,6 +5603,7 @@ template<typename T> struct nk_alignof{struct Big {T x; char c;}; enum {
#endif /* NK_NUKLEAR_H_ */ #endif /* NK_NUKLEAR_H_ */
#ifdef NK_IMPLEMENTATION #ifdef NK_IMPLEMENTATION
#ifndef NK_INTERNAL_H #ifndef NK_INTERNAL_H
@@ -6085,18 +6007,15 @@ nk_sin(float x)
NK_LIB float NK_LIB float
nk_cos(float x) nk_cos(float x)
{ {
/* New implementation. Also generated using lolremez. */ NK_STORAGE const float a0 = +1.00238601909309722f;
/* Old version significantly deviated from expected results. */ NK_STORAGE const float a1 = -3.81919947353040024e-2f;
NK_STORAGE const float a0 = 9.9995999154986614e-1f; NK_STORAGE const float a2 = -3.94382342128062756e-1f;
NK_STORAGE const float a1 = 1.2548995793001028e-3f; NK_STORAGE const float a3 = -1.18134036025221444e-1f;
NK_STORAGE const float a2 = -5.0648546280678015e-1f; NK_STORAGE const float a4 = +1.07123798512170878e-1f;
NK_STORAGE const float a3 = 1.2942246466519995e-2f; NK_STORAGE const float a5 = -1.86637164165180873e-2f;
NK_STORAGE const float a4 = 2.8668384702547972e-2f; NK_STORAGE const float a6 = +9.90140908664079833e-4f;
NK_STORAGE const float a5 = 7.3726485210586547e-3f; NK_STORAGE const float a7 = -5.23022132118824778e-14f;
NK_STORAGE const float a6 = -3.8510875386947414e-3f; return a0 + x*(a1 + x*(a2 + x*(a3 + x*(a4 + x*(a5 + x*(a6 + x*a7))))));
NK_STORAGE const float a7 = 4.7196604604366623e-4f;
NK_STORAGE const float a8 = -1.8776444013090451e-5f;
return a0 + x*(a1 + x*(a2 + x*(a3 + x*(a4 + x*(a5 + x*(a6 + x*(a7 + x*a8)))))));
} }
NK_LIB nk_uint NK_LIB nk_uint
nk_round_up_pow2(nk_uint v) nk_round_up_pow2(nk_uint v)
@@ -7232,29 +7151,23 @@ nk_murmur_hash(const void * key, int len, nk_hash seed)
{ {
/* 32-Bit MurmurHash3: https://code.google.com/p/smhasher/wiki/MurmurHash3*/ /* 32-Bit MurmurHash3: https://code.google.com/p/smhasher/wiki/MurmurHash3*/
#define NK_ROTL(x,r) ((x) << (r) | ((x) >> (32 - r))) #define NK_ROTL(x,r) ((x) << (r) | ((x) >> (32 - r)))
union {const nk_uint *i; const nk_byte *b;} conv = {0};
nk_uint h1 = seed;
nk_uint k1;
const nk_byte *data = (const nk_byte*)key; const nk_byte *data = (const nk_byte*)key;
const nk_byte *keyptr = data;
nk_byte *k1ptr;
const int bsize = sizeof(k1);
const int nblocks = len/4; const int nblocks = len/4;
nk_uint h1 = seed;
const nk_uint c1 = 0xcc9e2d51; const nk_uint c1 = 0xcc9e2d51;
const nk_uint c2 = 0x1b873593; const nk_uint c2 = 0x1b873593;
const nk_byte *tail; const nk_byte *tail;
const nk_uint *blocks;
nk_uint k1;
int i; int i;
/* body */ /* body */
if (!key) return 0; if (!key) return 0;
for (i = 0; i < nblocks; ++i, keyptr += bsize) { conv.b = (data + nblocks*4);
k1ptr = (nk_byte*)&k1; blocks = (const nk_uint*)conv.i;
k1ptr[0] = keyptr[0]; for (i = -nblocks; i; ++i) {
k1ptr[1] = keyptr[1]; k1 = blocks[i];
k1ptr[2] = keyptr[2];
k1ptr[3] = keyptr[3];
k1 *= c1; k1 *= c1;
k1 = NK_ROTL(k1,15); k1 = NK_ROTL(k1,15);
k1 *= c2; k1 *= c2;
@@ -9443,7 +9356,7 @@ nk_draw_list_alloc_vertices(struct nk_draw_list *list, nk_size count)
* backend (OpenGL, DirectX, ...). For example in OpenGL for `glDrawElements` * backend (OpenGL, DirectX, ...). For example in OpenGL for `glDrawElements`
* instead of specifing `GL_UNSIGNED_SHORT` you have to define `GL_UNSIGNED_INT`. * instead of specifing `GL_UNSIGNED_SHORT` you have to define `GL_UNSIGNED_INT`.
* Sorry for the inconvenience. */ * Sorry for the inconvenience. */
if(sizeof(nk_draw_index)==2) NK_ASSERT((list->vertex_count < NK_USHORT_MAX && NK_ASSERT((sizeof(nk_draw_index) == 2 && list->vertex_count < NK_USHORT_MAX &&
"To many verticies for 16-bit vertex indicies. Please read comment above on how to solve this problem")); "To many verticies for 16-bit vertex indicies. Please read comment above on how to solve this problem"));
return vtx; return vtx;
} }
@@ -12896,9 +12809,6 @@ nk_font_bake(struct nk_font_baker *baker, void *image_memory, int width, int hei
dst_font->ascent = ((float)unscaled_ascent * font_scale); dst_font->ascent = ((float)unscaled_ascent * font_scale);
dst_font->descent = ((float)unscaled_descent * font_scale); dst_font->descent = ((float)unscaled_descent * font_scale);
dst_font->glyph_offset = glyph_n; dst_font->glyph_offset = glyph_n;
// Need to zero this, or it will carry over from a previous
// bake, and cause a segfault when accessing glyphs[].
dst_font->glyph_count = 0;
} }
/* fill own baked font glyph array */ /* fill own baked font glyph array */
@@ -13993,12 +13903,8 @@ nk_input_key(struct nk_context *ctx, enum nk_keys key, int down)
NK_ASSERT(ctx); NK_ASSERT(ctx);
if (!ctx) return; if (!ctx) return;
in = &ctx->input; in = &ctx->input;
#ifdef NK_KEYSTATE_BASED_INPUT
if (in->keyboard.keys[key].down != down) if (in->keyboard.keys[key].down != down)
in->keyboard.keys[key].clicked++; in->keyboard.keys[key].clicked++;
#else
in->keyboard.keys[key].clicked++;
#endif
in->keyboard.keys[key].down = down; in->keyboard.keys[key].down = down;
} }
NK_API void NK_API void
@@ -15882,7 +15788,7 @@ nk_panel_end(struct nk_context *ctx)
nk_fill_rect(out, empty_space, 0, style->window.background); nk_fill_rect(out, empty_space, 0, style->window.background);
/* fill right empty space */ /* fill right empty space */
empty_space.x = layout->bounds.x + layout->bounds.w; empty_space.x = layout->bounds.x + layout->bounds.w - layout->border;
empty_space.y = layout->bounds.y; empty_space.y = layout->bounds.y;
empty_space.w = panel_padding.x + layout->border; empty_space.w = panel_padding.x + layout->border;
empty_space.h = layout->bounds.h; empty_space.h = layout->bounds.h;
@@ -15891,11 +15797,11 @@ nk_panel_end(struct nk_context *ctx)
nk_fill_rect(out, empty_space, 0, style->window.background); nk_fill_rect(out, empty_space, 0, style->window.background);
/* fill bottom empty space */ /* fill bottom empty space */
if (layout->footer_height > 0) { if (*layout->offset_x != 0 && !(layout->flags & NK_WINDOW_NO_SCROLLBAR)) {
empty_space.x = window->bounds.x; empty_space.x = window->bounds.x;
empty_space.y = layout->bounds.y + layout->bounds.h; empty_space.y = layout->bounds.y + layout->bounds.h;
empty_space.w = window->bounds.w; empty_space.w = window->bounds.w;
empty_space.h = layout->footer_height; empty_space.h = scrollbar_size.y;
nk_fill_rect(out, empty_space, 0, style->window.background); nk_fill_rect(out, empty_space, 0, style->window.background);
} }
} }
@@ -16269,8 +16175,8 @@ nk_begin_titled(struct nk_context *ctx, const char *name, const char *title,
{ {
struct nk_window *win; struct nk_window *win;
struct nk_style *style; struct nk_style *style;
nk_hash name_hash; nk_hash title_hash;
int name_len; int title_len;
int ret = 0; int ret = 0;
NK_ASSERT(ctx); NK_ASSERT(ctx);
@@ -16283,12 +16189,12 @@ nk_begin_titled(struct nk_context *ctx, const char *name, const char *title,
/* find or create window */ /* find or create window */
style = &ctx->style; style = &ctx->style;
name_len = (int)nk_strlen(name); title_len = (int)nk_strlen(name);
name_hash = nk_murmur_hash(name, (int)name_len, NK_WINDOW_TITLE); title_hash = nk_murmur_hash(name, (int)title_len, NK_WINDOW_TITLE);
win = nk_find_window(ctx, name_hash, name); win = nk_find_window(ctx, title_hash, name);
if (!win) { if (!win) {
/* create new window */ /* create new window */
nk_size name_length = (nk_size)name_len; nk_size name_length = (nk_size)nk_strlen(name);
win = (struct nk_window*)nk_create_window(ctx); win = (struct nk_window*)nk_create_window(ctx);
NK_ASSERT(win); NK_ASSERT(win);
if (!win) return 0; if (!win) return 0;
@@ -16300,7 +16206,7 @@ nk_begin_titled(struct nk_context *ctx, const char *name, const char *title,
win->flags = flags; win->flags = flags;
win->bounds = bounds; win->bounds = bounds;
win->name = name_hash; win->name = title_hash;
name_length = NK_MIN(name_length, NK_WINDOW_MAX_NAME-1); name_length = NK_MIN(name_length, NK_WINDOW_MAX_NAME-1);
NK_MEMCPY(win->name_string, name, name_length); NK_MEMCPY(win->name_string, name, name_length);
win->name_string[name_length] = 0; win->name_string[name_length] = 0;
@@ -16528,20 +16434,6 @@ nk_window_get_panel(struct nk_context *ctx)
if (!ctx || !ctx->current) return 0; if (!ctx || !ctx->current) return 0;
return ctx->current->layout; return ctx->current->layout;
} }
NK_API void
nk_window_get_scroll(struct nk_context *ctx, nk_uint *offset_x, nk_uint *offset_y)
{
struct nk_window *win;
NK_ASSERT(ctx);
NK_ASSERT(ctx->current);
if (!ctx || !ctx->current)
return ;
win = ctx->current;
if (offset_x)
*offset_x = win->scrollbar.x;
if (offset_y)
*offset_y = win->scrollbar.y;
}
NK_API int NK_API int
nk_window_has_focus(const struct nk_context *ctx) nk_window_has_focus(const struct nk_context *ctx)
{ {
@@ -16708,18 +16600,6 @@ nk_window_set_size(struct nk_context *ctx,
win->bounds.h = size.y; win->bounds.h = size.y;
} }
NK_API void NK_API void
nk_window_set_scroll(struct nk_context *ctx, nk_uint offset_x, nk_uint offset_y)
{
struct nk_window *win;
NK_ASSERT(ctx);
NK_ASSERT(ctx->current);
if (!ctx || !ctx->current)
return;
win = ctx->current;
win->scrollbar.x = offset_x;
win->scrollbar.y = offset_y;
}
NK_API void
nk_window_collapse(struct nk_context *ctx, const char *name, nk_window_collapse(struct nk_context *ctx, const char *name,
enum nk_collapse_states c) enum nk_collapse_states c)
{ {
@@ -16793,6 +16673,7 @@ nk_window_set_focus(struct nk_context *ctx, const char *name)
/* =============================================================== /* ===============================================================
* *
* POPUP * POPUP
@@ -16926,11 +16807,7 @@ nk_nonblock_begin(struct nk_context *ctx,
} else { } else {
/* close the popup if user pressed outside or in the header */ /* close the popup if user pressed outside or in the header */
int pressed, in_body, in_header; int pressed, in_body, in_header;
#ifdef NK_BUTTON_TRIGGER_ON_RELEASE
pressed = nk_input_is_mouse_released(&ctx->input, NK_BUTTON_LEFT);
#else
pressed = nk_input_is_mouse_pressed(&ctx->input, NK_BUTTON_LEFT); pressed = nk_input_is_mouse_pressed(&ctx->input, NK_BUTTON_LEFT);
#endif
in_body = nk_input_is_mouse_hovering_rect(&ctx->input, body); in_body = nk_input_is_mouse_hovering_rect(&ctx->input, body);
in_header = nk_input_is_mouse_hovering_rect(&ctx->input, header); in_header = nk_input_is_mouse_hovering_rect(&ctx->input, header);
if (pressed && (!in_body || in_header)) if (pressed && (!in_body || in_header))
@@ -17021,38 +16898,7 @@ nk_popup_end(struct nk_context *ctx)
ctx->current = win; ctx->current = win;
nk_push_scissor(&win->buffer, win->layout->clip); nk_push_scissor(&win->buffer, win->layout->clip);
} }
NK_API void
nk_popup_get_scroll(struct nk_context *ctx, nk_uint *offset_x, nk_uint *offset_y)
{
struct nk_window *popup;
NK_ASSERT(ctx);
NK_ASSERT(ctx->current);
NK_ASSERT(ctx->current->layout);
if (!ctx || !ctx->current || !ctx->current->layout)
return;
popup = ctx->current;
if (offset_x)
*offset_x = popup->scrollbar.x;
if (offset_y)
*offset_y = popup->scrollbar.y;
}
NK_API void
nk_popup_set_scroll(struct nk_context *ctx, nk_uint offset_x, nk_uint offset_y)
{
struct nk_window *popup;
NK_ASSERT(ctx);
NK_ASSERT(ctx->current);
NK_ASSERT(ctx->current->layout);
if (!ctx || !ctx->current || !ctx->current->layout)
return;
popup = ctx->current;
popup->scrollbar.x = offset_x;
popup->scrollbar.y = offset_y;
}
@@ -18179,25 +18025,22 @@ nk_layout_widget_space(struct nk_rect *bounds, const struct nk_context *ctx,
panel_space = nk_layout_row_calculate_usable_space(&ctx->style, layout->type, panel_space = nk_layout_row_calculate_usable_space(&ctx->style, layout->type,
layout->bounds.w, layout->row.columns); layout->bounds.w, layout->row.columns);
#define NK_FRAC(x) (x - (int)x) /* will be used to remove fookin gaps */
/* calculate the width of one item inside the current layout space */ /* calculate the width of one item inside the current layout space */
switch (layout->row.type) { switch (layout->row.type) {
case NK_LAYOUT_DYNAMIC_FIXED: { case NK_LAYOUT_DYNAMIC_FIXED: {
/* scaling fixed size widgets item width */ /* scaling fixed size widgets item width */
float w = NK_MAX(1.0f,panel_space) / (float)layout->row.columns; item_width = NK_MAX(1.0f,panel_space) / (float)layout->row.columns;
item_offset = (float)layout->row.index * w; item_offset = (float)layout->row.index * item_width;
item_width = w + NK_FRAC(item_offset);
item_spacing = (float)layout->row.index * spacing.x; item_spacing = (float)layout->row.index * spacing.x;
} break; } break;
case NK_LAYOUT_DYNAMIC_ROW: { case NK_LAYOUT_DYNAMIC_ROW: {
/* scaling single ratio widget width */ /* scaling single ratio widget width */
float w = layout->row.item_width * panel_space; item_width = layout->row.item_width * panel_space;
item_offset = layout->row.item_offset; item_offset = layout->row.item_offset;
item_width = w + NK_FRAC(item_offset);
item_spacing = 0; item_spacing = 0;
if (modify) { if (modify) {
layout->row.item_offset += w + spacing.x; layout->row.item_offset += item_width + spacing.x;
layout->row.filled += layout->row.item_width; layout->row.filled += layout->row.item_width;
layout->row.index = 0; layout->row.index = 0;
} }
@@ -18208,24 +18051,23 @@ nk_layout_widget_space(struct nk_rect *bounds, const struct nk_context *ctx,
bounds->x -= (float)*layout->offset_x; bounds->x -= (float)*layout->offset_x;
bounds->y = layout->at_y + (layout->row.height * layout->row.item.y); bounds->y = layout->at_y + (layout->row.height * layout->row.item.y);
bounds->y -= (float)*layout->offset_y; bounds->y -= (float)*layout->offset_y;
bounds->w = layout->bounds.w * layout->row.item.w + NK_FRAC(bounds->x); bounds->w = layout->bounds.w * layout->row.item.w;
bounds->h = layout->row.height * layout->row.item.h + NK_FRAC(bounds->y); bounds->h = layout->row.height * layout->row.item.h;
return; return;
} }
case NK_LAYOUT_DYNAMIC: { case NK_LAYOUT_DYNAMIC: {
/* scaling arrays of panel width ratios for every widget */ /* scaling arrays of panel width ratios for every widget */
float ratio, w; float ratio;
NK_ASSERT(layout->row.ratio); NK_ASSERT(layout->row.ratio);
ratio = (layout->row.ratio[layout->row.index] < 0) ? ratio = (layout->row.ratio[layout->row.index] < 0) ?
layout->row.item_width : layout->row.ratio[layout->row.index]; layout->row.item_width : layout->row.ratio[layout->row.index];
w = (ratio * panel_space);
item_spacing = (float)layout->row.index * spacing.x; item_spacing = (float)layout->row.index * spacing.x;
item_width = (ratio * panel_space);
item_offset = layout->row.item_offset; item_offset = layout->row.item_offset;
item_width = w + NK_FRAC(item_offset);
if (modify) { if (modify) {
layout->row.item_offset += w; layout->row.item_offset += item_width;
layout->row.filled += ratio; layout->row.filled += ratio;
} }
} break; } break;
@@ -18263,16 +18105,13 @@ nk_layout_widget_space(struct nk_rect *bounds, const struct nk_context *ctx,
} break; } break;
case NK_LAYOUT_TEMPLATE: { case NK_LAYOUT_TEMPLATE: {
/* stretchy row layout with combined dynamic/static widget width*/ /* stretchy row layout with combined dynamic/static widget width*/
float w;
NK_ASSERT(layout->row.index < layout->row.columns); NK_ASSERT(layout->row.index < layout->row.columns);
NK_ASSERT(layout->row.index < NK_MAX_LAYOUT_ROW_TEMPLATE_COLUMNS); NK_ASSERT(layout->row.index < NK_MAX_LAYOUT_ROW_TEMPLATE_COLUMNS);
w = layout->row.templates[layout->row.index]; item_width = layout->row.templates[layout->row.index];
item_offset = layout->row.item_offset; item_offset = layout->row.item_offset;
item_width = w + NK_FRAC(item_offset);
item_spacing = (float)layout->row.index * spacing.x; item_spacing = (float)layout->row.index * spacing.x;
if (modify) layout->row.item_offset += w; if (modify) layout->row.item_offset += item_width;
} break; } break;
#undef NK_FRAC
default: NK_ASSERT(0); break; default: NK_ASSERT(0); break;
}; };
@@ -18848,74 +18687,7 @@ nk_group_end(struct nk_context *ctx)
{ {
nk_group_scrolled_end(ctx); nk_group_scrolled_end(ctx);
} }
NK_API void
nk_group_get_scroll(struct nk_context *ctx, const char *id, nk_uint *x_offset, nk_uint *y_offset)
{
int id_len;
nk_hash id_hash;
struct nk_window *win;
nk_uint *x_offset_ptr;
nk_uint *y_offset_ptr;
NK_ASSERT(ctx);
NK_ASSERT(id);
NK_ASSERT(ctx->current);
NK_ASSERT(ctx->current->layout);
if (!ctx || !ctx->current || !ctx->current->layout || !id)
return;
/* find persistent group scrollbar value */
win = ctx->current;
id_len = (int)nk_strlen(id);
id_hash = nk_murmur_hash(id, (int)id_len, NK_PANEL_GROUP);
x_offset_ptr = nk_find_value(win, id_hash);
if (!x_offset_ptr) {
x_offset_ptr = nk_add_value(ctx, win, id_hash, 0);
y_offset_ptr = nk_add_value(ctx, win, id_hash+1, 0);
NK_ASSERT(x_offset_ptr);
NK_ASSERT(y_offset_ptr);
if (!x_offset_ptr || !y_offset_ptr) return;
*x_offset_ptr = *y_offset_ptr = 0;
} else y_offset_ptr = nk_find_value(win, id_hash+1);
if (x_offset)
*x_offset = *x_offset_ptr;
if (y_offset)
*y_offset = *y_offset_ptr;
}
NK_API void
nk_group_set_scroll(struct nk_context *ctx, const char *id, nk_uint x_offset, nk_uint y_offset)
{
int id_len;
nk_hash id_hash;
struct nk_window *win;
nk_uint *x_offset_ptr;
nk_uint *y_offset_ptr;
NK_ASSERT(ctx);
NK_ASSERT(id);
NK_ASSERT(ctx->current);
NK_ASSERT(ctx->current->layout);
if (!ctx || !ctx->current || !ctx->current->layout || !id)
return;
/* find persistent group scrollbar value */
win = ctx->current;
id_len = (int)nk_strlen(id);
id_hash = nk_murmur_hash(id, (int)id_len, NK_PANEL_GROUP);
x_offset_ptr = nk_find_value(win, id_hash);
if (!x_offset_ptr) {
x_offset_ptr = nk_add_value(ctx, win, id_hash, 0);
y_offset_ptr = nk_add_value(ctx, win, id_hash+1, 0);
NK_ASSERT(x_offset_ptr);
NK_ASSERT(y_offset_ptr);
if (!x_offset_ptr || !y_offset_ptr) return;
*x_offset_ptr = *y_offset_ptr = 0;
} else y_offset_ptr = nk_find_value(win, id_hash+1);
*x_offset_ptr = x_offset;
*y_offset_ptr = y_offset;
}
@@ -21407,7 +21179,6 @@ nk_scrollbar_behavior(nk_flags *state, struct nk_input *in,
{ {
nk_flags ws = 0; nk_flags ws = 0;
int left_mouse_down; int left_mouse_down;
int left_mouse_clicked;
int left_mouse_click_in_cursor; int left_mouse_click_in_cursor;
float scroll_delta; float scroll_delta;
@@ -21415,14 +21186,13 @@ nk_scrollbar_behavior(nk_flags *state, struct nk_input *in,
if (!in) return scroll_offset; if (!in) return scroll_offset;
left_mouse_down = in->mouse.buttons[NK_BUTTON_LEFT].down; left_mouse_down = in->mouse.buttons[NK_BUTTON_LEFT].down;
left_mouse_clicked = in->mouse.buttons[NK_BUTTON_LEFT].clicked;
left_mouse_click_in_cursor = nk_input_has_mouse_click_down_in_rect(in, left_mouse_click_in_cursor = nk_input_has_mouse_click_down_in_rect(in,
NK_BUTTON_LEFT, *cursor, nk_true); NK_BUTTON_LEFT, *cursor, nk_true);
if (nk_input_is_mouse_hovering_rect(in, *scroll)) if (nk_input_is_mouse_hovering_rect(in, *scroll))
*state = NK_WIDGET_STATE_HOVERED; *state = NK_WIDGET_STATE_HOVERED;
scroll_delta = (o == NK_VERTICAL) ? in->mouse.scroll_delta.y: in->mouse.scroll_delta.x; scroll_delta = (o == NK_VERTICAL) ? in->mouse.scroll_delta.y: in->mouse.scroll_delta.x;
if (left_mouse_down && left_mouse_click_in_cursor && !left_mouse_clicked) { if (left_mouse_down && left_mouse_click_in_cursor) {
/* update cursor by mouse dragging */ /* update cursor by mouse dragging */
float pixel, delta; float pixel, delta;
*state = NK_WIDGET_STATE_ACTIVE; *state = NK_WIDGET_STATE_ACTIVE;
@@ -25473,105 +25243,95 @@ nk_tooltipfv(struct nk_context *ctx, const char *fmt, va_list args)
/// - [yy]: Minor version with non-breaking API and library changes /// - [yy]: Minor version with non-breaking API and library changes
/// - [zz]: Bug fix version with no direct changes to API /// - [zz]: Bug fix version with no direct changes to API
/// ///
/// - 2019/09/20 (4.01.3) - Fixed a bug wherein combobox cannot be closed by clicking the header /// - 2018/04/01 (4.00.1) - Fixed calling `nk_convert` multiple time per single frame
/// when NK_BUTTON_TRIGGER_ON_RELEASE is defined.
/// - 2019/09/10 (4.01.2) - Fixed the nk_cos function, which deviated significantly.
/// - 2019/09/08 (4.01.1) - Fixed a bug wherein re-baking of fonts caused a segmentation
/// fault due to dst_font->glyph_count not being zeroed on subsequent
/// bakes of the same set of fonts.
/// - 2019/06/23 (4.01.0) - Added nk_***_get_scroll and nk_***_set_scroll for groups, windows, and popups.
/// - 2019/06/12 (4.00.3) - Fix panel background drawing bug.
/// - 2018/10/31 (4.00.2) - Added NK_KEYSTATE_BASED_INPUT to "fix" state based backends
/// like GLFW without breaking key repeat behavior on event based.
/// - 2018/04/01 (4.00.1) - Fixed calling `nk_convert` multiple time per single frame.
/// - 2018/04/01 (4.00.0) - BREAKING CHANGE: nk_draw_list_clear no longer tries to /// - 2018/04/01 (4.00.0) - BREAKING CHANGE: nk_draw_list_clear no longer tries to
/// clear provided buffers. So make sure to either free /// clear provided buffers. So make sure to either free
/// or clear each passed buffer after calling nk_convert. /// or clear each passed buffer after calling nk_convert.
/// - 2018/02/23 (3.00.6) - Fixed slider dragging behavior. /// - 2018/02/23 (3.00.6) - Fixed slider dragging behavior
/// - 2018/01/31 (3.00.5) - Fixed overcalculation of cursor data in font baking process. /// - 2018/01/31 (3.00.5) - Fixed overcalculation of cursor data in font baking process
/// - 2018/01/31 (3.00.4) - Removed name collision with stb_truetype. /// - 2018/01/31 (3.00.4) - Removed name collision with stb_truetype
/// - 2018/01/28 (3.00.3) - Fixed panel window border drawing bug. /// - 2018/01/28 (3.00.3) - Fixed panel window border drawing bug
/// - 2018/01/12 (3.00.2) - Added `nk_group_begin_titled` for separed group identifier and title. /// - 2018/01/12 (3.00.2) - Added `nk_group_begin_titled` for separed group identifier and title
/// - 2018/01/07 (3.00.1) - Started to change documentation style. /// - 2018/01/07 (3.00.1) - Started to change documentation style
/// - 2018/01/05 (3.00.0) - BREAKING CHANGE: The previous color picker API was broken /// - 2018/01/05 (3.00.0) - BREAKING CHANGE: The previous color picker API was broken
/// because of conversions between float and byte color representation. /// because of conversions between float and byte color representation.
/// Color pickers now use floating point values to represent /// Color pickers now use floating point values to represent
/// HSV values. To get back the old behavior I added some additional /// HSV values. To get back the old behavior I added some additional
/// color conversion functions to cast between nk_color and /// color conversion functions to cast between nk_color and
/// nk_colorf. /// nk_colorf.
/// - 2017/12/23 (2.00.7) - Fixed small warning. /// - 2017/12/23 (2.00.7) - Fixed small warning
/// - 2017/12/23 (2.00.7) - Fixed `nk_edit_buffer` behavior if activated to allow input. /// - 2017/12/23 (2.00.7) - Fixed nk_edit_buffer behavior if activated to allow input
/// - 2017/12/23 (2.00.7) - Fixed modifyable progressbar dragging visuals and input behavior. /// - 2017/12/23 (2.00.7) - Fixed modifyable progressbar dragging visuals and input behavior
/// - 2017/12/04 (2.00.6) - Added formated string tooltip widget. /// - 2017/12/04 (2.00.6) - Added formated string tooltip widget
/// - 2017/11/18 (2.00.5) - Fixed window becoming hidden with flag `NK_WINDOW_NO_INPUT`. /// - 2017/11/18 (2.00.5) - Fixed window becoming hidden with flag NK_WINDOW_NO_INPUT
/// - 2017/11/15 (2.00.4) - Fixed font merging. /// - 2017/11/15 (2.00.4) - Fixed font merging
/// - 2017/11/07 (2.00.3) - Fixed window size and position modifier functions. /// - 2017/11/07 (2.00.3) - Fixed window size and position modifier functions
/// - 2017/09/14 (2.00.2) - Fixed `nk_edit_buffer` and `nk_edit_focus` behavior. /// - 2017/09/14 (2.00.2) - Fixed nk_edit_buffer and nk_edit_focus behavior
/// - 2017/09/14 (2.00.1) - Fixed window closing behavior. /// - 2017/09/14 (2.00.1) - Fixed window closing behavior
/// - 2017/09/14 (2.00.0) - BREAKING CHANGE: Modifing window position and size funtions now /// - 2017/09/14 (2.00.0) - BREAKING CHANGE: Modifing window position and size funtions now
/// require the name of the window and must happen outside the window /// require the name of the window and must happen outside the window
/// building process (between function call nk_begin and nk_end). /// building process (between function call nk_begin and nk_end).
/// - 2017/09/11 (1.40.9) - Fixed window background flag if background window is declared last. /// - 2017/09/11 (1.40.9) - Fixed window background flag if background window is declared last
/// - 2017/08/27 (1.40.8) - Fixed `nk_item_is_any_active` for hidden windows. /// - 2017/08/27 (1.40.8) - Fixed `nk_item_is_any_active` for hidden windows
/// - 2017/08/27 (1.40.7) - Fixed window background flag. /// - 2017/08/27 (1.40.7) - Fixed window background flag
/// - 2017/07/07 (1.40.6) - Fixed missing clipping rect check for hovering/clicked /// - 2017/07/07 (1.40.6) - Fixed missing clipping rect check for hovering/clicked
/// query for widgets. /// query for widgets
/// - 2017/07/07 (1.40.5) - Fixed drawing bug for vertex output for lines and stroked /// - 2017/07/07 (1.40.5) - Fixed drawing bug for vertex output for lines and stroked
/// and filled rectangles. /// and filled rectangles
/// - 2017/07/07 (1.40.4) - Fixed bug in nk_convert trying to add windows that are in /// - 2017/07/07 (1.40.4) - Fixed bug in nk_convert trying to add windows that are in
/// process of being destroyed. /// process of being destroyed.
/// - 2017/07/07 (1.40.3) - Fixed table internal bug caused by storing table size in /// - 2017/07/07 (1.40.3) - Fixed table internal bug caused by storing table size in
/// window instead of directly in table. /// window instead of directly in table.
/// - 2017/06/30 (1.40.2) - Removed unneeded semicolon in C++ NK_ALIGNOF macro. /// - 2017/06/30 (1.40.2) - Removed unneeded semicolon in C++ NK_ALIGNOF macro
/// - 2017/06/30 (1.40.1) - Fixed drawing lines smaller or equal zero. /// - 2017/06/30 (1.40.1) - Fixed drawing lines smaller or equal zero
/// - 2017/06/08 (1.40.0) - Removed the breaking part of last commit. Auto layout now only /// - 2017/06/08 (1.40.0) - Removed the breaking part of last commit. Auto layout now only
/// comes in effect if you pass in zero was row height argument. /// comes in effect if you pass in zero was row height argument
/// - 2017/06/08 (1.40.0) - BREAKING CHANGE: while not directly API breaking it will change /// - 2017/06/08 (1.40.0) - BREAKING CHANGE: while not directly API breaking it will change
/// how layouting works. From now there will be an internal minimum /// how layouting works. From now there will be an internal minimum
/// row height derived from font height. If you need a row smaller than /// row height derived from font height. If you need a row smaller than
/// that you can directly set it by `nk_layout_set_min_row_height` and /// that you can directly set it by `nk_layout_set_min_row_height` and
/// reset the value back by calling `nk_layout_reset_min_row_height. /// reset the value back by calling `nk_layout_reset_min_row_height.
/// - 2017/06/08 (1.39.1) - Fixed property text edit handling bug caused by past `nk_widget` fix. /// - 2017/06/08 (1.39.1) - Fixed property text edit handling bug caused by past `nk_widget` fix
/// - 2017/06/08 (1.39.0) - Added function to retrieve window space without calling a `nk_layout_xxx` function. /// - 2017/06/08 (1.39.0) - Added function to retrieve window space without calling a nk_layout_xxx function
/// - 2017/06/06 (1.38.5) - Fixed `nk_convert` return flag for command buffer. /// - 2017/06/06 (1.38.5) - Fixed `nk_convert` return flag for command buffer
/// - 2017/05/23 (1.38.4) - Fixed activation behavior for widgets partially clipped. /// - 2017/05/23 (1.38.4) - Fixed activation behavior for widgets partially clipped
/// - 2017/05/10 (1.38.3) - Fixed wrong min window size mouse scaling over boundries. /// - 2017/05/10 (1.38.3) - Fixed wrong min window size mouse scaling over boundries
/// - 2017/05/09 (1.38.2) - Fixed vertical scrollbar drawing with not enough space. /// - 2017/05/09 (1.38.2) - Fixed vertical scrollbar drawing with not enough space
/// - 2017/05/09 (1.38.1) - Fixed scaler dragging behavior if window size hits minimum size. /// - 2017/05/09 (1.38.1) - Fixed scaler dragging behavior if window size hits minimum size
/// - 2017/05/06 (1.38.0) - Added platform double-click support. /// - 2017/05/06 (1.38.0) - Added platform double-click support
/// - 2017/04/20 (1.37.1) - Fixed key repeat found inside glfw demo backends. /// - 2017/04/20 (1.37.1) - Fixed key repeat found inside glfw demo backends
/// - 2017/04/20 (1.37.0) - Extended properties with selection and clipboard support. /// - 2017/04/20 (1.37.0) - Extended properties with selection and clipbard support
/// - 2017/04/20 (1.36.2) - Fixed #405 overlapping rows with zero padding and spacing. /// - 2017/04/20 (1.36.2) - Fixed #405 overlapping rows with zero padding and spacing
/// - 2017/04/09 (1.36.1) - Fixed #403 with another widget float error. /// - 2017/04/09 (1.36.1) - Fixed #403 with another widget float error
/// - 2017/04/09 (1.36.0) - Added window `NK_WINDOW_NO_INPUT` and `NK_WINDOW_NOT_INTERACTIVE` flags. /// - 2017/04/09 (1.36.0) - Added window `NK_WINDOW_NO_INPUT` and `NK_WINDOW_NOT_INTERACTIVE` flags
/// - 2017/04/09 (1.35.3) - Fixed buffer heap corruption. /// - 2017/04/09 (1.35.3) - Fixed buffer heap corruption
/// - 2017/03/25 (1.35.2) - Fixed popup overlapping for `NK_WINDOW_BACKGROUND` windows. /// - 2017/03/25 (1.35.2) - Fixed popup overlapping for `NK_WINDOW_BACKGROUND` windows
/// - 2017/03/25 (1.35.1) - Fixed windows closing behavior. /// - 2017/03/25 (1.35.1) - Fixed windows closing behavior
/// - 2017/03/18 (1.35.0) - Added horizontal scroll requested in #377. /// - 2017/03/18 (1.35.0) - Added horizontal scroll requested in #377
/// - 2017/03/18 (1.34.3) - Fixed long window header titles. /// - 2017/03/18 (1.34.3) - Fixed long window header titles
/// - 2017/03/04 (1.34.2) - Fixed text edit filtering. /// - 2017/03/04 (1.34.2) - Fixed text edit filtering
/// - 2017/03/04 (1.34.1) - Fixed group closable flag. /// - 2017/03/04 (1.34.1) - Fixed group closable flag
/// - 2017/02/25 (1.34.0) - Added custom draw command for better language binding support. /// - 2017/02/25 (1.34.0) - Added custom draw command for better language binding support
/// - 2017/01/24 (1.33.0) - Added programatic way of remove edit focus. /// - 2017/01/24 (1.33.0) - Added programatic way of remove edit focus
/// - 2017/01/24 (1.32.3) - Fixed wrong define for basic type definitions for windows. /// - 2017/01/24 (1.32.3) - Fixed wrong define for basic type definitions for windows
/// - 2017/01/21 (1.32.2) - Fixed input capture from hidden or closed windows. /// - 2017/01/21 (1.32.2) - Fixed input capture from hidden or closed windows
/// - 2017/01/21 (1.32.1) - Fixed slider behavior and drawing. /// - 2017/01/21 (1.32.1) - Fixed slider behavior and drawing
/// - 2017/01/13 (1.32.0) - Added flag to put scaler into the bottom left corner. /// - 2017/01/13 (1.32.0) - Added flag to put scaler into the bottom left corner
/// - 2017/01/13 (1.31.0) - Added additional row layouting method to combine both /// - 2017/01/13 (1.31.0) - Added additional row layouting method to combine both
/// dynamic and static widgets. /// dynamic and static widgets.
/// - 2016/12/31 (1.30.0) - Extended scrollbar offset from 16-bit to 32-bit. /// - 2016/12/31 (1.30.0) - Extended scrollbar offset from 16-bit to 32-bit
/// - 2016/12/31 (1.29.2) - Fixed closing window bug of minimized windows. /// - 2016/12/31 (1.29.2)- Fixed closing window bug of minimized windows
/// - 2016/12/03 (1.29.1) - Fixed wrapped text with no seperator and C89 error. /// - 2016/12/03 (1.29.1)- Fixed wrapped text with no seperator and C89 error
/// - 2016/12/03 (1.29.0) - Changed text wrapping to process words not characters. /// - 2016/12/03 (1.29.0) - Changed text wrapping to process words not characters
/// - 2016/11/22 (1.28.6) - Fixed window minimized closing bug. /// - 2016/11/22 (1.28.6)- Fixed window minimized closing bug
/// - 2016/11/19 (1.28.5) - Fixed abstract combo box closing behavior. /// - 2016/11/19 (1.28.5)- Fixed abstract combo box closing behavior
/// - 2016/11/19 (1.28.4) - Fixed tooltip flickering. /// - 2016/11/19 (1.28.4)- Fixed tooltip flickering
/// - 2016/11/19 (1.28.3) - Fixed memory leak caused by popup repeated closing. /// - 2016/11/19 (1.28.3)- Fixed memory leak caused by popup repeated closing
/// - 2016/11/18 (1.28.2) - Fixed memory leak caused by popup panel allocation. /// - 2016/11/18 (1.28.2)- Fixed memory leak caused by popup panel allocation
/// - 2016/11/10 (1.28.1) - Fixed some warnings and C++ error. /// - 2016/11/10 (1.28.1)- Fixed some warnings and C++ error
/// - 2016/11/10 (1.28.0)- Added additional `nk_button` versions which allows to directly /// - 2016/11/10 (1.28.0)- Added additional `nk_button` versions which allows to directly
/// pass in a style struct to change buttons visual. /// pass in a style struct to change buttons visual.
/// - 2016/11/10 (1.27.0) - Added additional `nk_tree` versions to support external state /// - 2016/11/10 (1.27.0)- Added additional 'nk_tree' versions to support external state
/// storage. Just like last the `nk_group` commit the main /// storage. Just like last the `nk_group` commit the main
/// advantage is that you optionally can minimize nuklears runtime /// advantage is that you optionally can minimize nuklears runtime
/// memory consumption or handle hash collisions. /// memory consumption or handle hash collisions.
@@ -25582,25 +25342,25 @@ nk_tooltipfv(struct nk_context *ctx, const char *fmt, va_list args)
/// want the name. In addition I added `nk_list_view` which allows /// want the name. In addition I added `nk_list_view` which allows
/// to draw big lists inside a group without actually having to /// to draw big lists inside a group without actually having to
/// commit the whole list to nuklear (issue #269). /// commit the whole list to nuklear (issue #269).
/// - 2016/10/30 (1.25.1) - Fixed clipping rectangle bug inside `nk_draw_list`. /// - 2016/10/30 (1.25.1)- Fixed clipping rectangle bug inside `nk_draw_list`
/// - 2016/10/29 (1.25.0)- Pulled `nk_panel` memory management into nuklear and out of /// - 2016/10/29 (1.25.0)- Pulled `nk_panel` memory management into nuklear and out of
/// the hands of the user. From now on users don't have to care /// the hands of the user. From now on users don't have to care
/// about panels unless they care about some information. If you /// about panels unless they care about some information. If you
/// still need the panel just call `nk_window_get_panel`. /// still need the panel just call `nk_window_get_panel`.
/// - 2016/10/21 (1.24.0)- Changed widget border drawing to stroked rectangle from filled /// - 2016/10/21 (1.24.0)- Changed widget border drawing to stroked rectangle from filled
/// rectangle for less overdraw and widget background transparency. /// rectangle for less overdraw and widget background transparency.
/// - 2016/10/18 (1.23.0) - Added `nk_edit_focus` for manually edit widget focus control. /// - 2016/10/18 (1.23.0)- Added `nk_edit_focus` for manually edit widget focus control
/// - 2016/09/29 (1.22.7) - Fixed deduction of basic type in non `<stdint.h>` compilation. /// - 2016/09/29 (1.22.7)- Fixed deduction of basic type in non `<stdint.h>` compilation
/// - 2016/09/29 (1.22.6) - Fixed edit widget UTF-8 text cursor drawing bug. /// - 2016/09/29 (1.22.6)- Fixed edit widget UTF-8 text cursor drawing bug
/// - 2016/09/28 (1.22.5) - Fixed edit widget UTF-8 text appending/inserting/removing. /// - 2016/09/28 (1.22.5)- Fixed edit widget UTF-8 text appending/inserting/removing
/// - 2016/09/28 (1.22.4)- Fixed drawing bug inside edit widgets which offset all text /// - 2016/09/28 (1.22.4)- Fixed drawing bug inside edit widgets which offset all text
/// text in every edit widget if one of them is scrolled. /// text in every edit widget if one of them is scrolled.
/// - 2016/09/28 (1.22.3)- Fixed small bug in edit widgets if not active. The wrong /// - 2016/09/28 (1.22.3)- Fixed small bug in edit widgets if not active. The wrong
/// text length is passed. It should have been in bytes but /// text length is passed. It should have been in bytes but
/// was passed as glyphes. /// was passed as glyphes.
/// - 2016/09/20 (1.22.2) - Fixed color button size calculation. /// - 2016/09/20 (1.22.2)- Fixed color button size calculation
/// - 2016/09/20 (1.22.1) - Fixed some `nk_vsnprintf` behavior bugs and removed `<stdio.h>` /// - 2016/09/20 (1.22.1)- Fixed some `nk_vsnprintf` behavior bugs and removed
/// again from `NK_INCLUDE_STANDARD_VARARGS`. /// `<stdio.h>` again from `NK_INCLUDE_STANDARD_VARARGS`.
/// - 2016/09/18 (1.22.0)- C89 does not support vsnprintf only C99 and newer as well /// - 2016/09/18 (1.22.0)- C89 does not support vsnprintf only C99 and newer as well
/// as C++11 and newer. In addition to use vsnprintf you have /// as C++11 and newer. In addition to use vsnprintf you have
/// to include <stdio.h>. So just defining `NK_INCLUDE_STD_VAR_ARGS` /// to include <stdio.h>. So just defining `NK_INCLUDE_STD_VAR_ARGS`
@@ -25608,14 +25368,14 @@ nk_tooltipfv(struct nk_context *ctx, const char *fmt, va_list args)
/// both varargs as well as stdio is selected I try to use /// both varargs as well as stdio is selected I try to use
/// vsnprintf if not possible I will revert to vsprintf. If /// vsnprintf if not possible I will revert to vsprintf. If
/// varargs but not stdio was defined I will use my own function. /// varargs but not stdio was defined I will use my own function.
/// - 2016/09/15 (1.21.2) - Fixed panel `close` behavior for deeper panel levels. /// - 2016/09/15 (1.21.2)- Fixed panel `close` behavior for deeper panel levels
/// - 2016/09/15 (1.21.1) - Fixed C++ errors and wrong argument to `nk_panel_get_xxxx`. /// - 2016/09/15 (1.21.1)- Fixed C++ errors and wrong argument to `nk_panel_get_xxxx`
/// - 2016/09/13 (1.21.0) - !BREAKING! Fixed nonblocking popup behavior in menu, combo, /// - 2016/09/13 (1.21.0) - !BREAKING! Fixed nonblocking popup behavior in menu, combo,
/// and contextual which prevented closing in y-direction if /// and contextual which prevented closing in y-direction if
/// popup did not reach max height. /// popup did not reach max height.
/// In addition the height parameter was changed into vec2 /// In addition the height parameter was changed into vec2
/// for width and height to have more control over the popup size. /// for width and height to have more control over the popup size.
/// - 2016/09/13 (1.20.3) - Cleaned up and extended type selection. /// - 2016/09/13 (1.20.3) - Cleaned up and extended type selection
/// - 2016/09/13 (1.20.2)- Fixed slider behavior hopefully for the last time. This time /// - 2016/09/13 (1.20.2)- Fixed slider behavior hopefully for the last time. This time
/// all calculation are correct so no more hackery. /// all calculation are correct so no more hackery.
/// - 2016/09/13 (1.20.1)- Internal change to divide window/panel flags into panel flags and types. /// - 2016/09/13 (1.20.1)- Internal change to divide window/panel flags into panel flags and types.
@@ -25638,17 +25398,17 @@ nk_tooltipfv(struct nk_context *ctx, const char *fmt, va_list args)
/// `NK_SYMBOL_CIRCLE_OUTLINE`. /// `NK_SYMBOL_CIRCLE_OUTLINE`.
/// - 2016/09/08 (1.16.0)- Added additional checks to select correct types if `NK_INCLUDE_FIXED_TYPES` /// - 2016/09/08 (1.16.0)- Added additional checks to select correct types if `NK_INCLUDE_FIXED_TYPES`
/// is not defined by supporting the biggest compiler GCC, clang and MSVC. /// is not defined by supporting the biggest compiler GCC, clang and MSVC.
/// - 2016/09/07 (1.15.3) - Fixed `NK_INCLUDE_COMMAND_USERDATA` define to not cause an error. /// - 2016/09/07 (1.15.3)- Fixed `NK_INCLUDE_COMMAND_USERDATA` define to not cause an error
/// - 2016/09/04 (1.15.2) - Fixed wrong combobox height calculation. /// - 2016/09/04 (1.15.2)- Fixed wrong combobox height calculation
/// - 2016/09/03 (1.15.1) - Fixed gaps inside combo boxes in OpenGL. /// - 2016/09/03 (1.15.1)- Fixed gaps inside combo boxes in OpenGL
/// - 2016/09/02 (1.15.0) - Changed nuklear to not have any default vertex layout and /// - 2016/09/02 (1.15.0) - Changed nuklear to not have any default vertex layout and
/// instead made it user provided. The range of types to convert /// instead made it user provided. The range of types to convert
/// to is quite limited at the moment, but I would be more than /// to is quite limited at the moment, but I would be more than
/// happy to accept PRs to add additional. /// happy to accept PRs to add additional.
/// - 2016/08/30 (1.14.2) - Removed unused variables. /// - 2016/08/30 (1.14.2) - Removed unused variables
/// - 2016/08/30 (1.14.1) - Fixed C++ build errors. /// - 2016/08/30 (1.14.1) - Fixed C++ build errors
/// - 2016/08/30 (1.14.0) - Removed mouse dragging from SDL demo since it does not work correctly. /// - 2016/08/30 (1.14.0) - Removed mouse dragging from SDL demo since it does not work correctly
/// - 2016/08/30 (1.13.4) - Tweaked some default styling variables. /// - 2016/08/30 (1.13.4) - Tweaked some default styling variables
/// - 2016/08/30 (1.13.3) - Hopefully fixed drawing bug in slider, in general I would /// - 2016/08/30 (1.13.3) - Hopefully fixed drawing bug in slider, in general I would
/// refrain from using slider with a big number of steps. /// refrain from using slider with a big number of steps.
/// - 2016/08/30 (1.13.2) - Fixed close and minimize button which would fire even if the /// - 2016/08/30 (1.13.2) - Fixed close and minimize button which would fire even if the
@@ -25658,28 +25418,28 @@ nk_tooltipfv(struct nk_context *ctx, const char *fmt, va_list args)
/// - 2016/08/30 (1.13.0) - Removed `NK_WINDOW_DYNAMIC` flag from public API since /// - 2016/08/30 (1.13.0) - Removed `NK_WINDOW_DYNAMIC` flag from public API since
/// it is bugged and causes issues in window selection. /// it is bugged and causes issues in window selection.
/// - 2016/08/30 (1.12.0) - Removed scaler size. The size of the scaler is now /// - 2016/08/30 (1.12.0) - Removed scaler size. The size of the scaler is now
/// determined by the scrollbar size. /// determined by the scrollbar size
/// - 2016/08/30 (1.11.2) - Fixed some drawing bugs caused by changes from 1.11.0. /// - 2016/08/30 (1.11.2) - Fixed some drawing bugs caused by changes from 1.11
/// - 2016/08/30 (1.11.1) - Fixed overlapping minimized window selection. /// - 2016/08/30 (1.11.1) - Fixed overlapping minimized window selection
/// - 2016/08/30 (1.11.0) - Removed some internal complexity and overly complex code /// - 2016/08/30 (1.11.0) - Removed some internal complexity and overly complex code
/// handling panel padding and panel border. /// handling panel padding and panel border.
/// - 2016/08/29 (1.10.0) - Added additional height parameter to `nk_combobox_xxx`. /// - 2016/08/29 (1.10.0) - Added additional height parameter to `nk_combobox_xxx`
/// - 2016/08/29 (1.10.0) - Fixed drawing bug in dynamic popups. /// - 2016/08/29 (1.10.0) - Fixed drawing bug in dynamic popups
/// - 2016/08/29 (1.10.0) - Added experimental mouse scrolling to popups, menus and comboboxes. /// - 2016/08/29 (1.10.0) - Added experimental mouse scrolling to popups, menus and comboboxes
/// - 2016/08/26 (1.10.0) - Added window name string prepresentation to account for /// - 2016/08/26 (1.10.0) - Added window name string prepresentation to account for
/// hash collisions. Currently limited to `NK_WINDOW_MAX_NAME` /// hash collisions. Currently limited to NK_WINDOW_MAX_NAME
/// which in term can be redefined if not big enough. /// which in term can be redefined if not big enough.
/// - 2016/08/26 (1.10.0) - Added stacks for temporary style/UI changes in code. /// - 2016/08/26 (1.10.0) - Added stacks for temporary style/UI changes in code
/// - 2016/08/25 (1.10.0) - Changed `nk_input_is_key_pressed` and 'nk_input_is_key_released' /// - 2016/08/25 (1.10.0) - Changed `nk_input_is_key_pressed` and 'nk_input_is_key_released'
/// to account for key press and release happening in one frame. /// to account for key press and release happening in one frame.
/// - 2016/08/25 (1.10.0) - Added additional nk_edit flag to directly jump to the end on activate. /// - 2016/08/25 (1.10.0) - Added additional nk_edit flag to directly jump to the end on activate
/// - 2016/08/17 (1.09.6) - Removed invalid check for value zero in `nk_propertyx`. /// - 2016/08/17 (1.09.6)- Removed invalid check for value zero in nk_propertyx
/// - 2016/08/16 (1.09.5)- Fixed ROM mode for deeper levels of popup windows parents. /// - 2016/08/16 (1.09.5)- Fixed ROM mode for deeper levels of popup windows parents.
/// - 2016/08/15 (1.09.4)- Editbox are now still active if enter was pressed with flag /// - 2016/08/15 (1.09.4)- Editbox are now still active if enter was pressed with flag
/// `NK_EDIT_SIG_ENTER`. Main reasoning is to be able to keep /// `NK_EDIT_SIG_ENTER`. Main reasoning is to be able to keep
/// typing after commiting. /// typing after commiting.
/// - 2016/08/15 (1.09.4) - Removed redundant code. /// - 2016/08/15 (1.09.4)- Removed redundant code
/// - 2016/08/15 (1.09.4) - Fixed negative numbers in `nk_strtoi` and remove unused variable. /// - 2016/08/15 (1.09.4)- Fixed negative numbers in `nk_strtoi` and remove unused variable
/// - 2016/08/15 (1.09.3)- Fixed `NK_WINDOW_BACKGROUND` flag behavior to select a background /// - 2016/08/15 (1.09.3)- Fixed `NK_WINDOW_BACKGROUND` flag behavior to select a background
/// window only as selected by hovering and not by clicking. /// window only as selected by hovering and not by clicking.
/// - 2016/08/14 (1.09.2)- Fixed a bug in font atlas which caused wrong loading /// - 2016/08/14 (1.09.2)- Fixed a bug in font atlas which caused wrong loading
@@ -25687,7 +25447,7 @@ nk_tooltipfv(struct nk_context *ctx, const char *fmt, va_list args)
/// - 2016/08/12 (1.09.1)- Added additional function to check if window is currently /// - 2016/08/12 (1.09.1)- Added additional function to check if window is currently
/// hidden and therefore not visible. /// hidden and therefore not visible.
/// - 2016/08/12 (1.09.1)- nk_window_is_closed now queries the correct flag `NK_WINDOW_CLOSED` /// - 2016/08/12 (1.09.1)- nk_window_is_closed now queries the correct flag `NK_WINDOW_CLOSED`
/// instead of the old flag `NK_WINDOW_HIDDEN`. /// instead of the old flag `NK_WINDOW_HIDDEN`
/// - 2016/08/09 (1.09.0) - Added additional double version to nk_property and changed /// - 2016/08/09 (1.09.0) - Added additional double version to nk_property and changed
/// the underlying implementation to not cast to float and instead /// the underlying implementation to not cast to float and instead
/// work directly on the given values. /// work directly on the given values.
@@ -25697,7 +25457,7 @@ nk_tooltipfv(struct nk_context *ctx, const char *fmt, va_list args)
/// - 2016/08/09 (1.08.0) - Added additional define to overwrite library internal /// - 2016/08/09 (1.08.0) - Added additional define to overwrite library internal
/// string to floating point number conversion for additional /// string to floating point number conversion for additional
/// precision. /// precision.
/// - 2016/08/08 (1.07.2) - Fixed compiling error without define `NK_INCLUDE_FIXED_TYPE`. /// - 2016/08/08 (1.07.2)- Fixed compiling error without define NK_INCLUDE_FIXED_TYPE
/// - 2016/08/08 (1.07.1)- Fixed possible floating point error inside `nk_widget` leading /// - 2016/08/08 (1.07.1)- Fixed possible floating point error inside `nk_widget` leading
/// to wrong wiget width calculation which results in widgets falsly /// to wrong wiget width calculation which results in widgets falsly
/// becomming tagged as not inside window and cannot be accessed. /// becomming tagged as not inside window and cannot be accessed.
@@ -25709,31 +25469,31 @@ nk_tooltipfv(struct nk_context *ctx, const char *fmt, va_list args)
/// remain. /// remain.
/// - 2016/08/08 (1.06.0) - Added `nk_edit_string_zero_terminated` as a second option to /// - 2016/08/08 (1.06.0) - Added `nk_edit_string_zero_terminated` as a second option to
/// `nk_edit_string` which takes, edits and outputs a '\0' terminated string. /// `nk_edit_string` which takes, edits and outputs a '\0' terminated string.
/// - 2016/08/08 (1.05.4) - Fixed scrollbar auto hiding behavior. /// - 2016/08/08 (1.05.4)- Fixed scrollbar auto hiding behavior
/// - 2016/08/08 (1.05.3) - Fixed wrong panel padding selection in `nk_layout_widget_space`. /// - 2016/08/08 (1.05.3)- Fixed wrong panel padding selection in `nk_layout_widget_space`
/// - 2016/08/07 (1.05.2)- Fixed old bug in dynamic immediate mode layout API, calculating /// - 2016/08/07 (1.05.2)- Fixed old bug in dynamic immediate mode layout API, calculating
/// wrong item spacing and panel width. /// wrong item spacing and panel width.
/// - 2016/08/07 (1.05.1) - Hopefully finally fixed combobox popup drawing bug. ///- 2016/08/07 (1.05.1)- Hopefully finally fixed combobox popup drawing bug
/// - 2016/08/07 (1.05.0) - Split varargs away from `NK_INCLUDE_STANDARD_IO` into own ///- 2016/08/07 (1.05.0) - Split varargs away from NK_INCLUDE_STANDARD_IO into own
/// define `NK_INCLUDE_STANDARD_VARARGS` to allow more fine /// define NK_INCLUDE_STANDARD_VARARGS to allow more fine
/// grained controlled over library includes. /// grained controlled over library includes.
/// - 2016/08/06 (1.04.5) - Changed memset calls to `NK_MEMSET`. /// - 2016/08/06 (1.04.5)- Changed memset calls to NK_MEMSET
/// - 2016/08/04 (1.04.4) - Fixed fast window scaling behavior. /// - 2016/08/04 (1.04.4)- Fixed fast window scaling behavior
/// - 2016/08/04 (1.04.3)- Fixed window scaling, movement bug which appears if you /// - 2016/08/04 (1.04.3)- Fixed window scaling, movement bug which appears if you
/// move/scale a window and another window is behind it. /// move/scale a window and another window is behind it.
/// If you are fast enough then the window behind gets activated /// If you are fast enough then the window behind gets activated
/// and the operation is blocked. I now require activating /// and the operation is blocked. I now require activating
/// by hovering only if mouse is not pressed. /// by hovering only if mouse is not pressed.
/// - 2016/08/04 (1.04.2) - Fixed changing fonts. /// - 2016/08/04 (1.04.2)- Fixed changing fonts
/// - 2016/08/03 (1.04.1) - Fixed `NK_WINDOW_BACKGROUND` behavior. /// - 2016/08/03 (1.04.1)- Fixed `NK_WINDOW_BACKGROUND` behavior
/// - 2016/08/03 (1.04.0) - Added color parameter to `nk_draw_image`. /// - 2016/08/03 (1.04.0) - Added color parameter to `nk_draw_image`
/// - 2016/08/03 (1.04.0) - Added additional window padding style attributes for /// - 2016/08/03 (1.04.0) - Added additional window padding style attributes for
/// sub windows (combo, menu, ...). /// sub windows (combo, menu, ...)
/// - 2016/08/03 (1.04.0) - Added functions to show/hide software cursor. /// - 2016/08/03 (1.04.0) - Added functions to show/hide software cursor
/// - 2016/08/03 (1.04.0) - Added `NK_WINDOW_BACKGROUND` flag to force a window /// - 2016/08/03 (1.04.0) - Added `NK_WINDOW_BACKGROUND` flag to force a window
/// to be always in the background of the screen. /// to be always in the background of the screen
/// - 2016/08/03 (1.03.2) - Removed invalid assert macro for NK_RGB color picker. /// - 2016/08/03 (1.03.2)- Removed invalid assert macro for NK_RGB color picker
/// - 2016/08/01 (1.03.1) - Added helper macros into header include guard. /// - 2016/08/01 (1.03.1)- Added helper macros into header include guard
/// - 2016/07/29 (1.03.0) - Moved the window/table pool into the header part to /// - 2016/07/29 (1.03.0) - Moved the window/table pool into the header part to
/// simplify memory management by removing the need to /// simplify memory management by removing the need to
/// allocate the pool. /// allocate the pool.
@@ -25741,15 +25501,16 @@ nk_tooltipfv(struct nk_context *ctx, const char *fmt, va_list args)
/// will hide the window scrollbar after NK_SCROLLBAR_HIDING_TIMEOUT /// will hide the window scrollbar after NK_SCROLLBAR_HIDING_TIMEOUT
/// seconds without window interaction. To make it work /// seconds without window interaction. To make it work
/// you have to also set a delta time inside the `nk_context`. /// you have to also set a delta time inside the `nk_context`.
/// - 2016/07/25 (1.01.1) - Fixed small panel and panel border drawing bugs. /// - 2016/07/25 (1.01.1) - Fixed small panel and panel border drawing bugs
/// - 2016/07/15 (1.01.0) - Added software cursor to `nk_style` and `nk_context`. /// - 2016/07/15 (1.01.0) - Added software cursor to `nk_style` and `nk_context`
/// - 2016/07/15 (1.01.0) - Added const correctness to `nk_buffer_push' data argument. /// - 2016/07/15 (1.01.0) - Added const correctness to `nk_buffer_push' data argument
/// - 2016/07/15 (1.01.0) - Removed internal font baking API and simplified /// - 2016/07/15 (1.01.0) - Removed internal font baking API and simplified
/// font atlas memory management by converting pointer /// font atlas memory management by converting pointer
/// arrays for fonts and font configurations to lists. /// arrays for fonts and font configurations to lists.
/// - 2016/07/15 (1.00.0) - Changed button API to use context dependend button /// - 2016/07/15 (1.00.0) - Changed button API to use context dependend button
/// behavior instead of passing it for every function call. /// behavior instead of passing it for every function call.
/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/// ## Gallery /// ## Gallery
/// ![Figure [blue]: Feature overview with blue color styling](https://cloud.githubusercontent.com/assets/8057201/13538240/acd96876-e249-11e5-9547-5ac0b19667a0.png) /// ![Figure [blue]: Feature overview with blue color styling](https://cloud.githubusercontent.com/assets/8057201/13538240/acd96876-e249-11e5-9547-5ac0b19667a0.png)
/// ![Figure [red]: Feature overview with red color styling](https://cloud.githubusercontent.com/assets/8057201/13538243/b04acd4c-e249-11e5-8fd2-ad7744a5b446.png) /// ![Figure [red]: Feature overview with red color styling](https://cloud.githubusercontent.com/assets/8057201/13538243/b04acd4c-e249-11e5-8fd2-ad7744a5b446.png)
+4 -4
View File
@@ -230,7 +230,7 @@ nk_glfw3_mouse_button_callback(GLFWwindow* window, int button, int action, int m
} }
NK_INTERN void NK_INTERN void
nk_glfw3_clipboard_paste(nk_handle usr, struct nk_text_edit *edit) nk_glfw3_clipbard_paste(nk_handle usr, struct nk_text_edit *edit)
{ {
const char *text = glfwGetClipboardString(glfw.win); const char *text = glfwGetClipboardString(glfw.win);
if (text) nk_textedit_paste(edit, text, nk_strlen(text)); if (text) nk_textedit_paste(edit, text, nk_strlen(text));
@@ -238,7 +238,7 @@ nk_glfw3_clipboard_paste(nk_handle usr, struct nk_text_edit *edit)
} }
NK_INTERN void NK_INTERN void
nk_glfw3_clipboard_copy(nk_handle usr, const char *text, int len) nk_glfw3_clipbard_copy(nk_handle usr, const char *text, int len)
{ {
char *str = 0; char *str = 0;
(void)usr; (void)usr;
@@ -261,8 +261,8 @@ nk_glfw3_init(GLFWwindow *win, enum nk_glfw_init_state init_state)
glfwSetMouseButtonCallback(win, nk_glfw3_mouse_button_callback); glfwSetMouseButtonCallback(win, nk_glfw3_mouse_button_callback);
} }
nk_init_default(&glfw.ctx, 0); nk_init_default(&glfw.ctx, 0);
glfw.ctx.clip.copy = nk_glfw3_clipboard_copy; glfw.ctx.clip.copy = nk_glfw3_clipbard_copy;
glfw.ctx.clip.paste = nk_glfw3_clipboard_paste; glfw.ctx.clip.paste = nk_glfw3_clipbard_paste;
glfw.ctx.clip.userdata = nk_handle_ptr(0); glfw.ctx.clip.userdata = nk_handle_ptr(0);
nk_buffer_init_default(&glfw.ogl.cmds); nk_buffer_init_default(&glfw.ogl.cmds);
+1 -1
View File
@@ -4,7 +4,7 @@
src/wl_* @linkmauve src/wl_* @linkmauve
docs/*.css @glfw/webdev docs/*.css @glfw/webdev
docs/*.scss @glfw/webdev docs/*.less @glfw/webdev
docs/*.html @glfw/webdev docs/*.html @glfw/webdev
docs/*.xml @glfw/webdev docs/*.xml @glfw/webdev
+930 -1600
View File
File diff suppressed because it is too large Load Diff
+20 -23
View File
@@ -25,41 +25,39 @@ GLFW.
#include <GLFW/glfw3.h> #include <GLFW/glfw3.h>
@endcode @endcode
This header defines all the constants and declares all the types and function This header declares the GLFW API and by default also includes the OpenGL header
prototypes of the GLFW API. By default it also includes the OpenGL header from from your development environment. See below for how to control this.
your development environment. See [option macros](@ref build_macros) below for
how to select OpenGL ES headers and more.
The GLFW header also defines any platform-specific macros needed by your OpenGL The GLFW header also defines any platform-specific macros needed by your OpenGL
header, so that it can be included without needing any window system headers. header, so it can be included without needing any window system headers.
It does this only when needed, so if window system headers are included, the For example, under Windows you are normally required to include `windows.h`
GLFW header does not try to redefine those symbols. The reverse is not true, before the OpenGL header, which would bring in the whole Win32 API. The GLFW
i.e. `windows.h` cannot cope if any Win32 symbols have already been defined. header duplicates the small number of macros needed.
It does this only when needed, so if `windows.h` _is_ included, the GLFW header
does not try to redefine those symbols. The reverse is not true, i.e.
`windows.h` cannot cope if any of its symbols have already been defined.
In other words: In other words:
- Use the GLFW header to include OpenGL or OpenGL ES headers portably - Do _not_ include the OpenGL headers yourself, as GLFW does this for you
- Do not include window system headers unless you will use those APIs directly - Do _not_ include `windows.h` or other platform-specific headers unless you
- If you do need such headers, include them before the GLFW header plan on using those APIs directly
- If you _do_ need to include such headers, do it _before_ including
the GLFW header and it will handle this
If you are using an OpenGL extension loading library such as If you are using an OpenGL extension loading library such as
[glad](https://github.com/Dav1dde/glad), the extension loader header should [glad](https://github.com/Dav1dde/glad), the extension loader header should
be included before the GLFW one. GLFW attempts to detect any OpenGL or OpenGL be included _before_ the GLFW one.
ES header or extension loader header included before it and will then disable
the inclusion of the default OpenGL header. Most extension loaders also define
macros that disable similar headers below it.
@code @code
#include <glad/gl.h> #include <glad/gl.h>
#include <GLFW/glfw3.h> #include <GLFW/glfw3.h>
@endcode @endcode
Both of these mechanisms depend on the extension loader header defining a known Alternatively the @ref GLFW_INCLUDE_NONE macro (described below) can be used to
macro. If yours doesn't or you don't know which one your users will pick, the prevent the GLFW header from including the OpenGL header.
@ref GLFW_INCLUDE_NONE macro will explicitly to prevent the GLFW header from
including the OpenGL header. This will also allow you to include the two
headers in any order.
@code @code
#define GLFW_INCLUDE_NONE #define GLFW_INCLUDE_NONE
@@ -107,7 +105,7 @@ __GLFW_INCLUDE_ES31__ makes the GLFW header include the OpenGL ES 3.1
`GLES3/gl31.h` header instead of the regular OpenGL header. `GLES3/gl31.h` header instead of the regular OpenGL header.
@anchor GLFW_INCLUDE_ES32 @anchor GLFW_INCLUDE_ES32
__GLFW_INCLUDE_ES32__ makes the GLFW header include the OpenGL ES 3.2 __GLFW_INCLUDE_ES31__ makes the GLFW header include the OpenGL ES 3.2
`GLES3/gl32.h` header instead of the regular OpenGL header. `GLES3/gl32.h` header instead of the regular OpenGL header.
@anchor GLFW_INCLUDE_NONE @anchor GLFW_INCLUDE_NONE
@@ -115,8 +113,7 @@ __GLFW_INCLUDE_NONE__ makes the GLFW header not include any OpenGL or OpenGL ES
API header. This is useful in combination with an extension loading library. API header. This is useful in combination with an extension loading library.
If none of the above inclusion macros are defined, the standard OpenGL `GL/gl.h` If none of the above inclusion macros are defined, the standard OpenGL `GL/gl.h`
header (`OpenGL/gl.h` on macOS) is included, unless GLFW detects the inclusion header (`OpenGL/gl.h` on macOS) is included.
guards of any OpenGL, OpenGL ES or extension loader header it knows about.
The following macros control the inclusion of additional API headers. Any The following macros control the inclusion of additional API headers. Any
number of these may be defined simultaneously, and/or together with one of the number of these may be defined simultaneously, and/or together with one of the
+10 -8
View File
@@ -163,9 +163,10 @@ multisampling anti-aliasing. Where this extension is unavailable, the
GLFW uses the `GLX_ARB_create_context` extension when available, even when GLFW uses the `GLX_ARB_create_context` extension when available, even when
creating OpenGL contexts of version 2.1 and below. Where this extension is creating OpenGL contexts of version 2.1 and below. Where this extension is
unavailable, the `GLFW_CONTEXT_VERSION_MAJOR` and `GLFW_CONTEXT_VERSION_MINOR` unavailable, the `GLFW_CONTEXT_VERSION_MAJOR` and `GLFW_CONTEXT_VERSION_MINOR`
hints will only be partially supported, the `GLFW_CONTEXT_DEBUG` hint will have hints will only be partially supported, the `GLFW_OPENGL_DEBUG_CONTEXT` hint
no effect, and setting the `GLFW_OPENGL_PROFILE` or `GLFW_OPENGL_FORWARD_COMPAT` will have no effect, and setting the `GLFW_OPENGL_PROFILE` or
hints to `GLFW_TRUE` will cause @ref glfwCreateWindow to fail. `GLFW_OPENGL_FORWARD_COMPAT` hints to `GLFW_TRUE` will cause @ref
glfwCreateWindow to fail.
GLFW uses the `GLX_ARB_create_context_profile` extension to provide support for GLFW uses the `GLX_ARB_create_context_profile` extension to provide support for
context profiles. Where this extension is unavailable, setting the context profiles. Where this extension is unavailable, setting the
@@ -205,9 +206,10 @@ unavailable, the `GLFW_SAMPLES` hint will have no effect.
GLFW uses the `WGL_ARB_create_context` extension when available, even when GLFW uses the `WGL_ARB_create_context` extension when available, even when
creating OpenGL contexts of version 2.1 and below. Where this extension is creating OpenGL contexts of version 2.1 and below. Where this extension is
unavailable, the `GLFW_CONTEXT_VERSION_MAJOR` and `GLFW_CONTEXT_VERSION_MINOR` unavailable, the `GLFW_CONTEXT_VERSION_MAJOR` and `GLFW_CONTEXT_VERSION_MINOR`
hints will only be partially supported, the `GLFW_CONTEXT_DEBUG` hint will have hints will only be partially supported, the `GLFW_OPENGL_DEBUG_CONTEXT` hint
no effect, and setting the `GLFW_OPENGL_PROFILE` or `GLFW_OPENGL_FORWARD_COMPAT` will have no effect, and setting the `GLFW_OPENGL_PROFILE` or
hints to `GLFW_TRUE` will cause @ref glfwCreateWindow to fail. `GLFW_OPENGL_FORWARD_COMPAT` hints to `GLFW_TRUE` will cause @ref
glfwCreateWindow to fail.
GLFW uses the `WGL_ARB_create_context_profile` extension to provide support for GLFW uses the `WGL_ARB_create_context_profile` extension to provide support for
context profiles. Where this extension is unavailable, setting the context profiles. Where this extension is unavailable, setting the
@@ -237,13 +239,13 @@ Because of this, on OS X 10.7 and later, the `GLFW_CONTEXT_VERSION_MAJOR` and
`GLFW_CONTEXT_VERSION_MINOR` hints will cause @ref glfwCreateWindow to fail if `GLFW_CONTEXT_VERSION_MINOR` hints will cause @ref glfwCreateWindow to fail if
given version 3.0 or 3.1. The `GLFW_OPENGL_PROFILE` hint must be set to given version 3.0 or 3.1. The `GLFW_OPENGL_PROFILE` hint must be set to
`GLFW_OPENGL_CORE_PROFILE` when creating OpenGL 3.2 and later contexts. The `GLFW_OPENGL_CORE_PROFILE` when creating OpenGL 3.2 and later contexts. The
`GLFW_CONTEXT_DEBUG` and `GLFW_CONTEXT_NO_ERROR` hints are ignored. `GLFW_OPENGL_DEBUG_CONTEXT` and `GLFW_CONTEXT_NO_ERROR` hints are ignored.
Also, on Mac OS X 10.6 and below, the `GLFW_CONTEXT_VERSION_MAJOR` and Also, on Mac OS X 10.6 and below, the `GLFW_CONTEXT_VERSION_MAJOR` and
`GLFW_CONTEXT_VERSION_MINOR` hints will fail if given a version above 2.1, `GLFW_CONTEXT_VERSION_MINOR` hints will fail if given a version above 2.1,
setting the `GLFW_OPENGL_PROFILE` or `GLFW_OPENGL_FORWARD_COMPAT` hints to setting the `GLFW_OPENGL_PROFILE` or `GLFW_OPENGL_FORWARD_COMPAT` hints to
a non-default value will cause @ref glfwCreateWindow to fail and the a non-default value will cause @ref glfwCreateWindow to fail and the
`GLFW_CONTEXT_DEBUG` hint is ignored. `GLFW_OPENGL_DEBUG_CONTEXT` hint is ignored.
@section compat_vulkan Vulkan loader and API @section compat_vulkan Vulkan loader and API
+2 -1
View File
@@ -103,7 +103,8 @@ To compile GLFW for Wayland, you need to have the Wayland packages installed,
as well as the basic development tools like GCC and make. For example, on as well as the basic development tools like GCC and make. For example, on
Ubuntu and other distributions based on Debian GNU/Linux, you need to install Ubuntu and other distributions based on Debian GNU/Linux, you need to install
the `libwayland-dev` package, which contains all Wayland headers and pulls in the `libwayland-dev` package, which contains all Wayland headers and pulls in
wayland-scanner, as well as the `wayland-protocols` package. wayland-scanner, as well as the `wayland-protocols` and `extra-cmake-modules`
packages.
Once you have installed the necessary packages, move on to @ref Once you have installed the necessary packages, move on to @ref
compile_generate. compile_generate.
+1 -1
View File
File diff suppressed because one or more lines are too long
-1
View File
@@ -1 +0,0 @@
{"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"}
+79 -95
View File
@@ -1,79 +1,79 @@
// NOTE: Please use this file to perform modifications on default style sheets. // NOTE: Please use this file to perform modifications on default style sheets.
// //
// You need to install the official Sass CLI tool: // You need to install a few Ruby gems to generate extra.css from this file:
// npm install -g sass // gem install less therubyracer
// //
// Run this command to regenerate extra.css after you're finished with changes: // Run this command to regenerate extra.css after you're finished with changes:
// sass --style=compressed extra.scss extra.css // lessc --compress extra.less > extra.css
// //
// Alternatively you can use online services to regenerate extra.css. // Alternatively you can use online services to regenerate extra.css.
// Default text color for page contents // Default text color for page contents
$default-text-color: hsl(0,0%,30%); @default-text-color: hsl(0,0%,30%);
// Page header, footer, table rows, inline codes and definition lists // Page header, footer, table rows, inline codes and definition lists
$header-footer-background-color: hsl(0,0%,95%); @header-footer-background-color: hsl(0,0%,95%);
// Page header, footer links and navigation bar background // Page header, footer links and navigation bar background
$header-footer-link-color: hsl(0,0%,40%); @header-footer-link-color: hsl(0,0%,40%);
// Doxygen navigation bar links // Doxygen navigation bar links
$navbar-link-color: $header-footer-background-color; @navbar-link-color: @header-footer-background-color;
// Page content background color // Page content background color
$content-background-color: hsl(0,0%,100%); @content-background-color: hsl(0,0%,100%);
// Bold, italic, h1, h2, ... and table of contents // Bold, italic, h1, h2, ... and table of contents
$heading-color: hsl(0,0%,10%); @heading-color: hsl(0,0%,10%);
// Function, enum and macro definition separator // Function, enum and macro definition separator
$def-separator-color: $header-footer-background-color; @def-separator-color: @header-footer-background-color;
// Base color hue // Base color hue
$base-hue: 24; @base-hue: 24;
// Default color used for links // Default color used for links
$default-link-color: hsl($base-hue,100%,50%); @default-link-color: hsl(@base-hue,100%,50%);
// Doxygen navigation bar active tab // Doxygen navigation bar active tab
$tab-text-color: hsl(0,0%,100%); @tab-text-color: hsl(0,0%,100%);
$tab-background-color1: $default-link-color; @tab-background-color1: @default-link-color;
$tab-background-color2: lighten(adjust-hue($tab-background-color1, 10), 10%); @tab-background-color2: lighten(spin(@tab-background-color1, 10), 10%);
// Table borders // Table borders
$default-border-color: $default-link-color; @default-border-color: @default-link-color;
// Table header // Table header
$table-text-color: $tab-text-color; @table-text-color: @tab-text-color;
$table-background-color1: $tab-background-color1; @table-background-color1: @tab-background-color1;
$table-background-color2: $tab-background-color2; @table-background-color2: @tab-background-color2;
// Table of contents, data structure index and prototypes // Table of contents, data structure index and prototypes
$toc-background-color1: hsl(0,0%,90%); @toc-background-color1: hsl(0,0%,90%);
$toc-background-color2: lighten($toc-background-color1, 5%); @toc-background-color2: lighten(@toc-background-color1, 5%);
// Function prototype parameters color // Function prototype parameters color
$prototype-param-color: darken($default-link-color, 25%); @prototype-param-color: darken(@default-link-color, 25%);
// Message box color: note, pre, post and invariant // Message box color: note, pre, post and invariant
$box-note-color: hsl(103,80%,85%); @box-note-color: hsl(103,80%,85%);
// Message box color: warning and attention // Message box color: warning and attention
$box-warning-color: hsl(34,80%,85%); @box-warning-color: hsl(34,80%,85%);
// Message box color: deprecated and bug // Message box color: deprecated and bug
$box-bug-color: hsl(333,80%,85%); @box-bug-color: hsl(333,80%,85%);
// Message box color: todo and test // Message box color: todo and test
$box-todo-color: hsl(200,80%,85%); @box-todo-color: hsl(200,80%,85%);
// Message box helper function // Message box helper function
@mixin message-box($base-color){ .message-box(@base-color) {
background:linear-gradient(to bottom,lighten($base-color, 5%) 0%,$base-color 100%); background:linear-gradient(to bottom,lighten(@base-color, 5%) 0%,@base-color 100%);
box-shadow:inset 0 0 32px darken($base-color, 5%); box-shadow:inset 0 0 32px darken(@base-color, 5%);
color:darken($base-color, 67%); color:darken(@base-color, 67%);
border:2px solid desaturate(darken($base-color, 10%), 20%); border:2px solid desaturate(darken(@base-color, 10%), 20%);
} }
.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 { .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 {
@@ -82,24 +82,24 @@ $box-todo-color: hsl(200,80%,85%);
} }
.sm-dox a span.sub-arrow { .sm-dox a span.sub-arrow {
border-color:$navbar-link-color transparent transparent transparent; border-color:@navbar-link-color 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 { .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:$default-link-color transparent transparent transparent; border-color:@default-link-color 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 { .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 $default-link-color; border-color:transparent transparent transparent @default-link-color;
} }
.sm-dox ul a:hover { .sm-dox ul a:hover {
background:$header-footer-link-color; background:@header-footer-link-color;
text-shadow:none; text-shadow:none;
} }
.sm-dox ul.sm-nowrap a { .sm-dox ul.sm-nowrap a {
color:$default-text-color; color:@default-text-color;
text-shadow:none; text-shadow:none;
} }
@@ -128,15 +128,15 @@ div.headertitle,.note code,.pre code,.post code,.invariant code,.warning code,.a
} }
html,#titlearea,.footer,tr.even,.directory tr.even,.doxtable tr:nth-child(even),tr.markdownTableBody:nth-child(even),.mdescLeft,.mdescRight,.memItemLeft,.memItemRight,code,.markdownTableRowEven { 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:$header-footer-background-color; background:@header-footer-background-color;
} }
body { body {
color:$default-text-color; color:@default-text-color;
} }
h1,h2,h2.groupheader,h3,div.toc h3,h4,h5,h6,strong,em { h1,h2,h2.groupheader,h3,div.toc h3,h4,h5,h6,strong,em {
color:$heading-color; color:@heading-color;
border-bottom:none; border-bottom:none;
} }
@@ -159,30 +159,24 @@ h3 {
.glfwheader { .glfwheader {
font-size:16px; font-size:16px;
min-height:64px; height:64px;
max-width:920px; max-width:920px;
min-width:800px;
padding:0 32px; padding:0 32px;
margin:0 auto; margin:0 auto;
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: flex-start;
align-items: center;
align-content: stretch;
} }
#glfwhome { #glfwhome {
line-height:64px; line-height:64px;
padding-right:48px; padding-right:48px;
color:$header-footer-link-color; color:@header-footer-link-color;
font-size:2.5em; font-size:2.5em;
background:url("https://www.glfw.org/css/arrow.png") no-repeat right; background:url("https://www.glfw.org/css/arrow.png") no-repeat right;
} }
.glfwnavbar { .glfwnavbar {
list-style-type:none; list-style-type:none;
margin:0 0 0 auto; margin:0 auto;
float:right; float:right;
} }
@@ -194,11 +188,7 @@ h3 {
line-height:64px; line-height:64px;
margin-left:2em; margin-left:2em;
display:block; display:block;
color:$header-footer-link-color; color:@header-footer-link-color;
}
.glfwnavbar {
padding-left: 0;
} }
#glfwhome,.glfwnavbar a,.glfwnavbar a:visited { #glfwhome,.glfwnavbar a,.glfwnavbar a:visited {
@@ -206,7 +196,7 @@ h3 {
} }
#titlearea,.footer { #titlearea,.footer {
color:$header-footer-link-color; color:@header-footer-link-color;
} }
address.footer { address.footer {
@@ -216,17 +206,19 @@ address.footer {
} }
#top { #top {
background:$header-footer-link-color; background:@header-footer-link-color;
} }
#main-nav { #main-nav {
max-width:960px; max-width:960px;
min-width:800px;
margin:0 auto; margin:0 auto;
font-size:13px; font-size:13px;
} }
#main-menu { #main-menu {
max-width:920px; max-width:920px;
min-width:800px;
margin:0 auto; margin:0 auto;
font-size:13px; font-size:13px;
} }
@@ -241,29 +233,21 @@ address.footer {
} }
#main-menu { #main-menu {
min-height:36px; height:36px;
display: flex; display:block;
flex-direction: row; position:relative;
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 { #main-menu a,#main-menu a:visited,#main-menu a:hover,#main-menu li {
color:$navbar-link-color; color:@navbar-link-color;
} }
#main-menu li ul.sm-nowrap li a { #main-menu li ul.sm-nowrap li a {
color:$default-text-color; color:@default-text-color;
} }
#main-menu li ul.sm-nowrap li a:hover { #main-menu li ul.sm-nowrap li a:hover {
color:$default-link-color; color:@default-link-color;
}
#main-menu > li:last-child {
margin: 0 0 0 auto;
} }
.contents { .contents {
@@ -274,22 +258,22 @@ div.contents,div.header {
max-width:920px; max-width:920px;
margin:0 auto; margin:0 auto;
padding:0 32px; padding:0 32px;
background:$content-background-color none; background:@content-background-color none;
} }
table.doxtable th,table.markdownTable th,dl.reflist dt { table.doxtable th,table.markdownTable th,dl.reflist dt {
background:linear-gradient(to bottom,$table-background-color2 0%,$table-background-color1 100%); background:linear-gradient(to bottom,@table-background-color2 0%,@table-background-color1 100%);
box-shadow:inset 0 0 32px $table-background-color1; box-shadow:inset 0 0 32px @table-background-color1;
text-shadow:0 -1px 1px darken($table-background-color1, 15%); text-shadow:0 -1px 1px darken(@table-background-color1, 15%);
text-align:left; text-align:left;
color:$table-text-color; color:@table-text-color;
} }
dl.reflist dt a.el { dl.reflist dt a.el {
color:$default-link-color; color:@default-link-color;
padding:.2em; padding:.2em;
border-radius:4px; border-radius:4px;
background-color:lighten($default-link-color, 40%); background-color:lighten(@default-link-color, 40%);
} }
div.toc { div.toc {
@@ -312,27 +296,27 @@ div.toc li {
} }
div.toc,.memproto,div.qindex,div.ah { div.toc,.memproto,div.qindex,div.ah {
background:linear-gradient(to bottom,$toc-background-color2 0%,$toc-background-color1 100%); background:linear-gradient(to bottom,@toc-background-color2 0%,@toc-background-color1 100%);
box-shadow:inset 0 0 32px $toc-background-color1; box-shadow:inset 0 0 32px @toc-background-color1;
text-shadow:0 1px 1px lighten($toc-background-color2, 10%); text-shadow:0 1px 1px lighten(@toc-background-color2, 10%);
color:$heading-color; color:@heading-color;
border:2px solid $toc-background-color1; border:2px solid @toc-background-color1;
border-radius:4px; border-radius:4px;
} }
.paramname { .paramname {
color:$prototype-param-color; color:@prototype-param-color;
} }
dl.reflist dt { dl.reflist dt {
border:2px solid $default-border-color; border:2px solid @default-border-color;
border-top-left-radius:4px; border-top-left-radius:4px;
border-top-right-radius:4px; border-top-right-radius:4px;
border-bottom:none; border-bottom:none;
} }
dl.reflist dd { dl.reflist dd {
border:2px solid $default-border-color; border:2px solid @default-border-color;
border-bottom-right-radius:4px; border-bottom-right-radius:4px;
border-bottom-left-radius:4px; border-bottom-left-radius:4px;
border-top:none; border-top:none;
@@ -341,41 +325,41 @@ dl.reflist dd {
table.doxtable,table.markdownTable { table.doxtable,table.markdownTable {
border-collapse:inherit; border-collapse:inherit;
border-spacing:0; border-spacing:0;
border:2px solid $default-border-color; border:2px solid @default-border-color;
border-radius:4px; 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 { 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:$default-link-color; color:@default-link-color;
text-decoration:none; text-decoration:none;
} }
div.directory { div.directory {
border-collapse:inherit; border-collapse:inherit;
border-spacing:0; border-spacing:0;
border:2px solid $default-border-color; border:2px solid @default-border-color;
border-radius:4px; border-radius:4px;
} }
hr,.memSeparator { hr,.memSeparator {
height:2px; height:2px;
background:linear-gradient(to right,$def-separator-color 0%,darken($def-separator-color, 10%) 50%,$def-separator-color 100%); background:linear-gradient(to right,@def-separator-color 0%,darken(@def-separator-color, 10%) 50%,@def-separator-color 100%);
} }
dl.note,dl.pre,dl.post,dl.invariant { dl.note,dl.pre,dl.post,dl.invariant {
@include message-box($box-note-color); .message-box(@box-note-color);
} }
dl.warning,dl.attention { dl.warning,dl.attention {
@include message-box($box-warning-color); .message-box(@box-warning-color);
} }
dl.deprecated,dl.bug { dl.deprecated,dl.bug {
@include message-box($box-bug-color); .message-box(@box-bug-color);
} }
dl.todo,dl.test { dl.todo,dl.test {
@include message-box($box-todo-color); .message-box(@box-todo-color);
} }
dl.note,dl.pre,dl.post,dl.invariant,dl.warning,dl.attention,dl.deprecated,dl.bug,dl.todo,dl.test { dl.note,dl.pre,dl.post,dl.invariant,dl.warning,dl.attention,dl.deprecated,dl.bug,dl.todo,dl.test {
@@ -404,7 +388,7 @@ div.fragment,pre.fragment {
} }
.lineno a,.lineno a:visited,.line,pre.fragment { .lineno a,.lineno a:visited,.line,pre.fragment {
color:$default-text-color; color:@default-text-color;
} }
span.preprocessor,span.comment { span.preprocessor,span.comment {
@@ -416,7 +400,7 @@ a.code,a.code:visited {
} }
span.keyword,span.keywordtype,span.keywordflow { span.keyword,span.keywordtype,span.keywordflow {
color:darken($default-text-color, 5%); color:darken(@default-text-color, 5%);
font-weight:bold; font-weight:bold;
} }
+2 -3
View File
@@ -1,8 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en"> <html xmlns="http://www.w3.org/1999/xhtml">
<head> <head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=9"/> <meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen $doxygenversion"/> <meta name="generator" content="Doxygen $doxygenversion"/>
<!--BEGIN PROJECT_NAME--><title>$projectname: $title</title><!--END PROJECT_NAME--> <!--BEGIN PROJECT_NAME--><title>$projectname: $title</title><!--END PROJECT_NAME-->
+31 -5
View File
@@ -230,6 +230,32 @@ specified key is `GLFW_KEY_UNKNOWN` then the scancode is used, otherwise it is
ignored. This matches the behavior of the key callback, meaning the callback ignored. This matches the behavior of the key callback, meaning the callback
arguments can always be passed unmodified to this function. arguments can always be passed unmodified to this function.
The name of a key will not change unless the keyboard layout changes.
@subsection keyboard_layout Keyboard layout
The human-readable name of the current keyboard layout is returned by @ref
glfwGetKeyboardLayoutName.
If you wish to be notified when the keyboard layout changes, set a keyboard
layout callback.
@code
glfwSetKeyboardLayoutCallback(keyboard_layout_callback);
@endcode
The callback is called when the new layout takes effect for the application,
which on some platforms may not happen until one of its windows gets input
focus.
@code
void keyboard_layout_callback(void)
{
update_keyboard_layout_name(glfwGetKeyboardLayoutName());
}
@endcode
@section input_mouse Mouse input @section input_mouse Mouse input
@@ -550,10 +576,10 @@ int present = glfwJoystickPresent(GLFW_JOYSTICK_1);
Each joystick has zero or more axes, zero or more buttons, zero or more hats, Each joystick has zero or more axes, zero or more buttons, zero or more hats,
a human-readable name, a user pointer and an SDL compatible GUID. a human-readable name, a user pointer and an SDL compatible GUID.
Detected joysticks are added to the beginning of the array. Once a joystick is When GLFW is initialized, detected joysticks are added to the beginning of
detected, it keeps its assigned ID until it is disconnected or the library is the array. Once a joystick is detected, it keeps its assigned ID until it is
terminated, so as joysticks are connected and disconnected, there may appear disconnected or the library is terminated, so as joysticks are connected and
gaps in the IDs. disconnected, there may appear gaps in the IDs.
Joystick axis, button and hat state is updated when polled and does not require Joystick axis, button and hat state is updated when polled and does not require
a window to be created or events to be processed. However, if you want joystick a window to be created or events to be processed. However, if you want joystick
@@ -648,7 +674,7 @@ const char* name = glfwGetJoystickName(GLFW_JOYSTICK_4);
@endcode @endcode
Joystick names are not guaranteed to be unique. Two joysticks of the same model Joystick names are not guaranteed to be unique. Two joysticks of the same model
and make may have the same name. Only the [joystick ID](@ref joysticks) is and make may have the same name. Only the [joystick token](@ref joysticks) is
guaranteed to be unique, and only until that joystick is disconnected. guaranteed to be unique, and only until that joystick is disconnected.
+6 -24
View File
@@ -22,8 +22,8 @@ There are also guides for the other areas of GLFW.
Before most GLFW functions may be called, the library must be initialized. Before most GLFW functions may be called, the library must be initialized.
This initialization checks what features are available on the machine, This initialization checks what features are available on the machine,
enumerates monitors, initializes the timer and performs any required enumerates monitors and joysticks, initializes the timer and performs any
platform-specific initialization. required platform-specific initialization.
Only the following functions may be called before the library has been Only the following functions may be called before the library has been
successfully initialized, and only from the main thread. successfully initialized, and only from the main thread.
@@ -91,22 +91,7 @@ Setting these hints requires no platform specific headers or functions.
@anchor GLFW_JOYSTICK_HAT_BUTTONS @anchor GLFW_JOYSTICK_HAT_BUTTONS
__GLFW_JOYSTICK_HAT_BUTTONS__ specifies whether to also expose joystick hats as __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 buttons, for compatibility with earlier versions of GLFW that did not have @ref
glfwGetJoystickHats. Possible values are `GLFW_TRUE` and `GLFW_FALSE`. glfwGetJoystickHats. Set this with @ref glfwInitHint.
@anchor GLFW_ANGLE_PLATFORM_TYPE_hint
__GLFW_ANGLE_PLATFORM_TYPE__ specifies the platform type (rendering backend) to
request when using OpenGL ES and EGL via
[ANGLE](https://chromium.googlesource.com/angle/angle/). If the requested
platform type is unavailable, ANGLE will use its default. Possible values are
one of `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` and
`GLFW_ANGLE_PLATFORM_TYPE_METAL`.
@par
The ANGLE platform type is specified via the `EGL_ANGLE_platform_angle`
extension. This extension is not used if this hint is
`GLFW_ANGLE_PLATFORM_TYPE_NONE`, which is the default value.
@subsubsection init_hints_osx macOS specific init hints @subsubsection init_hints_osx macOS specific init hints
@@ -114,22 +99,19 @@ extension. This extension is not used if this hint is
@anchor GLFW_COCOA_CHDIR_RESOURCES_hint @anchor GLFW_COCOA_CHDIR_RESOURCES_hint
__GLFW_COCOA_CHDIR_RESOURCES__ specifies whether to set the current directory to __GLFW_COCOA_CHDIR_RESOURCES__ specifies whether to set the current directory to
the application to the `Contents/Resources` subdirectory of the application's the application to the `Contents/Resources` subdirectory of the application's
bundle, if present. Possible values are `GLFW_TRUE` and `GLFW_FALSE`. This is bundle, if present. Set this with @ref glfwInitHint.
ignored on other platforms.
@anchor GLFW_COCOA_MENUBAR_hint @anchor GLFW_COCOA_MENUBAR_hint
__GLFW_COCOA_MENUBAR__ specifies whether to create the menu bar and dock icon __GLFW_COCOA_MENUBAR__ specifies whether to create the menu bar and dock icon
when GLFW is initialized. This applies whether the menu bar is created from when GLFW is initialized. This applies whether the menu bar is created from
a nib or manually by GLFW. Possible values are `GLFW_TRUE` and `GLFW_FALSE`. a nib or manually by GLFW. Set this with @ref glfwInitHint.
This is ignored on other platforms.
@subsubsection init_hints_values Supported and default values @subsubsection init_hints_values Supported and default values
Initialization hint | Default value | Supported values Initialization hint | Default value | Supported values
------------------------------- | ------------------------------- | ---------------- ------------------------------- | ------------- | ----------------
@ref GLFW_JOYSTICK_HAT_BUTTONS | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE` @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` @ref GLFW_COCOA_CHDIR_RESOURCES | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE`
@ref GLFW_COCOA_MENUBAR | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE` @ref GLFW_COCOA_MENUBAR | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE`
+2 -2
View File
@@ -362,8 +362,8 @@ should be using the character callback instead, on both GLFW 2 and 3. This will
give you the characters being input, as opposed to the keys being pressed. give you the characters being input, as opposed to the keys being pressed.
GLFW 3 has key tokens for all keys on a standard 105 key keyboard, so instead of GLFW 3 has key tokens for all keys on a standard 105 key keyboard, so instead of
having to remember whether to check for `a` or `A`, you now check for having to remember whether to check for `'a'` or `'A'`, you now check for
@ref GLFW_KEY_A. `GLFW_KEY_A`.
@subsection moving_joystick Joystick function changes @subsection moving_joystick Joystick function changes
+9 -58
View File
@@ -9,6 +9,15 @@
@subsection features_34 New features in version 3.4 @subsection features_34 New features in version 3.4
@subsubsection keyboard_layout_34 Keyboard layouts
GLFW can now notify when the keyboard layout has changed with @ref
glfwSetKeyboardLayoutCallback and provides the human-readable name of the
current layout with @ref glfwGetKeyboardLayoutName.
For more information, see @ref keyboard_layout.
@subsubsection standard_cursors_34 More standard cursors @subsubsection standard_cursors_34 More standard cursors
GLFW now provides the standard cursor shapes @ref GLFW_RESIZE_NWSE_CURSOR and GLFW now provides the standard cursor shapes @ref GLFW_RESIZE_NWSE_CURSOR and
@@ -27,23 +36,6 @@ are still available.
For more information see @ref cursor_standard. For more information see @ref cursor_standard.
@subsubsection mouse_passthrough_34 Mouse event passthrough
GLFW now provides the [GLFW_MOUSE_PASSTHROUGH](@ref GLFW_MOUSE_PASSTHROUGH_hint)
window hint for making a window transparent to mouse input, lettings events pass
to whatever window is behind it. This can also be changed after window
creation with the matching [window attribute](@ref GLFW_MOUSE_PASSTHROUGH_attrib).
@subsubsection features_34_angle_backend Support for ANGLE rendering backend selection
GLFW now provides the
[GLFW_ANGLE_PLATFORM_TYPE](@ref GLFW_ANGLE_PLATFORM_TYPE_hint) init hint for
requesting a specific rendering backend when using
[ANGLE](https://chromium.googlesource.com/angle/angle/) to create OpenGL ES
contexts.
@subsubsection features_34_win32_keymenu Support for keyboard access to Windows window menu @subsubsection features_34_win32_keymenu Support for keyboard access to Windows window menu
GLFW now provides the GLFW now provides the
@@ -55,21 +47,6 @@ applications.
@subsection caveats_34 Caveats for version 3.4 @subsection caveats_34 Caveats for version 3.4
@subsubsection joysticks_34 Joystick support is initialized on demand
The joystick part of GLFW is now initialized when first used, primarily to work
around faulty Windows drivers that cause DirectInput to take up to several
seconds to enumerate devices.
This change will usually not be observable. However, if your application waits
for events without having first called any joystick function or created any
visible windows, the wait may never unblock as GLFW may not yet have subscribed
to joystick related OS events.
To work around this, call any joystick function before waiting for events, for
example by setting a [joystick callback](@ref joystick_event).
@subsubsection standalone_34 Tests and examples are disabled when built as a sub-project @subsubsection standalone_34 Tests and examples are disabled when built as a sub-project
GLFW now does not build the tests and examples when it is added as GLFW now does not build the tests and examples when it is added as
@@ -97,24 +74,10 @@ GLFW no longer depends on the CoreVideo framework on macOS and it no longer
needs to be specified during compilation or linking. needs to be specified during compilation or linking.
@subsubsection caveat_fbtransparency_34 Framebuffer transparency requires DWM transparency
GLFW no longer supports framebuffer transparency enabled via @ref
GLFW_TRANSPARENT_FRAMEBUFFER on Windows 7 if DWM transparency is off
(the Transparency setting under Personalization > Window Color).
@subsection deprecations_34 Deprecations in version 3.4 @subsection deprecations_34 Deprecations in version 3.4
@subsection removals_34 Removals in 3.4 @subsection removals_34 Removals in 3.4
@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
the XDG-Shell protocol. If your Wayland compositor does not support XDG-Shell
then GLFW will fail to initialize.
@subsection symbols_34 New symbols in version 3.4 @subsection symbols_34 New symbols in version 3.4
@subsubsection functions_34 New functions in version 3.4 @subsubsection functions_34 New functions in version 3.4
@@ -127,21 +90,9 @@ then GLFW will fail to initialize.
- @ref GLFW_RESIZE_NWSE_CURSOR - @ref GLFW_RESIZE_NWSE_CURSOR
- @ref GLFW_RESIZE_NESW_CURSOR - @ref GLFW_RESIZE_NESW_CURSOR
- @ref GLFW_RESIZE_ALL_CURSOR - @ref GLFW_RESIZE_ALL_CURSOR
- @ref GLFW_MOUSE_PASSTHROUGH
- @ref GLFW_NOT_ALLOWED_CURSOR - @ref GLFW_NOT_ALLOWED_CURSOR
- @ref GLFW_CURSOR_UNAVAILABLE - @ref GLFW_CURSOR_UNAVAILABLE
- @ref GLFW_WIN32_KEYBOARD_MENU - @ref GLFW_WIN32_KEYBOARD_MENU
- @ref GLFW_CONTEXT_DEBUG
- @ref GLFW_FEATURE_UNAVAILABLE
- @ref GLFW_FEATURE_UNIMPLEMENTED
- @ref GLFW_ANGLE_PLATFORM_TYPE
- @ref GLFW_ANGLE_PLATFORM_TYPE_NONE
- @ref GLFW_ANGLE_PLATFORM_TYPE_OPENGL
- @ref GLFW_ANGLE_PLATFORM_TYPE_OPENGLES
- @ref GLFW_ANGLE_PLATFORM_TYPE_D3D9
- @ref GLFW_ANGLE_PLATFORM_TYPE_D3D11
- @ref GLFW_ANGLE_PLATFORM_TYPE_VULKAN
- @ref GLFW_ANGLE_PLATFORM_TYPE_METAL
@section news_archive Release notes for earlier versions @section news_archive Release notes for earlier versions
+24 -23
View File
@@ -18,42 +18,43 @@ behave differently in GLFW 3.
@subsection quick_include Including the GLFW header @subsection quick_include Including the GLFW header
In the source files of your application where you use GLFW, you need to include In the source files of your application where you use OpenGL or GLFW, you need
its header file. to include the GLFW 3 header file.
@code @code
#include <GLFW/glfw3.h> #include <GLFW/glfw3.h>
@endcode @endcode
This header provides all the constants, types and function prototypes of the This defines all the constants, types and function prototypes of the GLFW API.
GLFW API. It also includes the OpenGL header from your development environment and
defines all the constants and types necessary for it to work on your platform
without including any platform-specific headers.
By default it also includes the OpenGL header from your development environment. In other words:
On some platforms this header only supports older versions of OpenGL. The most
extreme case is Windows, where it typically only supports OpenGL 1.2.
Most programs will instead use an - Do _not_ include the OpenGL header yourself, as GLFW does this for you in
[extension loader library](@ref context_glext_auto) and include its header. a platform-independent way
This example uses files generated by [glad](https://gen.glad.sh/). The GLFW - Do _not_ include `windows.h` or other platform-specific headers unless
header can detect most such headers if they are included first and will then not you plan on using those APIs yourself
include the one from your development environment. - If you _do_ need to include such headers, include them _before_ the GLFW
header and it will detect this
On some platforms supported by GLFW the OpenGL header and link library only
expose older versions of OpenGL. The most extreme case is Windows, which only
exposes OpenGL 1.2. The easiest way to work around this is to use an
[extension loader library](@ref context_glext_auto).
If you are using such a library then you should include its header _before_ the
GLFW header. This lets it replace the OpenGL header included by GLFW without
conflicts. This example uses
[glad2](https://github.com/Dav1dde/glad), but the same rule applies to all such
libraries.
@code @code
#include <glad/gl.h> #include <glad/gl.h>
#include <GLFW/glfw3.h> #include <GLFW/glfw3.h>
@endcode @endcode
To make sure there will be no header conflicts, you can define @ref
GLFW_INCLUDE_NONE before the GLFW header to explicitly disable inclusion of the
development environment header. This also allows the two headers to be included
in any order.
@code
#define GLFW_INCLUDE_NONE
#include <GLFW/glfw3.h>
#include <glad/gl.h>
@endcode
@subsection quick_init_term Initializing and terminating GLFW @subsection quick_init_term Initializing and terminating GLFW
+15 -43
View File
@@ -234,6 +234,13 @@ alpha channel will be used to combine the framebuffer with the background. This
does not affect window decorations. Possible values are `GLFW_TRUE` and does not affect window decorations. Possible values are `GLFW_TRUE` and
`GLFW_FALSE`. `GLFW_FALSE`.
@par
@win32 GLFW sets a color key for the window to work around repainting issues
with a transparent framebuffer. The chosen color value is RGB 255,0,255
(magenta). This will make pixels with that exact color fully transparent
regardless of their alpha values. If this is a problem, make these pixels any
other color before buffer swap.
@anchor GLFW_FOCUS_ON_SHOW_hint @anchor GLFW_FOCUS_ON_SHOW_hint
__GLFW_FOCUS_ON_SHOW__ specifies whether the window will be given input __GLFW_FOCUS_ON_SHOW__ specifies whether the window will be given input
focus when @ref glfwShowWindow is called. Possible values are `GLFW_TRUE` and `GLFW_FALSE`. focus when @ref glfwShowWindow is called. Possible values are `GLFW_TRUE` and `GLFW_FALSE`.
@@ -248,13 +255,6 @@ This hint only has an effect on platforms where screen coordinates and pixels
always map 1:1 such as Windows and X11. On platforms like macOS the resolution always map 1:1 such as Windows and X11. On platforms like macOS the resolution
of the framebuffer is changed independently of the window size. of the framebuffer is changed independently of the window size.
@anchor GLFW_MOUSE_PASSTHROUGH_hint
__GLFW_MOUSE_PASSTHROUGH__ specifies whether the window is transparent to mouse
input, letting any mouse events pass through to whatever window is behind it.
This is only supported for undecorated windows. Decorated windows with this
enabled will behave differently between platforms. Possible values are
`GLFW_TRUE` and `GLFW_FALSE`.
@subsubsection window_hints_fb Framebuffer related hints @subsubsection window_hints_fb Framebuffer related hints
@@ -405,20 +405,11 @@ version is 3.0 or above. If OpenGL ES is requested, this hint is ignored.
Forward-compatibility is described in detail in the Forward-compatibility is described in detail in the
[OpenGL Reference Manual](https://www.opengl.org/registry/). [OpenGL Reference Manual](https://www.opengl.org/registry/).
@anchor GLFW_CONTEXT_DEBUG_hint
@anchor GLFW_OPENGL_DEBUG_CONTEXT_hint @anchor GLFW_OPENGL_DEBUG_CONTEXT_hint
__GLFW_CONTEXT_DEBUG__ specifies whether the context should be created in debug __GLFW_OPENGL_DEBUG_CONTEXT__ specifies whether to create a debug OpenGL
mode, which may provide additional error and diagnostic reporting functionality. context, which may have additional error and performance issue reporting
Possible values are `GLFW_TRUE` and `GLFW_FALSE`. functionality. Possible values are `GLFW_TRUE` and `GLFW_FALSE`. If OpenGL ES
is requested, this hint is ignored.
@par
Debug contexts for OpenGL and OpenGL ES are described in detail by the
[GL_KHR_debug](https://www.khronos.org/registry/OpenGL/extensions/KHR/KHR_debug.txt)
extension.
@par
This is the new name, introduced in GLFW 3.4. The older
`GLFW_OPENGL_DEBUG_CONTEXT` name is also available for compatibility.
@anchor GLFW_OPENGL_PROFILE_hint @anchor GLFW_OPENGL_PROFILE_hint
__GLFW_OPENGL_PROFILE__ specifies which OpenGL profile to create the context __GLFW_OPENGL_PROFILE__ specifies which OpenGL profile to create the context
@@ -527,7 +518,6 @@ GLFW_CENTER_CURSOR | `GLFW_TRUE` | `GLFW_TRUE` or `GL
GLFW_TRANSPARENT_FRAMEBUFFER | `GLFW_FALSE` | `GLFW_TRUE` or `GLFW_FALSE` GLFW_TRANSPARENT_FRAMEBUFFER | `GLFW_FALSE` | `GLFW_TRUE` or `GLFW_FALSE`
GLFW_FOCUS_ON_SHOW | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE` GLFW_FOCUS_ON_SHOW | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE`
GLFW_SCALE_TO_MONITOR | `GLFW_FALSE` | `GLFW_TRUE` or `GLFW_FALSE` GLFW_SCALE_TO_MONITOR | `GLFW_FALSE` | `GLFW_TRUE` or `GLFW_FALSE`
GLFW_MOUSE_PASSTHROUGH | `GLFW_FALSE` | `GLFW_TRUE` or `GLFW_FALSE`
GLFW_RED_BITS | 8 | 0 to `INT_MAX` or `GLFW_DONT_CARE` GLFW_RED_BITS | 8 | 0 to `INT_MAX` or `GLFW_DONT_CARE`
GLFW_GREEN_BITS | 8 | 0 to `INT_MAX` or `GLFW_DONT_CARE` GLFW_GREEN_BITS | 8 | 0 to `INT_MAX` or `GLFW_DONT_CARE`
GLFW_BLUE_BITS | 8 | 0 to `INT_MAX` or `GLFW_DONT_CARE` GLFW_BLUE_BITS | 8 | 0 to `INT_MAX` or `GLFW_DONT_CARE`
@@ -551,7 +541,7 @@ GLFW_CONTEXT_VERSION_MINOR | 0 | Any valid minor ve
GLFW_CONTEXT_ROBUSTNESS | `GLFW_NO_ROBUSTNESS` | `GLFW_NO_ROBUSTNESS`, `GLFW_NO_RESET_NOTIFICATION` or `GLFW_LOSE_CONTEXT_ON_RESET` GLFW_CONTEXT_ROBUSTNESS | `GLFW_NO_ROBUSTNESS` | `GLFW_NO_ROBUSTNESS`, `GLFW_NO_RESET_NOTIFICATION` or `GLFW_LOSE_CONTEXT_ON_RESET`
GLFW_CONTEXT_RELEASE_BEHAVIOR | `GLFW_ANY_RELEASE_BEHAVIOR` | `GLFW_ANY_RELEASE_BEHAVIOR`, `GLFW_RELEASE_BEHAVIOR_FLUSH` or `GLFW_RELEASE_BEHAVIOR_NONE` GLFW_CONTEXT_RELEASE_BEHAVIOR | `GLFW_ANY_RELEASE_BEHAVIOR` | `GLFW_ANY_RELEASE_BEHAVIOR`, `GLFW_RELEASE_BEHAVIOR_FLUSH` or `GLFW_RELEASE_BEHAVIOR_NONE`
GLFW_OPENGL_FORWARD_COMPAT | `GLFW_FALSE` | `GLFW_TRUE` or `GLFW_FALSE` GLFW_OPENGL_FORWARD_COMPAT | `GLFW_FALSE` | `GLFW_TRUE` or `GLFW_FALSE`
GLFW_CONTEXT_DEBUG | `GLFW_FALSE` | `GLFW_TRUE` or `GLFW_FALSE` GLFW_OPENGL_DEBUG_CONTEXT | `GLFW_FALSE` | `GLFW_TRUE` or `GLFW_FALSE`
GLFW_OPENGL_PROFILE | `GLFW_OPENGL_ANY_PROFILE` | `GLFW_OPENGL_ANY_PROFILE`, `GLFW_OPENGL_COMPAT_PROFILE` or `GLFW_OPENGL_CORE_PROFILE` GLFW_OPENGL_PROFILE | `GLFW_OPENGL_ANY_PROFILE` | `GLFW_OPENGL_ANY_PROFILE`, `GLFW_OPENGL_COMPAT_PROFILE` or `GLFW_OPENGL_CORE_PROFILE`
GLFW_WIN32_KEYBOARD_MENU | `GLFW_FALSE` | `GLFW_TRUE` or `GLFW_FALSE` GLFW_WIN32_KEYBOARD_MENU | `GLFW_FALSE` | `GLFW_TRUE` or `GLFW_FALSE`
GLFW_COCOA_RETINA_FRAMEBUFFER | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE` GLFW_COCOA_RETINA_FRAMEBUFFER | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE`
@@ -1228,11 +1218,7 @@ If the system does not support whole window transparency, this function always
returns one. returns one.
GLFW comes with a test program that lets you control whole window transparency GLFW comes with a test program that lets you control whole window transparency
at run-time called `window`. at run-time called `opacity`.
If you want to use either of these transparency methods to display a temporary
overlay like for example a notification, the @ref GLFW_FLOATING and @ref
GLFW_MOUSE_PASSTHROUGH window hints and attributes may be useful.
@subsection window_attribs Window attributes @subsection window_attribs Window attributes
@@ -1322,15 +1308,6 @@ focus when @ref glfwShowWindow is called. This can be set before creation
with the [GLFW_FOCUS_ON_SHOW](@ref GLFW_FOCUS_ON_SHOW_hint) window hint or with the [GLFW_FOCUS_ON_SHOW](@ref GLFW_FOCUS_ON_SHOW_hint) window hint or
after with @ref glfwSetWindowAttrib. after with @ref glfwSetWindowAttrib.
@anchor GLFW_MOUSE_PASSTHROUGH_attrib
__GLFW_MOUSE_PASSTHROUGH__ specifies whether the window is transparent to mouse
input, letting any mouse events pass through to whatever window is behind it.
This can be set before creation with the
[GLFW_MOUSE_PASSTHROUGH](@ref GLFW_MOUSE_PASSTHROUGH_hint) window hint or after
with @ref glfwSetWindowAttrib. This is only supported for undecorated windows.
Decorated windows with this enabled will behave differently between platforms.
@subsubsection window_attribs_ctx Context related attributes @subsubsection window_attribs_ctx Context related attributes
@anchor GLFW_CLIENT_API_attrib @anchor GLFW_CLIENT_API_attrib
@@ -1357,14 +1334,9 @@ of the GLFW header.
__GLFW_OPENGL_FORWARD_COMPAT__ is `GLFW_TRUE` if the window's context is an __GLFW_OPENGL_FORWARD_COMPAT__ is `GLFW_TRUE` if the window's context is an
OpenGL forward-compatible one, or `GLFW_FALSE` otherwise. OpenGL forward-compatible one, or `GLFW_FALSE` otherwise.
@anchor GLFW_CONTEXT_DEBUG_attrib
@anchor GLFW_OPENGL_DEBUG_CONTEXT_attrib @anchor GLFW_OPENGL_DEBUG_CONTEXT_attrib
__GLFW_CONTEXT_DEBUG__ is `GLFW_TRUE` if the window's context is in debug __GLFW_OPENGL_DEBUG_CONTEXT__ is `GLFW_TRUE` if the window's context is an
mode, or `GLFW_FALSE` otherwise. OpenGL debug context, or `GLFW_FALSE` otherwise.
@par
This is the new name, introduced in GLFW 3.4. The older
`GLFW_OPENGL_DEBUG_CONTEXT` name is also available for compatibility.
@anchor GLFW_OPENGL_PROFILE_attrib @anchor GLFW_OPENGL_PROFILE_attrib
__GLFW_OPENGL_PROFILE__ indicates the OpenGL profile used by the context. This __GLFW_OPENGL_PROFILE__ indicates the OpenGL profile used by the context. This
+1 -4
View File
@@ -33,7 +33,6 @@ add_executable(sharing WIN32 MACOSX_BUNDLE sharing.c ${ICON} ${GLAD_GL})
add_executable(splitview WIN32 MACOSX_BUNDLE splitview.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-opengl WIN32 MACOSX_BUNDLE triangle-opengl.c ${ICON} ${GLAD_GL})
add_executable(wave WIN32 MACOSX_BUNDLE wave.c ${ICON} ${GLAD_GL}) add_executable(wave WIN32 MACOSX_BUNDLE wave.c ${ICON} ${GLAD_GL})
add_executable(windows WIN32 MACOSX_BUNDLE windows.c ${ICON} ${GLAD_GL})
target_link_libraries(particles Threads::Threads) target_link_libraries(particles Threads::Threads)
if (RT_LIBRARY) if (RT_LIBRARY)
@@ -41,7 +40,7 @@ if (RT_LIBRARY)
endif() endif()
set(GUI_ONLY_BINARIES boing gears heightmap particles sharing splitview set(GUI_ONLY_BINARIES boing gears heightmap particles sharing splitview
triangle-opengl wave windows) triangle-opengl wave)
set(CONSOLE_BINARIES offscreen) set(CONSOLE_BINARIES offscreen)
set_target_properties(${GUI_ONLY_BINARIES} ${CONSOLE_BINARIES} PROPERTIES set_target_properties(${GUI_ONLY_BINARIES} ${CONSOLE_BINARIES} PROPERTIES
@@ -49,7 +48,6 @@ set_target_properties(${GUI_ONLY_BINARIES} ${CONSOLE_BINARIES} PROPERTIES
FOLDER "GLFW3/Examples") FOLDER "GLFW3/Examples")
if (GLFW_USE_OSMESA) if (GLFW_USE_OSMESA)
find_package(OSMesa REQUIRED)
target_compile_definitions(offscreen PRIVATE USE_NATIVE_OSMESA) target_compile_definitions(offscreen PRIVATE USE_NATIVE_OSMESA)
endif() endif()
@@ -68,7 +66,6 @@ if (APPLE)
set_target_properties(triangle-opengl PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "OpenGL Triangle") set_target_properties(triangle-opengl PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "OpenGL Triangle")
set_target_properties(splitview PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "SplitView") set_target_properties(splitview PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "SplitView")
set_target_properties(wave PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Wave") set_target_properties(wave PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Wave")
set_target_properties(windows PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Windows")
set_source_files_properties(glfw.icns PROPERTIES set_source_files_properties(glfw.icns PROPERTIES
MACOSX_PACKAGE_LOCATION "Resources") MACOSX_PACKAGE_LOCATION "Resources")
+122 -120
View File
@@ -193,38 +193,7 @@ extern "C" {
#endif /*__APPLE__*/ #endif /*__APPLE__*/
#elif defined(GLFW_INCLUDE_GLU) #elif !defined(GLFW_INCLUDE_NONE)
#if defined(__APPLE__)
#if defined(GLFW_INCLUDE_GLU)
#include <OpenGL/glu.h>
#endif
#else /*__APPLE__*/
#if defined(GLFW_INCLUDE_GLU)
#include <GL/glu.h>
#endif
#endif /*__APPLE__*/
#elif !defined(GLFW_INCLUDE_NONE) && \
!defined(__gl_h_) && \
!defined(__gles1_gl_h_) && \
!defined(__gles2_gl2_h_) && \
!defined(__gles2_gl3_h_) && \
!defined(__gles2_gl31_h_) && \
!defined(__gles2_gl32_h_) && \
!defined(__gl_glcorearb_h_) && \
!defined(__gl2_h_) /*legacy*/ && \
!defined(__gl3_h_) /*legacy*/ && \
!defined(__gl31_h_) /*legacy*/ && \
!defined(__gl32_h_) /*legacy*/ && \
!defined(__glcorearb_h_) /*legacy*/ && \
!defined(__GL_H__) /*non-standard*/ && \
!defined(__gltypes_h_) /*non-standard*/ && \
!defined(__glee_h_) /*non-standard*/
#if defined(__APPLE__) #if defined(__APPLE__)
@@ -232,6 +201,9 @@ extern "C" {
#define GL_GLEXT_LEGACY #define GL_GLEXT_LEGACY
#endif #endif
#include <OpenGL/gl.h> #include <OpenGL/gl.h>
#if defined(GLFW_INCLUDE_GLU)
#include <OpenGL/glu.h>
#endif
#else /*__APPLE__*/ #else /*__APPLE__*/
@@ -239,6 +211,9 @@ extern "C" {
#if defined(GLFW_INCLUDE_GLEXT) #if defined(GLFW_INCLUDE_GLEXT)
#include <GL/glext.h> #include <GL/glext.h>
#endif #endif
#if defined(GLFW_INCLUDE_GLU)
#include <GL/glu.h>
#endif
#endif /*__APPLE__*/ #endif /*__APPLE__*/
@@ -793,33 +768,6 @@ extern "C" {
* [custom cursor](@ref cursor_custom). * [custom cursor](@ref cursor_custom).
*/ */
#define GLFW_CURSOR_UNAVAILABLE 0x0001000B #define GLFW_CURSOR_UNAVAILABLE 0x0001000B
/*! @brief The requested feature is not provided by the platform.
*
* The requested feature is not provided by the platform, so GLFW is unable to
* implement it. The documentation for each function notes if it could emit
* this error.
*
* @analysis Platform or platform version limitation. The error can be ignored
* unless the feature is critical to the application.
*
* @par
* A function call that emits this error has no effect other than the error and
* updating any existing out parameters.
*/
#define GLFW_FEATURE_UNAVAILABLE 0x0001000C
/*! @brief The requested feature is not implemented for the platform.
*
* The requested feature has not yet been implemented in GLFW for this platform.
*
* @analysis An incomplete implementation of GLFW for this platform, hopefully
* fixed in a future release. The error can be ignored unless the feature is
* critical to the application.
*
* @par
* A function call that emits this error has no effect other than the error and
* updating any existing out parameters.
*/
#define GLFW_FEATURE_UNIMPLEMENTED 0x0001000D
/*! @} */ /*! @} */
/*! @addtogroup window /*! @addtogroup window
@@ -895,13 +843,6 @@ extern "C" {
*/ */
#define GLFW_FOCUS_ON_SHOW 0x0002000C #define GLFW_FOCUS_ON_SHOW 0x0002000C
/*! @brief Mouse input transparency window hint and attribute
*
* Mouse input transparency [window hint](@ref GLFW_MOUSE_PASSTHROUGH_hint) or
* [window attribute](@ref GLFW_MOUSE_PASSTHROUGH_attrib).
*/
#define GLFW_MOUSE_PASSTHROUGH 0x0002000D
/*! @brief Framebuffer bit depth hint. /*! @brief Framebuffer bit depth hint.
* *
* Framebuffer bit depth [hint](@ref GLFW_RED_BITS). * Framebuffer bit depth [hint](@ref GLFW_RED_BITS).
@@ -1019,17 +960,12 @@ extern "C" {
* and [attribute](@ref GLFW_OPENGL_FORWARD_COMPAT_attrib). * and [attribute](@ref GLFW_OPENGL_FORWARD_COMPAT_attrib).
*/ */
#define GLFW_OPENGL_FORWARD_COMPAT 0x00022006 #define GLFW_OPENGL_FORWARD_COMPAT 0x00022006
/*! @brief Debug mode context hint and attribute. /*! @brief OpenGL debug context hint and attribute.
* *
* Debug mode context [hint](@ref GLFW_CONTEXT_DEBUG_hint) and * OpenGL debug context [hint](@ref GLFW_OPENGL_DEBUG_CONTEXT_hint) and
* [attribute](@ref GLFW_CONTEXT_DEBUG_attrib). * [attribute](@ref GLFW_OPENGL_DEBUG_CONTEXT_attrib).
*/ */
#define GLFW_CONTEXT_DEBUG 0x00022007 #define GLFW_OPENGL_DEBUG_CONTEXT 0x00022007
/*! @brief Legacy name for compatibility.
*
* This is an alias for compatibility with earlier versions.
*/
#define GLFW_OPENGL_DEBUG_CONTEXT GLFW_CONTEXT_DEBUG
/*! @brief OpenGL profile hint and attribute. /*! @brief OpenGL profile hint and attribute.
* *
* OpenGL profile [hint](@ref GLFW_OPENGL_PROFILE_hint) and * OpenGL profile [hint](@ref GLFW_OPENGL_PROFILE_hint) and
@@ -1111,14 +1047,6 @@ extern "C" {
#define GLFW_EGL_CONTEXT_API 0x00036002 #define GLFW_EGL_CONTEXT_API 0x00036002
#define GLFW_OSMESA_CONTEXT_API 0x00036003 #define GLFW_OSMESA_CONTEXT_API 0x00036003
#define GLFW_ANGLE_PLATFORM_TYPE_NONE 0x00037001
#define GLFW_ANGLE_PLATFORM_TYPE_OPENGL 0x00037002
#define GLFW_ANGLE_PLATFORM_TYPE_OPENGLES 0x00037003
#define GLFW_ANGLE_PLATFORM_TYPE_D3D9 0x00037004
#define GLFW_ANGLE_PLATFORM_TYPE_D3D11 0x00037005
#define GLFW_ANGLE_PLATFORM_TYPE_VULKAN 0x00037007
#define GLFW_ANGLE_PLATFORM_TYPE_METAL 0x00037008
/*! @defgroup shapes Standard cursor shapes /*! @defgroup shapes Standard cursor shapes
* @brief Standard system cursor shapes. * @brief Standard system cursor shapes.
* *
@@ -1235,11 +1163,6 @@ extern "C" {
* Joystick hat buttons [init hint](@ref GLFW_JOYSTICK_HAT_BUTTONS). * Joystick hat buttons [init hint](@ref GLFW_JOYSTICK_HAT_BUTTONS).
*/ */
#define GLFW_JOYSTICK_HAT_BUTTONS 0x00050001 #define GLFW_JOYSTICK_HAT_BUTTONS 0x00050001
/*! @brief ANGLE rendering backend init hint.
*
* ANGLE rendering backend [init hint](@ref GLFW_ANGLE_PLATFORM_TYPE_hint).
*/
#define GLFW_ANGLE_PLATFORM_TYPE 0x00050002
/*! @brief macOS specific init hint. /*! @brief macOS specific init hint.
* *
* macOS specific [init hint](@ref GLFW_COCOA_CHDIR_RESOURCES_hint). * macOS specific [init hint](@ref GLFW_COCOA_CHDIR_RESOURCES_hint).
@@ -1347,6 +1270,23 @@ typedef struct GLFWcursor GLFWcursor;
*/ */
typedef void (* GLFWerrorfun)(int,const char*); typedef void (* GLFWerrorfun)(int,const char*);
/*! @brief The function pointer type for keyboard layout callbacks.
*
* This is the function pointer type for keyboard layout callbacks. A keyboard
* layout callback function has the following signature:
* @code
* void callback_name(void);
* @endcode
*
* @sa @ref keyboard_layout
* @sa @ref glfwSetKeyboardLayoutCallback
*
* @since Added in version 3.4.
*
* @ingroup input
*/
typedef void (* GLFWkeyboardlayoutfun)(void);
/*! @brief The function pointer type for window position callbacks. /*! @brief The function pointer type for window position callbacks.
* *
* This is the function pointer type for window position callbacks. A window * This is the function pointer type for window position callbacks. A window
@@ -1483,7 +1423,7 @@ typedef void (* GLFWwindowiconifyfun)(GLFWwindow*,int);
* @endcode * @endcode
* *
* @param[in] window The window that was maximized or restored. * @param[in] window The window that was maximized or restored.
* @param[in] maximized `GLFW_TRUE` if the window was maximized, or * @param[in] iconified `GLFW_TRUE` if the window was maximized, or
* `GLFW_FALSE` if it was restored. * `GLFW_FALSE` if it was restored.
* *
* @sa @ref window_maximize * @sa @ref window_maximize
@@ -1943,8 +1883,6 @@ GLFWAPI int glfwInit(void);
* call this function, as it is called by @ref glfwInit before it returns * call this function, as it is called by @ref glfwInit before it returns
* failure. * failure.
* *
* This function has no effect if GLFW is not initialized.
*
* @errors Possible errors include @ref GLFW_PLATFORM_ERROR. * @errors Possible errors include @ref GLFW_PLATFORM_ERROR.
* *
* @remark This function may be called before @ref glfwInit. * @remark This function may be called before @ref glfwInit.
@@ -2933,21 +2871,21 @@ GLFWAPI void glfwSetWindowTitle(GLFWwindow* window, const char* title);
* @param[in] images The images to create the icon from. This is ignored if * @param[in] images The images to create the icon from. This is ignored if
* count is zero. * count is zero.
* *
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
* GLFW_PLATFORM_ERROR and @ref GLFW_FEATURE_UNAVAILABLE (see remarks). * GLFW_PLATFORM_ERROR.
* *
* @pointer_lifetime The specified image data is copied before this function * @pointer_lifetime The specified image data is copied before this function
* returns. * returns.
* *
* @remark @macos Regular windows do not have icons on macOS. This function * @remark @macos The GLFW window has no icon, as it is not a document
* will emit @ref GLFW_FEATURE_UNAVAILABLE. The dock icon will be the same as * window, so this function does nothing. The dock icon will be the same as
* the application bundle's icon. For more information on bundles, see the * the application bundle's icon. For more information on bundles, see the
* [Bundle Programming Guide](https://developer.apple.com/library/mac/documentation/CoreFoundation/Conceptual/CFBundles/) * [Bundle Programming Guide](https://developer.apple.com/library/mac/documentation/CoreFoundation/Conceptual/CFBundles/)
* in the Mac Developer Library. * in the Mac Developer Library.
* *
* @remark @wayland There is no existing protocol to change an icon, the * @remark @wayland There is no existing protocol to change an icon, the
* window will thus inherit the one defined in the application's desktop file. * window will thus inherit the one defined in the application's desktop file.
* This function will emit @ref GLFW_FEATURE_UNAVAILABLE. * This function always emits @ref GLFW_PLATFORM_ERROR.
* *
* @thread_safety This function must only be called from the main thread. * @thread_safety This function must only be called from the main thread.
* *
@@ -2973,12 +2911,12 @@ GLFWAPI void glfwSetWindowIcon(GLFWwindow* window, int count, const GLFWimage* i
* @param[out] ypos Where to store the y-coordinate of the upper-left corner of * @param[out] ypos Where to store the y-coordinate of the upper-left corner of
* the content area, or `NULL`. * the content area, or `NULL`.
* *
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
* GLFW_PLATFORM_ERROR and @ref GLFW_FEATURE_UNAVAILABLE (see remarks). * GLFW_PLATFORM_ERROR.
* *
* @remark @wayland There is no way for an application to retrieve the global * @remark @wayland There is no way for an application to retrieve the global
* position of its windows. This function will emit @ref * position of its windows, this function will always emit @ref
* GLFW_FEATURE_UNAVAILABLE. * GLFW_PLATFORM_ERROR.
* *
* @thread_safety This function must only be called from the main thread. * @thread_safety This function must only be called from the main thread.
* *
@@ -3007,12 +2945,12 @@ GLFWAPI void glfwGetWindowPos(GLFWwindow* window, int* xpos, int* ypos);
* @param[in] xpos The x-coordinate of the upper-left corner of the content area. * @param[in] xpos The x-coordinate of the upper-left corner of the content area.
* @param[in] ypos The y-coordinate of the upper-left corner of the content area. * @param[in] ypos The y-coordinate of the upper-left corner of the content area.
* *
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
* GLFW_PLATFORM_ERROR and @ref GLFW_FEATURE_UNAVAILABLE (see remarks). * GLFW_PLATFORM_ERROR.
* *
* @remark @wayland There is no way for an application to set the global * @remark @wayland There is no way for an application to set the global
* position of its windows. This function will emit @ref * position of its windows, this function will always emit @ref
* GLFW_FEATURE_UNAVAILABLE. * GLFW_PLATFORM_ERROR.
* *
* @thread_safety This function must only be called from the main thread. * @thread_safety This function must only be called from the main thread.
* *
@@ -3324,11 +3262,8 @@ GLFWAPI float glfwGetWindowOpacity(GLFWwindow* window);
* @param[in] window The window to set the opacity for. * @param[in] window The window to set the opacity for.
* @param[in] opacity The desired opacity of the specified window. * @param[in] opacity The desired opacity of the specified window.
* *
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
* GLFW_PLATFORM_ERROR and @ref GLFW_FEATURE_UNAVAILABLE (see remarks). * GLFW_PLATFORM_ERROR.
*
* @remark @wayland There is no way to set an opacity factor for a window.
* This function will emit @ref GLFW_FEATURE_UNAVAILABLE.
* *
* @thread_safety This function must only be called from the main thread. * @thread_safety This function must only be called from the main thread.
* *
@@ -3495,11 +3430,11 @@ GLFWAPI void glfwHideWindow(GLFWwindow* window);
* *
* @param[in] window The window to give input focus. * @param[in] window The window to give input focus.
* *
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
* GLFW_PLATFORM_ERROR and @ref GLFW_FEATURE_UNAVAILABLE (see remarks). * GLFW_PLATFORM_ERROR.
* *
* @remark @wayland It is not possible for an application to set the input * @remark @wayland It is not possible for an application to bring its windows
* focus. This function will emit @ref GLFW_FEATURE_UNAVAILABLE. * to front, this function will always emit @ref GLFW_PLATFORM_ERROR.
* *
* @thread_safety This function must only be called from the main thread. * @thread_safety This function must only be called from the main thread.
* *
@@ -3663,7 +3598,6 @@ GLFWAPI int glfwGetWindowAttrib(GLFWwindow* window, int attrib);
* [GLFW_FLOATING](@ref GLFW_FLOATING_attrib), * [GLFW_FLOATING](@ref GLFW_FLOATING_attrib),
* [GLFW_AUTO_ICONIFY](@ref GLFW_AUTO_ICONIFY_attrib) and * [GLFW_AUTO_ICONIFY](@ref GLFW_AUTO_ICONIFY_attrib) and
* [GLFW_FOCUS_ON_SHOW](@ref GLFW_FOCUS_ON_SHOW_attrib). * [GLFW_FOCUS_ON_SHOW](@ref GLFW_FOCUS_ON_SHOW_attrib).
* [GLFW_MOUSE_PASSTHROUGH](@ref GLFW_MOUSE_PASSTHROUGH_attrib)
* *
* Some of these attributes are ignored for full screen windows. The new * Some of these attributes are ignored for full screen windows. The new
* value will take effect if the window is later made windowed. * value will take effect if the window is later made windowed.
@@ -4252,7 +4186,7 @@ GLFWAPI int glfwGetInputMode(GLFWwindow* window, int mode);
* If the mode is `GLFW_RAW_MOUSE_MOTION`, the value must be either `GLFW_TRUE` * If the mode is `GLFW_RAW_MOUSE_MOTION`, the value must be either `GLFW_TRUE`
* to enable raw (unscaled and unaccelerated) mouse motion when the cursor is * to enable raw (unscaled and unaccelerated) mouse motion when the cursor is
* disabled, or `GLFW_FALSE` to disable it. If raw motion is not supported, * disabled, or `GLFW_FALSE` to disable it. If raw motion is not supported,
* attempting to set this will emit @ref GLFW_FEATURE_UNAVAILABLE. Call @ref * attempting to set this will emit @ref GLFW_PLATFORM_ERROR. Call @ref
* glfwRawMouseMotionSupported to check for support. * glfwRawMouseMotionSupported to check for support.
* *
* @param[in] window The window whose input mode to set. * @param[in] window The window whose input mode to set.
@@ -4262,8 +4196,7 @@ GLFWAPI int glfwGetInputMode(GLFWwindow* window, int mode);
* @param[in] value The new value of the specified input mode. * @param[in] value The new value of the specified input mode.
* *
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
* GLFW_INVALID_ENUM, @ref GLFW_PLATFORM_ERROR and @ref * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
* GLFW_FEATURE_UNAVAILABLE (see above).
* *
* @thread_safety This function must only be called from the main thread. * @thread_safety This function must only be called from the main thread.
* *
@@ -4349,6 +4282,11 @@ GLFWAPI int glfwRawMouseMotionSupported(void);
* non-printable keys are the same across layouts but depend on the application * non-printable keys are the same across layouts but depend on the application
* language and should be localized along with other user interface text. * language and should be localized along with other user interface text.
* *
* The contents of the returned string may change when a keyboard
* layout change event is received. Set a
* [keyboard layout](@ref keyboard_layout) callback to be notified when the
* layout changes.
*
* @param[in] key The key to query, or `GLFW_KEY_UNKNOWN`. * @param[in] key The key to query, or `GLFW_KEY_UNKNOWN`.
* @param[in] scancode The scancode of the key to query. * @param[in] scancode The scancode of the key to query.
* @return The UTF-8 encoded, layout-specific name of the key, or `NULL`. * @return The UTF-8 encoded, layout-specific name of the key, or `NULL`.
@@ -4356,9 +4294,6 @@ GLFWAPI int glfwRawMouseMotionSupported(void);
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
* GLFW_PLATFORM_ERROR. * GLFW_PLATFORM_ERROR.
* *
* @remark The contents of the returned string may change when a keyboard
* layout change event is received.
*
* @pointer_lifetime The returned string is allocated and freed by GLFW. You * @pointer_lifetime The returned string is allocated and freed by GLFW. You
* should not free it yourself. It is valid until the library is terminated. * should not free it yourself. It is valid until the library is terminated.
* *
@@ -4396,6 +4331,73 @@ GLFWAPI const char* glfwGetKeyName(int key, int scancode);
*/ */
GLFWAPI int glfwGetKeyScancode(int key); GLFWAPI int glfwGetKeyScancode(int key);
/*! @brief Returns the human-readable name of the current keyboard layout.
*
* This function returns the human-readable name, encoded as UTF-8, of the
* current keyboard layout. On some platforms this may not be updated until
* one of the application's windows gets input focus.
*
* The keyboard layout name is intended to be shown to the user during text
* input, especially in full screen applications.
*
* The name may be localized into the current operating system UI language. It
* is provided by the operating system and may not be identical for a given
* layout across platforms.
*
* @return The UTF-8 encoded name of the current keyboard layout, or `NULL` if
* an [error](@ref error_handling) occurred.
*
* @errors Possible errors include @ref GLFW_PLATFORM_ERROR and @ref
* GLFW_NOT_INITIALIZED.
*
* @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 this
* function or the library is terminated.
*
* @thread_safety This function must only be called from the main thread.
*
* @sa @ref keyboard_layout
* @sa @ref glfwSetKeyboardLayoutCallback
*
* @since Added in version 3.4.
*
* @ingroup input
*/
GLFWAPI const char* glfwGetKeyboardLayoutName(void);
/*! @brief Sets the keyboard layout callback.
*
* This function sets the keyboard layout callback, which is called when the
* keyboard layout is changed. The name of the current layout is returned by
* @ref glfwGetKeyboardLayoutName.
*
* On some platforms the keyboard layout event may not arrive until one of the
* application's windows get input focus. Layout changes may not be reported
* while other applications have input focus.
*
* @param[in] callback The new callback, or `NULL` to remove the currently set
* callback.
* @return The previously set callback, or `NULL` if no callback was set or the
* library had not been [initialized](@ref intro_init).
*
* @callback_signature
* @code
* void function_name(void)
* @endcode
*
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
*
* @thread_safety This function must only be called from the main thread.
*
* @sa @ref keyboard_layout
* @sa @ref glfwGetKeyboardLayoutName
*
* @since Added in version 3.4.
*
* @ingroup input
*/
GLFWAPI GLFWkeyboardlayoutfun glfwSetKeyboardLayoutCallback(GLFWkeyboardlayoutfun callback);
/*! @brief Returns the last reported state of a keyboard key for the specified /*! @brief Returns the last reported state of a keyboard key for the specified
* window. * window.
* *
+29 -100
View File
@@ -45,47 +45,30 @@ if (_GLFW_X11 OR _GLFW_WAYLAND)
endif() endif()
if (_GLFW_WAYLAND) if (_GLFW_WAYLAND)
find_program(WAYLAND_SCANNER_EXECUTABLE NAMES wayland-scanner) ecm_add_wayland_client_protocol(GLFW_WAYLAND_PROTOCOL_SOURCES
pkg_check_modules(WAYLAND_PROTOCOLS REQUIRED wayland-protocols>=1.15) PROTOCOL
pkg_get_variable(WAYLAND_PROTOCOLS_BASE wayland-protocols pkgdatadir) "${WAYLAND_PROTOCOLS_PKGDATADIR}/stable/xdg-shell/xdg-shell.xml"
BASENAME xdg-shell)
macro(wayland_generate protocol_file output_file) ecm_add_wayland_client_protocol(GLFW_WAYLAND_PROTOCOL_SOURCES
add_custom_command(OUTPUT ${output_file}.h PROTOCOL
COMMAND ${WAYLAND_SCANNER_EXECUTABLE} client-header "${WAYLAND_PROTOCOLS_PKGDATADIR}/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml"
< ${protocol_file} > ${output_file}.h BASENAME xdg-decoration)
DEPENDS ${protocol_file}) ecm_add_wayland_client_protocol(GLFW_WAYLAND_PROTOCOL_SOURCES
list(APPEND GLFW_WAYLAND_PROTOCOL_SOURCES ${output_file}.h) PROTOCOL
"${WAYLAND_PROTOCOLS_PKGDATADIR}/stable/viewporter/viewporter.xml"
add_custom_command(OUTPUT ${output_file}.c BASENAME viewporter)
COMMAND ${WAYLAND_SCANNER_EXECUTABLE} private-code ecm_add_wayland_client_protocol(GLFW_WAYLAND_PROTOCOL_SOURCES
< ${protocol_file} > ${output_file}.c PROTOCOL
DEPENDS ${protocol_file}) "${WAYLAND_PROTOCOLS_PKGDATADIR}/unstable/relative-pointer/relative-pointer-unstable-v1.xml"
list(APPEND GLFW_WAYLAND_PROTOCOL_SOURCES ${output_file}.c) BASENAME relative-pointer-unstable-v1)
endmacro() ecm_add_wayland_client_protocol(GLFW_WAYLAND_PROTOCOL_SOURCES
PROTOCOL
set(GLFW_WAYLAND_PROTOCOL_SOURCES) "${WAYLAND_PROTOCOLS_PKGDATADIR}/unstable/pointer-constraints/pointer-constraints-unstable-v1.xml"
wayland_generate( BASENAME pointer-constraints-unstable-v1)
${WAYLAND_PROTOCOLS_BASE}/stable/xdg-shell/xdg-shell.xml ecm_add_wayland_client_protocol(GLFW_WAYLAND_PROTOCOL_SOURCES
${CMAKE_BINARY_DIR}/src/wayland-xdg-shell-client-protocol) PROTOCOL
wayland_generate( "${WAYLAND_PROTOCOLS_PKGDATADIR}/unstable/idle-inhibit/idle-inhibit-unstable-v1.xml"
${WAYLAND_PROTOCOLS_BASE}/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml BASENAME idle-inhibit-unstable-v1)
${CMAKE_BINARY_DIR}/src/wayland-xdg-decoration-client-protocol)
wayland_generate(
${WAYLAND_PROTOCOLS_BASE}/stable/viewporter/viewporter.xml
${CMAKE_BINARY_DIR}/src/wayland-viewporter-client-protocol)
wayland_generate(
${WAYLAND_PROTOCOLS_BASE}/unstable/relative-pointer/relative-pointer-unstable-v1.xml
${CMAKE_BINARY_DIR}/src/wayland-relative-pointer-unstable-v1-client-protocol)
wayland_generate(
${WAYLAND_PROTOCOLS_BASE}/unstable/pointer-constraints/pointer-constraints-unstable-v1.xml
${CMAKE_BINARY_DIR}/src/wayland-pointer-constraints-unstable-v1-client-protocol)
wayland_generate(
${WAYLAND_PROTOCOLS_BASE}/unstable/tablet/tablet-unstable-v2.xml
${CMAKE_BINARY_DIR}/src/wayland-tablet-unstable-v2-client-protocol)
wayland_generate(
${WAYLAND_PROTOCOLS_BASE}/unstable/idle-inhibit/idle-inhibit-unstable-v1.xml
${CMAKE_BINARY_DIR}/src/wayland-idle-inhibit-unstable-v1-client-protocol)
target_sources(glfw PRIVATE ${GLFW_WAYLAND_PROTOCOL_SOURCES}) target_sources(glfw PRIVATE ${GLFW_WAYLAND_PROTOCOL_SOURCES})
endif() endif()
@@ -117,8 +100,8 @@ target_include_directories(glfw PRIVATE
${glfw_INCLUDE_DIRS}) ${glfw_INCLUDE_DIRS})
target_link_libraries(glfw PRIVATE Threads::Threads ${glfw_LIBRARIES}) target_link_libraries(glfw PRIVATE Threads::Threads ${glfw_LIBRARIES})
# Workaround for CMake not knowing about .m files before version 3.16
if (APPLE) if (APPLE)
# For some reason CMake didn't know about .m until version 3.16
set_source_files_properties(cocoa_init.m cocoa_joystick.m cocoa_monitor.m set_source_files_properties(cocoa_init.m cocoa_joystick.m cocoa_monitor.m
cocoa_window.m nsgl_context.m PROPERTIES cocoa_window.m nsgl_context.m PROPERTIES
LANGUAGE C) LANGUAGE C)
@@ -153,35 +136,6 @@ if (MINGW)
target_compile_definitions(glfw PRIVATE UNICODE WINVER=0x0501) target_compile_definitions(glfw PRIVATE UNICODE WINVER=0x0501)
endif() endif()
# Workaround for legacy MinGW not providing XInput and DirectInput
if (MINGW)
include(CheckIncludeFile)
check_include_file(dinput.h DINPUT_H_FOUND)
check_include_file(xinput.h XINPUT_H_FOUND)
if (NOT DINPUT_H_FOUND OR NOT XINPUT_H_FOUND)
target_include_directories(glfw PRIVATE "${GLFW_SOURCE_DIR}/deps/mingw")
endif()
endif()
# Workaround for VS deprecating parts of the standard library
if (MSVC)
target_compile_definitions(glfw PRIVATE _CRT_SECURE_NO_WARNINGS)
endif()
# Workaround for VS 2008 not shipping with stdint.h
if (MSVC90)
target_include_directories(glfw PUBLIC "${GLFW_SOURCE_DIR}/deps/vs2008")
endif()
# Check for the DirectX 9 SDK as it is not included with VS 2008
if (MSVC90)
include(CheckIncludeFile)
check_include_file(dinput.h DINPUT_H_FOUND)
if (NOT DINPUT_H_FOUND)
message(FATAL_ERROR "DirectX 9 headers not found; install DirectX 9 SDK")
endif()
endif()
if (BUILD_SHARED_LIBS) if (BUILD_SHARED_LIBS)
if (WIN32) if (WIN32)
if (MINGW) if (MINGW)
@@ -205,41 +159,16 @@ if (BUILD_SHARED_LIBS)
INSTALL_NAME_DIR "${CMAKE_INSTALL_LIBDIR}") INSTALL_NAME_DIR "${CMAKE_INSTALL_LIBDIR}")
endif() endif()
if (MINGW)
# Enable link-time exploit mitigation features enabled by default on MSVC
include(CheckCCompilerFlag)
# Compatibility with data execution prevention (DEP)
set(CMAKE_REQUIRED_FLAGS "-Wl,--nxcompat")
check_c_compiler_flag("" _GLFW_HAS_DEP)
if (_GLFW_HAS_DEP)
target_link_libraries(glfw PRIVATE "-Wl,--nxcompat")
endif()
# Compatibility with address space layout randomization (ASLR)
set(CMAKE_REQUIRED_FLAGS "-Wl,--dynamicbase")
check_c_compiler_flag("" _GLFW_HAS_ASLR)
if (_GLFW_HAS_ASLR)
target_link_libraries(glfw PRIVATE "-Wl,--dynamicbase")
endif()
# Compatibility with 64-bit address space layout randomization (ASLR)
set(CMAKE_REQUIRED_FLAGS "-Wl,--high-entropy-va")
check_c_compiler_flag("" _GLFW_HAS_64ASLR)
if (_GLFW_HAS_64ASLR)
target_link_libraries(glfw PRIVATE "-Wl,--high-entropy-va")
endif()
# Clear flags again to avoid breaking later tests
set(CMAKE_REQUIRED_FLAGS)
endif()
if (UNIX) if (UNIX)
# Hide symbols not explicitly tagged for export from the shared library # Hide symbols not explicitly tagged for export from the shared library
target_compile_options(glfw PRIVATE "-fvisibility=hidden") target_compile_options(glfw PRIVATE "-fvisibility=hidden")
endif() endif()
endif() endif()
if (MSVC)
target_compile_definitions(glfw PRIVATE _CRT_SECURE_NO_WARNINGS)
endif()
if (GLFW_INSTALL) if (GLFW_INSTALL)
install(TARGETS glfw install(TARGETS glfw
EXPORT glfwTargets EXPORT glfwTargets
+55 -35
View File
@@ -305,38 +305,6 @@ static void createKeyTables(void)
} }
} }
// Retrieve Unicode data for the current keyboard layout
//
static GLFWbool updateUnicodeDataNS(void)
{
if (_glfw.ns.inputSource)
{
CFRelease(_glfw.ns.inputSource);
_glfw.ns.inputSource = NULL;
_glfw.ns.unicodeData = nil;
}
_glfw.ns.inputSource = TISCopyCurrentKeyboardLayoutInputSource();
if (!_glfw.ns.inputSource)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"Cocoa: Failed to retrieve keyboard layout input source");
return GLFW_FALSE;
}
_glfw.ns.unicodeData =
TISGetInputSourceProperty(_glfw.ns.inputSource,
kTISPropertyUnicodeKeyLayoutData);
if (!_glfw.ns.unicodeData)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"Cocoa: Failed to retrieve keyboard layout Unicode data");
return GLFW_FALSE;
}
return GLFW_TRUE;
}
// Load HIToolbox.framework and the TIS symbols we need from it // Load HIToolbox.framework and the TIS symbols we need from it
// //
static GLFWbool initializeTIS(void) static GLFWbool initializeTIS(void)
@@ -354,6 +322,15 @@ static GLFWbool initializeTIS(void)
CFStringRef* kPropertyUnicodeKeyLayoutData = CFStringRef* kPropertyUnicodeKeyLayoutData =
CFBundleGetDataPointerForName(_glfw.ns.tis.bundle, CFBundleGetDataPointerForName(_glfw.ns.tis.bundle,
CFSTR("kTISPropertyUnicodeKeyLayoutData")); CFSTR("kTISPropertyUnicodeKeyLayoutData"));
CFStringRef* kPropertyInputSourceID =
CFBundleGetDataPointerForName(_glfw.ns.tis.bundle,
CFSTR("kTISPropertyInputSourceID"));
CFStringRef* kPropertyLocalizedName =
CFBundleGetDataPointerForName(_glfw.ns.tis.bundle,
CFSTR("kTISPropertyLocalizedName"));
_glfw.ns.tis.CopyCurrentKeyboardInputSource =
CFBundleGetFunctionPointerForName(_glfw.ns.tis.bundle,
CFSTR("TISCopyCurrentKeyboardInputSource"));
_glfw.ns.tis.CopyCurrentKeyboardLayoutInputSource = _glfw.ns.tis.CopyCurrentKeyboardLayoutInputSource =
CFBundleGetFunctionPointerForName(_glfw.ns.tis.bundle, CFBundleGetFunctionPointerForName(_glfw.ns.tis.bundle,
CFSTR("TISCopyCurrentKeyboardLayoutInputSource")); CFSTR("TISCopyCurrentKeyboardLayoutInputSource"));
@@ -365,6 +342,9 @@ static GLFWbool initializeTIS(void)
CFSTR("LMGetKbdType")); CFSTR("LMGetKbdType"));
if (!kPropertyUnicodeKeyLayoutData || if (!kPropertyUnicodeKeyLayoutData ||
!kPropertyInputSourceID ||
!kPropertyLocalizedName ||
!TISCopyCurrentKeyboardInputSource ||
!TISCopyCurrentKeyboardLayoutInputSource || !TISCopyCurrentKeyboardLayoutInputSource ||
!TISGetInputSourceProperty || !TISGetInputSourceProperty ||
!LMGetKbdType) !LMGetKbdType)
@@ -376,8 +356,18 @@ static GLFWbool initializeTIS(void)
_glfw.ns.tis.kPropertyUnicodeKeyLayoutData = _glfw.ns.tis.kPropertyUnicodeKeyLayoutData =
*kPropertyUnicodeKeyLayoutData; *kPropertyUnicodeKeyLayoutData;
_glfw.ns.tis.kPropertyInputSourceID =
*kPropertyInputSourceID;
_glfw.ns.tis.kPropertyLocalizedName =
*kPropertyLocalizedName;
return updateUnicodeDataNS(); _glfw.ns.inputSource = TISCopyCurrentKeyboardInputSource();
_glfw.ns.keyboardLayout = TISCopyCurrentKeyboardLayoutInputSource();
_glfw.ns.unicodeData =
TISGetInputSourceProperty(_glfw.ns.keyboardLayout,
kTISPropertyUnicodeKeyLayoutData);
return GLFW_TRUE;
} }
@interface GLFWHelper : NSObject @interface GLFWHelper : NSObject
@@ -387,7 +377,28 @@ static GLFWbool initializeTIS(void)
- (void)selectedKeyboardInputSourceChanged:(NSObject* )object - (void)selectedKeyboardInputSourceChanged:(NSObject* )object
{ {
updateUnicodeDataNS(); // The keyboard layout is needed for Unicode data which is the source of
// GLFW key names on Cocoa (the generic input source may not have this)
CFRelease(_glfw.ns.keyboardLayout);
_glfw.ns.keyboardLayout = TISCopyCurrentKeyboardLayoutInputSource();
_glfw.ns.unicodeData =
TISGetInputSourceProperty(_glfw.ns.keyboardLayout,
kTISPropertyUnicodeKeyLayoutData);
// The generic input source may be something higher level than a keyboard
// layout and if so will provide a better layout name than the layout source
const TISInputSourceRef source = TISCopyCurrentKeyboardInputSource();
const CFStringRef newID =
TISGetInputSourceProperty(source, kTISPropertyInputSourceID);
const CFStringRef oldID =
TISGetInputSourceProperty(_glfw.ns.inputSource, kTISPropertyInputSourceID);
const CFComparisonResult result = CFStringCompare(oldID, newID, 0);
CFRelease(_glfw.ns.inputSource);
_glfw.ns.inputSource = source;
// Filter events as we may receive more than one per input source switch
if (result != kCFCompareEqualTo)
_glfwInputKeyboardLayout();
} }
- (void)doNothing:(id)object - (void)doNothing:(id)object
@@ -551,6 +562,7 @@ int _glfwPlatformInit(void)
return GLFW_FALSE; return GLFW_FALSE;
_glfwInitTimerNS(); _glfwInitTimerNS();
_glfwInitJoysticksNS();
_glfwPollMonitorsNS(); _glfwPollMonitorsNS();
@@ -566,11 +578,17 @@ void _glfwPlatformTerminate(void)
{ {
@autoreleasepool { @autoreleasepool {
if (_glfw.ns.keyboardLayout)
{
CFRelease(_glfw.ns.keyboardLayout);
_glfw.ns.keyboardLayout = NULL;
_glfw.ns.unicodeData = NULL;
}
if (_glfw.ns.inputSource) if (_glfw.ns.inputSource)
{ {
CFRelease(_glfw.ns.inputSource); CFRelease(_glfw.ns.inputSource);
_glfw.ns.inputSource = NULL; _glfw.ns.inputSource = NULL;
_glfw.ns.unicodeData = nil;
} }
if (_glfw.ns.eventSource) if (_glfw.ns.eventSource)
@@ -602,8 +620,10 @@ void _glfwPlatformTerminate(void)
[NSEvent removeMonitor:_glfw.ns.keyUpMonitor]; [NSEvent removeMonitor:_glfw.ns.keyUpMonitor];
free(_glfw.ns.clipboardString); free(_glfw.ns.clipboardString);
free(_glfw.ns.keyboardLayoutName);
_glfwTerminateNSGL(); _glfwTerminateNSGL();
_glfwTerminateJoysticksNS();
} // autoreleasepool } // autoreleasepool
} }
+4
View File
@@ -44,3 +44,7 @@ typedef struct _GLFWjoystickNS
CFMutableArrayRef hats; CFMutableArrayRef hats;
} _GLFWjoystickNS; } _GLFWjoystickNS;
void _glfwInitJoysticksNS(void);
void _glfwTerminateJoysticksNS(void);
+12 -8
View File
@@ -304,10 +304,12 @@ static void removeCallback(void* context,
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
////// GLFW platform API ////// ////// GLFW internal API //////
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
GLFWbool _glfwPlatformInitJoysticks(void) // Initialize joystick interface
//
void _glfwInitJoysticksNS(void)
{ {
CFMutableArrayRef matching; CFMutableArrayRef matching;
const long usages[] = const long usages[] =
@@ -326,7 +328,7 @@ GLFWbool _glfwPlatformInitJoysticks(void)
if (!matching) if (!matching)
{ {
_glfwInputError(GLFW_PLATFORM_ERROR, "Cocoa: Failed to create array"); _glfwInputError(GLFW_PLATFORM_ERROR, "Cocoa: Failed to create array");
return GLFW_FALSE; return;
} }
for (size_t i = 0; i < sizeof(usages) / sizeof(long); i++) for (size_t i = 0; i < sizeof(usages) / sizeof(long); i++)
@@ -381,24 +383,26 @@ GLFWbool _glfwPlatformInitJoysticks(void)
// Execute the run loop once in order to register any initially-attached // Execute the run loop once in order to register any initially-attached
// joysticks // joysticks
CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, false); CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, false);
return GLFW_TRUE;
} }
void _glfwPlatformTerminateJoysticks(void) // Close all opened joystick handles
//
void _glfwTerminateJoysticksNS(void)
{ {
int jid; int jid;
for (jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++) for (jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++)
closeJoystick(_glfw.joysticks + jid); closeJoystick(_glfw.joysticks + jid);
if (_glfw.ns.hidManager)
{
CFRelease(_glfw.ns.hidManager); CFRelease(_glfw.ns.hidManager);
_glfw.ns.hidManager = NULL; _glfw.ns.hidManager = NULL;
} }
}
//////////////////////////////////////////////////////////////////////////
////// GLFW platform API //////
//////////////////////////////////////////////////////////////////////////
int _glfwPlatformPollJoystick(_GLFWjoystick* js, int mode) int _glfwPlatformPollJoystick(_GLFWjoystick* js, int mode)
{ {
if (mode & _GLFW_POLL_AXES) if (mode & _GLFW_POLL_AXES)
+3 -9
View File
@@ -277,20 +277,14 @@ static double getFallbackRefreshRate(CGDirectDisplayID displayID)
CFSTR("IOFBCurrentPixelCount"), CFSTR("IOFBCurrentPixelCount"),
kCFAllocatorDefault, kCFAllocatorDefault,
kNilOptions); kNilOptions);
if (!clockRef || !countRef)
break;
uint32_t clock = 0, count = 0; uint32_t clock = 0, count = 0;
if (clockRef)
{
CFNumberGetValue(clockRef, kCFNumberIntType, &clock); CFNumberGetValue(clockRef, kCFNumberIntType, &clock);
CFRelease(clockRef);
}
if (countRef)
{
CFNumberGetValue(countRef, kCFNumberIntType, &count); CFNumberGetValue(countRef, kCFNumberIntType, &count);
CFRelease(clockRef);
CFRelease(countRef); CFRelease(countRef);
}
if (clock > 0 && count > 0) if (clock > 0 && count > 0)
refreshRate = clock / (double) count; refreshRate = clock / (double) count;
+15 -1
View File
@@ -85,11 +85,16 @@ typedef VkResult (APIENTRY *PFN_vkCreateMetalSurfaceEXT)(VkInstance,const VkMeta
#include "posix_thread.h" #include "posix_thread.h"
#include "cocoa_joystick.h" #include "cocoa_joystick.h"
#include "nsgl_context.h" #include "nsgl_context.h"
#include "egl_context.h"
#include "osmesa_context.h"
#define _glfw_dlopen(name) dlopen(name, RTLD_LAZY | RTLD_LOCAL) #define _glfw_dlopen(name) dlopen(name, RTLD_LAZY | RTLD_LOCAL)
#define _glfw_dlclose(handle) dlclose(handle) #define _glfw_dlclose(handle) dlclose(handle)
#define _glfw_dlsym(handle, name) dlsym(handle, name) #define _glfw_dlsym(handle, name) dlsym(handle, name)
#define _GLFW_EGL_NATIVE_WINDOW ((EGLNativeWindowType) window->ns.view)
#define _GLFW_EGL_NATIVE_DISPLAY EGL_DEFAULT_DISPLAY
#define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowNS ns #define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowNS ns
#define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryNS ns #define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryNS ns
#define _GLFW_PLATFORM_LIBRARY_TIMER_STATE _GLFWtimerNS ns #define _GLFW_PLATFORM_LIBRARY_TIMER_STATE _GLFWtimerNS ns
@@ -98,6 +103,10 @@ typedef VkResult (APIENTRY *PFN_vkCreateMetalSurfaceEXT)(VkInstance,const VkMeta
// HIToolbox.framework pointer typedefs // HIToolbox.framework pointer typedefs
#define kTISPropertyUnicodeKeyLayoutData _glfw.ns.tis.kPropertyUnicodeKeyLayoutData #define kTISPropertyUnicodeKeyLayoutData _glfw.ns.tis.kPropertyUnicodeKeyLayoutData
#define kTISPropertyInputSourceID _glfw.ns.tis.kPropertyInputSourceID
#define kTISPropertyLocalizedName _glfw.ns.tis.kPropertyLocalizedName
typedef TISInputSourceRef (*PFN_TISCopyCurrentKeyboardInputSource)(void);
#define TISCopyCurrentKeyboardInputSource _glfw.ns.tis.CopyCurrentKeyboardInputSource
typedef TISInputSourceRef (*PFN_TISCopyCurrentKeyboardLayoutInputSource)(void); typedef TISInputSourceRef (*PFN_TISCopyCurrentKeyboardLayoutInputSource)(void);
#define TISCopyCurrentKeyboardLayoutInputSource _glfw.ns.tis.CopyCurrentKeyboardLayoutInputSource #define TISCopyCurrentKeyboardLayoutInputSource _glfw.ns.tis.CopyCurrentKeyboardLayoutInputSource
typedef void* (*PFN_TISGetInputSourceProperty)(TISInputSourceRef,CFStringRef); typedef void* (*PFN_TISGetInputSourceProperty)(TISInputSourceRef,CFStringRef);
@@ -139,8 +148,9 @@ typedef struct _GLFWlibraryNS
id delegate; id delegate;
GLFWbool cursorHidden; GLFWbool cursorHidden;
TISInputSourceRef inputSource; TISInputSourceRef inputSource;
TISInputSourceRef keyboardLayout;
IOHIDManagerRef hidManager; IOHIDManagerRef hidManager;
id unicodeData; void* unicodeData;
id helper; id helper;
id keyUpMonitor; id keyUpMonitor;
id nibObjects; id nibObjects;
@@ -149,6 +159,7 @@ typedef struct _GLFWlibraryNS
short int keycodes[256]; short int keycodes[256];
short int scancodes[GLFW_KEY_LAST + 1]; short int scancodes[GLFW_KEY_LAST + 1];
char* clipboardString; char* clipboardString;
char* keyboardLayoutName;
CGPoint cascadePoint; CGPoint cascadePoint;
// Where to place the cursor when re-enabled // Where to place the cursor when re-enabled
double restoreCursorPosX, restoreCursorPosY; double restoreCursorPosX, restoreCursorPosY;
@@ -157,10 +168,13 @@ typedef struct _GLFWlibraryNS
struct { struct {
CFBundleRef bundle; CFBundleRef bundle;
PFN_TISCopyCurrentKeyboardInputSource CopyCurrentKeyboardInputSource;
PFN_TISCopyCurrentKeyboardLayoutInputSource CopyCurrentKeyboardLayoutInputSource; PFN_TISCopyCurrentKeyboardLayoutInputSource CopyCurrentKeyboardLayoutInputSource;
PFN_TISGetInputSourceProperty GetInputSourceProperty; PFN_TISGetInputSourceProperty GetInputSourceProperty;
PFN_LMGetKbdType GetKbdType; PFN_LMGetKbdType GetKbdType;
CFStringRef kPropertyUnicodeKeyLayoutData; CFStringRef kPropertyUnicodeKeyLayoutData;
CFStringRef kPropertyInputSourceID;
CFStringRef kPropertyLocalizedName;
} tis; } tis;
} _GLFWlibraryNS; } _GLFWlibraryNS;
+31 -71
View File
@@ -731,26 +731,16 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
else else
characters = (NSString*) string; characters = (NSString*) string;
NSRange range = NSMakeRange(0, [characters length]); const NSUInteger length = [characters length];
while (range.length) for (NSUInteger i = 0; i < length; i++)
{ {
uint32_t codepoint = 0; const unichar codepoint = [characters characterAtIndex:i];
if ((codepoint & 0xff00) == 0xf700)
if ([characters getBytes:&codepoint
maxLength:sizeof(codepoint)
usedLength:NULL
encoding:NSUTF32StringEncoding
options:0
range:range
remainingRange:&range])
{
if (codepoint >= 0xf700 && codepoint <= 0xf7ff)
continue; continue;
_glfwInputChar(window, codepoint, mods, plain); _glfwInputChar(window, codepoint, mods, plain);
} }
} }
}
- (void)doCommandBySelector:(SEL)selector - (void)doCommandBySelector:(SEL)selector
{ {
@@ -916,11 +906,6 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
} }
else if (ctxconfig->source == GLFW_EGL_CONTEXT_API) else if (ctxconfig->source == GLFW_EGL_CONTEXT_API)
{ {
// EGL implementation on macOS use CALayer* EGLNativeWindowType so we
// need to get the layer for EGL window surface creation.
[window->ns.view setWantsLayer:YES];
window->ns.layer = [window->ns.view layer];
if (!_glfwInitEGL()) if (!_glfwInitEGL())
return GLFW_FALSE; return GLFW_FALSE;
if (!_glfwCreateContextEGL(window, ctxconfig, fbconfig)) if (!_glfwCreateContextEGL(window, ctxconfig, fbconfig))
@@ -992,8 +977,7 @@ void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title)
void _glfwPlatformSetWindowIcon(_GLFWwindow* window, void _glfwPlatformSetWindowIcon(_GLFWwindow* window,
int count, const GLFWimage* images) int count, const GLFWimage* images)
{ {
_glfwInputError(GLFW_FEATURE_UNAVAILABLE, // Regular windows do not have icons
"Cocoa: Regular windows do not have icons on macOS");
} }
void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos) void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos)
@@ -1371,13 +1355,6 @@ void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled)
} // autoreleasepool } // autoreleasepool
} }
void _glfwPlatformSetWindowMousePassthrough(_GLFWwindow* window, GLFWbool enabled)
{
@autoreleasepool {
[window->ns.object setIgnoresMouseEvents:enabled];
}
}
float _glfwPlatformGetWindowOpacity(_GLFWwindow* window) float _glfwPlatformGetWindowOpacity(_GLFWwindow* window)
{ {
@autoreleasepool { @autoreleasepool {
@@ -1394,8 +1371,6 @@ void _glfwPlatformSetWindowOpacity(_GLFWwindow* window, float opacity)
void _glfwPlatformSetRawMouseMotion(_GLFWwindow *window, GLFWbool enabled) void _glfwPlatformSetRawMouseMotion(_GLFWwindow *window, GLFWbool enabled)
{ {
_glfwInputError(GLFW_FEATURE_UNIMPLEMENTED,
"Cocoa: Raw mouse motion not yet implemented");
} }
GLFWbool _glfwPlatformRawMouseMotionSupported(void) GLFWbool _glfwPlatformRawMouseMotionSupported(void)
@@ -1541,6 +1516,12 @@ const char* _glfwPlatformGetScancodeName(int scancode)
return NULL; return NULL;
} }
if (!_glfw.ns.unicodeData)
{
_glfwInputError(GLFW_PLATFORM_ERROR, "Cocoa: Keyboard Unicode data missing");
return NULL;
}
const int key = _glfw.ns.keycodes[scancode]; const int key = _glfw.ns.keycodes[scancode];
UInt32 deadKeyState = 0; UInt32 deadKeyState = 0;
@@ -1584,6 +1565,26 @@ int _glfwPlatformGetKeyScancode(int key)
return _glfw.ns.scancodes[key]; return _glfw.ns.scancodes[key];
} }
const char* _glfwPlatformGetKeyboardLayoutName(void)
{
TISInputSourceRef source = TISCopyCurrentKeyboardInputSource();
NSString* name = (__bridge NSString*)
TISGetInputSourceProperty(source, kTISPropertyLocalizedName);
if (!name)
{
CFRelease(source);
_glfwInputError(GLFW_PLATFORM_ERROR,
"Cocoa: Failed to retrieve keyboard layout name");
return NULL;
}
free(_glfw.ns.keyboardLayoutName);
_glfw.ns.keyboardLayoutName = _glfw_strdup([name UTF8String]);
CFRelease(source);
return _glfw.ns.keyboardLayoutName;
}
int _glfwPlatformCreateCursor(_GLFWcursor* cursor, int _glfwPlatformCreateCursor(_GLFWcursor* cursor,
const GLFWimage* image, const GLFWimage* image,
int xhot, int yhot) int xhot, int yhot)
@@ -1738,47 +1739,6 @@ const char* _glfwPlatformGetClipboardString(void)
} // autoreleasepool } // autoreleasepool
} }
EGLenum _glfwPlatformGetEGLPlatform(EGLint** attribs)
{
if (_glfw.egl.ANGLE_platform_angle)
{
int type = 0;
if (_glfw.egl.ANGLE_platform_angle_opengl)
{
if (_glfw.hints.init.angleType == GLFW_ANGLE_PLATFORM_TYPE_OPENGL)
type = EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE;
}
if (_glfw.egl.ANGLE_platform_angle_metal)
{
if (_glfw.hints.init.angleType == GLFW_ANGLE_PLATFORM_TYPE_METAL)
type = EGL_PLATFORM_ANGLE_TYPE_METAL_ANGLE;
}
if (type)
{
*attribs = calloc(3, sizeof(EGLint));
(*attribs)[0] = EGL_PLATFORM_ANGLE_TYPE_ANGLE;
(*attribs)[1] = type;
(*attribs)[2] = EGL_NONE;
return EGL_PLATFORM_ANGLE_ANGLE;
}
}
return 0;
}
EGLNativeDisplayType _glfwPlatformGetEGLNativeDisplay(void)
{
return EGL_DEFAULT_DISPLAY;
}
EGLNativeWindowType _glfwPlatformGetEGLNativeWindow(_GLFWwindow* window)
{
return window->ns.layer;
}
void _glfwPlatformGetRequiredInstanceExtensions(char** extensions) void _glfwPlatformGetRequiredInstanceExtensions(char** extensions)
{ {
if (_glfw.vk.KHR_surface && _glfw.vk.EXT_metal_surface) if (_glfw.vk.KHR_surface && _glfw.vk.EXT_metal_surface)
+8 -62
View File
@@ -303,8 +303,6 @@ static void destroyContextEGL(_GLFWwindow* window)
GLFWbool _glfwInitEGL(void) GLFWbool _glfwInitEGL(void)
{ {
int i; int i;
EGLint* attribs = NULL;
const char* extensions;
const char* sonames[] = const char* sonames[] =
{ {
#if defined(_GLFW_EGL_LIBRARY) #if defined(_GLFW_EGL_LIBRARY)
@@ -397,51 +395,7 @@ GLFWbool _glfwInitEGL(void)
return GLFW_FALSE; return GLFW_FALSE;
} }
extensions = eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS); _glfw.egl.display = eglGetDisplay(_GLFW_EGL_NATIVE_DISPLAY);
if (extensions && eglGetError() == EGL_SUCCESS)
_glfw.egl.EXT_client_extensions = GLFW_TRUE;
if (_glfw.egl.EXT_client_extensions)
{
_glfw.egl.EXT_platform_base =
_glfwStringInExtensionString("EGL_EXT_platform_base", extensions);
_glfw.egl.EXT_platform_x11 =
_glfwStringInExtensionString("EGL_EXT_platform_x11", extensions);
_glfw.egl.EXT_platform_wayland =
_glfwStringInExtensionString("EGL_EXT_platform_wayland", extensions);
_glfw.egl.ANGLE_platform_angle =
_glfwStringInExtensionString("EGL_ANGLE_platform_angle", extensions);
_glfw.egl.ANGLE_platform_angle_opengl =
_glfwStringInExtensionString("EGL_ANGLE_platform_angle_opengl", extensions);
_glfw.egl.ANGLE_platform_angle_d3d =
_glfwStringInExtensionString("EGL_ANGLE_platform_angle_d3d", extensions);
_glfw.egl.ANGLE_platform_angle_vulkan =
_glfwStringInExtensionString("EGL_ANGLE_platform_angle_vulkan", extensions);
_glfw.egl.ANGLE_platform_angle_metal =
_glfwStringInExtensionString("EGL_ANGLE_platform_angle_metal", extensions);
}
if (_glfw.egl.EXT_platform_base)
{
_glfw.egl.GetPlatformDisplayEXT = (PFNEGLGETPLATFORMDISPLAYEXTPROC)
eglGetProcAddress("eglGetPlatformDisplayEXT");
_glfw.egl.CreatePlatformWindowSurfaceEXT = (PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC)
eglGetProcAddress("eglCreatePlatformWindowSurfaceEXT");
}
_glfw.egl.platform = _glfwPlatformGetEGLPlatform(&attribs);
if (_glfw.egl.platform)
{
_glfw.egl.display =
eglGetPlatformDisplayEXT(_glfw.egl.platform,
_glfwPlatformGetEGLNativeDisplay(),
attribs);
}
else
_glfw.egl.display = eglGetDisplay(_glfwPlatformGetEGLNativeDisplay());
free(attribs);
if (_glfw.egl.display == EGL_NO_DISPLAY) if (_glfw.egl.display == EGL_NO_DISPLAY)
{ {
_glfwInputError(GLFW_API_UNAVAILABLE, _glfwInputError(GLFW_API_UNAVAILABLE,
@@ -509,7 +463,6 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window,
EGLint attribs[40]; EGLint attribs[40];
EGLConfig config; EGLConfig config;
EGLContext share = NULL; EGLContext share = NULL;
EGLNativeWindowType native;
int index = 0; int index = 0;
if (!_glfw.egl.display) if (!_glfw.egl.display)
@@ -635,7 +588,8 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window,
} }
// Set up attributes for surface creation // Set up attributes for surface creation
index = 0; {
int index = 0;
if (fbconfig->sRGB) if (fbconfig->sRGB)
{ {
@@ -644,21 +598,13 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window,
} }
setAttrib(EGL_NONE, EGL_NONE); setAttrib(EGL_NONE, EGL_NONE);
native = _glfwPlatformGetEGLNativeWindow(window);
// HACK: ANGLE does not implement eglCreatePlatformWindowSurfaceEXT
// despite reporting EGL_EXT_platform_base
if (_glfw.egl.platform && _glfw.egl.platform != EGL_PLATFORM_ANGLE_ANGLE)
{
window->context.egl.surface =
eglCreatePlatformWindowSurfaceEXT(_glfw.egl.display, config, native, attribs);
}
else
{
window->context.egl.surface =
eglCreateWindowSurface(_glfw.egl.display, config, native, attribs);
} }
window->context.egl.surface =
eglCreateWindowSurface(_glfw.egl.display,
config,
_GLFW_EGL_NATIVE_WINDOW,
attribs);
if (window->context.egl.surface == EGL_NO_SURFACE) if (window->context.egl.surface == EGL_NO_SURFACE)
{ {
_glfwInputError(GLFW_PLATFORM_ERROR, _glfwInputError(GLFW_PLATFORM_ERROR,
+21 -33
View File
@@ -25,10 +25,26 @@
// //
//======================================================================== //========================================================================
#if defined(_GLFW_WIN32) #if defined(_GLFW_USE_EGLPLATFORM_H)
#include <EGL/eglplatform.h>
#elif defined(_GLFW_WIN32)
#define EGLAPIENTRY __stdcall #define EGLAPIENTRY __stdcall
#else typedef HDC EGLNativeDisplayType;
typedef HWND EGLNativeWindowType;
#elif defined(_GLFW_COCOA)
#define EGLAPIENTRY #define EGLAPIENTRY
typedef void* EGLNativeDisplayType;
typedef id EGLNativeWindowType;
#elif defined(_GLFW_X11)
#define EGLAPIENTRY
typedef Display* EGLNativeDisplayType;
typedef Window EGLNativeWindowType;
#elif defined(_GLFW_WAYLAND)
#define EGLAPIENTRY
typedef struct wl_display* EGLNativeDisplayType;
typedef struct wl_egl_window* EGLNativeWindowType;
#else
#error "No supported EGL platform selected"
#endif #endif
#define EGL_SUCCESS 0x3000 #define EGL_SUCCESS 0x3000
@@ -90,17 +106,6 @@
#define EGL_CONTEXT_RELEASE_BEHAVIOR_KHR 0x2097 #define EGL_CONTEXT_RELEASE_BEHAVIOR_KHR 0x2097
#define EGL_CONTEXT_RELEASE_BEHAVIOR_NONE_KHR 0 #define EGL_CONTEXT_RELEASE_BEHAVIOR_NONE_KHR 0
#define EGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_KHR 0x2098 #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 int EGLint;
typedef unsigned int EGLBoolean; typedef unsigned int EGLBoolean;
@@ -110,9 +115,6 @@ typedef void* EGLContext;
typedef void* EGLDisplay; typedef void* EGLDisplay;
typedef void* EGLSurface; typedef void* EGLSurface;
typedef void* EGLNativeDisplayType;
typedef void* EGLNativeWindowType;
// EGL function pointer typedefs // EGL function pointer typedefs
typedef EGLBoolean (EGLAPIENTRY * PFN_eglGetConfigAttrib)(EGLDisplay,EGLConfig,EGLint,EGLint*); typedef EGLBoolean (EGLAPIENTRY * PFN_eglGetConfigAttrib)(EGLDisplay,EGLConfig,EGLint,EGLint*);
typedef EGLBoolean (EGLAPIENTRY * PFN_eglGetConfigs)(EGLDisplay,EGLConfig*,EGLint,EGLint*); typedef EGLBoolean (EGLAPIENTRY * PFN_eglGetConfigs)(EGLDisplay,EGLConfig*,EGLint,EGLint*);
@@ -147,10 +149,9 @@ typedef GLFWglproc (EGLAPIENTRY * PFN_eglGetProcAddress)(const char*);
#define eglQueryString _glfw.egl.QueryString #define eglQueryString _glfw.egl.QueryString
#define eglGetProcAddress _glfw.egl.GetProcAddress #define eglGetProcAddress _glfw.egl.GetProcAddress
typedef EGLDisplay (EGLAPIENTRY * PFNEGLGETPLATFORMDISPLAYEXTPROC)(EGLenum,void*,const EGLint*); #define _GLFW_EGL_CONTEXT_STATE _GLFWcontextEGL egl
typedef EGLSurface (EGLAPIENTRY * PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC)(EGLDisplay,EGLConfig,void*,const EGLint*); #define _GLFW_EGL_LIBRARY_CONTEXT_STATE _GLFWlibraryEGL egl
#define eglGetPlatformDisplayEXT _glfw.egl.GetPlatformDisplayEXT
#define eglCreatePlatformWindowSurfaceEXT _glfw.egl.CreatePlatformWindowSurfaceEXT
// EGL-specific per-context data // EGL-specific per-context data
// //
@@ -168,7 +169,6 @@ typedef struct _GLFWcontextEGL
// //
typedef struct _GLFWlibraryEGL typedef struct _GLFWlibraryEGL
{ {
EGLenum platform;
EGLDisplay display; EGLDisplay display;
EGLint major, minor; EGLint major, minor;
GLFWbool prefix; GLFWbool prefix;
@@ -178,15 +178,6 @@ typedef struct _GLFWlibraryEGL
GLFWbool KHR_gl_colorspace; GLFWbool KHR_gl_colorspace;
GLFWbool KHR_get_all_proc_addresses; GLFWbool KHR_get_all_proc_addresses;
GLFWbool KHR_context_flush_control; 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; void* handle;
@@ -207,9 +198,6 @@ typedef struct _GLFWlibraryEGL
PFN_eglQueryString QueryString; PFN_eglQueryString QueryString;
PFN_eglGetProcAddress GetProcAddress; PFN_eglGetProcAddress GetProcAddress;
PFNEGLGETPLATFORMDISPLAYEXTPROC GetPlatformDisplayEXT;
PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC CreatePlatformWindowSurfaceEXT;
} _GLFWlibraryEGL; } _GLFWlibraryEGL;
-9
View File
@@ -53,7 +53,6 @@ static GLFWerrorfun _glfwErrorCallback;
static _GLFWinitconfig _glfwInitHints = static _GLFWinitconfig _glfwInitHints =
{ {
GLFW_TRUE, // hat buttons GLFW_TRUE, // hat buttons
GLFW_ANGLE_PLATFORM_TYPE_NONE, // ANGLE backend
{ {
GLFW_TRUE, // macOS menu bar GLFW_TRUE, // macOS menu bar
GLFW_TRUE // macOS bundle chdir GLFW_TRUE // macOS bundle chdir
@@ -91,7 +90,6 @@ static void terminate(void)
_glfw.mappingCount = 0; _glfw.mappingCount = 0;
_glfwTerminateVulkan(); _glfwTerminateVulkan();
_glfwPlatformTerminateJoysticks();
_glfwPlatformTerminate(); _glfwPlatformTerminate();
_glfw.initialized = GLFW_FALSE; _glfw.initialized = GLFW_FALSE;
@@ -193,10 +191,6 @@ void _glfwInputError(int code, const char* format, ...)
strcpy(description, "The specified window has no context"); strcpy(description, "The specified window has no context");
else if (code == GLFW_CURSOR_UNAVAILABLE) else if (code == GLFW_CURSOR_UNAVAILABLE)
strcpy(description, "The specified cursor shape is unavailable"); strcpy(description, "The specified cursor shape is unavailable");
else if (code == GLFW_FEATURE_UNAVAILABLE)
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 else
strcpy(description, "ERROR: UNKNOWN GLFW ERROR"); strcpy(description, "ERROR: UNKNOWN GLFW ERROR");
} }
@@ -289,9 +283,6 @@ GLFWAPI void glfwInitHint(int hint, int value)
case GLFW_JOYSTICK_HAT_BUTTONS: case GLFW_JOYSTICK_HAT_BUTTONS:
_glfwInitHints.hatButtons = value; _glfwInitHints.hatButtons = value;
return; return;
case GLFW_ANGLE_PLATFORM_TYPE:
_glfwInitHints.angleType = value;
return;
case GLFW_COCOA_CHDIR_RESOURCES: case GLFW_COCOA_CHDIR_RESOURCES:
_glfwInitHints.ns.chdir = value; _glfwInitHints.ns.chdir = value;
return; return;
+21 -47
View File
@@ -43,22 +43,6 @@
#define _GLFW_JOYSTICK_BUTTON 2 #define _GLFW_JOYSTICK_BUTTON 2
#define _GLFW_JOYSTICK_HATBIT 3 #define _GLFW_JOYSTICK_HATBIT 3
// Initializes the platform joystick API if it has not been already
//
static GLFWbool initJoysticks(void)
{
if (!_glfw.joysticksInitialized)
{
if (!_glfwPlatformInitJoysticks())
{
_glfwPlatformTerminateJoysticks();
return GLFW_FALSE;
}
}
return _glfw.joysticksInitialized = GLFW_TRUE;
}
// Finds a mapping based on joystick GUID // Finds a mapping based on joystick GUID
// //
static _GLFWmapping* findMapping(const char* guid) static _GLFWmapping* findMapping(const char* guid)
@@ -272,6 +256,14 @@ static GLFWbool parseMapping(_GLFWmapping* mapping, const char* string)
////// GLFW event API ////// ////// GLFW event API //////
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// Notifies shared code of a keyboard layout change event
//
void _glfwInputKeyboardLayout(void)
{
if (_glfw.callbacks.layout)
_glfw.callbacks.layout();
}
// Notifies shared code of a physical key event // Notifies shared code of a physical key event
// //
void _glfwInputKey(_GLFWwindow* window, int key, int scancode, int action, int mods) void _glfwInputKey(_GLFWwindow* window, int key, int scancode, int action, int mods)
@@ -642,6 +634,19 @@ GLFWAPI int glfwGetKeyScancode(int key)
return _glfwPlatformGetKeyScancode(key); return _glfwPlatformGetKeyScancode(key);
} }
GLFWAPI const char* glfwGetKeyboardLayoutName(void)
{
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
return _glfwPlatformGetKeyboardLayoutName();
}
GLFWAPI GLFWkeyboardlayoutfun glfwSetKeyboardLayoutCallback(GLFWkeyboardlayoutfun cbfun)
{
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
_GLFW_SWAP_POINTERS(_glfw.callbacks.layout, cbfun);
return cbfun;
}
GLFWAPI int glfwGetKey(GLFWwindow* handle, int key) GLFWAPI int glfwGetKey(GLFWwindow* handle, int key)
{ {
_GLFWwindow* window = (_GLFWwindow*) handle; _GLFWwindow* window = (_GLFWwindow*) handle;
@@ -945,9 +950,6 @@ GLFWAPI int glfwJoystickPresent(int jid)
return GLFW_FALSE; return GLFW_FALSE;
} }
if (!initJoysticks())
return GLFW_FALSE;
js = _glfw.joysticks + jid; js = _glfw.joysticks + jid;
if (!js->present) if (!js->present)
return GLFW_FALSE; return GLFW_FALSE;
@@ -973,9 +975,6 @@ GLFWAPI const float* glfwGetJoystickAxes(int jid, int* count)
return NULL; return NULL;
} }
if (!initJoysticks())
return NULL;
js = _glfw.joysticks + jid; js = _glfw.joysticks + jid;
if (!js->present) if (!js->present)
return NULL; return NULL;
@@ -1005,9 +1004,6 @@ GLFWAPI const unsigned char* glfwGetJoystickButtons(int jid, int* count)
return NULL; return NULL;
} }
if (!initJoysticks())
return NULL;
js = _glfw.joysticks + jid; js = _glfw.joysticks + jid;
if (!js->present) if (!js->present)
return NULL; return NULL;
@@ -1041,9 +1037,6 @@ GLFWAPI const unsigned char* glfwGetJoystickHats(int jid, int* count)
return NULL; return NULL;
} }
if (!initJoysticks())
return NULL;
js = _glfw.joysticks + jid; js = _glfw.joysticks + jid;
if (!js->present) if (!js->present)
return NULL; return NULL;
@@ -1070,9 +1063,6 @@ GLFWAPI const char* glfwGetJoystickName(int jid)
return NULL; return NULL;
} }
if (!initJoysticks())
return NULL;
js = _glfw.joysticks + jid; js = _glfw.joysticks + jid;
if (!js->present) if (!js->present)
return NULL; return NULL;
@@ -1098,9 +1088,6 @@ GLFWAPI const char* glfwGetJoystickGUID(int jid)
return NULL; return NULL;
} }
if (!initJoysticks())
return NULL;
js = _glfw.joysticks + jid; js = _glfw.joysticks + jid;
if (!js->present) if (!js->present)
return NULL; return NULL;
@@ -1146,10 +1133,6 @@ GLFWAPI void* glfwGetJoystickUserPointer(int jid)
GLFWAPI GLFWjoystickfun glfwSetJoystickCallback(GLFWjoystickfun cbfun) GLFWAPI GLFWjoystickfun glfwSetJoystickCallback(GLFWjoystickfun cbfun)
{ {
_GLFW_REQUIRE_INIT_OR_RETURN(NULL); _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
if (!initJoysticks())
return NULL;
_GLFW_SWAP_POINTERS(_glfw.callbacks.joystick, cbfun); _GLFW_SWAP_POINTERS(_glfw.callbacks.joystick, cbfun);
return cbfun; return cbfun;
} }
@@ -1229,9 +1212,6 @@ GLFWAPI int glfwJoystickIsGamepad(int jid)
return GLFW_FALSE; return GLFW_FALSE;
} }
if (!initJoysticks())
return GLFW_FALSE;
js = _glfw.joysticks + jid; js = _glfw.joysticks + jid;
if (!js->present) if (!js->present)
return GLFW_FALSE; return GLFW_FALSE;
@@ -1257,9 +1237,6 @@ GLFWAPI const char* glfwGetGamepadName(int jid)
return NULL; return NULL;
} }
if (!initJoysticks())
return NULL;
js = _glfw.joysticks + jid; js = _glfw.joysticks + jid;
if (!js->present) if (!js->present)
return NULL; return NULL;
@@ -1292,9 +1269,6 @@ GLFWAPI int glfwGetGamepadState(int jid, GLFWgamepadstate* state)
return GLFW_FALSE; return GLFW_FALSE;
} }
if (!initJoysticks())
return GLFW_FALSE;
js = _glfw.joysticks + jid; js = _glfw.joysticks + jid;
if (!js->present) if (!js->present)
return GLFW_FALSE; return GLFW_FALSE;
+7 -18
View File
@@ -194,9 +194,6 @@ typedef void (APIENTRY * PFN_vkVoidFunction)(void);
#error "No supported window creation API selected" #error "No supported window creation API selected"
#endif #endif
#include "egl_context.h"
#include "osmesa_context.h"
// Constructs a version number string from the public header macros // Constructs a version number string from the public header macros
#define _GLFW_CONCAT_VERSION(m, n, r) #m "." #n "." #r #define _GLFW_CONCAT_VERSION(m, n, r) #m "." #n "." #r
#define _GLFW_MAKE_VERSION(m, n, r) _GLFW_CONCAT_VERSION(m, n, r) #define _GLFW_MAKE_VERSION(m, n, r) _GLFW_CONCAT_VERSION(m, n, r)
@@ -243,7 +240,6 @@ struct _GLFWerror
struct _GLFWinitconfig struct _GLFWinitconfig
{ {
GLFWbool hatButtons; GLFWbool hatButtons;
int angleType;
struct { struct {
GLFWbool menubar; GLFWbool menubar;
GLFWbool chdir; GLFWbool chdir;
@@ -270,7 +266,6 @@ struct _GLFWwndconfig
GLFWbool maximized; GLFWbool maximized;
GLFWbool centerCursor; GLFWbool centerCursor;
GLFWbool focusOnShow; GLFWbool focusOnShow;
GLFWbool mousePassthrough;
GLFWbool scaleToMonitor; GLFWbool scaleToMonitor;
struct { struct {
GLFWbool retina; GLFWbool retina;
@@ -364,9 +359,9 @@ struct _GLFWcontext
// This is defined in the context API's context.h // This is defined in the context API's context.h
_GLFW_PLATFORM_CONTEXT_STATE; _GLFW_PLATFORM_CONTEXT_STATE;
// This is defined in egl_context.h // This is defined in egl_context.h
_GLFWcontextEGL egl; _GLFW_EGL_CONTEXT_STATE;
// This is defined in osmesa_context.h // This is defined in osmesa_context.h
_GLFWcontextOSMesa osmesa; _GLFW_OSMESA_CONTEXT_STATE;
}; };
// Window and context structure // Window and context structure
@@ -381,7 +376,6 @@ struct _GLFWwindow
GLFWbool autoIconify; GLFWbool autoIconify;
GLFWbool floating; GLFWbool floating;
GLFWbool focusOnShow; GLFWbool focusOnShow;
GLFWbool mousePassthrough;
GLFWbool shouldClose; GLFWbool shouldClose;
void* userPointer; void* userPointer;
GLFWvidmode videoMode; GLFWvidmode videoMode;
@@ -539,7 +533,6 @@ struct _GLFWlibrary
_GLFWmonitor** monitors; _GLFWmonitor** monitors;
int monitorCount; int monitorCount;
GLFWbool joysticksInitialized;
_GLFWjoystick joysticks[GLFW_JOYSTICK_LAST + 1]; _GLFWjoystick joysticks[GLFW_JOYSTICK_LAST + 1];
_GLFWmapping* mappings; _GLFWmapping* mappings;
int mappingCount; int mappingCount;
@@ -579,6 +572,7 @@ struct _GLFWlibrary
struct { struct {
GLFWmonitorfun monitor; GLFWmonitorfun monitor;
GLFWjoystickfun joystick; GLFWjoystickfun joystick;
GLFWkeyboardlayoutfun layout;
} callbacks; } callbacks;
// This is defined in the window API's platform.h // This is defined in the window API's platform.h
@@ -588,9 +582,9 @@ struct _GLFWlibrary
// This is defined in the platform's joystick.h // This is defined in the platform's joystick.h
_GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE; _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE;
// This is defined in egl_context.h // This is defined in egl_context.h
_GLFWlibraryEGL egl; _GLFW_EGL_LIBRARY_CONTEXT_STATE;
// This is defined in osmesa_context.h // This is defined in osmesa_context.h
_GLFWlibraryOSMesa osmesa; _GLFW_OSMESA_LIBRARY_CONTEXT_STATE;
}; };
// Global state shared between compilation units of GLFW // Global state shared between compilation units of GLFW
@@ -619,6 +613,7 @@ void _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor);
const char* _glfwPlatformGetScancodeName(int scancode); const char* _glfwPlatformGetScancodeName(int scancode);
int _glfwPlatformGetKeyScancode(int key); int _glfwPlatformGetKeyScancode(int key);
const char* _glfwPlatformGetKeyboardLayoutName(void);
void _glfwPlatformFreeMonitor(_GLFWmonitor* monitor); void _glfwPlatformFreeMonitor(_GLFWmonitor* monitor);
void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos); void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos);
@@ -633,8 +628,6 @@ void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp)
void _glfwPlatformSetClipboardString(const char* string); void _glfwPlatformSetClipboardString(const char* string);
const char* _glfwPlatformGetClipboardString(void); const char* _glfwPlatformGetClipboardString(void);
GLFWbool _glfwPlatformInitJoysticks(void);
void _glfwPlatformTerminateJoysticks(void);
int _glfwPlatformPollJoystick(_GLFWjoystick* js, int mode); int _glfwPlatformPollJoystick(_GLFWjoystick* js, int mode);
void _glfwPlatformUpdateGamepadGUID(char* guid); void _glfwPlatformUpdateGamepadGUID(char* guid);
@@ -683,7 +676,6 @@ float _glfwPlatformGetWindowOpacity(_GLFWwindow* window);
void _glfwPlatformSetWindowResizable(_GLFWwindow* window, GLFWbool enabled); void _glfwPlatformSetWindowResizable(_GLFWwindow* window, GLFWbool enabled);
void _glfwPlatformSetWindowDecorated(_GLFWwindow* window, GLFWbool enabled); void _glfwPlatformSetWindowDecorated(_GLFWwindow* window, GLFWbool enabled);
void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled); void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled);
void _glfwPlatformSetWindowMousePassthrough(_GLFWwindow* window, GLFWbool enabled);
void _glfwPlatformSetWindowOpacity(_GLFWwindow* window, float opacity); void _glfwPlatformSetWindowOpacity(_GLFWwindow* window, float opacity);
void _glfwPlatformPollEvents(void); void _glfwPlatformPollEvents(void);
@@ -691,10 +683,6 @@ void _glfwPlatformWaitEvents(void);
void _glfwPlatformWaitEventsTimeout(double timeout); void _glfwPlatformWaitEventsTimeout(double timeout);
void _glfwPlatformPostEmptyEvent(void); void _glfwPlatformPostEmptyEvent(void);
EGLenum _glfwPlatformGetEGLPlatform(EGLint** attribs);
EGLNativeDisplayType _glfwPlatformGetEGLNativeDisplay(void);
EGLNativeWindowType _glfwPlatformGetEGLNativeWindow(_GLFWwindow* window);
void _glfwPlatformGetRequiredInstanceExtensions(char** extensions); void _glfwPlatformGetRequiredInstanceExtensions(char** extensions);
int _glfwPlatformGetPhysicalDevicePresentationSupport(VkInstance instance, int _glfwPlatformGetPhysicalDevicePresentationSupport(VkInstance instance,
VkPhysicalDevice device, VkPhysicalDevice device,
@@ -731,6 +719,7 @@ void _glfwInputWindowDamage(_GLFWwindow* window);
void _glfwInputWindowCloseRequest(_GLFWwindow* window); void _glfwInputWindowCloseRequest(_GLFWwindow* window);
void _glfwInputWindowMonitor(_GLFWwindow* window, _GLFWmonitor* monitor); void _glfwInputWindowMonitor(_GLFWwindow* window, _GLFWmonitor* monitor);
void _glfwInputKeyboardLayout(void);
void _glfwInputKey(_GLFWwindow* window, void _glfwInputKey(_GLFWwindow* window,
int key, int scancode, int action, int mods); int key, int scancode, int action, int mods);
void _glfwInputChar(_GLFWwindow* window, void _glfwInputChar(_GLFWwindow* window,
+51 -46
View File
@@ -264,50 +264,9 @@ static int compareJoysticks(const void* fp, const void* sp)
////// GLFW internal API ////// ////// GLFW internal API //////
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void _glfwDetectJoystickConnectionLinux(void) // Initialize joystick interface
{ //
if (_glfw.linjs.inotify <= 0) GLFWbool _glfwInitJoysticksLinux(void)
return;
ssize_t offset = 0;
char buffer[16384];
const ssize_t size = read(_glfw.linjs.inotify, buffer, sizeof(buffer));
while (size > offset)
{
regmatch_t match;
const struct inotify_event* e = (struct inotify_event*) (buffer + offset);
offset += sizeof(struct inotify_event) + e->len;
if (regexec(&_glfw.linjs.regex, e->name, 1, &match, 0) != 0)
continue;
char path[PATH_MAX];
snprintf(path, sizeof(path), "/dev/input/%s", e->name);
if (e->mask & (IN_CREATE | IN_ATTRIB))
openJoystickDevice(path);
else if (e->mask & IN_DELETE)
{
for (int jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++)
{
if (strcmp(_glfw.joysticks[jid].linjs.path, path) == 0)
{
closeJoystick(_glfw.joysticks + jid);
break;
}
}
}
}
}
//////////////////////////////////////////////////////////////////////////
////// GLFW platform API //////
//////////////////////////////////////////////////////////////////////////
GLFWbool _glfwPlatformInitJoysticks(void)
{ {
const char* dirname = "/dev/input"; const char* dirname = "/dev/input";
@@ -361,7 +320,9 @@ GLFWbool _glfwPlatformInitJoysticks(void)
return GLFW_TRUE; return GLFW_TRUE;
} }
void _glfwPlatformTerminateJoysticks(void) // Close all opened joystick handles
//
void _glfwTerminateJoysticksLinux(void)
{ {
int jid; int jid;
@@ -372,16 +333,60 @@ void _glfwPlatformTerminateJoysticks(void)
closeJoystick(js); closeJoystick(js);
} }
regfree(&_glfw.linjs.regex);
if (_glfw.linjs.inotify > 0) if (_glfw.linjs.inotify > 0)
{ {
if (_glfw.linjs.watch > 0) if (_glfw.linjs.watch > 0)
inotify_rm_watch(_glfw.linjs.inotify, _glfw.linjs.watch); inotify_rm_watch(_glfw.linjs.inotify, _glfw.linjs.watch);
close(_glfw.linjs.inotify); close(_glfw.linjs.inotify);
regfree(&_glfw.linjs.regex);
} }
} }
void _glfwDetectJoystickConnectionLinux(void)
{
if (_glfw.linjs.inotify <= 0)
return;
ssize_t offset = 0;
char buffer[16384];
const ssize_t size = read(_glfw.linjs.inotify, buffer, sizeof(buffer));
while (size > offset)
{
regmatch_t match;
const struct inotify_event* e = (struct inotify_event*) (buffer + offset);
offset += sizeof(struct inotify_event) + e->len;
if (regexec(&_glfw.linjs.regex, e->name, 1, &match, 0) != 0)
continue;
char path[PATH_MAX];
snprintf(path, sizeof(path), "/dev/input/%s", e->name);
if (e->mask & (IN_CREATE | IN_ATTRIB))
openJoystickDevice(path);
else if (e->mask & IN_DELETE)
{
for (int jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++)
{
if (strcmp(_glfw.joysticks[jid].linjs.path, path) == 0)
{
closeJoystick(_glfw.joysticks + jid);
break;
}
}
}
}
}
//////////////////////////////////////////////////////////////////////////
////// GLFW platform API //////
//////////////////////////////////////////////////////////////////////////
int _glfwPlatformPollJoystick(_GLFWjoystick* js, int mode) int _glfwPlatformPollJoystick(_GLFWjoystick* js, int mode)
{ {
// Read all queued events (non-blocking) // Read all queued events (non-blocking)
+3
View File
@@ -55,5 +55,8 @@ typedef struct _GLFWlibraryLinux
GLFWbool dropped; GLFWbool dropped;
} _GLFWlibraryLinux; } _GLFWlibraryLinux;
GLFWbool _glfwInitJoysticksLinux(void);
void _glfwTerminateJoysticksLinux(void);
void _glfwDetectJoystickConnectionLinux(void); void _glfwDetectJoystickConnectionLinux(void);
-5
View File
@@ -29,8 +29,6 @@
#include "internal.h" #include "internal.h"
#include <stdlib.h>
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
////// GLFW platform API ////// ////// GLFW platform API //////
@@ -39,14 +37,11 @@
int _glfwPlatformInit(void) int _glfwPlatformInit(void)
{ {
_glfwInitTimerPOSIX(); _glfwInitTimerPOSIX();
_glfwPollMonitorsNull();
return GLFW_TRUE; return GLFW_TRUE;
} }
void _glfwPlatformTerminate(void) void _glfwPlatformTerminate(void)
{ {
free(_glfw.null.clipboardString);
_glfwTerminateOSMesa(); _glfwTerminateOSMesa();
} }
-9
View File
@@ -33,15 +33,6 @@
////// GLFW platform API ////// ////// GLFW platform API //////
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
GLFWbool _glfwPlatformInitJoysticks(void)
{
return GLFW_TRUE;
}
void _glfwPlatformTerminateJoysticks(void)
{
}
int _glfwPlatformPollJoystick(_GLFWjoystick* js, int mode) int _glfwPlatformPollJoystick(_GLFWjoystick* js, int mode)
{ {
return GLFW_FALSE; return GLFW_FALSE;
+2 -84
View File
@@ -29,37 +29,6 @@
#include "internal.h" #include "internal.h"
#include <stdlib.h>
#include <string.h>
#include <math.h>
// The the sole (fake) video mode of our (sole) fake monitor
//
static GLFWvidmode getVideoMode(void)
{
GLFWvidmode mode;
mode.width = 1920;
mode.height = 1080;
mode.redBits = 8;
mode.greenBits = 8;
mode.blueBits = 8;
mode.refreshRate = 60;
return mode;
}
//////////////////////////////////////////////////////////////////////////
////// GLFW internal API //////
//////////////////////////////////////////////////////////////////////////
void _glfwPollMonitorsNull(void)
{
const float dpi = 141.f;
const GLFWvidmode mode = getVideoMode();
_GLFWmonitor* monitor = _glfwAllocMonitor("Null SuperNoop 0",
(int) (mode.width * 25.4f / dpi),
(int) (mode.height * 25.4f / dpi));
_glfwInputMonitor(monitor, GLFW_CONNECTED, _GLFW_INSERT_FIRST);
}
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
////// GLFW platform API ////// ////// GLFW platform API //////
@@ -67,15 +36,10 @@ void _glfwPollMonitorsNull(void)
void _glfwPlatformFreeMonitor(_GLFWmonitor* monitor) void _glfwPlatformFreeMonitor(_GLFWmonitor* monitor)
{ {
_glfwFreeGammaArrays(&monitor->null.ramp);
} }
void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos) void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos)
{ {
if (xpos)
*xpos = 0;
if (ypos)
*ypos = 0;
} }
void _glfwPlatformGetMonitorContentScale(_GLFWmonitor* monitor, void _glfwPlatformGetMonitorContentScale(_GLFWmonitor* monitor,
@@ -91,69 +55,23 @@ void _glfwPlatformGetMonitorWorkarea(_GLFWmonitor* monitor,
int* xpos, int* ypos, int* xpos, int* ypos,
int* width, int* height) int* width, int* height)
{ {
const GLFWvidmode mode = getVideoMode();
if (xpos)
*xpos = 0;
if (ypos)
*ypos = 10;
if (width)
*width = mode.width;
if (height)
*height = mode.height - 10;
} }
GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* found) GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* found)
{ {
GLFWvidmode* mode = calloc(1, sizeof(GLFWvidmode)); return NULL;
*mode = getVideoMode();
*found = 1;
return mode;
} }
void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode) void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode)
{ {
*mode = getVideoMode();
} }
GLFWbool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp) GLFWbool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
{ {
if (!monitor->null.ramp.size) return GLFW_FALSE;
{
_glfwAllocGammaArrays(&monitor->null.ramp, 256);
for (unsigned int i = 0; i < monitor->null.ramp.size; i++)
{
const float gamma = 2.2f;
float value;
value = i / (float) (monitor->null.ramp.size - 1);
value = powf(value, 1.f / gamma) * 65535.f + 0.5f;
value = _glfw_fminf(value, 65535.f);
monitor->null.ramp.red[i] = (unsigned short) value;
monitor->null.ramp.green[i] = (unsigned short) value;
monitor->null.ramp.blue[i] = (unsigned short) value;
}
}
_glfwAllocGammaArrays(ramp, monitor->null.ramp.size);
memcpy(ramp->red, monitor->null.ramp.red, sizeof(short) * ramp->size);
memcpy(ramp->green, monitor->null.ramp.green, sizeof(short) * ramp->size);
memcpy(ramp->blue, monitor->null.ramp.blue, sizeof(short) * ramp->size);
return GLFW_TRUE;
} }
void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp) void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp)
{ {
if (monitor->null.ramp.size != ramp->size)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"Null: Gamma ramp size must match current ramp size");
return;
}
memcpy(monitor->null.ramp.red, ramp->red, sizeof(short) * ramp->size);
memcpy(monitor->null.ramp.green, ramp->green, sizeof(short) * ramp->size);
memcpy(monitor->null.ramp.blue, ramp->blue, sizeof(short) * ramp->size);
} }
+5 -32
View File
@@ -28,13 +28,16 @@
#include <dlfcn.h> #include <dlfcn.h>
#define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowNull null #define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowNull null
#define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryNull null
#define _GLFW_PLATFORM_MONITOR_STATE _GLFWmonitorNull null
#define _GLFW_PLATFORM_CONTEXT_STATE struct { int dummyContext; } #define _GLFW_PLATFORM_CONTEXT_STATE struct { int dummyContext; }
#define _GLFW_PLATFORM_MONITOR_STATE struct { int dummyMonitor; }
#define _GLFW_PLATFORM_CURSOR_STATE struct { int dummyCursor; } #define _GLFW_PLATFORM_CURSOR_STATE struct { int dummyCursor; }
#define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE struct { int dummyLibraryWindow; }
#define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE struct { int dummyLibraryContext; } #define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE struct { int dummyLibraryContext; }
#define _GLFW_EGL_CONTEXT_STATE struct { int dummyEGLContext; }
#define _GLFW_EGL_LIBRARY_CONTEXT_STATE struct { int dummyEGLLibraryContext; }
#include "osmesa_context.h"
#include "posix_time.h" #include "posix_time.h"
#include "posix_thread.h" #include "posix_thread.h"
#include "null_joystick.h" #include "null_joystick.h"
@@ -53,37 +56,7 @@
// //
typedef struct _GLFWwindowNull typedef struct _GLFWwindowNull
{ {
int xpos;
int ypos;
int width; int width;
int height; int height;
char* title;
GLFWbool visible;
GLFWbool iconified;
GLFWbool maximized;
GLFWbool resizable;
GLFWbool decorated;
GLFWbool floating;
GLFWbool transparent;
float opacity;
} _GLFWwindowNull; } _GLFWwindowNull;
// Null-specific per-monitor data
//
typedef struct _GLFWmonitorNull
{
GLFWgammaramp ramp;
} _GLFWmonitorNull;
// Null-specific global data
//
typedef struct _GLFWlibraryNull
{
int xcursor;
int ycursor;
char* clipboardString;
_GLFWwindow* focusedWindow;
} _GLFWlibraryNull;
void _glfwPollMonitorsNull(void);
+23 -356
View File
@@ -29,71 +29,12 @@
#include "internal.h" #include "internal.h"
#include <stdlib.h>
static void applySizeLimits(_GLFWwindow* window, int* width, int* height)
{
if (window->numer != GLFW_DONT_CARE && window->denom != GLFW_DONT_CARE)
{
const float ratio = (float) window->numer / (float) window->denom;
*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->minheight != GLFW_DONT_CARE && *height < window->minheight)
*height = window->minheight;
else if (window->maxheight != GLFW_DONT_CARE && *height > window->maxheight)
*height = window->maxheight;
}
static void fitToMonitor(_GLFWwindow* window)
{
GLFWvidmode mode;
_glfwPlatformGetVideoMode(window->monitor, &mode);
_glfwPlatformGetMonitorPos(window->monitor,
&window->null.xpos,
&window->null.ypos);
window->null.width = mode.width;
window->null.height = mode.height;
}
static void acquireMonitor(_GLFWwindow* window)
{
_glfwInputMonitorWindow(window->monitor, window);
}
static void releaseMonitor(_GLFWwindow* window)
{
if (window->monitor->window != window)
return;
_glfwInputMonitorWindow(window->monitor, NULL);
}
static int createNativeWindow(_GLFWwindow* window, static int createNativeWindow(_GLFWwindow* window,
const _GLFWwndconfig* wndconfig, const _GLFWwndconfig* wndconfig)
const _GLFWfbconfig* fbconfig)
{ {
if (window->monitor)
fitToMonitor(window);
else
{
window->null.xpos = 17;
window->null.ypos = 17;
window->null.width = wndconfig->width; window->null.width = wndconfig->width;
window->null.height = wndconfig->height; window->null.height = wndconfig->height;
}
window->null.visible = wndconfig->visible;
window->null.decorated = wndconfig->decorated;
window->null.maximized = wndconfig->maximized;
window->null.floating = wndconfig->floating;
window->null.transparent = fbconfig->transparent;
window->null.opacity = 1.f;
return GLFW_TRUE; return GLFW_TRUE;
} }
@@ -108,7 +49,7 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
const _GLFWctxconfig* ctxconfig, const _GLFWctxconfig* ctxconfig,
const _GLFWfbconfig* fbconfig) const _GLFWfbconfig* fbconfig)
{ {
if (!createNativeWindow(window, wndconfig, fbconfig)) if (!createNativeWindow(window, wndconfig))
return GLFW_FALSE; return GLFW_FALSE;
if (ctxconfig->client != GLFW_NO_API) if (ctxconfig->client != GLFW_NO_API)
@@ -128,24 +69,11 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
} }
} }
if (window->monitor)
{
_glfwPlatformShowWindow(window);
_glfwPlatformFocusWindow(window);
acquireMonitor(window);
}
return GLFW_TRUE; return GLFW_TRUE;
} }
void _glfwPlatformDestroyWindow(_GLFWwindow* window) void _glfwPlatformDestroyWindow(_GLFWwindow* window)
{ {
if (window->monitor)
releaseMonitor(window);
if (_glfw.null.focusedWindow == window)
_glfw.null.focusedWindow = NULL;
if (window->context.destroy) if (window->context.destroy)
window->context.destroy(window); window->context.destroy(window);
} }
@@ -165,54 +93,14 @@ void _glfwPlatformSetWindowMonitor(_GLFWwindow* window,
int width, int height, int width, int height,
int refreshRate) int refreshRate)
{ {
if (window->monitor == monitor)
{
if (!monitor)
{
_glfwPlatformSetWindowPos(window, xpos, ypos);
_glfwPlatformSetWindowSize(window, width, height);
}
return;
}
if (window->monitor)
releaseMonitor(window);
_glfwInputWindowMonitor(window, monitor);
if (window->monitor)
{
window->null.visible = GLFW_TRUE;
acquireMonitor(window);
fitToMonitor(window);
}
else
{
_glfwPlatformSetWindowPos(window, xpos, ypos);
_glfwPlatformSetWindowSize(window, width, height);
}
} }
void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos) void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos)
{ {
if (xpos)
*xpos = window->null.xpos;
if (ypos)
*ypos = window->null.ypos;
} }
void _glfwPlatformSetWindowPos(_GLFWwindow* window, int xpos, int ypos) void _glfwPlatformSetWindowPos(_GLFWwindow* window, int xpos, int ypos)
{ {
if (window->monitor)
return;
if (window->null.xpos != xpos || window->null.ypos != ypos)
{
window->null.xpos = xpos;
window->null.ypos = ypos;
_glfwInputWindowPos(window, xpos, ypos);
}
} }
void _glfwPlatformGetWindowSize(_GLFWwindow* window, int* width, int* height) void _glfwPlatformGetWindowSize(_GLFWwindow* window, int* width, int* height)
@@ -224,35 +112,19 @@ void _glfwPlatformGetWindowSize(_GLFWwindow* window, int* width, int* height)
} }
void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height) void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
{
if (window->monitor)
return;
if (window->null.width != width || window->null.height != height)
{ {
window->null.width = width; window->null.width = width;
window->null.height = height; window->null.height = height;
_glfwInputWindowSize(window, width, height);
_glfwInputFramebufferSize(window, width, height);
}
} }
void _glfwPlatformSetWindowSizeLimits(_GLFWwindow* window, void _glfwPlatformSetWindowSizeLimits(_GLFWwindow* window,
int minwidth, int minheight, int minwidth, int minheight,
int maxwidth, int maxheight) int maxwidth, int maxheight)
{ {
int width = window->null.width;
int height = window->null.height;
applySizeLimits(window, &width, &height);
_glfwPlatformSetWindowSize(window, width, height);
} }
void _glfwPlatformSetWindowAspectRatio(_GLFWwindow* window, int n, int d) void _glfwPlatformSetWindowAspectRatio(_GLFWwindow* window, int n, int d)
{ {
int width = window->null.width;
int height = window->null.height;
applySizeLimits(window, &width, &height);
_glfwPlatformSetWindowSize(window, width, height);
} }
void _glfwPlatformGetFramebufferSize(_GLFWwindow* window, int* width, int* height) void _glfwPlatformGetFramebufferSize(_GLFWwindow* window, int* width, int* height)
@@ -267,28 +139,6 @@ void _glfwPlatformGetWindowFrameSize(_GLFWwindow* window,
int* left, int* top, int* left, int* top,
int* right, int* bottom) int* right, int* bottom)
{ {
if (window->null.decorated && !window->monitor)
{
if (left)
*left = 1;
if (top)
*top = 10;
if (right)
*right = 1;
if (bottom)
*bottom = 1;
}
else
{
if (left)
*left = 0;
if (top)
*top = 0;
if (right)
*right = 0;
if (bottom)
*bottom = 0;
}
} }
void _glfwPlatformGetWindowContentScale(_GLFWwindow* window, void _glfwPlatformGetWindowContentScale(_GLFWwindow* window,
@@ -302,93 +152,50 @@ void _glfwPlatformGetWindowContentScale(_GLFWwindow* window,
void _glfwPlatformIconifyWindow(_GLFWwindow* window) void _glfwPlatformIconifyWindow(_GLFWwindow* window)
{ {
if (_glfw.null.focusedWindow == window)
{
_glfw.null.focusedWindow = NULL;
_glfwInputWindowFocus(window, GLFW_FALSE);
}
if (!window->null.iconified)
{
window->null.iconified = GLFW_TRUE;
_glfwInputWindowIconify(window, GLFW_TRUE);
if (window->monitor)
releaseMonitor(window);
}
} }
void _glfwPlatformRestoreWindow(_GLFWwindow* window) void _glfwPlatformRestoreWindow(_GLFWwindow* window)
{ {
if (window->null.iconified)
{
window->null.iconified = GLFW_FALSE;
_glfwInputWindowIconify(window, GLFW_FALSE);
if (window->monitor)
acquireMonitor(window);
}
else if (window->null.maximized)
{
window->null.maximized = GLFW_FALSE;
_glfwInputWindowMaximize(window, GLFW_FALSE);
}
} }
void _glfwPlatformMaximizeWindow(_GLFWwindow* window) void _glfwPlatformMaximizeWindow(_GLFWwindow* window)
{ {
if (!window->null.maximized)
{
window->null.maximized = GLFW_TRUE;
_glfwInputWindowMaximize(window, GLFW_TRUE);
}
} }
int _glfwPlatformWindowMaximized(_GLFWwindow* window) int _glfwPlatformWindowMaximized(_GLFWwindow* window)
{ {
return window->null.maximized; return GLFW_FALSE;
} }
int _glfwPlatformWindowHovered(_GLFWwindow* window) int _glfwPlatformWindowHovered(_GLFWwindow* window)
{ {
return _glfw.null.xcursor >= window->null.xpos && return GLFW_FALSE;
_glfw.null.ycursor >= window->null.ypos &&
_glfw.null.xcursor <= window->null.xpos + window->null.width - 1 &&
_glfw.null.ycursor <= window->null.ypos + window->null.height - 1;
} }
int _glfwPlatformFramebufferTransparent(_GLFWwindow* window) int _glfwPlatformFramebufferTransparent(_GLFWwindow* window)
{ {
return window->null.transparent; return GLFW_FALSE;
} }
void _glfwPlatformSetWindowResizable(_GLFWwindow* window, GLFWbool enabled) void _glfwPlatformSetWindowResizable(_GLFWwindow* window, GLFWbool enabled)
{ {
window->null.resizable = enabled;
} }
void _glfwPlatformSetWindowDecorated(_GLFWwindow* window, GLFWbool enabled) void _glfwPlatformSetWindowDecorated(_GLFWwindow* window, GLFWbool enabled)
{ {
window->null.decorated = enabled;
} }
void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled) void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled)
{
window->null.floating = enabled;
}
void _glfwPlatformSetWindowMousePassthrough(_GLFWwindow* window, GLFWbool enabled)
{ {
} }
float _glfwPlatformGetWindowOpacity(_GLFWwindow* window) float _glfwPlatformGetWindowOpacity(_GLFWwindow* window)
{ {
return window->null.opacity; return 1.f;
} }
void _glfwPlatformSetWindowOpacity(_GLFWwindow* window, float opacity) void _glfwPlatformSetWindowOpacity(_GLFWwindow* window, float opacity)
{ {
window->null.opacity = opacity;
} }
void _glfwPlatformSetRawMouseMotion(_GLFWwindow *window, GLFWbool enabled) void _glfwPlatformSetRawMouseMotion(_GLFWwindow *window, GLFWbool enabled)
@@ -397,63 +204,43 @@ void _glfwPlatformSetRawMouseMotion(_GLFWwindow *window, GLFWbool enabled)
GLFWbool _glfwPlatformRawMouseMotionSupported(void) GLFWbool _glfwPlatformRawMouseMotionSupported(void)
{ {
return GLFW_TRUE; return GLFW_FALSE;
} }
void _glfwPlatformShowWindow(_GLFWwindow* window) void _glfwPlatformShowWindow(_GLFWwindow* window)
{ {
window->null.visible = GLFW_TRUE;
} }
void _glfwPlatformRequestWindowAttention(_GLFWwindow* window) void _glfwPlatformRequestWindowAttention(_GLFWwindow* window)
{ {
} }
void _glfwPlatformHideWindow(_GLFWwindow* window) void _glfwPlatformUnhideWindow(_GLFWwindow* window)
{ {
if (_glfw.null.focusedWindow == window)
{
_glfw.null.focusedWindow = NULL;
_glfwInputWindowFocus(window, GLFW_FALSE);
} }
window->null.visible = GLFW_FALSE; void _glfwPlatformHideWindow(_GLFWwindow* window)
{
} }
void _glfwPlatformFocusWindow(_GLFWwindow* window) void _glfwPlatformFocusWindow(_GLFWwindow* window)
{ {
if (_glfw.null.focusedWindow == window)
return;
if (!window->null.visible)
return;
_GLFWwindow* previous = _glfw.null.focusedWindow;
_glfw.null.focusedWindow = window;
if (previous)
{
_glfwInputWindowFocus(previous, GLFW_FALSE);
if (previous->monitor && previous->autoIconify)
_glfwPlatformIconifyWindow(previous);
}
_glfwInputWindowFocus(window, GLFW_TRUE);
} }
int _glfwPlatformWindowFocused(_GLFWwindow* window) int _glfwPlatformWindowFocused(_GLFWwindow* window)
{ {
return _glfw.null.focusedWindow == window; return GLFW_FALSE;
} }
int _glfwPlatformWindowIconified(_GLFWwindow* window) int _glfwPlatformWindowIconified(_GLFWwindow* window)
{ {
return window->null.iconified; return GLFW_FALSE;
} }
int _glfwPlatformWindowVisible(_GLFWwindow* window) int _glfwPlatformWindowVisible(_GLFWwindow* window)
{ {
return window->null.visible; return GLFW_FALSE;
} }
void _glfwPlatformPollEvents(void) void _glfwPlatformPollEvents(void)
@@ -474,16 +261,10 @@ void _glfwPlatformPostEmptyEvent(void)
void _glfwPlatformGetCursorPos(_GLFWwindow* window, double* xpos, double* ypos) void _glfwPlatformGetCursorPos(_GLFWwindow* window, double* xpos, double* ypos)
{ {
if (xpos)
*xpos = _glfw.null.xcursor - window->null.xpos;
if (ypos)
*ypos = _glfw.null.ycursor - window->null.ypos;
} }
void _glfwPlatformSetCursorPos(_GLFWwindow* window, double x, double y) void _glfwPlatformSetCursorPos(_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 _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode)
@@ -512,140 +293,26 @@ void _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor)
void _glfwPlatformSetClipboardString(const char* string) void _glfwPlatformSetClipboardString(const char* string)
{ {
char* copy = _glfw_strdup(string);
free(_glfw.null.clipboardString);
_glfw.null.clipboardString = copy;
} }
const char* _glfwPlatformGetClipboardString(void) const char* _glfwPlatformGetClipboardString(void)
{ {
return _glfw.null.clipboardString; return NULL;
} }
const char* _glfwPlatformGetScancodeName(int scancode) const char* _glfwPlatformGetScancodeName(int scancode)
{ {
switch (scancode) return "";
{
case GLFW_KEY_APOSTROPHE:
return "'";
case GLFW_KEY_COMMA:
return ",";
case GLFW_KEY_MINUS:
case GLFW_KEY_KP_SUBTRACT:
return "-";
case GLFW_KEY_PERIOD:
case GLFW_KEY_KP_DECIMAL:
return ".";
case GLFW_KEY_SLASH:
case GLFW_KEY_KP_DIVIDE:
return "/";
case GLFW_KEY_SEMICOLON:
return ";";
case GLFW_KEY_EQUAL:
case GLFW_KEY_KP_EQUAL:
return "=";
case GLFW_KEY_LEFT_BRACKET:
return "[";
case GLFW_KEY_RIGHT_BRACKET:
return "]";
case GLFW_KEY_KP_MULTIPLY:
return "*";
case GLFW_KEY_KP_ADD:
return "+";
case GLFW_KEY_BACKSLASH:
case GLFW_KEY_WORLD_1:
case GLFW_KEY_WORLD_2:
return "\\";
case GLFW_KEY_0:
case GLFW_KEY_KP_0:
return "0";
case GLFW_KEY_1:
case GLFW_KEY_KP_1:
return "1";
case GLFW_KEY_2:
case GLFW_KEY_KP_2:
return "2";
case GLFW_KEY_3:
case GLFW_KEY_KP_3:
return "3";
case GLFW_KEY_4:
case GLFW_KEY_KP_4:
return "4";
case GLFW_KEY_5:
case GLFW_KEY_KP_5:
return "5";
case GLFW_KEY_6:
case GLFW_KEY_KP_6:
return "6";
case GLFW_KEY_7:
case GLFW_KEY_KP_7:
return "7";
case GLFW_KEY_8:
case GLFW_KEY_KP_8:
return "8";
case GLFW_KEY_9:
case GLFW_KEY_KP_9:
return "9";
case GLFW_KEY_A:
return "a";
case GLFW_KEY_B:
return "b";
case GLFW_KEY_C:
return "c";
case GLFW_KEY_D:
return "d";
case GLFW_KEY_E:
return "e";
case GLFW_KEY_F:
return "f";
case GLFW_KEY_G:
return "g";
case GLFW_KEY_H:
return "h";
case GLFW_KEY_I:
return "i";
case GLFW_KEY_J:
return "j";
case GLFW_KEY_K:
return "k";
case GLFW_KEY_L:
return "l";
case GLFW_KEY_M:
return "m";
case GLFW_KEY_N:
return "n";
case GLFW_KEY_O:
return "o";
case GLFW_KEY_P:
return "p";
case GLFW_KEY_Q:
return "q";
case GLFW_KEY_R:
return "r";
case GLFW_KEY_S:
return "s";
case GLFW_KEY_T:
return "t";
case GLFW_KEY_U:
return "u";
case GLFW_KEY_V:
return "v";
case GLFW_KEY_W:
return "w";
case GLFW_KEY_X:
return "x";
case GLFW_KEY_Y:
return "y";
case GLFW_KEY_Z:
return "z";
}
return NULL;
} }
int _glfwPlatformGetKeyScancode(int key) int _glfwPlatformGetKeyScancode(int key)
{ {
return key; return -1;
}
const char* _glfwPlatformGetKeyboardLayoutName(void)
{
return "";
} }
void _glfwPlatformGetRequiredInstanceExtensions(char** extensions) void _glfwPlatformGetRequiredInstanceExtensions(char** extensions)
@@ -665,6 +332,6 @@ VkResult _glfwPlatformCreateWindowSurface(VkInstance instance,
VkSurfaceKHR* surface) VkSurfaceKHR* surface)
{ {
// This seems like the most appropriate error to return here // This seems like the most appropriate error to return here
return VK_ERROR_EXTENSION_NOT_PRESENT; return VK_ERROR_INITIALIZATION_FAILED;
} }
+4
View File
@@ -54,6 +54,10 @@ typedef GLFWglproc (GLAPIENTRY * PFN_OSMesaGetProcAddress)(const char*);
#define OSMesaGetDepthBuffer _glfw.osmesa.GetDepthBuffer #define OSMesaGetDepthBuffer _glfw.osmesa.GetDepthBuffer
#define OSMesaGetProcAddress _glfw.osmesa.GetProcAddress #define OSMesaGetProcAddress _glfw.osmesa.GetProcAddress
#define _GLFW_OSMESA_CONTEXT_STATE _GLFWcontextOSMesa osmesa
#define _GLFW_OSMESA_LIBRARY_CONTEXT_STATE _GLFWlibraryOSMesa osmesa
// OSMesa-specific per-context data // OSMesa-specific per-context data
// //
typedef struct _GLFWcontextOSMesa typedef struct _GLFWcontextOSMesa
+4 -2
View File
@@ -143,8 +143,6 @@ static GLFWbool loadLibraries(void)
GetProcAddress(_glfw.win32.dwmapi.instance, "DwmFlush"); GetProcAddress(_glfw.win32.dwmapi.instance, "DwmFlush");
_glfw.win32.dwmapi.EnableBlurBehindWindow = (PFN_DwmEnableBlurBehindWindow) _glfw.win32.dwmapi.EnableBlurBehindWindow = (PFN_DwmEnableBlurBehindWindow)
GetProcAddress(_glfw.win32.dwmapi.instance, "DwmEnableBlurBehindWindow"); GetProcAddress(_glfw.win32.dwmapi.instance, "DwmEnableBlurBehindWindow");
_glfw.win32.dwmapi.GetColorizationColor = (PFN_DwmGetColorizationColor)
GetProcAddress(_glfw.win32.dwmapi.instance, "DwmGetColorizationColor");
} }
_glfw.win32.shcore.instance = LoadLibraryA("shcore.dll"); _glfw.win32.shcore.instance = LoadLibraryA("shcore.dll");
@@ -582,6 +580,7 @@ int _glfwPlatformInit(void)
return GLFW_FALSE; return GLFW_FALSE;
_glfwInitTimerWin32(); _glfwInitTimerWin32();
_glfwInitJoysticksWin32();
_glfwPollMonitorsWin32(); _glfwPollMonitorsWin32();
return GLFW_TRUE; return GLFW_TRUE;
@@ -603,11 +602,14 @@ void _glfwPlatformTerminate(void)
SPIF_SENDCHANGE); SPIF_SENDCHANGE);
free(_glfw.win32.clipboardString); free(_glfw.win32.clipboardString);
free(_glfw.win32.keyboardLayoutName);
free(_glfw.win32.rawInput); free(_glfw.win32.rawInput);
_glfwTerminateWGL(); _glfwTerminateWGL();
_glfwTerminateEGL(); _glfwTerminateEGL();
_glfwTerminateJoysticksWin32();
freeLibraries(); freeLibraries();
} }
+38 -36
View File
@@ -356,7 +356,7 @@ static BOOL CALLBACK deviceCallback(const DIDEVICEINSTANCE* di, void* user)
for (jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++) for (jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++)
{ {
js = _glfw.joysticks + jid; _GLFWjoystick* js = _glfw.joysticks + jid;
if (js->present) if (js->present)
{ {
if (memcmp(&js->win32.guid, &di->guidInstance, sizeof(GUID)) == 0) if (memcmp(&js->win32.guid, &di->guidInstance, sizeof(GUID)) == 0)
@@ -491,6 +491,39 @@ static BOOL CALLBACK deviceCallback(const DIDEVICEINSTANCE* di, void* user)
////// GLFW internal API ////// ////// GLFW internal API //////
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// Initialize joystick interface
//
void _glfwInitJoysticksWin32(void)
{
if (_glfw.win32.dinput8.instance)
{
if (FAILED(DirectInput8Create(GetModuleHandle(NULL),
DIRECTINPUT_VERSION,
&IID_IDirectInput8W,
(void**) &_glfw.win32.dinput8.api,
NULL)))
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"Win32: Failed to create interface");
}
}
_glfwDetectJoystickConnectionWin32();
}
// Close all opened joystick handles
//
void _glfwTerminateJoysticksWin32(void)
{
int jid;
for (jid = GLFW_JOYSTICK_1; jid <= GLFW_JOYSTICK_LAST; jid++)
closeJoystick(_glfw.joysticks + jid);
if (_glfw.win32.dinput8.api)
IDirectInput8_Release(_glfw.win32.dinput8.api);
}
// Checks for new joysticks after DBT_DEVICEARRIVAL // Checks for new joysticks after DBT_DEVICEARRIVAL
// //
void _glfwDetectJoystickConnectionWin32(void) void _glfwDetectJoystickConnectionWin32(void)
@@ -570,37 +603,6 @@ void _glfwDetectJoystickDisconnectionWin32(void)
////// GLFW platform API ////// ////// GLFW platform API //////
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
GLFWbool _glfwPlatformInitJoysticks(void)
{
if (_glfw.win32.dinput8.instance)
{
if (FAILED(DirectInput8Create(GetModuleHandle(NULL),
DIRECTINPUT_VERSION,
&IID_IDirectInput8W,
(void**) &_glfw.win32.dinput8.api,
NULL)))
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"Win32: Failed to create interface");
return GLFW_FALSE;
}
}
_glfwDetectJoystickConnectionWin32();
return GLFW_TRUE;
}
void _glfwPlatformTerminateJoysticks(void)
{
int jid;
for (jid = GLFW_JOYSTICK_1; jid <= GLFW_JOYSTICK_LAST; jid++)
closeJoystick(_glfw.joysticks + jid);
if (_glfw.win32.dinput8.api)
IDirectInput8_Release(_glfw.win32.dinput8.api);
}
int _glfwPlatformPollJoystick(_GLFWjoystick* js, int mode) int _glfwPlatformPollJoystick(_GLFWjoystick* js, int mode)
{ {
if (js->win32.device) if (js->win32.device)
@@ -670,11 +672,11 @@ int _glfwPlatformPollJoystick(_GLFWjoystick* js, int mode)
}; };
// Screams of horror are appropriate at this point // Screams of horror are appropriate at this point
int stateIndex = LOWORD(*(DWORD*) data) / (45 * DI_DEGREES); int state = LOWORD(*(DWORD*) data) / (45 * DI_DEGREES);
if (stateIndex < 0 || stateIndex > 8) if (state < 0 || state > 8)
stateIndex = 8; state = 8;
_glfwInputJoystickHat(js, pi, states[stateIndex]); _glfwInputJoystickHat(js, pi, states[state]);
pi++; pi++;
break; break;
} }
+3
View File
@@ -48,6 +48,9 @@ typedef struct _GLFWjoystickWin32
GUID guid; GUID guid;
} _GLFWjoystickWin32; } _GLFWjoystickWin32;
void _glfwInitJoysticksWin32(void);
void _glfwTerminateJoysticksWin32(void);
void _glfwDetectJoystickConnectionWin32(void); void _glfwDetectJoystickConnectionWin32(void);
void _glfwDetectJoystickDisconnectionWin32(void); void _glfwDetectJoystickDisconnectionWin32(void);
-2
View File
@@ -185,8 +185,6 @@ void _glfwPollMonitorsWin32(void)
display.DeviceName) == 0) display.DeviceName) == 0)
{ {
disconnected[i] = NULL; disconnected[i] = NULL;
// handle may have changed, update
EnumDisplayMonitors(NULL, NULL, monitorCallback, (LPARAM) _glfw.monitors[i]);
break; break;
} }
} }
+10 -9
View File
@@ -77,9 +77,6 @@
#ifndef WM_DWMCOMPOSITIONCHANGED #ifndef WM_DWMCOMPOSITIONCHANGED
#define WM_DWMCOMPOSITIONCHANGED 0x031E #define WM_DWMCOMPOSITIONCHANGED 0x031E
#endif #endif
#ifndef WM_DWMCOLORIZATIONCOLORCHANGED
#define WM_DWMCOLORIZATIONCOLORCHANGED 0x0320
#endif
#ifndef WM_COPYGLOBALDATA #ifndef WM_COPYGLOBALDATA
#define WM_COPYGLOBALDATA 0x0049 #define WM_COPYGLOBALDATA 0x0049
#endif #endif
@@ -102,7 +99,7 @@
#define DISPLAY_DEVICE_ACTIVE 0x00000001 #define DISPLAY_DEVICE_ACTIVE 0x00000001
#endif #endif
#ifndef _WIN32_WINNT_WINBLUE #ifndef _WIN32_WINNT_WINBLUE
#define _WIN32_WINNT_WINBLUE 0x0603 #define _WIN32_WINNT_WINBLUE 0x0602
#endif #endif
#ifndef _WIN32_WINNT_WIN8 #ifndef _WIN32_WINNT_WIN8
#define _WIN32_WINNT_WIN8 0x0602 #define _WIN32_WINNT_WIN8 0x0602
@@ -163,6 +160,9 @@ typedef enum
#endif /*DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2*/ #endif /*DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2*/
// HACK: Define versionhelpers.h functions manually as MinGW lacks the header // HACK: Define versionhelpers.h functions manually as MinGW lacks the header
#define IsWindowsXPOrGreater() \
_glfwIsWindowsVersionOrGreaterWin32(HIBYTE(_WIN32_WINNT_WINXP), \
LOBYTE(_WIN32_WINNT_WINXP), 0)
#define IsWindowsVistaOrGreater() \ #define IsWindowsVistaOrGreater() \
_glfwIsWindowsVersionOrGreaterWin32(HIBYTE(_WIN32_WINNT_VISTA), \ _glfwIsWindowsVersionOrGreaterWin32(HIBYTE(_WIN32_WINNT_VISTA), \
LOBYTE(_WIN32_WINNT_VISTA), 0) LOBYTE(_WIN32_WINNT_VISTA), 0)
@@ -247,11 +247,9 @@ typedef BOOL (WINAPI * PFN_AdjustWindowRectExForDpi)(LPRECT,DWORD,BOOL,DWORD,UIN
typedef HRESULT (WINAPI * PFN_DwmIsCompositionEnabled)(BOOL*); typedef HRESULT (WINAPI * PFN_DwmIsCompositionEnabled)(BOOL*);
typedef HRESULT (WINAPI * PFN_DwmFlush)(VOID); typedef HRESULT (WINAPI * PFN_DwmFlush)(VOID);
typedef HRESULT(WINAPI * PFN_DwmEnableBlurBehindWindow)(HWND,const DWM_BLURBEHIND*); typedef HRESULT(WINAPI * PFN_DwmEnableBlurBehindWindow)(HWND,const DWM_BLURBEHIND*);
typedef HRESULT (WINAPI * PFN_DwmGetColorizationColor)(DWORD*,BOOL*);
#define DwmIsCompositionEnabled _glfw.win32.dwmapi.IsCompositionEnabled #define DwmIsCompositionEnabled _glfw.win32.dwmapi.IsCompositionEnabled
#define DwmFlush _glfw.win32.dwmapi.Flush #define DwmFlush _glfw.win32.dwmapi.Flush
#define DwmEnableBlurBehindWindow _glfw.win32.dwmapi.EnableBlurBehindWindow #define DwmEnableBlurBehindWindow _glfw.win32.dwmapi.EnableBlurBehindWindow
#define DwmGetColorizationColor _glfw.win32.dwmapi.GetColorizationColor
// shcore.dll function pointer typedefs // shcore.dll function pointer typedefs
typedef HRESULT (WINAPI * PFN_SetProcessDpiAwareness)(PROCESS_DPI_AWARENESS); typedef HRESULT (WINAPI * PFN_SetProcessDpiAwareness)(PROCESS_DPI_AWARENESS);
@@ -279,6 +277,8 @@ typedef VkBool32 (APIENTRY *PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR)(
#include "win32_joystick.h" #include "win32_joystick.h"
#include "wgl_context.h" #include "wgl_context.h"
#include "egl_context.h"
#include "osmesa_context.h"
#if !defined(_GLFW_WNDCLASSNAME) #if !defined(_GLFW_WNDCLASSNAME)
#define _GLFW_WNDCLASSNAME L"GLFW30" #define _GLFW_WNDCLASSNAME L"GLFW30"
@@ -288,6 +288,9 @@ typedef VkBool32 (APIENTRY *PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR)(
#define _glfw_dlclose(handle) FreeLibrary((HMODULE) handle) #define _glfw_dlclose(handle) FreeLibrary((HMODULE) handle)
#define _glfw_dlsym(handle, name) GetProcAddress((HMODULE) handle, name) #define _glfw_dlsym(handle, name) GetProcAddress((HMODULE) handle, name)
#define _GLFW_EGL_NATIVE_WINDOW ((EGLNativeWindowType) window->win32.handle)
#define _GLFW_EGL_NATIVE_DISPLAY EGL_DEFAULT_DISPLAY
#define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowWin32 win32 #define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowWin32 win32
#define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryWin32 win32 #define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryWin32 win32
#define _GLFW_PLATFORM_LIBRARY_TIMER_STATE _GLFWtimerWin32 win32 #define _GLFW_PLATFORM_LIBRARY_TIMER_STATE _GLFWtimerWin32 win32
@@ -316,8 +319,6 @@ typedef struct _GLFWwindowWin32
// The last received cursor position, regardless of source // The last received cursor position, regardless of source
int lastCursorPosX, lastCursorPosY; int lastCursorPosX, lastCursorPosY;
// The last recevied high surrogate when decoding pairs of UTF-16 messages
WCHAR highSurrogate;
} _GLFWwindowWin32; } _GLFWwindowWin32;
@@ -330,6 +331,7 @@ typedef struct _GLFWlibraryWin32
DWORD foregroundLockTimeout; DWORD foregroundLockTimeout;
int acquiredMonitorCount; int acquiredMonitorCount;
char* clipboardString; char* clipboardString;
char* keyboardLayoutName;
short int keycodes[512]; short int keycodes[512];
short int scancodes[GLFW_KEY_LAST + 1]; short int scancodes[GLFW_KEY_LAST + 1];
char keynames[GLFW_KEY_LAST + 1][5]; char keynames[GLFW_KEY_LAST + 1][5];
@@ -373,7 +375,6 @@ typedef struct _GLFWlibraryWin32
PFN_DwmIsCompositionEnabled IsCompositionEnabled; PFN_DwmIsCompositionEnabled IsCompositionEnabled;
PFN_DwmFlush Flush; PFN_DwmFlush Flush;
PFN_DwmEnableBlurBehindWindow EnableBlurBehindWindow; PFN_DwmEnableBlurBehindWindow EnableBlurBehindWindow;
PFN_DwmGetColorizationColor GetColorizationColor;
} dwmapi; } dwmapi;
struct { struct {
+93 -157
View File
@@ -377,17 +377,12 @@ static void updateWindowStyles(const _GLFWwindow* window)
// //
static void updateFramebufferTransparency(const _GLFWwindow* window) static void updateFramebufferTransparency(const _GLFWwindow* window)
{ {
BOOL composition, opaque; BOOL enabled;
DWORD color;
if (!IsWindowsVistaOrGreater()) if (!IsWindowsVistaOrGreater())
return; return;
if (FAILED(DwmIsCompositionEnabled(&composition)) || !composition) if (SUCCEEDED(DwmIsCompositionEnabled(&enabled)) && enabled)
return;
if (IsWindows8OrGreater() ||
(SUCCEEDED(DwmGetColorizationColor(&color, &opaque)) && !opaque))
{ {
HRGN region = CreateRectRgn(0, 0, -1, -1); HRGN region = CreateRectRgn(0, 0, -1, -1);
DWM_BLURBEHIND bb = {0}; DWM_BLURBEHIND bb = {0};
@@ -395,18 +390,37 @@ static void updateFramebufferTransparency(const _GLFWwindow* window)
bb.hRgnBlur = region; bb.hRgnBlur = region;
bb.fEnable = TRUE; bb.fEnable = TRUE;
DwmEnableBlurBehindWindow(window->win32.handle, &bb); if (SUCCEEDED(DwmEnableBlurBehindWindow(window->win32.handle, &bb)))
{
// Decorated windows don't repaint the transparent background
// leaving a trail behind animations
// HACK: Making the window layered with a transparency color key
// seems to fix this. Normally, when specifying
// a transparency color key to be used when composing the
// layered window, all pixels painted by the window in this
// color will be transparent. That doesn't seem to be the
// case anymore, at least when used with blur behind window
// plus negative region.
LONG exStyle = GetWindowLongW(window->win32.handle, GWL_EXSTYLE);
exStyle |= WS_EX_LAYERED;
SetWindowLongW(window->win32.handle, GWL_EXSTYLE, exStyle);
// Using a color key not equal to black to fix the trailing
// issue. When set to black, something is making the hit test
// not resize with the window frame.
SetLayeredWindowAttributes(window->win32.handle,
RGB(255, 0, 255), 255, LWA_COLORKEY);
}
DeleteObject(region); DeleteObject(region);
} }
else else
{ {
// HACK: Disable framebuffer transparency on Windows 7 when the LONG exStyle = GetWindowLongW(window->win32.handle, GWL_EXSTYLE);
// colorization color is opaque, because otherwise the window exStyle &= ~WS_EX_LAYERED;
// contents is blended additively with the previous frame instead SetWindowLongW(window->win32.handle, GWL_EXSTYLE, exStyle);
// of replacing it RedrawWindow(window->win32.handle, NULL, NULL,
DWM_BLURBEHIND bb = {0}; RDW_ERASE | RDW_INVALIDATE | RDW_FRAME);
bb.dwFlags = DWM_BB_ENABLE;
DwmEnableBlurBehindWindow(window->win32.handle, &bb);
} }
} }
@@ -454,9 +468,12 @@ static void acquireMonitor(_GLFWwindow* window)
// HACK: When mouse trails are enabled the cursor becomes invisible when // HACK: When mouse trails are enabled the cursor becomes invisible when
// the OpenGL ICD switches to page flipping // the OpenGL ICD switches to page flipping
if (IsWindowsXPOrGreater())
{
SystemParametersInfo(SPI_GETMOUSETRAILS, 0, &_glfw.win32.mouseTrailSize, 0); SystemParametersInfo(SPI_GETMOUSETRAILS, 0, &_glfw.win32.mouseTrailSize, 0);
SystemParametersInfo(SPI_SETMOUSETRAILS, 0, 0, 0); SystemParametersInfo(SPI_SETMOUSETRAILS, 0, 0, 0);
} }
}
if (!window->monitor->window) if (!window->monitor->window)
_glfw.win32.acquiredMonitorCount++; _glfw.win32.acquiredMonitorCount++;
@@ -478,6 +495,7 @@ static void releaseMonitor(_GLFWwindow* window)
SetThreadExecutionState(ES_CONTINUOUS); SetThreadExecutionState(ES_CONTINUOUS);
// HACK: Restore mouse trail length saved in acquireMonitor // HACK: Restore mouse trail length saved in acquireMonitor
if (IsWindowsXPOrGreater())
SystemParametersInfo(SPI_SETMOUSETRAILS, _glfw.win32.mouseTrailSize, 0, 0); SystemParametersInfo(SPI_SETMOUSETRAILS, _glfw.win32.mouseTrailSize, 0, 0);
} }
@@ -512,9 +530,6 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
case WM_DEVICECHANGE: case WM_DEVICECHANGE:
{ {
if (!_glfw.joysticksInitialized)
break;
if (wParam == DBT_DEVICEARRIVAL) if (wParam == DBT_DEVICEARRIVAL)
{ {
DEV_BROADCAST_HDR* dbh = (DEV_BROADCAST_HDR*) lParam; DEV_BROADCAST_HDR* dbh = (DEV_BROADCAST_HDR*) lParam;
@@ -630,43 +645,17 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
case WM_INPUTLANGCHANGE: case WM_INPUTLANGCHANGE:
{ {
_glfwUpdateKeyNamesWin32(); _glfwUpdateKeyNamesWin32();
_glfwInputKeyboardLayout();
break; break;
} }
case WM_CHAR: case WM_CHAR:
case WM_SYSCHAR: case WM_SYSCHAR:
{
if (wParam >= 0xd800 && wParam <= 0xdbff)
window->win32.highSurrogate = (WCHAR) wParam;
else
{
unsigned int codepoint = 0;
if (wParam >= 0xdc00 && wParam <= 0xdfff)
{
if (window->win32.highSurrogate)
{
codepoint += (window->win32.highSurrogate - 0xd800) << 10;
codepoint += (WCHAR) wParam - 0xdc00;
codepoint += 0x10000;
}
}
else
codepoint = (WCHAR) wParam;
window->win32.highSurrogate = 0;
_glfwInputChar(window, codepoint, getKeyMods(), uMsg != WM_SYSCHAR);
}
if (uMsg == WM_SYSCHAR && window->win32.keymenu)
break;
return 0;
}
case WM_UNICHAR: case WM_UNICHAR:
{ {
if (wParam == UNICODE_NOCHAR) const GLFWbool plain = (uMsg != WM_SYSCHAR);
if (uMsg == WM_UNICHAR && wParam == UNICODE_NOCHAR)
{ {
// WM_UNICHAR is not sent by Windows, but is sent by some // WM_UNICHAR is not sent by Windows, but is sent by some
// third-party input method engine // third-party input method engine
@@ -674,7 +663,11 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
return TRUE; return TRUE;
} }
_glfwInputChar(window, (unsigned int) wParam, getKeyMods(), GLFW_TRUE); _glfwInputChar(window, (unsigned int) wParam, getKeyMods(), plain);
if (uMsg == WM_SYSCHAR && window->win32.keymenu)
break;
return 0; return 0;
} }
@@ -1090,7 +1083,6 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
} }
case WM_DWMCOMPOSITIONCHANGED: case WM_DWMCOMPOSITIONCHANGED:
case WM_DWMCOLORIZATIONCOLORCHANGED:
{ {
if (window->win32.transparent) if (window->win32.transparent)
updateFramebufferTransparency(window); updateFramebufferTransparency(window);
@@ -1816,8 +1808,7 @@ int _glfwPlatformWindowHovered(_GLFWwindow* window)
int _glfwPlatformFramebufferTransparent(_GLFWwindow* window) int _glfwPlatformFramebufferTransparent(_GLFWwindow* window)
{ {
BOOL composition, opaque; BOOL enabled;
DWORD color;
if (!window->win32.transparent) if (!window->win32.transparent)
return GLFW_FALSE; return GLFW_FALSE;
@@ -1825,20 +1816,7 @@ int _glfwPlatformFramebufferTransparent(_GLFWwindow* window)
if (!IsWindowsVistaOrGreater()) if (!IsWindowsVistaOrGreater())
return GLFW_FALSE; return GLFW_FALSE;
if (FAILED(DwmIsCompositionEnabled(&composition)) || !composition) return SUCCEEDED(DwmIsCompositionEnabled(&enabled)) && enabled;
return GLFW_FALSE;
if (!IsWindows8OrGreater())
{
// HACK: Disable framebuffer transparency on Windows 7 when the
// colorization color is opaque, because otherwise the window
// contents is blended additively with the previous frame instead
// of replacing it
if (FAILED(DwmGetColorizationColor(&color, &opaque)) || opaque)
return GLFW_FALSE;
}
return GLFW_TRUE;
} }
void _glfwPlatformSetWindowResizable(_GLFWwindow* window, GLFWbool enabled) void _glfwPlatformSetWindowResizable(_GLFWwindow* window, GLFWbool enabled)
@@ -1858,36 +1836,6 @@ void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled)
SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE); SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
} }
void _glfwPlatformSetWindowMousePassthrough(_GLFWwindow* window, GLFWbool enabled)
{
COLORREF key = 0;
BYTE alpha = 0;
DWORD flags = 0;
DWORD exStyle = GetWindowLongW(window->win32.handle, GWL_EXSTYLE);
if (exStyle & WS_EX_LAYERED)
GetLayeredWindowAttributes(window->win32.handle, &key, &alpha, &flags);
if (enabled)
exStyle |= (WS_EX_TRANSPARENT | WS_EX_LAYERED);
else
{
exStyle &= ~WS_EX_TRANSPARENT;
// NOTE: Window opacity also needs the layered window style so do not
// remove it if the window is alpha blended
if (exStyle & WS_EX_LAYERED)
{
if (!(flags & LWA_ALPHA))
exStyle &= ~WS_EX_LAYERED;
}
}
SetWindowLongW(window->win32.handle, GWL_EXSTYLE, exStyle);
if (enabled)
SetLayeredWindowAttributes(window->win32.handle, key, alpha, flags);
}
float _glfwPlatformGetWindowOpacity(_GLFWwindow* window) float _glfwPlatformGetWindowOpacity(_GLFWwindow* window)
{ {
BYTE alpha; BYTE alpha;
@@ -1905,22 +1853,19 @@ float _glfwPlatformGetWindowOpacity(_GLFWwindow* window)
void _glfwPlatformSetWindowOpacity(_GLFWwindow* window, float opacity) void _glfwPlatformSetWindowOpacity(_GLFWwindow* window, float opacity)
{ {
LONG exStyle = GetWindowLongW(window->win32.handle, GWL_EXSTYLE); if (opacity < 1.f)
if (opacity < 1.f || (exStyle & WS_EX_TRANSPARENT))
{ {
const BYTE alpha = (BYTE) (255 * opacity); const BYTE alpha = (BYTE) (255 * opacity);
exStyle |= WS_EX_LAYERED; DWORD style = GetWindowLongW(window->win32.handle, GWL_EXSTYLE);
SetWindowLongW(window->win32.handle, GWL_EXSTYLE, exStyle); style |= WS_EX_LAYERED;
SetWindowLongW(window->win32.handle, GWL_EXSTYLE, style);
SetLayeredWindowAttributes(window->win32.handle, 0, alpha, LWA_ALPHA); SetLayeredWindowAttributes(window->win32.handle, 0, alpha, LWA_ALPHA);
} }
else if (exStyle & WS_EX_TRANSPARENT)
{
SetLayeredWindowAttributes(window->win32.handle, 0, 0, 0);
}
else else
{ {
exStyle &= ~WS_EX_LAYERED; DWORD style = GetWindowLongW(window->win32.handle, GWL_EXSTYLE);
SetWindowLongW(window->win32.handle, GWL_EXSTYLE, exStyle); style &= ~WS_EX_LAYERED;
SetWindowLongW(window->win32.handle, GWL_EXSTYLE, style);
} }
} }
@@ -2098,6 +2043,48 @@ int _glfwPlatformGetKeyScancode(int key)
return _glfw.win32.scancodes[key]; return _glfw.win32.scancodes[key];
} }
const char* _glfwPlatformGetKeyboardLayoutName(void)
{
WCHAR klid[KL_NAMELENGTH];
int size;
LCID lcid;
WCHAR* language;
if (!GetKeyboardLayoutNameW(klid))
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"Win32: Failed to retrieve keyboard layout name");
return NULL;
}
// NOTE: We only care about the language part of the keyboard layout ID
lcid = MAKELCID(LANGIDFROMLCID(wcstoul(klid, NULL, 16)), 0);
size = GetLocaleInfoW(lcid, LOCALE_SLANGUAGE, NULL, 0);
if (!size)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"Win32: Failed to retrieve keyboard layout name length");
return NULL;
}
language = calloc(size, sizeof(WCHAR));
if (!GetLocaleInfoW(lcid, LOCALE_SLANGUAGE, language, size))
{
free(language);
_glfwInputError(GLFW_PLATFORM_ERROR,
"Win32: Failed to translate keyboard layout name");
return NULL;
}
free(_glfw.win32.keyboardLayoutName);
_glfw.win32.keyboardLayoutName = _glfwCreateUTF8FromWideStringWin32(language);
free(language);
return _glfw.win32.keyboardLayoutName;
}
int _glfwPlatformCreateCursor(_GLFWcursor* cursor, int _glfwPlatformCreateCursor(_GLFWcursor* cursor,
const GLFWimage* image, const GLFWimage* image,
int xhot, int yhot) int xhot, int yhot)
@@ -2246,57 +2233,6 @@ const char* _glfwPlatformGetClipboardString(void)
return _glfw.win32.clipboardString; return _glfw.win32.clipboardString;
} }
EGLenum _glfwPlatformGetEGLPlatform(EGLint** attribs)
{
if (_glfw.egl.ANGLE_platform_angle)
{
int type = 0;
if (_glfw.egl.ANGLE_platform_angle_opengl)
{
if (_glfw.hints.init.angleType == GLFW_ANGLE_PLATFORM_TYPE_OPENGL)
type = EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE;
else if (_glfw.hints.init.angleType == GLFW_ANGLE_PLATFORM_TYPE_OPENGLES)
type = EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE;
}
if (_glfw.egl.ANGLE_platform_angle_d3d)
{
if (_glfw.hints.init.angleType == GLFW_ANGLE_PLATFORM_TYPE_D3D9)
type = EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE;
else if (_glfw.hints.init.angleType == GLFW_ANGLE_PLATFORM_TYPE_D3D11)
type = EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE;
}
if (_glfw.egl.ANGLE_platform_angle_vulkan)
{
if (_glfw.hints.init.angleType == GLFW_ANGLE_PLATFORM_TYPE_VULKAN)
type = EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE;
}
if (type)
{
*attribs = calloc(3, sizeof(EGLint));
(*attribs)[0] = EGL_PLATFORM_ANGLE_TYPE_ANGLE;
(*attribs)[1] = type;
(*attribs)[2] = EGL_NONE;
return EGL_PLATFORM_ANGLE_ANGLE;
}
}
return 0;
}
EGLNativeDisplayType _glfwPlatformGetEGLNativeDisplay(void)
{
return GetDC(_glfw.win32.helperWindowHandle);
}
EGLNativeWindowType _glfwPlatformGetEGLNativeWindow(_GLFWwindow* window)
{
return window->win32.handle;
}
void _glfwPlatformGetRequiredInstanceExtensions(char** extensions) void _glfwPlatformGetRequiredInstanceExtensions(char** extensions)
{ {
if (!_glfw.vk.KHR_surface || !_glfw.vk.KHR_win32_surface) if (!_glfw.vk.KHR_surface || !_glfw.vk.KHR_win32_surface)
+2 -20
View File
@@ -203,7 +203,6 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height,
window->autoIconify = wndconfig.autoIconify; window->autoIconify = wndconfig.autoIconify;
window->floating = wndconfig.floating; window->floating = wndconfig.floating;
window->focusOnShow = wndconfig.focusOnShow; window->focusOnShow = wndconfig.focusOnShow;
window->mousePassthrough = wndconfig.mousePassthrough;
window->cursorMode = GLFW_CURSOR_NORMAL; window->cursorMode = GLFW_CURSOR_NORMAL;
window->minwidth = GLFW_DONT_CARE; window->minwidth = GLFW_DONT_CARE;
@@ -229,9 +228,6 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height,
} }
} }
if (wndconfig.mousePassthrough)
_glfwPlatformSetWindowMousePassthrough(window, GLFW_TRUE);
if (window->monitor) if (window->monitor)
{ {
if (wndconfig.centerCursor) if (wndconfig.centerCursor)
@@ -382,9 +378,6 @@ GLFWAPI void glfwWindowHint(int hint, int value)
case GLFW_FOCUS_ON_SHOW: case GLFW_FOCUS_ON_SHOW:
_glfw.hints.window.focusOnShow = value ? GLFW_TRUE : GLFW_FALSE; _glfw.hints.window.focusOnShow = value ? GLFW_TRUE : GLFW_FALSE;
return; return;
case GLFW_MOUSE_PASSTHROUGH:
_glfw.hints.window.mousePassthrough = value ? GLFW_TRUE : GLFW_FALSE;
return;
case GLFW_CLIENT_API: case GLFW_CLIENT_API:
_glfw.hints.context.client = value; _glfw.hints.context.client = value;
return; return;
@@ -403,7 +396,7 @@ GLFWAPI void glfwWindowHint(int hint, int value)
case GLFW_OPENGL_FORWARD_COMPAT: case GLFW_OPENGL_FORWARD_COMPAT:
_glfw.hints.context.forward = value ? GLFW_TRUE : GLFW_FALSE; _glfw.hints.context.forward = value ? GLFW_TRUE : GLFW_FALSE;
return; return;
case GLFW_CONTEXT_DEBUG: case GLFW_OPENGL_DEBUG_CONTEXT:
_glfw.hints.context.debug = value ? GLFW_TRUE : GLFW_FALSE; _glfw.hints.context.debug = value ? GLFW_TRUE : GLFW_FALSE;
return; return;
case GLFW_CONTEXT_NO_ERROR: case GLFW_CONTEXT_NO_ERROR:
@@ -829,8 +822,6 @@ GLFWAPI int glfwGetWindowAttrib(GLFWwindow* handle, int attrib)
return _glfwPlatformWindowHovered(window); return _glfwPlatformWindowHovered(window);
case GLFW_FOCUS_ON_SHOW: case GLFW_FOCUS_ON_SHOW:
return window->focusOnShow; return window->focusOnShow;
case GLFW_MOUSE_PASSTHROUGH:
return window->mousePassthrough;
case GLFW_TRANSPARENT_FRAMEBUFFER: case GLFW_TRANSPARENT_FRAMEBUFFER:
return _glfwPlatformFramebufferTransparent(window); return _glfwPlatformFramebufferTransparent(window);
case GLFW_RESIZABLE: case GLFW_RESIZABLE:
@@ -855,7 +846,7 @@ GLFWAPI int glfwGetWindowAttrib(GLFWwindow* handle, int attrib)
return window->context.robustness; return window->context.robustness;
case GLFW_OPENGL_FORWARD_COMPAT: case GLFW_OPENGL_FORWARD_COMPAT:
return window->context.forward; return window->context.forward;
case GLFW_CONTEXT_DEBUG: case GLFW_OPENGL_DEBUG_CONTEXT:
return window->context.debug; return window->context.debug;
case GLFW_OPENGL_PROFILE: case GLFW_OPENGL_PROFILE:
return window->context.profile; return window->context.profile;
@@ -909,14 +900,6 @@ GLFWAPI void glfwSetWindowAttrib(GLFWwindow* handle, int attrib, int value)
} }
else if (attrib == GLFW_FOCUS_ON_SHOW) else if (attrib == GLFW_FOCUS_ON_SHOW)
window->focusOnShow = value; window->focusOnShow = value;
else if (attrib == GLFW_MOUSE_PASSTHROUGH)
{
if (window->mousePassthrough == value)
return;
window->mousePassthrough = value;
_glfwPlatformSetWindowMousePassthrough(window, value);
}
else else
_glfwInputError(GLFW_INVALID_ENUM, "Invalid window attribute 0x%08X", attrib); _glfwInputError(GLFW_INVALID_ENUM, "Invalid window attribute 0x%08X", attrib);
} }
@@ -1119,4 +1102,3 @@ GLFWAPI void glfwPostEmptyEvent(void)
_GLFW_REQUIRE_INIT(); _GLFW_REQUIRE_INIT();
_glfwPlatformPostEmptyEvent(); _glfwPlatformPostEmptyEvent();
} }
+20 -405
View File
@@ -341,9 +341,9 @@ static void pointerHandleAxis(void* data,
axis == WL_POINTER_AXIS_VERTICAL_SCROLL); axis == WL_POINTER_AXIS_VERTICAL_SCROLL);
if (axis == WL_POINTER_AXIS_HORIZONTAL_SCROLL) if (axis == WL_POINTER_AXIS_HORIZONTAL_SCROLL)
x = -wl_fixed_to_double(value) * scrollFactor; x = wl_fixed_to_double(value) * scrollFactor;
else if (axis == WL_POINTER_AXIS_VERTICAL_SCROLL) else if (axis == WL_POINTER_AXIS_VERTICAL_SCROLL)
y = -wl_fixed_to_double(value) * scrollFactor; y = wl_fixed_to_double(value) * scrollFactor;
_glfwInputScroll(window, x, y); _glfwInputScroll(window, x, y);
} }
@@ -640,6 +640,12 @@ static void keyboardHandleModifiers(void* data,
if (mask & _glfw.wl.xkb.numLockMask) if (mask & _glfw.wl.xkb.numLockMask)
modifiers |= GLFW_MOD_NUM_LOCK; modifiers |= GLFW_MOD_NUM_LOCK;
_glfw.wl.xkb.modifiers = modifiers; _glfw.wl.xkb.modifiers = modifiers;
if (_glfw.wl.xkb.group != group)
{
_glfw.wl.xkb.group = group;
_glfwInputKeyboardLayout();
}
} }
#ifdef WL_KEYBOARD_REPEAT_INFO_SINCE_VERSION #ifdef WL_KEYBOARD_REPEAT_INFO_SINCE_VERSION
@@ -769,390 +775,6 @@ static const struct wl_data_device_listener dataDeviceListener = {
dataDeviceHandleSelection, dataDeviceHandleSelection,
}; };
void tabletName(void *data,
struct zwp_tablet_v2 *zwp_tablet_v2,
const char *name)
{
printf("Tablet name: %s\n", name);
}
void tabletId(void *data,
struct zwp_tablet_v2 *zwp_tablet_v2,
uint32_t vid,
uint32_t pid)
{
printf("Tablet id: %04u:%04u\n", vid, pid);
}
void tabletPath(void *data,
struct zwp_tablet_v2 *zwp_tablet_v2,
const char *path)
{
printf("Tablet path: %s\n", path);
}
void tabletDone(void *data,
struct zwp_tablet_v2 *zwp_tablet_v2)
{
printf("Tablet done\n");
}
void tabletRemoved(void *data,
struct zwp_tablet_v2 *zwp_tablet_v2)
{
printf("Tablet removed\n");
_glfw.wl.tablet = NULL;
}
static const struct zwp_tablet_v2_listener tabletListener = {
tabletName,
tabletId,
tabletPath,
tabletDone,
tabletRemoved,
};
void tabletToolType(void *data,
struct zwp_tablet_tool_v2 *tool,
uint32_t toolType)
{
const char *name;
switch (toolType)
{
case ZWP_TABLET_TOOL_V2_TYPE_PEN:
name = "pen";
break;
case ZWP_TABLET_TOOL_V2_TYPE_ERASER:
name = "eraser";
break;
case ZWP_TABLET_TOOL_V2_TYPE_BRUSH:
name = "brush";
break;
case ZWP_TABLET_TOOL_V2_TYPE_PENCIL:
name = "pencil";
break;
case ZWP_TABLET_TOOL_V2_TYPE_AIRBRUSH:
name = "airbrush";
break;
case ZWP_TABLET_TOOL_V2_TYPE_FINGER:
name = "finger";
break;
case ZWP_TABLET_TOOL_V2_TYPE_MOUSE:
name = "mouse";
break;
case ZWP_TABLET_TOOL_V2_TYPE_LENS:
name = "lens";
break;
default:
name = "unknown";
break;
}
printf("Tablet tool type: %s\n", name);
}
void tabletToolHardwareSerial(void *data,
struct zwp_tablet_tool_v2 *tool,
uint32_t hardwareSerialHi,
uint32_t hardwareSerialLo)
{
uint64_t hardwareSerial = (uint64_t)hardwareSerialHi << 32 | (uint64_t)hardwareSerialLo;
printf("Tablet tool hardware serial: %"PRId64"\n", hardwareSerial);
}
void tabletToolHardwareIdWacom(void *data,
struct zwp_tablet_tool_v2 *tool,
uint32_t hardwareIdHi,
uint32_t hardwareIdLo)
{
uint64_t hardwareId = (uint64_t)hardwareIdHi << 32 | (uint64_t)hardwareIdLo;
printf("Tablet tool hardware id Wacom: %"PRId64"\n", hardwareId);
}
void tabletToolCapability(void *data,
struct zwp_tablet_tool_v2 *tool,
uint32_t capability)
{
const char *name;
switch (capability)
{
case ZWP_TABLET_TOOL_V2_CAPABILITY_TILT:
name = "tilt";
break;
case ZWP_TABLET_TOOL_V2_CAPABILITY_PRESSURE:
name = "pressure";
break;
case ZWP_TABLET_TOOL_V2_CAPABILITY_DISTANCE:
name = "distance";
break;
case ZWP_TABLET_TOOL_V2_CAPABILITY_ROTATION:
name = "rotation";
break;
case ZWP_TABLET_TOOL_V2_CAPABILITY_SLIDER:
name = "slider";
break;
case ZWP_TABLET_TOOL_V2_CAPABILITY_WHEEL:
name = "wheel";
break;
default:
name = "unknown";
break;
}
printf("Tablet tool capability: %s\n", name);
}
void tabletToolDone(void *data,
struct zwp_tablet_tool_v2 *tool)
{
printf("Tablet tool done\n");
}
void tabletToolRemoved(void *data,
struct zwp_tablet_tool_v2 *tool)
{
printf("Tablet tool removed (unimplemented)\n");
}
void tabletToolProximityIn(void *data,
struct zwp_tablet_tool_v2 *tool,
uint32_t serial,
struct zwp_tablet_v2 *tablet,
struct wl_surface *surface)
{
printf("Tablet tool proximity in: %p %p\n", tablet, surface);
}
void tabletToolProximityOut(void *data,
struct zwp_tablet_tool_v2 *tool)
{
printf("Tablet tool proximity out\n");
}
void tabletToolDown(void *data,
struct zwp_tablet_tool_v2 *tool,
uint32_t serial)
{
printf("Tablet tool down\n");
}
void tabletToolUp(void *data,
struct zwp_tablet_tool_v2 *tool)
{
printf("Tablet tool up\n");
}
void tabletToolMotion(void *data,
struct zwp_tablet_tool_v2 *tool,
wl_fixed_t x,
wl_fixed_t y)
{
printf("Tablet tool motion: %f %f\n", wl_fixed_to_double(x), wl_fixed_to_double(y));
}
void tabletToolPressure(void *data,
struct zwp_tablet_tool_v2 *tool,
uint32_t pressure)
{
printf("Tablet tool pressure: %u\n", pressure);
}
void tabletToolDistance(void *data,
struct zwp_tablet_tool_v2 *tool,
uint32_t distance)
{
printf("Tablet tool distance: %u\n", distance);
}
void tabletToolTilt(void *data,
struct zwp_tablet_tool_v2 *tool,
wl_fixed_t tiltX,
wl_fixed_t tiltY)
{
printf("Tablet tool tilt: %f %f\n", wl_fixed_to_double(tiltX), wl_fixed_to_double(tiltY));
}
void tabletToolRotation(void *data,
struct zwp_tablet_tool_v2 *tool,
wl_fixed_t degrees)
{
printf("Tablet tool rotation: %f°\n", wl_fixed_to_double(degrees));
}
void tabletToolSlider(void *data,
struct zwp_tablet_tool_v2 *tool,
int32_t position)
{
printf("Tablet tool slider: %d\n", position);
}
void tabletToolWheel(void *data,
struct zwp_tablet_tool_v2 *tool,
wl_fixed_t degrees,
int32_t clicks)
{
printf("Tablet tool wheel: %f° %d\n", wl_fixed_to_double(degrees), clicks);
}
void tabletToolButton(void *data,
struct zwp_tablet_tool_v2 *tool,
uint32_t serial,
uint32_t button,
uint32_t state)
{
printf("Tablet tool button: %u %u\n", button, state);
}
void tabletToolFrame(void *data,
struct zwp_tablet_tool_v2 *tool,
uint32_t time)
{
printf("Tablet tool frame: %u\n", time);
}
struct zwp_tablet_tool_v2_listener tabletToolListener = {
tabletToolType,
tabletToolHardwareSerial,
tabletToolHardwareIdWacom,
tabletToolCapability,
tabletToolDone,
tabletToolRemoved,
tabletToolProximityIn,
tabletToolProximityOut,
tabletToolDown,
tabletToolUp,
tabletToolMotion,
tabletToolPressure,
tabletToolDistance,
tabletToolTilt,
tabletToolRotation,
tabletToolSlider,
tabletToolWheel,
tabletToolButton,
tabletToolFrame,
};
void tabletPadGroup(void *data,
struct zwp_tablet_pad_v2 *pad,
struct zwp_tablet_pad_group_v2 *padGroup)
{
printf("New pad group: %p\n", padGroup);
}
void tabletPadPath(void *data,
struct zwp_tablet_pad_v2 *pad,
const char *path)
{
printf("Tablet pad path: %s\n", path);
}
void tabletPadButtons(void *data,
struct zwp_tablet_pad_v2 *pad,
uint32_t buttons)
{
printf("Tablet pad buttons: %u\n", buttons);
}
void tabletPadDone(void *data,
struct zwp_tablet_pad_v2 *pad)
{
printf("Tablet pad done\n");
}
void tabletPadButton(void *data,
struct zwp_tablet_pad_v2 *pad,
uint32_t time,
uint32_t button,
uint32_t state)
{
printf("Tablet pad button: %u %u %u\n", time, button, state);
}
void tabletPadEnter(void *data,
struct zwp_tablet_pad_v2 *pad,
uint32_t serial,
struct zwp_tablet_v2 *tablet,
struct wl_surface *surface)
{
printf("Tablet pad enter: %p %p\n", tablet, surface);
}
void tabletPadLeave(void *data,
struct zwp_tablet_pad_v2 *pad,
uint32_t serial,
struct wl_surface *surface)
{
printf("Tablet pad leave: %p\n", surface);
}
void tabletPadRemoved(void *data,
struct zwp_tablet_pad_v2 *pad)
{
printf("Tablet pad removed (unimplemented)\n");
}
struct zwp_tablet_pad_v2_listener tabletPadListener = {
tabletPadGroup,
tabletPadPath,
tabletPadButtons,
tabletPadDone,
tabletPadButton,
tabletPadEnter,
tabletPadLeave,
tabletPadRemoved,
};
void tabletSeatTabletAdded(void *data,
struct zwp_tablet_seat_v2 *seat,
struct zwp_tablet_v2 *tablet)
{
printf("New tablet %p!\n", tablet);
if (_glfw.wl.tablet) {
printf("Already there, skipping…\n");
return;
}
_glfw.wl.tablet = tablet;
zwp_tablet_v2_add_listener(_glfw.wl.tablet, &tabletListener, NULL);
}
void tabletSeatToolAdded(void *data,
struct zwp_tablet_seat_v2 *seat,
struct zwp_tablet_tool_v2 *tool)
{
printf("New tool %p!\n", tool);
if (_glfw.wl.tabletToolsCount + 1 > _glfw.wl.tabletToolsSize)
{
++_glfw.wl.tabletToolsSize;
_glfw.wl.tabletTools =
realloc(_glfw.wl.tabletTools,
_glfw.wl.tabletToolsSize * sizeof(struct zwp_tablet_tool_v2 *));
}
zwp_tablet_tool_v2_add_listener(tool, &tabletToolListener, NULL);
_glfw.wl.tabletTools[_glfw.wl.tabletToolsCount++] = tool;
}
void tabletSeatPadAdded(void *data,
struct zwp_tablet_seat_v2 *seat,
struct zwp_tablet_pad_v2 *pad)
{
// TODO: Do we really want to implement that now?
printf("New pad %p\n", pad);
if (_glfw.wl.tabletPad) {
printf("Already there, skipping…\n");
return;
}
_glfw.wl.tabletPad = pad;
zwp_tablet_pad_v2_add_listener(_glfw.wl.tabletPad, &tabletPadListener, NULL);
}
static const struct zwp_tablet_seat_v2_listener tabletSeatListener = {
tabletSeatTabletAdded,
tabletSeatToolAdded,
tabletSeatPadAdded,
};
static void wmBaseHandlePing(void* data, static void wmBaseHandlePing(void* data,
struct xdg_wm_base* wmBase, struct xdg_wm_base* wmBase,
uint32_t serial) uint32_t serial)
@@ -1243,13 +865,6 @@ static void registryHandleGlobal(void* data,
&zwp_pointer_constraints_v1_interface, &zwp_pointer_constraints_v1_interface,
1); 1);
} }
else if (strcmp(interface, "zwp_tablet_manager_v2") == 0)
{
_glfw.wl.tabletManager =
wl_registry_bind(registry, name,
&zwp_tablet_manager_v2_interface,
1);
}
else if (strcmp(interface, "zwp_idle_inhibit_manager_v1") == 0) else if (strcmp(interface, "zwp_idle_inhibit_manager_v1") == 0)
{ {
_glfw.wl.idleInhibitManager = _glfw.wl.idleInhibitManager =
@@ -1492,6 +1107,8 @@ int _glfwPlatformInit(void)
_glfw_dlsym(_glfw.wl.xkb.handle, "xkb_state_update_mask"); _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_state_update_mask");
_glfw.wl.xkb.state_serialize_mods = (PFN_xkb_state_serialize_mods) _glfw.wl.xkb.state_serialize_mods = (PFN_xkb_state_serialize_mods)
_glfw_dlsym(_glfw.wl.xkb.handle, "xkb_state_serialize_mods"); _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_state_serialize_mods");
_glfw.wl.xkb.keymap_layout_get_name = (PFN_xkb_keymap_layout_get_name)
_glfw_dlsym(_glfw.wl.xkb.handle, "xkb_keymap_layout_get_name");
#ifdef HAVE_XKBCOMMON_COMPOSE_H #ifdef HAVE_XKBCOMMON_COMPOSE_H
_glfw.wl.xkb.compose_table_new_from_locale = (PFN_xkb_compose_table_new_from_locale) _glfw.wl.xkb.compose_table_new_from_locale = (PFN_xkb_compose_table_new_from_locale)
@@ -1537,6 +1154,11 @@ int _glfwPlatformInit(void)
// Sync so we got all initial output events // Sync so we got all initial output events
wl_display_roundtrip(_glfw.wl.display); wl_display_roundtrip(_glfw.wl.display);
#ifdef __linux__
if (!_glfwInitJoysticksLinux())
return GLFW_FALSE;
#endif
_glfwInitTimerPOSIX(); _glfwInitTimerPOSIX();
_glfw.wl.timerfd = -1; _glfw.wl.timerfd = -1;
@@ -1594,19 +1216,14 @@ int _glfwPlatformInit(void)
_glfw.wl.clipboardSize = 4096; _glfw.wl.clipboardSize = 4096;
} }
if (_glfw.wl.seat && _glfw.wl.tabletManager)
{
_glfw.wl.tabletSeat =
zwp_tablet_manager_v2_get_tablet_seat(_glfw.wl.tabletManager,
_glfw.wl.seat);
zwp_tablet_seat_v2_add_listener(_glfw.wl.tabletSeat, &tabletSeatListener, NULL);
}
return GLFW_TRUE; return GLFW_TRUE;
} }
void _glfwPlatformTerminate(void) void _glfwPlatformTerminate(void)
{ {
#ifdef __linux__
_glfwTerminateJoysticksLinux();
#endif
_glfwTerminateEGL(); _glfwTerminateEGL();
if (_glfw.wl.egl.handle) if (_glfw.wl.egl.handle)
{ {
@@ -1672,10 +1289,6 @@ void _glfwPlatformTerminate(void)
zwp_relative_pointer_manager_v1_destroy(_glfw.wl.relativePointerManager); zwp_relative_pointer_manager_v1_destroy(_glfw.wl.relativePointerManager);
if (_glfw.wl.pointerConstraints) if (_glfw.wl.pointerConstraints)
zwp_pointer_constraints_v1_destroy(_glfw.wl.pointerConstraints); zwp_pointer_constraints_v1_destroy(_glfw.wl.pointerConstraints);
if (_glfw.wl.tabletSeat)
zwp_tablet_seat_v2_destroy(_glfw.wl.tabletSeat);
if (_glfw.wl.tabletManager)
zwp_tablet_manager_v2_destroy(_glfw.wl.tabletManager);
if (_glfw.wl.idleInhibitManager) if (_glfw.wl.idleInhibitManager)
zwp_idle_inhibit_manager_v1_destroy(_glfw.wl.idleInhibitManager); zwp_idle_inhibit_manager_v1_destroy(_glfw.wl.idleInhibitManager);
if (_glfw.wl.registry) if (_glfw.wl.registry)
@@ -1695,6 +1308,8 @@ void _glfwPlatformTerminate(void)
free(_glfw.wl.clipboardString); free(_glfw.wl.clipboardString);
if (_glfw.wl.clipboardSendString) if (_glfw.wl.clipboardSendString)
free(_glfw.wl.clipboardSendString); free(_glfw.wl.clipboardSendString);
if (_glfw.wl.keyboardLayoutName)
free(_glfw.wl.keyboardLayoutName);
} }
const char* _glfwPlatformGetVersionString(void) const char* _glfwPlatformGetVersionString(void)
+2 -2
View File
@@ -199,7 +199,7 @@ void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode)
GLFWbool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp) GLFWbool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
{ {
_glfwInputError(GLFW_FEATURE_UNAVAILABLE, _glfwInputError(GLFW_PLATFORM_ERROR,
"Wayland: Gamma ramp access is not available"); "Wayland: Gamma ramp access is not available");
return GLFW_FALSE; return GLFW_FALSE;
} }
@@ -207,7 +207,7 @@ GLFWbool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor,
const GLFWgammaramp* ramp) const GLFWgammaramp* ramp)
{ {
_glfwInputError(GLFW_FEATURE_UNAVAILABLE, _glfwInputError(GLFW_PLATFORM_ERROR,
"Wayland: Gamma ramp access is not available"); "Wayland: Gamma ramp access is not available");
} }
+10 -8
View File
@@ -53,19 +53,23 @@ typedef VkBool32 (APIENTRY *PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR
#include "null_joystick.h" #include "null_joystick.h"
#endif #endif
#include "xkb_unicode.h" #include "xkb_unicode.h"
#include "egl_context.h"
#include "osmesa_context.h"
#include "wayland-xdg-shell-client-protocol.h" #include "wayland-xdg-shell-client-protocol.h"
#include "wayland-xdg-decoration-client-protocol.h" #include "wayland-xdg-decoration-client-protocol.h"
#include "wayland-viewporter-client-protocol.h" #include "wayland-viewporter-client-protocol.h"
#include "wayland-relative-pointer-unstable-v1-client-protocol.h" #include "wayland-relative-pointer-unstable-v1-client-protocol.h"
#include "wayland-pointer-constraints-unstable-v1-client-protocol.h" #include "wayland-pointer-constraints-unstable-v1-client-protocol.h"
#include "wayland-tablet-unstable-v2-client-protocol.h"
#include "wayland-idle-inhibit-unstable-v1-client-protocol.h" #include "wayland-idle-inhibit-unstable-v1-client-protocol.h"
#define _glfw_dlopen(name) dlopen(name, RTLD_LAZY | RTLD_LOCAL) #define _glfw_dlopen(name) dlopen(name, RTLD_LAZY | RTLD_LOCAL)
#define _glfw_dlclose(handle) dlclose(handle) #define _glfw_dlclose(handle) dlclose(handle)
#define _glfw_dlsym(handle, name) dlsym(handle, name) #define _glfw_dlsym(handle, name) dlsym(handle, name)
#define _GLFW_EGL_NATIVE_WINDOW ((EGLNativeWindowType) window->wl.native)
#define _GLFW_EGL_NATIVE_DISPLAY ((EGLNativeDisplayType) _glfw.wl.display)
#define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowWayland wl #define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowWayland wl
#define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryWayland wl #define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryWayland wl
#define _GLFW_PLATFORM_MONITOR_STATE _GLFWmonitorWayland wl #define _GLFW_PLATFORM_MONITOR_STATE _GLFWmonitorWayland wl
@@ -113,6 +117,7 @@ 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 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 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_mod_mask_t (* PFN_xkb_state_serialize_mods)(struct xkb_state*, enum xkb_state_component);
typedef const char * (* PFN_xkb_keymap_layout_get_name)(struct xkb_keymap*,xkb_layout_index_t);
#define xkb_context_new _glfw.wl.xkb.context_new #define xkb_context_new _glfw.wl.xkb.context_new
#define xkb_context_unref _glfw.wl.xkb.context_unref #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_new_from_string _glfw.wl.xkb.keymap_new_from_string
@@ -124,6 +129,7 @@ typedef xkb_mod_mask_t (* PFN_xkb_state_serialize_mods)(struct xkb_state*, enum
#define xkb_state_key_get_syms _glfw.wl.xkb.state_key_get_syms #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_update_mask _glfw.wl.xkb.state_update_mask
#define xkb_state_serialize_mods _glfw.wl.xkb.state_serialize_mods #define xkb_state_serialize_mods _glfw.wl.xkb.state_serialize_mods
#define xkb_keymap_layout_get_name _glfw.wl.xkb.keymap_layout_get_name
#ifdef HAVE_XKBCOMMON_COMPOSE_H #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 struct xkb_compose_table* (* PFN_xkb_compose_table_new_from_locale)(struct xkb_context*, const char*, enum xkb_compose_compile_flags);
@@ -235,13 +241,6 @@ typedef struct _GLFWlibraryWayland
struct wp_viewporter* viewporter; struct wp_viewporter* viewporter;
struct zwp_relative_pointer_manager_v1* relativePointerManager; struct zwp_relative_pointer_manager_v1* relativePointerManager;
struct zwp_pointer_constraints_v1* pointerConstraints; struct zwp_pointer_constraints_v1* pointerConstraints;
struct zwp_tablet_manager_v2* tabletManager;
struct zwp_tablet_seat_v2* tabletSeat;
struct zwp_tablet_v2* tablet;
struct zwp_tablet_tool_v2** tabletTools;
int tabletToolsCount;
int tabletToolsSize;
struct zwp_tablet_pad_v2* tabletPad;
struct zwp_idle_inhibit_manager_v1* idleInhibitManager; struct zwp_idle_inhibit_manager_v1* idleInhibitManager;
int compositorVersion; int compositorVersion;
@@ -262,6 +261,7 @@ typedef struct _GLFWlibraryWayland
size_t clipboardSize; size_t clipboardSize;
char* clipboardSendString; char* clipboardSendString;
size_t clipboardSendSize; size_t clipboardSendSize;
char* keyboardLayoutName;
int timerfd; int timerfd;
short int keycodes[256]; short int keycodes[256];
short int scancodes[GLFW_KEY_LAST + 1]; short int scancodes[GLFW_KEY_LAST + 1];
@@ -283,6 +283,7 @@ typedef struct _GLFWlibraryWayland
xkb_mod_mask_t capsLockMask; xkb_mod_mask_t capsLockMask;
xkb_mod_mask_t numLockMask; xkb_mod_mask_t numLockMask;
unsigned int modifiers; unsigned int modifiers;
xkb_layout_index_t group;
PFN_xkb_context_new context_new; PFN_xkb_context_new context_new;
PFN_xkb_context_unref context_unref; PFN_xkb_context_unref context_unref;
@@ -295,6 +296,7 @@ typedef struct _GLFWlibraryWayland
PFN_xkb_state_key_get_syms state_key_get_syms; PFN_xkb_state_key_get_syms state_key_get_syms;
PFN_xkb_state_update_mask state_update_mask; PFN_xkb_state_update_mask state_update_mask;
PFN_xkb_state_serialize_mods state_serialize_mods; PFN_xkb_state_serialize_mods state_serialize_mods;
PFN_xkb_keymap_layout_get_name keymap_layout_get_name;
#ifdef HAVE_XKBCOMMON_COMPOSE_H #ifdef HAVE_XKBCOMMON_COMPOSE_H
PFN_xkb_compose_table_new_from_locale compose_table_new_from_locale; PFN_xkb_compose_table_new_from_locale compose_table_new_from_locale;
+39 -62
View File
@@ -142,8 +142,8 @@ static struct wl_buffer* createShmBuffer(const GLFWimage* image)
if (fd < 0) if (fd < 0)
{ {
_glfwInputError(GLFW_PLATFORM_ERROR, _glfwInputError(GLFW_PLATFORM_ERROR,
"Wayland: Creating a buffer file for %d B failed: %s", "Wayland: Creating a buffer file for %d B failed: %m",
length, strerror(errno)); length);
return NULL; return NULL;
} }
@@ -151,7 +151,7 @@ static struct wl_buffer* createShmBuffer(const GLFWimage* image)
if (data == MAP_FAILED) if (data == MAP_FAILED)
{ {
_glfwInputError(GLFW_PLATFORM_ERROR, _glfwInputError(GLFW_PLATFORM_ERROR,
"Wayland: mmap failed: %s", strerror(errno)); "Wayland: mmap failed: %m");
close(fd); close(fd);
return NULL; return NULL;
} }
@@ -749,18 +749,11 @@ static void handleEvents(int timeout)
if (read_ret != 8) if (read_ret != 8)
return; return;
if (_glfw.wl.keyboardFocus)
{
for (i = 0; i < repeats; ++i) for (i = 0; i < repeats; ++i)
{ _glfwInputKey(_glfw.wl.keyboardFocus, _glfw.wl.keyboardLastKey,
_glfwInputKey(_glfw.wl.keyboardFocus, _glfw.wl.keyboardLastScancode, GLFW_REPEAT,
_glfw.wl.keyboardLastKey,
_glfw.wl.keyboardLastScancode,
GLFW_REPEAT,
_glfw.wl.xkb.modifiers); _glfw.wl.xkb.modifiers);
} }
}
}
if (fds[2].revents & POLLIN) if (fds[2].revents & POLLIN)
{ {
@@ -890,8 +883,8 @@ void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title)
void _glfwPlatformSetWindowIcon(_GLFWwindow* window, void _glfwPlatformSetWindowIcon(_GLFWwindow* window,
int count, const GLFWimage* images) int count, const GLFWimage* images)
{ {
_glfwInputError(GLFW_FEATURE_UNAVAILABLE, _glfwInputError(GLFW_PLATFORM_ERROR,
"Wayland: The platform does not support setting the window icon"); "Wayland: Setting window icon not supported");
} }
void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos) void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos)
@@ -899,16 +892,16 @@ void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos)
// A Wayland client is not aware of its position, so just warn and leave it // A Wayland client is not aware of its position, so just warn and leave it
// as (0, 0) // as (0, 0)
_glfwInputError(GLFW_FEATURE_UNAVAILABLE, _glfwInputError(GLFW_PLATFORM_ERROR,
"Wayland: The platform does not provide the window position"); "Wayland: Window position retrieval not supported");
} }
void _glfwPlatformSetWindowPos(_GLFWwindow* window, int xpos, int ypos) void _glfwPlatformSetWindowPos(_GLFWwindow* window, int xpos, int ypos)
{ {
// A Wayland client can not set its position, so just warn // A Wayland client can not set its position, so just warn
_glfwInputError(GLFW_FEATURE_UNAVAILABLE, _glfwInputError(GLFW_PLATFORM_ERROR,
"Wayland: The platform does not support setting the window position"); "Wayland: Window position setting not supported");
} }
void _glfwPlatformGetWindowSize(_GLFWwindow* window, int* width, int* height) void _glfwPlatformGetWindowSize(_GLFWwindow* window, int* width, int* height)
@@ -947,17 +940,13 @@ void _glfwPlatformSetWindowAspectRatio(_GLFWwindow* window,
{ {
// TODO: find out how to trigger a resize. // TODO: find out how to trigger a resize.
// The actual limits are checked in the xdg_toplevel::configure handler. // The actual limits are checked in the xdg_toplevel::configure handler.
_glfwInputError(GLFW_FEATURE_UNIMPLEMENTED,
"Wayland: Window aspect ratio not yet implemented");
} }
void _glfwPlatformGetFramebufferSize(_GLFWwindow* window, void _glfwPlatformGetFramebufferSize(_GLFWwindow* window,
int* width, int* height) int* width, int* height)
{ {
_glfwPlatformGetWindowSize(window, width, height); _glfwPlatformGetWindowSize(window, width, height);
if (width)
*width *= window->wl.scale; *width *= window->wl.scale;
if (height)
*height *= window->wl.scale; *height *= window->wl.scale;
} }
@@ -1041,14 +1030,14 @@ void _glfwPlatformHideWindow(_GLFWwindow* window)
void _glfwPlatformRequestWindowAttention(_GLFWwindow* window) void _glfwPlatformRequestWindowAttention(_GLFWwindow* window)
{ {
// TODO // TODO
_glfwInputError(GLFW_FEATURE_UNIMPLEMENTED, _glfwInputError(GLFW_PLATFORM_ERROR,
"Wayland: Window attention request not implemented yet"); "Wayland: Window attention request not implemented yet");
} }
void _glfwPlatformFocusWindow(_GLFWwindow* window) void _glfwPlatformFocusWindow(_GLFWwindow* window)
{ {
_glfwInputError(GLFW_FEATURE_UNAVAILABLE, _glfwInputError(GLFW_PLATFORM_ERROR,
"Wayland: The platform does not support setting the input focus"); "Wayland: Focusing a window requires user interaction");
} }
void _glfwPlatformSetWindowMonitor(_GLFWwindow* window, void _glfwPlatformSetWindowMonitor(_GLFWwindow* window,
@@ -1107,7 +1096,7 @@ int _glfwPlatformFramebufferTransparent(_GLFWwindow* window)
void _glfwPlatformSetWindowResizable(_GLFWwindow* window, GLFWbool enabled) void _glfwPlatformSetWindowResizable(_GLFWwindow* window, GLFWbool enabled)
{ {
// TODO // TODO
_glfwInputError(GLFW_FEATURE_UNIMPLEMENTED, _glfwInputError(GLFW_PLATFORM_ERROR,
"Wayland: Window attribute setting not implemented yet"); "Wayland: Window attribute setting not implemented yet");
} }
@@ -1125,23 +1114,10 @@ void _glfwPlatformSetWindowDecorated(_GLFWwindow* window, GLFWbool enabled)
void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled) void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled)
{ {
// TODO // TODO
_glfwInputError(GLFW_FEATURE_UNIMPLEMENTED, _glfwInputError(GLFW_PLATFORM_ERROR,
"Wayland: Window attribute setting not implemented yet"); "Wayland: Window attribute setting not implemented yet");
} }
void _glfwPlatformSetWindowMousePassthrough(_GLFWwindow* window, GLFWbool enabled)
{
if (enabled)
{
struct wl_region* region = wl_compositor_create_region(_glfw.wl.compositor);
wl_surface_set_input_region(window->wl.surface, region);
wl_region_destroy(region);
}
else
wl_surface_set_input_region(window->wl.surface, 0);
wl_surface_commit(window->wl.surface);
}
float _glfwPlatformGetWindowOpacity(_GLFWwindow* window) float _glfwPlatformGetWindowOpacity(_GLFWwindow* window)
{ {
return 1.f; return 1.f;
@@ -1149,8 +1125,6 @@ float _glfwPlatformGetWindowOpacity(_GLFWwindow* window)
void _glfwPlatformSetWindowOpacity(_GLFWwindow* window, float opacity) void _glfwPlatformSetWindowOpacity(_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 _glfwPlatformSetRawMouseMotion(_GLFWwindow *window, GLFWbool enabled)
@@ -1212,8 +1186,6 @@ void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode)
const char* _glfwPlatformGetScancodeName(int scancode) const char* _glfwPlatformGetScancodeName(int scancode)
{ {
// TODO // TODO
_glfwInputError(GLFW_FEATURE_UNIMPLEMENTED,
"Wayland: Key names not yet implemented");
return NULL; return NULL;
} }
@@ -1222,6 +1194,29 @@ int _glfwPlatformGetKeyScancode(int key)
return _glfw.wl.scancodes[key]; return _glfw.wl.scancodes[key];
} }
const char* _glfwPlatformGetKeyboardLayoutName(void)
{
if (!_glfw.wl.xkb.keymap)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"Wayland: Keymap missing");
return NULL;
}
const char* name = xkb_keymap_layout_get_name(_glfw.wl.xkb.keymap,
_glfw.wl.xkb.group);
if (!name)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"Wayland: Failed to query keyboard layout name");
return NULL;
}
free(_glfw.wl.keyboardLayoutName);
_glfw.wl.keyboardLayoutName = _glfw_strdup(name);
return _glfw.wl.keyboardLayoutName;
}
int _glfwPlatformCreateCursor(_GLFWcursor* cursor, int _glfwPlatformCreateCursor(_GLFWcursor* cursor,
const GLFWimage* image, const GLFWimage* image,
int xhot, int yhot) int xhot, int yhot)
@@ -1699,24 +1694,6 @@ const char* _glfwPlatformGetClipboardString(void)
return _glfw.wl.clipboardString; return _glfw.wl.clipboardString;
} }
EGLenum _glfwPlatformGetEGLPlatform(EGLint** attribs)
{
if (_glfw.egl.EXT_platform_base && _glfw.egl.EXT_platform_wayland)
return EGL_PLATFORM_WAYLAND_EXT;
else
return 0;
}
EGLNativeDisplayType _glfwPlatformGetEGLNativeDisplay(void)
{
return _glfw.wl.display;
}
EGLNativeWindowType _glfwPlatformGetEGLNativeWindow(_GLFWwindow* window)
{
return window->wl.native;
}
void _glfwPlatformGetRequiredInstanceExtensions(char** extensions) void _glfwPlatformGetRequiredInstanceExtensions(char** extensions)
{ {
if (!_glfw.vk.KHR_surface || !_glfw.vk.KHR_wayland_surface) if (!_glfw.vk.KHR_surface || !_glfw.vk.KHR_wayland_surface)
+38 -57
View File
@@ -489,15 +489,15 @@ static void inputMethodInstantiateCallback(Display* display,
} }
} }
// Return the atom ID only if it is listed in the specified array // Check whether the specified atom is supported
// //
static Atom getAtomIfSupported(Atom* supportedAtoms, static Atom getSupportedAtom(Atom* supportedAtoms,
unsigned long atomCount, unsigned long atomCount,
const char* atomName) const char* atomName)
{ {
const Atom atom = XInternAtom(_glfw.x11.display, atomName, False); const Atom atom = XInternAtom(_glfw.x11.display, atomName, False);
for (unsigned long i = 0; i < atomCount; i++) for (unsigned int i = 0; i < atomCount; i++)
{ {
if (supportedAtoms[i] == atom) if (supportedAtoms[i] == atom)
return atom; return atom;
@@ -565,33 +565,33 @@ static void detectEWMH(void)
// See which of the atoms we support that are supported by the WM // See which of the atoms we support that are supported by the WM
_glfw.x11.NET_WM_STATE = _glfw.x11.NET_WM_STATE =
getAtomIfSupported(supportedAtoms, atomCount, "_NET_WM_STATE"); getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_STATE");
_glfw.x11.NET_WM_STATE_ABOVE = _glfw.x11.NET_WM_STATE_ABOVE =
getAtomIfSupported(supportedAtoms, atomCount, "_NET_WM_STATE_ABOVE"); getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_STATE_ABOVE");
_glfw.x11.NET_WM_STATE_FULLSCREEN = _glfw.x11.NET_WM_STATE_FULLSCREEN =
getAtomIfSupported(supportedAtoms, atomCount, "_NET_WM_STATE_FULLSCREEN"); getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_STATE_FULLSCREEN");
_glfw.x11.NET_WM_STATE_MAXIMIZED_VERT = _glfw.x11.NET_WM_STATE_MAXIMIZED_VERT =
getAtomIfSupported(supportedAtoms, atomCount, "_NET_WM_STATE_MAXIMIZED_VERT"); getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_STATE_MAXIMIZED_VERT");
_glfw.x11.NET_WM_STATE_MAXIMIZED_HORZ = _glfw.x11.NET_WM_STATE_MAXIMIZED_HORZ =
getAtomIfSupported(supportedAtoms, atomCount, "_NET_WM_STATE_MAXIMIZED_HORZ"); getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_STATE_MAXIMIZED_HORZ");
_glfw.x11.NET_WM_STATE_DEMANDS_ATTENTION = _glfw.x11.NET_WM_STATE_DEMANDS_ATTENTION =
getAtomIfSupported(supportedAtoms, atomCount, "_NET_WM_STATE_DEMANDS_ATTENTION"); getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_STATE_DEMANDS_ATTENTION");
_glfw.x11.NET_WM_FULLSCREEN_MONITORS = _glfw.x11.NET_WM_FULLSCREEN_MONITORS =
getAtomIfSupported(supportedAtoms, atomCount, "_NET_WM_FULLSCREEN_MONITORS"); getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_FULLSCREEN_MONITORS");
_glfw.x11.NET_WM_WINDOW_TYPE = _glfw.x11.NET_WM_WINDOW_TYPE =
getAtomIfSupported(supportedAtoms, atomCount, "_NET_WM_WINDOW_TYPE"); getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_WINDOW_TYPE");
_glfw.x11.NET_WM_WINDOW_TYPE_NORMAL = _glfw.x11.NET_WM_WINDOW_TYPE_NORMAL =
getAtomIfSupported(supportedAtoms, atomCount, "_NET_WM_WINDOW_TYPE_NORMAL"); getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_WINDOW_TYPE_NORMAL");
_glfw.x11.NET_WORKAREA = _glfw.x11.NET_WORKAREA =
getAtomIfSupported(supportedAtoms, atomCount, "_NET_WORKAREA"); getSupportedAtom(supportedAtoms, atomCount, "_NET_WORKAREA");
_glfw.x11.NET_CURRENT_DESKTOP = _glfw.x11.NET_CURRENT_DESKTOP =
getAtomIfSupported(supportedAtoms, atomCount, "_NET_CURRENT_DESKTOP"); getSupportedAtom(supportedAtoms, atomCount, "_NET_CURRENT_DESKTOP");
_glfw.x11.NET_ACTIVE_WINDOW = _glfw.x11.NET_ACTIVE_WINDOW =
getAtomIfSupported(supportedAtoms, atomCount, "_NET_ACTIVE_WINDOW"); getSupportedAtom(supportedAtoms, atomCount, "_NET_ACTIVE_WINDOW");
_glfw.x11.NET_FRAME_EXTENTS = _glfw.x11.NET_FRAME_EXTENTS =
getAtomIfSupported(supportedAtoms, atomCount, "_NET_FRAME_EXTENTS"); getSupportedAtom(supportedAtoms, atomCount, "_NET_FRAME_EXTENTS");
_glfw.x11.NET_REQUEST_FRAME_EXTENTS = _glfw.x11.NET_REQUEST_FRAME_EXTENTS =
getAtomIfSupported(supportedAtoms, atomCount, "_NET_REQUEST_FRAME_EXTENTS"); getSupportedAtom(supportedAtoms, atomCount, "_NET_REQUEST_FRAME_EXTENTS");
if (supportedAtoms) if (supportedAtoms)
XFree(supportedAtoms); XFree(supportedAtoms);
@@ -805,12 +805,13 @@ static GLFWbool initExtensions(void)
_glfw.x11.xkb.detectable = GLFW_TRUE; _glfw.x11.xkb.detectable = GLFW_TRUE;
} }
_glfw.x11.xkb.group = 0;
XkbStateRec state; XkbStateRec state;
if (XkbGetState(_glfw.x11.display, XkbUseCoreKbd, &state) == Success) if (XkbGetState(_glfw.x11.display, XkbUseCoreKbd, &state) == Success)
{
XkbSelectEventDetails(_glfw.x11.display, XkbUseCoreKbd, XkbStateNotify, XkbAllStateComponentsMask, XkbGroupStateMask);
_glfw.x11.xkb.group = (unsigned int)state.group; _glfw.x11.xkb.group = (unsigned int)state.group;
}
XkbSelectEventDetails(_glfw.x11.display, XkbUseCoreKbd, XkbStateNotify,
XkbGroupStateMask, XkbGroupStateMask);
} }
#if defined(__CYGWIN__) #if defined(__CYGWIN__)
@@ -851,35 +852,6 @@ static GLFWbool initExtensions(void)
} }
} }
#if defined(__CYGWIN__)
_glfw.x11.xshape.handle = _glfw_dlopen("libXext-6.so");
#else
_glfw.x11.xshape.handle = _glfw_dlopen("libXext.so.6");
#endif
if (_glfw.x11.xshape.handle)
{
_glfw.x11.xshape.QueryExtension = (PFN_XShapeQueryExtension)
_glfw_dlsym(_glfw.x11.xshape.handle, "XShapeQueryExtension");
_glfw.x11.xshape.ShapeCombineRegion = (PFN_XShapeCombineRegion)
_glfw_dlsym(_glfw.x11.xshape.handle, "XShapeCombineRegion");
_glfw.x11.xshape.QueryVersion = (PFN_XShapeQueryVersion)
_glfw_dlsym(_glfw.x11.xshape.handle, "XShapeQueryVersion");
_glfw.x11.xshape.ShapeCombineMask = (PFN_XShapeCombineMask)
_glfw_dlsym(_glfw.x11.xshape.handle, "XShapeCombineMask");
if (XShapeQueryExtension(_glfw.x11.display,
&_glfw.x11.xshape.errorBase,
&_glfw.x11.xshape.eventBase))
{
if (XShapeQueryVersion(_glfw.x11.display,
&_glfw.x11.xshape.major,
&_glfw.x11.xshape.minor))
{
_glfw.x11.xshape.available = GLFW_TRUE;
}
}
}
// Update the key code LUT // Update the key code LUT
// FIXME: We should listen to XkbMapNotify events to track changes to // FIXME: We should listen to XkbMapNotify events to track changes to
// the keyboard mapping. // the keyboard mapping.
@@ -1151,8 +1123,6 @@ int _glfwPlatformInit(void)
_glfw_dlsym(_glfw.x11.xlib.handle, "XCreateFontCursor"); _glfw_dlsym(_glfw.x11.xlib.handle, "XCreateFontCursor");
_glfw.x11.xlib.CreateIC = (PFN_XCreateIC) _glfw.x11.xlib.CreateIC = (PFN_XCreateIC)
_glfw_dlsym(_glfw.x11.xlib.handle, "XCreateIC"); _glfw_dlsym(_glfw.x11.xlib.handle, "XCreateIC");
_glfw.x11.xlib.CreateRegion = (PFN_XCreateRegion)
_glfw_dlsym(_glfw.x11.xlib.handle, "XCreateRegion");
_glfw.x11.xlib.CreateWindow = (PFN_XCreateWindow) _glfw.x11.xlib.CreateWindow = (PFN_XCreateWindow)
_glfw_dlsym(_glfw.x11.xlib.handle, "XCreateWindow"); _glfw_dlsym(_glfw.x11.xlib.handle, "XCreateWindow");
_glfw.x11.xlib.DefineCursor = (PFN_XDefineCursor) _glfw.x11.xlib.DefineCursor = (PFN_XDefineCursor)
@@ -1163,8 +1133,6 @@ int _glfwPlatformInit(void)
_glfw_dlsym(_glfw.x11.xlib.handle, "XDeleteProperty"); _glfw_dlsym(_glfw.x11.xlib.handle, "XDeleteProperty");
_glfw.x11.xlib.DestroyIC = (PFN_XDestroyIC) _glfw.x11.xlib.DestroyIC = (PFN_XDestroyIC)
_glfw_dlsym(_glfw.x11.xlib.handle, "XDestroyIC"); _glfw_dlsym(_glfw.x11.xlib.handle, "XDestroyIC");
_glfw.x11.xlib.DestroyRegion = (PFN_XDestroyRegion)
_glfw_dlsym(_glfw.x11.xlib.handle, "XDestroyRegion");
_glfw.x11.xlib.DestroyWindow = (PFN_XDestroyWindow) _glfw.x11.xlib.DestroyWindow = (PFN_XDestroyWindow)
_glfw_dlsym(_glfw.x11.xlib.handle, "XDestroyWindow"); _glfw_dlsym(_glfw.x11.xlib.handle, "XDestroyWindow");
_glfw.x11.xlib.DisplayKeycodes = (PFN_XDisplayKeycodes) _glfw.x11.xlib.DisplayKeycodes = (PFN_XDisplayKeycodes)
@@ -1185,6 +1153,8 @@ int _glfwPlatformInit(void)
_glfw_dlsym(_glfw.x11.xlib.handle, "XFreeCursor"); _glfw_dlsym(_glfw.x11.xlib.handle, "XFreeCursor");
_glfw.x11.xlib.FreeEventData = (PFN_XFreeEventData) _glfw.x11.xlib.FreeEventData = (PFN_XFreeEventData)
_glfw_dlsym(_glfw.x11.xlib.handle, "XFreeEventData"); _glfw_dlsym(_glfw.x11.xlib.handle, "XFreeEventData");
_glfw.x11.xlib.GetAtomName = (PFN_XGetAtomName)
_glfw_dlsym(_glfw.x11.xlib.handle, "XGetAtomName");
_glfw.x11.xlib.GetErrorText = (PFN_XGetErrorText) _glfw.x11.xlib.GetErrorText = (PFN_XGetErrorText)
_glfw_dlsym(_glfw.x11.xlib.handle, "XGetErrorText"); _glfw_dlsym(_glfw.x11.xlib.handle, "XGetErrorText");
_glfw.x11.xlib.GetEventData = (PFN_XGetEventData) _glfw.x11.xlib.GetEventData = (PFN_XGetEventData)
@@ -1295,6 +1265,8 @@ int _glfwPlatformInit(void)
_glfw_dlsym(_glfw.x11.xlib.handle, "XVisualIDFromVisual"); _glfw_dlsym(_glfw.x11.xlib.handle, "XVisualIDFromVisual");
_glfw.x11.xlib.WarpPointer = (PFN_XWarpPointer) _glfw.x11.xlib.WarpPointer = (PFN_XWarpPointer)
_glfw_dlsym(_glfw.x11.xlib.handle, "XWarpPointer"); _glfw_dlsym(_glfw.x11.xlib.handle, "XWarpPointer");
_glfw.x11.xkb.AllocKeyboard = (PFN_XkbAllocKeyboard)
_glfw_dlsym(_glfw.x11.xlib.handle, "XkbAllocKeyboard");
_glfw.x11.xkb.FreeKeyboard = (PFN_XkbFreeKeyboard) _glfw.x11.xkb.FreeKeyboard = (PFN_XkbFreeKeyboard)
_glfw_dlsym(_glfw.x11.xlib.handle, "XkbFreeKeyboard"); _glfw_dlsym(_glfw.x11.xlib.handle, "XkbFreeKeyboard");
_glfw.x11.xkb.FreeNames = (PFN_XkbFreeNames) _glfw.x11.xkb.FreeNames = (PFN_XkbFreeNames)
@@ -1330,9 +1302,6 @@ int _glfwPlatformInit(void)
_glfw.x11.xlib.utf8SetWMProperties = (PFN_Xutf8SetWMProperties) _glfw.x11.xlib.utf8SetWMProperties = (PFN_Xutf8SetWMProperties)
_glfw_dlsym(_glfw.x11.xlib.handle, "Xutf8SetWMProperties"); _glfw_dlsym(_glfw.x11.xlib.handle, "Xutf8SetWMProperties");
if (_glfw.x11.xlib.utf8LookupString && _glfw.x11.xlib.utf8SetWMProperties)
_glfw.x11.xlib.utf8 = GLFW_TRUE;
XInitThreads(); XInitThreads();
XrmInitialize(); XrmInitialize();
@@ -1366,7 +1335,7 @@ int _glfwPlatformInit(void)
_glfw.x11.helperWindowHandle = createHelperWindow(); _glfw.x11.helperWindowHandle = createHelperWindow();
_glfw.x11.hiddenCursorHandle = createHiddenCursor(); _glfw.x11.hiddenCursorHandle = createHiddenCursor();
if (XSupportsLocale() && _glfw.x11.xlib.utf8) if (XSupportsLocale())
{ {
XSetLocaleModifiers(""); XSetLocaleModifiers("");
@@ -1377,6 +1346,11 @@ int _glfwPlatformInit(void)
NULL); NULL);
} }
#if defined(__linux__)
if (!_glfwInitJoysticksLinux())
return GLFW_FALSE;
#endif
_glfwInitTimerPOSIX(); _glfwInitTimerPOSIX();
_glfwPollMonitorsX11(); _glfwPollMonitorsX11();
@@ -1406,6 +1380,9 @@ void _glfwPlatformTerminate(void)
free(_glfw.x11.primarySelectionString); free(_glfw.x11.primarySelectionString);
free(_glfw.x11.clipboardString); free(_glfw.x11.clipboardString);
if (_glfw.x11.keyboardLayoutName)
XFree(_glfw.x11.keyboardLayoutName);
XUnregisterIMInstantiateCallback(_glfw.x11.display, XUnregisterIMInstantiateCallback(_glfw.x11.display,
NULL, NULL, NULL, NULL, NULL, NULL,
inputMethodInstantiateCallback, inputMethodInstantiateCallback,
@@ -1470,6 +1447,10 @@ void _glfwPlatformTerminate(void)
_glfwTerminateEGL(); _glfwTerminateEGL();
_glfwTerminateGLX(); _glfwTerminateGLX();
#if defined(__linux__)
_glfwTerminateJoysticksLinux();
#endif
if (_glfw.x11.xlib.handle) if (_glfw.x11.xlib.handle)
{ {
_glfw_dlclose(_glfw.x11.xlib.handle); _glfw_dlclose(_glfw.x11.xlib.handle);
+1 -1
View File
@@ -164,7 +164,7 @@ void _glfwPollMonitorsX11(void)
if (widthMM <= 0 || heightMM <= 0) if (widthMM <= 0 || heightMM <= 0)
{ {
// HACK: If RandR does not provide a physical size, assume the // HACK: If RandR does not provide a physical size, assume the
// X11 default 96 DPI and calculate from the CRTC viewport // X11 default 96 DPI and calcuate from the CRTC viewport
// NOTE: These members are affected by rotation, unlike the mode // NOTE: These members are affected by rotation, unlike the mode
// info and output info members // info and output info members
widthMM = (int) (ci->width * 25.4f / 96.f); widthMM = (int) (ci->width * 25.4f / 96.f);
+14 -36
View File
@@ -48,9 +48,6 @@
// The XInput extension provides raw mouse motion input // The XInput extension provides raw mouse motion input
#include <X11/extensions/XInput2.h> #include <X11/extensions/XInput2.h>
// The Shape extension provides custom window shapes
#include <X11/extensions/shape.h>
typedef XClassHint* (* PFN_XAllocClassHint)(void); typedef XClassHint* (* PFN_XAllocClassHint)(void);
typedef XSizeHints* (* PFN_XAllocSizeHints)(void); typedef XSizeHints* (* PFN_XAllocSizeHints)(void);
typedef XWMHints* (* PFN_XAllocWMHints)(void); typedef XWMHints* (* PFN_XAllocWMHints)(void);
@@ -64,13 +61,11 @@ typedef int (* PFN_XConvertSelection)(Display*,Atom,Atom,Atom,Window,Time);
typedef Colormap (* PFN_XCreateColormap)(Display*,Window,Visual*,int); typedef Colormap (* PFN_XCreateColormap)(Display*,Window,Visual*,int);
typedef Cursor (* PFN_XCreateFontCursor)(Display*,unsigned int); typedef Cursor (* PFN_XCreateFontCursor)(Display*,unsigned int);
typedef XIC (* PFN_XCreateIC)(XIM,...); typedef XIC (* PFN_XCreateIC)(XIM,...);
typedef Region (* PFN_XCreateRegion)(void);
typedef Window (* PFN_XCreateWindow)(Display*,Window,int,int,unsigned int,unsigned int,unsigned int,int,unsigned int,Visual*,unsigned long,XSetWindowAttributes*); typedef Window (* PFN_XCreateWindow)(Display*,Window,int,int,unsigned int,unsigned int,unsigned int,int,unsigned int,Visual*,unsigned long,XSetWindowAttributes*);
typedef int (* PFN_XDefineCursor)(Display*,Window,Cursor); typedef int (* PFN_XDefineCursor)(Display*,Window,Cursor);
typedef int (* PFN_XDeleteContext)(Display*,XID,XContext); typedef int (* PFN_XDeleteContext)(Display*,XID,XContext);
typedef int (* PFN_XDeleteProperty)(Display*,Window,Atom); typedef int (* PFN_XDeleteProperty)(Display*,Window,Atom);
typedef void (* PFN_XDestroyIC)(XIC); typedef void (* PFN_XDestroyIC)(XIC);
typedef int (* PFN_XDestroyRegion)(Region);
typedef int (* PFN_XDestroyWindow)(Display*,Window); typedef int (* PFN_XDestroyWindow)(Display*,Window);
typedef int (* PFN_XDisplayKeycodes)(Display*,int*,int*); typedef int (* PFN_XDisplayKeycodes)(Display*,int*,int*);
typedef int (* PFN_XEventsQueued)(Display*,int); typedef int (* PFN_XEventsQueued)(Display*,int);
@@ -81,6 +76,7 @@ typedef int (* PFN_XFree)(void*);
typedef int (* PFN_XFreeColormap)(Display*,Colormap); typedef int (* PFN_XFreeColormap)(Display*,Colormap);
typedef int (* PFN_XFreeCursor)(Display*,Cursor); typedef int (* PFN_XFreeCursor)(Display*,Cursor);
typedef void (* PFN_XFreeEventData)(Display*,XGenericEventCookie*); typedef void (* PFN_XFreeEventData)(Display*,XGenericEventCookie*);
typedef char* (* PFN_XGetAtomName)(Display*,Atom);
typedef int (* PFN_XGetErrorText)(Display*,int,char*,int); typedef int (* PFN_XGetErrorText)(Display*,int,char*,int);
typedef Bool (* PFN_XGetEventData)(Display*,XGenericEventCookie*); typedef Bool (* PFN_XGetEventData)(Display*,XGenericEventCookie*);
typedef char* (* PFN_XGetICValues)(XIC,...); typedef char* (* PFN_XGetICValues)(XIC,...);
@@ -138,6 +134,7 @@ typedef VisualID (* PFN_XVisualIDFromVisual)(Visual*);
typedef int (* PFN_XWarpPointer)(Display*,Window,Window,int,int,unsigned int,unsigned int,int,int); typedef int (* PFN_XWarpPointer)(Display*,Window,Window,int,int,unsigned int,unsigned int,int,int);
typedef void (* PFN_XkbFreeKeyboard)(XkbDescPtr,unsigned int,Bool); typedef void (* PFN_XkbFreeKeyboard)(XkbDescPtr,unsigned int,Bool);
typedef void (* PFN_XkbFreeNames)(XkbDescPtr,unsigned int,Bool); typedef void (* PFN_XkbFreeNames)(XkbDescPtr,unsigned int,Bool);
typedef XkbDescPtr (* PFN_XkbAllocKeyboard)(void);
typedef XkbDescPtr (* PFN_XkbGetMap)(Display*,unsigned int,unsigned int); typedef XkbDescPtr (* PFN_XkbGetMap)(Display*,unsigned int,unsigned int);
typedef Status (* PFN_XkbGetNames)(Display*,unsigned int,XkbDescPtr); typedef Status (* PFN_XkbGetNames)(Display*,unsigned int,XkbDescPtr);
typedef Status (* PFN_XkbGetState)(Display*,unsigned int,XkbStatePtr); typedef Status (* PFN_XkbGetState)(Display*,unsigned int,XkbStatePtr);
@@ -166,13 +163,11 @@ typedef void (* PFN_Xutf8SetWMProperties)(Display*,Window,const char*,const char
#define XCreateColormap _glfw.x11.xlib.CreateColormap #define XCreateColormap _glfw.x11.xlib.CreateColormap
#define XCreateFontCursor _glfw.x11.xlib.CreateFontCursor #define XCreateFontCursor _glfw.x11.xlib.CreateFontCursor
#define XCreateIC _glfw.x11.xlib.CreateIC #define XCreateIC _glfw.x11.xlib.CreateIC
#define XCreateRegion _glfw.x11.xlib.CreateRegion
#define XCreateWindow _glfw.x11.xlib.CreateWindow #define XCreateWindow _glfw.x11.xlib.CreateWindow
#define XDefineCursor _glfw.x11.xlib.DefineCursor #define XDefineCursor _glfw.x11.xlib.DefineCursor
#define XDeleteContext _glfw.x11.xlib.DeleteContext #define XDeleteContext _glfw.x11.xlib.DeleteContext
#define XDeleteProperty _glfw.x11.xlib.DeleteProperty #define XDeleteProperty _glfw.x11.xlib.DeleteProperty
#define XDestroyIC _glfw.x11.xlib.DestroyIC #define XDestroyIC _glfw.x11.xlib.DestroyIC
#define XDestroyRegion _glfw.x11.xlib.DestroyRegion
#define XDestroyWindow _glfw.x11.xlib.DestroyWindow #define XDestroyWindow _glfw.x11.xlib.DestroyWindow
#define XDisplayKeycodes _glfw.x11.xlib.DisplayKeycodes #define XDisplayKeycodes _glfw.x11.xlib.DisplayKeycodes
#define XEventsQueued _glfw.x11.xlib.EventsQueued #define XEventsQueued _glfw.x11.xlib.EventsQueued
@@ -183,6 +178,7 @@ typedef void (* PFN_Xutf8SetWMProperties)(Display*,Window,const char*,const char
#define XFreeColormap _glfw.x11.xlib.FreeColormap #define XFreeColormap _glfw.x11.xlib.FreeColormap
#define XFreeCursor _glfw.x11.xlib.FreeCursor #define XFreeCursor _glfw.x11.xlib.FreeCursor
#define XFreeEventData _glfw.x11.xlib.FreeEventData #define XFreeEventData _glfw.x11.xlib.FreeEventData
#define XGetAtomName _glfw.x11.xlib.GetAtomName
#define XGetErrorText _glfw.x11.xlib.GetErrorText #define XGetErrorText _glfw.x11.xlib.GetErrorText
#define XGetEventData _glfw.x11.xlib.GetEventData #define XGetEventData _glfw.x11.xlib.GetEventData
#define XGetICValues _glfw.x11.xlib.GetICValues #define XGetICValues _glfw.x11.xlib.GetICValues
@@ -238,6 +234,7 @@ typedef void (* PFN_Xutf8SetWMProperties)(Display*,Window,const char*,const char
#define XUnsetICFocus _glfw.x11.xlib.UnsetICFocus #define XUnsetICFocus _glfw.x11.xlib.UnsetICFocus
#define XVisualIDFromVisual _glfw.x11.xlib.VisualIDFromVisual #define XVisualIDFromVisual _glfw.x11.xlib.VisualIDFromVisual
#define XWarpPointer _glfw.x11.xlib.WarpPointer #define XWarpPointer _glfw.x11.xlib.WarpPointer
#define XkbAllocKeyboard _glfw.x11.xkb.AllocKeyboard
#define XkbFreeKeyboard _glfw.x11.xkb.FreeKeyboard #define XkbFreeKeyboard _glfw.x11.xkb.FreeKeyboard
#define XkbFreeNames _glfw.x11.xkb.FreeNames #define XkbFreeNames _glfw.x11.xkb.FreeNames
#define XkbGetMap _glfw.x11.xkb.GetMap #define XkbGetMap _glfw.x11.xkb.GetMap
@@ -338,16 +335,6 @@ typedef XRenderPictFormat* (* PFN_XRenderFindVisualFormat)(Display*,Visual const
#define XRenderQueryVersion _glfw.x11.xrender.QueryVersion #define XRenderQueryVersion _glfw.x11.xrender.QueryVersion
#define XRenderFindVisualFormat _glfw.x11.xrender.FindVisualFormat #define XRenderFindVisualFormat _glfw.x11.xrender.FindVisualFormat
typedef Bool (* PFN_XShapeQueryExtension)(Display*,int*,int*);
typedef Status (* PFN_XShapeQueryVersion)(Display*dpy,int*,int*);
typedef void (* PFN_XShapeCombineRegion)(Display*,Window,int,int,int,Region,int);
typedef void (* PFN_XShapeCombineMask)(Display*,Window,int,int,int,Pixmap,int);
#define XShapeQueryExtension _glfw.x11.xshape.QueryExtension
#define XShapeQueryVersion _glfw.x11.xshape.QueryVersion
#define XShapeCombineRegion _glfw.x11.xshape.ShapeCombineRegion
#define XShapeCombineMask _glfw.x11.xshape.ShapeCombineMask
typedef VkFlags VkXlibSurfaceCreateFlagsKHR; typedef VkFlags VkXlibSurfaceCreateFlagsKHR;
typedef VkFlags VkXcbSurfaceCreateFlagsKHR; typedef VkFlags VkXcbSurfaceCreateFlagsKHR;
@@ -378,6 +365,8 @@ typedef VkBool32 (APIENTRY *PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR)(Vk
#include "posix_time.h" #include "posix_time.h"
#include "xkb_unicode.h" #include "xkb_unicode.h"
#include "glx_context.h" #include "glx_context.h"
#include "egl_context.h"
#include "osmesa_context.h"
#if defined(__linux__) #if defined(__linux__)
#include "linux_joystick.h" #include "linux_joystick.h"
#else #else
@@ -388,6 +377,9 @@ typedef VkBool32 (APIENTRY *PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR)(Vk
#define _glfw_dlclose(handle) dlclose(handle) #define _glfw_dlclose(handle) dlclose(handle)
#define _glfw_dlsym(handle, name) dlsym(handle, name) #define _glfw_dlsym(handle, name) dlsym(handle, name)
#define _GLFW_EGL_NATIVE_WINDOW ((EGLNativeWindowType) window->x11.handle)
#define _GLFW_EGL_NATIVE_DISPLAY ((EGLNativeDisplayType) _glfw.x11.display)
#define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowX11 x11 #define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowX11 x11
#define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryX11 x11 #define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryX11 x11
#define _GLFW_PLATFORM_MONITOR_STATE _GLFWmonitorX11 x11 #define _GLFW_PLATFORM_MONITOR_STATE _GLFWmonitorX11 x11
@@ -419,9 +411,8 @@ typedef struct _GLFWwindowX11
// The last position the cursor was warped to by GLFW // The last position the cursor was warped to by GLFW
int warpCursorPosX, warpCursorPosY; int warpCursorPosX, warpCursorPosY;
// The time of the last KeyPress event per keycode, for discarding // The time of the last KeyPress event
// duplicate key events generated for some keys by ibus Time lastKeyTime;
Time keyPressTimes[256];
} _GLFWwindowX11; } _GLFWwindowX11;
@@ -455,6 +446,7 @@ typedef struct _GLFWlibraryX11
short int keycodes[256]; short int keycodes[256];
// GLFW key to X11 keycode LUT // GLFW key to X11 keycode LUT
short int scancodes[GLFW_KEY_LAST + 1]; short int scancodes[GLFW_KEY_LAST + 1];
char* keyboardLayoutName;
// Where to place the cursor when re-enabled // Where to place the cursor when re-enabled
double restoreCursorPosX, restoreCursorPosY; double restoreCursorPosX, restoreCursorPosY;
// The window whose disabled cursor mode is active // The window whose disabled cursor mode is active
@@ -518,7 +510,6 @@ typedef struct _GLFWlibraryX11
struct { struct {
void* handle; void* handle;
GLFWbool utf8;
PFN_XAllocClassHint AllocClassHint; PFN_XAllocClassHint AllocClassHint;
PFN_XAllocSizeHints AllocSizeHints; PFN_XAllocSizeHints AllocSizeHints;
PFN_XAllocWMHints AllocWMHints; PFN_XAllocWMHints AllocWMHints;
@@ -532,13 +523,11 @@ typedef struct _GLFWlibraryX11
PFN_XCreateColormap CreateColormap; PFN_XCreateColormap CreateColormap;
PFN_XCreateFontCursor CreateFontCursor; PFN_XCreateFontCursor CreateFontCursor;
PFN_XCreateIC CreateIC; PFN_XCreateIC CreateIC;
PFN_XCreateRegion CreateRegion;
PFN_XCreateWindow CreateWindow; PFN_XCreateWindow CreateWindow;
PFN_XDefineCursor DefineCursor; PFN_XDefineCursor DefineCursor;
PFN_XDeleteContext DeleteContext; PFN_XDeleteContext DeleteContext;
PFN_XDeleteProperty DeleteProperty; PFN_XDeleteProperty DeleteProperty;
PFN_XDestroyIC DestroyIC; PFN_XDestroyIC DestroyIC;
PFN_XDestroyRegion DestroyRegion;
PFN_XDestroyWindow DestroyWindow; PFN_XDestroyWindow DestroyWindow;
PFN_XDisplayKeycodes DisplayKeycodes; PFN_XDisplayKeycodes DisplayKeycodes;
PFN_XEventsQueued EventsQueued; PFN_XEventsQueued EventsQueued;
@@ -549,6 +538,7 @@ typedef struct _GLFWlibraryX11
PFN_XFreeColormap FreeColormap; PFN_XFreeColormap FreeColormap;
PFN_XFreeCursor FreeCursor; PFN_XFreeCursor FreeCursor;
PFN_XFreeEventData FreeEventData; PFN_XFreeEventData FreeEventData;
PFN_XGetAtomName GetAtomName;
PFN_XGetErrorText GetErrorText; PFN_XGetErrorText GetErrorText;
PFN_XGetEventData GetEventData; PFN_XGetEventData GetEventData;
PFN_XGetICValues GetICValues; PFN_XGetICValues GetICValues;
@@ -654,6 +644,7 @@ typedef struct _GLFWlibraryX11
int major; int major;
int minor; int minor;
unsigned int group; unsigned int group;
PFN_XkbAllocKeyboard AllocKeyboard;
PFN_XkbFreeKeyboard FreeKeyboard; PFN_XkbFreeKeyboard FreeKeyboard;
PFN_XkbFreeNames FreeNames; PFN_XkbFreeNames FreeNames;
PFN_XkbGetMap GetMap; PFN_XkbGetMap GetMap;
@@ -739,19 +730,6 @@ typedef struct _GLFWlibraryX11
PFN_XRenderFindVisualFormat FindVisualFormat; PFN_XRenderFindVisualFormat FindVisualFormat;
} xrender; } xrender;
struct {
GLFWbool available;
void* handle;
int major;
int minor;
int eventBase;
int errorBase;
PFN_XShapeQueryExtension QueryExtension;
PFN_XShapeCombineRegion ShapeCombineRegion;
PFN_XShapeQueryVersion QueryVersion;
PFN_XShapeCombineMask ShapeCombineMask;
} xshape;
} _GLFWlibraryX11; } _GLFWlibraryX11;
// X11-specific per-monitor data // X11-specific per-monitor data
+92 -98
View File
@@ -463,6 +463,7 @@ static size_t encodeUTF8(char* s, unsigned int ch)
// Decode a Unicode code point from a UTF-8 stream // Decode a Unicode code point from a UTF-8 stream
// Based on cutef8 by Jeff Bezanson (Public Domain) // Based on cutef8 by Jeff Bezanson (Public Domain)
// //
#if defined(X_HAVE_UTF8_STRING)
static unsigned int decodeUTF8(const char** s) static unsigned int decodeUTF8(const char** s)
{ {
unsigned int ch = 0, count = 0; unsigned int ch = 0, count = 0;
@@ -482,6 +483,7 @@ static unsigned int decodeUTF8(const char** s)
assert(count <= 6); assert(count <= 6);
return ch - offsets[count - 1]; return ch - offsets[count - 1];
} }
#endif /*X_HAVE_UTF8_STRING*/
// Convert the specified Latin-1 string to UTF-8 // Convert the specified Latin-1 string to UTF-8
// //
@@ -1182,9 +1184,8 @@ static void processEvent(XEvent *event)
(((XkbEvent*) event)->state.changed & XkbGroupStateMask)) (((XkbEvent*) event)->state.changed & XkbGroupStateMask))
{ {
_glfw.x11.xkb.group = ((XkbEvent*) event)->state.group; _glfw.x11.xkb.group = ((XkbEvent*) event)->state.group;
_glfwInputKeyboardLayout();
} }
return;
} }
} }
@@ -1263,26 +1264,23 @@ static void processEvent(XEvent *event)
if (window->x11.ic) if (window->x11.ic)
{ {
// HACK: Do not report the key press events duplicated by XIM // HACK: Ignore duplicate key press events generated by ibus
// Duplicate key releases are filtered out implicitly by // These have the same timestamp as the original event
// the GLFW key repeat logic in _glfwInputKey // Corresponding release events are filtered out
// A timestamp per key is used to handle simultaneous keys // implicitly by the GLFW key repeat logic
// NOTE: Always allow the first event for each key through if (window->x11.lastKeyTime < event->xkey.time)
// (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 (keycode) if (keycode)
_glfwInputKey(window, key, keycode, GLFW_PRESS, mods); _glfwInputKey(window, key, keycode, GLFW_PRESS, mods);
window->x11.keyPressTimes[keycode] = event->xkey.time; window->x11.lastKeyTime = event->xkey.time;
} }
if (!filtered) if (!filtered)
{ {
int count; int count;
Status status; Status status;
#if defined(X_HAVE_UTF8_STRING)
char buffer[100]; char buffer[100];
char* chars = buffer; char* chars = buffer;
@@ -1307,6 +1305,33 @@ static void processEvent(XEvent *event)
while (c - chars < count) while (c - chars < count)
_glfwInputChar(window, decodeUTF8(&c), mods, plain); _glfwInputChar(window, decodeUTF8(&c), mods, plain);
} }
#else /*X_HAVE_UTF8_STRING*/
wchar_t buffer[16];
wchar_t* chars = buffer;
count = XwcLookupString(window->x11.ic,
&event->xkey,
buffer,
sizeof(buffer) / sizeof(wchar_t),
NULL,
&status);
if (status == XBufferOverflow)
{
chars = calloc(count, sizeof(wchar_t));
count = XwcLookupString(window->x11.ic,
&event->xkey,
chars, count,
NULL, &status);
}
if (status == XLookupChars || status == XLookupBoth)
{
int i;
for (i = 0; i < count; i++)
_glfwInputChar(window, chars[i], mods, plain);
}
#endif /*X_HAVE_UTF8_STRING*/
if (chars != buffer) if (chars != buffer)
free(chars); free(chars);
@@ -1975,7 +2000,7 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
const _GLFWctxconfig* ctxconfig, const _GLFWctxconfig* ctxconfig,
const _GLFWfbconfig* fbconfig) const _GLFWfbconfig* fbconfig)
{ {
Visual* visual = NULL; Visual* visual;
int depth; int depth;
if (ctxconfig->client != GLFW_NO_API) if (ctxconfig->client != GLFW_NO_API)
@@ -2001,7 +2026,8 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
} }
} }
if (!visual) if (ctxconfig->client == GLFW_NO_API ||
ctxconfig->source == GLFW_OSMESA_CONTEXT_API)
{ {
visual = DefaultVisual(_glfw.x11.display, _glfw.x11.screen); visual = DefaultVisual(_glfw.x11.display, _glfw.x11.screen);
depth = DefaultDepth(_glfw.x11.display, _glfw.x11.screen); depth = DefaultDepth(_glfw.x11.display, _glfw.x11.screen);
@@ -2076,14 +2102,21 @@ void _glfwPlatformDestroyWindow(_GLFWwindow* window)
void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title) void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title)
{ {
if (_glfw.x11.xlib.utf8) #if defined(X_HAVE_UTF8_STRING)
{
Xutf8SetWMProperties(_glfw.x11.display, Xutf8SetWMProperties(_glfw.x11.display,
window->x11.handle, window->x11.handle,
title, title, title, title,
NULL, 0, NULL, 0,
NULL, NULL, NULL); NULL, NULL, NULL);
} #else
// This may be a slightly better fallback than using XStoreName and
// XSetIconName, which always store their arguments using STRING
XmbSetWMProperties(_glfw.x11.display,
window->x11.handle,
title, title,
NULL, 0,
NULL, NULL, NULL);
#endif
XChangeProperty(_glfw.x11.display, window->x11.handle, XChangeProperty(_glfw.x11.display, window->x11.handle,
_glfw.x11.NET_WM_NAME, _glfw.x11.UTF8_STRING, 8, _glfw.x11.NET_WM_NAME, _glfw.x11.UTF8_STRING, 8,
@@ -2576,19 +2609,13 @@ int _glfwPlatformWindowHovered(_GLFWwindow* window)
int rootX, rootY, childX, childY; int rootX, rootY, childX, childY;
unsigned int mask; unsigned int mask;
_glfwGrabErrorHandlerX11(); if (!XQueryPointer(_glfw.x11.display, w,
&root, &w, &rootX, &rootY, &childX, &childY, &mask))
const Bool result = XQueryPointer(_glfw.x11.display, w, {
&root, &w, &rootX, &rootY,
&childX, &childY, &mask);
_glfwReleaseErrorHandlerX11();
if (_glfw.x11.errorCode == BadWindow)
w = _glfw.x11.root;
else if (!result)
return GLFW_FALSE; return GLFW_FALSE;
else if (w == window->x11.handle) }
if (w == window->x11.handle)
return GLFW_TRUE; return GLFW_TRUE;
} }
@@ -2702,25 +2729,6 @@ void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled)
XFlush(_glfw.x11.display); XFlush(_glfw.x11.display);
} }
void _glfwPlatformSetWindowMousePassthrough(_GLFWwindow* window, GLFWbool enabled)
{
if (!_glfw.x11.xshape.available)
return;
if (enabled)
{
Region region = XCreateRegion();
XShapeCombineRegion(_glfw.x11.display, window->x11.handle,
ShapeInput, 0, 0, region, ShapeSet);
XDestroyRegion(region);
}
else
{
XShapeCombineMask(_glfw.x11.display, window->x11.handle,
ShapeInput, 0, 0, None, ShapeSet);
}
}
float _glfwPlatformGetWindowOpacity(_GLFWwindow* window) float _glfwPlatformGetWindowOpacity(_GLFWwindow* window)
{ {
float opacity = 1.f; float opacity = 1.f;
@@ -2776,7 +2784,6 @@ void _glfwPlatformPollEvents(void)
_GLFWwindow* window; _GLFWwindow* window;
#if defined(__linux__) #if defined(__linux__)
if (_glfw.joysticksInitialized)
_glfwDetectJoystickConnectionLinux(); _glfwDetectJoystickConnectionLinux();
#endif #endif
XPending(_glfw.x11.display); XPending(_glfw.x11.display);
@@ -2914,6 +2921,42 @@ int _glfwPlatformGetKeyScancode(int key)
return _glfw.x11.scancodes[key]; return _glfw.x11.scancodes[key];
} }
const char* _glfwPlatformGetKeyboardLayoutName(void)
{
if (!_glfw.x11.xkb.available)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"X11: XKB extension required for keyboard layout names");
return NULL;
}
XkbStateRec state = {0};
XkbGetState(_glfw.x11.display, XkbUseCoreKbd, &state);
XkbDescPtr desc = XkbAllocKeyboard();
if (XkbGetNames(_glfw.x11.display, XkbGroupNamesMask, desc) != Success)
{
XkbFreeKeyboard(desc, 0, True);
_glfwInputError(GLFW_PLATFORM_ERROR,
"X11: Failed to retrieve keyboard layout names");
return NULL;
}
const Atom atom = desc->names->groups[state.group];
XkbFreeKeyboard(desc, 0, True);
if (atom == None)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"X11: Name missing for current keyboard layout");
return NULL;
}
free(_glfw.x11.keyboardLayoutName);
_glfw.x11.keyboardLayoutName = XGetAtomName(_glfw.x11.display, atom);
return _glfw.x11.keyboardLayoutName;
}
int _glfwPlatformCreateCursor(_GLFWcursor* cursor, int _glfwPlatformCreateCursor(_GLFWcursor* cursor,
const GLFWimage* image, const GLFWimage* image,
int xhot, int yhot) int xhot, int yhot)
@@ -3041,55 +3084,6 @@ const char* _glfwPlatformGetClipboardString(void)
return getSelectionString(_glfw.x11.CLIPBOARD); return getSelectionString(_glfw.x11.CLIPBOARD);
} }
EGLenum _glfwPlatformGetEGLPlatform(EGLint** attribs)
{
if (_glfw.egl.ANGLE_platform_angle)
{
int type = 0;
if (_glfw.egl.ANGLE_platform_angle_opengl)
{
if (_glfw.hints.init.angleType == GLFW_ANGLE_PLATFORM_TYPE_OPENGL)
type = EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE;
}
if (_glfw.egl.ANGLE_platform_angle_vulkan)
{
if (_glfw.hints.init.angleType == GLFW_ANGLE_PLATFORM_TYPE_VULKAN)
type = EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE;
}
if (type)
{
*attribs = calloc(5, sizeof(EGLint));
(*attribs)[0] = EGL_PLATFORM_ANGLE_TYPE_ANGLE;
(*attribs)[1] = type;
(*attribs)[2] = EGL_PLATFORM_ANGLE_NATIVE_PLATFORM_TYPE_ANGLE;
(*attribs)[3] = EGL_PLATFORM_X11_EXT;
(*attribs)[4] = EGL_NONE;
return EGL_PLATFORM_ANGLE_ANGLE;
}
}
if (_glfw.egl.EXT_platform_base && _glfw.egl.EXT_platform_x11)
return EGL_PLATFORM_X11_EXT;
return 0;
}
EGLNativeDisplayType _glfwPlatformGetEGLNativeDisplay(void)
{
return _glfw.x11.display;
}
EGLNativeWindowType _glfwPlatformGetEGLNativeWindow(_GLFWwindow* window)
{
if (_glfw.egl.platform)
return &window->x11.handle;
else
return (EGLNativeWindowType) window->x11.handle;
}
void _glfwPlatformGetRequiredInstanceExtensions(char** extensions) void _glfwPlatformGetRequiredInstanceExtensions(char** extensions)
{ {
if (!_glfw.vk.KHR_surface) if (!_glfw.vk.KHR_surface)
+6 -4
View File
@@ -34,12 +34,13 @@ add_executable(gamma WIN32 MACOSX_BUNDLE gamma.c ${GLAD_GL})
add_executable(icon WIN32 MACOSX_BUNDLE icon.c ${GLAD_GL}) add_executable(icon WIN32 MACOSX_BUNDLE icon.c ${GLAD_GL})
add_executable(inputlag WIN32 MACOSX_BUNDLE inputlag.c ${GETOPT} ${GLAD_GL}) add_executable(inputlag WIN32 MACOSX_BUNDLE inputlag.c ${GETOPT} ${GLAD_GL})
add_executable(joysticks WIN32 MACOSX_BUNDLE joysticks.c ${GLAD_GL}) add_executable(joysticks WIN32 MACOSX_BUNDLE joysticks.c ${GLAD_GL})
add_executable(opacity WIN32 MACOSX_BUNDLE opacity.c ${GLAD_GL})
add_executable(tearing WIN32 MACOSX_BUNDLE tearing.c ${GLAD_GL}) add_executable(tearing WIN32 MACOSX_BUNDLE tearing.c ${GLAD_GL})
add_executable(threads WIN32 MACOSX_BUNDLE threads.c ${TINYCTHREAD} ${GLAD_GL}) add_executable(threads WIN32 MACOSX_BUNDLE threads.c ${TINYCTHREAD} ${GLAD_GL})
add_executable(timeout WIN32 MACOSX_BUNDLE timeout.c ${GLAD_GL}) add_executable(timeout WIN32 MACOSX_BUNDLE timeout.c ${GLAD_GL})
add_executable(title WIN32 MACOSX_BUNDLE title.c ${GLAD_GL}) add_executable(title WIN32 MACOSX_BUNDLE title.c ${GLAD_GL})
add_executable(triangle-vulkan WIN32 triangle-vulkan.c ${GLAD_VULKAN}) add_executable(triangle-vulkan WIN32 triangle-vulkan.c ${GLAD_VULKAN})
add_executable(window WIN32 MACOSX_BUNDLE window.c ${GLAD_GL}) add_executable(windows WIN32 MACOSX_BUNDLE windows.c ${GLAD_GL})
target_link_libraries(empty Threads::Threads) target_link_libraries(empty Threads::Threads)
target_link_libraries(threads Threads::Threads) target_link_libraries(threads Threads::Threads)
@@ -48,8 +49,8 @@ if (RT_LIBRARY)
target_link_libraries(threads "${RT_LIBRARY}") target_link_libraries(threads "${RT_LIBRARY}")
endif() endif()
set(GUI_ONLY_BINARIES empty gamma icon inputlag joysticks tearing threads set(GUI_ONLY_BINARIES empty gamma icon inputlag joysticks opacity tearing
timeout title triangle-vulkan window) threads timeout title triangle-vulkan windows)
set(CONSOLE_BINARIES clipboard events msaa glfwinfo iconify monitors reopen set(CONSOLE_BINARIES clipboard events msaa glfwinfo iconify monitors reopen
cursor) cursor)
@@ -68,11 +69,12 @@ if (APPLE)
set_target_properties(gamma PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Gamma") set_target_properties(gamma PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Gamma")
set_target_properties(inputlag PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Input Lag") set_target_properties(inputlag PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Input Lag")
set_target_properties(joysticks PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Joysticks") set_target_properties(joysticks PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Joysticks")
set_target_properties(opacity PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Opacity")
set_target_properties(tearing PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Tearing") set_target_properties(tearing PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Tearing")
set_target_properties(threads PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Threads") set_target_properties(threads PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Threads")
set_target_properties(timeout PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Timeout") set_target_properties(timeout PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Timeout")
set_target_properties(title PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Title") set_target_properties(title PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Title")
set_target_properties(window PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Window") set_target_properties(windows PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Windows")
set_target_properties(${GUI_ONLY_BINARIES} PROPERTIES set_target_properties(${GUI_ONLY_BINARIES} PROPERTIES
MACOSX_BUNDLE_SHORT_VERSION_STRING ${GLFW_VERSION} MACOSX_BUNDLE_SHORT_VERSION_STRING ${GLFW_VERSION}
+7
View File
@@ -465,6 +465,12 @@ static void drop_callback(GLFWwindow* window, int count, const char* paths[])
printf(" %i: \"%s\"\n", i, paths[i]); printf(" %i: \"%s\"\n", i, paths[i]);
} }
static void keyboard_layout_callback(void)
{
printf("%08x at %0.3f: Keyboard layout changed to \'%s\'\n",
counter++, glfwGetTime(), glfwGetKeyboardLayoutName());
}
static void monitor_callback(GLFWmonitor* monitor, int event) static void monitor_callback(GLFWmonitor* monitor, int event)
{ {
if (event == GLFW_CONNECTED) if (event == GLFW_CONNECTED)
@@ -546,6 +552,7 @@ int main(int argc, char** argv)
glfwSetMonitorCallback(monitor_callback); glfwSetMonitorCallback(monitor_callback);
glfwSetJoystickCallback(joystick_callback); glfwSetJoystickCallback(joystick_callback);
glfwSetKeyboardLayoutCallback(keyboard_layout_callback);
while ((ch = getopt(argc, argv, "hfn:")) != -1) while ((ch = getopt(argc, argv, "hfn:")) != -1)
{ {
+82 -158
View File
@@ -55,13 +55,6 @@
#define BEHAVIOR_NAME_NONE "none" #define BEHAVIOR_NAME_NONE "none"
#define BEHAVIOR_NAME_FLUSH "flush" #define BEHAVIOR_NAME_FLUSH "flush"
#define ANGLE_TYPE_OPENGL "gl"
#define ANGLE_TYPE_OPENGLES "es"
#define ANGLE_TYPE_D3D9 "d3d9"
#define ANGLE_TYPE_D3D11 "d3d11"
#define ANGLE_TYPE_VULKAN "vk"
#define ANGLE_TYPE_METAL "mtl"
static void usage(void) static void usage(void)
{ {
printf("Usage: glfwinfo [OPTION]...\n"); printf("Usage: glfwinfo [OPTION]...\n");
@@ -108,13 +101,6 @@ static void usage(void)
printf(" --srgb request an sRGB capable framebuffer\n"); printf(" --srgb request an sRGB capable framebuffer\n");
printf(" --singlebuffer request single-buffering\n"); printf(" --singlebuffer request single-buffering\n");
printf(" --no-error request a context that does not emit errors\n"); printf(" --no-error request a context that does not emit errors\n");
printf(" --angle-type=TYPE the ANGLE platform type to use ("
ANGLE_TYPE_OPENGL ", "
ANGLE_TYPE_OPENGLES ", "
ANGLE_TYPE_D3D9 ", "
ANGLE_TYPE_D3D11 ", "
ANGLE_TYPE_VULKAN " or "
ANGLE_TYPE_METAL ")\n");
printf(" --graphics-switching request macOS graphics switching\n"); printf(" --graphics-switching request macOS graphics switching\n");
} }
@@ -292,7 +278,7 @@ static void list_vulkan_device_layers(VkInstance instance, VkPhysicalDevice devi
free(lp); free(lp);
} }
static bool valid_version(void) static int valid_version(void)
{ {
int major, minor, revision; int major, minor, revision;
glfwGetVersion(&major, &minor, &revision); glfwGetVersion(&major, &minor, &revision);
@@ -300,13 +286,13 @@ static bool valid_version(void)
if (major != GLFW_VERSION_MAJOR) if (major != GLFW_VERSION_MAJOR)
{ {
printf("*** ERROR: GLFW major version mismatch! ***\n"); printf("*** ERROR: GLFW major version mismatch! ***\n");
return false; return GLFW_FALSE;
} }
if (minor != GLFW_VERSION_MINOR || revision != GLFW_VERSION_REVISION) if (minor != GLFW_VERSION_MINOR || revision != GLFW_VERSION_REVISION)
printf("*** WARNING: GLFW version mismatch! ***\n"); printf("*** WARNING: GLFW version mismatch! ***\n");
return true; return GLFW_TRUE;
} }
static void print_version(void) static void print_version(void)
@@ -332,42 +318,13 @@ int main(int argc, char** argv)
int ch; int ch;
bool list_extensions = false, list_layers = false; bool list_extensions = false, list_layers = false;
// These duplicate the defaults for each hint
int client_api = GLFW_OPENGL_API;
int context_major = 1;
int context_minor = 0;
int context_release = GLFW_ANY_RELEASE_BEHAVIOR;
int context_creation_api = GLFW_NATIVE_CONTEXT_API;
int context_robustness = GLFW_NO_ROBUSTNESS;
bool context_debug = false;
bool context_no_error = false;
bool opengl_forward = false;
int opengl_profile = GLFW_OPENGL_ANY_PROFILE;
int fb_red_bits = 8;
int fb_green_bits = 8;
int fb_blue_bits = 8;
int fb_alpha_bits = 8;
int fb_depth_bits = 24;
int fb_stencil_bits = 8;
int fb_accum_red_bits = 0;
int fb_accum_green_bits = 0;
int fb_accum_blue_bits = 0;
int fb_accum_alpha_bits = 0;
int fb_aux_buffers = 0;
int fb_samples = 0;
bool fb_stereo = false;
bool fb_srgb = false;
bool fb_doublebuffer = true;
int angle_type = GLFW_ANGLE_PLATFORM_TYPE_NONE;
bool cocoa_graphics_switching = false;
enum { CLIENT, CONTEXT, BEHAVIOR, DEBUG_CONTEXT, FORWARD, HELP, enum { CLIENT, CONTEXT, BEHAVIOR, DEBUG_CONTEXT, FORWARD, HELP,
EXTENSIONS, LAYERS, EXTENSIONS, LAYERS,
MAJOR, MINOR, PROFILE, ROBUSTNESS, VERSION, MAJOR, MINOR, PROFILE, ROBUSTNESS, VERSION,
REDBITS, GREENBITS, BLUEBITS, ALPHABITS, DEPTHBITS, STENCILBITS, REDBITS, GREENBITS, BLUEBITS, ALPHABITS, DEPTHBITS, STENCILBITS,
ACCUMREDBITS, ACCUMGREENBITS, ACCUMBLUEBITS, ACCUMALPHABITS, ACCUMREDBITS, ACCUMGREENBITS, ACCUMBLUEBITS, ACCUMALPHABITS,
AUXBUFFERS, SAMPLES, STEREO, SRGB, SINGLEBUFFER, NOERROR_SRSLY, AUXBUFFERS, SAMPLES, STEREO, SRGB, SINGLEBUFFER, NOERROR_SRSLY,
ANGLE_TYPE, GRAPHICS_SWITCHING }; GRAPHICS_SWITCHING };
const struct option options[] = const struct option options[] =
{ {
{ "behavior", 1, NULL, BEHAVIOR }, { "behavior", 1, NULL, BEHAVIOR },
@@ -399,11 +356,22 @@ int main(int argc, char** argv)
{ "srgb", 0, NULL, SRGB }, { "srgb", 0, NULL, SRGB },
{ "singlebuffer", 0, NULL, SINGLEBUFFER }, { "singlebuffer", 0, NULL, SINGLEBUFFER },
{ "no-error", 0, NULL, NOERROR_SRSLY }, { "no-error", 0, NULL, NOERROR_SRSLY },
{ "angle-type", 1, NULL, ANGLE_TYPE },
{ "graphics-switching", 0, NULL, GRAPHICS_SWITCHING }, { "graphics-switching", 0, NULL, GRAPHICS_SWITCHING },
{ NULL, 0, NULL, 0 } { NULL, 0, NULL, 0 }
}; };
// Initialize GLFW and create window
if (!valid_version())
exit(EXIT_FAILURE);
glfwSetErrorCallback(error_callback);
glfwInitHint(GLFW_COCOA_MENUBAR, GLFW_FALSE);
if (!glfwInit())
exit(EXIT_FAILURE);
while ((ch = getopt_long(argc, argv, "a:b:c:dfhlm:n:p:s:v", options, NULL)) != -1) while ((ch = getopt_long(argc, argv, "a:b:c:dfhlm:n:p:s:v", options, NULL)) != -1)
{ {
switch (ch) switch (ch)
@@ -411,9 +379,9 @@ int main(int argc, char** argv)
case 'a': case 'a':
case CLIENT: case CLIENT:
if (strcasecmp(optarg, API_NAME_OPENGL) == 0) if (strcasecmp(optarg, API_NAME_OPENGL) == 0)
client_api = GLFW_OPENGL_API; glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_API);
else if (strcasecmp(optarg, API_NAME_OPENGL_ES) == 0) else if (strcasecmp(optarg, API_NAME_OPENGL_ES) == 0)
client_api = GLFW_OPENGL_ES_API; glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_ES_API);
else else
{ {
usage(); usage();
@@ -423,9 +391,15 @@ int main(int argc, char** argv)
case 'b': case 'b':
case BEHAVIOR: case BEHAVIOR:
if (strcasecmp(optarg, BEHAVIOR_NAME_NONE) == 0) if (strcasecmp(optarg, BEHAVIOR_NAME_NONE) == 0)
context_release = GLFW_RELEASE_BEHAVIOR_NONE; {
glfwWindowHint(GLFW_CONTEXT_RELEASE_BEHAVIOR,
GLFW_RELEASE_BEHAVIOR_NONE);
}
else if (strcasecmp(optarg, BEHAVIOR_NAME_FLUSH) == 0) else if (strcasecmp(optarg, BEHAVIOR_NAME_FLUSH) == 0)
context_release = GLFW_RELEASE_BEHAVIOR_FLUSH; {
glfwWindowHint(GLFW_CONTEXT_RELEASE_BEHAVIOR,
GLFW_RELEASE_BEHAVIOR_FLUSH);
}
else else
{ {
usage(); usage();
@@ -435,11 +409,11 @@ int main(int argc, char** argv)
case 'c': case 'c':
case CONTEXT: case CONTEXT:
if (strcasecmp(optarg, API_NAME_NATIVE) == 0) if (strcasecmp(optarg, API_NAME_NATIVE) == 0)
context_creation_api = GLFW_NATIVE_CONTEXT_API; glfwWindowHint(GLFW_CONTEXT_CREATION_API, GLFW_NATIVE_CONTEXT_API);
else if (strcasecmp(optarg, API_NAME_EGL) == 0) else if (strcasecmp(optarg, API_NAME_EGL) == 0)
context_creation_api = GLFW_EGL_CONTEXT_API; glfwWindowHint(GLFW_CONTEXT_CREATION_API, GLFW_EGL_CONTEXT_API);
else if (strcasecmp(optarg, API_NAME_OSMESA) == 0) else if (strcasecmp(optarg, API_NAME_OSMESA) == 0)
context_creation_api = GLFW_OSMESA_CONTEXT_API; glfwWindowHint(GLFW_CONTEXT_CREATION_API, GLFW_OSMESA_CONTEXT_API);
else else
{ {
usage(); usage();
@@ -448,11 +422,11 @@ int main(int argc, char** argv)
break; break;
case 'd': case 'd':
case DEBUG_CONTEXT: case DEBUG_CONTEXT:
context_debug = true; glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GLFW_TRUE);
break; break;
case 'f': case 'f':
case FORWARD: case FORWARD:
opengl_forward = true; glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GLFW_TRUE);
break; break;
case 'h': case 'h':
case HELP: case HELP:
@@ -460,25 +434,31 @@ int main(int argc, char** argv)
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
case 'l': case 'l':
case EXTENSIONS: case EXTENSIONS:
list_extensions = true; list_extensions = GLFW_TRUE;
break; break;
case LAYERS: case LAYERS:
list_layers = true; list_layers = GLFW_TRUE;
break; break;
case 'm': case 'm':
case MAJOR: case MAJOR:
context_major = atoi(optarg); glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, atoi(optarg));
break; break;
case 'n': case 'n':
case MINOR: case MINOR:
context_minor = atoi(optarg); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, atoi(optarg));
break; break;
case 'p': case 'p':
case PROFILE: case PROFILE:
if (strcasecmp(optarg, PROFILE_NAME_CORE) == 0) if (strcasecmp(optarg, PROFILE_NAME_CORE) == 0)
opengl_profile = GLFW_OPENGL_CORE_PROFILE; {
glfwWindowHint(GLFW_OPENGL_PROFILE,
GLFW_OPENGL_CORE_PROFILE);
}
else if (strcasecmp(optarg, PROFILE_NAME_COMPAT) == 0) else if (strcasecmp(optarg, PROFILE_NAME_COMPAT) == 0)
opengl_profile = GLFW_OPENGL_COMPAT_PROFILE; {
glfwWindowHint(GLFW_OPENGL_PROFILE,
GLFW_OPENGL_COMPAT_PROFILE);
}
else else
{ {
usage(); usage();
@@ -488,9 +468,15 @@ int main(int argc, char** argv)
case 's': case 's':
case ROBUSTNESS: case ROBUSTNESS:
if (strcasecmp(optarg, STRATEGY_NAME_NONE) == 0) if (strcasecmp(optarg, STRATEGY_NAME_NONE) == 0)
context_robustness = GLFW_NO_RESET_NOTIFICATION; {
glfwWindowHint(GLFW_CONTEXT_ROBUSTNESS,
GLFW_NO_RESET_NOTIFICATION);
}
else if (strcasecmp(optarg, STRATEGY_NAME_LOSE) == 0) else if (strcasecmp(optarg, STRATEGY_NAME_LOSE) == 0)
context_robustness = GLFW_LOSE_CONTEXT_ON_RESET; {
glfwWindowHint(GLFW_CONTEXT_ROBUSTNESS,
GLFW_LOSE_CONTEXT_ON_RESET);
}
else else
{ {
usage(); usage();
@@ -503,109 +489,90 @@ int main(int argc, char** argv)
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
case REDBITS: case REDBITS:
if (strcmp(optarg, "-") == 0) if (strcmp(optarg, "-") == 0)
fb_red_bits = GLFW_DONT_CARE; glfwWindowHint(GLFW_RED_BITS, GLFW_DONT_CARE);
else else
fb_red_bits = atoi(optarg); glfwWindowHint(GLFW_RED_BITS, atoi(optarg));
break; break;
case GREENBITS: case GREENBITS:
if (strcmp(optarg, "-") == 0) if (strcmp(optarg, "-") == 0)
fb_green_bits = GLFW_DONT_CARE; glfwWindowHint(GLFW_GREEN_BITS, GLFW_DONT_CARE);
else else
fb_green_bits = atoi(optarg); glfwWindowHint(GLFW_GREEN_BITS, atoi(optarg));
break; break;
case BLUEBITS: case BLUEBITS:
if (strcmp(optarg, "-") == 0) if (strcmp(optarg, "-") == 0)
fb_blue_bits = GLFW_DONT_CARE; glfwWindowHint(GLFW_BLUE_BITS, GLFW_DONT_CARE);
else else
fb_blue_bits = atoi(optarg); glfwWindowHint(GLFW_BLUE_BITS, atoi(optarg));
break; break;
case ALPHABITS: case ALPHABITS:
if (strcmp(optarg, "-") == 0) if (strcmp(optarg, "-") == 0)
fb_alpha_bits = GLFW_DONT_CARE; glfwWindowHint(GLFW_ALPHA_BITS, GLFW_DONT_CARE);
else else
fb_alpha_bits = atoi(optarg); glfwWindowHint(GLFW_ALPHA_BITS, atoi(optarg));
break; break;
case DEPTHBITS: case DEPTHBITS:
if (strcmp(optarg, "-") == 0) if (strcmp(optarg, "-") == 0)
fb_depth_bits = GLFW_DONT_CARE; glfwWindowHint(GLFW_DEPTH_BITS, GLFW_DONT_CARE);
else else
fb_depth_bits = atoi(optarg); glfwWindowHint(GLFW_DEPTH_BITS, atoi(optarg));
break; break;
case STENCILBITS: case STENCILBITS:
if (strcmp(optarg, "-") == 0) if (strcmp(optarg, "-") == 0)
fb_stencil_bits = GLFW_DONT_CARE; glfwWindowHint(GLFW_STENCIL_BITS, GLFW_DONT_CARE);
else else
fb_stencil_bits = atoi(optarg); glfwWindowHint(GLFW_STENCIL_BITS, atoi(optarg));
break; break;
case ACCUMREDBITS: case ACCUMREDBITS:
if (strcmp(optarg, "-") == 0) if (strcmp(optarg, "-") == 0)
fb_accum_red_bits = GLFW_DONT_CARE; glfwWindowHint(GLFW_ACCUM_RED_BITS, GLFW_DONT_CARE);
else else
fb_accum_red_bits = atoi(optarg); glfwWindowHint(GLFW_ACCUM_RED_BITS, atoi(optarg));
break; break;
case ACCUMGREENBITS: case ACCUMGREENBITS:
if (strcmp(optarg, "-") == 0) if (strcmp(optarg, "-") == 0)
fb_accum_green_bits = GLFW_DONT_CARE; glfwWindowHint(GLFW_ACCUM_GREEN_BITS, GLFW_DONT_CARE);
else else
fb_accum_green_bits = atoi(optarg); glfwWindowHint(GLFW_ACCUM_GREEN_BITS, atoi(optarg));
break; break;
case ACCUMBLUEBITS: case ACCUMBLUEBITS:
if (strcmp(optarg, "-") == 0) if (strcmp(optarg, "-") == 0)
fb_accum_blue_bits = GLFW_DONT_CARE; glfwWindowHint(GLFW_ACCUM_BLUE_BITS, GLFW_DONT_CARE);
else else
fb_accum_blue_bits = atoi(optarg); glfwWindowHint(GLFW_ACCUM_BLUE_BITS, atoi(optarg));
break; break;
case ACCUMALPHABITS: case ACCUMALPHABITS:
if (strcmp(optarg, "-") == 0) if (strcmp(optarg, "-") == 0)
fb_accum_alpha_bits = GLFW_DONT_CARE; glfwWindowHint(GLFW_ACCUM_ALPHA_BITS, GLFW_DONT_CARE);
else else
fb_accum_alpha_bits = atoi(optarg); glfwWindowHint(GLFW_ACCUM_ALPHA_BITS, atoi(optarg));
break; break;
case AUXBUFFERS: case AUXBUFFERS:
if (strcmp(optarg, "-") == 0) if (strcmp(optarg, "-") == 0)
fb_aux_buffers = GLFW_DONT_CARE; glfwWindowHint(GLFW_AUX_BUFFERS, GLFW_DONT_CARE);
else else
fb_aux_buffers = atoi(optarg); glfwWindowHint(GLFW_AUX_BUFFERS, atoi(optarg));
break; break;
case SAMPLES: case SAMPLES:
if (strcmp(optarg, "-") == 0) if (strcmp(optarg, "-") == 0)
fb_samples = GLFW_DONT_CARE; glfwWindowHint(GLFW_SAMPLES, GLFW_DONT_CARE);
else else
fb_samples = atoi(optarg); glfwWindowHint(GLFW_SAMPLES, atoi(optarg));
break; break;
case STEREO: case STEREO:
fb_stereo = true; glfwWindowHint(GLFW_STEREO, GLFW_TRUE);
break; break;
case SRGB: case SRGB:
fb_srgb = true; glfwWindowHint(GLFW_SRGB_CAPABLE, GLFW_TRUE);
break; break;
case SINGLEBUFFER: case SINGLEBUFFER:
fb_doublebuffer = false; glfwWindowHint(GLFW_DOUBLEBUFFER, GLFW_FALSE);
break; break;
case NOERROR_SRSLY: case NOERROR_SRSLY:
context_no_error = true; glfwWindowHint(GLFW_CONTEXT_NO_ERROR, GLFW_TRUE);
break;
case ANGLE_TYPE:
if (strcmp(optarg, ANGLE_TYPE_OPENGL) == 0)
angle_type = GLFW_ANGLE_PLATFORM_TYPE_OPENGL;
else if (strcmp(optarg, ANGLE_TYPE_OPENGLES) == 0)
angle_type = GLFW_ANGLE_PLATFORM_TYPE_OPENGLES;
else if (strcmp(optarg, ANGLE_TYPE_D3D9) == 0)
angle_type = GLFW_ANGLE_PLATFORM_TYPE_D3D9;
else if (strcmp(optarg, ANGLE_TYPE_D3D11) == 0)
angle_type = GLFW_ANGLE_PLATFORM_TYPE_D3D11;
else if (strcmp(optarg, ANGLE_TYPE_VULKAN) == 0)
angle_type = GLFW_ANGLE_PLATFORM_TYPE_VULKAN;
else if (strcmp(optarg, ANGLE_TYPE_METAL) == 0)
angle_type = GLFW_ANGLE_PLATFORM_TYPE_METAL;
else
{
usage();
exit(EXIT_FAILURE);
}
break; break;
case GRAPHICS_SWITCHING: case GRAPHICS_SWITCHING:
cocoa_graphics_switching = true; glfwWindowHint(GLFW_COCOA_GRAPHICS_SWITCHING, GLFW_TRUE);
break; break;
default: default:
usage(); usage();
@@ -613,52 +580,9 @@ int main(int argc, char** argv)
} }
} }
// Initialize GLFW and create window
if (!valid_version())
exit(EXIT_FAILURE);
glfwSetErrorCallback(error_callback);
glfwInitHint(GLFW_COCOA_MENUBAR, false);
glfwInitHint(GLFW_ANGLE_PLATFORM_TYPE, angle_type);
if (!glfwInit())
exit(EXIT_FAILURE);
print_version(); print_version();
glfwWindowHint(GLFW_VISIBLE, false); glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE);
glfwWindowHint(GLFW_CLIENT_API, client_api);
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, context_major);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, context_minor);
glfwWindowHint(GLFW_CONTEXT_RELEASE_BEHAVIOR, context_release);
glfwWindowHint(GLFW_CONTEXT_CREATION_API, context_creation_api);
glfwWindowHint(GLFW_CONTEXT_ROBUSTNESS, context_robustness);
glfwWindowHint(GLFW_CONTEXT_DEBUG, context_debug);
glfwWindowHint(GLFW_CONTEXT_NO_ERROR, context_no_error);
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, opengl_forward);
glfwWindowHint(GLFW_OPENGL_PROFILE, opengl_profile);
glfwWindowHint(GLFW_RED_BITS, fb_red_bits);
glfwWindowHint(GLFW_BLUE_BITS, fb_blue_bits);
glfwWindowHint(GLFW_GREEN_BITS, fb_green_bits);
glfwWindowHint(GLFW_ALPHA_BITS, fb_alpha_bits);
glfwWindowHint(GLFW_DEPTH_BITS, fb_depth_bits);
glfwWindowHint(GLFW_STENCIL_BITS, fb_stencil_bits);
glfwWindowHint(GLFW_ACCUM_RED_BITS, fb_accum_red_bits);
glfwWindowHint(GLFW_ACCUM_GREEN_BITS, fb_accum_green_bits);
glfwWindowHint(GLFW_ACCUM_BLUE_BITS, fb_accum_blue_bits);
glfwWindowHint(GLFW_ACCUM_ALPHA_BITS, fb_accum_alpha_bits);
glfwWindowHint(GLFW_AUX_BUFFERS, fb_aux_buffers);
glfwWindowHint(GLFW_SAMPLES, fb_samples);
glfwWindowHint(GLFW_STEREO, fb_stereo);
glfwWindowHint(GLFW_SRGB_CAPABLE, fb_srgb);
glfwWindowHint(GLFW_DOUBLEBUFFER, fb_doublebuffer);
glfwWindowHint(GLFW_COCOA_GRAPHICS_SWITCHING, cocoa_graphics_switching);
GLFWwindow* window = glfwCreateWindow(200, 200, "Version", NULL, NULL); GLFWwindow* window = glfwCreateWindow(200, 200, "Version", NULL, NULL);
if (!window) if (!window)
@@ -715,7 +639,7 @@ int main(int argc, char** argv)
if (glfwGetWindowAttrib(window, GLFW_OPENGL_FORWARD_COMPAT)) if (glfwGetWindowAttrib(window, GLFW_OPENGL_FORWARD_COMPAT))
printf(" forward-compatible"); printf(" forward-compatible");
if (glfwGetWindowAttrib(window, GLFW_CONTEXT_DEBUG)) if (glfwGetWindowAttrib(window, GLFW_OPENGL_DEBUG_CONTEXT))
printf(" debug"); printf(" debug");
if (glfwGetWindowAttrib(window, GLFW_CONTEXT_ROBUSTNESS) == GLFW_LOSE_CONTEXT_ON_RESET) if (glfwGetWindowAttrib(window, GLFW_CONTEXT_ROBUSTNESS) == GLFW_LOSE_CONTEXT_ON_RESET)
printf(" robustness"); printf(" robustness");
+109
View File
@@ -0,0 +1,109 @@
//========================================================================
// Window opacity test program
// Copyright (c) Camilla Löwy <elmindreda@glfw.org>
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// 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 <glad/gl.h>
#define GLFW_INCLUDE_NONE
#include <GLFW/glfw3.h>
#define NK_IMPLEMENTATION
#define NK_INCLUDE_FIXED_TYPES
#define NK_INCLUDE_FONT_BAKING
#define NK_INCLUDE_DEFAULT_FONT
#define NK_INCLUDE_DEFAULT_ALLOCATOR
#define NK_INCLUDE_VERTEX_BUFFER_OUTPUT
#define NK_INCLUDE_STANDARD_VARARGS
#include <nuklear.h>
#define NK_GLFW_GL2_IMPLEMENTATION
#include <nuklear_glfw_gl2.h>
#include <stdio.h>
#include <stdlib.h>
static void error_callback(int error, const char* description)
{
fprintf(stderr, "Error: %s\n", description);
}
int main(int argc, char** argv)
{
GLFWwindow* window;
struct nk_context* nk;
struct nk_font_atlas* atlas;
glfwSetErrorCallback(error_callback);
if (!glfwInit())
exit(EXIT_FAILURE);
glfwWindowHint(GLFW_SCALE_TO_MONITOR, GLFW_TRUE);
glfwWindowHint(GLFW_WIN32_KEYBOARD_MENU, GLFW_TRUE);
window = glfwCreateWindow(400, 400, "Opacity", NULL, NULL);
if (!window)
{
glfwTerminate();
exit(EXIT_FAILURE);
}
glfwMakeContextCurrent(window);
gladLoadGL(glfwGetProcAddress);
glfwSwapInterval(1);
nk = nk_glfw3_init(window, NK_GLFW3_INSTALL_CALLBACKS);
nk_glfw3_font_stash_begin(&atlas);
nk_glfw3_font_stash_end();
while (!glfwWindowShouldClose(window))
{
int width, height;
struct nk_rect area;
glfwGetWindowSize(window, &width, &height);
area = nk_rect(0.f, 0.f, (float) width, (float) height);
glClear(GL_COLOR_BUFFER_BIT);
nk_glfw3_new_frame();
if (nk_begin(nk, "", area, 0))
{
float opacity = glfwGetWindowOpacity(window);
nk_layout_row_dynamic(nk, 30, 2);
if (nk_slider_float(nk, 0.f, &opacity, 1.f, 0.001f))
glfwSetWindowOpacity(window, opacity);
nk_labelf(nk, NK_TEXT_LEFT, "%0.3f", opacity);
}
nk_end(nk);
nk_glfw3_render(NK_ANTI_ALIASING_ON);
glfwSwapBuffers(window);
glfwWaitEventsTimeout(1.0);
}
nk_glfw3_shutdown();
glfwTerminate();
exit(EXIT_SUCCESS);
}
+142 -46
View File
@@ -70,54 +70,150 @@ static GLADapiproc glad_vulkan_callback(const char* name, void* user)
return glfwGetInstanceProcAddress((VkInstance) user, name); return glfwGetInstanceProcAddress((VkInstance) user, name);
} }
static const uint32_t fragShaderCode[] = { static const char fragShaderCode[] = {
0x07230203,0x00010000,0x00080007,0x00000014,0x00000000,0x00020011,0x00000001,0x0006000b, 0x03, 0x02, 0x23, 0x07, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x08, 0x00,
0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x02, 0x00,
0x0007000f,0x00000004,0x00000004,0x6e69616d,0x00000000,0x00000009,0x00000011,0x00030010, 0x01, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x06, 0x00, 0x01, 0x00, 0x00, 0x00,
0x00000004,0x00000007,0x00030003,0x00000002,0x00000190,0x00090004,0x415f4c47,0x735f4252, 0x47, 0x4c, 0x53, 0x4c, 0x2e, 0x73, 0x74, 0x64, 0x2e, 0x34, 0x35, 0x30,
0x72617065,0x5f657461,0x64616873,0x6f5f7265,0x63656a62,0x00007374,0x00090004,0x415f4c47, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00,
0x735f4252,0x69646168,0x6c5f676e,0x75676e61,0x5f656761,0x70303234,0x006b6361,0x00040005, 0x01, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x07, 0x00, 0x04, 0x00, 0x00, 0x00,
0x00000004,0x6e69616d,0x00000000,0x00050005,0x00000009,0x61724675,0x6c6f4367,0x0000726f, 0x04, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00,
0x00030005,0x0000000d,0x00786574,0x00050005,0x00000011,0x63786574,0x64726f6f,0x00000000, 0x09, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x10, 0x00, 0x03, 0x00,
0x00040047,0x00000009,0x0000001e,0x00000000,0x00040047,0x0000000d,0x00000022,0x00000000, 0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00,
0x00040047,0x0000000d,0x00000021,0x00000000,0x00040047,0x00000011,0x0000001e,0x00000000, 0x02, 0x00, 0x00, 0x00, 0x90, 0x01, 0x00, 0x00, 0x04, 0x00, 0x09, 0x00,
0x00020013,0x00000002,0x00030021,0x00000003,0x00000002,0x00030016,0x00000006,0x00000020, 0x47, 0x4c, 0x5f, 0x41, 0x52, 0x42, 0x5f, 0x73, 0x65, 0x70, 0x61, 0x72,
0x00040017,0x00000007,0x00000006,0x00000004,0x00040020,0x00000008,0x00000003,0x00000007, 0x61, 0x74, 0x65, 0x5f, 0x73, 0x68, 0x61, 0x64, 0x65, 0x72, 0x5f, 0x6f,
0x0004003b,0x00000008,0x00000009,0x00000003,0x00090019,0x0000000a,0x00000006,0x00000001, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x00, 0x00, 0x04, 0x00, 0x09, 0x00,
0x00000000,0x00000000,0x00000000,0x00000001,0x00000000,0x0003001b,0x0000000b,0x0000000a, 0x47, 0x4c, 0x5f, 0x41, 0x52, 0x42, 0x5f, 0x73, 0x68, 0x61, 0x64, 0x69,
0x00040020,0x0000000c,0x00000000,0x0000000b,0x0004003b,0x0000000c,0x0000000d,0x00000000, 0x6e, 0x67, 0x5f, 0x6c, 0x61, 0x6e, 0x67, 0x75, 0x61, 0x67, 0x65, 0x5f,
0x00040017,0x0000000f,0x00000006,0x00000002,0x00040020,0x00000010,0x00000001,0x0000000f, 0x34, 0x32, 0x30, 0x70, 0x61, 0x63, 0x6b, 0x00, 0x05, 0x00, 0x04, 0x00,
0x0004003b,0x00000010,0x00000011,0x00000001,0x00050036,0x00000002,0x00000004,0x00000000, 0x04, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00,
0x00000003,0x000200f8,0x00000005,0x0004003d,0x0000000b,0x0000000e,0x0000000d,0x0004003d, 0x05, 0x00, 0x05, 0x00, 0x09, 0x00, 0x00, 0x00, 0x75, 0x46, 0x72, 0x61,
0x0000000f,0x00000012,0x00000011,0x00050057,0x00000007,0x00000013,0x0000000e,0x00000012, 0x67, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00,
0x0003003e,0x00000009,0x00000013,0x000100fd,0x00010038 0x0d, 0x00, 0x00, 0x00, 0x74, 0x65, 0x78, 0x00, 0x05, 0x00, 0x05, 0x00,
0x11, 0x00, 0x00, 0x00, 0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64,
0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x09, 0x00, 0x00, 0x00,
0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00,
0x0d, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x47, 0x00, 0x04, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x11, 0x00, 0x00, 0x00,
0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x02, 0x00,
0x02, 0x00, 0x00, 0x00, 0x21, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x00,
0x02, 0x00, 0x00, 0x00, 0x16, 0x00, 0x03, 0x00, 0x06, 0x00, 0x00, 0x00,
0x20, 0x00, 0x00, 0x00, 0x17, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00,
0x06, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00,
0x08, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
0x3b, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00,
0x03, 0x00, 0x00, 0x00, 0x19, 0x00, 0x09, 0x00, 0x0a, 0x00, 0x00, 0x00,
0x06, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x1b, 0x00, 0x03, 0x00, 0x0b, 0x00, 0x00, 0x00,
0x0a, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00,
0x0c, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x17, 0x00, 0x04, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
0x02, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x10, 0x00, 0x00, 0x00,
0x01, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00,
0x10, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0x36, 0x00, 0x05, 0x00, 0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00,
0x05, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x0b, 0x00, 0x00, 0x00,
0x0e, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00,
0x0f, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00,
0x57, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00,
0x0e, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00,
0x09, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0xfd, 0x00, 0x01, 0x00,
0x38, 0x00, 0x01, 0x00
}; };
static const uint32_t vertShaderCode[] = { static const char vertShaderCode[] = {
0x07230203,0x00010000,0x00080007,0x00000018,0x00000000,0x00020011,0x00000001,0x0006000b, 0x03, 0x02, 0x23, 0x07, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x08, 0x00,
0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x02, 0x00,
0x0009000f,0x00000000,0x00000004,0x6e69616d,0x00000000,0x00000009,0x0000000b,0x00000010, 0x01, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x06, 0x00, 0x01, 0x00, 0x00, 0x00,
0x00000014,0x00030003,0x00000002,0x00000190,0x00090004,0x415f4c47,0x735f4252,0x72617065, 0x47, 0x4c, 0x53, 0x4c, 0x2e, 0x73, 0x74, 0x64, 0x2e, 0x34, 0x35, 0x30,
0x5f657461,0x64616873,0x6f5f7265,0x63656a62,0x00007374,0x00090004,0x415f4c47,0x735f4252, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00,
0x69646168,0x6c5f676e,0x75676e61,0x5f656761,0x70303234,0x006b6361,0x00040005,0x00000004, 0x01, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00,
0x6e69616d,0x00000000,0x00050005,0x00000009,0x63786574,0x64726f6f,0x00000000,0x00040005, 0x04, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00,
0x0000000b,0x72747461,0x00000000,0x00060005,0x0000000e,0x505f6c67,0x65567265,0x78657472, 0x09, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00,
0x00000000,0x00060006,0x0000000e,0x00000000,0x505f6c67,0x7469736f,0x006e6f69,0x00030005, 0x17, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00,
0x00000010,0x00000000,0x00030005,0x00000014,0x00736f70,0x00040047,0x00000009,0x0000001e, 0x03, 0x00, 0x03, 0x00, 0x02, 0x00, 0x00, 0x00, 0x90, 0x01, 0x00, 0x00,
0x00000000,0x00040047,0x0000000b,0x0000001e,0x00000001,0x00050048,0x0000000e,0x00000000, 0x04, 0x00, 0x09, 0x00, 0x47, 0x4c, 0x5f, 0x41, 0x52, 0x42, 0x5f, 0x73,
0x0000000b,0x00000000,0x00030047,0x0000000e,0x00000002,0x00040047,0x00000014,0x0000001e, 0x65, 0x70, 0x61, 0x72, 0x61, 0x74, 0x65, 0x5f, 0x73, 0x68, 0x61, 0x64,
0x00000000,0x00020013,0x00000002,0x00030021,0x00000003,0x00000002,0x00030016,0x00000006, 0x65, 0x72, 0x5f, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x00, 0x00,
0x00000020,0x00040017,0x00000007,0x00000006,0x00000002,0x00040020,0x00000008,0x00000003, 0x04, 0x00, 0x09, 0x00, 0x47, 0x4c, 0x5f, 0x41, 0x52, 0x42, 0x5f, 0x73,
0x00000007,0x0004003b,0x00000008,0x00000009,0x00000003,0x00040020,0x0000000a,0x00000001, 0x68, 0x61, 0x64, 0x69, 0x6e, 0x67, 0x5f, 0x6c, 0x61, 0x6e, 0x67, 0x75,
0x00000007,0x0004003b,0x0000000a,0x0000000b,0x00000001,0x00040017,0x0000000d,0x00000006, 0x61, 0x67, 0x65, 0x5f, 0x34, 0x32, 0x30, 0x70, 0x61, 0x63, 0x6b, 0x00,
0x00000004,0x0003001e,0x0000000e,0x0000000d,0x00040020,0x0000000f,0x00000003,0x0000000e, 0x05, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e,
0x0004003b,0x0000000f,0x00000010,0x00000003,0x00040015,0x00000011,0x00000020,0x00000001, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x05, 0x00, 0x09, 0x00, 0x00, 0x00,
0x0004002b,0x00000011,0x00000012,0x00000000,0x00040020,0x00000013,0x00000001,0x0000000d, 0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x00, 0x00, 0x00, 0x00,
0x0004003b,0x00000013,0x00000014,0x00000001,0x00040020,0x00000016,0x00000003,0x0000000d, 0x05, 0x00, 0x04, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x61, 0x74, 0x74, 0x72,
0x00050036,0x00000002,0x00000004,0x00000000,0x00000003,0x000200f8,0x00000005,0x0004003d, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x06, 0x00, 0x11, 0x00, 0x00, 0x00,
0x00000007,0x0000000c,0x0000000b,0x0003003e,0x00000009,0x0000000c,0x0004003d,0x0000000d, 0x67, 0x6c, 0x5f, 0x50, 0x65, 0x72, 0x56, 0x65, 0x72, 0x74, 0x65, 0x78,
0x00000015,0x00000014,0x00050041,0x00000016,0x00000017,0x00000010,0x00000012,0x0003003e, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x06, 0x00, 0x11, 0x00, 0x00, 0x00,
0x00000017,0x00000015,0x000100fd,0x00010038 0x00, 0x00, 0x00, 0x00, 0x67, 0x6c, 0x5f, 0x50, 0x6f, 0x73, 0x69, 0x74,
0x69, 0x6f, 0x6e, 0x00, 0x06, 0x00, 0x07, 0x00, 0x11, 0x00, 0x00, 0x00,
0x01, 0x00, 0x00, 0x00, 0x67, 0x6c, 0x5f, 0x50, 0x6f, 0x69, 0x6e, 0x74,
0x53, 0x69, 0x7a, 0x65, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x07, 0x00,
0x11, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x67, 0x6c, 0x5f, 0x43,
0x6c, 0x69, 0x70, 0x44, 0x69, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x00,
0x05, 0x00, 0x03, 0x00, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x03, 0x00, 0x17, 0x00, 0x00, 0x00, 0x70, 0x6f, 0x73, 0x00,
0x05, 0x00, 0x05, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x67, 0x6c, 0x5f, 0x56,
0x65, 0x72, 0x74, 0x65, 0x78, 0x49, 0x44, 0x00, 0x05, 0x00, 0x06, 0x00,
0x1d, 0x00, 0x00, 0x00, 0x67, 0x6c, 0x5f, 0x49, 0x6e, 0x73, 0x74, 0x61,
0x6e, 0x63, 0x65, 0x49, 0x44, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00,
0x09, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x47, 0x00, 0x04, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00,
0x01, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x11, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x48, 0x00, 0x05, 0x00, 0x11, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0x0b, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00,
0x11, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00,
0x03, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, 0x11, 0x00, 0x00, 0x00,
0x02, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x17, 0x00, 0x00, 0x00,
0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00,
0x1c, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
0x47, 0x00, 0x04, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00,
0x06, 0x00, 0x00, 0x00, 0x13, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00, 0x00,
0x21, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
0x16, 0x00, 0x03, 0x00, 0x06, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
0x17, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
0x02, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00,
0x03, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00,
0x08, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
0x20, 0x00, 0x04, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x0a, 0x00, 0x00, 0x00,
0x0b, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x17, 0x00, 0x04, 0x00,
0x0d, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
0x15, 0x00, 0x04, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x0e, 0x00, 0x00, 0x00,
0x0f, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x04, 0x00,
0x10, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00,
0x1e, 0x00, 0x05, 0x00, 0x11, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00,
0x06, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00,
0x12, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00,
0x3b, 0x00, 0x04, 0x00, 0x12, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00,
0x03, 0x00, 0x00, 0x00, 0x15, 0x00, 0x04, 0x00, 0x14, 0x00, 0x00, 0x00,
0x20, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00,
0x14, 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x20, 0x00, 0x04, 0x00, 0x16, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0x0d, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x16, 0x00, 0x00, 0x00,
0x17, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00,
0x19, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00,
0x20, 0x00, 0x04, 0x00, 0x1b, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0x14, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x1b, 0x00, 0x00, 0x00,
0x1c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00,
0x1b, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0x36, 0x00, 0x05, 0x00, 0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00,
0x05, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00,
0x0c, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00,
0x09, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00,
0x0d, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00,
0x41, 0x00, 0x05, 0x00, 0x19, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x00, 0x00,
0x13, 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00,
0x1a, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0xfd, 0x00, 0x01, 0x00,
0x38, 0x00, 0x01, 0x00
}; };
struct texture_object { struct texture_object {
-417
View File
@@ -1,417 +0,0 @@
//========================================================================
// Window properties test
// Copyright (c) Camilla Löwy <elmindreda@glfw.org>
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// 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 <glad/gl.h>
#define GLFW_INCLUDE_NONE
#include <GLFW/glfw3.h>
#include <stdarg.h>
#define NK_IMPLEMENTATION
#define NK_INCLUDE_FIXED_TYPES
#define NK_INCLUDE_FONT_BAKING
#define NK_INCLUDE_DEFAULT_FONT
#define NK_INCLUDE_DEFAULT_ALLOCATOR
#define NK_INCLUDE_VERTEX_BUFFER_OUTPUT
#define NK_INCLUDE_STANDARD_VARARGS
#define NK_BUTTON_TRIGGER_ON_RELEASE
#include <nuklear.h>
#define NK_GLFW_GL2_IMPLEMENTATION
#include <nuklear_glfw_gl2.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
int main(int argc, char** argv)
{
int windowed_x, windowed_y, windowed_width, windowed_height;
int last_xpos = INT_MIN, last_ypos = INT_MIN;
int last_width = INT_MIN, last_height = INT_MIN;
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] = "";
int may_close = true;
if (!glfwInit())
exit(EXIT_FAILURE);
glfwWindowHint(GLFW_SCALE_TO_MONITOR, GLFW_TRUE);
glfwWindowHint(GLFW_WIN32_KEYBOARD_MENU, GLFW_TRUE);
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1);
GLFWwindow* window = glfwCreateWindow(600, 600, "Window Features", NULL, NULL);
if (!window)
{
glfwTerminate();
exit(EXIT_FAILURE);
}
glfwMakeContextCurrent(window);
gladLoadGL(glfwGetProcAddress);
glfwSwapInterval(0);
bool position_supported = true;
glfwGetError(NULL);
glfwGetWindowPos(window, &last_xpos, &last_ypos);
sprintf(xpos_buffer, "%i", last_xpos);
sprintf(ypos_buffer, "%i", last_ypos);
if (glfwGetError(NULL) == GLFW_FEATURE_UNAVAILABLE)
position_supported = false;
glfwGetWindowSize(window, &last_width, &last_height);
sprintf(width_buffer, "%i", last_width);
sprintf(height_buffer, "%i", last_height);
sprintf(numer_buffer, "%i", aspect_numer);
sprintf(denom_buffer, "%i", aspect_denom);
sprintf(min_width_buffer, "%i", min_width);
sprintf(min_height_buffer, "%i", min_height);
sprintf(max_width_buffer, "%i", max_width);
sprintf(max_height_buffer, "%i", max_height);
struct nk_context* nk = nk_glfw3_init(window, NK_GLFW3_INSTALL_CALLBACKS);
struct nk_font_atlas* atlas;
nk_glfw3_font_stash_begin(&atlas);
nk_glfw3_font_stash_end();
while (!(may_close && glfwWindowShouldClose(window)))
{
int width, height;
glfwGetWindowSize(window, &width, &height);
struct nk_rect area = nk_rect(0.f, 0.f, (float) width, (float) height);
nk_window_set_bounds(nk, "main", area);
nk_glfw3_new_frame();
if (nk_begin(nk, "main", area, 0))
{
nk_layout_row_dynamic(nk, 30, 4);
if (nk_button_label(nk, "Toggle Fullscreen"))
{
if (glfwGetWindowMonitor(window))
{
glfwSetWindowMonitor(window, NULL,
windowed_x, windowed_y,
windowed_width, windowed_height, 0);
}
else
{
GLFWmonitor* monitor = glfwGetPrimaryMonitor();
const GLFWvidmode* mode = glfwGetVideoMode(monitor);
glfwGetWindowPos(window, &windowed_x, &windowed_y);
glfwGetWindowSize(window, &windowed_width, &windowed_height);
glfwSetWindowMonitor(window, monitor,
0, 0, mode->width, mode->height,
mode->refreshRate);
}
}
if (nk_button_label(nk, "Maximize"))
glfwMaximizeWindow(window);
if (nk_button_label(nk, "Iconify"))
glfwIconifyWindow(window);
if (nk_button_label(nk, "Restore"))
glfwRestoreWindow(window);
nk_layout_row_dynamic(nk, 30, 1);
if (glfwGetWindowAttrib(window, GLFW_MOUSE_PASSTHROUGH))
{
nk_label(nk, "Press H to disable mouse passthrough", NK_TEXT_CENTERED);
if (glfwGetKey(window, GLFW_KEY_H))
glfwSetWindowAttrib(window, GLFW_MOUSE_PASSTHROUGH, false);
}
nk_label(nk, "Press Enter in a text field to set value", NK_TEXT_CENTERED);
nk_flags events;
const nk_flags flags = NK_EDIT_FIELD |
NK_EDIT_SIG_ENTER |
NK_EDIT_GOTO_END_ON_ACTIVATE;
if (position_supported)
{
int xpos, ypos;
glfwGetWindowPos(window, &xpos, &ypos);
nk_layout_row_dynamic(nk, 30, 3);
nk_label(nk, "Position", NK_TEXT_LEFT);
events = nk_edit_string_zero_terminated(nk, flags, xpos_buffer,
sizeof(xpos_buffer),
nk_filter_decimal);
if (events & NK_EDIT_COMMITED)
{
xpos = atoi(xpos_buffer);
glfwSetWindowPos(window, xpos, ypos);
}
else if (xpos != last_xpos || (events & NK_EDIT_DEACTIVATED))
sprintf(xpos_buffer, "%i", xpos);
events = nk_edit_string_zero_terminated(nk, flags, ypos_buffer,
sizeof(ypos_buffer),
nk_filter_decimal);
if (events & NK_EDIT_COMMITED)
{
ypos = atoi(ypos_buffer);
glfwSetWindowPos(window, xpos, ypos);
}
else if (ypos != last_ypos || (events & NK_EDIT_DEACTIVATED))
sprintf(ypos_buffer, "%i", ypos);
last_xpos = xpos;
last_ypos = ypos;
}
else
nk_label(nk, "Position not supported", NK_TEXT_LEFT);
nk_layout_row_dynamic(nk, 30, 3);
nk_label(nk, "Size", NK_TEXT_LEFT);
events = nk_edit_string_zero_terminated(nk, flags, width_buffer,
sizeof(width_buffer),
nk_filter_decimal);
if (events & NK_EDIT_COMMITED)
{
width = atoi(width_buffer);
glfwSetWindowSize(window, width, height);
}
else if (width != last_width || (events & NK_EDIT_DEACTIVATED))
sprintf(width_buffer, "%i", width);
events = nk_edit_string_zero_terminated(nk, flags, height_buffer,
sizeof(height_buffer),
nk_filter_decimal);
if (events & NK_EDIT_COMMITED)
{
height = atoi(height_buffer);
glfwSetWindowSize(window, width, height);
}
else if (height != last_height || (events & NK_EDIT_DEACTIVATED))
sprintf(height_buffer, "%i", height);
last_width = width;
last_height = height;
bool update_ratio_limit = false;
if (nk_checkbox_label(nk, "Aspect Ratio", &limit_aspect_ratio))
update_ratio_limit = true;
events = nk_edit_string_zero_terminated(nk, flags, numer_buffer,
sizeof(numer_buffer),
nk_filter_decimal);
if (events & NK_EDIT_COMMITED)
{
aspect_numer = abs(atoi(numer_buffer));
update_ratio_limit = true;
}
else if (events & NK_EDIT_DEACTIVATED)
sprintf(numer_buffer, "%i", aspect_numer);
events = nk_edit_string_zero_terminated(nk, flags, denom_buffer,
sizeof(denom_buffer),
nk_filter_decimal);
if (events & NK_EDIT_COMMITED)
{
aspect_denom = abs(atoi(denom_buffer));
update_ratio_limit = true;
}
else if (events & NK_EDIT_DEACTIVATED)
sprintf(denom_buffer, "%i", aspect_denom);
if (update_ratio_limit)
{
if (limit_aspect_ratio)
glfwSetWindowAspectRatio(window, aspect_numer, aspect_denom);
else
glfwSetWindowAspectRatio(window, GLFW_DONT_CARE, GLFW_DONT_CARE);
}
bool update_size_limit = false;
if (nk_checkbox_label(nk, "Minimum Size", &limit_min_size))
update_size_limit = true;
events = nk_edit_string_zero_terminated(nk, flags, min_width_buffer,
sizeof(min_width_buffer),
nk_filter_decimal);
if (events & NK_EDIT_COMMITED)
{
min_width = abs(atoi(min_width_buffer));
update_size_limit = true;
}
else if (events & NK_EDIT_DEACTIVATED)
sprintf(min_width_buffer, "%i", min_width);
events = nk_edit_string_zero_terminated(nk, flags, min_height_buffer,
sizeof(min_height_buffer),
nk_filter_decimal);
if (events & NK_EDIT_COMMITED)
{
min_height = abs(atoi(min_height_buffer));
update_size_limit = true;
}
else if (events & NK_EDIT_DEACTIVATED)
sprintf(min_height_buffer, "%i", min_height);
if (nk_checkbox_label(nk, "Maximum Size", &limit_max_size))
update_size_limit = true;
events = nk_edit_string_zero_terminated(nk, flags, max_width_buffer,
sizeof(max_width_buffer),
nk_filter_decimal);
if (events & NK_EDIT_COMMITED)
{
max_width = abs(atoi(max_width_buffer));
update_size_limit = true;
}
else if (events & NK_EDIT_DEACTIVATED)
sprintf(max_width_buffer, "%i", max_width);
events = nk_edit_string_zero_terminated(nk, flags, max_height_buffer,
sizeof(max_height_buffer),
nk_filter_decimal);
if (events & NK_EDIT_COMMITED)
{
max_height = abs(atoi(max_height_buffer));
update_size_limit = true;
}
else if (events & NK_EDIT_DEACTIVATED)
sprintf(max_height_buffer, "%i", max_height);
if (update_size_limit)
{
glfwSetWindowSizeLimits(window,
limit_min_size ? min_width : GLFW_DONT_CARE,
limit_min_size ? min_height : GLFW_DONT_CARE,
limit_max_size ? max_width : GLFW_DONT_CARE,
limit_max_size ? max_height : GLFW_DONT_CARE);
}
int fb_width, fb_height;
glfwGetFramebufferSize(window, &fb_width, &fb_height);
nk_label(nk, "Framebuffer Size", NK_TEXT_LEFT);
nk_labelf(nk, NK_TEXT_LEFT, "%i", fb_width);
nk_labelf(nk, NK_TEXT_LEFT, "%i", fb_height);
float xscale, yscale;
glfwGetWindowContentScale(window, &xscale, &yscale);
nk_label(nk, "Content Scale", NK_TEXT_LEFT);
nk_labelf(nk, NK_TEXT_LEFT, "%f", xscale);
nk_labelf(nk, NK_TEXT_LEFT, "%f", yscale);
nk_layout_row_begin(nk, NK_DYNAMIC, 30, 5);
int frame_left, frame_top, frame_right, frame_bottom;
glfwGetWindowFrameSize(window, &frame_left, &frame_top, &frame_right, &frame_bottom);
nk_layout_row_push(nk, 1.f / 3.f);
nk_label(nk, "Frame Size:", NK_TEXT_LEFT);
nk_layout_row_push(nk, 1.f / 6.f);
nk_labelf(nk, NK_TEXT_LEFT, "%i", frame_left);
nk_layout_row_push(nk, 1.f / 6.f);
nk_labelf(nk, NK_TEXT_LEFT, "%i", frame_top);
nk_layout_row_push(nk, 1.f / 6.f);
nk_labelf(nk, NK_TEXT_LEFT, "%i", frame_right);
nk_layout_row_push(nk, 1.f / 6.f);
nk_labelf(nk, NK_TEXT_LEFT, "%i", frame_bottom);
nk_layout_row_end(nk);
nk_layout_row_begin(nk, NK_DYNAMIC, 30, 2);
float opacity = glfwGetWindowOpacity(window);
nk_layout_row_push(nk, 1.f / 3.f);
nk_labelf(nk, NK_TEXT_LEFT, "Opacity: %0.3f", opacity);
nk_layout_row_push(nk, 2.f / 3.f);
if (nk_slider_float(nk, 0.f, &opacity, 1.f, 0.001f))
glfwSetWindowOpacity(window, opacity);
nk_layout_row_end(nk);
nk_layout_row_begin(nk, NK_DYNAMIC, 30, 2);
int should_close = glfwWindowShouldClose(window);
nk_layout_row_push(nk, 1.f / 3.f);
if (nk_checkbox_label(nk, "Should Close", &should_close))
glfwSetWindowShouldClose(window, should_close);
nk_layout_row_push(nk, 2.f / 3.f);
nk_checkbox_label(nk, "May Close", &may_close);
nk_layout_row_end(nk);
nk_layout_row_dynamic(nk, 30, 1);
nk_label(nk, "Attributes", NK_TEXT_CENTERED);
nk_layout_row_dynamic(nk, 30, width > 200 ? width / 200 : 1);
int decorated = glfwGetWindowAttrib(window, GLFW_DECORATED);
if (nk_checkbox_label(nk, "Decorated", &decorated))
glfwSetWindowAttrib(window, GLFW_DECORATED, decorated);
int resizable = glfwGetWindowAttrib(window, GLFW_RESIZABLE);
if (nk_checkbox_label(nk, "Resizable", &resizable))
glfwSetWindowAttrib(window, GLFW_RESIZABLE, resizable);
int floating = glfwGetWindowAttrib(window, GLFW_FLOATING);
if (nk_checkbox_label(nk, "Floating", &floating))
glfwSetWindowAttrib(window, GLFW_FLOATING, floating);
int passthrough = glfwGetWindowAttrib(window, GLFW_MOUSE_PASSTHROUGH);
if (nk_checkbox_label(nk, "Mouse Passthrough", &passthrough))
glfwSetWindowAttrib(window, GLFW_MOUSE_PASSTHROUGH, passthrough);
int auto_iconify = glfwGetWindowAttrib(window, GLFW_AUTO_ICONIFY);
if (nk_checkbox_label(nk, "Auto Iconify", &auto_iconify))
glfwSetWindowAttrib(window, GLFW_AUTO_ICONIFY, auto_iconify);
nk_value_bool(nk, "Focused", glfwGetWindowAttrib(window, GLFW_FOCUSED));
nk_value_bool(nk, "Hovered", glfwGetWindowAttrib(window, GLFW_HOVERED));
nk_value_bool(nk, "Visible", glfwGetWindowAttrib(window, GLFW_VISIBLE));
nk_value_bool(nk, "Iconified", glfwGetWindowAttrib(window, GLFW_ICONIFIED));
nk_value_bool(nk, "Maximized", glfwGetWindowAttrib(window, GLFW_MAXIMIZED));
}
nk_end(nk);
glClear(GL_COLOR_BUFFER_BIT);
nk_glfw3_render(NK_ANTI_ALIASING_ON);
glfwSwapBuffers(window);
glfwWaitEvents();
}
nk_glfw3_shutdown();
glfwTerminate();
exit(EXIT_SUCCESS);
}
+82 -30
View File
@@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// Simple multi-window example // Simple multi-window test
// Copyright (c) Camilla Löwy <elmindreda@glfw.org> // Copyright (c) Camilla Löwy <elmindreda@glfw.org>
// //
// This software is provided 'as-is', without any express or implied // This software is provided 'as-is', without any express or implied
@@ -22,6 +22,10 @@
// distribution. // distribution.
// //
//======================================================================== //========================================================================
//
// This test creates four windows and clears each in a different color
//
//========================================================================
#include <glad/gl.h> #include <glad/gl.h>
#define GLFW_INCLUDE_NONE #define GLFW_INCLUDE_NONE
@@ -30,28 +34,16 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
int main(int argc, char** argv) static GLFWwindow* windows[4];
static const char* titles[] =
{ {
int xpos, ypos, height; "Red",
const char* description; "Green",
GLFWwindow* windows[4]; "Blue",
"Yellow"
};
if (!glfwInit()) static const struct
{
glfwGetError(&description);
printf("Error: %s\n", description);
exit(EXIT_FAILURE);
}
glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE);
glfwWindowHint(GLFW_DECORATED, GLFW_FALSE);
glfwGetMonitorWorkarea(glfwGetPrimaryMonitor(), &xpos, &ypos, NULL, &height);
for (int i = 0; i < 4; i++)
{
const int size = height / 5;
const struct
{ {
float r, g, b; float r, g, b;
} colors[] = } colors[] =
@@ -62,28 +54,89 @@ int main(int argc, char** argv)
{ 0.98f, 0.74f, 0.04f } { 0.98f, 0.74f, 0.04f }
}; };
static void error_callback(int error, const char* description)
{
fprintf(stderr, "Error: %s\n", description);
}
static void arrange_windows(void)
{
int xbase, ybase;
glfwGetWindowPos(windows[0], &xbase, &ybase);
for (int i = 0; i < 4; i++)
{
int left, top, right, bottom;
glfwGetWindowFrameSize(windows[i], &left, &top, &right, &bottom);
glfwSetWindowPos(windows[i],
xbase + (i & 1) * (200 + left + right),
ybase + (i >> 1) * (200 + top + bottom));
}
}
static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
{
if (action != GLFW_PRESS)
return;
switch (key)
{
case GLFW_KEY_SPACE:
{
int xpos, ypos;
glfwGetWindowPos(window, &xpos, &ypos);
glfwSetWindowPos(window, xpos, ypos);
break;
}
case GLFW_KEY_ESCAPE:
glfwSetWindowShouldClose(window, GLFW_TRUE);
break;
case GLFW_KEY_D:
{
for (int i = 0; i < 4; i++)
{
const int decorated = glfwGetWindowAttrib(windows[i], GLFW_DECORATED);
glfwSetWindowAttrib(windows[i], GLFW_DECORATED, !decorated);
}
arrange_windows();
break;
}
}
}
int main(int argc, char** argv)
{
glfwSetErrorCallback(error_callback);
if (!glfwInit())
exit(EXIT_FAILURE);
glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE);
for (int i = 0; i < 4; i++)
{
if (i > 0) if (i > 0)
glfwWindowHint(GLFW_FOCUS_ON_SHOW, GLFW_FALSE); glfwWindowHint(GLFW_FOCUS_ON_SHOW, GLFW_FALSE);
windows[i] = glfwCreateWindow(size, size, "Multi-Window Example", NULL, NULL); windows[i] = glfwCreateWindow(200, 200, titles[i], NULL, NULL);
if (!windows[i]) if (!windows[i])
{ {
glfwGetError(&description);
printf("Error: %s\n", description);
glfwTerminate(); glfwTerminate();
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
glfwSetWindowPos(windows[i], glfwSetKeyCallback(windows[i], key_callback);
xpos + size * (1 + (i & 1)),
ypos + size * (1 + (i >> 1)));
glfwSetInputMode(windows[i], GLFW_STICKY_KEYS, GLFW_TRUE);
glfwMakeContextCurrent(windows[i]); glfwMakeContextCurrent(windows[i]);
gladLoadGL(glfwGetProcAddress); gladLoadGL(glfwGetProcAddress);
glClearColor(colors[i].r, colors[i].g, colors[i].b, 1.f); glClearColor(colors[i].r, colors[i].g, colors[i].b, 1.f);
} }
arrange_windows();
for (int i = 0; i < 4; i++) for (int i = 0; i < 4; i++)
glfwShowWindow(windows[i]); glfwShowWindow(windows[i]);
@@ -95,8 +148,7 @@ int main(int argc, char** argv)
glClear(GL_COLOR_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT);
glfwSwapBuffers(windows[i]); glfwSwapBuffers(windows[i]);
if (glfwWindowShouldClose(windows[i]) || if (glfwWindowShouldClose(windows[i]))
glfwGetKey(windows[i], GLFW_KEY_ESCAPE))
{ {
glfwTerminate(); glfwTerminate();
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);