Merge branch 'glfw:master' into master

This commit is contained in:
bojosos 2021-08-05 15:33:22 +03:00 committed by GitHub
commit a90e0f21e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
51 changed files with 1648 additions and 911 deletions

View File

@ -1,10 +1,10 @@
image: image:
- Visual Studio 2015 - Visual Studio 2015
- Visual Studio 2019
branches: branches:
only: only:
- ci - ci
- master - master
- latest
- 3.3-stable - 3.3-stable
skip_tags: true skip_tags: true
environment: environment:
@ -21,26 +21,13 @@ environment:
- GENERATOR: Visual Studio 10 2010 - GENERATOR: Visual Studio 10 2010
BUILD_SHARED_LIBS: OFF BUILD_SHARED_LIBS: OFF
CFLAGS: /WX CFLAGS: /WX
- GENERATOR: Visual Studio 16 2019
BUILD_SHARED_LIBS: ON
CFLAGS: /WX
- GENERATOR: Visual Studio 16 2019
BUILD_SHARED_LIBS: OFF
CFLAGS: /WX
matrix: matrix:
fast_finish: true fast_finish: true
exclude:
- image: Visual Studio 2015
GENERATOR: Visual Studio 16 2019
- image: Visual Studio 2019
GENERATOR: Visual Studio 10 2010
- image: Visual Studio 2019
GENERATOR: MinGW Makefiles
for: for:
- -
matrix: matrix:
except: only:
- GENERATOR: Visual Studio 10 2010 - GENERATOR: MinGW Makefiles
build_script: build_script:
- set PATH=%PATH:C:\Program Files\Git\usr\bin=C:\MinGW\bin% - set PATH=%PATH:C:\Program Files\Git\usr\bin=C:\MinGW\bin%
- cmake -S . -B build -G "%GENERATOR%" -DBUILD_SHARED_LIBS=%BUILD_SHARED_LIBS% - cmake -S . -B build -G "%GENERATOR%" -DBUILD_SHARED_LIBS=%BUILD_SHARED_LIBS%

116
.github/workflows/build.yml vendored Normal file
View File

@ -0,0 +1,116 @@
name: Build
on:
pull_request:
push:
branches: [ ci, master, latest, 3.3-stable ]
permissions:
statuses: write
contents: read
jobs:
build-linux-x11-clang:
name: X11 (Linux, Clang)
runs-on: ubuntu-latest
env:
CC: clang
CFLAGS: -Werror
steps:
- uses: actions/checkout@v2
- name: Install dependencies
run: |
sudo apt update
sudo apt install libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev libxext-dev
- name: Configure static library
run: cmake -S . -B build-static
- name: Build static library
run: cmake --build build-static --parallel
- name: Configure shared library
run: cmake -S . -B build-shared -D BUILD_SHARED_LIBS=ON
- name: Build shared library
run: cmake --build build-shared --parallel
build-linux-wayland-clang:
name: Wayland (Linux, Clang)
runs-on: ubuntu-latest
env:
CC: clang
CFLAGS: -Werror
steps:
- uses: actions/checkout@v2
- name: Install dependencies
run: |
sudo apt update
sudo apt install wayland-protocols libwayland-dev libxkbcommon-dev
- name: Configure static library
run: cmake -S . -B build-static -D GLFW_USE_WAYLAND=ON
- name: Build static library
run: cmake --build build-static --parallel
- name: Configure shared library
run: cmake -S . -B build-shared -D GLFW_USE_WAYLAND=ON -D BUILD_SHARED_LIBS=ON
- name: Build shared library
run: cmake --build build-shared --parallel
build-linux-null-clang:
name: Null (Linux, Clang)
runs-on: ubuntu-latest
env:
CC: clang
CFLAGS: -Werror
steps:
- uses: actions/checkout@v2
- name: Install dependencies
run: |
sudo apt update
sudo apt install libosmesa6-dev
- name: Configure static library
run: cmake -S . -B build-static -D GLFW_USE_OSMESA=ON
- name: Build static library
run: cmake --build build-static --parallel
- name: Configure shared library
run: cmake -S . -B build-shared -D GLFW_USE_OSMESA=ON -D BUILD_SHARED_LIBS=ON
- name: Build shared library
run: cmake --build build-shared --parallel
build-macos-cocoa-clang:
name: Cocoa (macOS, Clang)
runs-on: macos-latest
env:
CFLAGS: -Werror
MACOSX_DEPLOYMENT_TARGET: 10.8
steps:
- uses: actions/checkout@v2
- name: Configure static library
run: cmake -S . -B build-static
- name: Build static library
run: cmake --build build-static --parallel
- name: Configure shared library
run: cmake -S . -B build-shared -D BUILD_SHARED_LIBS=ON
- name: Build shared library
run: cmake --build build-shared --parallel
build-windows-win32-vs2019:
name: Win32 (Windows, VS2019)
runs-on: windows-latest
env:
CFLAGS: /WX
steps:
- uses: actions/checkout@v2
- name: Configure static library
run: cmake -S . -B build-static -G "Visual Studio 16 2019"
- name: Build static library
run: cmake --build build-static --parallel
- name: Configure shared library
run: cmake -S . -B build-shared -G "Visual Studio 16 2019" -D BUILD_SHARED_LIBS=ON
- name: Build shared library
run: cmake --build build-shared --parallel

View File

@ -1,114 +0,0 @@
language: c
compiler: clang
branches:
only:
- ci
- master
- 3.3-stable
matrix:
include:
- os: linux
dist: xenial
name: "X11 shared library"
addons:
apt:
packages:
- libxrandr-dev
- libxinerama-dev
- libxcursor-dev
- libxi-dev
- libxext-dev
env:
- BUILD_SHARED_LIBS=ON
- CFLAGS=-Werror
- os: linux
dist: xenial
name: "X11 static library"
addons:
apt:
packages:
- libxrandr-dev
- libxinerama-dev
- libxcursor-dev
- libxi-dev
- libxext-dev
env:
- BUILD_SHARED_LIBS=OFF
- CFLAGS=-Werror
- os: linux
dist: focal
name: "Wayland shared library"
addons:
apt:
packages:
- wayland-protocols
- libwayland-dev
- libxkbcommon-dev
- libegl1-mesa-dev
env:
- USE_WAYLAND=ON
- BUILD_SHARED_LIBS=ON
- CFLAGS=-Werror
- os: linux
dist: focal
name: "Wayland static library"
addons:
apt:
packages:
- wayland-protocols
- libwayland-dev
- libxkbcommon-dev
- libegl1-mesa-dev
env:
- USE_WAYLAND=ON
- BUILD_SHARED_LIBS=OFF
- 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
name: "Cocoa shared library"
env:
- BUILD_SHARED_LIBS=ON
- CFLAGS=-Werror
- MACOSX_DEPLOYMENT_TARGET=10.8
- os: osx
name: "Cocoa static library"
env:
- BUILD_SHARED_LIBS=OFF
- CFLAGS=-Werror
- MACOSX_DEPLOYMENT_TARGET=10.8
script:
- if grep -Inr '\s$' src include docs tests examples CMake *.md .gitattributes .gitignore; then
echo Trailing whitespace found, aborting;
exit 1;
fi
- mkdir build
- cd build
- cmake -DCMAKE_VERBOSE_MAKEFILE=ON -DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS} -DGLFW_USE_WAYLAND=${USE_WAYLAND} -DGLFW_USE_OSMESA=${USE_OSMESA} ..
- cmake --build .
notifications:
email:
recipients:
- ci@glfw.org
on_success: never
on_failure: always

View File

@ -24,7 +24,22 @@ endif()
file(STRINGS "${source_path}" lines) file(STRINGS "${source_path}" lines)
foreach(line ${lines}) foreach(line ${lines})
if ("${line}" MATCHES "^[0-9a-fA-F].*$") if ("${line}" MATCHES "^[0-9a-fA-F].*$")
set(GLFW_GAMEPAD_MAPPINGS "${GLFW_GAMEPAD_MAPPINGS}\"${line}\",\n") if ("${line}" MATCHES "platform:Windows")
if (GLFW_WIN32_MAPPINGS)
set(GLFW_WIN32_MAPPINGS "${GLFW_WIN32_MAPPINGS}\n")
endif()
set(GLFW_WIN32_MAPPINGS "${GLFW_WIN32_MAPPINGS}\"${line}\",")
elseif ("${line}" MATCHES "platform:Mac OS X")
if (GLFW_COCOA_MAPPINGS)
set(GLFW_COCOA_MAPPINGS "${GLFW_COCOA_MAPPINGS}\n")
endif()
set(GLFW_COCOA_MAPPINGS "${GLFW_COCOA_MAPPINGS}\"${line}\",")
elseif ("${line}" MATCHES "platform:Linux")
if (GLFW_LINUX_MAPPINGS)
set(GLFW_LINUX_MAPPINGS "${GLFW_LINUX_MAPPINGS}\n")
endif()
set(GLFW_LINUX_MAPPINGS "${GLFW_LINUX_MAPPINGS}\"${line}\",")
endif()
endif() endif()
endforeach() endforeach()

View File

@ -13,5 +13,5 @@ if (EPOLLSHIM_INCLUDE_DIRS AND EPOLLSHIM_LIBRARIES)
endif (EPOLLSHIM_INCLUDE_DIRS AND EPOLLSHIM_LIBRARIES) endif (EPOLLSHIM_INCLUDE_DIRS AND EPOLLSHIM_LIBRARIES)
include(FindPackageHandleStandardArgs) include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(EPOLLSHIM DEFAULT_MSG EPOLLSHIM_LIBRARIES EPOLLSHIM_INCLUDE_DIRS) find_package_handle_standard_args(EpollShim DEFAULT_MSG EPOLLSHIM_LIBRARIES EPOLLSHIM_INCLUDE_DIRS)
mark_as_advanced(EPOLLSHIM_INCLUDE_DIRS EPOLLSHIM_LIBRARIES) mark_as_advanced(EPOLLSHIM_INCLUDE_DIRS EPOLLSHIM_LIBRARIES)

View File

@ -69,8 +69,8 @@ endif()
#-------------------------------------------------------------------- #--------------------------------------------------------------------
# Set compiler specific flags # Set compiler specific flags
#-------------------------------------------------------------------- #--------------------------------------------------------------------
if (MSVC) if (MSVC AND NOT USE_MSVC_RUNTIME_LIBRARY_DLL)
if (NOT USE_MSVC_RUNTIME_LIBRARY_DLL) if (${CMAKE_VERSION} VERSION_LESS 3.15)
foreach (flag CMAKE_C_FLAGS foreach (flag CMAKE_C_FLAGS
CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_DEBUG
CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_RELEASE
@ -85,6 +85,8 @@ if (MSVC)
endif() endif()
endforeach() endforeach()
else()
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
endif() endif()
endif() endif()

View File

@ -1,6 +1,6 @@
# GLFW # GLFW
[![Build status](https://travis-ci.org/glfw/glfw.svg?branch=master)](https://travis-ci.org/glfw/glfw) [![Build status](https://github.com/glfw/glfw/actions/workflows/build.yml/badge.svg)](https://github.com/glfw/glfw/actions)
[![Build status](https://ci.appveyor.com/api/projects/status/0kf0ct9831i5l6sp/branch/master?svg=true)](https://ci.appveyor.com/project/elmindreda/glfw) [![Build status](https://ci.appveyor.com/api/projects/status/0kf0ct9831i5l6sp/branch/master?svg=true)](https://ci.appveyor.com/project/elmindreda/glfw)
[![Coverity Scan](https://scan.coverity.com/projects/4884/badge.svg)](https://scan.coverity.com/projects/glfw-glfw) [![Coverity Scan](https://scan.coverity.com/projects/4884/badge.svg)](https://scan.coverity.com/projects/glfw-glfw)
@ -14,18 +14,18 @@ GLFW natively supports Windows, macOS and Linux and other Unix-like systems. On
Linux both X11 and Wayland are supported. Linux both X11 and Wayland are supported.
GLFW is licensed under the [zlib/libpng GLFW is licensed under the [zlib/libpng
license](http://www.glfw.org/license.html). license](https://www.glfw.org/license.html).
You can [download](http://www.glfw.org/download.html) the latest stable release You can [download](https://www.glfw.org/download.html) the latest stable release
as source or Windows binaries, or fetch the `latest` branch from GitHub. Each as source or Windows binaries, or fetch the `latest` branch from GitHub. Each
release starting with 3.0 also has a corresponding [annotated release starting with 3.0 also has a corresponding [annotated
tag](https://github.com/glfw/glfw/releases) with source and binary archives. tag](https://github.com/glfw/glfw/releases) with source and binary archives.
The [documentation](http://www.glfw.org/docs/latest/) is available online and is The [documentation](https://www.glfw.org/docs/latest/) is available online and is
included in all source and binary archives. See the [release included in all source and binary archives. See the [release
notes](https://www.glfw.org/docs/latest/news.html) for new features, caveats and notes](https://www.glfw.org/docs/latest/news.html) for new features, caveats and
deprecations in the latest release. For more details see the [version deprecations in the latest release. For more details see the [version
history](http://www.glfw.org/changelog.html). history](https://www.glfw.org/changelog.html).
The `master` branch is the stable integration branch and _should_ always compile The `master` branch is the stable integration branch and _should_ always compile
and run on all supported platforms, although details of newly added features may and run on all supported platforms, although details of newly added features may
@ -34,9 +34,9 @@ fixes live in [other branches](https://github.com/glfw/glfw/branches/all) until
they are stable enough to merge. they are stable enough to merge.
If you are new to GLFW, you may find the If you are new to GLFW, you may find the
[tutorial](http://www.glfw.org/docs/latest/quick.html) for GLFW 3 useful. If [tutorial](https://www.glfw.org/docs/latest/quick.html) for GLFW 3 useful. If
you have used GLFW 2 in the past, there is a [transition you have used GLFW 2 in the past, there is a [transition
guide](http://www.glfw.org/docs/latest/moving.html) for moving to the GLFW guide](https://www.glfw.org/docs/latest/moving.html) for moving to the GLFW
3 API. 3 API.
@ -52,16 +52,16 @@ MinGW-w64, on macOS with Clang and on Linux and other Unix-like systems with GCC
and Clang. It will likely compile in other environments as well, but this is and Clang. It will likely compile in other environments as well, but this is
not regularly tested. not regularly tested.
There are [pre-compiled Windows binaries](http://www.glfw.org/download.html) There are [pre-compiled Windows binaries](https://www.glfw.org/download.html)
available for all supported compilers. available for all supported compilers.
See the [compilation guide](http://www.glfw.org/docs/latest/compile.html) for See the [compilation guide](https://www.glfw.org/docs/latest/compile.html) for
more information about how to compile GLFW yourself. more information about how to compile GLFW yourself.
## Using GLFW ## Using GLFW
See the [documentation](http://www.glfw.org/docs/latest/) for tutorials, guides See the [documentation](https://www.glfw.org/docs/latest/) for tutorials, guides
and the API reference. and the API reference.
@ -79,7 +79,7 @@ Unix-like systems running the X Window System are supported even without
a desktop environment or modern extensions, although some features require a desktop environment or modern extensions, although some features require
a running window or clipboard manager. The OSMesa backend requires Mesa 6.3. a running window or clipboard manager. The OSMesa backend requires Mesa 6.3.
See the [compatibility guide](http://www.glfw.org/docs/latest/compat.html) See the [compatibility guide](https://www.glfw.org/docs/latest/compat.html)
in the documentation for more information. in the documentation for more information.
@ -102,7 +102,7 @@ located in the `deps/` directory.
- [Nuklear](https://github.com/Immediate-Mode-UI/Nuklear) for test and example UI - [Nuklear](https://github.com/Immediate-Mode-UI/Nuklear) for test and example UI
- [stb\_image\_write](https://github.com/nothings/stb) for writing images to disk - [stb\_image\_write](https://github.com/nothings/stb) for writing images to disk
The documentation is generated with [Doxygen](http://doxygen.org/) if CMake can The documentation is generated with [Doxygen](https://doxygen.org/) if CMake can
find that tool. find that tool.
@ -127,7 +127,10 @@ information on what to include when reporting a bug.
- Added `GLFW_FEATURE_UNIMPLEMENTED` error for incomplete backends (#1692) - Added `GLFW_FEATURE_UNIMPLEMENTED` error for incomplete backends (#1692)
- Added `GLFW_ANGLE_PLATFORM_TYPE` init hint and `GLFW_ANGLE_PLATFORM_TYPE_*` - Added `GLFW_ANGLE_PLATFORM_TYPE` init hint and `GLFW_ANGLE_PLATFORM_TYPE_*`
values to select ANGLE backend (#1380) values to select ANGLE backend (#1380)
- Added `GLFW_X11_XCB_VULKAN_SURFACE` init hint for selecting X11 Vulkan
surface extension (#1793)
- Made joystick subsystem initialize at first use (#1284,#1646) - Made joystick subsystem initialize at first use (#1284,#1646)
- Made `GLFW_DOUBLEBUFFER` a read-only window attribute
- Updated the minimum required CMake version to 3.1 - Updated 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
@ -137,6 +140,9 @@ information on what to include when reporting a bug.
- 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 - Bugfix: Some extension loader headers did not prevent default OpenGL header
inclusion (#1695) inclusion (#1695)
- Bugfix: Buffers were swapped at creation on single-buffered windows (#1873)
- Bugfix: Gamepad mapping updates could spam `GLFW_INVALID_VALUE` due to
incompatible controllers sharing hardware ID (#1763)
- [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
@ -159,6 +165,13 @@ information on what to include when reporting a bug.
configuration change (#1761) configuration change (#1761)
- [Win32] Bugfix: Initialization would segfault on Windows 8 (not 8.1) (#1775) - [Win32] Bugfix: Initialization would segfault on Windows 8 (not 8.1) (#1775)
- [Win32] Bugfix: Duplicate size events were not filtered (#1610) - [Win32] Bugfix: Duplicate size events were not filtered (#1610)
- [Win32] Bugfix: Full screen windows were incorrectly resized by DPI changes
(#1582)
- [Win32] Bugfix: `GLFW_SCALE_TO_MONITOR` had no effect on systems older than
Windows 10 version 1703 (#1511)
- [Win32] Bugfix: `USE_MSVC_RUNTIME_LIBRARY_DLL` had no effect on CMake 3.15 or
later (#1783,#1796)
- [Win32] Bugfix: Compilation with LLVM for Windows failed (#1807,#1824,#1874)
- [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)
@ -183,6 +196,8 @@ information on what to include when reporting a bug.
regained focus (#1648,#1802) regained focus (#1648,#1802)
- [Cocoa] Bugfix: Monitor name query could segfault on macOS 11 (#1809,#1833) - [Cocoa] Bugfix: Monitor name query could segfault on macOS 11 (#1809,#1833)
- [Cocoa] Bugfix: The install name of the installed dylib was relative (#1504) - [Cocoa] Bugfix: The install name of the installed dylib was relative (#1504)
- [Cocoa] Bugfix: The MoltenVK layer contents scale was updated only after
related events were emitted
- [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)
@ -208,6 +223,8 @@ information on what to include when reporting a bug.
combinaitons (#1598) combinaitons (#1598)
- [X11] Bugfix: Keys pressed simultaneously with others were not always - [X11] Bugfix: Keys pressed simultaneously with others were not always
reported (#1112,#1415,#1472,#1616) reported (#1112,#1415,#1472,#1616)
- [X11] Bugfix: Some window attributes were not applied on leaving fullscreen
(#1863)
- [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
@ -217,25 +234,29 @@ information on what to include when reporting a bug.
(#1463) (#1463)
- [Wayland] Bugfix: Client-Side Decorations were destroyed in the wrong worder - [Wayland] Bugfix: Client-Side Decorations were destroyed in the wrong worder
(#1798) (#1798)
- [Wayland] Bugfix: Monitors physical size could report zero (#1784,#1792)
- [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)
- [NSGL] Bugfix: Defining `GL_SILENCE_DEPRECATION` externally caused
a duplicate definition warning (#1840)
- [EGL] Added platform selection via the `EGL_EXT_platform_base` extension - [EGL] Added platform selection via the `EGL_EXT_platform_base` extension
(#442) (#442)
- [EGL] Added ANGLE backend selection via `EGL_ANGLE_platform_angle` extension - [EGL] Added ANGLE backend selection via `EGL_ANGLE_platform_angle` extension
(#1380) (#1380)
- [EGL] Bugfix: The `GLFW_DOUBLEBUFFER` context attribute was ignored (#1843)
## Contact ## Contact
On [glfw.org](http://www.glfw.org/) you can find the latest version of GLFW, as On [glfw.org](https://www.glfw.org/) you can find the latest version of GLFW, as
well as news, documentation and other information about the project. well as news, documentation and other information about the project.
If you have questions related to the use of GLFW, we have a If you have questions related to the use of GLFW, we have a
[forum](https://discourse.glfw.org/), and the `#glfw` IRC channel on [forum](https://discourse.glfw.org/), and the `#glfw` IRC channel on
[Freenode](http://freenode.net/). [Libera.Chat](https://libera.chat/).
If you have a bug to report, a patch to submit or a feature you'd like to If you have a bug to report, a patch to submit or a feature you'd like to
request, please file it in the request, please file it in the
@ -282,6 +303,7 @@ skills.
- Andrew Corrigan - Andrew Corrigan
- Bailey Cosier - Bailey Cosier
- Noel Cower - Noel Cower
- CuriouserThing
- Jason Daly - Jason Daly
- Jarrod Davis - Jarrod Davis
- Olivier Delannoy - Olivier Delannoy
@ -351,6 +373,7 @@ skills.
- Adam Marcus - Adam Marcus
- Célestin Marot - Célestin Marot
- Kyle McDonald - Kyle McDonald
- David V. McKay
- David Medlock - David Medlock
- Bryce Mehring - Bryce Mehring
- Jonathan Mercier - Jonathan Mercier

147
deps/linmath.h vendored
View File

@ -1,14 +1,13 @@
#ifndef LINMATH_H #ifndef LINMATH_H
#define LINMATH_H #define LINMATH_H
#include <string.h>
#include <math.h> #include <math.h>
#include <string.h>
/* 2020-03-02 Camilla Löwy <elmindreda@elmindreda.org> /* 2021-03-21 Camilla Löwy <elmindreda@elmindreda.org>
* - Added inclusion of string.h for memcpy
* - Replaced tan and acos with tanf and acosf
* - Replaced double constants with float equivalents * - Replaced double constants with float equivalents
*/ */
#include <string.h>
#ifdef LINMATH_NO_INLINE #ifdef LINMATH_NO_INLINE
#define LINMATH_H_FUNC static #define LINMATH_H_FUNC static
@ -38,7 +37,7 @@ LINMATH_H_FUNC void vec##n##_scale(vec##n r, vec##n const v, float const s) \
} \ } \
LINMATH_H_FUNC float vec##n##_mul_inner(vec##n const a, vec##n const b) \ LINMATH_H_FUNC float vec##n##_mul_inner(vec##n const a, vec##n const b) \
{ \ { \
float p = 0.; \ float p = 0.f; \
int i; \ int i; \
for(i=0; i<n; ++i) \ for(i=0; i<n; ++i) \
p += b[i]*a[i]; \ p += b[i]*a[i]; \
@ -64,6 +63,12 @@ LINMATH_H_FUNC void vec##n##_max(vec##n r, vec##n const a, vec##n const b) \
int i; \ int i; \
for(i=0; i<n; ++i) \ for(i=0; i<n; ++i) \
r[i] = a[i]>b[i] ? a[i] : b[i]; \ r[i] = a[i]>b[i] ? a[i] : b[i]; \
} \
LINMATH_H_FUNC void vec##n##_dup(vec##n r, vec##n const src) \
{ \
int i; \
for(i=0; i<n; ++i) \
r[i] = src[i]; \
} }
LINMATH_H_DEFINE_VEC(2) LINMATH_H_DEFINE_VEC(2)
@ -79,13 +84,13 @@ LINMATH_H_FUNC void vec3_mul_cross(vec3 r, vec3 const a, vec3 const b)
LINMATH_H_FUNC void vec3_reflect(vec3 r, vec3 const v, vec3 const n) LINMATH_H_FUNC void vec3_reflect(vec3 r, vec3 const v, vec3 const n)
{ {
float p = 2.f*vec3_mul_inner(v, n); float p = 2.f * vec3_mul_inner(v, n);
int i; int i;
for(i=0;i<3;++i) for(i=0;i<3;++i)
r[i] = v[i] - p*n[i]; r[i] = v[i] - p*n[i];
} }
LINMATH_H_FUNC void vec4_mul_cross(vec4 r, vec4 a, vec4 b) LINMATH_H_FUNC void vec4_mul_cross(vec4 r, vec4 const a, vec4 const b)
{ {
r[0] = a[1]*b[2] - a[2]*b[1]; r[0] = a[1]*b[2] - a[2]*b[1];
r[1] = a[2]*b[0] - a[0]*b[2]; r[1] = a[2]*b[0] - a[0]*b[2];
@ -93,7 +98,7 @@ LINMATH_H_FUNC void vec4_mul_cross(vec4 r, vec4 a, vec4 b)
r[3] = 1.f; r[3] = 1.f;
} }
LINMATH_H_FUNC void vec4_reflect(vec4 r, vec4 v, vec4 n) LINMATH_H_FUNC void vec4_reflect(vec4 r, vec4 const v, vec4 const n)
{ {
float p = 2.f*vec4_mul_inner(v, n); float p = 2.f*vec4_mul_inner(v, n);
int i; int i;
@ -109,61 +114,59 @@ LINMATH_H_FUNC void mat4x4_identity(mat4x4 M)
for(j=0; j<4; ++j) for(j=0; j<4; ++j)
M[i][j] = i==j ? 1.f : 0.f; M[i][j] = i==j ? 1.f : 0.f;
} }
LINMATH_H_FUNC void mat4x4_dup(mat4x4 M, mat4x4 N) LINMATH_H_FUNC void mat4x4_dup(mat4x4 M, mat4x4 const N)
{ {
int i, j; int i;
for(i=0; i<4; ++i) for(i=0; i<4; ++i)
for(j=0; j<4; ++j) vec4_dup(M[i], N[i]);
M[i][j] = N[i][j];
} }
LINMATH_H_FUNC void mat4x4_row(vec4 r, mat4x4 M, int i) LINMATH_H_FUNC void mat4x4_row(vec4 r, mat4x4 const M, int i)
{ {
int k; int k;
for(k=0; k<4; ++k) for(k=0; k<4; ++k)
r[k] = M[k][i]; r[k] = M[k][i];
} }
LINMATH_H_FUNC void mat4x4_col(vec4 r, mat4x4 M, int i) LINMATH_H_FUNC void mat4x4_col(vec4 r, mat4x4 const M, int i)
{ {
int k; int k;
for(k=0; k<4; ++k) for(k=0; k<4; ++k)
r[k] = M[i][k]; r[k] = M[i][k];
} }
LINMATH_H_FUNC void mat4x4_transpose(mat4x4 M, mat4x4 N) LINMATH_H_FUNC void mat4x4_transpose(mat4x4 M, mat4x4 const N)
{ {
// Note: if M and N are the same, the user has to
// explicitly make a copy of M and set it to N.
int i, j; int i, j;
for(j=0; j<4; ++j) for(j=0; j<4; ++j)
for(i=0; i<4; ++i) for(i=0; i<4; ++i)
M[i][j] = N[j][i]; M[i][j] = N[j][i];
} }
LINMATH_H_FUNC void mat4x4_add(mat4x4 M, mat4x4 a, mat4x4 b) LINMATH_H_FUNC void mat4x4_add(mat4x4 M, mat4x4 const a, mat4x4 const b)
{ {
int i; int i;
for(i=0; i<4; ++i) for(i=0; i<4; ++i)
vec4_add(M[i], a[i], b[i]); vec4_add(M[i], a[i], b[i]);
} }
LINMATH_H_FUNC void mat4x4_sub(mat4x4 M, mat4x4 a, mat4x4 b) LINMATH_H_FUNC void mat4x4_sub(mat4x4 M, mat4x4 const a, mat4x4 const b)
{ {
int i; int i;
for(i=0; i<4; ++i) for(i=0; i<4; ++i)
vec4_sub(M[i], a[i], b[i]); vec4_sub(M[i], a[i], b[i]);
} }
LINMATH_H_FUNC void mat4x4_scale(mat4x4 M, mat4x4 a, float k) LINMATH_H_FUNC void mat4x4_scale(mat4x4 M, mat4x4 const a, float k)
{ {
int i; int i;
for(i=0; i<4; ++i) for(i=0; i<4; ++i)
vec4_scale(M[i], a[i], k); vec4_scale(M[i], a[i], k);
} }
LINMATH_H_FUNC void mat4x4_scale_aniso(mat4x4 M, mat4x4 a, float x, float y, float z) LINMATH_H_FUNC void mat4x4_scale_aniso(mat4x4 M, mat4x4 const a, float x, float y, float z)
{ {
int i;
vec4_scale(M[0], a[0], x); vec4_scale(M[0], a[0], x);
vec4_scale(M[1], a[1], y); vec4_scale(M[1], a[1], y);
vec4_scale(M[2], a[2], z); vec4_scale(M[2], a[2], z);
for(i = 0; i < 4; ++i) { vec4_dup(M[3], a[3]);
M[3][i] = a[3][i];
}
} }
LINMATH_H_FUNC void mat4x4_mul(mat4x4 M, mat4x4 a, mat4x4 b) LINMATH_H_FUNC void mat4x4_mul(mat4x4 M, mat4x4 const a, mat4x4 const b)
{ {
mat4x4 temp; mat4x4 temp;
int k, r, c; int k, r, c;
@ -174,7 +177,7 @@ LINMATH_H_FUNC void mat4x4_mul(mat4x4 M, mat4x4 a, mat4x4 b)
} }
mat4x4_dup(M, temp); mat4x4_dup(M, temp);
} }
LINMATH_H_FUNC void mat4x4_mul_vec4(vec4 r, mat4x4 M, vec4 v) LINMATH_H_FUNC void mat4x4_mul_vec4(vec4 r, mat4x4 const M, vec4 const v)
{ {
int i, j; int i, j;
for(j=0; j<4; ++j) { for(j=0; j<4; ++j) {
@ -200,13 +203,13 @@ LINMATH_H_FUNC void mat4x4_translate_in_place(mat4x4 M, float x, float y, float
M[3][i] += vec4_mul_inner(r, t); M[3][i] += vec4_mul_inner(r, t);
} }
} }
LINMATH_H_FUNC void mat4x4_from_vec3_mul_outer(mat4x4 M, vec3 a, vec3 b) LINMATH_H_FUNC void mat4x4_from_vec3_mul_outer(mat4x4 M, vec3 const a, vec3 const b)
{ {
int i, j; int i, j;
for(i=0; i<4; ++i) for(j=0; j<4; ++j) for(i=0; i<4; ++i) for(j=0; j<4; ++j)
M[i][j] = i<3 && j<3 ? a[i] * b[j] : 0.f; M[i][j] = i<3 && j<3 ? a[i] * b[j] : 0.f;
} }
LINMATH_H_FUNC void mat4x4_rotate(mat4x4 R, mat4x4 M, float x, float y, float z, float angle) LINMATH_H_FUNC void mat4x4_rotate(mat4x4 R, mat4x4 const M, float x, float y, float z, float angle)
{ {
float s = sinf(angle); float s = sinf(angle);
float c = cosf(angle); float c = cosf(angle);
@ -234,13 +237,13 @@ LINMATH_H_FUNC void mat4x4_rotate(mat4x4 R, mat4x4 M, float x, float y, float z,
mat4x4_add(T, T, C); mat4x4_add(T, T, C);
mat4x4_add(T, T, S); mat4x4_add(T, T, S);
T[3][3] = 1.; T[3][3] = 1.f;
mat4x4_mul(R, M, T); mat4x4_mul(R, M, T);
} else { } else {
mat4x4_dup(R, M); mat4x4_dup(R, M);
} }
} }
LINMATH_H_FUNC void mat4x4_rotate_X(mat4x4 Q, mat4x4 M, float angle) LINMATH_H_FUNC void mat4x4_rotate_X(mat4x4 Q, mat4x4 const M, float angle)
{ {
float s = sinf(angle); float s = sinf(angle);
float c = cosf(angle); float c = cosf(angle);
@ -252,7 +255,7 @@ LINMATH_H_FUNC void mat4x4_rotate_X(mat4x4 Q, mat4x4 M, float angle)
}; };
mat4x4_mul(Q, M, R); mat4x4_mul(Q, M, R);
} }
LINMATH_H_FUNC void mat4x4_rotate_Y(mat4x4 Q, mat4x4 M, float angle) LINMATH_H_FUNC void mat4x4_rotate_Y(mat4x4 Q, mat4x4 const M, float angle)
{ {
float s = sinf(angle); float s = sinf(angle);
float c = cosf(angle); float c = cosf(angle);
@ -264,7 +267,7 @@ LINMATH_H_FUNC void mat4x4_rotate_Y(mat4x4 Q, mat4x4 M, float angle)
}; };
mat4x4_mul(Q, M, R); mat4x4_mul(Q, M, R);
} }
LINMATH_H_FUNC void mat4x4_rotate_Z(mat4x4 Q, mat4x4 M, float angle) LINMATH_H_FUNC void mat4x4_rotate_Z(mat4x4 Q, mat4x4 const M, float angle)
{ {
float s = sinf(angle); float s = sinf(angle);
float c = cosf(angle); float c = cosf(angle);
@ -276,7 +279,7 @@ LINMATH_H_FUNC void mat4x4_rotate_Z(mat4x4 Q, mat4x4 M, float angle)
}; };
mat4x4_mul(Q, M, R); mat4x4_mul(Q, M, R);
} }
LINMATH_H_FUNC void mat4x4_invert(mat4x4 T, mat4x4 M) LINMATH_H_FUNC void mat4x4_invert(mat4x4 T, mat4x4 const M)
{ {
float s[6]; float s[6];
float c[6]; float c[6];
@ -317,10 +320,10 @@ LINMATH_H_FUNC void mat4x4_invert(mat4x4 T, mat4x4 M)
T[3][2] = (-M[3][0] * s[3] + M[3][1] * s[1] - M[3][2] * s[0]) * idet; T[3][2] = (-M[3][0] * s[3] + M[3][1] * s[1] - M[3][2] * s[0]) * idet;
T[3][3] = ( M[2][0] * s[3] - M[2][1] * s[1] + M[2][2] * s[0]) * idet; T[3][3] = ( M[2][0] * s[3] - M[2][1] * s[1] + M[2][2] * s[0]) * idet;
} }
LINMATH_H_FUNC void mat4x4_orthonormalize(mat4x4 R, mat4x4 M) LINMATH_H_FUNC void mat4x4_orthonormalize(mat4x4 R, mat4x4 const M)
{ {
mat4x4_dup(R, M); mat4x4_dup(R, M);
float s = 1.; float s = 1.f;
vec3 h; vec3 h;
vec3_norm(R[2], R[2]); vec3_norm(R[2], R[2]);
@ -398,7 +401,7 @@ LINMATH_H_FUNC void mat4x4_perspective(mat4x4 m, float y_fov, float aspect, floa
m[3][2] = -((2.f * f * n) / (f - n)); m[3][2] = -((2.f * f * n) / (f - n));
m[3][3] = 0.f; m[3][3] = 0.f;
} }
LINMATH_H_FUNC void mat4x4_look_at(mat4x4 m, vec3 eye, vec3 center, vec3 up) LINMATH_H_FUNC void mat4x4_look_at(mat4x4 m, vec3 const eye, vec3 const center, vec3 const up)
{ {
/* Adapted from Android's OpenGL Matrix.java. */ /* Adapted from Android's OpenGL Matrix.java. */
/* See the OpenGL GLUT documentation for gluLookAt for a description */ /* See the OpenGL GLUT documentation for gluLookAt for a description */
@ -441,24 +444,18 @@ LINMATH_H_FUNC void mat4x4_look_at(mat4x4 m, vec3 eye, vec3 center, vec3 up)
} }
typedef float quat[4]; typedef float quat[4];
#define quat_add vec4_add
#define quat_sub vec4_sub
#define quat_norm vec4_norm
#define quat_scale vec4_scale
#define quat_mul_inner vec4_mul_inner
LINMATH_H_FUNC void quat_identity(quat q) LINMATH_H_FUNC void quat_identity(quat q)
{ {
q[0] = q[1] = q[2] = 0.f; q[0] = q[1] = q[2] = 0.f;
q[3] = 1.f; q[3] = 1.f;
} }
LINMATH_H_FUNC void quat_add(quat r, quat a, quat b) LINMATH_H_FUNC void quat_mul(quat r, quat const p, quat const q)
{
int i;
for(i=0; i<4; ++i)
r[i] = a[i] + b[i];
}
LINMATH_H_FUNC void quat_sub(quat r, quat a, quat b)
{
int i;
for(i=0; i<4; ++i)
r[i] = a[i] - b[i];
}
LINMATH_H_FUNC void quat_mul(quat r, quat p, quat q)
{ {
vec3 w; vec3 w;
vec3_mul_cross(r, p, q); vec3_mul_cross(r, p, q);
@ -468,37 +465,22 @@ LINMATH_H_FUNC void quat_mul(quat r, quat p, quat q)
vec3_add(r, r, w); vec3_add(r, r, w);
r[3] = p[3]*q[3] - vec3_mul_inner(p, q); r[3] = p[3]*q[3] - vec3_mul_inner(p, q);
} }
LINMATH_H_FUNC void quat_scale(quat r, quat v, float s) LINMATH_H_FUNC void quat_conj(quat r, quat const q)
{
int i;
for(i=0; i<4; ++i)
r[i] = v[i] * s;
}
LINMATH_H_FUNC float quat_inner_product(quat a, quat b)
{
float p = 0.f;
int i;
for(i=0; i<4; ++i)
p += b[i]*a[i];
return p;
}
LINMATH_H_FUNC void quat_conj(quat r, quat q)
{ {
int i; int i;
for(i=0; i<3; ++i) for(i=0; i<3; ++i)
r[i] = -q[i]; r[i] = -q[i];
r[3] = q[3]; r[3] = q[3];
} }
LINMATH_H_FUNC void quat_rotate(quat r, float angle, vec3 axis) { LINMATH_H_FUNC void quat_rotate(quat r, float angle, vec3 const axis) {
vec3 v; vec3 axis_norm;
vec3_scale(v, axis, sinf(angle / 2)); vec3_norm(axis_norm, axis);
int i; float s = sinf(angle / 2);
for(i=0; i<3; ++i) float c = cosf(angle / 2);
r[i] = v[i]; vec3_scale(r, axis_norm, s);
r[3] = cosf(angle / 2); r[3] = c;
} }
#define quat_norm vec4_norm LINMATH_H_FUNC void quat_mul_vec3(vec3 r, quat const q, vec3 const v)
LINMATH_H_FUNC void quat_mul_vec3(vec3 r, quat q, vec3 v)
{ {
/* /*
* Method by Fabian 'ryg' Giessen (of Farbrausch) * Method by Fabian 'ryg' Giessen (of Farbrausch)
@ -518,7 +500,7 @@ v' = v + q.w * t + cross(q.xyz, t)
vec3_add(r, v, t); vec3_add(r, v, t);
vec3_add(r, r, u); vec3_add(r, r, u);
} }
LINMATH_H_FUNC void mat4x4_from_quat(mat4x4 M, quat q) LINMATH_H_FUNC void mat4x4_from_quat(mat4x4 M, quat const q)
{ {
float a = q[3]; float a = q[3];
float b = q[0]; float b = q[0];
@ -548,18 +530,21 @@ LINMATH_H_FUNC void mat4x4_from_quat(mat4x4 M, quat q)
M[3][3] = 1.f; M[3][3] = 1.f;
} }
LINMATH_H_FUNC void mat4x4o_mul_quat(mat4x4 R, mat4x4 M, quat q) LINMATH_H_FUNC void mat4x4o_mul_quat(mat4x4 R, mat4x4 const M, quat const q)
{ {
/* XXX: The way this is written only works for othogonal matrices. */ /* XXX: The way this is written only works for orthogonal matrices. */
/* TODO: Take care of non-orthogonal case. */ /* TODO: Take care of non-orthogonal case. */
quat_mul_vec3(R[0], q, M[0]); quat_mul_vec3(R[0], q, M[0]);
quat_mul_vec3(R[1], q, M[1]); quat_mul_vec3(R[1], q, M[1]);
quat_mul_vec3(R[2], q, M[2]); quat_mul_vec3(R[2], q, M[2]);
R[3][0] = R[3][1] = R[3][2] = 0.f; R[3][0] = R[3][1] = R[3][2] = 0.f;
R[3][3] = 1.f; R[0][3] = M[0][3];
R[1][3] = M[1][3];
R[2][3] = M[2][3];
R[3][3] = M[3][3]; // typically 1.0, but here we make it general
} }
LINMATH_H_FUNC void quat_from_mat4x4(quat q, mat4x4 M) LINMATH_H_FUNC void quat_from_mat4x4(quat q, mat4x4 const M)
{ {
float r=0.f; float r=0.f;
int i; int i;
@ -589,13 +574,13 @@ LINMATH_H_FUNC void quat_from_mat4x4(quat q, mat4x4 M)
q[3] = (M[p[2]][p[1]] - M[p[1]][p[2]])/(2.f*r); q[3] = (M[p[2]][p[1]] - M[p[1]][p[2]])/(2.f*r);
} }
LINMATH_H_FUNC void mat4x4_arcball(mat4x4 R, mat4x4 M, vec2 _a, vec2 _b, float s) LINMATH_H_FUNC void mat4x4_arcball(mat4x4 R, mat4x4 const M, vec2 const _a, vec2 const _b, float s)
{ {
vec2 a; memcpy(a, _a, sizeof(a)); vec2 a; memcpy(a, _a, sizeof(a));
vec2 b; memcpy(b, _b, sizeof(b)); vec2 b; memcpy(b, _b, sizeof(b));
float z_a = 0.; float z_a = 0.f;
float z_b = 0.; float z_b = 0.f;
if(vec2_len(a) < 1.f) { if(vec2_len(a) < 1.f) {
z_a = sqrtf(1.f - vec2_mul_inner(a, a)); z_a = sqrtf(1.f - vec2_mul_inner(a, a));
@ -615,7 +600,7 @@ LINMATH_H_FUNC void mat4x4_arcball(mat4x4 R, mat4x4 M, vec2 _a, vec2 _b, float s
vec3 c_; vec3 c_;
vec3_mul_cross(c_, a_, b_); vec3_mul_cross(c_, a_, b_);
float const angle = acosf(vec3_mul_inner(a_, b_)) * s; float const angle = acos(vec3_mul_inner(a_, b_)) * s;
mat4x4_rotate(R, M, c_[0], c_[1], c_[2], angle); mat4x4_rotate(R, M, c_[0], c_[1], c_[2], angle);
} }
#endif #endif

View File

@ -24,7 +24,7 @@ section](https://discourse.glfw.org/c/support) of the forum, under the [Stack
Overflow tag](https://stackoverflow.com/questions/tagged/glfw) or [Game Overflow tag](https://stackoverflow.com/questions/tagged/glfw) or [Game
Development tag](https://gamedev.stackexchange.com/questions/tagged/glfw) on Development tag](https://gamedev.stackexchange.com/questions/tagged/glfw) on
Stack Exchange or in the IRC channel `#glfw` on Stack Exchange or in the IRC channel `#glfw` on
[Freenode](http://freenode.net/). [Libera.Chat](https://libera.chat/).
Questions about the design or implementation of GLFW or about future plans Questions about the design or implementation of GLFW or about future plans
should be asked in the [dev section](https://discourse.glfw.org/c/dev) of the should be asked in the [dev section](https://discourse.glfw.org/c/dev) of the

View File

@ -1074,13 +1074,6 @@ VERBATIM_HEADERS = YES
ALPHABETICAL_INDEX = YES ALPHABETICAL_INDEX = YES
# The COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns in
# which the alphabetical index list will be split.
# Minimum value: 1, maximum value: 20, default value: 5.
# This tag requires that the tag ALPHABETICAL_INDEX is set to YES.
COLS_IN_ALPHA_INDEX = 5
# In case all classes in a project start with a common prefix, all classes will # In case all classes in a project start with a common prefix, all classes will
# be put under the same header in the alphabetical index. The IGNORE_PREFIX tag # be put under the same header in the alphabetical index. The IGNORE_PREFIX tag
# can be used to specify a prefix (or a list of prefixes) that should be ignored # can be used to specify a prefix (or a list of prefixes) that should be ignored

View File

@ -1,11 +1,11 @@
# Support resources # Support resources
See the [latest documentation](http://www.glfw.org/docs/latest/) for tutorials, See the [latest documentation](https://www.glfw.org/docs/latest/) for tutorials,
guides and the API reference. guides and the API reference.
If you have questions about using GLFW, we have a If you have questions about using GLFW, we have a
[forum](https://discourse.glfw.org/), and the `#glfw` IRC channel on [forum](https://discourse.glfw.org/), and the `#glfw` IRC channel on
[Freenode](http://freenode.net/). [Libera.Chat](https://libera.chat/).
Bugs are reported to our [issue tracker](https://github.com/glfw/glfw/issues). Bugs are reported to our [issue tracker](https://github.com/glfw/glfw/issues).
Please check the [contribution Please check the [contribution

View File

@ -10,164 +10,171 @@ build applications that use GLFW, see @ref build_guide.
@section compile_cmake Using CMake @section compile_cmake Using CMake
@note GLFW behaves like most other libraries that use CMake so this guide mostly
describes the basic configure/generate/compile sequence. If you are already
familiar with this from other projects, you may want to focus on the @ref
compile_deps and @ref compile_options sections for GLFW-specific information.
GLFW uses [CMake](https://cmake.org/) to generate project files or makefiles GLFW uses [CMake](https://cmake.org/) to generate project files or makefiles
for a particular development environment. If you are on a Unix-like system such for your chosen development environment. To compile GLFW, first generate these
as Linux or FreeBSD or have a package system like Fink, MacPorts, Cygwin or files with CMake and then use them to compile the GLFW library.
Homebrew, you can install its CMake package. If not, you can download
installers for Windows and macOS from the
[CMake website](https://cmake.org/).
@note CMake only generates project files or makefiles. It does not compile the If you are on Windows and macOS you can
actual GLFW library. To compile GLFW, first generate these files for your [download CMake](https://cmake.org/download/) from their site.
chosen development environment and then use them to compile the actual GLFW
library. If you are on a Unix-like system such as Linux, FreeBSD or Cygwin or have
a package system like Fink, MacPorts or Homebrew, you can install its CMake
package.
CMake is a complex tool and this guide will only show a few of the possible ways
to set up and compile GLFW. The CMake project has their own much more detailed
[CMake user guide](https://cmake.org/cmake/help/latest/guide/user-interaction/)
that includes everything in this guide not specific to GLFW. It may be a useful
companion to this one.
@subsection compile_deps Dependencies @subsection compile_deps Installing dependencies
Once you have installed CMake, make sure that all other dependencies are The C/C++ development environments in Visual Studio, Xcode and MinGW come with
available. On some platforms, GLFW needs a few additional packages to be all necessary dependencies for compiling GLFW, but on Unix-like systems like
installed. See the section for your chosen platform and development environment Linux and FreeBSD you will need a few extra packages.
below.
@subsubsection compile_deps_msvc Dependencies for Visual C++ on Windows @subsubsection compile_deps_x11 Dependencies for X11 on Unix-like systems
The Windows SDK bundled with Visual C++ already contains all the necessary To compile GLFW for X11, you need to have the X11 development packages
headers, link libraries and tools except for CMake. Move on to @ref installed. They are not needed to build or run programs that use GLFW.
compile_generate.
On Debian and derivates like Ubuntu and Linux Mint the `xorg-dev` meta-package
@subsubsection compile_deps_mingw Dependencies for MinGW or MinGW-w64 on Windows pulls in the development packages for all of X11.
Both the MinGW and the MinGW-w64 packages already contain all the necessary
headers, link libraries and tools except for CMake. Move on to @ref
compile_generate.
@subsubsection compile_deps_mingw_cross Dependencies for MinGW or MinGW-w64 cross-compilation
Both Cygwin and many Linux distributions have MinGW or MinGW-w64 packages. For
example, Cygwin has the `mingw64-i686-gcc` and `mingw64-x86_64-gcc` packages
for 32- and 64-bit version of MinGW-w64, while Debian GNU/Linux and derivatives
like Ubuntu have the `mingw-w64` package for both.
GLFW has CMake toolchain files in the `CMake/` directory that set up
cross-compilation of Windows binaries. To use these files you add an option
when running `cmake` to generate the project files or makefiles:
@code{.sh} @code{.sh}
cmake -DCMAKE_TOOLCHAIN_FILE=<toolchain-file> . sudo apt install xorg-dev
@endcode @endcode
The exact toolchain file to use depends on the prefix used by the MinGW or On Fedora and derivatives like Red Hat the X11 extension packages
MinGW-w64 binaries on your system. You can usually see this in the /usr `libXcursor-devel`, `libXi-devel`, `libXinerama-devel` and `libXrandr-devel`
directory. For example, both the Debian/Ubuntu and Cygwin MinGW-w64 packages required by GLFW pull in all its other dependencies.
have `/usr/x86_64-w64-mingw32` for the 64-bit compilers, so the correct
invocation would be:
@code{.sh} @code{.sh}
cmake -DCMAKE_TOOLCHAIN_FILE=CMake/x86_64-w64-mingw32.cmake . sudo dnf install libXcursor-devel libXi-devel libXinerama-devel libXrandr-devel
@endcode @endcode
For more details see the article On FreeBSD the X11 headers are installed along the end-user X11 packages, so if
[CMake Cross Compiling](https://gitlab.kitware.com/cmake/community/wikis/doc/cmake/CrossCompiling) on you have an X server running you should have the headers as well. If not,
the CMake wiki. install the `xorgproto` package.
Once you have this set up, move on to @ref compile_generate. @code{.sh}
pkg install xorgproto
@endcode
On Cygwin the `xorgproto` package in the Devel section of the GUI installer will
install the headers and other development related files for all of X11.
Once you have the required depdendencies, move on to @ref compile_generate.
@subsubsection compile_deps_xcode Dependencies for Xcode on macOS @subsubsection compile_deps_wayland Dependencies for Wayland on Unix-like systems
Xcode comes with all necessary tools except for CMake. The required headers To compile GLFW for Wayland, you need to have the Wayland and xkbcommon
and libraries are included in the core macOS frameworks. Xcode can be development packages installed. They are not needed to build or run programs
downloaded from the Mac App Store or from the ADC Member Center. that use GLFW.
Once you have Xcode installed, move on to @ref compile_generate. On Debian and derivates like Ubuntu and Linux Mint you will need the
`libwayland-dev`, `libxkbcommon-dev` and `wayland-protocols` packages.
@code{.sh}
sudo apt install libwayland-dev libxkbcommon-dev wayland-protocols
@endcode
@subsubsection compile_deps_x11 Dependencies for Linux and X11 On Fedora and derivatives like Red Hat you will need the `wayland-devel`,
`libxkbcommon-devel` and `wayland-protocols-devel` packages.
To compile GLFW for X11, you need to have the X11 packages installed, as well as @code{.sh}
the basic development tools like GCC and make. For example, on Ubuntu and other sudo dnf install wayland-devel libxkbcommon-devel wayland-protocols-devel
distributions based on Debian GNU/Linux, you need to install the `xorg-dev` @endcode
package, which pulls in all X.org header packages.
Once you have installed the necessary packages, move on to @ref On FreeBSD you will need the `wayland`, `libxkbcommon` and `wayland-protocols`
compile_generate. packages.
@code{.sh}
pkg install wayland libxkbcommon wayland-protocols
@endcode
@subsubsection compile_deps_wayland Dependencies for Linux and Wayland Once you have the required depdendencies, move on to @ref compile_generate.
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
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
wayland-scanner, as well as the `wayland-protocols` package.
Once you have installed the necessary packages, move on to @ref
compile_generate.
@subsection compile_deps_osmesa Dependencies for Linux and OSMesa
To compile GLFW for OSMesa, you need to install the OSMesa library and header
packages. For example, on Ubuntu and other distributions based on Debian
GNU/Linux, you need to install the `libosmesa6-dev` package. The OSMesa library
is required at runtime for context creation and is loaded on demand.
Once you have installed the necessary packages, move on to @ref
compile_generate.
@subsection compile_generate Generating build files with CMake @subsection compile_generate Generating build files with CMake
Once you have all necessary dependencies it is time to generate the project Once you have all necessary dependencies it is time to generate the project
files or makefiles for your development environment. CMake needs to know two files or makefiles for your development environment. CMake needs two paths for
paths for this: the path to the _root_ directory of the GLFW source tree (i.e. this:
_not_ the `src` subdirectory) and the target path for the generated files and
compiled binaries. If these are the same, it is called an in-tree build,
otherwise it is called an out-of-tree build.
One of several advantages of out-of-tree builds is that you can generate files - the path to the root directory of the GLFW source tree (not its `src`
and compile for different development environments using a single source tree. subdirectory)
- the path to the directory where the generated build files and compiled
binaries will be placed
@note This section is about generating the project files or makefiles necessary If these are the same, it is called an in-tree build, otherwise it is called an
to compile the GLFW library, not about compiling the actual library. out-of-tree build.
Out-of-tree builds are recommended as they avoid cluttering up the source tree.
They also allow you to have several build directories for different
configurations all using the same source tree.
A common pattern when building a single configuration is to have a build
directory named `build` in the root of the source tree.
@subsubsection compile_generate_cli Generating files with the CMake command-line tool @subsubsection compile_generate_gui Generating files with the CMake GUI
To make an in-tree build, enter the _root_ directory of the GLFW source tree Start the CMake GUI and set the paths to the source and build directories
(i.e. _not_ the `src` subdirectory) and run CMake. The current directory is described above. Then press _Configure_ and _Generate_.
used as target path, while the path provided as an argument is used to find the
source tree.
@code{.sh} If you wish change any CMake variables in the list, press _Configure_ and then
cd <glfw-root-dir> _Generate_ to have the new values take effect. The variable list will be
cmake . populated after the first configure step.
@endcode
To make an out-of-tree build, make a directory outside of the source tree, enter By default GLFW will use X11 on Linux and other Unix-like systems other
it and run CMake with the (relative or absolute) path to the root of the source than macOS. To use Wayland instead, set the `GLFW_USE_WAYLAND` option in the
tree as an argument. GLFW section of the variable list, then apply the new value as described above.
@code{.sh}
mkdir glfw-build
cd glfw-build
cmake <glfw-root-dir>
@endcode
Once you have generated the project files or makefiles for your chosen Once you have generated the project files or makefiles for your chosen
development environment, move on to @ref compile_compile. development environment, move on to @ref compile_compile.
@subsubsection compile_generate_gui Generating files with the CMake GUI @subsubsection compile_generate_cli Generating files with the CMake command-line tool
If you are using the GUI version, choose the root of the GLFW source tree as To make a build directory, pass the source and build directories to the `cmake`
source location and the same directory or another, empty directory as the command. These can be relative or absolute paths. The build directory is
destination for binaries. Choose _Configure_, change any options you wish to, created if it doesn't already exist.
_Configure_ again to let the changes take effect and then _Generate_.
@code{.sh}
cmake -S path/to/glfw -B path/to/build
@endcode
It is common to name the build directory `build` and place it in the root of the
source tree when only planning to build a single configuration.
@code{.sh}
cd path/to/glfw
cmake -S . -B build
@endcode
Without other flags these will generate Visual Studio project files on Windows
and makefiles on other platforms. You can choose other targets using the `-G`
flag.
@code{.sh}
cmake -S path/to/glfw -B path/to/build -G Xcode
@endcode
By default GLFW will use X11 on Linux and other Unix-like systems other
than macOS. To use Wayland instead, set the `GLFW_USE_WAYLAND` CMake option.
@code{.sh}
cmake -S path/to/glfw -B path/to/build -D GLFW_USE_WAYLAND=1
@endcode
Once you have generated the project files or makefiles for your chosen Once you have generated the project files or makefiles for your chosen
development environment, move on to @ref compile_compile. development environment, move on to @ref compile_compile.
@ -177,13 +184,39 @@ development environment, move on to @ref compile_compile.
You should now have all required dependencies and the project files or makefiles You should now have all required dependencies and the project files or makefiles
necessary to compile GLFW. Go ahead and compile the actual GLFW library with necessary to compile GLFW. Go ahead and compile the actual GLFW library with
these files, as you would with any other project. these files as you would with any other project.
Once the GLFW library is compiled, you are ready to build your applications, With Visual Studio open `GLFW.sln` and use the Build menu. With Xcode open
`GLFW.xcodeproj` and use the Project menu.
With Linux, macOS and other forms of Unix, run `make`.
@code{.sh}
cd path/to/build
make
@endcode
With MinGW, it is `mingw32-make`.
@code{.sh}
cd path/to/build
mingw32-make
@endcode
Any CMake build directory can also be built with the `cmake` command and the
`--build` flag.
@code{.sh}
cmake --build path/to/build
@endcode
This will run the platform specific build tool the directory was generated for.
Once the GLFW library is compiled you are ready to build your application,
linking it to the GLFW library. See @ref build_guide for more information. linking it to the GLFW library. See @ref build_guide for more information.
@subsection compile_options CMake options @section compile_options CMake options
The CMake files for GLFW provide a number of options, although not all are The CMake files for GLFW provide a number of options, although not all are
available on all supported platforms. Some of these are de facto standards available on all supported platforms. Some of these are de facto standards
@ -199,55 +232,103 @@ Finally, if you don't want to use any GUI, you can set options from the `cmake`
command-line with the `-D` flag. command-line with the `-D` flag.
@code{.sh} @code{.sh}
cmake -DBUILD_SHARED_LIBS=ON . cmake -S path/to/glfw -B path/to/build -D BUILD_SHARED_LIBS=ON
@endcode @endcode
@subsubsection compile_options_shared Shared CMake options @subsection compile_options_shared Shared CMake options
@anchor BUILD_SHARED_LIBS @anchor BUILD_SHARED_LIBS
__BUILD_SHARED_LIBS__ determines whether GLFW is built as a static __BUILD_SHARED_LIBS__ determines whether GLFW is built as a static
library or as a DLL / shared library / dynamic library. library or as a DLL / shared library / dynamic library. This is disabled by
default, producing a static GLFW library.
@anchor GLFW_BUILD_EXAMPLES @anchor GLFW_BUILD_EXAMPLES
__GLFW_BUILD_EXAMPLES__ determines whether the GLFW examples are built __GLFW_BUILD_EXAMPLES__ determines whether the GLFW examples are built
along with the library. This is enabled by default unless GLFW is being built along with the library. This is enabled by default unless GLFW is being built
as a sub-project. as a sub-project of a larger CMake project.
@anchor GLFW_BUILD_TESTS @anchor GLFW_BUILD_TESTS
__GLFW_BUILD_TESTS__ determines whether the GLFW test programs are __GLFW_BUILD_TESTS__ determines whether the GLFW test programs are
built along with the library. This is enabled by default unless GLFW is being built along with the library. This is enabled by default unless GLFW is being
built as a sub-project. built as a sub-project of a larger CMake project.
@anchor GLFW_BUILD_DOCS @anchor GLFW_BUILD_DOCS
__GLFW_BUILD_DOCS__ determines whether the GLFW documentation is built along __GLFW_BUILD_DOCS__ determines whether the GLFW documentation is built along
with the library. with the library. This is enabled by default if
[Doxygen](https://www.doxygen.nl/) is found by CMake during configuration.
@anchor GLFW_VULKAN_STATIC @anchor GLFW_VULKAN_STATIC
__GLFW_VULKAN_STATIC__ determines whether to use the Vulkan loader linked __GLFW_VULKAN_STATIC__ determines whether to use the Vulkan loader linked
directly with the application. directly with the application. This is disabled by default.
@subsubsection compile_options_win32 Windows specific CMake options @subsection compile_options_win32 Windows specific CMake options
@anchor USE_MSVC_RUNTIME_LIBRARY_DLL @anchor USE_MSVC_RUNTIME_LIBRARY_DLL
__USE_MSVC_RUNTIME_LIBRARY_DLL__ determines whether to use the DLL version or the __USE_MSVC_RUNTIME_LIBRARY_DLL__ determines whether to use the DLL version or the
static library version of the Visual C++ runtime library. If set to `ON`, the static library version of the Visual C++ runtime library. When enabled, the
DLL version of the Visual C++ library is used. DLL version of the Visual C++ library is used. This is enabled by default.
On CMake 3.15 and later you can set the standard CMake
[CMAKE_MSVC_RUNTIME_LIBRARY](https://cmake.org/cmake/help/latest/variable/CMAKE_MSVC_RUNTIME_LIBRARY.html)
variable instead of this GLFW-specific option.
@anchor GLFW_USE_HYBRID_HPG @anchor GLFW_USE_HYBRID_HPG
__GLFW_USE_HYBRID_HPG__ determines whether to export the `NvOptimusEnablement` and __GLFW_USE_HYBRID_HPG__ determines whether to export the `NvOptimusEnablement` and
`AmdPowerXpressRequestHighPerformance` symbols, which force the use of the `AmdPowerXpressRequestHighPerformance` symbols, which force the use of the
high-performance GPU on Nvidia Optimus and AMD PowerXpress systems. These symbols high-performance GPU on Nvidia Optimus and AMD PowerXpress systems. These symbols
need to be exported by the EXE to be detected by the driver, so the override need to be exported by the EXE to be detected by the driver, so the override
will not work if GLFW is built as a DLL. will not work if GLFW is built as a DLL. This is disabled by default, letting
the operating system and driver decide.
@subsection compile_options_wayland Wayland specific CMake options
@anchor GLFW_USE_WAYLAND
__GLFW_USE_WAYLAND__ determines whether to compile the library for Wayland.
This option is only available on Linux and other Unix-like systems other than
macOS. This is disabled by default.
@section compile_mingw_cross Cross-compilation with CMake and MinGW
Both Cygwin and many Linux distributions have MinGW or MinGW-w64 packages. For
example, Cygwin has the `mingw64-i686-gcc` and `mingw64-x86_64-gcc` packages
for 32- and 64-bit version of MinGW-w64, while Debian GNU/Linux and derivatives
like Ubuntu have the `mingw-w64` package for both.
GLFW has CMake toolchain files in the `CMake` subdirectory that set up
cross-compilation of Windows binaries. To use these files you set the
`CMAKE_TOOLCHAIN_FILE` CMake variable with the `-D` flag add an option when
configuring and generating the build files.
@code{.sh}
cmake -S path/to/glfw -B path/to/build -D CMAKE_TOOLCHAIN_FILE=path/to/file
@endcode
The exact toolchain file to use depends on the prefix used by the MinGW or
MinGW-w64 binaries on your system. You can usually see this in the /usr
directory. For example, both the Ubuntu and Cygwin MinGW-w64 packages have
`/usr/x86_64-w64-mingw32` for the 64-bit compilers, so the correct invocation
would be:
@code{.sh}
cmake -S path/to/glfw -B path/to/build -D CMAKE_TOOLCHAIN_FILE=CMake/x86_64-w64-mingw32.cmake
@endcode
The path to the toolchain file is relative to the path to the GLFW source tree
passed to the `-S` flag, not to the current directory.
For more details see the
[CMake toolchain guide](https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html).
@section compile_manual Compiling GLFW manually @section compile_manual Compiling GLFW manually
If you wish to compile GLFW without its CMake build environment then you will If you wish to compile GLFW without its CMake build environment then you will
have to do at least some of the platform detection yourself. GLFW needs have to do at least some of the platform detection yourself. GLFW needs
a configuration macro to be defined in order to know what window system it's a configuration macro to be defined in order to know what window system it is
being compiled for and also has optional, platform-specific ones for various being compiled for and also has optional, platform-specific ones for various
features. features.
@ -279,11 +360,6 @@ of @b _GLFW_VULKAN_LIBRARY, @b _GLFW_EGL_LIBRARY, @b _GLFW_GLX_LIBRARY, @b
_GLFW_OSMESA_LIBRARY, @b _GLFW_OPENGL_LIBRARY, @b _GLFW_GLESV1_LIBRARY and @b _GLFW_OSMESA_LIBRARY, @b _GLFW_OPENGL_LIBRARY, @b _GLFW_GLESV1_LIBRARY and @b
_GLFW_GLESV2_LIBRARY. Otherwise, GLFW will use the built-in default names. _GLFW_GLESV2_LIBRARY. Otherwise, GLFW will use the built-in default names.
For the EGL context creation API, the following options are available:
- @b _GLFW_USE_EGLPLATFORM_H to use an existing `EGL/eglplatform.h` header file
for native handle types (fallback)
@note None of the @ref build_macros may be defined during the compilation of @note None of the @ref build_macros may be defined during the compilation of
GLFW. If you define any of these in your build files, make sure they are not GLFW. If you define any of these in your build files, make sure they are not
applied to the GLFW sources. applied to the GLFW sources.

View File

@ -138,9 +138,9 @@ as extensions until they become obsolete.
An extension is defined by: An extension is defined by:
- An extension name (e.g. `GL_ARB_debug_output`) - An extension name (e.g. `GL_ARB_gl_spirv`)
- New OpenGL tokens (e.g. `GL_DEBUG_SEVERITY_HIGH_ARB`) - New OpenGL tokens (e.g. `GL_SPIR_V_BINARY_ARB`)
- New OpenGL functions (e.g. `glGetDebugMessageLogARB`) - New OpenGL functions (e.g. `glSpecializeShaderARB`)
Note the `ARB` affix, which stands for Architecture Review Board and is used Note the `ARB` affix, which stands for Architecture Review Board and is used
for official extensions. The extension above was created by the ARB, but there for official extensions. The extension above was created by the ARB, but there
@ -225,9 +225,9 @@ To check whether a specific extension is supported, use the `GLAD_GL_xxx`
booleans. booleans.
@code @code
if (GLAD_GL_ARB_debug_output) if (GLAD_GL_ARB_gl_spirv)
{ {
// Use GL_ARB_debug_output // Use GL_ARB_gl_spirv
} }
@endcode @endcode
@ -259,8 +259,8 @@ included in your development environment may be several years out of date and
may not include the extensions you wish to use. may not include the extensions you wish to use.
The header defines function pointer types for all functions of all extensions it The header defines function pointer types for all functions of all extensions it
supports. These have names like `PFNGLGETDEBUGMESSAGELOGARBPROC` (for supports. These have names like `PFNGLSPECIALIZESHADERARBPROC` (for
`glGetDebugMessageLogARB`), i.e. the name is made uppercase and `PFN` (pointer `glSpecializeShaderARB`), i.e. the name is made uppercase and `PFN` (pointer
to function) and `PROC` (procedure) are added to the ends. to function) and `PROC` (procedure) are added to the ends.
To include the extension header, define @ref GLFW_INCLUDE_GLEXT before including To include the extension header, define @ref GLFW_INCLUDE_GLEXT before including
@ -280,7 +280,7 @@ is necessary to check at run-time whether the context supports the extension.
This is done with @ref glfwExtensionSupported. This is done with @ref glfwExtensionSupported.
@code @code
if (glfwExtensionSupported("GL_ARB_debug_output")) if (glfwExtensionSupported("GL_ARB_gl_spirv"))
{ {
// The extension is supported by the current context // The extension is supported by the current context
} }
@ -299,7 +299,7 @@ your operating system, making it necessary to fetch them at run time. You can
retrieve pointers to these functions with @ref glfwGetProcAddress. retrieve pointers to these functions with @ref glfwGetProcAddress.
@code @code
PFNGLGETDEBUGMESSAGELOGARBPROC pfnGetDebugMessageLog = glfwGetProcAddress("glGetDebugMessageLogARB"); PFNGLSPECIALIZESHADERARBPROC pfnSpecializeShaderARB = glfwGetProcAddress("glSpecializeShaderARB");
@endcode @endcode
In general, you should avoid giving the function pointer variables the (exact) In general, you should avoid giving the function pointer variables the (exact)
@ -313,28 +313,28 @@ when used together.
#define GLFW_INCLUDE_GLEXT #define GLFW_INCLUDE_GLEXT
#include <GLFW/glfw3.h> #include <GLFW/glfw3.h>
#define glGetDebugMessageLogARB pfnGetDebugMessageLog #define glSpecializeShaderARB pfnSpecializeShaderARB
PFNGLGETDEBUGMESSAGELOGARBPROC pfnGetDebugMessageLog; PFNGLSPECIALIZESHADERARBPROC pfnSpecializeShaderARB;
// Flag indicating whether the extension is supported // Flag indicating whether the extension is supported
int has_ARB_debug_output = 0; int has_ARB_gl_spirv = 0;
void load_extensions(void) void load_extensions(void)
{ {
if (glfwExtensionSupported("GL_ARB_debug_output")) if (glfwExtensionSupported("GL_ARB_gl_spirv"))
{ {
pfnGetDebugMessageLog = (PFNGLGETDEBUGMESSAGELOGARBPROC) pfnSpecializeShaderARB = (PFNGLSPECIALIZESHADERARBPROC)
glfwGetProcAddress("glGetDebugMessageLogARB"); glfwGetProcAddress("glSpecializeShaderARB");
has_ARB_debug_output = 1; has_ARB_gl_spirv = 1;
} }
} }
void some_function(void) void some_function(void)
{ {
if (has_ARB_debug_output) if (has_ARB_gl_spirv)
{ {
// Now the extension function can be called as usual // Now the extension function can be called as usual
glGetDebugMessageLogARB(...); glSpecializeShaderARB(...);
} }
} }
@endcode @endcode

View File

@ -797,6 +797,11 @@ glfwUpdateGamepadMappings(mappings);
This function supports everything from single lines up to and including the This function supports everything from single lines up to and including the
unmodified contents of the whole `gamecontrollerdb.txt` file. unmodified contents of the whole `gamecontrollerdb.txt` file.
If you are compiling GLFW from source with CMake you can update the built-in mappings by
building the _update_mappings_ target. This runs the `GenerateMappings.cmake` CMake
script, which downloads `gamecontrollerdb.txt` and regenerates the `mappings.h` header
file.
Below is a description of the mapping format. Please keep in mind that __this Below is a description of the mapping format. Please keep in mind that __this
description is not authoritative__. The format is defined by the SDL and description is not authoritative__. The format is defined by the SDL and
SDL_GameControllerDB projects and their documentation and code takes precedence. SDL_GameControllerDB projects and their documentation and code takes precedence.

View File

@ -103,7 +103,6 @@ one of `GLFW_ANGLE_PLATFORM_TYPE_NONE`, `GLFW_ANGLE_PLATFORM_TYPE_OPENGL`,
`GLFW_ANGLE_PLATFORM_TYPE_D3D11`, `GLFW_ANGLE_PLATFORM_TYPE_VULKAN` and `GLFW_ANGLE_PLATFORM_TYPE_D3D11`, `GLFW_ANGLE_PLATFORM_TYPE_VULKAN` and
`GLFW_ANGLE_PLATFORM_TYPE_METAL`. `GLFW_ANGLE_PLATFORM_TYPE_METAL`.
@par
The ANGLE platform type is specified via the `EGL_ANGLE_platform_angle` The ANGLE platform type is specified via the `EGL_ANGLE_platform_angle`
extension. This extension is not used if this hint is extension. This extension is not used if this hint is
`GLFW_ANGLE_PLATFORM_TYPE_NONE`, which is the default value. `GLFW_ANGLE_PLATFORM_TYPE_NONE`, which is the default value.
@ -124,14 +123,24 @@ a nib or manually by GLFW. Possible values are `GLFW_TRUE` and `GLFW_FALSE`.
This is ignored on other platforms. This is ignored on other platforms.
@subsubsection init_hints_x11 X11 specific init hints
@anchor GLFW_X11_XCB_VULKAN_SURFACE_hint
__GLFW_X11_XCB_VULKAN_SURFACE__ specifies whether to prefer the
`VK_KHR_xcb_surface` extension for creating Vulkan surfaces, or whether to use
the `VK_KHR_xlib_surface` extension. Possible values are `GLFW_TRUE` and
`GLFW_FALSE`. 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_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`
@ref GLFW_X11_XCB_VULKAN_SURFACE | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE`
@subsection intro_init_terminate Terminating GLFW @subsection intro_init_terminate Terminating GLFW

View File

@ -142,6 +142,7 @@ then GLFW will fail to initialize.
- @ref GLFW_ANGLE_PLATFORM_TYPE_D3D11 - @ref GLFW_ANGLE_PLATFORM_TYPE_D3D11
- @ref GLFW_ANGLE_PLATFORM_TYPE_VULKAN - @ref GLFW_ANGLE_PLATFORM_TYPE_VULKAN
- @ref GLFW_ANGLE_PLATFORM_TYPE_METAL - @ref GLFW_ANGLE_PLATFORM_TYPE_METAL
- @ref GLFW_X11_XCB_VULKAN_SURFACE
@section news_archive Release notes for earlier versions @section news_archive Release notes for earlier versions

View File

@ -236,7 +236,8 @@ does not affect window decorations. Possible values are `GLFW_TRUE` and
@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`.
@anchor GLFW_SCALE_TO_MONITOR @anchor GLFW_SCALE_TO_MONITOR
__GLFW_SCALE_TO_MONITOR__ specified whether the window content area should be __GLFW_SCALE_TO_MONITOR__ specified whether the window content area should be
@ -278,7 +279,6 @@ __GLFW_ACCUM_ALPHA_BITS__ specify the desired bit depths of the various
components of the accumulation buffer. A value of `GLFW_DONT_CARE` means the components of the accumulation buffer. A value of `GLFW_DONT_CARE` means the
application has no preference. application has no preference.
@par
Accumulation buffers are a legacy OpenGL feature and should not be used in new Accumulation buffers are a legacy OpenGL feature and should not be used in new
code. code.
@ -286,7 +286,6 @@ code.
__GLFW_AUX_BUFFERS__ specifies the desired number of auxiliary buffers. A value __GLFW_AUX_BUFFERS__ specifies the desired number of auxiliary buffers. A value
of `GLFW_DONT_CARE` means the application has no preference. of `GLFW_DONT_CARE` means the application has no preference.
@par
Auxiliary buffers are a legacy OpenGL feature and should not be used in new Auxiliary buffers are a legacy OpenGL feature and should not be used in new
code. code.
@ -303,16 +302,15 @@ the application has no preference.
__GLFW_SRGB_CAPABLE__ specifies whether the framebuffer should be sRGB capable. __GLFW_SRGB_CAPABLE__ specifies whether the framebuffer should be sRGB capable.
Possible values are `GLFW_TRUE` and `GLFW_FALSE`. Possible values are `GLFW_TRUE` and `GLFW_FALSE`.
@par @note __OpenGL:__ If enabled and supported by the system, the
__OpenGL:__ If enabled and supported by the system, the `GL_FRAMEBUFFER_SRGB` `GL_FRAMEBUFFER_SRGB` enable will control sRGB rendering. By default, sRGB
enable will control sRGB rendering. By default, sRGB rendering will be rendering will be disabled.
disabled.
@par @note __OpenGL ES:__ If enabled and supported by the system, the context will
__OpenGL ES:__ If enabled and supported by the system, the context will always always have sRGB rendering enabled.
have sRGB rendering enabled.
@anchor GLFW_DOUBLEBUFFER @anchor GLFW_DOUBLEBUFFER
@anchor GLFW_DOUBLEBUFFER_hint
__GLFW_DOUBLEBUFFER__ specifies whether the framebuffer should be double __GLFW_DOUBLEBUFFER__ specifies whether the framebuffer should be double
buffered. You nearly always want to use double buffering. This is a hard buffered. You nearly always want to use double buffering. This is a hard
constraint. Possible values are `GLFW_TRUE` and `GLFW_FALSE`. constraint. Possible values are `GLFW_TRUE` and `GLFW_FALSE`.
@ -339,28 +337,22 @@ create the context. Possible values are `GLFW_NATIVE_CONTEXT_API`,
`GLFW_EGL_CONTEXT_API` and `GLFW_OSMESA_CONTEXT_API`. This is a hard `GLFW_EGL_CONTEXT_API` and `GLFW_OSMESA_CONTEXT_API`. This is a hard
constraint. If no client API is requested, this hint is ignored. constraint. If no client API is requested, this hint is ignored.
@par An [extension loader library](@ref context_glext_auto) that assumes it knows
@macos The EGL API is not available on this platform and requests to use it which API was used to create the current context may fail if you change this
will fail. hint. This can be resolved by having it load functions via @ref
glfwGetProcAddress.
@par @note @wayland The EGL API _is_ the native context creation API, so this hint
__Wayland:__ The EGL API _is_ the native context creation API, so this hint
will have no effect. will have no effect.
@par @note @x11 On some Linux systems, creating contexts via both the native and EGL
__OSMesa:__ As its name implies, an OpenGL context created with OSMesa does not APIs in a single process will cause the application to segfault. Stick to one
update the window contents when its buffers are swapped. Use OpenGL functions API or the other on Linux for now.
or the OSMesa native access functions @ref glfwGetOSMesaColorBuffer and @ref
glfwGetOSMesaDepthBuffer to retrieve the framebuffer contents.
@note An OpenGL extension loader library that assumes it knows which context @note __OSMesa:__ As its name implies, an OpenGL context created with OSMesa
creation API is used on a given platform may fail if you change this hint. This does not update the window contents when its buffers are swapped. Use OpenGL
can be resolved by having it load via @ref glfwGetProcAddress, which always uses functions or the OSMesa native access functions @ref glfwGetOSMesaColorBuffer
the selected API. and @ref glfwGetOSMesaDepthBuffer to retrieve the framebuffer contents.
@bug On some Linux systems, creating contexts via both the native and EGL APIs
in a single process will cause the application to segfault. Stick to one API or
the other on Linux for now.
@anchor GLFW_CONTEXT_VERSION_MAJOR_hint @anchor GLFW_CONTEXT_VERSION_MAJOR_hint
@anchor GLFW_CONTEXT_VERSION_MINOR_hint @anchor GLFW_CONTEXT_VERSION_MINOR_hint
@ -368,27 +360,24 @@ __GLFW_CONTEXT_VERSION_MAJOR__ and __GLFW_CONTEXT_VERSION_MINOR__ specify the
client API version that the created context must be compatible with. The exact client API version that the created context must be compatible with. The exact
behavior of these hints depend on the requested client API. behavior of these hints depend on the requested client API.
@note Do not confuse these hints with `GLFW_VERSION_MAJOR` and
`GLFW_VERSION_MINOR`, which provide the API version of the GLFW header.
@par
__OpenGL:__ These hints are not hard constraints, but creation will fail if the
OpenGL version of the created context is less than the one requested. It is
therefore perfectly safe to use the default of version 1.0 for legacy code and
you will still get backwards-compatible contexts of version 3.0 and above when
available.
@par
While there is no way to ask the driver for a context of the highest supported While there is no way to ask the driver for a context of the highest supported
version, GLFW will attempt to provide this when you ask for a version 1.0 version, GLFW will attempt to provide this when you ask for a version 1.0
context, which is the default for these hints. context, which is the default for these hints.
@par Do not confuse these hints with @ref GLFW_VERSION_MAJOR and @ref
__OpenGL ES:__ These hints are not hard constraints, but creation will fail if GLFW_VERSION_MINOR, which provide the API version of the GLFW header.
the OpenGL ES version of the created context is less than the one requested.
Additionally, OpenGL ES 1.x cannot be returned if 2.0 or later was requested, @note __OpenGL:__ These hints are not hard constraints, but creation will fail
and vice versa. This is because OpenGL ES 3.x is backward compatible with 2.0, if the OpenGL version of the created context is less than the one requested. It
but OpenGL ES 2.0 is not backward compatible with 1.x. is therefore perfectly safe to use the default of version 1.0 for legacy code
and you will still get backwards-compatible contexts of version 3.0 and above
when available.
@note __OpenGL ES:__ These hints are not hard constraints, but creation will
fail if the OpenGL ES version of the created context is less than the one
requested. Additionally, OpenGL ES 1.x cannot be returned if 2.0 or later was
requested, and vice versa. This is because OpenGL ES 3.x is backward compatible
with 2.0, but OpenGL ES 2.0 is not backward compatible with 1.x.
@note @macos The OS only supports core profile contexts for OpenGL versions 3.2 @note @macos The OS only supports core profile contexts for OpenGL versions 3.2
and later. Before creating an OpenGL context of version 3.2 or later you must and later. Before creating an OpenGL context of version 3.2 or later you must
@ -401,7 +390,6 @@ forward-compatible, i.e. one where all functionality deprecated in the requested
version of OpenGL is removed. This must only be used if the requested OpenGL version of OpenGL is removed. This must only be used if the requested OpenGL
version is 3.0 or above. If OpenGL ES is requested, this hint is ignored. version is 3.0 or above. If OpenGL ES is requested, this hint is ignored.
@par
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/).
@ -411,13 +399,11 @@ __GLFW_CONTEXT_DEBUG__ specifies whether the context should be created in debug
mode, which may provide additional error and diagnostic reporting functionality. mode, which may provide additional error and diagnostic reporting functionality.
Possible values are `GLFW_TRUE` and `GLFW_FALSE`. Possible values are `GLFW_TRUE` and `GLFW_FALSE`.
@par
Debug contexts for OpenGL and OpenGL ES are described in detail by the 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) [GL_KHR_debug](https://www.khronos.org/registry/OpenGL/extensions/KHR/KHR_debug.txt)
extension. extension.
@par @note `GLFW_CONTEXT_DEBUG` is the new name introduced in GLFW 3.4. The older
This is the new name, introduced in GLFW 3.4. The older
`GLFW_OPENGL_DEBUG_CONTEXT` name is also available for compatibility. `GLFW_OPENGL_DEBUG_CONTEXT` name is also available for compatibility.
@anchor GLFW_OPENGL_PROFILE_hint @anchor GLFW_OPENGL_PROFILE_hint
@ -428,7 +414,6 @@ a specific profile. If requesting an OpenGL version below 3.2,
`GLFW_OPENGL_ANY_PROFILE` must be used. If OpenGL ES is requested, this hint `GLFW_OPENGL_ANY_PROFILE` must be used. If OpenGL ES is requested, this hint
is ignored. is ignored.
@par
OpenGL profiles are described in detail in the OpenGL profiles are described in detail in the
[OpenGL Reference Manual](https://www.opengl.org/registry/). [OpenGL Reference Manual](https://www.opengl.org/registry/).
@ -448,7 +433,6 @@ the pipeline will be flushed whenever the context is released from being the
current one. If the behavior is `GLFW_RELEASE_BEHAVIOR_NONE`, the pipeline will current one. If the behavior is `GLFW_RELEASE_BEHAVIOR_NONE`, the pipeline will
not be flushed on release. not be flushed on release.
@par
Context release behaviors are described in detail by the Context release behaviors are described in detail by the
[GL_KHR_context_flush_control](https://www.opengl.org/registry/specs/KHR/context_flush_control.txt) [GL_KHR_context_flush_control](https://www.opengl.org/registry/specs/KHR/context_flush_control.txt)
extension. extension.
@ -458,7 +442,6 @@ __GLFW_CONTEXT_NO_ERROR__ specifies whether errors should be generated by the
context. Possible values are `GLFW_TRUE` and `GLFW_FALSE`. If enabled, context. Possible values are `GLFW_TRUE` and `GLFW_FALSE`. If enabled,
situations that would have generated errors instead cause undefined behavior. situations that would have generated errors instead cause undefined behavior.
@par
The no error mode for OpenGL and OpenGL ES is described in detail by the The no error mode for OpenGL and OpenGL ES is described in detail by the
[GL_KHR_no_error](https://www.opengl.org/registry/specs/KHR/no_error.txt) [GL_KHR_no_error](https://www.opengl.org/registry/specs/KHR/no_error.txt)
extension. extension.
@ -492,12 +475,10 @@ run on the discrete GPU. This only affects systems with both integrated and
discrete GPUs. Possible values are `GLFW_TRUE` and `GLFW_FALSE`. This is discrete GPUs. Possible values are `GLFW_TRUE` and `GLFW_FALSE`. This is
ignored on other platforms. ignored on other platforms.
@par
Simpler programs and tools may want to enable this to save power, while games Simpler programs and tools may want to enable this to save power, while games
and other applications performing advanced rendering will want to leave it and other applications performing advanced rendering will want to leave it
disabled. disabled.
@par
A bundled application that wishes to participate in Automatic Graphics Switching A bundled application that wishes to participate in Automatic Graphics Switching
should also declare this in its `Info.plist` by setting the should also declare this in its `Info.plist` by setting the
`NSSupportsAutomaticGraphicsSwitching` key to `true`. `NSSupportsAutomaticGraphicsSwitching` key to `true`.
@ -1397,9 +1378,11 @@ if the window's context supports robustness, or `GLFW_NO_ROBUSTNESS` otherwise.
@subsubsection window_attribs_fb Framebuffer related attributes @subsubsection window_attribs_fb Framebuffer related attributes
GLFW does not expose attributes of the default framebuffer (i.e. the framebuffer GLFW does not expose most attributes of the default framebuffer (i.e. the
attached to the window) as these can be queried directly with either OpenGL, framebuffer attached to the window) as these can be queried directly with either
OpenGL ES or Vulkan. OpenGL, OpenGL ES or Vulkan. The one exception is
[GLFW_DOUBLEBUFFER](@ref GLFW_DOUBLEBUFFER_attrib), as this is not provided by
OpenGL ES.
If you are using version 3.0 or later of OpenGL or OpenGL ES, the If you are using version 3.0 or later of OpenGL or OpenGL ES, the
`glGetFramebufferAttachmentParameteriv` function can be used to retrieve the `glGetFramebufferAttachmentParameteriv` function can be used to retrieve the
@ -1425,6 +1408,11 @@ alpha sizes are queried from the `GL_BACK_LEFT`, while the depth and stencil
sizes are queried from the `GL_DEPTH` and `GL_STENCIL` attachments, sizes are queried from the `GL_DEPTH` and `GL_STENCIL` attachments,
respectively. respectively.
@anchor GLFW_DOUBLEBUFFER_attrib
__GLFW_DOUBLEBUFFER__ indicates whether the specified window is double-buffered
when rendering with OpenGL or OpenGL ES. This can be set before creation with
the [GLFW_DOUBLEBUFFER](@ref GLFW_DOUBLEBUFFER_hint) window hint.
@section buffer_swap Buffer swapping @section buffer_swap Buffer swapping

View File

@ -7,7 +7,8 @@ if (MATH_LIBRARY)
link_libraries("${MATH_LIBRARY}") link_libraries("${MATH_LIBRARY}")
endif() endif()
if (MSVC) # Workaround for the MS CRT deprecating parts of the standard library
if (MSVC OR CMAKE_C_SIMULATE_ID STREQUAL "MSVC")
add_definitions(-D_CRT_SECURE_NO_WARNINGS) add_definitions(-D_CRT_SECURE_NO_WARNINGS)
endif() endif()
@ -54,9 +55,13 @@ if (GLFW_USE_OSMESA)
endif() endif()
if (MSVC) if (MSVC)
# Tell MSVC to use main instead of WinMain for Windows subsystem executables # Tell MSVC to use main instead of WinMain
set_target_properties(${GUI_ONLY_BINARIES} PROPERTIES set_target_properties(${GUI_ONLY_BINARIES} PROPERTIES
LINK_FLAGS "/ENTRY:mainCRTStartup") LINK_FLAGS "/ENTRY:mainCRTStartup")
elseif (CMAKE_C_SIMULATE_ID STREQUAL "MSVC")
# Tell Clang using MS CRT to use main instead of WinMain
set_target_properties(${GUI_ONLY_BINARIES} PROPERTIES
LINK_FLAGS "-Wl,/entry:mainCRTStartup")
endif() endif()
if (APPLE) if (APPLE)

View File

@ -292,12 +292,12 @@ static void generate_heightmap__circle(float* center_x, float* center_y,
{ {
float sign; float sign;
/* random value for element in between [0-1.0] */ /* random value for element in between [0-1.0] */
*center_x = (MAP_SIZE * rand()) / (1.0f * RAND_MAX); *center_x = (MAP_SIZE * rand()) / (float) RAND_MAX;
*center_y = (MAP_SIZE * rand()) / (1.0f * RAND_MAX); *center_y = (MAP_SIZE * rand()) / (float) RAND_MAX;
*size = (MAX_CIRCLE_SIZE * rand()) / (1.0f * RAND_MAX); *size = (MAX_CIRCLE_SIZE * rand()) / (float) RAND_MAX;
sign = (1.0f * rand()) / (1.0f * RAND_MAX); sign = (1.0f * rand()) / (float) RAND_MAX;
sign = (sign < DISPLACEMENT_SIGN_LIMIT) ? -1.0f : 1.0f; sign = (sign < DISPLACEMENT_SIGN_LIMIT) ? -1.0f : 1.0f;
*displacement = (sign * (MAX_DISPLACEMENT * rand())) / (1.0f * RAND_MAX); *displacement = (sign * (MAX_DISPLACEMENT * rand())) / (float) RAND_MAX;
} }
/* Run the specified number of iterations of the generation process for the /* Run the specified number of iterations of the generation process for the

View File

@ -276,23 +276,24 @@ extern "C" {
/*! @name GLFW version macros /*! @name GLFW version macros
* @{ */ * @{ */
/*! @brief The major version number of the GLFW library. /*! @brief The major version number of the GLFW header.
* *
* This is incremented when the API is changed in non-compatible ways. * The major version number of the GLFW header. This is incremented when the
* API is changed in non-compatible ways.
* @ingroup init * @ingroup init
*/ */
#define GLFW_VERSION_MAJOR 3 #define GLFW_VERSION_MAJOR 3
/*! @brief The minor version number of the GLFW library. /*! @brief The minor version number of the GLFW header.
* *
* This is incremented when features are added to the API but it remains * The minor version number of the GLFW header. This is incremented when
* backward-compatible. * features are added to the API but it remains backward-compatible.
* @ingroup init * @ingroup init
*/ */
#define GLFW_VERSION_MINOR 4 #define GLFW_VERSION_MINOR 4
/*! @brief The revision number of the GLFW library. /*! @brief The revision number of the GLFW header.
* *
* This is incremented when a bug fix release is made that does not contain any * The revision number of the GLFW header. This is incremented when a bug fix
* API changes. * release is made that does not contain any API changes.
* @ingroup init * @ingroup init
*/ */
#define GLFW_VERSION_REVISION 0 #define GLFW_VERSION_REVISION 0
@ -977,9 +978,10 @@ extern "C" {
* Monitor refresh rate [hint](@ref GLFW_REFRESH_RATE). * Monitor refresh rate [hint](@ref GLFW_REFRESH_RATE).
*/ */
#define GLFW_REFRESH_RATE 0x0002100F #define GLFW_REFRESH_RATE 0x0002100F
/*! @brief Framebuffer double buffering hint. /*! @brief Framebuffer double buffering hint and attribute.
* *
* Framebuffer double buffering [hint](@ref GLFW_DOUBLEBUFFER). * Framebuffer double buffering [hint](@ref GLFW_DOUBLEBUFFER_hint) and
* [attribute](@ref GLFW_DOUBLEBUFFER_attrib).
*/ */
#define GLFW_DOUBLEBUFFER 0x00021010 #define GLFW_DOUBLEBUFFER 0x00021010
@ -1250,6 +1252,11 @@ extern "C" {
* macOS specific [init hint](@ref GLFW_COCOA_MENUBAR_hint). * macOS specific [init hint](@ref GLFW_COCOA_MENUBAR_hint).
*/ */
#define GLFW_COCOA_MENUBAR 0x00051002 #define GLFW_COCOA_MENUBAR 0x00051002
/*! @brief X11 specific init hint.
*
* X11 specific [init hint](@ref GLFW_X11_XCB_VULKAN_SURFACE_hint).
*/
#define GLFW_X11_XCB_VULKAN_SURFACE 0x00052001
/*! @} */ /*! @} */
#define GLFW_DONT_CARE -1 #define GLFW_DONT_CARE -1
@ -2417,8 +2424,9 @@ GLFWAPI GLFWmonitorfun glfwSetMonitorCallback(GLFWmonitorfun callback);
* *
* This function returns an array of all video modes supported by the specified * This function returns an array of all video modes supported by the specified
* monitor. The returned array is sorted in ascending order, first by color * monitor. The returned array is sorted in ascending order, first by color
* bit depth (the sum of all channel depths) and then by resolution area (the * bit depth (the sum of all channel depths), then by resolution area (the
* product of width and height). * product of width and height), then resolution width and finally by refresh
* rate.
* *
* @param[in] monitor The monitor to query. * @param[in] monitor The monitor to query.
* @param[out] count Where to store the number of video modes in the returned * @param[out] count Where to store the number of video modes in the returned
@ -5865,9 +5873,8 @@ GLFWAPI int glfwVulkanSupported(void);
* returned array, as it is an error to specify an extension more than once in * returned array, as it is an error to specify an extension more than once in
* the `VkInstanceCreateInfo` struct. * the `VkInstanceCreateInfo` struct.
* *
* @remark @macos This function currently supports either the * @remark @macos GLFW currently supports both the `VK_MVK_macos_surface` and
* `VK_MVK_macos_surface` extension from MoltenVK or `VK_EXT_metal_surface` * the newer `VK_EXT_metal_surface` extensions.
* extension.
* *
* @pointer_lifetime The returned array is allocated and freed by GLFW. You * @pointer_lifetime The returned array is allocated and freed by GLFW. You
* should not free it yourself. It is guaranteed to be valid only until the * should not free it yourself. It is guaranteed to be valid only until the
@ -5950,7 +5957,7 @@ GLFWAPI GLFWvkproc glfwGetInstanceProcAddress(VkInstance instance, const char* p
* GLFW_API_UNAVAILABLE and @ref GLFW_PLATFORM_ERROR. * GLFW_API_UNAVAILABLE and @ref GLFW_PLATFORM_ERROR.
* *
* @remark @macos This function currently always returns `GLFW_TRUE`, as the * @remark @macos This function currently always returns `GLFW_TRUE`, as the
* `VK_MVK_macos_surface` extension does not provide * `VK_MVK_macos_surface` and `VK_EXT_metal_surface` extensions do not provide
* a `vkGetPhysicalDevice*PresentationSupport` type function. * a `vkGetPhysicalDevice*PresentationSupport` type function.
* *
* @thread_safety This function may be called from any thread. For * @thread_safety This function may be called from any thread. For
@ -6013,6 +6020,12 @@ GLFWAPI int glfwGetPhysicalDevicePresentationSupport(VkInstance instance, VkPhys
* @remark @macos This function creates and sets a `CAMetalLayer` instance for * @remark @macos This function creates and sets a `CAMetalLayer` instance for
* the window content view, which is required for MoltenVK to function. * the window content view, which is required for MoltenVK to function.
* *
* @remark @x11 GLFW by default attempts to use the `VK_KHR_xcb_surface`
* extension, if available. You can make it prefer the `VK_KHR_xlib_surface`
* extension by setting the
* [GLFW_X11_XCB_VULKAN_SURFACE](@ref GLFW_X11_XCB_VULKAN_SURFACE_hint) init
* hint.
*
* @thread_safety This function may be called from any thread. For * @thread_safety This function may be called from any thread. For
* synchronization details of Vulkan objects, see the Vulkan specification. * synchronization details of Vulkan objects, see the Vulkan specification.
* *

View File

@ -83,8 +83,8 @@ extern "C" {
#if defined(GLFW_EXPOSE_NATIVE_WIN32) || defined(GLFW_EXPOSE_NATIVE_WGL) #if defined(GLFW_EXPOSE_NATIVE_WIN32) || defined(GLFW_EXPOSE_NATIVE_WGL)
// This is a workaround for the fact that glfw3.h needs to export APIENTRY (for // This is a workaround for the fact that glfw3.h needs to export APIENTRY (for
// example to allow applications to correctly declare a GL_ARB_debug_output // example to allow applications to correctly declare a GL_KHR_debug callback)
// callback) but windows.h assumes no one will define APIENTRY before it does // but windows.h assumes no one will define APIENTRY before it does
#if defined(GLFW_APIENTRY_DEFINED) #if defined(GLFW_APIENTRY_DEFINED)
#undef APIENTRY #undef APIENTRY
#undef GLFW_APIENTRY_DEFINED #undef GLFW_APIENTRY_DEFINED
@ -161,6 +161,14 @@ GLFWAPI const char* glfwGetWin32Monitor(GLFWmonitor* monitor);
* @return The `HWND` of the specified window, or `NULL` if an * @return The `HWND` of the specified window, or `NULL` if an
* [error](@ref error_handling) occurred. * [error](@ref error_handling) occurred.
* *
* @remark The `HDC` associated with the window can be queried with the
* [GetDC](https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getdc)
* function.
* @code
* HDC dc = GetDC(glfwGetWin32Window(window));
* @endcode
* This DC is private and does not need to be released.
*
* @thread_safety This function may be called from any thread. Access is not * @thread_safety This function may be called from any thread. Access is not
* synchronized. * synchronized.
* *
@ -177,6 +185,14 @@ GLFWAPI HWND glfwGetWin32Window(GLFWwindow* window);
* @return The `HGLRC` of the specified window, or `NULL` if an * @return The `HGLRC` of the specified window, or `NULL` if an
* [error](@ref error_handling) occurred. * [error](@ref error_handling) occurred.
* *
* @remark The `HDC` associated with the window can be queried with the
* [GetDC](https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getdc)
* function.
* @code
* HDC dc = GetDC(glfwGetWin32Window(window));
* @endcode
* This DC is private and does not need to be released.
*
* @thread_safety This function may be called from any thread. Access is not * @thread_safety This function may be called from any thread. Access is not
* synchronized. * synchronized.
* *

View File

@ -4,6 +4,15 @@ add_library(glfw "${GLFW_SOURCE_DIR}/include/GLFW/glfw3.h"
internal.h mappings.h context.c init.c input.c monitor.c internal.h mappings.h context.c init.c input.c monitor.c
vulkan.c window.c) vulkan.c window.c)
add_custom_target(update_mappings
COMMAND "${CMAKE_COMMAND}" -P "${GLFW_SOURCE_DIR}/CMake/GenerateMappings.cmake" mappings.h.in mappings.h
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
COMMENT "Updating gamepad mappings from upstream repository"
SOURCES mappings.h.in "${GLFW_SOURCE_DIR}/CMake/GenerateMappings.cmake"
VERBATIM)
set_target_properties(update_mappings PROPERTIES FOLDER "GLFW3")
if (_GLFW_COCOA) if (_GLFW_COCOA)
target_sources(glfw PRIVATE cocoa_platform.h cocoa_joystick.h posix_thread.h target_sources(glfw PRIVATE cocoa_platform.h cocoa_joystick.h posix_thread.h
nsgl_context.h egl_context.h osmesa_context.h nsgl_context.h egl_context.h osmesa_context.h
@ -130,22 +139,18 @@ if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
endif() endif()
# Enable a reasonable set of warnings # Enable a reasonable set of warnings
if (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR # NOTE: The order matters here, Clang-CL matches both MSVC and Clang
CMAKE_C_COMPILER_ID STREQUAL "Clang" OR if (MSVC)
CMAKE_C_COMPILER_ID STREQUAL "AppleClang")
if (CMAKE_C_SIMULATE_ID STREQUAL "MSVC")
# Tell Clang-CL that this is a Clang flag
target_compile_options(glfw PRIVATE "/clang:-Wall")
else()
target_compile_options(glfw PRIVATE "-Wall")
endif()
elseif (MSVC)
target_compile_options(glfw PRIVATE "/W3") target_compile_options(glfw PRIVATE "/W3")
elseif (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR
CMAKE_C_COMPILER_ID STREQUAL "Clang" OR
CMAKE_C_COMPILER_ID STREQUAL "AppleClang")
target_compile_options(glfw PRIVATE "-Wall")
endif() endif()
if (WIN32) if (_GLFW_WIN32)
target_compile_definitions(glfw PRIVATE _UNICODE) target_compile_definitions(glfw PRIVATE UNICODE _UNICODE)
endif() endif()
# HACK: When building on MinGW, WINVER and UNICODE need to be defined before # HACK: When building on MinGW, WINVER and UNICODE need to be defined before
@ -153,7 +158,7 @@ endif()
# win32_platform.h. We define them here until a saner solution can be found # win32_platform.h. We define them here until a saner solution can be found
# NOTE: MinGW-w64 and Visual C++ do /not/ need this hack. # NOTE: MinGW-w64 and Visual C++ do /not/ need this hack.
if (MINGW) if (MINGW)
target_compile_definitions(glfw PRIVATE UNICODE WINVER=0x0501) target_compile_definitions(glfw PRIVATE WINVER=0x0501)
endif() endif()
# Workaround for legacy MinGW not providing XInput and DirectInput # Workaround for legacy MinGW not providing XInput and DirectInput
@ -166,8 +171,8 @@ if (MINGW)
endif() endif()
endif() endif()
# Workaround for VS deprecating parts of the standard library # Workaround for the MS CRT deprecating parts of the standard library
if (MSVC) if (MSVC OR CMAKE_C_SIMULATE_ID STREQUAL "MSVC")
target_compile_definitions(glfw PRIVATE _CRT_SECURE_NO_WARNINGS) target_compile_definitions(glfw PRIVATE _CRT_SECURE_NO_WARNINGS)
endif() endif()
@ -243,7 +248,7 @@ endif()
if (GLFW_INSTALL) if (GLFW_INSTALL)
install(TARGETS glfw install(TARGETS glfw
EXPORT glfwTargets EXPORT glfwTargets
RUNTIME DESTINATION "bin" RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}") LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")
endif() endif()

View File

@ -555,7 +555,8 @@ int _glfwPlatformInit(void)
[NSApp run]; [NSApp run];
// In case we are unbundled, make us a proper UI application // In case we are unbundled, make us a proper UI application
[NSApp setActivationPolicy:NSApplicationActivationPolicyRegular]; if (_glfw.hints.init.ns.menubar)
[NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
return GLFW_TRUE; return GLFW_TRUE;

View File

@ -33,6 +33,7 @@
#define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE struct { int dummyJoystick; } #define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE struct { int dummyJoystick; }
#define _GLFW_PLATFORM_MAPPING_NAME "Mac OS X" #define _GLFW_PLATFORM_MAPPING_NAME "Mac OS X"
#define GLFW_BUILD_COCOA_MAPPINGS
// Cocoa-specific per-joystick data // Cocoa-specific per-joystick data
// //

View File

@ -63,7 +63,7 @@ static char* getMonitorName(CGDirectDisplayID displayID, NSScreen* screen)
&it) != 0) &it) != 0)
{ {
// This may happen if a desktop Mac is running headless // This may happen if a desktop Mac is running headless
return NULL; return _glfw_strdup("Display");
} }
while ((service = IOIteratorNext(it)) != 0) while ((service = IOIteratorNext(it)) != 0)
@ -101,7 +101,7 @@ static char* getMonitorName(CGDirectDisplayID displayID, NSScreen* screen)
{ {
_glfwInputError(GLFW_PLATFORM_ERROR, _glfwInputError(GLFW_PLATFORM_ERROR,
"Cocoa: Failed to find service port for display"); "Cocoa: Failed to find service port for display");
return NULL; return _glfw_strdup("Display");
} }
CFDictionaryRef names = CFDictionaryRef names =
@ -114,7 +114,7 @@ static char* getMonitorName(CGDirectDisplayID displayID, NSScreen* screen)
{ {
// This may happen if a desktop Mac is running headless // This may happen if a desktop Mac is running headless
CFRelease(info); CFRelease(info);
return NULL; return _glfw_strdup("Display");
} }
const CFIndex size = const CFIndex size =
@ -356,7 +356,7 @@ void _glfwPollMonitorsNS(void)
const CGSize size = CGDisplayScreenSize(displays[i]); const CGSize size = CGDisplayScreenSize(displays[i]);
char* name = getMonitorName(displays[i], screen); char* name = getMonitorName(displays[i], screen);
if (!name) if (!name)
name = _glfw_strdup("Unknown"); continue;
_GLFWmonitor* monitor = _glfwAllocMonitor(name, size.width, size.height); _GLFWmonitor* monitor = _glfwAllocMonitor(name, size.width, size.height);
monitor->ns.displayID = displays[i]; monitor->ns.displayID = displays[i];

View File

@ -31,7 +31,9 @@
// NOTE: All of NSGL was deprecated in the 10.14 SDK // NOTE: All of NSGL was deprecated in the 10.14 SDK
// This disables the pointless warnings for every symbol we use // This disables the pointless warnings for every symbol we use
#ifndef GL_SILENCE_DEPRECATION
#define GL_SILENCE_DEPRECATION #define GL_SILENCE_DEPRECATION
#endif
#if defined(__OBJC__) #if defined(__OBJC__)
#import <Cocoa/Cocoa.h> #import <Cocoa/Cocoa.h>

View File

@ -243,7 +243,7 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
- (void)windowDidResize:(NSNotification *)notification - (void)windowDidResize:(NSNotification *)notification
{ {
if (window->context.client != GLFW_NO_API) if (window->context.source == GLFW_NATIVE_CONTEXT_API)
[window->context.nsgl.object update]; [window->context.nsgl.object update];
if (_glfw.ns.disabledCursorWindow == window) if (_glfw.ns.disabledCursorWindow == window)
@ -278,7 +278,7 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
- (void)windowDidMove:(NSNotification *)notification - (void)windowDidMove:(NSNotification *)notification
{ {
if (window->context.client != GLFW_NO_API) if (window->context.source == GLFW_NATIVE_CONTEXT_API)
[window->context.nsgl.object update]; [window->context.nsgl.object update];
if (_glfw.ns.disabledCursorWindow == window) if (_glfw.ns.disabledCursorWindow == window)
@ -397,7 +397,7 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
- (void)updateLayer - (void)updateLayer
{ {
if (window->context.client != GLFW_NO_API) if (window->context.source == GLFW_NATIVE_CONTEXT_API)
[window->context.nsgl.object update]; [window->context.nsgl.object update];
_glfwInputWindowDamage(window); _glfwInputWindowDamage(window);
@ -520,6 +520,18 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
{ {
const NSRect contentRect = [window->ns.view frame]; const NSRect contentRect = [window->ns.view frame];
const NSRect fbRect = [window->ns.view convertRectToBacking:contentRect]; const NSRect fbRect = [window->ns.view convertRectToBacking:contentRect];
const float xscale = fbRect.size.width / contentRect.size.width;
const float yscale = fbRect.size.height / contentRect.size.height;
if (xscale != window->ns.xscale || yscale != window->ns.yscale)
{
if (window->ns.retina && window->ns.layer)
[window->ns.layer setContentsScale:[window->ns.object backingScaleFactor]];
window->ns.xscale = xscale;
window->ns.yscale = yscale;
_glfwInputWindowContentScale(window, xscale, yscale);
}
if (fbRect.size.width != window->ns.fbWidth || if (fbRect.size.width != window->ns.fbWidth ||
fbRect.size.height != window->ns.fbHeight) fbRect.size.height != window->ns.fbHeight)
@ -528,19 +540,6 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
window->ns.fbHeight = fbRect.size.height; window->ns.fbHeight = fbRect.size.height;
_glfwInputFramebufferSize(window, fbRect.size.width, fbRect.size.height); _glfwInputFramebufferSize(window, fbRect.size.width, fbRect.size.height);
} }
const float xscale = fbRect.size.width / contentRect.size.width;
const float yscale = fbRect.size.height / contentRect.size.height;
if (xscale != window->ns.xscale || yscale != window->ns.yscale)
{
window->ns.xscale = xscale;
window->ns.yscale = yscale;
_glfwInputWindowContentScale(window, xscale, yscale);
if (window->ns.retina && window->ns.layer)
[window->ns.layer setContentsScale:[window->ns.object backingScaleFactor]];
}
} }
- (void)drawRect:(NSRect)rect - (void)drawRect:(NSRect)rect
@ -1537,7 +1536,7 @@ const char* _glfwPlatformGetScancodeName(int scancode)
if (scancode < 0 || scancode > 0xff || if (scancode < 0 || scancode > 0xff ||
_glfw.ns.keycodes[scancode] == GLFW_KEY_UNKNOWN) _glfw.ns.keycodes[scancode] == GLFW_KEY_UNKNOWN)
{ {
_glfwInputError(GLFW_INVALID_VALUE, "Invalid scancode"); _glfwInputError(GLFW_INVALID_VALUE, "Invalid scancode %i", scancode);
return NULL; return NULL;
} }

View File

@ -196,12 +196,6 @@ const _GLFWfbconfig* _glfwChooseFBConfig(const _GLFWfbconfig* desired,
continue; continue;
} }
if (desired->doublebuffer != current->doublebuffer)
{
// Double buffering is a hard constraint
continue;
}
// Count number of missing buffers // Count number of missing buffers
{ {
missing = 0; missing = 0;
@ -570,7 +564,9 @@ GLFWbool _glfwRefreshContextAttribs(_GLFWwindow* window,
PFNGLCLEARPROC glClear = (PFNGLCLEARPROC) PFNGLCLEARPROC glClear = (PFNGLCLEARPROC)
window->context.getProcAddress("glClear"); window->context.getProcAddress("glClear");
glClear(GL_COLOR_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT);
window->context.swapBuffers(window);
if (window->doublebuffer)
window->context.swapBuffers(window);
} }
glfwMakeContextCurrent((GLFWwindow*) previous); glfwMakeContextCurrent((GLFWwindow*) previous);

View File

@ -173,7 +173,7 @@ static GLFWbool chooseEGLConfig(const _GLFWctxconfig* ctxconfig,
u->stencilBits = getEGLConfigAttrib(n, EGL_STENCIL_SIZE); u->stencilBits = getEGLConfigAttrib(n, EGL_STENCIL_SIZE);
u->samples = getEGLConfigAttrib(n, EGL_SAMPLES); u->samples = getEGLConfigAttrib(n, EGL_SAMPLES);
u->doublebuffer = GLFW_TRUE; u->doublebuffer = desired->doublebuffer;
u->handle = (uintptr_t) n; u->handle = (uintptr_t) n;
usableCount++; usableCount++;
@ -643,6 +643,9 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window,
setAttrib(EGL_GL_COLORSPACE_KHR, EGL_GL_COLORSPACE_SRGB_KHR); setAttrib(EGL_GL_COLORSPACE_KHR, EGL_GL_COLORSPACE_SRGB_KHR);
} }
if (!fbconfig->doublebuffer)
setAttrib(EGL_RENDER_BUFFER, EGL_SINGLE_BUFFER);
setAttrib(EGL_NONE, EGL_NONE); setAttrib(EGL_NONE, EGL_NONE);
native = _glfwPlatformGetEGLNativeWindow(window); native = _glfwPlatformGetEGLNativeWindow(window);

View File

@ -64,6 +64,8 @@
#define EGL_OPENGL_ES_API 0x30a0 #define EGL_OPENGL_ES_API 0x30a0
#define EGL_OPENGL_API 0x30a2 #define EGL_OPENGL_API 0x30a2
#define EGL_NONE 0x3038 #define EGL_NONE 0x3038
#define EGL_RENDER_BUFFER 0x3086
#define EGL_SINGLE_BUFFER 0x3085
#define EGL_EXTENSIONS 0x3055 #define EGL_EXTENSIONS 0x3055
#define EGL_CONTEXT_CLIENT_VERSION 0x3098 #define EGL_CONTEXT_CLIENT_VERSION 0x3098
#define EGL_NATIVE_VISUAL_ID 0x302e #define EGL_NATIVE_VISUAL_ID 0x302e

View File

@ -92,6 +92,9 @@ static GLFWbool chooseGLXFBConfig(const _GLFWfbconfig* desired,
continue; continue;
} }
if (getGLXFBConfigAttrib(n, GLX_DOUBLEBUFFER) != desired->doublebuffer)
continue;
if (desired->transparent) if (desired->transparent)
{ {
XVisualInfo* vi = glXGetVisualFromFBConfig(_glfw.x11.display, n); XVisualInfo* vi = glXGetVisualFromFBConfig(_glfw.x11.display, n);
@ -119,8 +122,6 @@ static GLFWbool chooseGLXFBConfig(const _GLFWfbconfig* desired,
if (getGLXFBConfigAttrib(n, GLX_STEREO)) if (getGLXFBConfigAttrib(n, GLX_STEREO))
u->stereo = GLFW_TRUE; u->stereo = GLFW_TRUE;
if (getGLXFBConfigAttrib(n, GLX_DOUBLEBUFFER))
u->doublebuffer = GLFW_TRUE;
if (_glfw.glx.ARB_multisample) if (_glfw.glx.ARB_multisample)
u->samples = getGLXFBConfigAttrib(n, GLX_SAMPLES); u->samples = getGLXFBConfigAttrib(n, GLX_SAMPLES);

View File

@ -28,7 +28,6 @@
//======================================================================== //========================================================================
#include "internal.h" #include "internal.h"
#include "mappings.h"
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
@ -57,7 +56,10 @@ static _GLFWinitconfig _glfwInitHints =
{ {
GLFW_TRUE, // macOS menu bar GLFW_TRUE, // macOS menu bar
GLFW_TRUE // macOS bundle chdir GLFW_TRUE // macOS bundle chdir
} },
{
GLFW_TRUE, // X11 XCB Vulkan surface
},
}; };
// Terminate the library // Terminate the library
@ -253,24 +255,12 @@ GLFWAPI int glfwInit(void)
_glfwPlatformSetTls(&_glfw.errorSlot, &_glfwMainThreadError); _glfwPlatformSetTls(&_glfw.errorSlot, &_glfwMainThreadError);
_glfwInitGamepadMappings();
_glfw.initialized = GLFW_TRUE; _glfw.initialized = GLFW_TRUE;
_glfw.timer.offset = _glfwPlatformGetTimerValue(); _glfw.timer.offset = _glfwPlatformGetTimerValue();
glfwDefaultWindowHints(); glfwDefaultWindowHints();
{
int i;
for (i = 0; _glfwDefaultMappings[i]; i++)
{
if (!glfwUpdateGamepadMappings(_glfwDefaultMappings[i]))
{
terminate();
return GLFW_FALSE;
}
}
}
return GLFW_TRUE; return GLFW_TRUE;
} }
@ -298,6 +288,9 @@ GLFWAPI void glfwInitHint(int hint, int value)
case GLFW_COCOA_MENUBAR: case GLFW_COCOA_MENUBAR:
_glfwInitHints.ns.menubar = value; _glfwInitHints.ns.menubar = value;
return; return;
case GLFW_X11_XCB_VULKAN_SURFACE:
_glfwInitHints.x11.xcbVulkanSurface = value;
return;
} }
_glfwInputError(GLFW_INVALID_ENUM, _glfwInputError(GLFW_INVALID_ENUM,

View File

@ -28,6 +28,7 @@
//======================================================================== //========================================================================
#include "internal.h" #include "internal.h"
#include "mappings.h"
#include <assert.h> #include <assert.h>
#include <float.h> #include <float.h>
@ -101,25 +102,13 @@ static _GLFWmapping* findValidMapping(const _GLFWjoystick* js)
for (i = 0; i <= GLFW_GAMEPAD_BUTTON_LAST; i++) for (i = 0; i <= GLFW_GAMEPAD_BUTTON_LAST; i++)
{ {
if (!isValidElementForJoystick(mapping->buttons + i, js)) if (!isValidElementForJoystick(mapping->buttons + i, js))
{
_glfwInputError(GLFW_INVALID_VALUE,
"Invalid button in gamepad mapping %s (%s)",
mapping->guid,
mapping->name);
return NULL; return NULL;
}
} }
for (i = 0; i <= GLFW_GAMEPAD_AXIS_LAST; i++) for (i = 0; i <= GLFW_GAMEPAD_AXIS_LAST; i++)
{ {
if (!isValidElementForJoystick(mapping->axes + i, js)) if (!isValidElementForJoystick(mapping->axes + i, js))
{
_glfwInputError(GLFW_INVALID_VALUE,
"Invalid axis in gamepad mapping %s (%s)",
mapping->guid,
mapping->name);
return NULL; return NULL;
}
} }
} }
@ -424,6 +413,21 @@ void _glfwInputJoystickHat(_GLFWjoystick* js, int hat, char value)
////// GLFW internal API ////// ////// GLFW internal API //////
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// Adds the built-in set of gamepad mappings
//
void _glfwInitGamepadMappings(void)
{
size_t i;
const size_t count = sizeof(_glfwDefaultMappings) / sizeof(char*);
_glfw.mappings = calloc(count, sizeof(_GLFWmapping));
for (i = 0; i < count; i++)
{
if (parseMapping(&_glfw.mappings[_glfw.mappingCount], _glfwDefaultMappings[i]))
_glfw.mappingCount++;
}
}
// Returns an available joystick object with arrays and name allocated // Returns an available joystick object with arrays and name allocated
// //
_GLFWjoystick* _glfwAllocJoystick(const char* name, _GLFWjoystick* _glfwAllocJoystick(const char* name,
@ -446,7 +450,6 @@ _GLFWjoystick* _glfwAllocJoystick(const char* name,
js = _glfw.joysticks + jid; js = _glfw.joysticks + jid;
js->present = GLFW_TRUE; js->present = GLFW_TRUE;
js->name = _glfw_strdup(name);
js->axes = calloc(axisCount, sizeof(float)); js->axes = calloc(axisCount, sizeof(float));
js->buttons = calloc(buttonCount + (size_t) hatCount * 4, 1); js->buttons = calloc(buttonCount + (size_t) hatCount * 4, 1);
js->hats = calloc(hatCount, 1); js->hats = calloc(hatCount, 1);
@ -454,6 +457,7 @@ _GLFWjoystick* _glfwAllocJoystick(const char* name,
js->buttonCount = buttonCount; js->buttonCount = buttonCount;
js->hatCount = hatCount; js->hatCount = hatCount;
strncpy(js->name, name, sizeof(js->name) - 1);
strncpy(js->guid, guid, sizeof(js->guid) - 1); strncpy(js->guid, guid, sizeof(js->guid) - 1);
js->mapping = findValidMapping(js); js->mapping = findValidMapping(js);
@ -464,7 +468,6 @@ _GLFWjoystick* _glfwAllocJoystick(const char* name,
// //
void _glfwFreeJoystick(_GLFWjoystick* js) void _glfwFreeJoystick(_GLFWjoystick* js)
{ {
free(js->name);
free(js->axes); free(js->axes);
free(js->buttons); free(js->buttons);
free(js->hats); free(js->hats);

View File

@ -248,6 +248,9 @@ struct _GLFWinitconfig
GLFWbool menubar; GLFWbool menubar;
GLFWbool chdir; GLFWbool chdir;
} ns; } ns;
struct {
GLFWbool xcbVulkanSurface;
} x11;
}; };
// Window configuration // Window configuration
@ -384,6 +387,7 @@ struct _GLFWwindow
GLFWbool mousePassthrough; GLFWbool mousePassthrough;
GLFWbool shouldClose; GLFWbool shouldClose;
void* userPointer; void* userPointer;
GLFWbool doublebuffer;
GLFWvidmode videoMode; GLFWvidmode videoMode;
_GLFWmonitor* monitor; _GLFWmonitor* monitor;
_GLFWcursor* cursor; _GLFWcursor* cursor;
@ -432,7 +436,7 @@ struct _GLFWwindow
// //
struct _GLFWmonitor struct _GLFWmonitor
{ {
char* name; char name[128];
void* userPointer; void* userPointer;
// Physical dimensions in millimeters. // Physical dimensions in millimeters.
@ -493,7 +497,7 @@ struct _GLFWjoystick
int buttonCount; int buttonCount;
unsigned char* hats; unsigned char* hats;
int hatCount; int hatCount;
char* name; char name[128];
void* userPointer; void* userPointer;
char guid[33]; char guid[33];
_GLFWmapping* mapping; _GLFWmapping* mapping;
@ -777,6 +781,7 @@ void _glfwAllocGammaArrays(GLFWgammaramp* ramp, unsigned int size);
void _glfwFreeGammaArrays(GLFWgammaramp* ramp); void _glfwFreeGammaArrays(GLFWgammaramp* ramp);
void _glfwSplitBPP(int bpp, int* red, int* green, int* blue); void _glfwSplitBPP(int bpp, int* red, int* green, int* blue);
void _glfwInitGamepadMappings(void);
_GLFWjoystick* _glfwAllocJoystick(const char* name, _GLFWjoystick* _glfwAllocJoystick(const char* name,
const char* guid, const char* guid,
int axisCount, int axisCount,

View File

@ -32,6 +32,7 @@
#define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE _GLFWlibraryLinux linjs #define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE _GLFWlibraryLinux linjs
#define _GLFW_PLATFORM_MAPPING_NAME "Linux" #define _GLFW_PLATFORM_MAPPING_NAME "Linux"
#define GLFW_BUILD_LINUX_MAPPINGS
// Linux-specific joystick data // Linux-specific joystick data
// //

File diff suppressed because it is too large Load Diff

View File

@ -31,7 +31,7 @@
// all available in SDL_GameControllerDB. Do not edit this file. Any gamepad // all available in SDL_GameControllerDB. Do not edit this file. Any gamepad
// mappings not specific to GLFW should be submitted to SDL_GameControllerDB. // mappings not specific to GLFW should be submitted to SDL_GameControllerDB.
// This file can be re-generated from mappings.h.in and the upstream // This file can be re-generated from mappings.h.in and the upstream
// gamecontrollerdb.txt with the GenerateMappings.cmake script. // gamecontrollerdb.txt with the 'update_mappings' CMake target.
//======================================================================== //========================================================================
// All gamepad mappings not labeled GLFW are copied from the // All gamepad mappings not labeled GLFW are copied from the
@ -60,7 +60,8 @@
const char* _glfwDefaultMappings[] = const char* _glfwDefaultMappings[] =
{ {
@GLFW_GAMEPAD_MAPPINGS@ #if defined(GLFW_BUILD_WIN32_MAPPINGS)
@GLFW_WIN32_MAPPINGS@
"78696e70757401000000000000000000,XInput Gamepad (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,", "78696e70757401000000000000000000,XInput Gamepad (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,",
"78696e70757402000000000000000000,XInput Wheel (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,", "78696e70757402000000000000000000,XInput Wheel (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,",
"78696e70757403000000000000000000,XInput Arcade Stick (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,", "78696e70757403000000000000000000,XInput Arcade Stick (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,",
@ -68,6 +69,14 @@ const char* _glfwDefaultMappings[] =
"78696e70757405000000000000000000,XInput Dance Pad (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,", "78696e70757405000000000000000000,XInput Dance Pad (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,",
"78696e70757406000000000000000000,XInput Guitar (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,", "78696e70757406000000000000000000,XInput Guitar (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,",
"78696e70757408000000000000000000,XInput Drum Kit (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,", "78696e70757408000000000000000000,XInput Drum Kit (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,",
NULL #endif // GLFW_BUILD_WIN32_MAPPINGS
#if defined(GLFW_BUILD_COCOA_MAPPINGS)
@GLFW_COCOA_MAPPINGS@
#endif // GLFW_BUILD_COCOA_MAPPINGS
#if defined(GLFW_BUILD_LINUX_MAPPINGS)
@GLFW_LINUX_MAPPINGS@
#endif // GLFW_BUILD_LINUX_MAPPINGS
}; };

View File

@ -170,8 +170,7 @@ _GLFWmonitor* _glfwAllocMonitor(const char* name, int widthMM, int heightMM)
monitor->widthMM = widthMM; monitor->widthMM = widthMM;
monitor->heightMM = heightMM; monitor->heightMM = heightMM;
if (name) strncpy(monitor->name, name, sizeof(monitor->name) - 1);
monitor->name = _glfw_strdup(name);
return monitor; return monitor;
} }
@ -189,7 +188,6 @@ void _glfwFreeMonitor(_GLFWmonitor* monitor)
_glfwFreeGammaArrays(&monitor->currentRamp); _glfwFreeGammaArrays(&monitor->currentRamp);
free(monitor->modes); free(monitor->modes);
free(monitor->name);
free(monitor); free(monitor);
} }

View File

@ -524,6 +524,12 @@ const char* _glfwPlatformGetClipboardString(void)
const char* _glfwPlatformGetScancodeName(int scancode) const char* _glfwPlatformGetScancodeName(int scancode)
{ {
if (scancode < GLFW_KEY_SPACE || scancode > GLFW_KEY_LAST)
{
_glfwInputError(GLFW_INVALID_VALUE, "Invalid scancode %i", scancode);
return NULL;
}
switch (scancode) switch (scancode)
{ {
case GLFW_KEY_APOSTROPHE: case GLFW_KEY_APOSTROPHE:

View File

@ -165,6 +165,9 @@ static int choosePixelFormat(_GLFWwindow* window,
if (findAttribValue(WGL_ACCELERATION_ARB) == WGL_NO_ACCELERATION_ARB) if (findAttribValue(WGL_ACCELERATION_ARB) == WGL_NO_ACCELERATION_ARB)
continue; continue;
if (findAttribValue(WGL_DOUBLE_BUFFER_ARB) != fbconfig->doublebuffer)
continue;
u->redBits = findAttribValue(WGL_RED_BITS_ARB); u->redBits = findAttribValue(WGL_RED_BITS_ARB);
u->greenBits = findAttribValue(WGL_GREEN_BITS_ARB); u->greenBits = findAttribValue(WGL_GREEN_BITS_ARB);
u->blueBits = findAttribValue(WGL_BLUE_BITS_ARB); u->blueBits = findAttribValue(WGL_BLUE_BITS_ARB);
@ -182,8 +185,6 @@ static int choosePixelFormat(_GLFWwindow* window,
if (findAttribValue(WGL_STEREO_ARB)) if (findAttribValue(WGL_STEREO_ARB))
u->stereo = GLFW_TRUE; u->stereo = GLFW_TRUE;
if (findAttribValue(WGL_DOUBLE_BUFFER_ARB))
u->doublebuffer = GLFW_TRUE;
if (_glfw.wgl.ARB_multisample) if (_glfw.wgl.ARB_multisample)
u->samples = findAttribValue(WGL_SAMPLES_ARB); u->samples = findAttribValue(WGL_SAMPLES_ARB);
@ -239,6 +240,9 @@ static int choosePixelFormat(_GLFWwindow* window,
if (pfd.iPixelType != PFD_TYPE_RGBA) if (pfd.iPixelType != PFD_TYPE_RGBA)
continue; continue;
if (!!(pfd.dwFlags & PFD_DOUBLEBUFFER) != fbconfig->doublebuffer)
continue;
u->redBits = pfd.cRedBits; u->redBits = pfd.cRedBits;
u->greenBits = pfd.cGreenBits; u->greenBits = pfd.cGreenBits;
u->blueBits = pfd.cBlueBits; u->blueBits = pfd.cBlueBits;
@ -256,8 +260,6 @@ static int choosePixelFormat(_GLFWwindow* window,
if (pfd.dwFlags & PFD_STEREO) if (pfd.dwFlags & PFD_STEREO)
u->stereo = GLFW_TRUE; u->stereo = GLFW_TRUE;
if (pfd.dwFlags & PFD_DOUBLEBUFFER)
u->doublebuffer = GLFW_TRUE;
} }
u->handle = pixelFormat; u->handle = pixelFormat;

View File

@ -39,6 +39,10 @@ static const GUID _glfw_GUID_DEVINTERFACE_HID =
#if defined(_GLFW_USE_HYBRID_HPG) || defined(_GLFW_USE_OPTIMUS_HPG) #if defined(_GLFW_USE_HYBRID_HPG) || defined(_GLFW_USE_OPTIMUS_HPG)
#if defined(_GLFW_BUILD_DLL)
#warning "These symbols must be exported by the executable and have no effect in a DLL"
#endif
// Executables (but not DLLs) exporting this symbol with this value will be // Executables (but not DLLs) exporting this symbol with this value will be
// automatically directed to the high-performance GPU on Nvidia Optimus systems // automatically directed to the high-performance GPU on Nvidia Optimus systems
// with up-to-date drivers // with up-to-date drivers
@ -614,7 +618,9 @@ void _glfwPlatformTerminate(void)
const char* _glfwPlatformGetVersionString(void) const char* _glfwPlatformGetVersionString(void)
{ {
return _GLFW_VERSION_NUMBER " Win32 WGL EGL OSMesa" return _GLFW_VERSION_NUMBER " Win32 WGL EGL OSMesa"
#if defined(__MINGW32__) #if defined(__MINGW64_VERSION_MAJOR)
" MinGW-w64"
#elif defined(__MINGW32__)
" MinGW" " MinGW"
#elif defined(_MSC_VER) #elif defined(_MSC_VER)
" VisualC" " VisualC"

View File

@ -28,6 +28,7 @@
#define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE struct { int dummyLibraryJoystick; } #define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE struct { int dummyLibraryJoystick; }
#define _GLFW_PLATFORM_MAPPING_NAME "Windows" #define _GLFW_PLATFORM_MAPPING_NAME "Windows"
#define GLFW_BUILD_WIN32_MAPPINGS
// Joystick element (axis, button or slider) // Joystick element (axis, button or slider)
// //

View File

@ -39,8 +39,8 @@
#endif #endif
// This is a workaround for the fact that glfw3.h needs to export APIENTRY (for // This is a workaround for the fact that glfw3.h needs to export APIENTRY (for
// example to allow applications to correctly declare a GL_ARB_debug_output // example to allow applications to correctly declare a GL_KHR_debug callback)
// callback) but windows.h assumes no one will define APIENTRY before it does // but windows.h assumes no one will define APIENTRY before it does
#undef APIENTRY #undef APIENTRY
// GLFW on Windows is Unicode only and does not work in MBCS mode // GLFW on Windows is Unicode only and does not work in MBCS mode

View File

@ -501,7 +501,17 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
case WM_NCCREATE: case WM_NCCREATE:
{ {
if (_glfwIsWindows10AnniversaryUpdateOrGreaterWin32()) if (_glfwIsWindows10AnniversaryUpdateOrGreaterWin32())
EnableNonClientDpiScaling(hWnd); {
const CREATESTRUCTW* cs = (const CREATESTRUCTW*) lParam;
const _GLFWwndconfig* wndconfig = cs->lpCreateParams;
// On per-monitor DPI aware V1 systems, only enable
// non-client scaling for windows that scale the client area
// We need WM_GETDPISCALEDSIZE from V2 to keep the client
// area static when the non-client area is scaled
if (wndconfig && wndconfig->scaleToMonitor)
EnableNonClientDpiScaling(hWnd);
}
break; break;
} }
@ -1138,9 +1148,11 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
const float xscale = HIWORD(wParam) / (float) USER_DEFAULT_SCREEN_DPI; const float xscale = HIWORD(wParam) / (float) USER_DEFAULT_SCREEN_DPI;
const float yscale = LOWORD(wParam) / (float) USER_DEFAULT_SCREEN_DPI; const float yscale = LOWORD(wParam) / (float) USER_DEFAULT_SCREEN_DPI;
// Only apply the suggested size if the OS is new enough to have // Resize windowed mode windows that either permit rescaling or that
// sent a WM_GETDPISCALEDSIZE before this // need it to compensate for non-client area scaling
if (_glfwIsWindows10CreatorsUpdateOrGreaterWin32()) if (!window->monitor &&
(window->win32.scaleToMonitor ||
_glfwIsWindows10CreatorsUpdateOrGreaterWin32()))
{ {
RECT* suggested = (RECT*) lParam; RECT* suggested = (RECT*) lParam;
SetWindowPos(window->win32.handle, HWND_TOP, SetWindowPos(window->win32.handle, HWND_TOP,
@ -1255,7 +1267,7 @@ static int createNativeWindow(_GLFWwindow* window,
NULL, // No parent window NULL, // No parent window
NULL, // No window menu NULL, // No window menu
GetModuleHandleW(NULL), GetModuleHandleW(NULL),
NULL); (LPVOID) wndconfig);
free(wideTitle); free(wideTitle);
@ -2096,7 +2108,7 @@ const char* _glfwPlatformGetScancodeName(int scancode)
if (scancode < 0 || scancode > (KF_EXTENDED | 0xff) || if (scancode < 0 || scancode > (KF_EXTENDED | 0xff) ||
_glfw.win32.keycodes[scancode] == GLFW_KEY_UNKNOWN) _glfw.win32.keycodes[scancode] == GLFW_KEY_UNKNOWN)
{ {
_glfwInputError(GLFW_INVALID_VALUE, "Invalid scancode"); _glfwInputError(GLFW_INVALID_VALUE, "Invalid scancode %i", scancode);
return NULL; return NULL;
} }

View File

@ -206,6 +206,8 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height,
window->mousePassthrough = wndconfig.mousePassthrough; window->mousePassthrough = wndconfig.mousePassthrough;
window->cursorMode = GLFW_CURSOR_NORMAL; window->cursorMode = GLFW_CURSOR_NORMAL;
window->doublebuffer = fbconfig.doublebuffer;
window->minwidth = GLFW_DONT_CARE; window->minwidth = GLFW_DONT_CARE;
window->minheight = GLFW_DONT_CARE; window->minheight = GLFW_DONT_CARE;
window->maxwidth = GLFW_DONT_CARE; window->maxwidth = GLFW_DONT_CARE;
@ -841,6 +843,8 @@ GLFWAPI int glfwGetWindowAttrib(GLFWwindow* handle, int attrib)
return window->floating; return window->floating;
case GLFW_AUTO_ICONIFY: case GLFW_AUTO_ICONIFY:
return window->autoIconify; return window->autoIconify;
case GLFW_DOUBLEBUFFER:
return window->doublebuffer;
case GLFW_CLIENT_API: case GLFW_CLIENT_API:
return window->context.client; return window->context.client;
case GLFW_CONTEXT_CREATION_API: case GLFW_CONTEXT_CREATION_API:
@ -882,27 +886,18 @@ GLFWAPI void glfwSetWindowAttrib(GLFWwindow* handle, int attrib, int value)
window->autoIconify = value; window->autoIconify = value;
else if (attrib == GLFW_RESIZABLE) else if (attrib == GLFW_RESIZABLE)
{ {
if (window->resizable == value)
return;
window->resizable = value; window->resizable = value;
if (!window->monitor) if (!window->monitor)
_glfwPlatformSetWindowResizable(window, value); _glfwPlatformSetWindowResizable(window, value);
} }
else if (attrib == GLFW_DECORATED) else if (attrib == GLFW_DECORATED)
{ {
if (window->decorated == value)
return;
window->decorated = value; window->decorated = value;
if (!window->monitor) if (!window->monitor)
_glfwPlatformSetWindowDecorated(window, value); _glfwPlatformSetWindowDecorated(window, value);
} }
else if (attrib == GLFW_FLOATING) else if (attrib == GLFW_FLOATING)
{ {
if (window->floating == value)
return;
window->floating = value; window->floating = value;
if (!window->monitor) if (!window->monitor)
_glfwPlatformSetWindowFloating(window, value); _glfwPlatformSetWindowFloating(window, value);
@ -911,9 +906,6 @@ GLFWAPI void glfwSetWindowAttrib(GLFWwindow* handle, int attrib, int value)
window->focusOnShow = value; window->focusOnShow = value;
else if (attrib == GLFW_MOUSE_PASSTHROUGH) else if (attrib == GLFW_MOUSE_PASSTHROUGH)
{ {
if (window->mousePassthrough == value)
return;
window->mousePassthrough = value; window->mousePassthrough = value;
_glfwPlatformSetWindowMousePassthrough(window, value); _glfwPlatformSetWindowMousePassthrough(window, value);
} }

View File

@ -26,7 +26,7 @@
// It is fine to use C99 in this file because it will not be built with VS // It is fine to use C99 in this file because it will not be built with VS
//======================================================================== //========================================================================
#define _POSIX_C_SOURCE 199309L #define _POSIX_C_SOURCE 200809L
#include "internal.h" #include "internal.h"

View File

@ -47,15 +47,13 @@ static void outputHandleGeometry(void* data,
int32_t transform) int32_t transform)
{ {
struct _GLFWmonitor *monitor = data; struct _GLFWmonitor *monitor = data;
char name[1024];
monitor->wl.x = x; monitor->wl.x = x;
monitor->wl.y = y; monitor->wl.y = y;
monitor->widthMM = physicalWidth; monitor->widthMM = physicalWidth;
monitor->heightMM = physicalHeight; monitor->heightMM = physicalHeight;
snprintf(name, sizeof(name), "%s %s", make, model); snprintf(monitor->name, sizeof(monitor->name), "%s %s", make, model);
monitor->name = _glfw_strdup(name);
} }
static void outputHandleMode(void* data, static void outputHandleMode(void* data,
@ -81,22 +79,21 @@ static void outputHandleMode(void* data,
monitor->modes[monitor->modeCount - 1] = mode; monitor->modes[monitor->modeCount - 1] = mode;
if (flags & WL_OUTPUT_MODE_CURRENT) if (flags & WL_OUTPUT_MODE_CURRENT)
{
monitor->wl.currentMode = monitor->modeCount - 1; monitor->wl.currentMode = monitor->modeCount - 1;
if (monitor->widthMM <= 0 || monitor->heightMM <= 0)
{
// If Wayland does not provide a physical size, assume the default 96 DPI
monitor->widthMM = (int) (width * 25.4f / 96.f);
monitor->heightMM = (int) (height * 25.4f / 96.f);
}
}
} }
static void outputHandleDone(void* data, struct wl_output* output) static void outputHandleDone(void* data, struct wl_output* output)
{ {
struct _GLFWmonitor *monitor = data; struct _GLFWmonitor *monitor = data;
if (monitor->widthMM <= 0 || monitor->heightMM <= 0)
{
// If Wayland does not provide a physical size, assume the default 96 DPI
const GLFWvidmode* mode = &monitor->modes[monitor->wl.currentMode];
monitor->widthMM = (int) (mode->width * 25.4f / 96.f);
monitor->heightMM = (int) (mode->height * 25.4f / 96.f);
}
_glfwInputMonitor(monitor, GLFW_CONNECTED, _GLFW_INSERT_LAST); _glfwInputMonitor(monitor, GLFW_CONNECTED, _GLFW_INSERT_LAST);
} }
@ -134,7 +131,7 @@ void _glfwAddOutputWayland(uint32_t name, uint32_t version)
} }
// The actual name of this output will be set in the geometry handler. // The actual name of this output will be set in the geometry handler.
monitor = _glfwAllocMonitor(NULL, 0, 0); monitor = _glfwAllocMonitor("", 0, 0);
output = wl_registry_bind(_glfw.wl.registry, output = wl_registry_bind(_glfw.wl.registry,
name, name,

View File

@ -813,11 +813,15 @@ static GLFWbool initExtensions(void)
XkbGroupStateMask, XkbGroupStateMask); XkbGroupStateMask, XkbGroupStateMask);
} }
if (_glfw.hints.init.x11.xcbVulkanSurface)
{
#if defined(__CYGWIN__) #if defined(__CYGWIN__)
_glfw.x11.x11xcb.handle = _glfw_dlopen("libX11-xcb-1.so"); _glfw.x11.x11xcb.handle = _glfw_dlopen("libX11-xcb-1.so");
#else #else
_glfw.x11.x11xcb.handle = _glfw_dlopen("libX11-xcb.so.1"); _glfw.x11.x11xcb.handle = _glfw_dlopen("libX11-xcb.so.1");
#endif #endif
}
if (_glfw.x11.x11xcb.handle) if (_glfw.x11.x11xcb.handle)
{ {
_glfw.x11.x11xcb.GetXCBConnection = (PFN_XGetXCBConnection) _glfw.x11.x11xcb.GetXCBConnection = (PFN_XGetXCBConnection)

View File

@ -2485,7 +2485,11 @@ void _glfwPlatformSetWindowMonitor(_GLFWwindow* window,
} }
if (window->monitor) if (window->monitor)
{
_glfwPlatformSetWindowDecorated(window, window->decorated);
_glfwPlatformSetWindowFloating(window, window->floating);
releaseMonitor(window); releaseMonitor(window);
}
_glfwInputWindowMonitor(window, monitor); _glfwInputWindowMonitor(window, monitor);
updateNormalHints(window, width, height); updateNormalHints(window, width, height);
@ -2887,7 +2891,7 @@ const char* _glfwPlatformGetScancodeName(int scancode)
if (scancode < 0 || scancode > 0xff || if (scancode < 0 || scancode > 0xff ||
_glfw.x11.keycodes[scancode] == GLFW_KEY_UNKNOWN) _glfw.x11.keycodes[scancode] == GLFW_KEY_UNKNOWN)
{ {
_glfwInputError(GLFW_INVALID_VALUE, "Invalid scancode"); _glfwInputError(GLFW_INVALID_VALUE, "Invalid scancode %i", scancode);
return NULL; return NULL;
} }

View File

@ -7,7 +7,8 @@ if (MATH_LIBRARY)
link_libraries("${MATH_LIBRARY}") link_libraries("${MATH_LIBRARY}")
endif() endif()
if (MSVC) # Workaround for the MS CRT deprecating parts of the standard library
if (MSVC OR CMAKE_C_SIMULATE_ID STREQUAL "MSVC")
add_definitions(-D_CRT_SECURE_NO_WARNINGS) add_definitions(-D_CRT_SECURE_NO_WARNINGS)
endif() endif()
@ -58,9 +59,13 @@ set_target_properties(${GUI_ONLY_BINARIES} ${CONSOLE_BINARIES} PROPERTIES
FOLDER "GLFW3/Tests") FOLDER "GLFW3/Tests")
if (MSVC) if (MSVC)
# Tell MSVC to use main instead of WinMain for Windows subsystem executables # Tell MSVC to use main instead of WinMain
set_target_properties(${GUI_ONLY_BINARIES} PROPERTIES set_target_properties(${GUI_ONLY_BINARIES} PROPERTIES
LINK_FLAGS "/ENTRY:mainCRTStartup") LINK_FLAGS "/ENTRY:mainCRTStartup")
elseif (CMAKE_C_SIMULATE_ID STREQUAL "MSVC")
# Tell Clang using MS CRT to use main instead of WinMain
set_target_properties(${GUI_ONLY_BINARIES} PROPERTIES
LINK_FLAGS "-Wl,/entry:mainCRTStartup")
endif() endif()
if (APPLE) if (APPLE)

View File

@ -116,6 +116,7 @@ static void usage(void)
ANGLE_TYPE_VULKAN " or " ANGLE_TYPE_VULKAN " or "
ANGLE_TYPE_METAL ")\n"); ANGLE_TYPE_METAL ")\n");
printf(" --graphics-switching request macOS graphics switching\n"); printf(" --graphics-switching request macOS graphics switching\n");
printf(" --disable-xcb-surface disable VK_KHR_xcb_surface extension\n");
} }
static void error_callback(int error, const char* description) static void error_callback(int error, const char* description)
@ -360,6 +361,7 @@ int main(int argc, char** argv)
bool fb_doublebuffer = true; bool fb_doublebuffer = true;
int angle_type = GLFW_ANGLE_PLATFORM_TYPE_NONE; int angle_type = GLFW_ANGLE_PLATFORM_TYPE_NONE;
bool cocoa_graphics_switching = false; bool cocoa_graphics_switching = false;
bool disable_xcb_surface = false;
enum { CLIENT, CONTEXT, BEHAVIOR, DEBUG_CONTEXT, FORWARD, HELP, enum { CLIENT, CONTEXT, BEHAVIOR, DEBUG_CONTEXT, FORWARD, HELP,
EXTENSIONS, LAYERS, EXTENSIONS, LAYERS,
@ -367,7 +369,7 @@ int main(int argc, char** argv)
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 }; ANGLE_TYPE, GRAPHICS_SWITCHING, XCB_SURFACE };
const struct option options[] = const struct option options[] =
{ {
{ "behavior", 1, NULL, BEHAVIOR }, { "behavior", 1, NULL, BEHAVIOR },
@ -401,6 +403,7 @@ int main(int argc, char** argv)
{ "no-error", 0, NULL, NOERROR_SRSLY }, { "no-error", 0, NULL, NOERROR_SRSLY },
{ "angle-type", 1, NULL, ANGLE_TYPE }, { "angle-type", 1, NULL, ANGLE_TYPE },
{ "graphics-switching", 0, NULL, GRAPHICS_SWITCHING }, { "graphics-switching", 0, NULL, GRAPHICS_SWITCHING },
{ "vk-xcb-surface", 0, NULL, XCB_SURFACE },
{ NULL, 0, NULL, 0 } { NULL, 0, NULL, 0 }
}; };
@ -607,6 +610,9 @@ int main(int argc, char** argv)
case GRAPHICS_SWITCHING: case GRAPHICS_SWITCHING:
cocoa_graphics_switching = true; cocoa_graphics_switching = true;
break; break;
case XCB_SURFACE:
disable_xcb_surface = true;
break;
default: default:
usage(); usage();
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
@ -623,6 +629,7 @@ int main(int argc, char** argv)
glfwInitHint(GLFW_COCOA_MENUBAR, false); glfwInitHint(GLFW_COCOA_MENUBAR, false);
glfwInitHint(GLFW_ANGLE_PLATFORM_TYPE, angle_type); glfwInitHint(GLFW_ANGLE_PLATFORM_TYPE, angle_type);
glfwInitHint(GLFW_X11_XCB_VULKAN_SURFACE, !disable_xcb_surface);
if (!glfwInit()) if (!glfwInit())
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
@ -843,6 +850,17 @@ int main(int argc, char** argv)
if (list_extensions) if (list_extensions)
list_context_extensions(client, major, minor); list_context_extensions(client, major, minor);
glfwDestroyWindow(window);
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
window = glfwCreateWindow(200, 200, "Version", NULL, NULL);
if (!window)
{
glfwTerminate();
exit(EXIT_FAILURE);
}
printf("Vulkan loader: %s\n", printf("Vulkan loader: %s\n",
glfwVulkanSupported() ? "available" : "missing"); glfwVulkanSupported() ? "available" : "missing");
@ -866,15 +884,14 @@ int main(int argc, char** argv)
uint32_t re_count; uint32_t re_count;
const char** re = glfwGetRequiredInstanceExtensions(&re_count); const char** re = glfwGetRequiredInstanceExtensions(&re_count);
printf("Vulkan required instance extensions:");
if (re) if (re)
{ {
printf("Vulkan window surface required instance extensions:\n");
for (uint32_t i = 0; i < re_count; i++) for (uint32_t i = 0; i < re_count; i++)
printf(" %s", re[i]); printf(" %s\n", re[i]);
putchar('\n');
} }
else else
printf(" missing\n"); printf("Vulkan window surface extensions missing\n");
if (list_extensions) if (list_extensions)
list_vulkan_instance_extensions(); list_vulkan_instance_extensions();
@ -908,6 +925,19 @@ int main(int argc, char** argv)
gladLoadVulkanUserPtr(NULL, glad_vulkan_callback, instance); gladLoadVulkanUserPtr(NULL, glad_vulkan_callback, instance);
if (re)
{
VkSurfaceKHR surface = VK_NULL_HANDLE;
if (glfwCreateWindowSurface(instance, window, NULL, &surface) == VK_SUCCESS)
{
printf("Vulkan window surface created successfully\n");
vkDestroySurfaceKHR(instance, surface, NULL);
}
else
printf("Failed to create Vulkan window surface\n");
}
uint32_t pd_count; uint32_t pd_count;
vkEnumeratePhysicalDevices(instance, &pd_count, NULL); vkEnumeratePhysicalDevices(instance, &pd_count, NULL);
VkPhysicalDevice* pd = calloc(pd_count, sizeof(VkPhysicalDevice)); VkPhysicalDevice* pd = calloc(pd_count, sizeof(VkPhysicalDevice));
@ -916,7 +946,6 @@ int main(int argc, char** argv)
for (uint32_t i = 0; i < pd_count; i++) for (uint32_t i = 0; i < pd_count; i++)
{ {
VkPhysicalDeviceProperties pdp; VkPhysicalDeviceProperties pdp;
vkGetPhysicalDeviceProperties(pd[i], &pdp); vkGetPhysicalDeviceProperties(pd[i], &pdp);
printf("Vulkan %s device: \"%s\" (API version %i.%i)\n", printf("Vulkan %s device: \"%s\" (API version %i.%i)\n",
@ -925,6 +954,19 @@ int main(int argc, char** argv)
VK_VERSION_MAJOR(pdp.apiVersion), VK_VERSION_MAJOR(pdp.apiVersion),
VK_VERSION_MINOR(pdp.apiVersion)); VK_VERSION_MINOR(pdp.apiVersion));
uint32_t qfp_count;
vkGetPhysicalDeviceQueueFamilyProperties(pd[i], &qfp_count, NULL);
printf("Vulkan device queue family presentation support:\n");
for (uint32_t j = 0; j < qfp_count; j++)
{
printf(" %u: ", j);
if (glfwGetPhysicalDevicePresentationSupport(instance, pd[i], j))
printf("supported\n");
else
printf("no\n");
}
if (list_extensions) if (list_extensions)
list_vulkan_device_extensions(instance, pd[i]); list_vulkan_device_extensions(instance, pd[i]);
@ -936,6 +978,8 @@ int main(int argc, char** argv)
vkDestroyInstance(instance, NULL); vkDestroyInstance(instance, NULL);
} }
glfwDestroyWindow(window);
glfwTerminate(); glfwTerminate();
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
} }