mirror of
https://github.com/gwm17/glfw.git
synced 2025-04-16 13:28:51 -04:00
Compare commits
149 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
ecda86fa4f | ||
|
359f0e103c | ||
|
821873974a | ||
|
e8d4cc327d | ||
|
7f775302ae | ||
|
cb49e1821b | ||
|
9fc5fd1375 | ||
|
bb8ed627bf | ||
|
ccb54c3e05 | ||
|
7c9d0081e3 | ||
|
c3b8afc5d6 | ||
|
4df0a2b38e | ||
|
94bb2a138e | ||
|
85a27e9f74 | ||
|
5615c16439 | ||
|
8dd40f1c48 | ||
|
640e3205a9 | ||
|
dd00c6dea1 | ||
|
e8dab39625 | ||
|
9724f33038 | ||
|
8c3d2f769f | ||
|
2b1e2d2e49 | ||
|
39c5e90d94 | ||
|
365321a9af | ||
|
d8648876da | ||
|
bf9c5fcfc2 | ||
|
f25202fbfa | ||
|
b5bccd1425 | ||
|
03f2cde34e | ||
|
cd70e1bbc4 | ||
|
f318ab7467 | ||
|
db2ff13d41 | ||
|
82bd22ec29 | ||
|
bcd232e2ae | ||
|
f650a898f2 | ||
|
8c1b59f885 | ||
|
5a1512aaa0 | ||
|
b05d887968 | ||
|
e135210cb3 | ||
|
2da4adce40 | ||
|
17d727cd35 | ||
|
58c1621481 | ||
|
9db0bd45e6 | ||
|
df4bda44fc | ||
|
50218fbf7e | ||
|
3a2c0aaa27 | ||
|
2bac7ee8da | ||
|
4116db14fd | ||
|
e3c83f684f | ||
|
0ecc84182c | ||
|
b4cc6101ed | ||
|
7c33fb22fd | ||
|
52b77030e4 | ||
|
e662492169 | ||
|
b3c2023ebc | ||
|
129a5ccb19 | ||
|
25af31528c | ||
|
5ea34d62bf | ||
|
7a10e6439c | ||
|
8c46a3e9f9 | ||
|
82effcb7ba | ||
|
11db404fa1 | ||
|
5f7e5cb92b | ||
|
c5a870ebd9 | ||
|
3484aa8187 | ||
|
399c082033 | ||
|
1bf892f603 | ||
|
f9a9bb6747 | ||
|
91c6a542ff | ||
|
411d4dd51e | ||
|
161e9e1215 | ||
|
3a8d97cc3d | ||
|
afcefcb5f7 | ||
|
8c69091c59 | ||
|
857951419a | ||
|
17f1cceb32 | ||
|
3f0390b827 | ||
|
4a62820646 | ||
|
3facbd2083 | ||
|
e4e9581557 | ||
|
087110aa63 | ||
|
e30718e927 | ||
|
613b169899 | ||
|
13a4e4e810 | ||
|
a1b65e8542 | ||
|
649553cc78 | ||
|
934f0e9ff1 | ||
|
b2919dca4b | ||
|
71cfafe2f9 | ||
|
79f4ec6822 | ||
|
2032a8f0dc | ||
|
c0d1249ca2 | ||
|
2d3f388158 | ||
|
30e67357be | ||
|
116f4c831d | ||
|
1e8dc836a0 | ||
|
adcd306fbd | ||
|
b1309dd42a | ||
|
d25e19b790 | ||
|
1daf9de40f | ||
|
cfd93597ec | ||
|
8e923e592d | ||
|
9fc035a562 | ||
|
ce7cd3e288 | ||
|
452a648abb | ||
|
75b415c5b8 | ||
|
248e827673 | ||
|
95e7ad7e5b | ||
|
ff2c00091d | ||
|
b3eb6dd38b | ||
|
84fa724456 | ||
|
633ba53f2c | ||
|
898b7f9c54 | ||
|
eb466a0e0b | ||
|
8542f8dd84 | ||
|
1e12653348 | ||
|
e276f6731e | ||
|
66e06b0609 | ||
|
71a4f2d8a2 | ||
|
7b18f79ea6 | ||
|
f2208ab135 | ||
|
b962ef1241 | ||
|
5416e347ad | ||
|
16186943b4 | ||
|
b436d8e3e6 | ||
|
ad3e7c7f39 | ||
|
15f078c6ad | ||
|
e01128f32f | ||
|
051424f196 | ||
|
97393223ee | ||
|
04522580ad | ||
|
d2634896d6 | ||
|
3afb2cc8ed | ||
|
9f5c6c6e89 | ||
|
4d99045e87 | ||
|
b383e70021 | ||
|
645b8c3bba | ||
|
80935c6c27 | ||
|
73a3ef86db | ||
|
d715917add | ||
|
b596c79014 | ||
|
bc8b567d7c | ||
|
37cc51b823 | ||
|
9cc83cf07f | ||
|
e826f839a4 | ||
|
2e3b4cf898 | ||
|
6648b3d4bb | ||
|
76505355e1 | ||
|
a9343d641c |
|
@ -1,20 +1,62 @@
|
||||||
|
image:
|
||||||
|
- Visual Studio 2015
|
||||||
|
- Visual Studio 2019
|
||||||
branches:
|
branches:
|
||||||
only:
|
only:
|
||||||
- ci
|
- ci
|
||||||
- master
|
- master
|
||||||
|
- 3.3-stable
|
||||||
skip_tags: true
|
skip_tags: true
|
||||||
|
skip_commits:
|
||||||
|
files:
|
||||||
|
- README.md
|
||||||
|
- LICENSE.md
|
||||||
|
- docs/*
|
||||||
environment:
|
environment:
|
||||||
CFLAGS: /WX
|
|
||||||
matrix:
|
matrix:
|
||||||
- BUILD_SHARED_LIBS: ON
|
- GENERATOR: MinGW Makefiles
|
||||||
- BUILD_SHARED_LIBS: OFF
|
BUILD_SHARED_LIBS: ON
|
||||||
|
CFLAGS: -Werror
|
||||||
|
- GENERATOR: MinGW Makefiles
|
||||||
|
BUILD_SHARED_LIBS: OFF
|
||||||
|
CFLAGS: -Werror
|
||||||
|
- GENERATOR: Visual Studio 10 2010
|
||||||
|
BUILD_SHARED_LIBS: ON
|
||||||
|
CFLAGS: /WX
|
||||||
|
- GENERATOR: Visual Studio 10 2010
|
||||||
|
BUILD_SHARED_LIBS: OFF
|
||||||
|
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
|
||||||
build_script:
|
exclude:
|
||||||
- mkdir build
|
- image: Visual Studio 2015
|
||||||
- cd build
|
GENERATOR: Visual Studio 16 2019
|
||||||
- cmake -DCMAKE_VERBOSE_MAKEFILE=ON -DBUILD_SHARED_LIBS=%BUILD_SHARED_LIBS% ..
|
- image: Visual Studio 2019
|
||||||
- cmake --build .
|
GENERATOR: Visual Studio 10 2010
|
||||||
|
- image: Visual Studio 2019
|
||||||
|
GENERATOR: MinGW Makefiles
|
||||||
|
for:
|
||||||
|
-
|
||||||
|
matrix:
|
||||||
|
except:
|
||||||
|
- GENERATOR: Visual Studio 10 2010
|
||||||
|
build_script:
|
||||||
|
- 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 --build build
|
||||||
|
-
|
||||||
|
matrix:
|
||||||
|
only:
|
||||||
|
- GENERATOR: Visual Studio 10 2010
|
||||||
|
build_script:
|
||||||
|
- cmake -S . -B build -G "%GENERATOR%" -DBUILD_SHARED_LIBS=%BUILD_SHARED_LIBS%
|
||||||
|
- cmake --build build --target glfw
|
||||||
notifications:
|
notifications:
|
||||||
- provider: Email
|
- provider: Email
|
||||||
to:
|
to:
|
||||||
|
|
33
.gitignore
vendored
33
.gitignore
vendored
|
@ -1,26 +1,45 @@
|
||||||
# External junk
|
# The canonical out-of-tree build subdirectory
|
||||||
.DS_Store
|
build
|
||||||
|
|
||||||
|
# Visual Studio clutter
|
||||||
_ReSharper*
|
_ReSharper*
|
||||||
*.opensdf
|
|
||||||
*.sdf
|
*.sdf
|
||||||
*.suo
|
*.suo
|
||||||
*.dir
|
*.dir
|
||||||
*.vcxproj*
|
*.vcxproj*
|
||||||
*.sln
|
*.sln
|
||||||
.vs/
|
.vs
|
||||||
|
CMakeSettings.json
|
||||||
Win32
|
Win32
|
||||||
x64
|
x64
|
||||||
Debug
|
Debug
|
||||||
Release
|
Release
|
||||||
MinSizeRel
|
MinSizeRel
|
||||||
RelWithDebInfo
|
RelWithDebInfo
|
||||||
*.xcodeproj
|
*.opensdf
|
||||||
|
|
||||||
# CMake files
|
# Xcode clutter
|
||||||
|
GLFW.build
|
||||||
|
GLFW.xcodeproj
|
||||||
|
|
||||||
|
# macOS clutter
|
||||||
|
.DS_Store
|
||||||
|
|
||||||
|
# Makefile generator clutter
|
||||||
Makefile
|
Makefile
|
||||||
|
|
||||||
|
# Ninja generator clutter
|
||||||
|
build.ninja
|
||||||
|
rules.ninja
|
||||||
|
.ninja_deps
|
||||||
|
.ninja_log
|
||||||
|
|
||||||
|
# CMake clutter
|
||||||
CMakeCache.txt
|
CMakeCache.txt
|
||||||
CMakeFiles
|
CMakeFiles
|
||||||
CMakeScripts
|
CMakeScripts
|
||||||
|
CMakeDoxyfile.in
|
||||||
|
CMakeDoxygenDefaults.cmake
|
||||||
cmake_install.cmake
|
cmake_install.cmake
|
||||||
cmake_uninstall.cmake
|
cmake_uninstall.cmake
|
||||||
|
|
||||||
|
@ -80,6 +99,6 @@ tests/tearing
|
||||||
tests/threads
|
tests/threads
|
||||||
tests/timeout
|
tests/timeout
|
||||||
tests/title
|
tests/title
|
||||||
tests/vulkan
|
tests/triangle-vulkan
|
||||||
tests/windows
|
tests/windows
|
||||||
|
|
||||||
|
|
10
.mailmap
Normal file
10
.mailmap
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
Camilla Löwy <elmindreda@glfw.org> <elmindreda@users.sourceforge.net>
|
||||||
|
Camilla Löwy <elmindreda@glfw.org> <elmindreda@elmindreda.org>
|
||||||
|
Camilla Löwy <elmindreda@glfw.org>
|
||||||
|
|
||||||
|
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
|
||||||
|
|
||||||
|
Marcus Geelnard <m@bitsnbites.eu> <marcus256@users.sourceforge.net>
|
||||||
|
Marcus Geelnard <m@bitsnbites.eu> <marcus@geelnards-pc.(none)>
|
||||||
|
Marcus Geelnard <m@bitsnbites.eu>
|
||||||
|
|
56
.travis.yml
56
.travis.yml
|
@ -4,31 +4,47 @@ branches:
|
||||||
only:
|
only:
|
||||||
- ci
|
- ci
|
||||||
- master
|
- master
|
||||||
sudo: false
|
- 3.3-stable
|
||||||
dist: trusty
|
|
||||||
addons:
|
|
||||||
apt:
|
|
||||||
packages:
|
|
||||||
- cmake
|
|
||||||
- libxrandr-dev
|
|
||||||
- libxinerama-dev
|
|
||||||
- libxcursor-dev
|
|
||||||
- libxi-dev
|
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
- os: linux
|
- os: linux
|
||||||
|
dist: xenial
|
||||||
|
sudo: false
|
||||||
|
name: "X11 shared library"
|
||||||
|
addons:
|
||||||
|
apt:
|
||||||
|
packages:
|
||||||
|
- libxrandr-dev
|
||||||
|
- libxinerama-dev
|
||||||
|
- libxcursor-dev
|
||||||
|
- libxi-dev
|
||||||
env:
|
env:
|
||||||
- BUILD_SHARED_LIBS=ON
|
- BUILD_SHARED_LIBS=ON
|
||||||
- CFLAGS=-Werror
|
- CFLAGS=-Werror
|
||||||
- os: linux
|
- os: linux
|
||||||
|
dist: xenial
|
||||||
|
sudo: false
|
||||||
|
name: "X11 static library"
|
||||||
|
addons:
|
||||||
|
apt:
|
||||||
|
packages:
|
||||||
|
- libxrandr-dev
|
||||||
|
- libxinerama-dev
|
||||||
|
- libxcursor-dev
|
||||||
|
- libxi-dev
|
||||||
env:
|
env:
|
||||||
- BUILD_SHARED_LIBS=OFF
|
- BUILD_SHARED_LIBS=OFF
|
||||||
- CFLAGS=-Werror
|
- CFLAGS=-Werror
|
||||||
- os: linux
|
- os: linux
|
||||||
|
dist: xenial
|
||||||
sudo: required
|
sudo: required
|
||||||
|
name: "Wayland shared library"
|
||||||
addons:
|
addons:
|
||||||
apt:
|
apt:
|
||||||
|
sources:
|
||||||
|
- ppa:kubuntu-ppa/backports
|
||||||
packages:
|
packages:
|
||||||
|
- extra-cmake-modules
|
||||||
- libwayland-dev
|
- libwayland-dev
|
||||||
- libxkbcommon-dev
|
- libxkbcommon-dev
|
||||||
- libegl1-mesa-dev
|
- libegl1-mesa-dev
|
||||||
|
@ -37,10 +53,15 @@ matrix:
|
||||||
- BUILD_SHARED_LIBS=ON
|
- BUILD_SHARED_LIBS=ON
|
||||||
- CFLAGS=-Werror
|
- CFLAGS=-Werror
|
||||||
- os: linux
|
- os: linux
|
||||||
|
dist: xenial
|
||||||
sudo: required
|
sudo: required
|
||||||
|
name: "Wayland static library"
|
||||||
addons:
|
addons:
|
||||||
apt:
|
apt:
|
||||||
|
sources:
|
||||||
|
- ppa:kubuntu-ppa/backports
|
||||||
packages:
|
packages:
|
||||||
|
- extra-cmake-modules
|
||||||
- libwayland-dev
|
- libwayland-dev
|
||||||
- libxkbcommon-dev
|
- libxkbcommon-dev
|
||||||
- libegl1-mesa-dev
|
- libegl1-mesa-dev
|
||||||
|
@ -49,20 +70,27 @@ matrix:
|
||||||
- BUILD_SHARED_LIBS=OFF
|
- BUILD_SHARED_LIBS=OFF
|
||||||
- CFLAGS=-Werror
|
- CFLAGS=-Werror
|
||||||
- os: osx
|
- os: osx
|
||||||
|
sudo: false
|
||||||
|
name: "Cocoa shared library"
|
||||||
env:
|
env:
|
||||||
- BUILD_SHARED_LIBS=ON
|
- BUILD_SHARED_LIBS=ON
|
||||||
- CFLAGS=-Werror
|
- CFLAGS=-Werror
|
||||||
|
- MACOSX_DEPLOYMENT_TARGET=10.8
|
||||||
- os: osx
|
- os: osx
|
||||||
|
sudo: false
|
||||||
|
name: "Cocoa static library"
|
||||||
env:
|
env:
|
||||||
- BUILD_SHARED_LIBS=OFF
|
- BUILD_SHARED_LIBS=OFF
|
||||||
- CFLAGS=-Werror
|
- CFLAGS=-Werror
|
||||||
|
- MACOSX_DEPLOYMENT_TARGET=10.8
|
||||||
script:
|
script:
|
||||||
- if grep -Inr '\s$' src include docs tests examples CMake *.md .gitattributes .gitignore; then echo Trailing whitespace found, aborting.; exit 1; fi
|
- if grep -Inr '\s$' src include docs tests examples CMake *.md .gitattributes .gitignore; then
|
||||||
|
echo Trailing whitespace found, aborting;
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
- mkdir build
|
- mkdir build
|
||||||
- cd build
|
- cd build
|
||||||
- if test -n "${USE_WAYLAND}";
|
- if test -n "${USE_WAYLAND}"; then
|
||||||
then wget https://mirrors.kernel.org/ubuntu/pool/universe/e/extra-cmake-modules/extra-cmake-modules_5.38.0a-0ubuntu1_amd64.deb;
|
|
||||||
sudo dpkg -i extra-cmake-modules_5.38.0a-0ubuntu1_amd64.deb;
|
|
||||||
git clone git://anongit.freedesktop.org/wayland/wayland-protocols;
|
git clone git://anongit.freedesktop.org/wayland/wayland-protocols;
|
||||||
pushd wayland-protocols;
|
pushd wayland-protocols;
|
||||||
git checkout 1.15 && ./autogen.sh --prefix=/usr && make && sudo make install;
|
git checkout 1.15 && ./autogen.sh --prefix=/usr && make && sudo make install;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
cmake_minimum_required(VERSION 3.0)
|
cmake_minimum_required(VERSION 3.0)
|
||||||
|
|
||||||
project(GLFW C)
|
project(GLFW VERSION 3.3.1 LANGUAGES C)
|
||||||
|
|
||||||
set(CMAKE_LEGACY_CYGWIN_WIN32 OFF)
|
set(CMAKE_LEGACY_CYGWIN_WIN32 OFF)
|
||||||
|
|
||||||
|
@ -8,12 +8,9 @@ if (POLICY CMP0054)
|
||||||
cmake_policy(SET CMP0054 NEW)
|
cmake_policy(SET CMP0054 NEW)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(GLFW_VERSION_MAJOR "3")
|
if (POLICY CMP0077)
|
||||||
set(GLFW_VERSION_MINOR "3")
|
cmake_policy(SET CMP0077 NEW)
|
||||||
set(GLFW_VERSION_PATCH "0")
|
endif()
|
||||||
set(GLFW_VERSION_EXTRA "")
|
|
||||||
set(GLFW_VERSION "${GLFW_VERSION_MAJOR}.${GLFW_VERSION_MINOR}")
|
|
||||||
set(GLFW_VERSION_FULL "${GLFW_VERSION}.${GLFW_VERSION_PATCH}${GLFW_VERSION_EXTRA}")
|
|
||||||
|
|
||||||
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
||||||
|
|
||||||
|
@ -25,22 +22,16 @@ option(GLFW_INSTALL "Generate installation target" ON)
|
||||||
option(GLFW_VULKAN_STATIC "Assume the Vulkan loader is linked with the application" OFF)
|
option(GLFW_VULKAN_STATIC "Assume the Vulkan loader is linked with the application" OFF)
|
||||||
|
|
||||||
include(GNUInstallDirs)
|
include(GNUInstallDirs)
|
||||||
|
include(CMakeDependentOption)
|
||||||
|
|
||||||
if (UNIX)
|
cmake_dependent_option(GLFW_USE_OSMESA "Use OSMesa for offscreen context creation" OFF
|
||||||
option(GLFW_USE_OSMESA "Use OSMesa for offscreen context creation" OFF)
|
"UNIX" OFF)
|
||||||
endif()
|
cmake_dependent_option(GLFW_USE_HYBRID_HPG "Force use of high-performance GPU on hybrid systems" OFF
|
||||||
|
"WIN32" OFF)
|
||||||
if (WIN32)
|
cmake_dependent_option(GLFW_USE_WAYLAND "Use Wayland for window creation" OFF
|
||||||
option(GLFW_USE_HYBRID_HPG "Force use of high-performance GPU on hybrid systems" OFF)
|
"UNIX;NOT APPLE" OFF)
|
||||||
endif()
|
cmake_dependent_option(USE_MSVC_RUNTIME_LIBRARY_DLL "Use MSVC runtime library DLL" ON
|
||||||
|
"MSVC" OFF)
|
||||||
if (UNIX AND NOT APPLE)
|
|
||||||
option(GLFW_USE_WAYLAND "Use Wayland for window creation" OFF)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if (MSVC)
|
|
||||||
option(USE_MSVC_RUNTIME_LIBRARY_DLL "Use MSVC runtime library DLL" ON)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if (BUILD_SHARED_LIBS)
|
if (BUILD_SHARED_LIBS)
|
||||||
set(_GLFW_BUILD_DLL 1)
|
set(_GLFW_BUILD_DLL 1)
|
||||||
|
@ -80,7 +71,7 @@ if (MSVC)
|
||||||
include(CheckIncludeFile)
|
include(CheckIncludeFile)
|
||||||
check_include_file(dinput.h DINPUT_H_FOUND)
|
check_include_file(dinput.h DINPUT_H_FOUND)
|
||||||
if (NOT DINPUT_H_FOUND)
|
if (NOT DINPUT_H_FOUND)
|
||||||
message(FATAL_ERROR "DirectX 9 SDK not found")
|
message(FATAL_ERROR "DirectX 9 headers not found; install DirectX 9 SDK")
|
||||||
endif()
|
endif()
|
||||||
# Workaround for VS 2008 not shipping with stdint.h
|
# Workaround for VS 2008 not shipping with stdint.h
|
||||||
list(APPEND glfw_INCLUDE_DIRS "${GLFW_SOURCE_DIR}/deps/vs2008")
|
list(APPEND glfw_INCLUDE_DIRS "${GLFW_SOURCE_DIR}/deps/vs2008")
|
||||||
|
@ -211,29 +202,35 @@ if (_GLFW_X11)
|
||||||
list(APPEND glfw_LIBRARIES "${X11_X11_LIB}" "${CMAKE_THREAD_LIBS_INIT}")
|
list(APPEND glfw_LIBRARIES "${X11_X11_LIB}" "${CMAKE_THREAD_LIBS_INIT}")
|
||||||
|
|
||||||
# Check for XRandR (modern resolution switching and gamma control)
|
# Check for XRandR (modern resolution switching and gamma control)
|
||||||
if (NOT X11_Xrandr_FOUND)
|
if (NOT X11_Xrandr_INCLUDE_PATH)
|
||||||
message(FATAL_ERROR "The RandR headers were not found")
|
message(FATAL_ERROR "RandR headers not found; install libxrandr development package")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Check for Xinerama (legacy multi-monitor support)
|
# Check for Xinerama (legacy multi-monitor support)
|
||||||
if (NOT X11_Xinerama_FOUND)
|
if (NOT X11_Xinerama_INCLUDE_PATH)
|
||||||
message(FATAL_ERROR "The Xinerama headers were not found")
|
message(FATAL_ERROR "Xinerama headers not found; install libxinerama development package")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Check for Xkb (X keyboard extension)
|
# Check for Xkb (X keyboard extension)
|
||||||
if (NOT X11_Xkb_FOUND)
|
if (NOT X11_Xkb_INCLUDE_PATH)
|
||||||
message(FATAL_ERROR "The X keyboard extension headers were not found")
|
message(FATAL_ERROR "XKB headers not found; install X11 development package")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Check for Xcursor (cursor creation from RGBA images)
|
# Check for Xcursor (cursor creation from RGBA images)
|
||||||
if (NOT X11_Xcursor_FOUND)
|
if (NOT X11_Xcursor_INCLUDE_PATH)
|
||||||
message(FATAL_ERROR "The Xcursor headers were not found")
|
message(FATAL_ERROR "Xcursor headers not found; install libxcursor development package")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Check for XInput (modern HID input)
|
||||||
|
if (NOT X11_Xi_INCLUDE_PATH)
|
||||||
|
message(FATAL_ERROR "XInput headers not found; install libxi development package")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
list(APPEND glfw_INCLUDE_DIRS "${X11_Xrandr_INCLUDE_PATH}"
|
list(APPEND glfw_INCLUDE_DIRS "${X11_Xrandr_INCLUDE_PATH}"
|
||||||
"${X11_Xinerama_INCLUDE_PATH}"
|
"${X11_Xinerama_INCLUDE_PATH}"
|
||||||
"${X11_Xkb_INCLUDE_PATH}"
|
"${X11_Xkb_INCLUDE_PATH}"
|
||||||
"${X11_Xcursor_INCLUDE_PATH}")
|
"${X11_Xcursor_INCLUDE_PATH}"
|
||||||
|
"${X11_Xi_INCLUDE_PATH}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
#--------------------------------------------------------------------
|
#--------------------------------------------------------------------
|
||||||
|
@ -285,11 +282,10 @@ if (_GLFW_COCOA)
|
||||||
list(APPEND glfw_LIBRARIES
|
list(APPEND glfw_LIBRARIES
|
||||||
"-framework Cocoa"
|
"-framework Cocoa"
|
||||||
"-framework IOKit"
|
"-framework IOKit"
|
||||||
"-framework CoreFoundation"
|
"-framework CoreFoundation")
|
||||||
"-framework CoreVideo")
|
|
||||||
|
|
||||||
set(glfw_PKG_DEPS "")
|
set(glfw_PKG_DEPS "")
|
||||||
set(glfw_PKG_LIBS "-framework Cocoa -framework IOKit -framework CoreFoundation -framework CoreVideo")
|
set(glfw_PKG_LIBS "-framework Cocoa -framework IOKit -framework CoreFoundation")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
#--------------------------------------------------------------------
|
#--------------------------------------------------------------------
|
||||||
|
@ -322,7 +318,7 @@ configure_package_config_file(src/glfw3Config.cmake.in
|
||||||
NO_CHECK_REQUIRED_COMPONENTS_MACRO)
|
NO_CHECK_REQUIRED_COMPONENTS_MACRO)
|
||||||
|
|
||||||
write_basic_package_version_file(src/glfw3ConfigVersion.cmake
|
write_basic_package_version_file(src/glfw3ConfigVersion.cmake
|
||||||
VERSION ${GLFW_VERSION_FULL}
|
VERSION ${GLFW_VERSION}
|
||||||
COMPATIBILITY SameMajorVersion)
|
COMPATIBILITY SameMajorVersion)
|
||||||
|
|
||||||
configure_file(src/glfw_config.h.in src/glfw_config.h @ONLY)
|
configure_file(src/glfw_config.h.in src/glfw_config.h @ONLY)
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
Copyright (c) 2002-2006 Marcus Geelnard
|
Copyright (c) 2002-2006 Marcus Geelnard
|
||||||
Copyright (c) 2006-2016 Camilla Löwy <elmindreda@glfw.org>
|
|
||||||
|
Copyright (c) 2006-2019 Camilla Löwy
|
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied
|
This software is provided 'as-is', without any express or implied
|
||||||
warranty. In no event will the authors be held liable for any damages
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
|
235
README.md
235
README.md
|
@ -11,7 +11,7 @@ application development. It provides a simple, platform-independent API for
|
||||||
creating windows, contexts and surfaces, reading input, handling events, etc.
|
creating windows, contexts and surfaces, reading input, handling events, etc.
|
||||||
|
|
||||||
GLFW natively supports Windows, macOS and Linux and other Unix-like systems. On
|
GLFW natively supports Windows, macOS and Linux and other Unix-like systems. On
|
||||||
Linux both X11 and Wayland is 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](http://www.glfw.org/license.html).
|
||||||
|
@ -88,7 +88,7 @@ in the documentation for more information.
|
||||||
GLFW itself depends only on the headers and libraries for your window system.
|
GLFW itself depends only on the headers and libraries for your window system.
|
||||||
|
|
||||||
The (experimental) Wayland backend also depends on the `extra-cmake-modules`
|
The (experimental) Wayland backend also depends on the `extra-cmake-modules`
|
||||||
package, which is used to generated Wayland protocol headers.
|
package, which is used to generate Wayland protocol headers.
|
||||||
|
|
||||||
The examples and test programs depend on a number of tiny libraries. These are
|
The examples and test programs depend on a number of tiny libraries. These are
|
||||||
located in the `deps/` directory.
|
located in the `deps/` directory.
|
||||||
|
@ -118,188 +118,39 @@ information on what to include when reporting a bug.
|
||||||
|
|
||||||
## Changelog
|
## Changelog
|
||||||
|
|
||||||
- Added `glfwGetError` function for querying the last error code and its
|
- Bugfix: The CMake config-file package used an absolute path and was not
|
||||||
description (#970)
|
relocatable (#1470)
|
||||||
- Added `glfwUpdateGamepadMappings` function for importing gamepad mappings in
|
- Bugfix: Video modes with a duplicate screen area were discarded (#1555,#1556)
|
||||||
SDL\_GameControllerDB format (#900)
|
- Bugfix: Compiling with -Wextra-semi caused warnings (#1440)
|
||||||
- Added `glfwJoystickIsGamepad` function for querying whether a joystick has
|
- Bugfix: Built-in mappings failed because some OEMs re-used VID/PID (#1583)
|
||||||
a gamepad mapping (#900)
|
- [Win32] Bugfix: `GLFW_INCLUDE_VULKAN` plus `VK_USE_PLATFORM_WIN32_KHR` caused
|
||||||
- Added `glfwGetJoystickGUID` function for querying the SDL compatible GUID of
|
symbol redefinition (#1524)
|
||||||
a joystick (#900)
|
- [Win32] Bugfix: The cursor position event was emitted before its cursor enter
|
||||||
- Added `glfwGetGamepadName` function for querying the name provided by the
|
event (#1490)
|
||||||
gamepad mapping (#900)
|
- [Win32] Bugfix: The window hint `GLFW_MAXIMIZED` did not move or resize the
|
||||||
- Added `glfwGetGamepadState` function, `GLFW_GAMEPAD_*` and `GLFWgamepadstate`
|
window (#1499)
|
||||||
for retrieving gamepad input state (#900)
|
- [Win32] Bugfix: Disabled cursor mode interfered with some non-client actions
|
||||||
- Added `glfwGetWindowContentScale`, `glfwGetMonitorContentScale` and
|
- [Cocoa] Removed dependency on the CoreVideo framework
|
||||||
`glfwSetWindowContentScaleCallback` for DPI-aware rendering
|
- [Cocoa] Bugfix: `glfwSetWindowSize` used a bottom-left anchor point (#1553)
|
||||||
(#235,#439,#677,#845,#898)
|
- [Cocoa] Bugfix: Window remained on screen after destruction until event poll
|
||||||
- Added `glfwRequestWindowAttention` function for requesting attention from the
|
(#1412)
|
||||||
user (#732,#988)
|
- [Cocoa] Bugfix: Event processing before window creation would assert (#1543)
|
||||||
- Added `glfwGetMonitorWorkarea` function for retrieving the monitor work area
|
- [Cocoa] Bugfix: Undecorated windows could not be iconified on recent macOS
|
||||||
(#920,#989,#1322)
|
- [X11] Bugfix: The CMake files did not check for the XInput headers (#1480)
|
||||||
- Added `glfwGetKeyScancode` function that allows retrieving platform dependent
|
- [X11] Bugfix: Key names were not updated when the keyboard layout changed
|
||||||
scancodes for keys (#830)
|
(#1462,#1528)
|
||||||
- Added `glfwSetWindowMaximizeCallback` and `GLFWwindowmaximizefun` for
|
- [X11] Bugfix: Decorations could not be enabled after window creation (#1566)
|
||||||
receiving window maximization events (#778)
|
- [X11] Bugfix: Content scale fallback value could be inconsistent (#1578)
|
||||||
- Added `glfwSetWindowAttrib` function for changing window attributes (#537)
|
- [X11] Bugfix: `glfwMaximizeWindow` had no effect on hidden windows
|
||||||
- Added `glfwGetJoystickHats` function for querying joystick hats
|
- [X11] Bugfix: Clearing `GLFW_FLOATING` on a hidden window caused invalid read
|
||||||
(#889,#906,#934)
|
- [X11] Bugfix: Changing `GLFW_FLOATING` on a hidden window could silently fail
|
||||||
- Added `glfwInitHint` for setting initialization hints
|
- [X11] Bugfix: Disabled cursor mode was interrupted by indicator windows
|
||||||
- Added `glfwWindowHintString` for setting string type window hints (#893,#1139)
|
- [X11] Bugfix: Monitor physical dimensions could be reported as zero mm
|
||||||
- Added `glfwGetWindowOpacity` and `glfwSetWindowOpacity` for controlling whole
|
- [X11] Bugfix: Window position events were not emitted during resizing (#1613)
|
||||||
window transparency (#1089)
|
- [Wayland] Bugfix: The `GLFW_HAND_CURSOR` shape used the wrong image (#1432)
|
||||||
- Added `glfwSetMonitorUserPointer` and `glfwGetMonitorUserPointer` for
|
- [NSGL] Bugfix: `GLFW_COCOA_RETINA_FRAMEBUFFER` had no effect on newer
|
||||||
per-monitor user pointers
|
macOS versions (#1442)
|
||||||
- Added `glfwSetJoystickUserPointer` and `glfwGetJoystickUserPointer` for
|
- [NSGL] Bugfix: Workaround for swap interval on 10.14 broke on 10.12 (#1483)
|
||||||
per-joystick user pointers
|
|
||||||
- Added `glfwGetX11SelectionString` and `glfwSetX11SelectionString`
|
|
||||||
functions for accessing X11 primary selection (#894,#1056)
|
|
||||||
- Added `glfwRawMouseMotionSupported` function for querying raw motion support
|
|
||||||
(#125,#1400,#1401)
|
|
||||||
- Added headless [OSMesa](http://mesa3d.org/osmesa.html) backend (#850)
|
|
||||||
- Added definition of `GLAPIENTRY` to public header
|
|
||||||
- Added `GLFW_TRANSPARENT_FRAMEBUFFER` window hint and attribute for controlling
|
|
||||||
per-pixel framebuffer transparency (#197,#663,#715,#723,#1078)
|
|
||||||
- Added `GLFW_HOVERED` window attribute for polling cursor hover state (#1166)
|
|
||||||
- Added `GLFW_CENTER_CURSOR` window hint for controlling cursor centering
|
|
||||||
(#749,#842)
|
|
||||||
- Added `GLFW_FOCUS_ON_SHOW` window hint and attribute to control input focus
|
|
||||||
on calling show window (#1189)
|
|
||||||
- Added `GLFW_SCALE_TO_MONITOR` window hint for automatic window resizing
|
|
||||||
(#676,#1115)
|
|
||||||
- Added `GLFW_JOYSTICK_HAT_BUTTONS` init hint (#889)
|
|
||||||
- Added `GLFW_LOCK_KEY_MODS` input mode and `GLFW_MOD_*_LOCK` mod bits (#946)
|
|
||||||
- Added `GLFW_RAW_MOUSE_MOTION` input mode for selecting raw motion input
|
|
||||||
(#125,#1400,#1401)
|
|
||||||
- Added macOS specific `GLFW_COCOA_RETINA_FRAMEBUFFER` window hint
|
|
||||||
- Added macOS specific `GLFW_COCOA_FRAME_NAME` window hint (#195)
|
|
||||||
- Added macOS specific `GLFW_COCOA_GRAPHICS_SWITCHING` window hint (#377,#935)
|
|
||||||
- Added macOS specific `GLFW_COCOA_CHDIR_RESOURCES` init hint
|
|
||||||
- Added macOS specific `GLFW_COCOA_MENUBAR` init hint
|
|
||||||
- Added X11 specific `GLFW_X11_CLASS_NAME` and `GLFW_X11_INSTANCE_NAME` window
|
|
||||||
hints (#893,#1139)
|
|
||||||
- Added `GLFW_INCLUDE_ES32` for including the OpenGL ES 3.2 header
|
|
||||||
- Added `GLFW_OSMESA_CONTEXT_API` for creating OpenGL contexts with
|
|
||||||
[OSMesa](https://www.mesa3d.org/osmesa.html) (#281)
|
|
||||||
- Added `GenerateMappings.cmake` script for updating gamepad mappings
|
|
||||||
- Made `glfwCreateWindowSurface` emit an error when the window has a context
|
|
||||||
(#1194,#1205)
|
|
||||||
- Deprecated window parameter of clipboard string functions
|
|
||||||
- Deprecated charmods callback
|
|
||||||
- Removed `GLFW_USE_RETINA` compile-time option
|
|
||||||
- Removed `GLFW_USE_CHDIR` compile-time option
|
|
||||||
- Removed `GLFW_USE_MENUBAR` compile-time option
|
|
||||||
- Removed requirement of at least one window for `glfwWaitEvents` and
|
|
||||||
`glfwPostEmptyEvent` (#1317)
|
|
||||||
- Removed all dependencies on the Vulkan SDK
|
|
||||||
- Bugfix: Calling `glfwMaximizeWindow` on a full screen window was not ignored
|
|
||||||
- Bugfix: `GLFW_INCLUDE_VULKAN` could not be combined with the corresponding
|
|
||||||
OpenGL and OpenGL ES header macros
|
|
||||||
- Bugfix: `glfwGetInstanceProcAddress` returned `NULL` for
|
|
||||||
`vkGetInstanceProcAddr` when `_GLFW_VULKAN_STATIC` was enabled
|
|
||||||
- Bugfix: Invalid library paths were used in test and example CMake files (#930)
|
|
||||||
- Bugfix: The scancode for synthetic key release events was always zero
|
|
||||||
- Bugfix: The generated Doxyfile did not handle paths with spaces (#1081)
|
|
||||||
- Bugfix: The gamma ramp generated by `glfwSetGamma` did not use the monitor
|
|
||||||
ramp size (#1387,#1388)
|
|
||||||
- [Win32] Added system error strings to relevant GLFW error descriptions (#733)
|
|
||||||
- [Win32] Removed XInput circular deadzone from joystick axis data (#1045)
|
|
||||||
- [Win32] Bugfix: Undecorated windows could not be iconified by the user (#861)
|
|
||||||
- [Win32] Bugfix: Deadzone logic could underflow with some controllers (#910)
|
|
||||||
- [Win32] Bugfix: `glfwVulkanSupported` emitted an error on systems with
|
|
||||||
a loader but no ICD (#916)
|
|
||||||
- [Win32] Bugfix: Non-iconified full sreeen windows did not prevent screen
|
|
||||||
blanking or password enabled screensavers (#851)
|
|
||||||
- [Win32] Bugfix: Mouse capture logic lost secondary release messages (#954)
|
|
||||||
- [Win32] Bugfix: Monitors with no display devices were not enumerated (#960)
|
|
||||||
- [Win32] Bugfix: Monitor events were not emitted (#784)
|
|
||||||
- [Win32] Bugfix: The DLL was installed to the wrong directory on Cygwin (#1035)
|
|
||||||
- [Win32] Bugfix: Normalization of axis data via XInput was incorrect (#1045)
|
|
||||||
- [Win32] Bugfix: `glfw3native.h` would undefine a foreign `APIENTRY` (#1062)
|
|
||||||
- [Win32] Bugfix: Disabled cursor mode prevented use of caption buttons
|
|
||||||
(#650,#1071)
|
|
||||||
- [Win32] Bugfix: Returned key names did not match other platforms (#943)
|
|
||||||
- [Win32] Bugfix: Undecorated windows did not maximize to workarea (#899)
|
|
||||||
- [Win32] Bugfix: Window was resized twice when entering full screen (#1085)
|
|
||||||
- [Win32] Bugfix: The HID device notification was not unregistered (#1170)
|
|
||||||
- [Win32] Bugfix: `glfwCreateWindow` activated window even with `GLFW_FOCUSED`
|
|
||||||
hint set to false (#1179,#1180)
|
|
||||||
- [Win32] Bugfix: The keypad equals key was reported as `GLFW_KEY_UNKNOWN`
|
|
||||||
(#1315,#1316)
|
|
||||||
- [Win32] Bugfix: A title bar would be drawn over undecorated windows in some
|
|
||||||
circumstances (#1383)
|
|
||||||
- [Win32] Bugfix: Standard cursors were not per-monitor DPI aware (#1431)
|
|
||||||
- [X11] Replaced `_GLFW_HAS_XF86VM` compile-time option with dynamic loading
|
|
||||||
- [X11] Bugfix: `glfwGetVideoMode` would segfault on Cygwin/X
|
|
||||||
- [X11] Bugfix: Dynamic X11 library loading did not use full sonames (#941)
|
|
||||||
- [X11] Bugfix: Window creation on 64-bit would read past top of stack (#951)
|
|
||||||
- [X11] Bugfix: XDND support had multiple non-conformance issues (#968)
|
|
||||||
- [X11] Bugfix: The RandR monitor path was disabled despite working RandR (#972)
|
|
||||||
- [X11] Bugfix: IM-duplicated key events would leak at low polling rates (#747)
|
|
||||||
- [X11] Bugfix: Gamma ramp setting via RandR did not validate ramp size
|
|
||||||
- [X11] Bugfix: Key name string encoding depended on current locale (#981,#983)
|
|
||||||
- [X11] Bugfix: Incremental reading of selections was not supported (#275)
|
|
||||||
- [X11] Bugfix: Selection I/O reported but did not support `COMPOUND_TEXT`
|
|
||||||
- [X11] Bugfix: Latin-1 text read from selections was not converted to UTF-8
|
|
||||||
- [X11] Bugfix: NVidia EGL would segfault if unloaded before closing the display
|
|
||||||
- [X11] Bugfix: Checking window maximized attrib could crash some WMs (#1356)
|
|
||||||
- [X11] Bugfix: Update cursor position on enter event (#1366)
|
|
||||||
- [X11] Bugfix: `glfwSetWindowMonitor` did not update hints when resizing
|
|
||||||
non-user-resizable windows
|
|
||||||
- [X11] Bugfix: `glfwSetWindowMonitor` did not flush output buffer in some cases
|
|
||||||
- [X11] Bugfix: `glfwSetWindowMonitor` did not update the EWMH state of hidden
|
|
||||||
windows (#1358)
|
|
||||||
- [Linux] Added workaround for missing `SYN_DROPPED` in pre-2.6.39 kernel
|
|
||||||
headers (#1196)
|
|
||||||
- [Linux] Moved to evdev for joystick input (#906,#1005)
|
|
||||||
- [Linux] Bugfix: Event processing did not detect joystick disconnection (#932)
|
|
||||||
- [Linux] Bugfix: The joystick device path could be truncated (#1025)
|
|
||||||
- [Linux] Bugfix: `glfwInit` would fail if inotify creation failed (#833)
|
|
||||||
- [Linux] Bugfix: `strdup` was used without any required feature macro (#1055)
|
|
||||||
- [Cocoa] Added support for Vulkan window surface creation via
|
|
||||||
[MoltenVK](https://moltengl.com/moltenvk/) (#870)
|
|
||||||
- [Cocoa] Added support for loading a `MainMenu.nib` when available
|
|
||||||
- [Cocoa] Disabled automatic window tabbing for created windows (#1250)
|
|
||||||
- [Cocoa] Bugfix: Disabling window aspect ratio would assert (#852)
|
|
||||||
- [Cocoa] Bugfix: Window creation failed to set first responder (#876,#883)
|
|
||||||
- [Cocoa] Bugfix: Removed use of deprecated `CGDisplayIOServicePort` function
|
|
||||||
(#165,#192,#508,#511)
|
|
||||||
- [Cocoa] Bugfix: Disabled use of deprecated `CGDisplayModeCopyPixelEncoding`
|
|
||||||
function on macOS 10.12+
|
|
||||||
- [Cocoa] Bugfix: Running in AppSandbox would emit warnings (#816,#882)
|
|
||||||
- [Cocoa] Bugfix: Windows created after the first were not cascaded (#195)
|
|
||||||
- [Cocoa] Bugfix: Leaving video mode with `glfwSetWindowMonitor` would set
|
|
||||||
incorrect position and size (#748)
|
|
||||||
- [Cocoa] Bugfix: Iconified full screen windows could not be restored (#848)
|
|
||||||
- [Cocoa] Bugfix: Value range was ignored for joystick hats and buttons (#888)
|
|
||||||
- [Cocoa] Bugfix: Full screen framebuffer was incorrectly sized for some video
|
|
||||||
modes (#682)
|
|
||||||
- [Cocoa] Bugfix: A string object for IME was updated non-idiomatically (#1050)
|
|
||||||
- [Cocoa] Bugfix: A hidden or disabled cursor would become visible when a user
|
|
||||||
notification was shown (#971,#1028)
|
|
||||||
- [Cocoa] Bugfix: Some characters did not repeat due to Press and Hold (#1010)
|
|
||||||
- [Cocoa] Bugfix: Window title was lost when full screen or undecorated (#1082)
|
|
||||||
- [Cocoa] Bugfix: Window was resized twice when entering full screen (#1085)
|
|
||||||
- [Cocoa] Bugfix: Duplicate size events were not filtered (#1085)
|
|
||||||
- [Cocoa] Bugfix: Event polling did not initialize AppKit if necessary (#1218)
|
|
||||||
- [Cocoa] Bugfix: OpenGL rendering was not visible before resize on early macOS
|
|
||||||
10.14 (#1334,#1346)
|
|
||||||
- [Cocoa] Bugfix: Caps Lock did not generate any key events (#1368,#1373)
|
|
||||||
- [Cocoa] Bugfix: Some buttons for some joysticks were ignored (#1385)
|
|
||||||
- [Cocoa] Bugfix: Analog joystick buttons were not translated correctly (#1385)
|
|
||||||
- [Cocoa] Bugfix: OpenGL swap interval was ignored for occluded windows (#680)
|
|
||||||
- [Cocoa] Bugfix: OpenGL swap interval was ignored on early macOS 10.14
|
|
||||||
(#1337,#1417,#1435)
|
|
||||||
- [Cocoa] Bugfix: The y-coordinate was incorrect for `glfwGetCursorPos` and
|
|
||||||
`glfwSetCursorPos` (#1461)
|
|
||||||
- [WGL] Added support for `WGL_EXT_colorspace` for OpenGL ES contexts
|
|
||||||
- [WGL] Added support for `WGL_ARB_create_context_no_error`
|
|
||||||
- [GLX] Added support for `GLX_ARB_create_context_no_error`
|
|
||||||
- [GLX] Bugfix: Context creation could segfault if no GLXFBConfigs were
|
|
||||||
available (#1040)
|
|
||||||
- [EGL] Added support for `EGL_KHR_get_all_proc_addresses` (#871)
|
|
||||||
- [EGL] Added support for `EGL_KHR_context_flush_control`
|
|
||||||
- [EGL] Bugfix: The test for `EGL_RGB_BUFFER` was invalid
|
|
||||||
|
|
||||||
|
|
||||||
## Contact
|
## Contact
|
||||||
|
@ -308,7 +159,7 @@ On [glfw.org](http://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](http://discourse.glfw.org/), and the `#glfw` IRC channel on
|
[forum](https://discourse.glfw.org/), and the `#glfw` IRC channel on
|
||||||
[Freenode](http://freenode.net/).
|
[Freenode](http://freenode.net/).
|
||||||
|
|
||||||
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
|
||||||
|
@ -338,6 +189,7 @@ skills.
|
||||||
- blanco
|
- blanco
|
||||||
- Kyle Brenneman
|
- Kyle Brenneman
|
||||||
- Rok Breulj
|
- Rok Breulj
|
||||||
|
- Kai Burjack
|
||||||
- Martin Capitanio
|
- Martin Capitanio
|
||||||
- David Carlier
|
- David Carlier
|
||||||
- Arturo Castro
|
- Arturo Castro
|
||||||
|
@ -370,6 +222,8 @@ skills.
|
||||||
- Mário Freitas
|
- Mário Freitas
|
||||||
- GeO4d
|
- GeO4d
|
||||||
- Marcus Geelnard
|
- Marcus Geelnard
|
||||||
|
- Charles Giessen
|
||||||
|
- Ryan C. Gordon
|
||||||
- Stephen Gowen
|
- Stephen Gowen
|
||||||
- Kovid Goyal
|
- Kovid Goyal
|
||||||
- Eloi Marín Gratacós
|
- Eloi Marín Gratacós
|
||||||
|
@ -381,6 +235,7 @@ skills.
|
||||||
- Lucas Hinderberger
|
- Lucas Hinderberger
|
||||||
- Paul Holden
|
- Paul Holden
|
||||||
- Warren Hu
|
- Warren Hu
|
||||||
|
- Charles Huber
|
||||||
- IntellectualKitty
|
- IntellectualKitty
|
||||||
- Aaron Jacobs
|
- Aaron Jacobs
|
||||||
- Erik S. V. Jansson
|
- Erik S. V. Jansson
|
||||||
|
@ -393,13 +248,17 @@ skills.
|
||||||
- Peter Knut
|
- Peter Knut
|
||||||
- Christoph Kubisch
|
- Christoph Kubisch
|
||||||
- Yuri Kunde Schlesner
|
- Yuri Kunde Schlesner
|
||||||
|
- Rokas Kupstys
|
||||||
- Konstantin Käfer
|
- Konstantin Käfer
|
||||||
- Eric Larson
|
- Eric Larson
|
||||||
- Robin Leffmann
|
- Robin Leffmann
|
||||||
- Glenn Lewis
|
- Glenn Lewis
|
||||||
- Shane Liesegang
|
- Shane Liesegang
|
||||||
|
- Anders Lindqvist
|
||||||
|
- Leon Linhart
|
||||||
- Eyal Lotem
|
- Eyal Lotem
|
||||||
- Aaron Loucks
|
- Aaron Loucks
|
||||||
|
- Luflosi
|
||||||
- Tristam MacDonald
|
- Tristam MacDonald
|
||||||
- Hans Mackowiak
|
- Hans Mackowiak
|
||||||
- Дмитри Малышев
|
- Дмитри Малышев
|
||||||
|
@ -412,6 +271,7 @@ skills.
|
||||||
- Jonathan Mercier
|
- Jonathan Mercier
|
||||||
- Marcel Metz
|
- Marcel Metz
|
||||||
- Liam Middlebrook
|
- Liam Middlebrook
|
||||||
|
- Ave Milia
|
||||||
- Jonathan Miller
|
- Jonathan Miller
|
||||||
- Kenneth Miller
|
- Kenneth Miller
|
||||||
- Bruce Mitchener
|
- Bruce Mitchener
|
||||||
|
@ -439,9 +299,13 @@ skills.
|
||||||
- Cyril Pichard
|
- Cyril Pichard
|
||||||
- Keith Pitt
|
- Keith Pitt
|
||||||
- Stanislav Podgorskiy
|
- Stanislav Podgorskiy
|
||||||
|
- Konstantin Podsvirov
|
||||||
- Nathan Poirier
|
- Nathan Poirier
|
||||||
- Alexandre Pretyman
|
- Alexandre Pretyman
|
||||||
|
- Pablo Prietz
|
||||||
- przemekmirek
|
- przemekmirek
|
||||||
|
- pthom
|
||||||
|
- Guillaume Racicot
|
||||||
- Philip Rideout
|
- Philip Rideout
|
||||||
- Eddie Ringle
|
- Eddie Ringle
|
||||||
- Max Risuhin
|
- Max Risuhin
|
||||||
|
@ -490,6 +354,7 @@ skills.
|
||||||
- Jay Weisskopf
|
- Jay Weisskopf
|
||||||
- Frank Wille
|
- Frank Wille
|
||||||
- Ryogo Yoshimura
|
- Ryogo Yoshimura
|
||||||
|
- Lukas Zanner
|
||||||
- Andrey Zholos
|
- Andrey Zholos
|
||||||
- Santi Zupancic
|
- Santi Zupancic
|
||||||
- Jonas Ådahl
|
- Jonas Ådahl
|
||||||
|
|
|
@ -1,24 +1,27 @@
|
||||||
|
|
||||||
set(glfw_DOCS_SOURCES
|
# NOTE: The order of this list determines the order of items in the Guides
|
||||||
"${GLFW_SOURCE_DIR}/include/GLFW/glfw3.h"
|
# (i.e. Pages) list in the generated documentation
|
||||||
"${GLFW_SOURCE_DIR}/include/GLFW/glfw3native.h"
|
set(GLFW_DOXYGEN_SOURCES
|
||||||
"${GLFW_SOURCE_DIR}/docs/main.dox"
|
"include/GLFW/glfw3.h"
|
||||||
"${GLFW_SOURCE_DIR}/docs/news.dox"
|
"include/GLFW/glfw3native.h"
|
||||||
"${GLFW_SOURCE_DIR}/docs/quick.dox"
|
"docs/main.dox"
|
||||||
"${GLFW_SOURCE_DIR}/docs/moving.dox"
|
"docs/news.dox"
|
||||||
"${GLFW_SOURCE_DIR}/docs/compile.dox"
|
"docs/quick.dox"
|
||||||
"${GLFW_SOURCE_DIR}/docs/build.dox"
|
"docs/moving.dox"
|
||||||
"${GLFW_SOURCE_DIR}/docs/intro.dox"
|
"docs/compile.dox"
|
||||||
"${GLFW_SOURCE_DIR}/docs/context.dox"
|
"docs/build.dox"
|
||||||
"${GLFW_SOURCE_DIR}/docs/monitor.dox"
|
"docs/intro.dox"
|
||||||
"${GLFW_SOURCE_DIR}/docs/window.dox"
|
"docs/context.dox"
|
||||||
"${GLFW_SOURCE_DIR}/docs/input.dox"
|
"docs/monitor.dox"
|
||||||
"${GLFW_SOURCE_DIR}/docs/vulkan.dox"
|
"docs/window.dox"
|
||||||
"${GLFW_SOURCE_DIR}/docs/compat.dox"
|
"docs/input.dox"
|
||||||
"${GLFW_SOURCE_DIR}/docs/internal.dox")
|
"docs/vulkan.dox"
|
||||||
|
"docs/compat.dox"
|
||||||
|
"docs/internal.dox")
|
||||||
|
|
||||||
foreach(arg ${glfw_DOCS_SOURCES})
|
# Format the source list into a Doxyfile INPUT value that Doxygen can parse
|
||||||
set(GLFW_DOCS_SOURCES "${GLFW_DOCS_SOURCES} \\\n\"${arg}\"")
|
foreach(path IN LISTS GLFW_DOXYGEN_SOURCES)
|
||||||
|
set(GLFW_DOXYGEN_INPUT "${GLFW_DOXYGEN_INPUT} \\\n\"${GLFW_SOURCE_DIR}/${path}\"")
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
configure_file(Doxyfile.in Doxyfile @ONLY)
|
configure_file(Doxyfile.in Doxyfile @ONLY)
|
||||||
|
|
10
docs/CODEOWNERS
Normal file
10
docs/CODEOWNERS
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
|
||||||
|
* @elmindreda
|
||||||
|
|
||||||
|
src/wl_* @linkmauve
|
||||||
|
|
||||||
|
docs/*.css @glfw/webdev
|
||||||
|
docs/*.less @glfw/webdev
|
||||||
|
docs/*.html @glfw/webdev
|
||||||
|
docs/*.xml @glfw/webdev
|
||||||
|
|
|
@ -20,14 +20,14 @@
|
||||||
## Asking a question
|
## Asking a question
|
||||||
|
|
||||||
Questions about how to use GLFW should be asked either in the [support
|
Questions about how to use GLFW should be asked either in the [support
|
||||||
section](http://discourse.glfw.org/c/support) of the forum, under the [Stack
|
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/).
|
[Freenode](http://freenode.net/).
|
||||||
|
|
||||||
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](http://discourse.glfw.org/c/dev) of the
|
should be asked in the [dev section](https://discourse.glfw.org/c/dev) of the
|
||||||
forum or in the IRC channel. Please don't open a GitHub issue to discuss design
|
forum or in the IRC channel. Please don't open a GitHub issue to discuss design
|
||||||
questions without first checking with a maintainer.
|
questions without first checking with a maintainer.
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ PROJECT_NAME = "GLFW"
|
||||||
# This could be handy for archiving the generated documentation or
|
# This could be handy for archiving the generated documentation or
|
||||||
# if some version control system is used.
|
# if some version control system is used.
|
||||||
|
|
||||||
PROJECT_NUMBER = @GLFW_VERSION_FULL@
|
PROJECT_NUMBER = @GLFW_VERSION@
|
||||||
|
|
||||||
# Using the PROJECT_BRIEF tag one can provide an optional one line description
|
# Using the PROJECT_BRIEF tag one can provide an optional one line description
|
||||||
# for a project that appears at the top of each page and should give viewer
|
# for a project that appears at the top of each page and should give viewer
|
||||||
|
@ -200,6 +200,7 @@ ALIASES = "thread_safety=@par Thread safety^^" \
|
||||||
"analysis=@par Analysis^^" \
|
"analysis=@par Analysis^^" \
|
||||||
"reentrancy=@par Reentrancy^^" \
|
"reentrancy=@par Reentrancy^^" \
|
||||||
"errors=@par Errors^^" \
|
"errors=@par Errors^^" \
|
||||||
|
"callback_signature=@par Callback signature^^" \
|
||||||
"glfw3=__GLFW 3:__" \
|
"glfw3=__GLFW 3:__" \
|
||||||
"x11=__X11:__" \
|
"x11=__X11:__" \
|
||||||
"wayland=__Wayland:__" \
|
"wayland=__Wayland:__" \
|
||||||
|
@ -662,7 +663,7 @@ WARN_LOGFILE = "@GLFW_BINARY_DIR@/docs/warnings.txt"
|
||||||
# directories like "/usr/src/myproject". Separate the files or directories
|
# directories like "/usr/src/myproject". Separate the files or directories
|
||||||
# with spaces.
|
# with spaces.
|
||||||
|
|
||||||
INPUT = @GLFW_DOCS_SOURCES@
|
INPUT = @GLFW_DOXYGEN_INPUT@
|
||||||
|
|
||||||
# This tag can be used to specify the character encoding of the source files
|
# This tag can be used to specify the character encoding of the source files
|
||||||
# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is
|
# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is
|
||||||
|
@ -1631,11 +1632,6 @@ ALLEXTERNALS = NO
|
||||||
|
|
||||||
EXTERNAL_GROUPS = YES
|
EXTERNAL_GROUPS = YES
|
||||||
|
|
||||||
# The PERL_PATH should be the absolute path and name of the perl script
|
|
||||||
# interpreter (i.e. the result of `which perl').
|
|
||||||
|
|
||||||
PERL_PATH = /usr/bin/perl
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
# Configuration options related to the dot tool
|
# Configuration options related to the dot tool
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
|
@ -1648,15 +1644,6 @@ PERL_PATH = /usr/bin/perl
|
||||||
|
|
||||||
CLASS_DIAGRAMS = YES
|
CLASS_DIAGRAMS = YES
|
||||||
|
|
||||||
# You can define message sequence charts within doxygen comments using the \msc
|
|
||||||
# command. Doxygen will then run the mscgen tool (see
|
|
||||||
# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the
|
|
||||||
# documentation. The MSCGEN_PATH tag allows you to specify the directory where
|
|
||||||
# the mscgen tool resides. If left empty the tool is assumed to be found in the
|
|
||||||
# default search path.
|
|
||||||
|
|
||||||
MSCGEN_PATH =
|
|
||||||
|
|
||||||
# If set to YES, the inheritance and collaboration graphs will hide
|
# If set to YES, the inheritance and collaboration graphs will hide
|
||||||
# inheritance and usage relations if the target is undocumented
|
# inheritance and usage relations if the target is undocumented
|
||||||
# or is not a class.
|
# or is not a class.
|
||||||
|
@ -1727,7 +1714,7 @@ UML_LOOK = NO
|
||||||
# the class node. If there are many fields or methods and many nodes the
|
# the class node. If there are many fields or methods and many nodes the
|
||||||
# graph may become too big to be useful. The UML_LIMIT_NUM_FIELDS
|
# graph may become too big to be useful. The UML_LIMIT_NUM_FIELDS
|
||||||
# threshold limits the number of items for each type to make the size more
|
# threshold limits the number of items for each type to make the size more
|
||||||
# managable. Set this to 0 for no limit. Note that the threshold may be
|
# manageable. Set this to 0 for no limit. Note that the threshold may be
|
||||||
# exceeded by 50% before the limit is enforced.
|
# exceeded by 50% before the limit is enforced.
|
||||||
|
|
||||||
UML_LIMIT_NUM_FIELDS = 10
|
UML_LIMIT_NUM_FIELDS = 10
|
||||||
|
|
14
docs/SUPPORT.md
Normal file
14
docs/SUPPORT.md
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
# Support resources
|
||||||
|
|
||||||
|
See the [latest documentation](http://www.glfw.org/docs/latest/) for tutorials,
|
||||||
|
guides and the API reference.
|
||||||
|
|
||||||
|
If you have questions about using GLFW, we have a
|
||||||
|
[forum](https://discourse.glfw.org/), and the `#glfw` IRC channel on
|
||||||
|
[Freenode](http://freenode.net/).
|
||||||
|
|
||||||
|
Bugs are reported to our [issue tracker](https://github.com/glfw/glfw/issues).
|
||||||
|
Please check the [contribution
|
||||||
|
guide](https://github.com/glfw/glfw/blob/master/docs/CONTRIBUTING.md) for
|
||||||
|
information on what to include when reporting a bug.
|
||||||
|
|
|
@ -354,8 +354,8 @@ If you are using the dynamic library version of GLFW, add it to the project
|
||||||
dependencies.
|
dependencies.
|
||||||
|
|
||||||
If you are using the static library version of GLFW, add it and the Cocoa,
|
If you are using the static library version of GLFW, add it and the Cocoa,
|
||||||
OpenGL, IOKit and CoreVideo frameworks to the project as dependencies. They can
|
OpenGL and IOKit frameworks to the project as dependencies. They can all be
|
||||||
all be found in `/System/Library/Frameworks`.
|
found in `/System/Library/Frameworks`.
|
||||||
|
|
||||||
|
|
||||||
@subsection build_link_osx With command-line on macOS
|
@subsection build_link_osx With command-line on macOS
|
||||||
|
@ -369,7 +369,7 @@ the `-l` and `-framework` switches.
|
||||||
If you are using the dynamic GLFW library, which is named `libglfw.3.dylib`, do:
|
If you are using the dynamic GLFW library, which is named `libglfw.3.dylib`, do:
|
||||||
|
|
||||||
@code{.sh}
|
@code{.sh}
|
||||||
cc -o myprog myprog.c -lglfw -framework Cocoa -framework OpenGL -framework IOKit -framework CoreVideo
|
cc -o myprog myprog.c -lglfw -framework Cocoa -framework OpenGL -framework IOKit
|
||||||
@endcode
|
@endcode
|
||||||
|
|
||||||
If you are using the static library, named `libglfw3.a`, substitute `-lglfw3`
|
If you are using the static library, named `libglfw3.a`, substitute `-lglfw3`
|
||||||
|
|
|
@ -864,31 +864,32 @@ GLFW provides high-resolution time input, in seconds, with @ref glfwGetTime.
|
||||||
double seconds = glfwGetTime();
|
double seconds = glfwGetTime();
|
||||||
@endcode
|
@endcode
|
||||||
|
|
||||||
It returns the number of seconds since the timer was started when the library
|
It returns the number of seconds since the library was initialized with @ref
|
||||||
was initialized with @ref glfwInit. The platform-specific time sources used
|
glfwInit. The platform-specific time sources used typically have micro- or
|
||||||
usually have micro- or nanosecond resolution.
|
nanosecond resolution.
|
||||||
|
|
||||||
You can modify the reference time with @ref glfwSetTime.
|
You can modify the base time with @ref glfwSetTime.
|
||||||
|
|
||||||
@code
|
@code
|
||||||
glfwSetTime(4.0);
|
glfwSetTime(4.0);
|
||||||
@endcode
|
@endcode
|
||||||
|
|
||||||
This sets the timer to the specified time, in seconds.
|
This sets the time to the specified time, in seconds, and it continues to count
|
||||||
|
from there.
|
||||||
|
|
||||||
You can also access the raw timer value, measured in 1 / frequency
|
You can also access the raw timer used to implement the functions above,
|
||||||
seconds, with @ref glfwGetTimerValue.
|
with @ref glfwGetTimerValue.
|
||||||
|
|
||||||
@code
|
@code
|
||||||
uint64_t value = glfwGetTimerValue();
|
uint64_t value = glfwGetTimerValue();
|
||||||
@endcode
|
@endcode
|
||||||
|
|
||||||
The frequency of the raw timer varies depending on what time sources are
|
This value is in 1 / frequency seconds. The frequency of the raw
|
||||||
available on the machine. You can query its frequency, in Hz, with @ref
|
timer varies depending on the operating system and hardware. You can query the
|
||||||
glfwGetTimerFrequency.
|
frequency, in Hz, with @ref glfwGetTimerFrequency.
|
||||||
|
|
||||||
@code
|
@code
|
||||||
uint64_t freqency = glfwGetTimerFrequency();
|
uint64_t frequency = glfwGetTimerFrequency();
|
||||||
@endcode
|
@endcode
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -94,8 +94,8 @@ for a disconnected monitor and only before the monitor callback returns.
|
||||||
@section monitor_properties Monitor properties
|
@section monitor_properties Monitor properties
|
||||||
|
|
||||||
Each monitor has a current video mode, a list of supported video modes,
|
Each monitor has a current video mode, a list of supported video modes,
|
||||||
a virtual position, a human-readable name, a user pointer, an estimated physical
|
a virtual position, a content scale, a human-readable name, a user pointer, an
|
||||||
size and a gamma ramp.
|
estimated physical size and a gamma ramp.
|
||||||
|
|
||||||
|
|
||||||
@subsection monitor_modes Video modes
|
@subsection monitor_modes Video modes
|
||||||
|
|
|
@ -337,7 +337,7 @@ presses _Escape_ or closes the window.
|
||||||
The program above can be found in the
|
The program above can be found in the
|
||||||
[source package](https://www.glfw.org/download.html) as `examples/simple.c`
|
[source package](https://www.glfw.org/download.html) as `examples/simple.c`
|
||||||
and is compiled along with all other examples when you build GLFW. If you
|
and is compiled along with all other examples when you build GLFW. If you
|
||||||
built GLFW from the source package then already have this as `simple.exe` on
|
built GLFW from the source package then you already have this as `simple.exe` on
|
||||||
Windows, `simple` on Linux or `simple.app` on macOS.
|
Windows, `simple` on Linux or `simple.app` on macOS.
|
||||||
|
|
||||||
This tutorial used only a few of the many functions GLFW provides. There are
|
This tutorial used only a few of the many functions GLFW provides. There are
|
||||||
|
|
|
@ -234,6 +234,13 @@ alpha channel will be used to combine the framebuffer with the background. This
|
||||||
does not affect window decorations. Possible values are `GLFW_TRUE` and
|
does not affect window decorations. Possible values are `GLFW_TRUE` and
|
||||||
`GLFW_FALSE`.
|
`GLFW_FALSE`.
|
||||||
|
|
||||||
|
@par
|
||||||
|
@win32 GLFW sets a color key for the window to work around repainting issues
|
||||||
|
with a transparent framebuffer. The chosen color value is RGB 255,0,255
|
||||||
|
(magenta). This will make pixels with that exact color fully transparent
|
||||||
|
regardless of their alpha values. If this is a problem, make these pixels any
|
||||||
|
other color before buffer swap.
|
||||||
|
|
||||||
@anchor GLFW_FOCUS_ON_SHOW_hint
|
@anchor GLFW_FOCUS_ON_SHOW_hint
|
||||||
__GLFW_FOCUS_ON_SHOW__ specifies whether the window will be given input
|
__GLFW_FOCUS_ON_SHOW__ specifies whether the window will be given input
|
||||||
focus when @ref glfwShowWindow is called. Possible values are `GLFW_TRUE` and `GLFW_FALSE`.
|
focus when @ref glfwShowWindow is called. Possible values are `GLFW_TRUE` and `GLFW_FALSE`.
|
||||||
|
@ -1332,6 +1339,21 @@ unknown or the context is an OpenGL ES context. Note that the returned profile
|
||||||
may not match the profile bits of the context flags, as GLFW will try other
|
may not match the profile bits of the context flags, as GLFW will try other
|
||||||
means of detecting the profile when no bits are set.
|
means of detecting the profile when no bits are set.
|
||||||
|
|
||||||
|
@anchor GLFW_CONTEXT_RELEASE_BEHAVIOR_attrib
|
||||||
|
__GLFW_CONTEXT_RELEASE_BEHAVIOR__ indicates the release used by the context.
|
||||||
|
Possible values are one of `GLFW_ANY_RELEASE_BEHAVIOR`,
|
||||||
|
`GLFW_RELEASE_BEHAVIOR_FLUSH` or `GLFW_RELEASE_BEHAVIOR_NONE`. If the
|
||||||
|
behavior is `GLFW_ANY_RELEASE_BEHAVIOR`, the default behavior of the context
|
||||||
|
creation API will be used. If the behavior is `GLFW_RELEASE_BEHAVIOR_FLUSH`,
|
||||||
|
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
|
||||||
|
not be flushed on release.
|
||||||
|
|
||||||
|
@anchor GLFW_CONTEXT_NO_ERROR_attrib
|
||||||
|
__GLFW_CONTEXT_NO_ERROR__ indicates whether errors are generated by the context.
|
||||||
|
Possible values are `GLFW_TRUE` and `GLFW_FALSE`. If enabled, situations that
|
||||||
|
would have generated errors instead cause undefined behavior.
|
||||||
|
|
||||||
@anchor GLFW_CONTEXT_ROBUSTNESS_attrib
|
@anchor GLFW_CONTEXT_ROBUSTNESS_attrib
|
||||||
__GLFW_CONTEXT_ROBUSTNESS__ indicates the robustness strategy used by the
|
__GLFW_CONTEXT_ROBUSTNESS__ indicates the robustness strategy used by the
|
||||||
context. This is `GLFW_LOSE_CONTEXT_ON_RESET` or `GLFW_NO_RESET_NOTIFICATION`
|
context. This is `GLFW_LOSE_CONTEXT_ON_RESET` or `GLFW_NO_RESET_NOTIFICATION`
|
||||||
|
@ -1385,7 +1407,7 @@ glfwSwapBuffers(window);
|
||||||
|
|
||||||
Sometimes it can be useful to select when the buffer swap will occur. With the
|
Sometimes it can be useful to select when the buffer swap will occur. With the
|
||||||
function @ref glfwSwapInterval it is possible to select the minimum number of
|
function @ref glfwSwapInterval it is possible to select the minimum number of
|
||||||
monitor refreshes the driver wait should from the time @ref glfwSwapBuffers was
|
monitor refreshes the driver should wait from the time @ref glfwSwapBuffers was
|
||||||
called before swapping the buffers:
|
called before swapping the buffers:
|
||||||
|
|
||||||
@code
|
@code
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
link_libraries(glfw)
|
link_libraries(glfw)
|
||||||
|
|
||||||
include_directories(${glfw_INCLUDE_DIRS} "${GLFW_SOURCE_DIR}/deps")
|
include_directories("${GLFW_SOURCE_DIR}/deps")
|
||||||
|
|
||||||
if (MATH_LIBRARY)
|
if (MATH_LIBRARY)
|
||||||
link_libraries("${MATH_LIBRARY}")
|
link_libraries("${MATH_LIBRARY}")
|
||||||
|
@ -11,16 +11,21 @@ if (MSVC)
|
||||||
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
|
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (GLFW_USE_OSMESA)
|
|
||||||
add_definitions(-DUSE_NATIVE_OSMESA)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
set(ICON glfw.rc)
|
set(ICON glfw.rc)
|
||||||
elseif (APPLE)
|
elseif (APPLE)
|
||||||
set(ICON glfw.icns)
|
set(ICON glfw.icns)
|
||||||
set_source_files_properties(glfw.icns PROPERTIES
|
endif()
|
||||||
MACOSX_PACKAGE_LOCATION "Resources")
|
|
||||||
|
if (${CMAKE_VERSION} VERSION_EQUAL "3.1.0" OR
|
||||||
|
${CMAKE_VERSION} VERSION_GREATER "3.1.0")
|
||||||
|
set(CMAKE_C_STANDARD 99)
|
||||||
|
else()
|
||||||
|
# Remove this fallback when removing support for CMake version less than 3.1
|
||||||
|
add_compile_options("$<$<C_COMPILER_ID:AppleClang>:-std=c99>"
|
||||||
|
"$<$<C_COMPILER_ID:Clang>:-std=c99>"
|
||||||
|
"$<$<C_COMPILER_ID:GNU>:-std=c99>")
|
||||||
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(GLAD_GL "${GLFW_SOURCE_DIR}/deps/glad/gl.h"
|
set(GLAD_GL "${GLFW_SOURCE_DIR}/deps/glad/gl.h"
|
||||||
|
@ -45,15 +50,20 @@ if (RT_LIBRARY)
|
||||||
target_link_libraries(particles "${RT_LIBRARY}")
|
target_link_libraries(particles "${RT_LIBRARY}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(WINDOWS_BINARIES boing gears heightmap particles sharing simple splitview wave)
|
set(GUI_ONLY_BINARIES boing gears heightmap particles sharing simple splitview
|
||||||
|
wave)
|
||||||
set(CONSOLE_BINARIES offscreen)
|
set(CONSOLE_BINARIES offscreen)
|
||||||
|
|
||||||
set_target_properties(${WINDOWS_BINARIES} ${CONSOLE_BINARIES} PROPERTIES
|
set_target_properties(${GUI_ONLY_BINARIES} ${CONSOLE_BINARIES} PROPERTIES
|
||||||
FOLDER "GLFW3/Examples")
|
FOLDER "GLFW3/Examples")
|
||||||
|
|
||||||
|
if (GLFW_USE_OSMESA)
|
||||||
|
target_compile_definitions(offscreen PRIVATE USE_NATIVE_OSMESA)
|
||||||
|
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 for Windows subsystem executables
|
||||||
set_target_properties(${WINDOWS_BINARIES} PROPERTIES
|
set_target_properties(${GUI_ONLY_BINARIES} PROPERTIES
|
||||||
LINK_FLAGS "/ENTRY:mainCRTStartup")
|
LINK_FLAGS "/ENTRY:mainCRTStartup")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@ -67,10 +77,11 @@ if (APPLE)
|
||||||
set_target_properties(splitview PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "SplitView")
|
set_target_properties(splitview PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "SplitView")
|
||||||
set_target_properties(wave PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Wave")
|
set_target_properties(wave PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Wave")
|
||||||
|
|
||||||
set_target_properties(${WINDOWS_BINARIES} PROPERTIES
|
set_source_files_properties(glfw.icns PROPERTIES
|
||||||
RESOURCE glfw.icns
|
MACOSX_PACKAGE_LOCATION "Resources")
|
||||||
|
set_target_properties(${GUI_ONLY_BINARIES} PROPERTIES
|
||||||
MACOSX_BUNDLE_SHORT_VERSION_STRING ${GLFW_VERSION}
|
MACOSX_BUNDLE_SHORT_VERSION_STRING ${GLFW_VERSION}
|
||||||
MACOSX_BUNDLE_LONG_VERSION_STRING ${GLFW_VERSION_FULL}
|
MACOSX_BUNDLE_LONG_VERSION_STRING ${GLFW_VERSION}
|
||||||
MACOSX_BUNDLE_ICON_FILE glfw.icns
|
MACOSX_BUNDLE_ICON_FILE glfw.icns
|
||||||
MACOSX_BUNDLE_INFO_PLIST "${GLFW_SOURCE_DIR}/CMake/MacOSXBundleInfo.plist.in")
|
MACOSX_BUNDLE_INFO_PLIST "${GLFW_SOURCE_DIR}/CMake/MacOSXBundleInfo.plist.in")
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
#include <glad/gl.h>
|
#include <glad/gl.h>
|
||||||
|
#define GLFW_INCLUDE_NONE
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
|
|
||||||
#include <linmath.h>
|
#include <linmath.h>
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include <glad/gl.h>
|
#include <glad/gl.h>
|
||||||
|
#define GLFW_INCLUDE_NONE
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
#include <glad/gl.h>
|
#include <glad/gl.h>
|
||||||
|
#define GLFW_INCLUDE_NONE
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
|
|
||||||
/* Map height updates */
|
/* Map height updates */
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
#include <glad/gl.h>
|
#include <glad/gl.h>
|
||||||
|
#define GLFW_INCLUDE_NONE
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
|
|
||||||
#if USE_NATIVE_OSMESA
|
#if USE_NATIVE_OSMESA
|
||||||
|
|
|
@ -40,6 +40,7 @@
|
||||||
#include <linmath.h>
|
#include <linmath.h>
|
||||||
|
|
||||||
#include <glad/gl.h>
|
#include <glad/gl.h>
|
||||||
|
#define GLFW_INCLUDE_NONE
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
|
|
||||||
// Define tokens for GL_EXT_separate_specular_color if not already defined
|
// Define tokens for GL_EXT_separate_specular_color if not already defined
|
||||||
|
@ -443,7 +444,7 @@ static void draw_particles(GLFWwindow* window, double t, float dt)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set up vertex arrays. We use interleaved arrays, which is easier to
|
// Set up vertex arrays. We use interleaved arrays, which is easier to
|
||||||
// handle (in most situations) and it gives a linear memeory access
|
// handle (in most situations) and it gives a linear memory access
|
||||||
// access pattern (which may give better performance in some
|
// access pattern (which may give better performance in some
|
||||||
// situations). GL_T2F_C4UB_V3F means: 2 floats for texture coords,
|
// situations). GL_T2F_C4UB_V3F means: 2 floats for texture coords,
|
||||||
// 4 ubytes for color and 3 floats for vertex coord (in that order).
|
// 4 ubytes for color and 3 floats for vertex coord (in that order).
|
||||||
|
@ -653,7 +654,7 @@ static void draw_fountain(void)
|
||||||
|
|
||||||
|
|
||||||
//========================================================================
|
//========================================================================
|
||||||
// Recursive function for building variable tesselated floor
|
// Recursive function for building variable tessellated floor
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
static void tessellate_floor(float x1, float y1, float x2, float y2, int depth)
|
static void tessellate_floor(float x1, float y1, float x2, float y2, int depth)
|
||||||
|
@ -720,7 +721,7 @@ static void draw_floor(void)
|
||||||
glMaterialfv(GL_FRONT, GL_SPECULAR, floor_specular);
|
glMaterialfv(GL_FRONT, GL_SPECULAR, floor_specular);
|
||||||
glMaterialf(GL_FRONT, GL_SHININESS, floor_shininess);
|
glMaterialf(GL_FRONT, GL_SHININESS, floor_shininess);
|
||||||
|
|
||||||
// Draw floor as a bunch of triangle strips (high tesselation
|
// Draw floor as a bunch of triangle strips (high tessellation
|
||||||
// improves lighting)
|
// improves lighting)
|
||||||
glNormal3f(0.f, 0.f, 1.f);
|
glNormal3f(0.f, 0.f, 1.f);
|
||||||
glBegin(GL_QUADS);
|
glBegin(GL_QUADS);
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
#include <glad/gl.h>
|
#include <glad/gl.h>
|
||||||
|
#define GLFW_INCLUDE_NONE
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
//! [code]
|
//! [code]
|
||||||
|
|
||||||
#include <glad/gl.h>
|
#include <glad/gl.h>
|
||||||
|
#define GLFW_INCLUDE_NONE
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
|
|
||||||
#include "linmath.h"
|
#include "linmath.h"
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
//
|
//
|
||||||
// The program uses a "split window" view, rendering four views of the
|
// The program uses a "split window" view, rendering four views of the
|
||||||
// same scene in one window (e.g. uesful for 3D modelling software). This
|
// same scene in one window (e.g. uesful for 3D modelling software). This
|
||||||
// demo uses scissors to separete the four different rendering areas from
|
// demo uses scissors to separate the four different rendering areas from
|
||||||
// each other.
|
// each other.
|
||||||
//
|
//
|
||||||
// (If the code seems a little bit strange here and there, it may be
|
// (If the code seems a little bit strange here and there, it may be
|
||||||
|
@ -11,6 +11,7 @@
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
#include <glad/gl.h>
|
#include <glad/gl.h>
|
||||||
|
#define GLFW_INCLUDE_NONE
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
|
|
||||||
#if defined(_MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
#include <glad/gl.h>
|
#include <glad/gl.h>
|
||||||
|
#define GLFW_INCLUDE_NONE
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
|
|
||||||
#include <linmath.h>
|
#include <linmath.h>
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -73,58 +73,78 @@ if (_GLFW_X11 OR _GLFW_WAYLAND)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (APPLE)
|
if (APPLE)
|
||||||
# For some reason, CMake doesn't know about .m
|
# For some reason CMake didn't know about .m until version 3.16
|
||||||
set_source_files_properties(${glfw_SOURCES} PROPERTIES LANGUAGE C)
|
set_source_files_properties(cocoa_init.m cocoa_joystick.m cocoa_monitor.m
|
||||||
endif()
|
cocoa_window.m nsgl_context.m PROPERTIES
|
||||||
|
LANGUAGE C)
|
||||||
# Make GCC and Clang warn about declarations that VS 2010 and 2012 won't accept
|
|
||||||
# for all source files that VS will build
|
|
||||||
if ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" OR
|
|
||||||
"${CMAKE_C_COMPILER_ID}" STREQUAL "Clang" OR
|
|
||||||
"${CMAKE_C_COMPILER_ID}" STREQUAL "AppleClang")
|
|
||||||
|
|
||||||
if (WIN32)
|
|
||||||
set(windows_SOURCES ${glfw_SOURCES})
|
|
||||||
else()
|
|
||||||
set(windows_SOURCES ${common_SOURCES})
|
|
||||||
endif()
|
|
||||||
set_source_files_properties(${windows_SOURCES} PROPERTIES
|
|
||||||
COMPILE_FLAGS -Wdeclaration-after-statement)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_library(glfw ${glfw_SOURCES} ${glfw_HEADERS})
|
add_library(glfw ${glfw_SOURCES} ${glfw_HEADERS})
|
||||||
set_target_properties(glfw PROPERTIES
|
set_target_properties(glfw PROPERTIES
|
||||||
OUTPUT_NAME ${GLFW_LIB_NAME}
|
OUTPUT_NAME ${GLFW_LIB_NAME}
|
||||||
VERSION ${GLFW_VERSION}
|
VERSION ${GLFW_VERSION_MAJOR}.${GLFW_VERSION_MINOR}
|
||||||
SOVERSION ${GLFW_VERSION_MAJOR}
|
SOVERSION ${GLFW_VERSION_MAJOR}
|
||||||
POSITION_INDEPENDENT_CODE ON
|
POSITION_INDEPENDENT_CODE ON
|
||||||
FOLDER "GLFW3")
|
FOLDER "GLFW3")
|
||||||
|
|
||||||
|
if (${CMAKE_VERSION} VERSION_EQUAL "3.1.0" OR
|
||||||
|
${CMAKE_VERSION} VERSION_GREATER "3.1.0")
|
||||||
|
|
||||||
|
set_target_properties(glfw PROPERTIES C_STANDARD 99)
|
||||||
|
else()
|
||||||
|
# Remove this fallback when removing support for CMake version less than 3.1
|
||||||
|
target_compile_options(glfw PRIVATE
|
||||||
|
"$<$<C_COMPILER_ID:AppleClang>:-std=c99>"
|
||||||
|
"$<$<C_COMPILER_ID:Clang>:-std=c99>"
|
||||||
|
"$<$<C_COMPILER_ID:GNU>:-std=c99>")
|
||||||
|
endif()
|
||||||
|
|
||||||
target_compile_definitions(glfw PRIVATE _GLFW_USE_CONFIG_H)
|
target_compile_definitions(glfw PRIVATE _GLFW_USE_CONFIG_H)
|
||||||
target_include_directories(glfw PUBLIC
|
target_include_directories(glfw PUBLIC
|
||||||
"$<BUILD_INTERFACE:${GLFW_SOURCE_DIR}/include>"
|
"$<BUILD_INTERFACE:${GLFW_SOURCE_DIR}/include>"
|
||||||
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_FULL_INCLUDEDIR}>")
|
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>")
|
||||||
target_include_directories(glfw PRIVATE
|
target_include_directories(glfw PRIVATE
|
||||||
"${GLFW_SOURCE_DIR}/src"
|
"${GLFW_SOURCE_DIR}/src"
|
||||||
"${GLFW_BINARY_DIR}/src"
|
"${GLFW_BINARY_DIR}/src"
|
||||||
${glfw_INCLUDE_DIRS})
|
${glfw_INCLUDE_DIRS})
|
||||||
|
target_link_libraries(glfw PRIVATE ${glfw_LIBRARIES})
|
||||||
|
|
||||||
|
if ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" OR
|
||||||
|
"${CMAKE_C_COMPILER_ID}" STREQUAL "Clang" OR
|
||||||
|
"${CMAKE_C_COMPILER_ID}" STREQUAL "AppleClang")
|
||||||
|
|
||||||
|
# Make GCC and Clang warn about declarations that VS 2010 and 2012 won't
|
||||||
|
# accept for all source files that VS will build
|
||||||
|
set_source_files_properties(context.c init.c input.c monitor.c vulkan.c
|
||||||
|
window.c win32_init.c win32_joystick.c
|
||||||
|
win32_monitor.c win32_time.c win32_thread.c
|
||||||
|
win32_window.c wgl_context.c egl_context.c
|
||||||
|
osmesa_context.c PROPERTIES
|
||||||
|
COMPILE_FLAGS -Wdeclaration-after-statement)
|
||||||
|
|
||||||
|
# Enable a reasonable set of warnings (no, -Wextra is not reasonable)
|
||||||
|
target_compile_options(glfw PRIVATE "-Wall")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (WIN32)
|
||||||
|
target_compile_definitions(glfw PRIVATE _UNICODE)
|
||||||
|
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
|
||||||
# the inclusion of stddef.h (by glfw3.h), which is itself included before
|
# the inclusion of stddef.h (by glfw3.h), which is itself included before
|
||||||
# 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.
|
||||||
target_compile_definitions(glfw PRIVATE
|
if (MINGW)
|
||||||
"$<$<BOOL:${MINGW}>:UNICODE;WINVER=0x0501>")
|
target_compile_definitions(glfw PRIVATE UNICODE WINVER=0x0501)
|
||||||
|
endif()
|
||||||
# Enable a reasonable set of warnings (no, -Wextra is not reasonable)
|
|
||||||
target_compile_options(glfw PRIVATE
|
|
||||||
"$<$<C_COMPILER_ID:AppleClang>:-Wall>"
|
|
||||||
"$<$<C_COMPILER_ID:Clang>:-Wall>"
|
|
||||||
"$<$<C_COMPILER_ID:GNU>:-Wall>")
|
|
||||||
|
|
||||||
if (BUILD_SHARED_LIBS)
|
if (BUILD_SHARED_LIBS)
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
if (MINGW)
|
if (MINGW)
|
||||||
|
# Remove the dependency on the shared version of libgcc
|
||||||
|
# NOTE: MinGW-w64 has the correct default but MinGW needs this
|
||||||
|
target_link_libraries(glfw PRIVATE "-static-libgcc")
|
||||||
|
|
||||||
# Remove the lib prefix on the DLL (but not the import library)
|
# Remove the lib prefix on the DLL (but not the import library)
|
||||||
set_target_properties(glfw PROPERTIES PREFIX "")
|
set_target_properties(glfw PROPERTIES PREFIX "")
|
||||||
|
|
||||||
|
@ -134,21 +154,20 @@ if (BUILD_SHARED_LIBS)
|
||||||
# Add a suffix to the import library to avoid naming conflicts
|
# Add a suffix to the import library to avoid naming conflicts
|
||||||
set_target_properties(glfw PROPERTIES IMPORT_SUFFIX "dll.lib")
|
set_target_properties(glfw PROPERTIES IMPORT_SUFFIX "dll.lib")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
target_compile_definitions(glfw INTERFACE GLFW_DLL)
|
||||||
elseif (APPLE)
|
elseif (APPLE)
|
||||||
# Add -fno-common to work around a bug in Apple's GCC
|
# Add -fno-common to work around a bug in Apple's GCC
|
||||||
target_compile_options(glfw PRIVATE "-fno-common")
|
target_compile_options(glfw PRIVATE "-fno-common")
|
||||||
|
|
||||||
set_target_properties(glfw PROPERTIES
|
set_target_properties(glfw PROPERTIES
|
||||||
INSTALL_NAME_DIR "${CMAKE_INSTALL_LIBDIR}")
|
INSTALL_NAME_DIR "${CMAKE_INSTALL_LIBDIR}")
|
||||||
elseif (UNIX)
|
endif()
|
||||||
|
|
||||||
|
if (UNIX)
|
||||||
# Hide symbols not explicitly tagged for export from the shared library
|
# Hide symbols not explicitly tagged for export from the shared library
|
||||||
target_compile_options(glfw PRIVATE "-fvisibility=hidden")
|
target_compile_options(glfw PRIVATE "-fvisibility=hidden")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_compile_definitions(glfw INTERFACE GLFW_DLL)
|
|
||||||
target_link_libraries(glfw PRIVATE ${glfw_LIBRARIES})
|
|
||||||
else()
|
|
||||||
target_link_libraries(glfw INTERFACE ${glfw_LIBRARIES})
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (MSVC)
|
if (MSVC)
|
||||||
|
|
|
@ -23,6 +23,8 @@
|
||||||
// distribution.
|
// distribution.
|
||||||
//
|
//
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
// It is fine to use C99 in this file because it will not be built with VS
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
#include <sys/param.h> // For MAXPATHLEN
|
#include <sys/param.h> // For MAXPATHLEN
|
||||||
|
@ -429,9 +431,8 @@ static GLFWbool initializeTIS(void)
|
||||||
// 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];
|
[NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
|
||||||
|
|
||||||
// Menu bar setup must go between sharedApplication above and
|
// Menu bar setup must go between sharedApplication and finishLaunching
|
||||||
// finishLaunching below, in order to properly emulate the behavior
|
// in order to properly emulate the behavior of NSApplicationMain
|
||||||
// of NSApplicationMain
|
|
||||||
|
|
||||||
if ([[NSBundle mainBundle] pathForResource:@"MainMenu" ofType:@"nib"])
|
if ([[NSBundle mainBundle] pathForResource:@"MainMenu" ofType:@"nib"])
|
||||||
{
|
{
|
||||||
|
@ -446,9 +447,9 @@ static GLFWbool initializeTIS(void)
|
||||||
|
|
||||||
- (void)applicationDidFinishLaunching:(NSNotification *)notification
|
- (void)applicationDidFinishLaunching:(NSNotification *)notification
|
||||||
{
|
{
|
||||||
[NSApp stop:nil];
|
_glfw.ns.finishedLaunching = GLFW_TRUE;
|
||||||
|
|
||||||
_glfwPlatformPostEmptyEvent();
|
_glfwPlatformPostEmptyEvent();
|
||||||
|
[NSApp stop:nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)applicationDidHide:(NSNotification *)notification
|
- (void)applicationDidHide:(NSNotification *)notification
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
#include <IOKit/hid/IOHIDKeys.h>
|
#include <IOKit/hid/IOHIDKeys.h>
|
||||||
|
|
||||||
#define _GLFW_PLATFORM_JOYSTICK_STATE _GLFWjoystickNS ns
|
#define _GLFW_PLATFORM_JOYSTICK_STATE _GLFWjoystickNS ns
|
||||||
#define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE
|
#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"
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,8 @@
|
||||||
// distribution.
|
// distribution.
|
||||||
//
|
//
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
// It is fine to use C99 in this file because it will not be built with VS
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
|
@ -329,7 +331,7 @@ void _glfwInitJoysticksNS(void)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < sizeof(usages) / sizeof(long); i++)
|
for (size_t i = 0; i < sizeof(usages) / sizeof(long); i++)
|
||||||
{
|
{
|
||||||
const long page = kHIDPage_GenericDesktop;
|
const long page = kHIDPage_GenericDesktop;
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,8 @@
|
||||||
// distribution.
|
// distribution.
|
||||||
//
|
//
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
// It is fine to use C99 in this file because it will not be built with VS
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
|
@ -142,7 +144,7 @@ static GLFWbool modeIsGood(CGDisplayModeRef mode)
|
||||||
// Convert Core Graphics display mode to GLFW video mode
|
// Convert Core Graphics display mode to GLFW video mode
|
||||||
//
|
//
|
||||||
static GLFWvidmode vidmodeFromCGDisplayMode(CGDisplayModeRef mode,
|
static GLFWvidmode vidmodeFromCGDisplayMode(CGDisplayModeRef mode,
|
||||||
CVDisplayLinkRef link)
|
double fallbackRefreshRate)
|
||||||
{
|
{
|
||||||
GLFWvidmode result;
|
GLFWvidmode result;
|
||||||
result.width = (int) CGDisplayModeGetWidth(mode);
|
result.width = (int) CGDisplayModeGetWidth(mode);
|
||||||
|
@ -150,11 +152,7 @@ static GLFWvidmode vidmodeFromCGDisplayMode(CGDisplayModeRef mode,
|
||||||
result.refreshRate = (int) round(CGDisplayModeGetRefreshRate(mode));
|
result.refreshRate = (int) round(CGDisplayModeGetRefreshRate(mode));
|
||||||
|
|
||||||
if (result.refreshRate == 0)
|
if (result.refreshRate == 0)
|
||||||
{
|
result.refreshRate = (int) round(fallbackRefreshRate);
|
||||||
const CVTime time = CVDisplayLinkGetNominalOutputVideoRefreshPeriod(link);
|
|
||||||
if (!(time.flags & kCVTimeIsIndefinite))
|
|
||||||
result.refreshRate = (int) (time.timeScale / (double) time.timeValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
#if MAC_OS_X_VERSION_MAX_ALLOWED <= 101100
|
#if MAC_OS_X_VERSION_MAX_ALLOWED <= 101100
|
||||||
CFStringRef format = CGDisplayModeCopyPixelEncoding(mode);
|
CFStringRef format = CGDisplayModeCopyPixelEncoding(mode);
|
||||||
|
@ -213,7 +211,7 @@ static void endFadeReservation(CGDisplayFadeReservationToken token)
|
||||||
|
|
||||||
// Finds and caches the NSScreen corresponding to the specified monitor
|
// Finds and caches the NSScreen corresponding to the specified monitor
|
||||||
//
|
//
|
||||||
GLFWbool refreshMonitorScreen(_GLFWmonitor* monitor)
|
static GLFWbool refreshMonitorScreen(_GLFWmonitor* monitor)
|
||||||
{
|
{
|
||||||
if (monitor->ns.screen)
|
if (monitor->ns.screen)
|
||||||
return GLFW_TRUE;
|
return GLFW_TRUE;
|
||||||
|
@ -236,6 +234,68 @@ GLFWbool refreshMonitorScreen(_GLFWmonitor* monitor)
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Returns the display refresh rate queried from the I/O registry
|
||||||
|
//
|
||||||
|
static double getFallbackRefreshRate(CGDirectDisplayID displayID)
|
||||||
|
{
|
||||||
|
double refreshRate = 60.0;
|
||||||
|
|
||||||
|
io_iterator_t it;
|
||||||
|
io_service_t service;
|
||||||
|
|
||||||
|
if (IOServiceGetMatchingServices(kIOMasterPortDefault,
|
||||||
|
IOServiceMatching("IOFramebuffer"),
|
||||||
|
&it) != 0)
|
||||||
|
{
|
||||||
|
return refreshRate;
|
||||||
|
}
|
||||||
|
|
||||||
|
while ((service = IOIteratorNext(it)) != 0)
|
||||||
|
{
|
||||||
|
const CFNumberRef indexRef =
|
||||||
|
IORegistryEntryCreateCFProperty(service,
|
||||||
|
CFSTR("IOFramebufferOpenGLIndex"),
|
||||||
|
kCFAllocatorDefault,
|
||||||
|
kNilOptions);
|
||||||
|
if (!indexRef)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
uint32_t index = 0;
|
||||||
|
CFNumberGetValue(indexRef, kCFNumberIntType, &index);
|
||||||
|
CFRelease(indexRef);
|
||||||
|
|
||||||
|
if (CGOpenGLDisplayMaskToDisplayID(1 << index) != displayID)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
const CFNumberRef clockRef =
|
||||||
|
IORegistryEntryCreateCFProperty(service,
|
||||||
|
CFSTR("IOFBCurrentPixelClock"),
|
||||||
|
kCFAllocatorDefault,
|
||||||
|
kNilOptions);
|
||||||
|
const CFNumberRef countRef =
|
||||||
|
IORegistryEntryCreateCFProperty(service,
|
||||||
|
CFSTR("IOFBCurrentPixelCount"),
|
||||||
|
kCFAllocatorDefault,
|
||||||
|
kNilOptions);
|
||||||
|
if (!clockRef || !countRef)
|
||||||
|
break;
|
||||||
|
|
||||||
|
uint32_t clock = 0, count = 0;
|
||||||
|
CFNumberGetValue(clockRef, kCFNumberIntType, &clock);
|
||||||
|
CFNumberGetValue(countRef, kCFNumberIntType, &count);
|
||||||
|
CFRelease(clockRef);
|
||||||
|
CFRelease(countRef);
|
||||||
|
|
||||||
|
if (clock > 0 && count > 0)
|
||||||
|
refreshRate = clock / (double) count;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
IOObjectRelease(it);
|
||||||
|
return refreshRate;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
////// GLFW internal API //////
|
////// GLFW internal API //////
|
||||||
|
@ -245,18 +305,16 @@ GLFWbool refreshMonitorScreen(_GLFWmonitor* monitor)
|
||||||
//
|
//
|
||||||
void _glfwPollMonitorsNS(void)
|
void _glfwPollMonitorsNS(void)
|
||||||
{
|
{
|
||||||
uint32_t i, j, displayCount, disconnectedCount;
|
uint32_t displayCount;
|
||||||
CGDirectDisplayID* displays;
|
|
||||||
_GLFWmonitor** disconnected = NULL;
|
|
||||||
|
|
||||||
CGGetOnlineDisplayList(0, NULL, &displayCount);
|
CGGetOnlineDisplayList(0, NULL, &displayCount);
|
||||||
displays = calloc(displayCount, sizeof(CGDirectDisplayID));
|
CGDirectDisplayID* displays = calloc(displayCount, sizeof(CGDirectDisplayID));
|
||||||
CGGetOnlineDisplayList(displayCount, displays, &displayCount);
|
CGGetOnlineDisplayList(displayCount, displays, &displayCount);
|
||||||
|
|
||||||
for (i = 0; i < _glfw.monitorCount; i++)
|
for (int i = 0; i < _glfw.monitorCount; i++)
|
||||||
_glfw.monitors[i]->ns.screen = nil;
|
_glfw.monitors[i]->ns.screen = nil;
|
||||||
|
|
||||||
disconnectedCount = _glfw.monitorCount;
|
_GLFWmonitor** disconnected = NULL;
|
||||||
|
uint32_t disconnectedCount = _glfw.monitorCount;
|
||||||
if (disconnectedCount)
|
if (disconnectedCount)
|
||||||
{
|
{
|
||||||
disconnected = calloc(_glfw.monitorCount, sizeof(_GLFWmonitor*));
|
disconnected = calloc(_glfw.monitorCount, sizeof(_GLFWmonitor*));
|
||||||
|
@ -265,19 +323,17 @@ void _glfwPollMonitorsNS(void)
|
||||||
_glfw.monitorCount * sizeof(_GLFWmonitor*));
|
_glfw.monitorCount * sizeof(_GLFWmonitor*));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < displayCount; i++)
|
for (uint32_t i = 0; i < displayCount; i++)
|
||||||
{
|
{
|
||||||
_GLFWmonitor* monitor;
|
|
||||||
const uint32_t unitNumber = CGDisplayUnitNumber(displays[i]);
|
|
||||||
|
|
||||||
if (CGDisplayIsAsleep(displays[i]))
|
if (CGDisplayIsAsleep(displays[i]))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
for (j = 0; j < disconnectedCount; j++)
|
// HACK: Compare unit numbers instead of display IDs to work around
|
||||||
|
// display replacement on machines with automatic graphics
|
||||||
|
// switching
|
||||||
|
const uint32_t unitNumber = CGDisplayUnitNumber(displays[i]);
|
||||||
|
for (uint32_t j = 0; j < disconnectedCount; j++)
|
||||||
{
|
{
|
||||||
// HACK: Compare unit numbers instead of display IDs to work around
|
|
||||||
// display replacement on machines with automatic graphics
|
|
||||||
// switching
|
|
||||||
if (disconnected[j] && disconnected[j]->ns.unitNumber == unitNumber)
|
if (disconnected[j] && disconnected[j]->ns.unitNumber == unitNumber)
|
||||||
{
|
{
|
||||||
disconnected[j] = NULL;
|
disconnected[j] = NULL;
|
||||||
|
@ -290,16 +346,21 @@ void _glfwPollMonitorsNS(void)
|
||||||
if (!name)
|
if (!name)
|
||||||
name = _glfw_strdup("Unknown");
|
name = _glfw_strdup("Unknown");
|
||||||
|
|
||||||
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];
|
||||||
monitor->ns.unitNumber = unitNumber;
|
monitor->ns.unitNumber = unitNumber;
|
||||||
|
|
||||||
free(name);
|
free(name);
|
||||||
|
|
||||||
|
CGDisplayModeRef mode = CGDisplayCopyDisplayMode(displays[i]);
|
||||||
|
if (CGDisplayModeGetRefreshRate(mode) == 0.0)
|
||||||
|
monitor->ns.fallbackRefreshRate = getFallbackRefreshRate(displays[i]);
|
||||||
|
CGDisplayModeRelease(mode);
|
||||||
|
|
||||||
_glfwInputMonitor(monitor, GLFW_CONNECTED, _GLFW_INSERT_LAST);
|
_glfwInputMonitor(monitor, GLFW_CONNECTED, _GLFW_INSERT_LAST);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < disconnectedCount; i++)
|
for (uint32_t i = 0; i < disconnectedCount; i++)
|
||||||
{
|
{
|
||||||
if (disconnected[i])
|
if (disconnected[i])
|
||||||
_glfwInputMonitor(disconnected[i], GLFW_DISCONNECTED, 0);
|
_glfwInputMonitor(disconnected[i], GLFW_DISCONNECTED, 0);
|
||||||
|
@ -313,30 +374,25 @@ void _glfwPollMonitorsNS(void)
|
||||||
//
|
//
|
||||||
void _glfwSetVideoModeNS(_GLFWmonitor* monitor, const GLFWvidmode* desired)
|
void _glfwSetVideoModeNS(_GLFWmonitor* monitor, const GLFWvidmode* desired)
|
||||||
{
|
{
|
||||||
CFArrayRef modes;
|
|
||||||
CFIndex count, i;
|
|
||||||
CVDisplayLinkRef link;
|
|
||||||
CGDisplayModeRef native = NULL;
|
|
||||||
GLFWvidmode current;
|
GLFWvidmode current;
|
||||||
const GLFWvidmode* best;
|
|
||||||
|
|
||||||
best = _glfwChooseVideoMode(monitor, desired);
|
|
||||||
_glfwPlatformGetVideoMode(monitor, ¤t);
|
_glfwPlatformGetVideoMode(monitor, ¤t);
|
||||||
|
|
||||||
|
const GLFWvidmode* best = _glfwChooseVideoMode(monitor, desired);
|
||||||
if (_glfwCompareVideoModes(¤t, best) == 0)
|
if (_glfwCompareVideoModes(¤t, best) == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
CVDisplayLinkCreateWithCGDisplay(monitor->ns.displayID, &link);
|
CFArrayRef modes = CGDisplayCopyAllDisplayModes(monitor->ns.displayID, NULL);
|
||||||
|
const CFIndex count = CFArrayGetCount(modes);
|
||||||
|
CGDisplayModeRef native = NULL;
|
||||||
|
|
||||||
modes = CGDisplayCopyAllDisplayModes(monitor->ns.displayID, NULL);
|
for (CFIndex i = 0; i < count; i++)
|
||||||
count = CFArrayGetCount(modes);
|
|
||||||
|
|
||||||
for (i = 0; i < count; i++)
|
|
||||||
{
|
{
|
||||||
CGDisplayModeRef dm = (CGDisplayModeRef) CFArrayGetValueAtIndex(modes, i);
|
CGDisplayModeRef dm = (CGDisplayModeRef) CFArrayGetValueAtIndex(modes, i);
|
||||||
if (!modeIsGood(dm))
|
if (!modeIsGood(dm))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
const GLFWvidmode mode = vidmodeFromCGDisplayMode(dm, link);
|
const GLFWvidmode mode =
|
||||||
|
vidmodeFromCGDisplayMode(dm, monitor->ns.fallbackRefreshRate);
|
||||||
if (_glfwCompareVideoModes(best, &mode) == 0)
|
if (_glfwCompareVideoModes(best, &mode) == 0)
|
||||||
{
|
{
|
||||||
native = dm;
|
native = dm;
|
||||||
|
@ -355,7 +411,6 @@ void _glfwSetVideoModeNS(_GLFWmonitor* monitor, const GLFWvidmode* desired)
|
||||||
}
|
}
|
||||||
|
|
||||||
CFRelease(modes);
|
CFRelease(modes);
|
||||||
CVDisplayLinkRelease(link);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Restore the previously saved (original) video mode
|
// Restore the previously saved (original) video mode
|
||||||
|
@ -443,26 +498,21 @@ GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* count)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
|
|
||||||
CFArrayRef modes;
|
|
||||||
CFIndex found, i, j;
|
|
||||||
GLFWvidmode* result;
|
|
||||||
CVDisplayLinkRef link;
|
|
||||||
|
|
||||||
*count = 0;
|
*count = 0;
|
||||||
|
|
||||||
CVDisplayLinkCreateWithCGDisplay(monitor->ns.displayID, &link);
|
CFArrayRef modes = CGDisplayCopyAllDisplayModes(monitor->ns.displayID, NULL);
|
||||||
|
const CFIndex found = CFArrayGetCount(modes);
|
||||||
|
GLFWvidmode* result = calloc(found, sizeof(GLFWvidmode));
|
||||||
|
|
||||||
modes = CGDisplayCopyAllDisplayModes(monitor->ns.displayID, NULL);
|
for (CFIndex i = 0; i < found; i++)
|
||||||
found = CFArrayGetCount(modes);
|
|
||||||
result = calloc(found, sizeof(GLFWvidmode));
|
|
||||||
|
|
||||||
for (i = 0; i < found; i++)
|
|
||||||
{
|
{
|
||||||
CGDisplayModeRef dm = (CGDisplayModeRef) CFArrayGetValueAtIndex(modes, i);
|
CGDisplayModeRef dm = (CGDisplayModeRef) CFArrayGetValueAtIndex(modes, i);
|
||||||
if (!modeIsGood(dm))
|
if (!modeIsGood(dm))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
const GLFWvidmode mode = vidmodeFromCGDisplayMode(dm, link);
|
const GLFWvidmode mode =
|
||||||
|
vidmodeFromCGDisplayMode(dm, monitor->ns.fallbackRefreshRate);
|
||||||
|
CFIndex j;
|
||||||
|
|
||||||
for (j = 0; j < *count; j++)
|
for (j = 0; j < *count; j++)
|
||||||
{
|
{
|
||||||
|
@ -479,7 +529,6 @@ GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* count)
|
||||||
}
|
}
|
||||||
|
|
||||||
CFRelease(modes);
|
CFRelease(modes);
|
||||||
CVDisplayLinkRelease(link);
|
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
} // autoreleasepool
|
} // autoreleasepool
|
||||||
|
@ -489,16 +538,9 @@ void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode *mode)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
|
|
||||||
CGDisplayModeRef displayMode;
|
CGDisplayModeRef native = CGDisplayCopyDisplayMode(monitor->ns.displayID);
|
||||||
CVDisplayLinkRef link;
|
*mode = vidmodeFromCGDisplayMode(native, monitor->ns.fallbackRefreshRate);
|
||||||
|
CGDisplayModeRelease(native);
|
||||||
CVDisplayLinkCreateWithCGDisplay(monitor->ns.displayID, &link);
|
|
||||||
|
|
||||||
displayMode = CGDisplayCopyDisplayMode(monitor->ns.displayID);
|
|
||||||
*mode = vidmodeFromCGDisplayMode(displayMode, link);
|
|
||||||
CGDisplayModeRelease(displayMode);
|
|
||||||
|
|
||||||
CVDisplayLinkRelease(link);
|
|
||||||
|
|
||||||
} // autoreleasepool
|
} // autoreleasepool
|
||||||
}
|
}
|
||||||
|
@ -507,7 +549,7 @@ GLFWbool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
|
|
||||||
uint32_t i, size = CGDisplayGammaTableCapacity(monitor->ns.displayID);
|
uint32_t size = CGDisplayGammaTableCapacity(monitor->ns.displayID);
|
||||||
CGGammaValue* values = calloc(size * 3, sizeof(CGGammaValue));
|
CGGammaValue* values = calloc(size * 3, sizeof(CGGammaValue));
|
||||||
|
|
||||||
CGGetDisplayTransferByTable(monitor->ns.displayID,
|
CGGetDisplayTransferByTable(monitor->ns.displayID,
|
||||||
|
@ -519,7 +561,7 @@ GLFWbool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
|
||||||
|
|
||||||
_glfwAllocGammaArrays(ramp, size);
|
_glfwAllocGammaArrays(ramp, size);
|
||||||
|
|
||||||
for (i = 0; i < size; i++)
|
for (uint32_t i = 0; i < size; i++)
|
||||||
{
|
{
|
||||||
ramp->red[i] = (unsigned short) (values[i] * 65535);
|
ramp->red[i] = (unsigned short) (values[i] * 65535);
|
||||||
ramp->green[i] = (unsigned short) (values[i + size] * 65535);
|
ramp->green[i] = (unsigned short) (values[i + size] * 65535);
|
||||||
|
@ -536,10 +578,9 @@ void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
|
|
||||||
int i;
|
|
||||||
CGGammaValue* values = calloc(ramp->size * 3, sizeof(CGGammaValue));
|
CGGammaValue* values = calloc(ramp->size * 3, sizeof(CGGammaValue));
|
||||||
|
|
||||||
for (i = 0; i < ramp->size; i++)
|
for (unsigned int i = 0; i < ramp->size; i++)
|
||||||
{
|
{
|
||||||
values[i] = ramp->red[i] / 65535.f;
|
values[i] = ramp->red[i] / 65535.f;
|
||||||
values[i + ramp->size] = ramp->green[i] / 65535.f;
|
values[i + ramp->size] = ramp->green[i] / 65535.f;
|
||||||
|
|
|
@ -28,8 +28,6 @@
|
||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
|
|
||||||
#include <Carbon/Carbon.h>
|
#include <Carbon/Carbon.h>
|
||||||
#include <CoreVideo/CVBase.h>
|
|
||||||
#include <CoreVideo/CVDisplayLink.h>
|
|
||||||
|
|
||||||
// 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
|
||||||
|
@ -41,6 +39,9 @@
|
||||||
typedef void* id;
|
typedef void* id;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// NOTE: Many Cocoa enum values have been renamed and we need to build across
|
||||||
|
// SDK versions where one is unavailable or the other deprecated
|
||||||
|
// We use the newer names in code and these macros to handle compatibility
|
||||||
#if MAC_OS_X_VERSION_MAX_ALLOWED < 101200
|
#if MAC_OS_X_VERSION_MAX_ALLOWED < 101200
|
||||||
#define NSBitmapFormatAlphaNonpremultiplied NSAlphaNonpremultipliedBitmapFormat
|
#define NSBitmapFormatAlphaNonpremultiplied NSAlphaNonpremultipliedBitmapFormat
|
||||||
#define NSEventMaskAny NSAnyEventMask
|
#define NSEventMaskAny NSAnyEventMask
|
||||||
|
@ -139,7 +140,7 @@ typedef struct _GLFWlibraryNS
|
||||||
id keyUpMonitor;
|
id keyUpMonitor;
|
||||||
id nibObjects;
|
id nibObjects;
|
||||||
|
|
||||||
char keyName[64];
|
char keynames[GLFW_KEY_LAST + 1][17];
|
||||||
short int keycodes[256];
|
short int keycodes[256];
|
||||||
short int scancodes[GLFW_KEY_LAST + 1];
|
short int scancodes[GLFW_KEY_LAST + 1];
|
||||||
char* clipboardString;
|
char* clipboardString;
|
||||||
|
@ -167,6 +168,7 @@ typedef struct _GLFWmonitorNS
|
||||||
CGDisplayModeRef previousMode;
|
CGDisplayModeRef previousMode;
|
||||||
uint32_t unitNumber;
|
uint32_t unitNumber;
|
||||||
id screen;
|
id screen;
|
||||||
|
double fallbackRefreshRate;
|
||||||
|
|
||||||
} _GLFWmonitorNS;
|
} _GLFWmonitorNS;
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,8 @@
|
||||||
// distribution.
|
// distribution.
|
||||||
//
|
//
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
// It is fine to use C99 in this file because it will not be built with VS
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,8 @@
|
||||||
// distribution.
|
// distribution.
|
||||||
//
|
//
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
// It is fine to use C99 in this file because it will not be built with VS
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
|
@ -33,15 +35,14 @@
|
||||||
//
|
//
|
||||||
static NSUInteger getStyleMask(_GLFWwindow* window)
|
static NSUInteger getStyleMask(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
NSUInteger styleMask = 0;
|
NSUInteger styleMask = NSWindowStyleMaskMiniaturizable;
|
||||||
|
|
||||||
if (window->monitor || !window->decorated)
|
if (window->monitor || !window->decorated)
|
||||||
styleMask |= NSWindowStyleMaskBorderless;
|
styleMask |= NSWindowStyleMaskBorderless;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
styleMask |= NSWindowStyleMaskTitled |
|
styleMask |= NSWindowStyleMaskTitled |
|
||||||
NSWindowStyleMaskClosable |
|
NSWindowStyleMaskClosable;
|
||||||
NSWindowStyleMaskMiniaturizable;
|
|
||||||
|
|
||||||
if (window->resizable)
|
if (window->resizable)
|
||||||
styleMask |= NSWindowStyleMaskResizable;
|
styleMask |= NSWindowStyleMaskResizable;
|
||||||
|
@ -321,12 +322,6 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
|
||||||
_glfwInputWindowFocus(window, GLFW_FALSE);
|
_glfwInputWindowFocus(window, GLFW_FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)windowDidChangeScreen:(NSNotification *)notification
|
|
||||||
{
|
|
||||||
if (window->context.source == GLFW_NATIVE_CONTEXT_API)
|
|
||||||
_glfwUpdateDisplayLinkDisplayNSGL(window);
|
|
||||||
}
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
||||||
|
@ -610,10 +605,8 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
|
||||||
|
|
||||||
- (void)scrollWheel:(NSEvent *)event
|
- (void)scrollWheel:(NSEvent *)event
|
||||||
{
|
{
|
||||||
double deltaX, deltaY;
|
double deltaX = [event scrollingDeltaX];
|
||||||
|
double deltaY = [event scrollingDeltaY];
|
||||||
deltaX = [event scrollingDeltaX];
|
|
||||||
deltaY = [event scrollingDeltaY];
|
|
||||||
|
|
||||||
if ([event hasPreciseScrollingDeltas])
|
if ([event hasPreciseScrollingDeltas])
|
||||||
{
|
{
|
||||||
|
@ -730,9 +723,8 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
|
||||||
else
|
else
|
||||||
characters = (NSString*) string;
|
characters = (NSString*) string;
|
||||||
|
|
||||||
NSUInteger i, length = [characters length];
|
const NSUInteger length = [characters length];
|
||||||
|
for (NSUInteger i = 0; i < length; i++)
|
||||||
for (i = 0; i < length; i++)
|
|
||||||
{
|
{
|
||||||
const unichar codepoint = [characters characterAtIndex:i];
|
const unichar codepoint = [characters characterAtIndex:i];
|
||||||
if ((codepoint & 0xff00) == 0xf700)
|
if ((codepoint & 0xff00) == 0xf700)
|
||||||
|
@ -817,7 +809,7 @@ static GLFWbool createNativeWindow(_GLFWwindow* window,
|
||||||
[window->ns.object setLevel:NSMainMenuWindowLevel + 1];
|
[window->ns.object setLevel:NSMainMenuWindowLevel + 1];
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
[window->ns.object center];
|
[(NSWindow*) window->ns.object center];
|
||||||
_glfw.ns.cascadePoint =
|
_glfw.ns.cascadePoint =
|
||||||
NSPointToCGPoint([window->ns.object cascadeTopLeftFromPoint:
|
NSPointToCGPoint([window->ns.object cascadeTopLeftFromPoint:
|
||||||
NSPointFromCGPoint(_glfw.ns.cascadePoint)]);
|
NSPointFromCGPoint(_glfw.ns.cascadePoint)]);
|
||||||
|
@ -893,10 +885,7 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
|
|
||||||
if (!_glfw.ns.finishedLaunching)
|
if (!_glfw.ns.finishedLaunching)
|
||||||
{
|
|
||||||
[NSApp run];
|
[NSApp run];
|
||||||
_glfw.ns.finishedLaunching = GLFW_TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!createNativeWindow(window, wndconfig, fbconfig))
|
if (!createNativeWindow(window, wndconfig, fbconfig))
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
|
@ -963,16 +952,20 @@ void _glfwPlatformDestroyWindow(_GLFWwindow* window)
|
||||||
[window->ns.object close];
|
[window->ns.object close];
|
||||||
window->ns.object = nil;
|
window->ns.object = nil;
|
||||||
|
|
||||||
|
// HACK: Allow Cocoa to catch up before returning
|
||||||
|
_glfwPlatformPollEvents();
|
||||||
|
|
||||||
} // autoreleasepool
|
} // autoreleasepool
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char *title)
|
void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
[window->ns.object setTitle:@(title)];
|
NSString* string = @(title);
|
||||||
|
[window->ns.object setTitle:string];
|
||||||
// HACK: Set the miniwindow title explicitly as setTitle: doesn't update it
|
// HACK: Set the miniwindow title explicitly as setTitle: doesn't update it
|
||||||
// if the window lacks NSWindowStyleMaskTitled
|
// if the window lacks NSWindowStyleMaskTitled
|
||||||
[window->ns.object setMiniwindowTitle:@(title)];
|
[window->ns.object setMiniwindowTitle:string];
|
||||||
} // autoreleasepool
|
} // autoreleasepool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1033,7 +1026,14 @@ void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
|
||||||
acquireMonitor(window);
|
acquireMonitor(window);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
[window->ns.object setContentSize:NSMakeSize(width, height)];
|
{
|
||||||
|
NSRect contentRect =
|
||||||
|
[window->ns.object contentRectForFrameRect:[window->ns.object frame]];
|
||||||
|
contentRect.origin.y += contentRect.size.height - height;
|
||||||
|
contentRect.size = NSMakeSize(width, height);
|
||||||
|
[window->ns.object setFrame:[window->ns.object frameRectForContentRect:contentRect]
|
||||||
|
display:YES];
|
||||||
|
}
|
||||||
|
|
||||||
} // autoreleasepool
|
} // autoreleasepool
|
||||||
}
|
}
|
||||||
|
@ -1222,7 +1222,7 @@ void _glfwPlatformSetWindowMonitor(_GLFWwindow* window,
|
||||||
// HACK: Changing the style mask can cause the first responder to be cleared
|
// HACK: Changing the style mask can cause the first responder to be cleared
|
||||||
[window->ns.object makeFirstResponder:window->ns.view];
|
[window->ns.object makeFirstResponder:window->ns.view];
|
||||||
|
|
||||||
if (monitor)
|
if (window->monitor)
|
||||||
{
|
{
|
||||||
[window->ns.object setLevel:NSMainMenuWindowLevel + 1];
|
[window->ns.object setLevel:NSMainMenuWindowLevel + 1];
|
||||||
[window->ns.object setHasShadow:NO];
|
[window->ns.object setHasShadow:NO];
|
||||||
|
@ -1377,6 +1377,9 @@ void _glfwPlatformPollEvents(void)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
|
|
||||||
|
if (!_glfw.ns.finishedLaunching)
|
||||||
|
[NSApp run];
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
NSEvent* event = [NSApp nextEventMatchingMask:NSEventMaskAny
|
NSEvent* event = [NSApp nextEventMatchingMask:NSEventMaskAny
|
||||||
|
@ -1396,6 +1399,9 @@ void _glfwPlatformWaitEvents(void)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
|
|
||||||
|
if (!_glfw.ns.finishedLaunching)
|
||||||
|
[NSApp run];
|
||||||
|
|
||||||
// I wanted to pass NO to dequeue:, and rely on PollEvents to
|
// I wanted to pass NO to dequeue:, and rely on PollEvents to
|
||||||
// dequeue and send. For reasons not at all clear to me, passing
|
// dequeue and send. For reasons not at all clear to me, passing
|
||||||
// NO to dequeue: causes this method never to return.
|
// NO to dequeue: causes this method never to return.
|
||||||
|
@ -1414,6 +1420,9 @@ void _glfwPlatformWaitEventsTimeout(double timeout)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
|
|
||||||
|
if (!_glfw.ns.finishedLaunching)
|
||||||
|
[NSApp run];
|
||||||
|
|
||||||
NSDate* date = [NSDate dateWithTimeIntervalSinceNow:timeout];
|
NSDate* date = [NSDate dateWithTimeIntervalSinceNow:timeout];
|
||||||
NSEvent* event = [NSApp nextEventMatchingMask:NSEventMaskAny
|
NSEvent* event = [NSApp nextEventMatchingMask:NSEventMaskAny
|
||||||
untilDate:date
|
untilDate:date
|
||||||
|
@ -1431,6 +1440,9 @@ void _glfwPlatformPostEmptyEvent(void)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
|
|
||||||
|
if (!_glfw.ns.finishedLaunching)
|
||||||
|
[NSApp run];
|
||||||
|
|
||||||
NSEvent* event = [NSEvent otherEventWithType:NSEventTypeApplicationDefined
|
NSEvent* event = [NSEvent otherEventWithType:NSEventTypeApplicationDefined
|
||||||
location:NSMakePoint(0, 0)
|
location:NSMakePoint(0, 0)
|
||||||
modifierFlags:0
|
modifierFlags:0
|
||||||
|
@ -1504,8 +1516,10 @@ const char* _glfwPlatformGetScancodeName(int scancode)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
|
|
||||||
|
const int key = _glfw.ns.keycodes[scancode];
|
||||||
|
|
||||||
UInt32 deadKeyState = 0;
|
UInt32 deadKeyState = 0;
|
||||||
UniChar characters[8];
|
UniChar characters[4];
|
||||||
UniCharCount characterCount = 0;
|
UniCharCount characterCount = 0;
|
||||||
|
|
||||||
if (UCKeyTranslate([(NSData*) _glfw.ns.unicodeData bytes],
|
if (UCKeyTranslate([(NSData*) _glfw.ns.unicodeData bytes],
|
||||||
|
@ -1530,12 +1544,12 @@ const char* _glfwPlatformGetScancodeName(int scancode)
|
||||||
characterCount,
|
characterCount,
|
||||||
kCFAllocatorNull);
|
kCFAllocatorNull);
|
||||||
CFStringGetCString(string,
|
CFStringGetCString(string,
|
||||||
_glfw.ns.keyName,
|
_glfw.ns.keynames[key],
|
||||||
sizeof(_glfw.ns.keyName),
|
sizeof(_glfw.ns.keynames[key]),
|
||||||
kCFStringEncodingUTF8);
|
kCFStringEncodingUTF8);
|
||||||
CFRelease(string);
|
CFRelease(string);
|
||||||
|
|
||||||
return _glfw.ns.keyName;
|
return _glfw.ns.keynames[key];
|
||||||
|
|
||||||
} // autoreleasepool
|
} // autoreleasepool
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,8 @@
|
||||||
// distribution.
|
// distribution.
|
||||||
//
|
//
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
// Please use C89 style variable declarations in this file because VS 2010
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,8 @@
|
||||||
// distribution.
|
// distribution.
|
||||||
//
|
//
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
// Please use C89 style variable declarations in this file because VS 2010
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
|
@ -121,23 +123,24 @@ static GLFWbool chooseEGLConfig(const _GLFWctxconfig* ctxconfig,
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
#if defined(_GLFW_X11)
|
#if defined(_GLFW_X11)
|
||||||
XVisualInfo vi = {0};
|
|
||||||
|
|
||||||
// Only consider EGLConfigs with associated Visuals
|
|
||||||
vi.visualid = getEGLConfigAttrib(n, EGL_NATIVE_VISUAL_ID);
|
|
||||||
if (!vi.visualid)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (desired->transparent)
|
|
||||||
{
|
{
|
||||||
int count;
|
XVisualInfo vi = {0};
|
||||||
XVisualInfo* vis = XGetVisualInfo(_glfw.x11.display,
|
|
||||||
VisualIDMask, &vi,
|
// Only consider EGLConfigs with associated Visuals
|
||||||
&count);
|
vi.visualid = getEGLConfigAttrib(n, EGL_NATIVE_VISUAL_ID);
|
||||||
if (vis)
|
if (!vi.visualid)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (desired->transparent)
|
||||||
{
|
{
|
||||||
u->transparent = _glfwIsVisualTransparentX11(vis[0].visual);
|
int count;
|
||||||
XFree(vis);
|
XVisualInfo* vis =
|
||||||
|
XGetVisualInfo(_glfw.x11.display, VisualIDMask, &vi, &count);
|
||||||
|
if (vis)
|
||||||
|
{
|
||||||
|
u->transparent = _glfwIsVisualTransparentX11(vis[0].visual);
|
||||||
|
XFree(vis);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // _GLFW_X11
|
#endif // _GLFW_X11
|
||||||
|
|
|
@ -47,26 +47,26 @@ typedef struct wl_egl_window* EGLNativeWindowType;
|
||||||
#error "No supported EGL platform selected"
|
#error "No supported EGL platform selected"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define EGL_SUCCESS 0x3000
|
#define EGL_SUCCESS 0x3000
|
||||||
#define EGL_NOT_INITIALIZED 0x3001
|
#define EGL_NOT_INITIALIZED 0x3001
|
||||||
#define EGL_BAD_ACCESS 0x3002
|
#define EGL_BAD_ACCESS 0x3002
|
||||||
#define EGL_BAD_ALLOC 0x3003
|
#define EGL_BAD_ALLOC 0x3003
|
||||||
#define EGL_BAD_ATTRIBUTE 0x3004
|
#define EGL_BAD_ATTRIBUTE 0x3004
|
||||||
#define EGL_BAD_CONFIG 0x3005
|
#define EGL_BAD_CONFIG 0x3005
|
||||||
#define EGL_BAD_CONTEXT 0x3006
|
#define EGL_BAD_CONTEXT 0x3006
|
||||||
#define EGL_BAD_CURRENT_SURFACE 0x3007
|
#define EGL_BAD_CURRENT_SURFACE 0x3007
|
||||||
#define EGL_BAD_DISPLAY 0x3008
|
#define EGL_BAD_DISPLAY 0x3008
|
||||||
#define EGL_BAD_MATCH 0x3009
|
#define EGL_BAD_MATCH 0x3009
|
||||||
#define EGL_BAD_NATIVE_PIXMAP 0x300a
|
#define EGL_BAD_NATIVE_PIXMAP 0x300a
|
||||||
#define EGL_BAD_NATIVE_WINDOW 0x300b
|
#define EGL_BAD_NATIVE_WINDOW 0x300b
|
||||||
#define EGL_BAD_PARAMETER 0x300c
|
#define EGL_BAD_PARAMETER 0x300c
|
||||||
#define EGL_BAD_SURFACE 0x300d
|
#define EGL_BAD_SURFACE 0x300d
|
||||||
#define EGL_CONTEXT_LOST 0x300e
|
#define EGL_CONTEXT_LOST 0x300e
|
||||||
#define EGL_COLOR_BUFFER_TYPE 0x303f
|
#define EGL_COLOR_BUFFER_TYPE 0x303f
|
||||||
#define EGL_RGB_BUFFER 0x308e
|
#define EGL_RGB_BUFFER 0x308e
|
||||||
#define EGL_SURFACE_TYPE 0x3033
|
#define EGL_SURFACE_TYPE 0x3033
|
||||||
#define EGL_WINDOW_BIT 0x0004
|
#define EGL_WINDOW_BIT 0x0004
|
||||||
#define EGL_RENDERABLE_TYPE 0x3040
|
#define EGL_RENDERABLE_TYPE 0x3040
|
||||||
#define EGL_OPENGL_ES_BIT 0x0001
|
#define EGL_OPENGL_ES_BIT 0x0001
|
||||||
#define EGL_OPENGL_ES2_BIT 0x0004
|
#define EGL_OPENGL_ES2_BIT 0x0004
|
||||||
#define EGL_OPENGL_BIT 0x0008
|
#define EGL_OPENGL_BIT 0x0008
|
||||||
|
@ -76,7 +76,7 @@ typedef struct wl_egl_window* EGLNativeWindowType;
|
||||||
#define EGL_RED_SIZE 0x3024
|
#define EGL_RED_SIZE 0x3024
|
||||||
#define EGL_DEPTH_SIZE 0x3025
|
#define EGL_DEPTH_SIZE 0x3025
|
||||||
#define EGL_STENCIL_SIZE 0x3026
|
#define EGL_STENCIL_SIZE 0x3026
|
||||||
#define EGL_SAMPLES 0x3031
|
#define EGL_SAMPLES 0x3031
|
||||||
#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
|
||||||
|
|
|
@ -5,7 +5,7 @@ libdir=@CMAKE_INSTALL_FULL_LIBDIR@
|
||||||
|
|
||||||
Name: GLFW
|
Name: GLFW
|
||||||
Description: A multi-platform library for OpenGL, window and input
|
Description: A multi-platform library for OpenGL, window and input
|
||||||
Version: @GLFW_VERSION_FULL@
|
Version: @GLFW_VERSION@
|
||||||
URL: https://www.glfw.org/
|
URL: https://www.glfw.org/
|
||||||
Requires.private: @GLFW_PKG_DEPS@
|
Requires.private: @GLFW_PKG_DEPS@
|
||||||
Libs: -L${libdir} -l@GLFW_LIB_NAME@
|
Libs: -L${libdir} -l@GLFW_LIB_NAME@
|
||||||
|
|
|
@ -24,6 +24,8 @@
|
||||||
// distribution.
|
// distribution.
|
||||||
//
|
//
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
// It is fine to use C99 in this file because it will not be built with VS
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
|
@ -226,8 +228,6 @@ static GLFWglproc getProcAddressGLX(const char* procname)
|
||||||
return _glfw_dlsym(_glfw.glx.handle, procname);
|
return _glfw_dlsym(_glfw.glx.handle, procname);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Destroy the OpenGL context
|
|
||||||
//
|
|
||||||
static void destroyContextGLX(_GLFWwindow* window)
|
static void destroyContextGLX(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
if (window->context.glx.window)
|
if (window->context.glx.window)
|
||||||
|
|
|
@ -29,11 +29,11 @@
|
||||||
#define GLX_RGBA_BIT 0x00000001
|
#define GLX_RGBA_BIT 0x00000001
|
||||||
#define GLX_WINDOW_BIT 0x00000001
|
#define GLX_WINDOW_BIT 0x00000001
|
||||||
#define GLX_DRAWABLE_TYPE 0x8010
|
#define GLX_DRAWABLE_TYPE 0x8010
|
||||||
#define GLX_RENDER_TYPE 0x8011
|
#define GLX_RENDER_TYPE 0x8011
|
||||||
#define GLX_RGBA_TYPE 0x8014
|
#define GLX_RGBA_TYPE 0x8014
|
||||||
#define GLX_DOUBLEBUFFER 5
|
#define GLX_DOUBLEBUFFER 5
|
||||||
#define GLX_STEREO 6
|
#define GLX_STEREO 6
|
||||||
#define GLX_AUX_BUFFERS 7
|
#define GLX_AUX_BUFFERS 7
|
||||||
#define GLX_RED_SIZE 8
|
#define GLX_RED_SIZE 8
|
||||||
#define GLX_GREEN_SIZE 9
|
#define GLX_GREEN_SIZE 9
|
||||||
#define GLX_BLUE_SIZE 10
|
#define GLX_BLUE_SIZE 10
|
||||||
|
@ -42,7 +42,7 @@
|
||||||
#define GLX_STENCIL_SIZE 13
|
#define GLX_STENCIL_SIZE 13
|
||||||
#define GLX_ACCUM_RED_SIZE 14
|
#define GLX_ACCUM_RED_SIZE 14
|
||||||
#define GLX_ACCUM_GREEN_SIZE 15
|
#define GLX_ACCUM_GREEN_SIZE 15
|
||||||
#define GLX_ACCUM_BLUE_SIZE 16
|
#define GLX_ACCUM_BLUE_SIZE 16
|
||||||
#define GLX_ACCUM_ALPHA_SIZE 17
|
#define GLX_ACCUM_ALPHA_SIZE 17
|
||||||
#define GLX_SAMPLES 0x186a1
|
#define GLX_SAMPLES 0x186a1
|
||||||
#define GLX_VISUAL_ID 0x800b
|
#define GLX_VISUAL_ID 0x800b
|
||||||
|
|
|
@ -24,6 +24,8 @@
|
||||||
// distribution.
|
// distribution.
|
||||||
//
|
//
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
// Please use C89 style variable declarations in this file because VS 2010
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
#include "mappings.h"
|
#include "mappings.h"
|
||||||
|
|
|
@ -24,6 +24,8 @@
|
||||||
// distribution.
|
// distribution.
|
||||||
//
|
//
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
// Please use C89 style variable declarations in this file because VS 2010
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
|
|
|
@ -84,8 +84,8 @@ typedef GLFWglproc (* _GLFWgetprocaddressfun)(const char*);
|
||||||
typedef void (* _GLFWdestroycontextfun)(_GLFWwindow*);
|
typedef void (* _GLFWdestroycontextfun)(_GLFWwindow*);
|
||||||
|
|
||||||
#define GL_VERSION 0x1f02
|
#define GL_VERSION 0x1f02
|
||||||
#define GL_NONE 0
|
#define GL_NONE 0
|
||||||
#define GL_COLOR_BUFFER_BIT 0x00004000
|
#define GL_COLOR_BUFFER_BIT 0x00004000
|
||||||
#define GL_UNSIGNED_BYTE 0x1401
|
#define GL_UNSIGNED_BYTE 0x1401
|
||||||
#define GL_EXTENSIONS 0x1f03
|
#define GL_EXTENSIONS 0x1f03
|
||||||
#define GL_NUM_EXTENSIONS 0x821d
|
#define GL_NUM_EXTENSIONS 0x821d
|
||||||
|
@ -102,7 +102,7 @@ typedef void (* _GLFWdestroycontextfun)(_GLFWwindow*);
|
||||||
#define GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH 0x82fc
|
#define GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH 0x82fc
|
||||||
#define GL_CONTEXT_FLAG_NO_ERROR_BIT_KHR 0x00000008
|
#define GL_CONTEXT_FLAG_NO_ERROR_BIT_KHR 0x00000008
|
||||||
|
|
||||||
typedef int GLint;
|
typedef int GLint;
|
||||||
typedef unsigned int GLuint;
|
typedef unsigned int GLuint;
|
||||||
typedef unsigned int GLenum;
|
typedef unsigned int GLenum;
|
||||||
typedef unsigned int GLbitfield;
|
typedef unsigned int GLbitfield;
|
||||||
|
|
|
@ -24,6 +24,8 @@
|
||||||
// distribution.
|
// distribution.
|
||||||
//
|
//
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
// It is fine to use C99 in this file because it will not be built with VS
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
|
@ -104,9 +106,7 @@ static void handleAbsEvent(_GLFWjoystick* js, int code, int value)
|
||||||
//
|
//
|
||||||
static void pollAbsState(_GLFWjoystick* js)
|
static void pollAbsState(_GLFWjoystick* js)
|
||||||
{
|
{
|
||||||
int code;
|
for (int code = 0; code < ABS_CNT; code++)
|
||||||
|
|
||||||
for (code = 0; code < ABS_CNT; code++)
|
|
||||||
{
|
{
|
||||||
if (js->linjs.absMap[code] < 0)
|
if (js->linjs.absMap[code] < 0)
|
||||||
continue;
|
continue;
|
||||||
|
@ -126,18 +126,7 @@ static void pollAbsState(_GLFWjoystick* js)
|
||||||
//
|
//
|
||||||
static GLFWbool openJoystickDevice(const char* path)
|
static GLFWbool openJoystickDevice(const char* path)
|
||||||
{
|
{
|
||||||
int jid, code;
|
for (int jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++)
|
||||||
char name[256] = "";
|
|
||||||
char guid[33] = "";
|
|
||||||
char evBits[(EV_CNT + 7) / 8] = {0};
|
|
||||||
char keyBits[(KEY_CNT + 7) / 8] = {0};
|
|
||||||
char absBits[(ABS_CNT + 7) / 8] = {0};
|
|
||||||
int axisCount = 0, buttonCount = 0, hatCount = 0;
|
|
||||||
struct input_id id;
|
|
||||||
_GLFWjoystickLinux linjs = {0};
|
|
||||||
_GLFWjoystick* js = NULL;
|
|
||||||
|
|
||||||
for (jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++)
|
|
||||||
{
|
{
|
||||||
if (!_glfw.joysticks[jid].present)
|
if (!_glfw.joysticks[jid].present)
|
||||||
continue;
|
continue;
|
||||||
|
@ -145,10 +134,16 @@ static GLFWbool openJoystickDevice(const char* path)
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_GLFWjoystickLinux linjs = {0};
|
||||||
linjs.fd = open(path, O_RDONLY | O_NONBLOCK);
|
linjs.fd = open(path, O_RDONLY | O_NONBLOCK);
|
||||||
if (linjs.fd == -1)
|
if (linjs.fd == -1)
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
|
|
||||||
|
char evBits[(EV_CNT + 7) / 8] = {0};
|
||||||
|
char keyBits[(KEY_CNT + 7) / 8] = {0};
|
||||||
|
char absBits[(ABS_CNT + 7) / 8] = {0};
|
||||||
|
struct input_id id;
|
||||||
|
|
||||||
if (ioctl(linjs.fd, EVIOCGBIT(0, sizeof(evBits)), evBits) < 0 ||
|
if (ioctl(linjs.fd, EVIOCGBIT(0, sizeof(evBits)), evBits) < 0 ||
|
||||||
ioctl(linjs.fd, EVIOCGBIT(EV_KEY, sizeof(keyBits)), keyBits) < 0 ||
|
ioctl(linjs.fd, EVIOCGBIT(EV_KEY, sizeof(keyBits)), keyBits) < 0 ||
|
||||||
ioctl(linjs.fd, EVIOCGBIT(EV_ABS, sizeof(absBits)), absBits) < 0 ||
|
ioctl(linjs.fd, EVIOCGBIT(EV_ABS, sizeof(absBits)), absBits) < 0 ||
|
||||||
|
@ -168,9 +163,13 @@ static GLFWbool openJoystickDevice(const char* path)
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char name[256] = "";
|
||||||
|
|
||||||
if (ioctl(linjs.fd, EVIOCGNAME(sizeof(name)), name) < 0)
|
if (ioctl(linjs.fd, EVIOCGNAME(sizeof(name)), name) < 0)
|
||||||
strncpy(name, "Unknown", sizeof(name));
|
strncpy(name, "Unknown", sizeof(name));
|
||||||
|
|
||||||
|
char guid[33] = "";
|
||||||
|
|
||||||
// Generate a joystick GUID that matches the SDL 2.0.5+ one
|
// Generate a joystick GUID that matches the SDL 2.0.5+ one
|
||||||
if (id.vendor && id.product && id.version)
|
if (id.vendor && id.product && id.version)
|
||||||
{
|
{
|
||||||
|
@ -189,7 +188,9 @@ static GLFWbool openJoystickDevice(const char* path)
|
||||||
name[8], name[9], name[10]);
|
name[8], name[9], name[10]);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (code = BTN_MISC; code < KEY_CNT; code++)
|
int axisCount = 0, buttonCount = 0, hatCount = 0;
|
||||||
|
|
||||||
|
for (int code = BTN_MISC; code < KEY_CNT; code++)
|
||||||
{
|
{
|
||||||
if (!isBitSet(code, keyBits))
|
if (!isBitSet(code, keyBits))
|
||||||
continue;
|
continue;
|
||||||
|
@ -198,7 +199,7 @@ static GLFWbool openJoystickDevice(const char* path)
|
||||||
buttonCount++;
|
buttonCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (code = 0; code < ABS_CNT; code++)
|
for (int code = 0; code < ABS_CNT; code++)
|
||||||
{
|
{
|
||||||
linjs.absMap[code] = -1;
|
linjs.absMap[code] = -1;
|
||||||
if (!isBitSet(code, absBits))
|
if (!isBitSet(code, absBits))
|
||||||
|
@ -221,7 +222,8 @@ static GLFWbool openJoystickDevice(const char* path)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
js = _glfwAllocJoystick(name, guid, axisCount, buttonCount, hatCount);
|
_GLFWjoystick* js =
|
||||||
|
_glfwAllocJoystick(name, guid, axisCount, buttonCount, hatCount);
|
||||||
if (!js)
|
if (!js)
|
||||||
{
|
{
|
||||||
close(linjs.fd);
|
close(linjs.fd);
|
||||||
|
@ -266,8 +268,6 @@ static int compareJoysticks(const void* fp, const void* sp)
|
||||||
//
|
//
|
||||||
GLFWbool _glfwInitJoysticksLinux(void)
|
GLFWbool _glfwInitJoysticksLinux(void)
|
||||||
{
|
{
|
||||||
DIR* dir;
|
|
||||||
int count = 0;
|
|
||||||
const char* dirname = "/dev/input";
|
const char* dirname = "/dev/input";
|
||||||
|
|
||||||
_glfw.linjs.inotify = inotify_init1(IN_NONBLOCK | IN_CLOEXEC);
|
_glfw.linjs.inotify = inotify_init1(IN_NONBLOCK | IN_CLOEXEC);
|
||||||
|
@ -289,7 +289,9 @@ GLFWbool _glfwInitJoysticksLinux(void)
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
dir = opendir(dirname);
|
int count = 0;
|
||||||
|
|
||||||
|
DIR* dir = opendir(dirname);
|
||||||
if (dir)
|
if (dir)
|
||||||
{
|
{
|
||||||
struct dirent* entry;
|
struct dirent* entry;
|
||||||
|
@ -344,12 +346,11 @@ void _glfwTerminateJoysticksLinux(void)
|
||||||
|
|
||||||
void _glfwDetectJoystickConnectionLinux(void)
|
void _glfwDetectJoystickConnectionLinux(void)
|
||||||
{
|
{
|
||||||
ssize_t offset = 0;
|
|
||||||
char buffer[16384];
|
|
||||||
|
|
||||||
if (_glfw.linjs.inotify <= 0)
|
if (_glfw.linjs.inotify <= 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
ssize_t offset = 0;
|
||||||
|
char buffer[16384];
|
||||||
const ssize_t size = read(_glfw.linjs.inotify, buffer, sizeof(buffer));
|
const ssize_t size = read(_glfw.linjs.inotify, buffer, sizeof(buffer));
|
||||||
|
|
||||||
while (size > offset)
|
while (size > offset)
|
||||||
|
@ -369,9 +370,7 @@ void _glfwDetectJoystickConnectionLinux(void)
|
||||||
openJoystickDevice(path);
|
openJoystickDevice(path);
|
||||||
else if (e->mask & IN_DELETE)
|
else if (e->mask & IN_DELETE)
|
||||||
{
|
{
|
||||||
int jid;
|
for (int jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++)
|
||||||
|
|
||||||
for (jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++)
|
|
||||||
{
|
{
|
||||||
if (strcmp(_glfw.joysticks[jid].linjs.path, path) == 0)
|
if (strcmp(_glfw.joysticks[jid].linjs.path, path) == 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -84,7 +84,6 @@ const char* _glfwDefaultMappings[] =
|
||||||
"030000000d0f00008700000000000000,Fighting Stick mini 4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows,",
|
"030000000d0f00008700000000000000,Fighting Stick mini 4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows,",
|
||||||
"030000000d0f00002700000000000000,FIGHTING STICK V3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows,",
|
"030000000d0f00002700000000000000,FIGHTING STICK V3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows,",
|
||||||
"78696e70757403000000000000000000,Fightstick TES,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,lefttrigger:a2,rightshoulder:b5,righttrigger:a5,start:b7,x:b2,y:b3,platform:Windows,",
|
"78696e70757403000000000000000000,Fightstick TES,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,lefttrigger:a2,rightshoulder:b5,righttrigger:a5,start:b7,x:b2,y:b3,platform:Windows,",
|
||||||
"03000000790000000600000000000000,G-Shark GS-GP702,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a4,start:b9,x:b3,y:b0,platform:Windows,",
|
|
||||||
"03000000260900002625000000000000,Gamecube Controller,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b6,lefttrigger:a4,leftx:a0,lefty:a1,righttrigger:a5,rightx:a2,righty:a3,start:b7,x:b2,y:b3,platform:Windows,",
|
"03000000260900002625000000000000,Gamecube Controller,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b6,lefttrigger:a4,leftx:a0,lefty:a1,righttrigger:a5,rightx:a2,righty:a3,start:b7,x:b2,y:b3,platform:Windows,",
|
||||||
"030000008f0e00000d31000000000000,GAMEPAD 3 TURBO,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
|
"030000008f0e00000d31000000000000,GAMEPAD 3 TURBO,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
|
||||||
"03000000280400000140000000000000,GamePad Pro USB,a:b1,b:b2,back:b8,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows,",
|
"03000000280400000140000000000000,GamePad Pro USB,a:b1,b:b2,back:b8,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows,",
|
||||||
|
@ -207,7 +206,6 @@ const char* _glfwDefaultMappings[] =
|
||||||
"030000008305000031b0000000000000,Cideko AK08b,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,",
|
"030000008305000031b0000000000000,Cideko AK08b,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,",
|
||||||
"03000000260900008888000088020000,Cyber Gadget GameCube Controller,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b6,righttrigger:a5,rightx:a2,righty:a3~,start:b7,x:b2,y:b3,platform:Mac OS X,",
|
"03000000260900008888000088020000,Cyber Gadget GameCube Controller,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b6,righttrigger:a5,rightx:a2,righty:a3~,start:b7,x:b2,y:b3,platform:Mac OS X,",
|
||||||
"03000000a306000022f6000001030000,Cyborg V.3 Rumble Pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:+a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:-a3,rightx:a2,righty:a4,start:b9,x:b0,y:b3,platform:Mac OS X,",
|
"03000000a306000022f6000001030000,Cyborg V.3 Rumble Pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:+a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:-a3,rightx:a2,righty:a4,start:b9,x:b0,y:b3,platform:Mac OS X,",
|
||||||
"03000000790000000600000000000000,G-Shark GP-702,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a4,start:b9,x:b3,y:b0,platform:Mac OS X,",
|
|
||||||
"03000000ad1b000001f9000000000000,Gamestop BB-070 X360 Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X,",
|
"03000000ad1b000001f9000000000000,Gamestop BB-070 X360 Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X,",
|
||||||
"0500000047532047616d657061640000,GameStop Gamepad,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Mac OS X,",
|
"0500000047532047616d657061640000,GameStop Gamepad,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Mac OS X,",
|
||||||
"030000000d0f00005f00000000010000,Hori Fighting Commander 4 (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,",
|
"030000000d0f00005f00000000010000,Hori Fighting Commander 4 (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,",
|
||||||
|
|
|
@ -24,6 +24,8 @@
|
||||||
// distribution.
|
// distribution.
|
||||||
//
|
//
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
// Please use C89 style variable declarations in this file because VS 2010
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
|
@ -54,6 +56,10 @@ static int compareVideoModes(const void* fp, const void* sp)
|
||||||
if (farea != sarea)
|
if (farea != sarea)
|
||||||
return farea - sarea;
|
return farea - sarea;
|
||||||
|
|
||||||
|
// Then sort on width
|
||||||
|
if (fm->width != sm->width)
|
||||||
|
return fm->width - sm->width;
|
||||||
|
|
||||||
// Lastly sort on refresh rate
|
// Lastly sort on refresh rate
|
||||||
return fm->refreshRate - sm->refreshRate;
|
return fm->refreshRate - sm->refreshRate;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,9 @@
|
||||||
//
|
//
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
|
// NOTE: Many Cocoa enum values have been renamed and we need to build across
|
||||||
|
// SDK versions where one is unavailable or the other deprecated
|
||||||
|
// We use the newer names in code and these macros to handle compatibility
|
||||||
#if MAC_OS_X_VERSION_MAX_ALLOWED < 101400
|
#if MAC_OS_X_VERSION_MAX_ALLOWED < 101400
|
||||||
#define NSOpenGLContextParameterSwapInterval NSOpenGLCPSwapInterval
|
#define NSOpenGLContextParameterSwapInterval NSOpenGLCPSwapInterval
|
||||||
#define NSOpenGLContextParameterSurfaceOpacity NSOpenGLCPSurfaceOpacity
|
#define NSOpenGLContextParameterSurfaceOpacity NSOpenGLCPSurfaceOpacity
|
||||||
|
@ -41,10 +44,6 @@ typedef struct _GLFWcontextNSGL
|
||||||
{
|
{
|
||||||
id pixelFormat;
|
id pixelFormat;
|
||||||
id object;
|
id object;
|
||||||
CVDisplayLinkRef displayLink;
|
|
||||||
atomic_int swapInterval;
|
|
||||||
int swapIntervalsPassed;
|
|
||||||
id swapIntervalCond;
|
|
||||||
|
|
||||||
} _GLFWcontextNSGL;
|
} _GLFWcontextNSGL;
|
||||||
|
|
||||||
|
@ -64,5 +63,4 @@ GLFWbool _glfwCreateContextNSGL(_GLFWwindow* window,
|
||||||
const _GLFWctxconfig* ctxconfig,
|
const _GLFWctxconfig* ctxconfig,
|
||||||
const _GLFWfbconfig* fbconfig);
|
const _GLFWfbconfig* fbconfig);
|
||||||
void _glfwDestroyContextNSGL(_GLFWwindow* window);
|
void _glfwDestroyContextNSGL(_GLFWwindow* window);
|
||||||
void _glfwUpdateDisplayLinkDisplayNSGL(_GLFWwindow* window);
|
|
||||||
|
|
||||||
|
|
|
@ -23,32 +23,13 @@
|
||||||
// distribution.
|
// distribution.
|
||||||
//
|
//
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
// It is fine to use C99 in this file because it will not be built with VS
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
// Display link callback for manual swap interval implementation
|
#include <unistd.h>
|
||||||
// This is based on a similar workaround added to SDL2
|
#include <math.h>
|
||||||
//
|
|
||||||
static CVReturn displayLinkCallback(CVDisplayLinkRef displayLink,
|
|
||||||
const CVTimeStamp* now,
|
|
||||||
const CVTimeStamp* outputTime,
|
|
||||||
CVOptionFlags flagsIn,
|
|
||||||
CVOptionFlags* flagsOut,
|
|
||||||
void* userInfo)
|
|
||||||
{
|
|
||||||
_GLFWwindow* window = (_GLFWwindow *) userInfo;
|
|
||||||
|
|
||||||
const int interval = atomic_load(&window->context.nsgl.swapInterval);
|
|
||||||
if (interval > 0)
|
|
||||||
{
|
|
||||||
[window->context.nsgl.swapIntervalCond lock];
|
|
||||||
window->context.nsgl.swapIntervalsPassed++;
|
|
||||||
[window->context.nsgl.swapIntervalCond signal];
|
|
||||||
[window->context.nsgl.swapIntervalCond unlock];
|
|
||||||
}
|
|
||||||
|
|
||||||
return kCVReturnSuccess;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void makeContextCurrentNSGL(_GLFWwindow* window)
|
static void makeContextCurrentNSGL(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
|
@ -68,19 +49,28 @@ static void swapBuffersNSGL(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
|
|
||||||
const int interval = atomic_load(&window->context.nsgl.swapInterval);
|
// HACK: Simulate vsync with usleep as NSGL swap interval does not apply to
|
||||||
if (interval > 0)
|
// windows with a non-visible occlusion state
|
||||||
|
if (!([window->ns.object occlusionState] & NSWindowOcclusionStateVisible))
|
||||||
{
|
{
|
||||||
[window->context.nsgl.swapIntervalCond lock];
|
int interval = 0;
|
||||||
do
|
[window->context.nsgl.object getValues:&interval
|
||||||
|
forParameter:NSOpenGLContextParameterSwapInterval];
|
||||||
|
|
||||||
|
if (interval > 0)
|
||||||
{
|
{
|
||||||
[window->context.nsgl.swapIntervalCond wait];
|
const double framerate = 60.0;
|
||||||
} while (window->context.nsgl.swapIntervalsPassed % interval != 0);
|
const uint64_t frequency = _glfwPlatformGetTimerFrequency();
|
||||||
window->context.nsgl.swapIntervalsPassed = 0;
|
const uint64_t value = _glfwPlatformGetTimerValue();
|
||||||
[window->context.nsgl.swapIntervalCond unlock];
|
|
||||||
|
const double elapsed = value / (double) frequency;
|
||||||
|
const double period = 1.0 / framerate;
|
||||||
|
const double delay = period - fmod(elapsed, period);
|
||||||
|
|
||||||
|
usleep(floorl(delay * 1e6));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ARP appears to be unnecessary, but this is future-proof
|
|
||||||
[window->context.nsgl.object flushBuffer];
|
[window->context.nsgl.object flushBuffer];
|
||||||
|
|
||||||
} // autoreleasepool
|
} // autoreleasepool
|
||||||
|
@ -89,11 +79,14 @@ static void swapBuffersNSGL(_GLFWwindow* window)
|
||||||
static void swapIntervalNSGL(int interval)
|
static void swapIntervalNSGL(int interval)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
|
|
||||||
_GLFWwindow* window = _glfwPlatformGetTls(&_glfw.contextSlot);
|
_GLFWwindow* window = _glfwPlatformGetTls(&_glfw.contextSlot);
|
||||||
atomic_store(&window->context.nsgl.swapInterval, interval);
|
if (window)
|
||||||
[window->context.nsgl.swapIntervalCond lock];
|
{
|
||||||
window->context.nsgl.swapIntervalsPassed = 0;
|
[window->context.nsgl.object setValues:&interval
|
||||||
[window->context.nsgl.swapIntervalCond unlock];
|
forParameter:NSOpenGLContextParameterSwapInterval];
|
||||||
|
}
|
||||||
|
|
||||||
} // autoreleasepool
|
} // autoreleasepool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,23 +110,10 @@ static GLFWglproc getProcAddressNSGL(const char* procname)
|
||||||
return symbol;
|
return symbol;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Destroy the OpenGL context
|
|
||||||
//
|
|
||||||
static void destroyContextNSGL(_GLFWwindow* window)
|
static void destroyContextNSGL(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
|
|
||||||
if (window->context.nsgl.displayLink)
|
|
||||||
{
|
|
||||||
if (CVDisplayLinkIsRunning(window->context.nsgl.displayLink))
|
|
||||||
CVDisplayLinkStop(window->context.nsgl.displayLink);
|
|
||||||
|
|
||||||
CVDisplayLinkRelease(window->context.nsgl.displayLink);
|
|
||||||
}
|
|
||||||
|
|
||||||
[window->context.nsgl.swapIntervalCond release];
|
|
||||||
window->context.nsgl.swapIntervalCond = nil;
|
|
||||||
|
|
||||||
[window->context.nsgl.pixelFormat release];
|
[window->context.nsgl.pixelFormat release];
|
||||||
window->context.nsgl.pixelFormat = nil;
|
window->context.nsgl.pixelFormat = nil;
|
||||||
|
|
||||||
|
@ -339,7 +319,7 @@ GLFWbool _glfwCreateContextNSGL(_GLFWwindow* window,
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
NSOpenGLContext* share = NULL;
|
NSOpenGLContext* share = nil;
|
||||||
|
|
||||||
if (ctxconfig->share)
|
if (ctxconfig->share)
|
||||||
share = ctxconfig->share->context.nsgl.object;
|
share = ctxconfig->share->context.nsgl.object;
|
||||||
|
@ -361,17 +341,10 @@ GLFWbool _glfwCreateContextNSGL(_GLFWwindow* window,
|
||||||
forParameter:NSOpenGLContextParameterSurfaceOpacity];
|
forParameter:NSOpenGLContextParameterSurfaceOpacity];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (window->ns.retina)
|
[window->ns.view setWantsBestResolutionOpenGLSurface:window->ns.retina];
|
||||||
[window->ns.view setWantsBestResolutionOpenGLSurface:YES];
|
|
||||||
|
|
||||||
GLint interval = 0;
|
|
||||||
[window->context.nsgl.object setValues:&interval
|
|
||||||
forParameter:NSOpenGLContextParameterSwapInterval];
|
|
||||||
|
|
||||||
[window->context.nsgl.object setView:window->ns.view];
|
[window->context.nsgl.object setView:window->ns.view];
|
||||||
|
|
||||||
window->context.nsgl.swapIntervalCond = [NSCondition new];
|
|
||||||
|
|
||||||
window->context.makeCurrent = makeContextCurrentNSGL;
|
window->context.makeCurrent = makeContextCurrentNSGL;
|
||||||
window->context.swapBuffers = swapBuffersNSGL;
|
window->context.swapBuffers = swapBuffersNSGL;
|
||||||
window->context.swapInterval = swapIntervalNSGL;
|
window->context.swapInterval = swapIntervalNSGL;
|
||||||
|
@ -379,26 +352,9 @@ GLFWbool _glfwCreateContextNSGL(_GLFWwindow* window,
|
||||||
window->context.getProcAddress = getProcAddressNSGL;
|
window->context.getProcAddress = getProcAddressNSGL;
|
||||||
window->context.destroy = destroyContextNSGL;
|
window->context.destroy = destroyContextNSGL;
|
||||||
|
|
||||||
CVDisplayLinkCreateWithActiveCGDisplays(&window->context.nsgl.displayLink);
|
|
||||||
CVDisplayLinkSetOutputCallback(window->context.nsgl.displayLink,
|
|
||||||
&displayLinkCallback,
|
|
||||||
window);
|
|
||||||
CVDisplayLinkStart(window->context.nsgl.displayLink);
|
|
||||||
|
|
||||||
_glfwUpdateDisplayLinkDisplayNSGL(window);
|
|
||||||
return GLFW_TRUE;
|
return GLFW_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwUpdateDisplayLinkDisplayNSGL(_GLFWwindow* window)
|
|
||||||
{
|
|
||||||
CGDirectDisplayID displayID =
|
|
||||||
[[[window->ns.object screen] deviceDescription][@"NSScreenNumber"] unsignedIntValue];
|
|
||||||
if (!displayID)
|
|
||||||
return;
|
|
||||||
|
|
||||||
CVDisplayLinkSetCurrentCGDisplay(window->context.nsgl.displayLink, displayID);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
////// GLFW native API //////
|
////// GLFW native API //////
|
||||||
|
@ -412,7 +368,7 @@ GLFWAPI id glfwGetNSGLContext(GLFWwindow* handle)
|
||||||
if (window->context.client == GLFW_NO_API)
|
if (window->context.client == GLFW_NO_API)
|
||||||
{
|
{
|
||||||
_glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL);
|
_glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL);
|
||||||
return NULL;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
return window->context.nsgl.object;
|
return window->context.nsgl.object;
|
||||||
|
|
|
@ -24,6 +24,8 @@
|
||||||
// distribution.
|
// distribution.
|
||||||
//
|
//
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
// It is fine to use C99 in this file because it will not be built with VS
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,8 @@
|
||||||
// distribution.
|
// distribution.
|
||||||
//
|
//
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
// It is fine to use C99 in this file because it will not be built with VS
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
|
|
|
@ -24,8 +24,8 @@
|
||||||
//
|
//
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
#define _GLFW_PLATFORM_JOYSTICK_STATE int nulljs
|
#define _GLFW_PLATFORM_JOYSTICK_STATE struct { int dummyJoystick; }
|
||||||
#define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE int nulljs
|
#define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE struct { int dummyLibraryJoystick; }
|
||||||
|
|
||||||
#define _GLFW_PLATFORM_MAPPING_NAME ""
|
#define _GLFW_PLATFORM_MAPPING_NAME ""
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,8 @@
|
||||||
// distribution.
|
// distribution.
|
||||||
//
|
//
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
// It is fine to use C99 in this file because it will not be built with VS
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
|
|
|
@ -29,13 +29,13 @@
|
||||||
|
|
||||||
#define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowNull null
|
#define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowNull null
|
||||||
|
|
||||||
#define _GLFW_PLATFORM_CONTEXT_STATE
|
#define _GLFW_PLATFORM_CONTEXT_STATE struct { int dummyContext; }
|
||||||
#define _GLFW_PLATFORM_MONITOR_STATE
|
#define _GLFW_PLATFORM_MONITOR_STATE struct { int dummyMonitor; }
|
||||||
#define _GLFW_PLATFORM_CURSOR_STATE
|
#define _GLFW_PLATFORM_CURSOR_STATE struct { int dummyCursor; }
|
||||||
#define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE
|
#define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE struct { int dummyLibraryWindow; }
|
||||||
#define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE
|
#define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE struct { int dummyLibraryContext; }
|
||||||
#define _GLFW_EGL_CONTEXT_STATE
|
#define _GLFW_EGL_CONTEXT_STATE struct { int dummyEGLContext; }
|
||||||
#define _GLFW_EGL_LIBRARY_CONTEXT_STATE
|
#define _GLFW_EGL_LIBRARY_CONTEXT_STATE struct { int dummyEGLLibraryContext; }
|
||||||
|
|
||||||
#include "osmesa_context.h"
|
#include "osmesa_context.h"
|
||||||
#include "posix_time.h"
|
#include "posix_time.h"
|
||||||
|
|
|
@ -24,6 +24,8 @@
|
||||||
// distribution.
|
// distribution.
|
||||||
//
|
//
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
// It is fine to use C99 in this file because it will not be built with VS
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,8 @@
|
||||||
// distribution.
|
// distribution.
|
||||||
//
|
//
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
// Please use C89 style variable declarations in this file because VS 2010
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
|
@ -24,6 +24,8 @@
|
||||||
// distribution.
|
// distribution.
|
||||||
//
|
//
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
// It is fine to use C99 in this file because it will not be built with VS
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,8 @@
|
||||||
// distribution.
|
// distribution.
|
||||||
//
|
//
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
// It is fine to use C99 in this file because it will not be built with VS
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,8 @@
|
||||||
// distribution.
|
// distribution.
|
||||||
//
|
//
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
// Please use C89 style variable declarations in this file because VS 2010
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,8 @@
|
||||||
// distribution.
|
// distribution.
|
||||||
//
|
//
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
// Please use C89 style variable declarations in this file because VS 2010
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
|
@ -75,8 +77,8 @@ static int choosePixelFormat(_GLFWwindow* window,
|
||||||
{
|
{
|
||||||
const int attrib = WGL_NUMBER_PIXEL_FORMATS_ARB;
|
const int attrib = WGL_NUMBER_PIXEL_FORMATS_ARB;
|
||||||
|
|
||||||
if (!_glfw.wgl.GetPixelFormatAttribivARB(window->context.wgl.dc,
|
if (!wglGetPixelFormatAttribivARB(window->context.wgl.dc,
|
||||||
1, 0, 1, &attrib, &nativeCount))
|
1, 0, 1, &attrib, &nativeCount))
|
||||||
{
|
{
|
||||||
_glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
|
_glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
|
||||||
"WGL: Failed to retrieve pixel format attribute");
|
"WGL: Failed to retrieve pixel format attribute");
|
||||||
|
@ -139,10 +141,10 @@ static int choosePixelFormat(_GLFWwindow* window,
|
||||||
{
|
{
|
||||||
// Get pixel format attributes through "modern" extension
|
// Get pixel format attributes through "modern" extension
|
||||||
|
|
||||||
if (!_glfw.wgl.GetPixelFormatAttribivARB(window->context.wgl.dc,
|
if (!wglGetPixelFormatAttribivARB(window->context.wgl.dc,
|
||||||
pixelFormat, 0,
|
pixelFormat, 0,
|
||||||
attribCount,
|
attribCount,
|
||||||
attribs, values))
|
attribs, values))
|
||||||
{
|
{
|
||||||
_glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
|
_glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
|
||||||
"WGL: Failed to retrieve pixel format attributes");
|
"WGL: Failed to retrieve pixel format attributes");
|
||||||
|
@ -360,7 +362,7 @@ static void swapIntervalWGL(int interval)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_glfw.wgl.EXT_swap_control)
|
if (_glfw.wgl.EXT_swap_control)
|
||||||
_glfw.wgl.SwapIntervalEXT(interval);
|
wglSwapIntervalEXT(interval);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int extensionSupportedWGL(const char* extension)
|
static int extensionSupportedWGL(const char* extension)
|
||||||
|
@ -368,9 +370,9 @@ static int extensionSupportedWGL(const char* extension)
|
||||||
const char* extensions = NULL;
|
const char* extensions = NULL;
|
||||||
|
|
||||||
if (_glfw.wgl.GetExtensionsStringARB)
|
if (_glfw.wgl.GetExtensionsStringARB)
|
||||||
extensions = _glfw.wgl.GetExtensionsStringARB(wglGetCurrentDC());
|
extensions = wglGetExtensionsStringARB(wglGetCurrentDC());
|
||||||
else if (_glfw.wgl.GetExtensionsStringEXT)
|
else if (_glfw.wgl.GetExtensionsStringEXT)
|
||||||
extensions = _glfw.wgl.GetExtensionsStringEXT();
|
extensions = wglGetExtensionsStringEXT();
|
||||||
|
|
||||||
if (!extensions)
|
if (!extensions)
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
|
@ -387,8 +389,6 @@ static GLFWglproc getProcAddressWGL(const char* procname)
|
||||||
return (GLFWglproc) GetProcAddress(_glfw.wgl.instance, procname);
|
return (GLFWglproc) GetProcAddress(_glfw.wgl.instance, procname);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Destroy the OpenGL context
|
|
||||||
//
|
|
||||||
static void destroyContextWGL(_GLFWwindow* window)
|
static void destroyContextWGL(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
if (window->context.wgl.handle)
|
if (window->context.wgl.handle)
|
||||||
|
@ -693,8 +693,7 @@ GLFWbool _glfwCreateContextWGL(_GLFWwindow* window,
|
||||||
setAttrib(0, 0);
|
setAttrib(0, 0);
|
||||||
|
|
||||||
window->context.wgl.handle =
|
window->context.wgl.handle =
|
||||||
_glfw.wgl.CreateContextAttribsARB(window->context.wgl.dc,
|
wglCreateContextAttribsARB(window->context.wgl.dc, share, attribs);
|
||||||
share, attribs);
|
|
||||||
if (!window->context.wgl.handle)
|
if (!window->context.wgl.handle)
|
||||||
{
|
{
|
||||||
const DWORD error = GetLastError();
|
const DWORD error = GetLastError();
|
||||||
|
|
|
@ -76,12 +76,19 @@
|
||||||
#define ERROR_INVALID_PROFILE_ARB 0x2096
|
#define ERROR_INVALID_PROFILE_ARB 0x2096
|
||||||
#define ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB 0x2054
|
#define ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB 0x2054
|
||||||
|
|
||||||
|
// WGL extension pointer typedefs
|
||||||
typedef BOOL (WINAPI * PFNWGLSWAPINTERVALEXTPROC)(int);
|
typedef BOOL (WINAPI * PFNWGLSWAPINTERVALEXTPROC)(int);
|
||||||
typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVARBPROC)(HDC,int,int,UINT,const int*,int*);
|
typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVARBPROC)(HDC,int,int,UINT,const int*,int*);
|
||||||
typedef const char* (WINAPI * PFNWGLGETEXTENSIONSSTRINGEXTPROC)(void);
|
typedef const char* (WINAPI * PFNWGLGETEXTENSIONSSTRINGEXTPROC)(void);
|
||||||
typedef const char* (WINAPI * PFNWGLGETEXTENSIONSSTRINGARBPROC)(HDC);
|
typedef const char* (WINAPI * PFNWGLGETEXTENSIONSSTRINGARBPROC)(HDC);
|
||||||
typedef HGLRC (WINAPI * PFNWGLCREATECONTEXTATTRIBSARBPROC)(HDC,HGLRC,const int*);
|
typedef HGLRC (WINAPI * PFNWGLCREATECONTEXTATTRIBSARBPROC)(HDC,HGLRC,const int*);
|
||||||
|
#define wglSwapIntervalEXT _glfw.wgl.SwapIntervalEXT
|
||||||
|
#define wglGetPixelFormatAttribivARB _glfw.wgl.GetPixelFormatAttribivARB
|
||||||
|
#define wglGetExtensionsStringEXT _glfw.wgl.GetExtensionsStringEXT
|
||||||
|
#define wglGetExtensionsStringARB _glfw.wgl.GetExtensionsStringARB
|
||||||
|
#define wglCreateContextAttribsARB _glfw.wgl.CreateContextAttribsARB
|
||||||
|
|
||||||
|
// opengl32.dll function pointer typedefs
|
||||||
typedef HGLRC (WINAPI * PFN_wglCreateContext)(HDC);
|
typedef HGLRC (WINAPI * PFN_wglCreateContext)(HDC);
|
||||||
typedef BOOL (WINAPI * PFN_wglDeleteContext)(HGLRC);
|
typedef BOOL (WINAPI * PFN_wglDeleteContext)(HGLRC);
|
||||||
typedef PROC (WINAPI * PFN_wglGetProcAddress)(LPCSTR);
|
typedef PROC (WINAPI * PFN_wglGetProcAddress)(LPCSTR);
|
||||||
|
@ -89,8 +96,6 @@ typedef HDC (WINAPI * PFN_wglGetCurrentDC)(void);
|
||||||
typedef HGLRC (WINAPI * PFN_wglGetCurrentContext)(void);
|
typedef HGLRC (WINAPI * PFN_wglGetCurrentContext)(void);
|
||||||
typedef BOOL (WINAPI * PFN_wglMakeCurrent)(HDC,HGLRC);
|
typedef BOOL (WINAPI * PFN_wglMakeCurrent)(HDC,HGLRC);
|
||||||
typedef BOOL (WINAPI * PFN_wglShareLists)(HGLRC,HGLRC);
|
typedef BOOL (WINAPI * PFN_wglShareLists)(HGLRC,HGLRC);
|
||||||
|
|
||||||
// opengl32.dll function pointer typedefs
|
|
||||||
#define wglCreateContext _glfw.wgl.CreateContext
|
#define wglCreateContext _glfw.wgl.CreateContext
|
||||||
#define wglDeleteContext _glfw.wgl.DeleteContext
|
#define wglDeleteContext _glfw.wgl.DeleteContext
|
||||||
#define wglGetProcAddress _glfw.wgl.GetProcAddress
|
#define wglGetProcAddress _glfw.wgl.GetProcAddress
|
||||||
|
|
|
@ -24,6 +24,8 @@
|
||||||
// distribution.
|
// distribution.
|
||||||
//
|
//
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
// Please use C89 style variable declarations in this file because VS 2010
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
|
@ -523,7 +525,7 @@ BOOL _glfwIsWindowsVersionOrGreaterWin32(WORD major, WORD minor, WORD sp)
|
||||||
cond = VerSetConditionMask(cond, VER_MINORVERSION, VER_GREATER_EQUAL);
|
cond = VerSetConditionMask(cond, VER_MINORVERSION, VER_GREATER_EQUAL);
|
||||||
cond = VerSetConditionMask(cond, VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL);
|
cond = VerSetConditionMask(cond, VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL);
|
||||||
// HACK: Use RtlVerifyVersionInfo instead of VerifyVersionInfoW as the
|
// HACK: Use RtlVerifyVersionInfo instead of VerifyVersionInfoW as the
|
||||||
// latter lies unless the user knew to embedd a non-default manifest
|
// latter lies unless the user knew to embed a non-default manifest
|
||||||
// announcing support for Windows 10 via supportedOS GUID
|
// announcing support for Windows 10 via supportedOS GUID
|
||||||
return RtlVerifyVersionInfo(&osvi, mask, cond) == 0;
|
return RtlVerifyVersionInfo(&osvi, mask, cond) == 0;
|
||||||
}
|
}
|
||||||
|
@ -538,7 +540,7 @@ BOOL _glfwIsWindows10BuildOrGreaterWin32(WORD build)
|
||||||
cond = VerSetConditionMask(cond, VER_MINORVERSION, VER_GREATER_EQUAL);
|
cond = VerSetConditionMask(cond, VER_MINORVERSION, VER_GREATER_EQUAL);
|
||||||
cond = VerSetConditionMask(cond, VER_BUILDNUMBER, VER_GREATER_EQUAL);
|
cond = VerSetConditionMask(cond, VER_BUILDNUMBER, VER_GREATER_EQUAL);
|
||||||
// HACK: Use RtlVerifyVersionInfo instead of VerifyVersionInfoW as the
|
// HACK: Use RtlVerifyVersionInfo instead of VerifyVersionInfoW as the
|
||||||
// latter lies unless the user knew to embedd a non-default manifest
|
// latter lies unless the user knew to embed a non-default manifest
|
||||||
// announcing support for Windows 10 via supportedOS GUID
|
// announcing support for Windows 10 via supportedOS GUID
|
||||||
return RtlVerifyVersionInfo(&osvi, mask, cond) == 0;
|
return RtlVerifyVersionInfo(&osvi, mask, cond) == 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,8 @@
|
||||||
// distribution.
|
// distribution.
|
||||||
//
|
//
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
// Please use C89 style variable declarations in this file because VS 2010
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
#define _GLFW_PLATFORM_JOYSTICK_STATE _GLFWjoystickWin32 win32
|
#define _GLFW_PLATFORM_JOYSTICK_STATE _GLFWjoystickWin32 win32
|
||||||
#define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE int dummy
|
#define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE struct { int dummyLibraryJoystick; }
|
||||||
|
|
||||||
#define _GLFW_PLATFORM_MAPPING_NAME "Windows"
|
#define _GLFW_PLATFORM_MAPPING_NAME "Windows"
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,8 @@
|
||||||
// distribution.
|
// distribution.
|
||||||
//
|
//
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
// Please use C89 style variable declarations in this file because VS 2010
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
|
@ -31,6 +33,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
|
#include <wchar.h>
|
||||||
|
|
||||||
|
|
||||||
// Callback for EnumDisplayMonitors in createMonitor
|
// Callback for EnumDisplayMonitors in createMonitor
|
||||||
|
@ -475,7 +478,7 @@ void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode)
|
||||||
GLFWbool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
|
GLFWbool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
|
||||||
{
|
{
|
||||||
HDC dc;
|
HDC dc;
|
||||||
WORD values[768];
|
WORD values[3][256];
|
||||||
|
|
||||||
dc = CreateDCW(L"DISPLAY", monitor->win32.adapterName, NULL, NULL);
|
dc = CreateDCW(L"DISPLAY", monitor->win32.adapterName, NULL, NULL);
|
||||||
GetDeviceGammaRamp(dc, values);
|
GetDeviceGammaRamp(dc, values);
|
||||||
|
@ -483,9 +486,9 @@ GLFWbool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
|
||||||
|
|
||||||
_glfwAllocGammaArrays(ramp, 256);
|
_glfwAllocGammaArrays(ramp, 256);
|
||||||
|
|
||||||
memcpy(ramp->red, values + 0, 256 * sizeof(unsigned short));
|
memcpy(ramp->red, values[0], sizeof(values[0]));
|
||||||
memcpy(ramp->green, values + 256, 256 * sizeof(unsigned short));
|
memcpy(ramp->green, values[1], sizeof(values[1]));
|
||||||
memcpy(ramp->blue, values + 512, 256 * sizeof(unsigned short));
|
memcpy(ramp->blue, values[2], sizeof(values[2]));
|
||||||
|
|
||||||
return GLFW_TRUE;
|
return GLFW_TRUE;
|
||||||
}
|
}
|
||||||
|
@ -493,7 +496,7 @@ GLFWbool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
|
||||||
void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp)
|
void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp)
|
||||||
{
|
{
|
||||||
HDC dc;
|
HDC dc;
|
||||||
WORD values[768];
|
WORD values[3][256];
|
||||||
|
|
||||||
if (ramp->size != 256)
|
if (ramp->size != 256)
|
||||||
{
|
{
|
||||||
|
@ -502,9 +505,9 @@ void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(values + 0, ramp->red, 256 * sizeof(unsigned short));
|
memcpy(values[0], ramp->red, sizeof(values[0]));
|
||||||
memcpy(values + 256, ramp->green, 256 * sizeof(unsigned short));
|
memcpy(values[1], ramp->green, sizeof(values[1]));
|
||||||
memcpy(values + 512, ramp->blue, 256 * sizeof(unsigned short));
|
memcpy(values[2], ramp->blue, sizeof(values[2]));
|
||||||
|
|
||||||
dc = CreateDCW(L"DISPLAY", monitor->win32.adapterName, NULL, NULL);
|
dc = CreateDCW(L"DISPLAY", monitor->win32.adapterName, NULL, NULL);
|
||||||
SetDeviceGammaRamp(dc, values);
|
SetDeviceGammaRamp(dc, values);
|
||||||
|
|
|
@ -212,7 +212,7 @@ typedef enum
|
||||||
|
|
||||||
// HACK: Define macros that some dinput.h variants don't
|
// HACK: Define macros that some dinput.h variants don't
|
||||||
#ifndef DIDFT_OPTIONAL
|
#ifndef DIDFT_OPTIONAL
|
||||||
#define DIDFT_OPTIONAL 0x80000000
|
#define DIDFT_OPTIONAL 0x80000000
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// winmm.dll function pointer typedefs
|
// winmm.dll function pointer typedefs
|
||||||
|
|
|
@ -24,6 +24,8 @@
|
||||||
// distribution.
|
// distribution.
|
||||||
//
|
//
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
// Please use C89 style variable declarations in this file because VS 2010
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,8 @@
|
||||||
// distribution.
|
// distribution.
|
||||||
//
|
//
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
// Please use C89 style variable declarations in this file because VS 2010
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,8 @@
|
||||||
// distribution.
|
// distribution.
|
||||||
//
|
//
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
// Please use C89 style variable declarations in this file because VS 2010
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
|
@ -409,7 +411,7 @@ static void updateFramebufferTransparency(const _GLFWwindow* window)
|
||||||
// issue. When set to black, something is making the hit test
|
// issue. When set to black, something is making the hit test
|
||||||
// not resize with the window frame.
|
// not resize with the window frame.
|
||||||
SetLayeredWindowAttributes(window->win32.handle,
|
SetLayeredWindowAttributes(window->win32.handle,
|
||||||
RGB(0, 193, 48), 255, LWA_COLORKEY);
|
RGB(255, 0, 255), 255, LWA_COLORKEY);
|
||||||
}
|
}
|
||||||
|
|
||||||
DeleteObject(region);
|
DeleteObject(region);
|
||||||
|
@ -479,7 +481,7 @@ static int translateKey(WPARAM wParam, LPARAM lParam)
|
||||||
DWORD time;
|
DWORD time;
|
||||||
|
|
||||||
// Right side keys have the extended key bit set
|
// Right side keys have the extended key bit set
|
||||||
if (lParam & 0x01000000)
|
if (HIWORD(lParam) & KF_EXTENDED)
|
||||||
return GLFW_KEY_RIGHT_CONTROL;
|
return GLFW_KEY_RIGHT_CONTROL;
|
||||||
|
|
||||||
// HACK: Alt Gr sends Left Ctrl and then Right Alt in close sequence
|
// HACK: Alt Gr sends Left Ctrl and then Right Alt in close sequence
|
||||||
|
@ -495,7 +497,7 @@ static int translateKey(WPARAM wParam, LPARAM lParam)
|
||||||
next.message == WM_SYSKEYUP)
|
next.message == WM_SYSKEYUP)
|
||||||
{
|
{
|
||||||
if (next.wParam == VK_MENU &&
|
if (next.wParam == VK_MENU &&
|
||||||
(next.lParam & 0x01000000) &&
|
(HIWORD(next.lParam) & KF_EXTENDED) &&
|
||||||
next.time == time)
|
next.time == time)
|
||||||
{
|
{
|
||||||
// Next message is Right Alt down so discard this
|
// Next message is Right Alt down so discard this
|
||||||
|
@ -629,12 +631,8 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
|
||||||
// clicking a caption button
|
// clicking a caption button
|
||||||
if (HIWORD(lParam) == WM_LBUTTONDOWN)
|
if (HIWORD(lParam) == WM_LBUTTONDOWN)
|
||||||
{
|
{
|
||||||
if (LOWORD(lParam) == HTCLOSE ||
|
if (LOWORD(lParam) != HTCLIENT)
|
||||||
LOWORD(lParam) == HTMINBUTTON ||
|
|
||||||
LOWORD(lParam) == HTMAXBUTTON)
|
|
||||||
{
|
|
||||||
window->win32.frameAction = GLFW_TRUE;
|
window->win32.frameAction = GLFW_TRUE;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -742,8 +740,8 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
|
||||||
case WM_SYSKEYUP:
|
case WM_SYSKEYUP:
|
||||||
{
|
{
|
||||||
const int key = translateKey(wParam, lParam);
|
const int key = translateKey(wParam, lParam);
|
||||||
const int scancode = (lParam >> 16) & 0x1ff;
|
const int scancode = (HIWORD(lParam) & 0x1ff);
|
||||||
const int action = ((lParam >> 31) & 1) ? GLFW_RELEASE : GLFW_PRESS;
|
const int action = (HIWORD(lParam) & KF_UP) ? GLFW_RELEASE : GLFW_PRESS;
|
||||||
const int mods = getKeyMods();
|
const int mods = getKeyMods();
|
||||||
|
|
||||||
if (key == _GLFW_KEY_INVALID)
|
if (key == _GLFW_KEY_INVALID)
|
||||||
|
@ -830,7 +828,19 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
|
||||||
const int x = GET_X_LPARAM(lParam);
|
const int x = GET_X_LPARAM(lParam);
|
||||||
const int y = GET_Y_LPARAM(lParam);
|
const int y = GET_Y_LPARAM(lParam);
|
||||||
|
|
||||||
// Disabled cursor motion input is provided by WM_INPUT
|
if (!window->win32.cursorTracked)
|
||||||
|
{
|
||||||
|
TRACKMOUSEEVENT tme;
|
||||||
|
ZeroMemory(&tme, sizeof(tme));
|
||||||
|
tme.cbSize = sizeof(tme);
|
||||||
|
tme.dwFlags = TME_LEAVE;
|
||||||
|
tme.hwndTrack = window->win32.handle;
|
||||||
|
TrackMouseEvent(&tme);
|
||||||
|
|
||||||
|
window->win32.cursorTracked = GLFW_TRUE;
|
||||||
|
_glfwInputCursorEnter(window, GLFW_TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
if (window->cursorMode == GLFW_CURSOR_DISABLED)
|
if (window->cursorMode == GLFW_CURSOR_DISABLED)
|
||||||
{
|
{
|
||||||
const int dx = x - window->win32.lastCursorPosX;
|
const int dx = x - window->win32.lastCursorPosX;
|
||||||
|
@ -851,19 +861,6 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
|
||||||
window->win32.lastCursorPosX = x;
|
window->win32.lastCursorPosX = x;
|
||||||
window->win32.lastCursorPosY = y;
|
window->win32.lastCursorPosY = y;
|
||||||
|
|
||||||
if (!window->win32.cursorTracked)
|
|
||||||
{
|
|
||||||
TRACKMOUSEEVENT tme;
|
|
||||||
ZeroMemory(&tme, sizeof(tme));
|
|
||||||
tme.cbSize = sizeof(tme);
|
|
||||||
tme.dwFlags = TME_LEAVE;
|
|
||||||
tme.hwndTrack = window->win32.handle;
|
|
||||||
TrackMouseEvent(&tme);
|
|
||||||
|
|
||||||
window->win32.cursorTracked = GLFW_TRUE;
|
|
||||||
_glfwInputCursorEnter(window, GLFW_TRUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -942,6 +939,9 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
|
||||||
case WM_ENTERSIZEMOVE:
|
case WM_ENTERSIZEMOVE:
|
||||||
case WM_ENTERMENULOOP:
|
case WM_ENTERMENULOOP:
|
||||||
{
|
{
|
||||||
|
if (window->win32.frameAction)
|
||||||
|
break;
|
||||||
|
|
||||||
// HACK: Enable the cursor while the user is moving or
|
// HACK: Enable the cursor while the user is moving or
|
||||||
// resizing the window or using the window menu
|
// resizing the window or using the window menu
|
||||||
if (window->cursorMode == GLFW_CURSOR_DISABLED)
|
if (window->cursorMode == GLFW_CURSOR_DISABLED)
|
||||||
|
@ -953,6 +953,9 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
|
||||||
case WM_EXITSIZEMOVE:
|
case WM_EXITSIZEMOVE:
|
||||||
case WM_EXITMENULOOP:
|
case WM_EXITMENULOOP:
|
||||||
{
|
{
|
||||||
|
if (window->win32.frameAction)
|
||||||
|
break;
|
||||||
|
|
||||||
// HACK: Disable the cursor once the user is done moving or
|
// HACK: Disable the cursor once the user is done moving or
|
||||||
// resizing the window or using the menu
|
// resizing the window or using the menu
|
||||||
if (window->cursorMode == GLFW_CURSOR_DISABLED)
|
if (window->cursorMode == GLFW_CURSOR_DISABLED)
|
||||||
|
@ -1225,6 +1228,7 @@ static int createNativeWindow(_GLFWwindow* window,
|
||||||
xpos = CW_USEDEFAULT;
|
xpos = CW_USEDEFAULT;
|
||||||
ypos = CW_USEDEFAULT;
|
ypos = CW_USEDEFAULT;
|
||||||
|
|
||||||
|
window->win32.maximized = wndconfig->maximized;
|
||||||
if (wndconfig->maximized)
|
if (wndconfig->maximized)
|
||||||
style |= WS_MAXIMIZE;
|
style |= WS_MAXIMIZE;
|
||||||
|
|
||||||
|
@ -1272,12 +1276,13 @@ static int createNativeWindow(_GLFWwindow* window,
|
||||||
|
|
||||||
window->win32.scaleToMonitor = wndconfig->scaleToMonitor;
|
window->win32.scaleToMonitor = wndconfig->scaleToMonitor;
|
||||||
|
|
||||||
// Adjust window size to account for DPI scaling of the window frame and
|
// Adjust window rect to account for DPI scaling of the window frame and
|
||||||
// optionally DPI scaling of the content area
|
// (if enabled) DPI scaling of the content area
|
||||||
// This cannot be done until we know what monitor it was placed on
|
// This cannot be done until we know what monitor the window was placed on
|
||||||
if (!window->monitor)
|
if (!window->monitor)
|
||||||
{
|
{
|
||||||
RECT rect = { 0, 0, wndconfig->width, wndconfig->height };
|
RECT rect = { 0, 0, wndconfig->width, wndconfig->height };
|
||||||
|
WINDOWPLACEMENT wp = { sizeof(wp) };
|
||||||
|
|
||||||
if (wndconfig->scaleToMonitor)
|
if (wndconfig->scaleToMonitor)
|
||||||
{
|
{
|
||||||
|
@ -1298,10 +1303,11 @@ static int createNativeWindow(_GLFWwindow* window,
|
||||||
else
|
else
|
||||||
AdjustWindowRectEx(&rect, style, FALSE, exStyle);
|
AdjustWindowRectEx(&rect, style, FALSE, exStyle);
|
||||||
|
|
||||||
SetWindowPos(window->win32.handle, NULL,
|
// Only update the restored window rect as the window may be maximized
|
||||||
rect.left, rect.top,
|
GetWindowPlacement(window->win32.handle, &wp);
|
||||||
rect.right - rect.left, rect.bottom - rect.top,
|
wp.rcNormalPosition = rect;
|
||||||
SWP_NOACTIVATE | SWP_NOZORDER);
|
wp.showCmd = SW_HIDE;
|
||||||
|
SetWindowPlacement(window->win32.handle, &wp);
|
||||||
}
|
}
|
||||||
|
|
||||||
DragAcceptFiles(window->win32.handle, TRUE);
|
DragAcceptFiles(window->win32.handle, TRUE);
|
||||||
|
@ -1722,7 +1728,7 @@ void _glfwPlatformSetWindowMonitor(_GLFWwindow* window,
|
||||||
|
|
||||||
_glfwInputWindowMonitor(window, monitor);
|
_glfwInputWindowMonitor(window, monitor);
|
||||||
|
|
||||||
if (monitor)
|
if (window->monitor)
|
||||||
{
|
{
|
||||||
MONITORINFO mi = { sizeof(mi) };
|
MONITORINFO mi = { sizeof(mi) };
|
||||||
UINT flags = SWP_SHOWWINDOW | SWP_NOACTIVATE | SWP_NOCOPYBITS;
|
UINT flags = SWP_SHOWWINDOW | SWP_NOACTIVATE | SWP_NOCOPYBITS;
|
||||||
|
@ -1928,8 +1934,8 @@ void _glfwPlatformPollEvents(void)
|
||||||
window = GetPropW(handle, L"GLFW");
|
window = GetPropW(handle, L"GLFW");
|
||||||
if (window)
|
if (window)
|
||||||
{
|
{
|
||||||
const GLFWbool lshift = (GetAsyncKeyState(VK_LSHIFT) >> 15) & 1;
|
const GLFWbool lshift = (GetAsyncKeyState(VK_LSHIFT) & 0x8000) != 0;
|
||||||
const GLFWbool rshift = (GetAsyncKeyState(VK_RSHIFT) >> 15) & 1;
|
const GLFWbool rshift = (GetAsyncKeyState(VK_RSHIFT) & 0x8000) != 0;
|
||||||
|
|
||||||
if (!lshift && window->keys[GLFW_KEY_LEFT_SHIFT] == GLFW_PRESS)
|
if (!lshift && window->keys[GLFW_KEY_LEFT_SHIFT] == GLFW_PRESS)
|
||||||
{
|
{
|
||||||
|
|
|
@ -25,6 +25,8 @@
|
||||||
// distribution.
|
// distribution.
|
||||||
//
|
//
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
// Please use C89 style variable declarations in this file because VS 2010
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,8 @@
|
||||||
// distribution.
|
// distribution.
|
||||||
//
|
//
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
// It is fine to use C99 in this file because it will not be built with VS
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
|
@ -123,6 +125,7 @@ static void pointerHandleLeave(void* data,
|
||||||
_glfw.wl.serial = serial;
|
_glfw.wl.serial = serial;
|
||||||
_glfw.wl.pointerFocus = NULL;
|
_glfw.wl.pointerFocus = NULL;
|
||||||
_glfwInputCursorEnter(window, GLFW_FALSE);
|
_glfwInputCursorEnter(window, GLFW_FALSE);
|
||||||
|
_glfw.wl.cursorPreviousName = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setCursor(_GLFWwindow* window, const char* name)
|
static void setCursor(_GLFWwindow* window, const char* name)
|
||||||
|
@ -167,6 +170,7 @@ static void setCursor(_GLFWwindow* window, const char* name)
|
||||||
wl_surface_damage(surface, 0, 0,
|
wl_surface_damage(surface, 0, 0,
|
||||||
image->width, image->height);
|
image->width, image->height);
|
||||||
wl_surface_commit(surface);
|
wl_surface_commit(surface);
|
||||||
|
_glfw.wl.cursorPreviousName = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void pointerHandleMotion(void* data,
|
static void pointerHandleMotion(void* data,
|
||||||
|
@ -176,48 +180,47 @@ static void pointerHandleMotion(void* data,
|
||||||
wl_fixed_t sy)
|
wl_fixed_t sy)
|
||||||
{
|
{
|
||||||
_GLFWwindow* window = _glfw.wl.pointerFocus;
|
_GLFWwindow* window = _glfw.wl.pointerFocus;
|
||||||
const char* cursorName;
|
const char* cursorName = NULL;
|
||||||
|
double x, y;
|
||||||
|
|
||||||
if (!window)
|
if (!window)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (window->cursorMode == GLFW_CURSOR_DISABLED)
|
if (window->cursorMode == GLFW_CURSOR_DISABLED)
|
||||||
return;
|
return;
|
||||||
else
|
x = wl_fixed_to_double(sx);
|
||||||
{
|
y = wl_fixed_to_double(sy);
|
||||||
window->wl.cursorPosX = wl_fixed_to_double(sx);
|
|
||||||
window->wl.cursorPosY = wl_fixed_to_double(sy);
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (window->wl.decorations.focus)
|
switch (window->wl.decorations.focus)
|
||||||
{
|
{
|
||||||
case mainWindow:
|
case mainWindow:
|
||||||
_glfwInputCursorPos(window,
|
window->wl.cursorPosX = x;
|
||||||
wl_fixed_to_double(sx),
|
window->wl.cursorPosY = y;
|
||||||
wl_fixed_to_double(sy));
|
_glfwInputCursorPos(window, x, y);
|
||||||
|
_glfw.wl.cursorPreviousName = NULL;
|
||||||
return;
|
return;
|
||||||
case topDecoration:
|
case topDecoration:
|
||||||
if (window->wl.cursorPosY < _GLFW_DECORATION_WIDTH)
|
if (y < _GLFW_DECORATION_WIDTH)
|
||||||
cursorName = "n-resize";
|
cursorName = "n-resize";
|
||||||
else
|
else
|
||||||
cursorName = "left_ptr";
|
cursorName = "left_ptr";
|
||||||
break;
|
break;
|
||||||
case leftDecoration:
|
case leftDecoration:
|
||||||
if (window->wl.cursorPosY < _GLFW_DECORATION_WIDTH)
|
if (y < _GLFW_DECORATION_WIDTH)
|
||||||
cursorName = "nw-resize";
|
cursorName = "nw-resize";
|
||||||
else
|
else
|
||||||
cursorName = "w-resize";
|
cursorName = "w-resize";
|
||||||
break;
|
break;
|
||||||
case rightDecoration:
|
case rightDecoration:
|
||||||
if (window->wl.cursorPosY < _GLFW_DECORATION_WIDTH)
|
if (y < _GLFW_DECORATION_WIDTH)
|
||||||
cursorName = "ne-resize";
|
cursorName = "ne-resize";
|
||||||
else
|
else
|
||||||
cursorName = "e-resize";
|
cursorName = "e-resize";
|
||||||
break;
|
break;
|
||||||
case bottomDecoration:
|
case bottomDecoration:
|
||||||
if (window->wl.cursorPosX < _GLFW_DECORATION_WIDTH)
|
if (x < _GLFW_DECORATION_WIDTH)
|
||||||
cursorName = "sw-resize";
|
cursorName = "sw-resize";
|
||||||
else if (window->wl.cursorPosX > window->wl.width + _GLFW_DECORATION_WIDTH)
|
else if (x > window->wl.width + _GLFW_DECORATION_WIDTH)
|
||||||
cursorName = "se-resize";
|
cursorName = "se-resize";
|
||||||
else
|
else
|
||||||
cursorName = "s-resize";
|
cursorName = "s-resize";
|
||||||
|
@ -225,7 +228,8 @@ static void pointerHandleMotion(void* data,
|
||||||
default:
|
default:
|
||||||
assert(0);
|
assert(0);
|
||||||
}
|
}
|
||||||
setCursor(window, cursorName);
|
if (_glfw.wl.cursorPreviousName != cursorName)
|
||||||
|
setCursor(window, cursorName);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void pointerHandleButton(void* data,
|
static void pointerHandleButton(void* data,
|
||||||
|
|
|
@ -23,6 +23,8 @@
|
||||||
// distribution.
|
// distribution.
|
||||||
//
|
//
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
// It is fine to use C99 in this file because it will not be built with VS
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
|
@ -198,7 +200,7 @@ void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode)
|
||||||
GLFWbool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
|
GLFWbool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
|
||||||
{
|
{
|
||||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||||
"Wayland: Gamma ramp access it not available");
|
"Wayland: Gamma ramp access is not available");
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -75,8 +75,8 @@ typedef VkBool32 (APIENTRY *PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR
|
||||||
#define _GLFW_PLATFORM_MONITOR_STATE _GLFWmonitorWayland wl
|
#define _GLFW_PLATFORM_MONITOR_STATE _GLFWmonitorWayland wl
|
||||||
#define _GLFW_PLATFORM_CURSOR_STATE _GLFWcursorWayland wl
|
#define _GLFW_PLATFORM_CURSOR_STATE _GLFWcursorWayland wl
|
||||||
|
|
||||||
#define _GLFW_PLATFORM_CONTEXT_STATE
|
#define _GLFW_PLATFORM_CONTEXT_STATE struct { int dummyContext; }
|
||||||
#define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE
|
#define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE struct { int dummyLibraryContext; }
|
||||||
|
|
||||||
struct wl_cursor_image {
|
struct wl_cursor_image {
|
||||||
uint32_t width;
|
uint32_t width;
|
||||||
|
@ -249,6 +249,7 @@ typedef struct _GLFWlibraryWayland
|
||||||
struct wl_cursor_theme* cursorTheme;
|
struct wl_cursor_theme* cursorTheme;
|
||||||
struct wl_cursor_theme* cursorThemeHiDPI;
|
struct wl_cursor_theme* cursorThemeHiDPI;
|
||||||
struct wl_surface* cursorSurface;
|
struct wl_surface* cursorSurface;
|
||||||
|
const char* cursorPreviousName;
|
||||||
int cursorTimerfd;
|
int cursorTimerfd;
|
||||||
uint32_t serial;
|
uint32_t serial;
|
||||||
|
|
||||||
|
@ -332,7 +333,7 @@ typedef struct _GLFWlibraryWayland
|
||||||
typedef struct _GLFWmonitorWayland
|
typedef struct _GLFWmonitorWayland
|
||||||
{
|
{
|
||||||
struct wl_output* output;
|
struct wl_output* output;
|
||||||
int name;
|
uint32_t name;
|
||||||
int currentMode;
|
int currentMode;
|
||||||
|
|
||||||
int x;
|
int x;
|
||||||
|
|
|
@ -23,6 +23,8 @@
|
||||||
// distribution.
|
// distribution.
|
||||||
//
|
//
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
// It is fine to use C99 in this file because it will not be built with VS
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
#define _GNU_SOURCE
|
#define _GNU_SOURCE
|
||||||
|
|
||||||
|
@ -132,7 +134,7 @@ static int createTmpfileCloexec(char* tmpname)
|
||||||
* SCM_RIGHTS methods.
|
* SCM_RIGHTS methods.
|
||||||
*
|
*
|
||||||
* posix_fallocate() is used to guarantee that disk space is available
|
* posix_fallocate() is used to guarantee that disk space is available
|
||||||
* for the file at the given size. If disk space is insufficent, errno
|
* for the file at the given size. If disk space is insufficient, errno
|
||||||
* is set to ENOSPC. If posix_fallocate() is not supported, program may
|
* is set to ENOSPC. If posix_fallocate() is not supported, program may
|
||||||
* receive SIGBUS on accessing mmap()'ed file contents instead.
|
* receive SIGBUS on accessing mmap()'ed file contents instead.
|
||||||
*/
|
*/
|
||||||
|
@ -902,7 +904,7 @@ static char *translateCursorShape(int shape)
|
||||||
case GLFW_CROSSHAIR_CURSOR:
|
case GLFW_CROSSHAIR_CURSOR:
|
||||||
return "crosshair";
|
return "crosshair";
|
||||||
case GLFW_HAND_CURSOR:
|
case GLFW_HAND_CURSOR:
|
||||||
return "grabbing";
|
return "hand2";
|
||||||
case GLFW_HRESIZE_CURSOR:
|
case GLFW_HRESIZE_CURSOR:
|
||||||
return "sb_h_double_arrow";
|
return "sb_h_double_arrow";
|
||||||
case GLFW_VRESIZE_CURSOR:
|
case GLFW_VRESIZE_CURSOR:
|
||||||
|
|
|
@ -24,6 +24,8 @@
|
||||||
// distribution.
|
// distribution.
|
||||||
//
|
//
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
// It is fine to use C99 in this file because it will not be built with VS
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
|
@ -52,7 +54,7 @@ static int translateKeyCode(int scancode)
|
||||||
// Note: This way we always force "NumLock = ON", which is intentional
|
// Note: This way we always force "NumLock = ON", which is intentional
|
||||||
// since the returned key code should correspond to a physical
|
// since the returned key code should correspond to a physical
|
||||||
// location.
|
// location.
|
||||||
keySym = XkbKeycodeToKeysym(_glfw.x11.display, scancode, 0, 1);
|
keySym = XkbKeycodeToKeysym(_glfw.x11.display, scancode, _glfw.x11.xkb.group, 1);
|
||||||
switch (keySym)
|
switch (keySym)
|
||||||
{
|
{
|
||||||
case XK_KP_0: return GLFW_KEY_KP_0;
|
case XK_KP_0: return GLFW_KEY_KP_0;
|
||||||
|
@ -74,7 +76,7 @@ static int translateKeyCode(int scancode)
|
||||||
|
|
||||||
// Now try primary keysym for function keys (non-printable keys)
|
// Now try primary keysym for function keys (non-printable keys)
|
||||||
// These should not depend on the current keyboard layout
|
// These should not depend on the current keyboard layout
|
||||||
keySym = XkbKeycodeToKeysym(_glfw.x11.display, scancode, 0, 0);
|
keySym = XkbKeycodeToKeysym(_glfw.x11.display, scancode, _glfw.x11.xkb.group, 0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -329,14 +331,13 @@ static void createKeyTables(void)
|
||||||
//
|
//
|
||||||
static GLFWbool hasUsableInputMethodStyle(void)
|
static GLFWbool hasUsableInputMethodStyle(void)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
|
||||||
GLFWbool found = GLFW_FALSE;
|
GLFWbool found = GLFW_FALSE;
|
||||||
XIMStyles* styles = NULL;
|
XIMStyles* styles = NULL;
|
||||||
|
|
||||||
if (XGetIMValues(_glfw.x11.im, XNQueryInputStyle, &styles, NULL) != NULL)
|
if (XGetIMValues(_glfw.x11.im, XNQueryInputStyle, &styles, NULL) != NULL)
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
|
|
||||||
for (i = 0; i < styles->count_styles; i++)
|
for (unsigned int i = 0; i < styles->count_styles; i++)
|
||||||
{
|
{
|
||||||
if (styles->supported_styles[i] == (XIMPreeditNothing | XIMStatusNothing))
|
if (styles->supported_styles[i] == (XIMPreeditNothing | XIMStatusNothing))
|
||||||
{
|
{
|
||||||
|
@ -355,10 +356,9 @@ static Atom getSupportedAtom(Atom* supportedAtoms,
|
||||||
unsigned long atomCount,
|
unsigned long atomCount,
|
||||||
const char* atomName)
|
const char* atomName)
|
||||||
{
|
{
|
||||||
unsigned long i;
|
|
||||||
const Atom atom = XInternAtom(_glfw.x11.display, atomName, False);
|
const Atom atom = XInternAtom(_glfw.x11.display, atomName, False);
|
||||||
|
|
||||||
for (i = 0; i < atomCount; i++)
|
for (unsigned int i = 0; i < atomCount; i++)
|
||||||
{
|
{
|
||||||
if (supportedAtoms[i] == atom)
|
if (supportedAtoms[i] == atom)
|
||||||
return atom;
|
return atom;
|
||||||
|
@ -371,18 +371,11 @@ static Atom getSupportedAtom(Atom* supportedAtoms,
|
||||||
//
|
//
|
||||||
static void detectEWMH(void)
|
static void detectEWMH(void)
|
||||||
{
|
{
|
||||||
|
// First we read the _NET_SUPPORTING_WM_CHECK property on the root window
|
||||||
|
|
||||||
Window* windowFromRoot = NULL;
|
Window* windowFromRoot = NULL;
|
||||||
Window* windowFromChild = NULL;
|
|
||||||
|
|
||||||
// First we need a couple of atoms
|
|
||||||
const Atom supportingWmCheck =
|
|
||||||
XInternAtom(_glfw.x11.display, "_NET_SUPPORTING_WM_CHECK", False);
|
|
||||||
const Atom wmSupported =
|
|
||||||
XInternAtom(_glfw.x11.display, "_NET_SUPPORTED", False);
|
|
||||||
|
|
||||||
// Then we look for the _NET_SUPPORTING_WM_CHECK property of the root window
|
|
||||||
if (!_glfwGetWindowPropertyX11(_glfw.x11.root,
|
if (!_glfwGetWindowPropertyX11(_glfw.x11.root,
|
||||||
supportingWmCheck,
|
_glfw.x11.NET_SUPPORTING_WM_CHECK,
|
||||||
XA_WINDOW,
|
XA_WINDOW,
|
||||||
(unsigned char**) &windowFromRoot))
|
(unsigned char**) &windowFromRoot))
|
||||||
{
|
{
|
||||||
|
@ -391,10 +384,12 @@ static void detectEWMH(void)
|
||||||
|
|
||||||
_glfwGrabErrorHandlerX11();
|
_glfwGrabErrorHandlerX11();
|
||||||
|
|
||||||
// It should be the ID of a child window (of the root)
|
// If it exists, it should be the XID of a top-level window
|
||||||
// Then we look for the same property on the child window
|
// Then we look for the same property on that window
|
||||||
|
|
||||||
|
Window* windowFromChild = NULL;
|
||||||
if (!_glfwGetWindowPropertyX11(*windowFromRoot,
|
if (!_glfwGetWindowPropertyX11(*windowFromRoot,
|
||||||
supportingWmCheck,
|
_glfw.x11.NET_SUPPORTING_WM_CHECK,
|
||||||
XA_WINDOW,
|
XA_WINDOW,
|
||||||
(unsigned char**) &windowFromChild))
|
(unsigned char**) &windowFromChild))
|
||||||
{
|
{
|
||||||
|
@ -404,7 +399,8 @@ static void detectEWMH(void)
|
||||||
|
|
||||||
_glfwReleaseErrorHandlerX11();
|
_glfwReleaseErrorHandlerX11();
|
||||||
|
|
||||||
// It should be the ID of that same child window
|
// If the property exists, it should contain the XID of the window
|
||||||
|
|
||||||
if (*windowFromRoot != *windowFromChild)
|
if (*windowFromRoot != *windowFromChild)
|
||||||
{
|
{
|
||||||
XFree(windowFromRoot);
|
XFree(windowFromRoot);
|
||||||
|
@ -415,19 +411,20 @@ static void detectEWMH(void)
|
||||||
XFree(windowFromRoot);
|
XFree(windowFromRoot);
|
||||||
XFree(windowFromChild);
|
XFree(windowFromChild);
|
||||||
|
|
||||||
// We are now fairly sure that an EWMH-compliant window manager is running
|
// We are now fairly sure that an EWMH-compliant WM is currently running
|
||||||
|
// We can now start querying the WM about what features it supports by
|
||||||
|
// looking in the _NET_SUPPORTED property on the root window
|
||||||
|
// It should contain a list of supported EWMH protocol and state atoms
|
||||||
|
|
||||||
Atom* supportedAtoms;
|
Atom* supportedAtoms = NULL;
|
||||||
unsigned long atomCount;
|
const unsigned long atomCount =
|
||||||
|
_glfwGetWindowPropertyX11(_glfw.x11.root,
|
||||||
// Now we need to check the _NET_SUPPORTED property of the root window
|
_glfw.x11.NET_SUPPORTED,
|
||||||
// It should be a list of supported WM protocol and state atoms
|
XA_ATOM,
|
||||||
atomCount = _glfwGetWindowPropertyX11(_glfw.x11.root,
|
(unsigned char**) &supportedAtoms);
|
||||||
wmSupported,
|
|
||||||
XA_ATOM,
|
|
||||||
(unsigned char**) &supportedAtoms);
|
|
||||||
|
|
||||||
// See which of the atoms we support that are supported by the WM
|
// See which of the atoms we support that are supported by the WM
|
||||||
|
|
||||||
_glfw.x11.NET_WM_STATE =
|
_glfw.x11.NET_WM_STATE =
|
||||||
getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_STATE");
|
getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_STATE");
|
||||||
_glfw.x11.NET_WM_STATE_ABOVE =
|
_glfw.x11.NET_WM_STATE_ABOVE =
|
||||||
|
@ -662,6 +659,14 @@ static GLFWbool initExtensions(void)
|
||||||
if (supported)
|
if (supported)
|
||||||
_glfw.x11.xkb.detectable = GLFW_TRUE;
|
_glfw.x11.xkb.detectable = GLFW_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_glfw.x11.xkb.group = 0;
|
||||||
|
XkbStateRec state;
|
||||||
|
if (XkbGetState(_glfw.x11.display, XkbUseCoreKbd, &state) == Success)
|
||||||
|
{
|
||||||
|
XkbSelectEventDetails(_glfw.x11.display, XkbUseCoreKbd, XkbStateNotify, XkbAllStateComponentsMask, XkbGroupStateMask);
|
||||||
|
_glfw.x11.xkb.group = (unsigned int)state.group;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(__CYGWIN__)
|
#if defined(__CYGWIN__)
|
||||||
|
@ -707,9 +712,6 @@ static GLFWbool initExtensions(void)
|
||||||
// the keyboard mapping.
|
// the keyboard mapping.
|
||||||
createKeyTables();
|
createKeyTables();
|
||||||
|
|
||||||
// Detect whether an EWMH-conformant window manager is running
|
|
||||||
detectEWMH();
|
|
||||||
|
|
||||||
// String format atoms
|
// String format atoms
|
||||||
_glfw.x11.NULL_ = XInternAtom(_glfw.x11.display, "NULL", False);
|
_glfw.x11.NULL_ = XInternAtom(_glfw.x11.display, "NULL", False);
|
||||||
_glfw.x11.UTF8_STRING = XInternAtom(_glfw.x11.display, "UTF8_STRING", False);
|
_glfw.x11.UTF8_STRING = XInternAtom(_glfw.x11.display, "UTF8_STRING", False);
|
||||||
|
@ -753,6 +755,10 @@ static GLFWbool initExtensions(void)
|
||||||
XInternAtom(_glfw.x11.display, "WM_STATE", False);
|
XInternAtom(_glfw.x11.display, "WM_STATE", False);
|
||||||
_glfw.x11.WM_DELETE_WINDOW =
|
_glfw.x11.WM_DELETE_WINDOW =
|
||||||
XInternAtom(_glfw.x11.display, "WM_DELETE_WINDOW", False);
|
XInternAtom(_glfw.x11.display, "WM_DELETE_WINDOW", False);
|
||||||
|
_glfw.x11.NET_SUPPORTED =
|
||||||
|
XInternAtom(_glfw.x11.display, "_NET_SUPPORTED", False);
|
||||||
|
_glfw.x11.NET_SUPPORTING_WM_CHECK =
|
||||||
|
XInternAtom(_glfw.x11.display, "_NET_SUPPORTING_WM_CHECK", False);
|
||||||
_glfw.x11.NET_WM_ICON =
|
_glfw.x11.NET_WM_ICON =
|
||||||
XInternAtom(_glfw.x11.display, "_NET_WM_ICON", False);
|
XInternAtom(_glfw.x11.display, "_NET_WM_ICON", False);
|
||||||
_glfw.x11.NET_WM_PING =
|
_glfw.x11.NET_WM_PING =
|
||||||
|
@ -777,6 +783,9 @@ static GLFWbool initExtensions(void)
|
||||||
_glfw.x11.NET_WM_CM_Sx = XInternAtom(_glfw.x11.display, name, False);
|
_glfw.x11.NET_WM_CM_Sx = XInternAtom(_glfw.x11.display, name, False);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Detect whether an EWMH-conformant window manager is running
|
||||||
|
detectEWMH();
|
||||||
|
|
||||||
return GLFW_TRUE;
|
return GLFW_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -784,13 +793,10 @@ static GLFWbool initExtensions(void)
|
||||||
//
|
//
|
||||||
static void getSystemContentScale(float* xscale, float* yscale)
|
static void getSystemContentScale(float* xscale, float* yscale)
|
||||||
{
|
{
|
||||||
// NOTE: Fall back to the display-wide DPI instead of RandR monitor DPI if
|
// Start by assuming the default X11 DPI
|
||||||
// Xft.dpi retrieval below fails as we don't currently have an exact
|
// NOTE: Some desktop environments (KDE) may remove the Xft.dpi field when it
|
||||||
// policy for which monitor a window is considered to "be on"
|
// would be set to 96, so assume that is the case if we cannot find it
|
||||||
float xdpi = DisplayWidth(_glfw.x11.display, _glfw.x11.screen) *
|
float xdpi = 96.f, ydpi = 96.f;
|
||||||
25.4f / DisplayWidthMM(_glfw.x11.display, _glfw.x11.screen);
|
|
||||||
float ydpi = DisplayHeight(_glfw.x11.display, _glfw.x11.screen) *
|
|
||||||
25.4f / DisplayHeightMM(_glfw.x11.display, _glfw.x11.screen);
|
|
||||||
|
|
||||||
// NOTE: Basing the scale on Xft.dpi where available should provide the most
|
// NOTE: Basing the scale on Xft.dpi where available should provide the most
|
||||||
// consistent user experience (matches Qt, Gtk, etc), although not
|
// consistent user experience (matches Qt, Gtk, etc), although not
|
||||||
|
|
|
@ -24,6 +24,8 @@
|
||||||
// distribution.
|
// distribution.
|
||||||
//
|
//
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
// It is fine to use C99 in this file because it will not be built with VS
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
|
@ -54,9 +56,7 @@ static int calculateRefreshRate(const XRRModeInfo* mi)
|
||||||
//
|
//
|
||||||
static const XRRModeInfo* getModeInfo(const XRRScreenResources* sr, RRMode id)
|
static const XRRModeInfo* getModeInfo(const XRRScreenResources* sr, RRMode id)
|
||||||
{
|
{
|
||||||
int i;
|
for (int i = 0; i < sr->nmode; i++)
|
||||||
|
|
||||||
for (i = 0; i < sr->nmode; i++)
|
|
||||||
{
|
{
|
||||||
if (sr->modes[i].id == id)
|
if (sr->modes[i].id == id)
|
||||||
return sr->modes + i;
|
return sr->modes + i;
|
||||||
|
@ -102,7 +102,7 @@ void _glfwPollMonitorsX11(void)
|
||||||
{
|
{
|
||||||
if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken)
|
if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken)
|
||||||
{
|
{
|
||||||
int i, j, disconnectedCount, screenCount = 0;
|
int disconnectedCount, screenCount = 0;
|
||||||
_GLFWmonitor** disconnected = NULL;
|
_GLFWmonitor** disconnected = NULL;
|
||||||
XineramaScreenInfo* screens = NULL;
|
XineramaScreenInfo* screens = NULL;
|
||||||
XRRScreenResources* sr = XRRGetScreenResourcesCurrent(_glfw.x11.display,
|
XRRScreenResources* sr = XRRGetScreenResourcesCurrent(_glfw.x11.display,
|
||||||
|
@ -122,14 +122,11 @@ void _glfwPollMonitorsX11(void)
|
||||||
_glfw.monitorCount * sizeof(_GLFWmonitor*));
|
_glfw.monitorCount * sizeof(_GLFWmonitor*));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < sr->noutput; i++)
|
for (int i = 0; i < sr->noutput; i++)
|
||||||
{
|
{
|
||||||
int type, widthMM, heightMM;
|
int j, type, widthMM, heightMM;
|
||||||
XRROutputInfo* oi;
|
|
||||||
XRRCrtcInfo* ci;
|
|
||||||
_GLFWmonitor* monitor;
|
|
||||||
|
|
||||||
oi = XRRGetOutputInfo(_glfw.x11.display, sr, sr->outputs[i]);
|
XRROutputInfo* oi = XRRGetOutputInfo(_glfw.x11.display, sr, sr->outputs[i]);
|
||||||
if (oi->connection != RR_Connected || oi->crtc == None)
|
if (oi->connection != RR_Connected || oi->crtc == None)
|
||||||
{
|
{
|
||||||
XRRFreeOutputInfo(oi);
|
XRRFreeOutputInfo(oi);
|
||||||
|
@ -152,7 +149,7 @@ void _glfwPollMonitorsX11(void)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
ci = XRRGetCrtcInfo(_glfw.x11.display, sr, oi->crtc);
|
XRRCrtcInfo* ci = XRRGetCrtcInfo(_glfw.x11.display, sr, oi->crtc);
|
||||||
if (ci->rotation == RR_Rotate_90 || ci->rotation == RR_Rotate_270)
|
if (ci->rotation == RR_Rotate_90 || ci->rotation == RR_Rotate_270)
|
||||||
{
|
{
|
||||||
widthMM = oi->mm_height;
|
widthMM = oi->mm_height;
|
||||||
|
@ -164,7 +161,17 @@ void _glfwPollMonitorsX11(void)
|
||||||
heightMM = oi->mm_height;
|
heightMM = oi->mm_height;
|
||||||
}
|
}
|
||||||
|
|
||||||
monitor = _glfwAllocMonitor(oi->name, widthMM, heightMM);
|
if (widthMM <= 0 || heightMM <= 0)
|
||||||
|
{
|
||||||
|
// HACK: If RandR does not provide a physical size, assume the
|
||||||
|
// X11 default 96 DPI and calcuate from the CRTC viewport
|
||||||
|
// NOTE: These members are affected by rotation, unlike the mode
|
||||||
|
// info and output info members
|
||||||
|
widthMM = (int) (ci->width * 25.4f / 96.f);
|
||||||
|
heightMM = (int) (ci->height * 25.4f / 96.f);
|
||||||
|
}
|
||||||
|
|
||||||
|
_GLFWmonitor* monitor = _glfwAllocMonitor(oi->name, widthMM, heightMM);
|
||||||
monitor->x11.output = sr->outputs[i];
|
monitor->x11.output = sr->outputs[i];
|
||||||
monitor->x11.crtc = oi->crtc;
|
monitor->x11.crtc = oi->crtc;
|
||||||
|
|
||||||
|
@ -196,7 +203,7 @@ void _glfwPollMonitorsX11(void)
|
||||||
if (screens)
|
if (screens)
|
||||||
XFree(screens);
|
XFree(screens);
|
||||||
|
|
||||||
for (i = 0; i < disconnectedCount; i++)
|
for (int i = 0; i < disconnectedCount; i++)
|
||||||
{
|
{
|
||||||
if (disconnected[i])
|
if (disconnected[i])
|
||||||
_glfwInputMonitor(disconnected[i], GLFW_DISCONNECTED, 0);
|
_glfwInputMonitor(disconnected[i], GLFW_DISCONNECTED, 0);
|
||||||
|
@ -221,24 +228,20 @@ void _glfwSetVideoModeX11(_GLFWmonitor* monitor, const GLFWvidmode* desired)
|
||||||
{
|
{
|
||||||
if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken)
|
if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken)
|
||||||
{
|
{
|
||||||
XRRScreenResources* sr;
|
|
||||||
XRRCrtcInfo* ci;
|
|
||||||
XRROutputInfo* oi;
|
|
||||||
GLFWvidmode current;
|
GLFWvidmode current;
|
||||||
const GLFWvidmode* best;
|
|
||||||
RRMode native = None;
|
RRMode native = None;
|
||||||
int i;
|
|
||||||
|
|
||||||
best = _glfwChooseVideoMode(monitor, desired);
|
const GLFWvidmode* best = _glfwChooseVideoMode(monitor, desired);
|
||||||
_glfwPlatformGetVideoMode(monitor, ¤t);
|
_glfwPlatformGetVideoMode(monitor, ¤t);
|
||||||
if (_glfwCompareVideoModes(¤t, best) == 0)
|
if (_glfwCompareVideoModes(¤t, best) == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
sr = XRRGetScreenResourcesCurrent(_glfw.x11.display, _glfw.x11.root);
|
XRRScreenResources* sr =
|
||||||
ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc);
|
XRRGetScreenResourcesCurrent(_glfw.x11.display, _glfw.x11.root);
|
||||||
oi = XRRGetOutputInfo(_glfw.x11.display, sr, monitor->x11.output);
|
XRRCrtcInfo* ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc);
|
||||||
|
XRROutputInfo* oi = XRRGetOutputInfo(_glfw.x11.display, sr, monitor->x11.output);
|
||||||
|
|
||||||
for (i = 0; i < oi->nmode; i++)
|
for (int i = 0; i < oi->nmode; i++)
|
||||||
{
|
{
|
||||||
const XRRModeInfo* mi = getModeInfo(sr, oi->modes[i]);
|
const XRRModeInfo* mi = getModeInfo(sr, oi->modes[i]);
|
||||||
if (!modeIsGood(mi))
|
if (!modeIsGood(mi))
|
||||||
|
@ -279,14 +282,12 @@ void _glfwRestoreVideoModeX11(_GLFWmonitor* monitor)
|
||||||
{
|
{
|
||||||
if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken)
|
if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken)
|
||||||
{
|
{
|
||||||
XRRScreenResources* sr;
|
|
||||||
XRRCrtcInfo* ci;
|
|
||||||
|
|
||||||
if (monitor->x11.oldMode == None)
|
if (monitor->x11.oldMode == None)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
sr = XRRGetScreenResourcesCurrent(_glfw.x11.display, _glfw.x11.root);
|
XRRScreenResources* sr =
|
||||||
ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc);
|
XRRGetScreenResourcesCurrent(_glfw.x11.display, _glfw.x11.root);
|
||||||
|
XRRCrtcInfo* ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc);
|
||||||
|
|
||||||
XRRSetCrtcConfig(_glfw.x11.display,
|
XRRSetCrtcConfig(_glfw.x11.display,
|
||||||
sr, monitor->x11.crtc,
|
sr, monitor->x11.crtc,
|
||||||
|
@ -317,11 +318,9 @@ void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos)
|
||||||
{
|
{
|
||||||
if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken)
|
if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken)
|
||||||
{
|
{
|
||||||
XRRScreenResources* sr;
|
XRRScreenResources* sr =
|
||||||
XRRCrtcInfo* ci;
|
XRRGetScreenResourcesCurrent(_glfw.x11.display, _glfw.x11.root);
|
||||||
|
XRRCrtcInfo* ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc);
|
||||||
sr = XRRGetScreenResourcesCurrent(_glfw.x11.display, _glfw.x11.root);
|
|
||||||
ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc);
|
|
||||||
|
|
||||||
if (xpos)
|
if (xpos)
|
||||||
*xpos = ci->x;
|
*xpos = ci->x;
|
||||||
|
@ -348,11 +347,9 @@ void _glfwPlatformGetMonitorWorkarea(_GLFWmonitor* monitor, int* xpos, int* ypos
|
||||||
|
|
||||||
if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken)
|
if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken)
|
||||||
{
|
{
|
||||||
XRRScreenResources* sr;
|
XRRScreenResources* sr =
|
||||||
XRRCrtcInfo* ci;
|
XRRGetScreenResourcesCurrent(_glfw.x11.display, _glfw.x11.root);
|
||||||
|
XRRCrtcInfo* ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc);
|
||||||
sr = XRRGetScreenResourcesCurrent(_glfw.x11.display, _glfw.x11.root);
|
|
||||||
ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc);
|
|
||||||
|
|
||||||
areaX = ci->x;
|
areaX = ci->x;
|
||||||
areaY = ci->y;
|
areaY = ci->y;
|
||||||
|
@ -444,24 +441,21 @@ GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* count)
|
||||||
|
|
||||||
if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken)
|
if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken)
|
||||||
{
|
{
|
||||||
int i, j;
|
XRRScreenResources* sr =
|
||||||
XRRScreenResources* sr;
|
XRRGetScreenResourcesCurrent(_glfw.x11.display, _glfw.x11.root);
|
||||||
XRRCrtcInfo* ci;
|
XRRCrtcInfo* ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc);
|
||||||
XRROutputInfo* oi;
|
XRROutputInfo* oi = XRRGetOutputInfo(_glfw.x11.display, sr, monitor->x11.output);
|
||||||
|
|
||||||
sr = XRRGetScreenResourcesCurrent(_glfw.x11.display, _glfw.x11.root);
|
|
||||||
ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc);
|
|
||||||
oi = XRRGetOutputInfo(_glfw.x11.display, sr, monitor->x11.output);
|
|
||||||
|
|
||||||
result = calloc(oi->nmode, sizeof(GLFWvidmode));
|
result = calloc(oi->nmode, sizeof(GLFWvidmode));
|
||||||
|
|
||||||
for (i = 0; i < oi->nmode; i++)
|
for (int i = 0; i < oi->nmode; i++)
|
||||||
{
|
{
|
||||||
const XRRModeInfo* mi = getModeInfo(sr, oi->modes[i]);
|
const XRRModeInfo* mi = getModeInfo(sr, oi->modes[i]);
|
||||||
if (!modeIsGood(mi))
|
if (!modeIsGood(mi))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
const GLFWvidmode mode = vidmodeFromModeInfo(mi, ci);
|
const GLFWvidmode mode = vidmodeFromModeInfo(mi, ci);
|
||||||
|
int j;
|
||||||
|
|
||||||
for (j = 0; j < *count; j++)
|
for (j = 0; j < *count; j++)
|
||||||
{
|
{
|
||||||
|
@ -495,11 +489,9 @@ void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode)
|
||||||
{
|
{
|
||||||
if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken)
|
if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken)
|
||||||
{
|
{
|
||||||
XRRScreenResources* sr;
|
XRRScreenResources* sr =
|
||||||
XRRCrtcInfo* ci;
|
XRRGetScreenResourcesCurrent(_glfw.x11.display, _glfw.x11.root);
|
||||||
|
XRRCrtcInfo* ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc);
|
||||||
sr = XRRGetScreenResourcesCurrent(_glfw.x11.display, _glfw.x11.root);
|
|
||||||
ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc);
|
|
||||||
|
|
||||||
*mode = vidmodeFromModeInfo(getModeInfo(sr, ci->mode), ci);
|
*mode = vidmodeFromModeInfo(getModeInfo(sr, ci->mode), ci);
|
||||||
|
|
||||||
|
|
|
@ -180,6 +180,7 @@ typedef struct _GLFWwindowX11
|
||||||
{
|
{
|
||||||
Colormap colormap;
|
Colormap colormap;
|
||||||
Window handle;
|
Window handle;
|
||||||
|
Window parent;
|
||||||
XIC ic;
|
XIC ic;
|
||||||
|
|
||||||
GLFWbool overrideRedirect;
|
GLFWbool overrideRedirect;
|
||||||
|
@ -228,7 +229,7 @@ typedef struct _GLFWlibraryX11
|
||||||
// Clipboard string (while the selection is owned)
|
// Clipboard string (while the selection is owned)
|
||||||
char* clipboardString;
|
char* clipboardString;
|
||||||
// Key name string
|
// Key name string
|
||||||
char keyName[5];
|
char keynames[GLFW_KEY_LAST + 1][5];
|
||||||
// X11 keycode to GLFW key LUT
|
// X11 keycode to GLFW key LUT
|
||||||
short int keycodes[256];
|
short int keycodes[256];
|
||||||
// GLFW key to X11 keycode LUT
|
// GLFW key to X11 keycode LUT
|
||||||
|
@ -239,6 +240,8 @@ typedef struct _GLFWlibraryX11
|
||||||
_GLFWwindow* disabledCursorWindow;
|
_GLFWwindow* disabledCursorWindow;
|
||||||
|
|
||||||
// Window manager atoms
|
// Window manager atoms
|
||||||
|
Atom NET_SUPPORTED;
|
||||||
|
Atom NET_SUPPORTING_WM_CHECK;
|
||||||
Atom WM_PROTOCOLS;
|
Atom WM_PROTOCOLS;
|
||||||
Atom WM_STATE;
|
Atom WM_STATE;
|
||||||
Atom WM_DELETE_WINDOW;
|
Atom WM_DELETE_WINDOW;
|
||||||
|
@ -321,13 +324,14 @@ typedef struct _GLFWlibraryX11
|
||||||
} randr;
|
} randr;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
GLFWbool available;
|
GLFWbool available;
|
||||||
GLFWbool detectable;
|
GLFWbool detectable;
|
||||||
int majorOpcode;
|
int majorOpcode;
|
||||||
int eventBase;
|
int eventBase;
|
||||||
int errorBase;
|
int errorBase;
|
||||||
int major;
|
int major;
|
||||||
int minor;
|
int minor;
|
||||||
|
unsigned int group;
|
||||||
} xkb;
|
} xkb;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
|
|
348
src/x11_window.c
348
src/x11_window.c
|
@ -24,6 +24,8 @@
|
||||||
// distribution.
|
// distribution.
|
||||||
//
|
//
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
// It is fine to use C99 in this file because it will not be built with VS
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
|
@ -48,6 +50,10 @@
|
||||||
#define Button6 6
|
#define Button6 6
|
||||||
#define Button7 7
|
#define Button7 7
|
||||||
|
|
||||||
|
// Motif WM hints flags
|
||||||
|
#define MWM_HINTS_DECORATIONS 2
|
||||||
|
#define MWM_DECOR_ALL 1
|
||||||
|
|
||||||
#define _GLFW_XDND_VERSION 5
|
#define _GLFW_XDND_VERSION 5
|
||||||
|
|
||||||
|
|
||||||
|
@ -213,10 +219,7 @@ static int translateKey(int scancode)
|
||||||
static void sendEventToWM(_GLFWwindow* window, Atom type,
|
static void sendEventToWM(_GLFWwindow* window, Atom type,
|
||||||
long a, long b, long c, long d, long e)
|
long a, long b, long c, long d, long e)
|
||||||
{
|
{
|
||||||
XEvent event;
|
XEvent event = { ClientMessage };
|
||||||
memset(&event, 0, sizeof(event));
|
|
||||||
|
|
||||||
event.type = ClientMessage;
|
|
||||||
event.xclient.window = window->x11.handle;
|
event.xclient.window = window->x11.handle;
|
||||||
event.xclient.format = 32; // Data is 32-bit longs
|
event.xclient.format = 32; // Data is 32-bit longs
|
||||||
event.xclient.message_type = type;
|
event.xclient.message_type = type;
|
||||||
|
@ -610,46 +613,40 @@ static GLFWbool createNativeWindow(_GLFWwindow* window,
|
||||||
|
|
||||||
window->x11.transparent = _glfwIsVisualTransparentX11(visual);
|
window->x11.transparent = _glfwIsVisualTransparentX11(visual);
|
||||||
|
|
||||||
// Create the actual window
|
XSetWindowAttributes wa = { 0 };
|
||||||
|
wa.colormap = window->x11.colormap;
|
||||||
|
wa.event_mask = StructureNotifyMask | KeyPressMask | KeyReleaseMask |
|
||||||
|
PointerMotionMask | ButtonPressMask | ButtonReleaseMask |
|
||||||
|
ExposureMask | FocusChangeMask | VisibilityChangeMask |
|
||||||
|
EnterWindowMask | LeaveWindowMask | PropertyChangeMask;
|
||||||
|
|
||||||
|
_glfwGrabErrorHandlerX11();
|
||||||
|
|
||||||
|
window->x11.handle = XCreateWindow(_glfw.x11.display,
|
||||||
|
_glfw.x11.root,
|
||||||
|
0, 0, // Position
|
||||||
|
width, height,
|
||||||
|
0, // Border width
|
||||||
|
depth, // Color depth
|
||||||
|
InputOutput,
|
||||||
|
visual,
|
||||||
|
CWBorderPixel | CWColormap | CWEventMask,
|
||||||
|
&wa);
|
||||||
|
|
||||||
|
_glfwReleaseErrorHandlerX11();
|
||||||
|
|
||||||
|
if (!window->x11.handle)
|
||||||
{
|
{
|
||||||
XSetWindowAttributes wa;
|
_glfwInputErrorX11(GLFW_PLATFORM_ERROR,
|
||||||
const unsigned long wamask = CWBorderPixel | CWColormap | CWEventMask;
|
"X11: Failed to create window");
|
||||||
|
return GLFW_FALSE;
|
||||||
wa.colormap = window->x11.colormap;
|
|
||||||
wa.border_pixel = 0;
|
|
||||||
wa.event_mask = StructureNotifyMask | KeyPressMask | KeyReleaseMask |
|
|
||||||
PointerMotionMask | ButtonPressMask | ButtonReleaseMask |
|
|
||||||
ExposureMask | FocusChangeMask | VisibilityChangeMask |
|
|
||||||
EnterWindowMask | LeaveWindowMask | PropertyChangeMask;
|
|
||||||
|
|
||||||
_glfwGrabErrorHandlerX11();
|
|
||||||
|
|
||||||
window->x11.handle = XCreateWindow(_glfw.x11.display,
|
|
||||||
_glfw.x11.root,
|
|
||||||
0, 0,
|
|
||||||
width, height,
|
|
||||||
0, // Border width
|
|
||||||
depth, // Color depth
|
|
||||||
InputOutput,
|
|
||||||
visual,
|
|
||||||
wamask,
|
|
||||||
&wa);
|
|
||||||
|
|
||||||
_glfwReleaseErrorHandlerX11();
|
|
||||||
|
|
||||||
if (!window->x11.handle)
|
|
||||||
{
|
|
||||||
_glfwInputErrorX11(GLFW_PLATFORM_ERROR,
|
|
||||||
"X11: Failed to create window");
|
|
||||||
return GLFW_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
XSaveContext(_glfw.x11.display,
|
|
||||||
window->x11.handle,
|
|
||||||
_glfw.x11.context,
|
|
||||||
(XPointer) window);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
XSaveContext(_glfw.x11.display,
|
||||||
|
window->x11.handle,
|
||||||
|
_glfw.x11.context,
|
||||||
|
(XPointer) window);
|
||||||
|
|
||||||
if (!wndconfig->decorated)
|
if (!wndconfig->decorated)
|
||||||
_glfwPlatformSetWindowDecorated(window, GLFW_FALSE);
|
_glfwPlatformSetWindowDecorated(window, GLFW_FALSE);
|
||||||
|
|
||||||
|
@ -679,7 +676,7 @@ static GLFWbool createNativeWindow(_GLFWwindow* window,
|
||||||
{
|
{
|
||||||
XChangeProperty(_glfw.x11.display, window->x11.handle,
|
XChangeProperty(_glfw.x11.display, window->x11.handle,
|
||||||
_glfw.x11.NET_WM_STATE, XA_ATOM, 32,
|
_glfw.x11.NET_WM_STATE, XA_ATOM, 32,
|
||||||
PropModeReplace, (unsigned char*) &states, count);
|
PropModeReplace, (unsigned char*) states, count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -784,6 +781,13 @@ static GLFWbool createNativeWindow(_GLFWwindow* window,
|
||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (window->x11.ic)
|
||||||
|
{
|
||||||
|
unsigned long filter = 0;
|
||||||
|
if (XGetICValues(window->x11.ic, XNFilterEvents, &filter, NULL) == NULL)
|
||||||
|
XSelectInput(_glfw.x11.display, window->x11.handle, wa.event_mask | filter);
|
||||||
|
}
|
||||||
|
|
||||||
_glfwPlatformGetWindowPos(window, &window->x11.xpos, &window->x11.ypos);
|
_glfwPlatformGetWindowPos(window, &window->x11.xpos, &window->x11.ypos);
|
||||||
_glfwPlatformGetWindowSize(window, &window->x11.width, &window->x11.height);
|
_glfwPlatformGetWindowSize(window, &window->x11.width, &window->x11.height);
|
||||||
|
|
||||||
|
@ -944,11 +948,8 @@ static void handleSelectionRequest(XEvent* event)
|
||||||
{
|
{
|
||||||
const XSelectionRequestEvent* request = &event->xselectionrequest;
|
const XSelectionRequestEvent* request = &event->xselectionrequest;
|
||||||
|
|
||||||
XEvent reply;
|
XEvent reply = { SelectionNotify };
|
||||||
memset(&reply, 0, sizeof(reply));
|
|
||||||
|
|
||||||
reply.xselection.property = writeTargetToProperty(request);
|
reply.xselection.property = writeTargetToProperty(request);
|
||||||
reply.xselection.type = SelectionNotify;
|
|
||||||
reply.xselection.display = request->display;
|
reply.xselection.display = request->display;
|
||||||
reply.xselection.requestor = request->requestor;
|
reply.xselection.requestor = request->requestor;
|
||||||
reply.xselection.selection = request->selection;
|
reply.xselection.selection = request->selection;
|
||||||
|
@ -960,7 +961,6 @@ static void handleSelectionRequest(XEvent* event)
|
||||||
|
|
||||||
static const char* getSelectionString(Atom selection)
|
static const char* getSelectionString(Atom selection)
|
||||||
{
|
{
|
||||||
size_t i;
|
|
||||||
char** selectionString = NULL;
|
char** selectionString = NULL;
|
||||||
const Atom targets[] = { _glfw.x11.UTF8_STRING, XA_STRING };
|
const Atom targets[] = { _glfw.x11.UTF8_STRING, XA_STRING };
|
||||||
const size_t targetCount = sizeof(targets) / sizeof(targets[0]);
|
const size_t targetCount = sizeof(targets) / sizeof(targets[0]);
|
||||||
|
@ -981,7 +981,7 @@ static const char* getSelectionString(Atom selection)
|
||||||
free(*selectionString);
|
free(*selectionString);
|
||||||
*selectionString = NULL;
|
*selectionString = NULL;
|
||||||
|
|
||||||
for (i = 0; i < targetCount; i++)
|
for (size_t i = 0; i < targetCount; i++)
|
||||||
{
|
{
|
||||||
char* data;
|
char* data;
|
||||||
Atom actualType;
|
Atom actualType;
|
||||||
|
@ -1165,7 +1165,6 @@ static void releaseMonitor(_GLFWwindow* window)
|
||||||
//
|
//
|
||||||
static void processEvent(XEvent *event)
|
static void processEvent(XEvent *event)
|
||||||
{
|
{
|
||||||
_GLFWwindow* window = NULL;
|
|
||||||
int keycode = 0;
|
int keycode = 0;
|
||||||
Bool filtered = False;
|
Bool filtered = False;
|
||||||
|
|
||||||
|
@ -1186,6 +1185,18 @@ static void processEvent(XEvent *event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_glfw.x11.xkb.available)
|
||||||
|
{
|
||||||
|
if (event->type == _glfw.x11.xkb.eventBase + XkbEventCode)
|
||||||
|
{
|
||||||
|
if (((XkbEvent*) event)->any.xkb_type == XkbStateNotify &&
|
||||||
|
(((XkbEvent*) event)->state.changed & XkbGroupStateMask))
|
||||||
|
{
|
||||||
|
_glfw.x11.xkb.group = ((XkbEvent*) event)->state.group;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (event->type == GenericEvent)
|
if (event->type == GenericEvent)
|
||||||
{
|
{
|
||||||
if (_glfw.x11.xi.available)
|
if (_glfw.x11.xi.available)
|
||||||
|
@ -1235,6 +1246,7 @@ static void processEvent(XEvent *event)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_GLFWwindow* window = NULL;
|
||||||
if (XFindContext(_glfw.x11.display,
|
if (XFindContext(_glfw.x11.display,
|
||||||
event->xany.window,
|
event->xany.window,
|
||||||
_glfw.x11.context,
|
_glfw.x11.context,
|
||||||
|
@ -1246,6 +1258,18 @@ static void processEvent(XEvent *event)
|
||||||
|
|
||||||
switch (event->type)
|
switch (event->type)
|
||||||
{
|
{
|
||||||
|
case CreateNotify:
|
||||||
|
{
|
||||||
|
window->x11.parent = event->xcreatewindow.parent;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
case ReparentNotify:
|
||||||
|
{
|
||||||
|
window->x11.parent = event->xreparent.parent;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
case KeyPress:
|
case KeyPress:
|
||||||
{
|
{
|
||||||
const int key = translateKey(keycode);
|
const int key = translateKey(keycode);
|
||||||
|
@ -1530,18 +1554,28 @@ static void processEvent(XEvent *event)
|
||||||
window->x11.height = event->xconfigure.height;
|
window->x11.height = event->xconfigure.height;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event->xconfigure.x != window->x11.xpos ||
|
int xpos = event->xconfigure.x;
|
||||||
event->xconfigure.y != window->x11.ypos)
|
int ypos = event->xconfigure.y;
|
||||||
{
|
|
||||||
if (window->x11.overrideRedirect || event->xany.send_event)
|
|
||||||
{
|
|
||||||
_glfwInputWindowPos(window,
|
|
||||||
event->xconfigure.x,
|
|
||||||
event->xconfigure.y);
|
|
||||||
|
|
||||||
window->x11.xpos = event->xconfigure.x;
|
// NOTE: ConfigureNotify events from the server are in local
|
||||||
window->x11.ypos = event->xconfigure.y;
|
// coordinates, so if we are reparented we need to translate
|
||||||
}
|
// the position into root (screen) coordinates
|
||||||
|
if (!event->xany.send_event && window->x11.parent != _glfw.x11.root)
|
||||||
|
{
|
||||||
|
Window dummy;
|
||||||
|
XTranslateCoordinates(_glfw.x11.display,
|
||||||
|
window->x11.parent,
|
||||||
|
_glfw.x11.root,
|
||||||
|
xpos, ypos,
|
||||||
|
&xpos, &ypos,
|
||||||
|
&dummy);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (xpos != window->x11.xpos || ypos != window->x11.ypos)
|
||||||
|
{
|
||||||
|
_glfwInputWindowPos(window, xpos, ypos);
|
||||||
|
window->x11.xpos = xpos;
|
||||||
|
window->x11.ypos = ypos;
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -1646,10 +1680,7 @@ static void processEvent(XEvent *event)
|
||||||
}
|
}
|
||||||
else if (_glfw.x11.xdnd.version >= 2)
|
else if (_glfw.x11.xdnd.version >= 2)
|
||||||
{
|
{
|
||||||
XEvent reply;
|
XEvent reply = { ClientMessage };
|
||||||
memset(&reply, 0, sizeof(reply));
|
|
||||||
|
|
||||||
reply.type = ClientMessage;
|
|
||||||
reply.xclient.window = _glfw.x11.xdnd.source;
|
reply.xclient.window = _glfw.x11.xdnd.source;
|
||||||
reply.xclient.message_type = _glfw.x11.XdndFinished;
|
reply.xclient.message_type = _glfw.x11.XdndFinished;
|
||||||
reply.xclient.format = 32;
|
reply.xclient.format = 32;
|
||||||
|
@ -1682,10 +1713,7 @@ static void processEvent(XEvent *event)
|
||||||
|
|
||||||
_glfwInputCursorPos(window, xpos, ypos);
|
_glfwInputCursorPos(window, xpos, ypos);
|
||||||
|
|
||||||
XEvent reply;
|
XEvent reply = { ClientMessage };
|
||||||
memset(&reply, 0, sizeof(reply));
|
|
||||||
|
|
||||||
reply.type = ClientMessage;
|
|
||||||
reply.xclient.window = _glfw.x11.xdnd.source;
|
reply.xclient.window = _glfw.x11.xdnd.source;
|
||||||
reply.xclient.message_type = _glfw.x11.XdndStatus;
|
reply.xclient.message_type = _glfw.x11.XdndStatus;
|
||||||
reply.xclient.format = 32;
|
reply.xclient.format = 32;
|
||||||
|
@ -1738,10 +1766,7 @@ static void processEvent(XEvent *event)
|
||||||
|
|
||||||
if (_glfw.x11.xdnd.version >= 2)
|
if (_glfw.x11.xdnd.version >= 2)
|
||||||
{
|
{
|
||||||
XEvent reply;
|
XEvent reply = { ClientMessage };
|
||||||
memset(&reply, 0, sizeof(reply));
|
|
||||||
|
|
||||||
reply.type = ClientMessage;
|
|
||||||
reply.xclient.window = _glfw.x11.xdnd.source;
|
reply.xclient.window = _glfw.x11.xdnd.source;
|
||||||
reply.xclient.message_type = _glfw.x11.XdndFinished;
|
reply.xclient.message_type = _glfw.x11.XdndFinished;
|
||||||
reply.xclient.format = 32;
|
reply.xclient.format = 32;
|
||||||
|
@ -1760,9 +1785,6 @@ static void processEvent(XEvent *event)
|
||||||
|
|
||||||
case FocusIn:
|
case FocusIn:
|
||||||
{
|
{
|
||||||
if (window->cursorMode == GLFW_CURSOR_DISABLED)
|
|
||||||
disableCursor(window);
|
|
||||||
|
|
||||||
if (event->xfocus.mode == NotifyGrab ||
|
if (event->xfocus.mode == NotifyGrab ||
|
||||||
event->xfocus.mode == NotifyUngrab)
|
event->xfocus.mode == NotifyUngrab)
|
||||||
{
|
{
|
||||||
|
@ -1771,6 +1793,9 @@ static void processEvent(XEvent *event)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (window->cursorMode == GLFW_CURSOR_DISABLED)
|
||||||
|
disableCursor(window);
|
||||||
|
|
||||||
if (window->x11.ic)
|
if (window->x11.ic)
|
||||||
XSetICFocus(window->x11.ic);
|
XSetICFocus(window->x11.ic);
|
||||||
|
|
||||||
|
@ -1780,9 +1805,6 @@ static void processEvent(XEvent *event)
|
||||||
|
|
||||||
case FocusOut:
|
case FocusOut:
|
||||||
{
|
{
|
||||||
if (window->cursorMode == GLFW_CURSOR_DISABLED)
|
|
||||||
enableCursor(window);
|
|
||||||
|
|
||||||
if (event->xfocus.mode == NotifyGrab ||
|
if (event->xfocus.mode == NotifyGrab ||
|
||||||
event->xfocus.mode == NotifyUngrab)
|
event->xfocus.mode == NotifyUngrab)
|
||||||
{
|
{
|
||||||
|
@ -1791,6 +1813,9 @@ static void processEvent(XEvent *event)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (window->cursorMode == GLFW_CURSOR_DISABLED)
|
||||||
|
enableCursor(window);
|
||||||
|
|
||||||
if (window->x11.ic)
|
if (window->x11.ic)
|
||||||
XUnsetICFocus(window->x11.ic);
|
XUnsetICFocus(window->x11.ic);
|
||||||
|
|
||||||
|
@ -2338,18 +2363,67 @@ void _glfwPlatformRestoreWindow(_GLFWwindow* window)
|
||||||
|
|
||||||
void _glfwPlatformMaximizeWindow(_GLFWwindow* window)
|
void _glfwPlatformMaximizeWindow(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
if (_glfw.x11.NET_WM_STATE &&
|
if (!_glfw.x11.NET_WM_STATE ||
|
||||||
_glfw.x11.NET_WM_STATE_MAXIMIZED_VERT &&
|
!_glfw.x11.NET_WM_STATE_MAXIMIZED_VERT ||
|
||||||
_glfw.x11.NET_WM_STATE_MAXIMIZED_HORZ)
|
!_glfw.x11.NET_WM_STATE_MAXIMIZED_HORZ)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_glfwPlatformWindowVisible(window))
|
||||||
{
|
{
|
||||||
sendEventToWM(window,
|
sendEventToWM(window,
|
||||||
_glfw.x11.NET_WM_STATE,
|
_glfw.x11.NET_WM_STATE,
|
||||||
_NET_WM_STATE_ADD,
|
_NET_WM_STATE_ADD,
|
||||||
_glfw.x11.NET_WM_STATE_MAXIMIZED_VERT,
|
_glfw.x11.NET_WM_STATE_MAXIMIZED_VERT,
|
||||||
_glfw.x11.NET_WM_STATE_MAXIMIZED_HORZ,
|
_glfw.x11.NET_WM_STATE_MAXIMIZED_HORZ,
|
||||||
1, 0);
|
1, 0);
|
||||||
XFlush(_glfw.x11.display);
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Atom* states = NULL;
|
||||||
|
unsigned long count =
|
||||||
|
_glfwGetWindowPropertyX11(window->x11.handle,
|
||||||
|
_glfw.x11.NET_WM_STATE,
|
||||||
|
XA_ATOM,
|
||||||
|
(unsigned char**) &states);
|
||||||
|
|
||||||
|
// NOTE: We don't check for failure as this property may not exist yet
|
||||||
|
// and that's fine (and we'll create it implicitly with append)
|
||||||
|
|
||||||
|
Atom missing[2] =
|
||||||
|
{
|
||||||
|
_glfw.x11.NET_WM_STATE_MAXIMIZED_VERT,
|
||||||
|
_glfw.x11.NET_WM_STATE_MAXIMIZED_HORZ
|
||||||
|
};
|
||||||
|
unsigned long missingCount = 2;
|
||||||
|
|
||||||
|
for (unsigned long i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
for (unsigned long j = 0; j < missingCount; j++)
|
||||||
|
{
|
||||||
|
if (states[i] == missing[j])
|
||||||
|
{
|
||||||
|
missing[j] = missing[missingCount - 1];
|
||||||
|
missingCount--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (states)
|
||||||
|
XFree(states);
|
||||||
|
|
||||||
|
if (!missingCount)
|
||||||
|
return;
|
||||||
|
|
||||||
|
XChangeProperty(_glfw.x11.display, window->x11.handle,
|
||||||
|
_glfw.x11.NET_WM_STATE, XA_ATOM, 32,
|
||||||
|
PropModeAppend,
|
||||||
|
(unsigned char*) missing,
|
||||||
|
missingCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
XFlush(_glfw.x11.display);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformShowWindow(_GLFWwindow* window)
|
void _glfwPlatformShowWindow(_GLFWwindow* window)
|
||||||
|
@ -2369,6 +2443,9 @@ void _glfwPlatformHideWindow(_GLFWwindow* window)
|
||||||
|
|
||||||
void _glfwPlatformRequestWindowAttention(_GLFWwindow* window)
|
void _glfwPlatformRequestWindowAttention(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
|
if (!_glfw.x11.NET_WM_STATE || !_glfw.x11.NET_WM_STATE_DEMANDS_ATTENTION)
|
||||||
|
return;
|
||||||
|
|
||||||
sendEventToWM(window,
|
sendEventToWM(window,
|
||||||
_glfw.x11.NET_WM_STATE,
|
_glfw.x11.NET_WM_STATE,
|
||||||
_NET_WM_STATE_ADD,
|
_NET_WM_STATE_ADD,
|
||||||
|
@ -2538,33 +2615,24 @@ void _glfwPlatformSetWindowResizable(_GLFWwindow* window, GLFWbool enabled)
|
||||||
|
|
||||||
void _glfwPlatformSetWindowDecorated(_GLFWwindow* window, GLFWbool enabled)
|
void _glfwPlatformSetWindowDecorated(_GLFWwindow* window, GLFWbool enabled)
|
||||||
{
|
{
|
||||||
if (enabled)
|
struct
|
||||||
{
|
{
|
||||||
XDeleteProperty(_glfw.x11.display,
|
unsigned long flags;
|
||||||
window->x11.handle,
|
unsigned long functions;
|
||||||
_glfw.x11.MOTIF_WM_HINTS);
|
unsigned long decorations;
|
||||||
}
|
long input_mode;
|
||||||
else
|
unsigned long status;
|
||||||
{
|
} hints = {0};
|
||||||
struct
|
|
||||||
{
|
|
||||||
unsigned long flags;
|
|
||||||
unsigned long functions;
|
|
||||||
unsigned long decorations;
|
|
||||||
long input_mode;
|
|
||||||
unsigned long status;
|
|
||||||
} hints;
|
|
||||||
|
|
||||||
hints.flags = 2; // Set decorations
|
hints.flags = MWM_HINTS_DECORATIONS;
|
||||||
hints.decorations = 0; // No decorations
|
hints.decorations = enabled ? MWM_DECOR_ALL : 0;
|
||||||
|
|
||||||
XChangeProperty(_glfw.x11.display, window->x11.handle,
|
XChangeProperty(_glfw.x11.display, window->x11.handle,
|
||||||
_glfw.x11.MOTIF_WM_HINTS,
|
_glfw.x11.MOTIF_WM_HINTS,
|
||||||
_glfw.x11.MOTIF_WM_HINTS, 32,
|
_glfw.x11.MOTIF_WM_HINTS, 32,
|
||||||
PropModeReplace,
|
PropModeReplace,
|
||||||
(unsigned char*) &hints,
|
(unsigned char*) &hints,
|
||||||
sizeof(hints) / sizeof(long));
|
sizeof(hints) / sizeof(long));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled)
|
void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled)
|
||||||
|
@ -2574,7 +2642,7 @@ void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled)
|
||||||
|
|
||||||
if (_glfwPlatformWindowVisible(window))
|
if (_glfwPlatformWindowVisible(window))
|
||||||
{
|
{
|
||||||
const Atom action = enabled ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE;
|
const long action = enabled ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE;
|
||||||
sendEventToWM(window,
|
sendEventToWM(window,
|
||||||
_glfw.x11.NET_WM_STATE,
|
_glfw.x11.NET_WM_STATE,
|
||||||
action,
|
action,
|
||||||
|
@ -2583,15 +2651,16 @@ void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Atom* states;
|
Atom* states = NULL;
|
||||||
unsigned long i, count;
|
unsigned long i, count;
|
||||||
|
|
||||||
count = _glfwGetWindowPropertyX11(window->x11.handle,
|
count = _glfwGetWindowPropertyX11(window->x11.handle,
|
||||||
_glfw.x11.NET_WM_STATE,
|
_glfw.x11.NET_WM_STATE,
|
||||||
XA_ATOM,
|
XA_ATOM,
|
||||||
(unsigned char**) &states);
|
(unsigned char**) &states);
|
||||||
if (!states)
|
|
||||||
return;
|
// NOTE: We don't check for failure as this property may not exist yet
|
||||||
|
// and that's fine (and we'll create it implicitly with append)
|
||||||
|
|
||||||
if (enabled)
|
if (enabled)
|
||||||
{
|
{
|
||||||
|
@ -2601,32 +2670,36 @@ void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i == count)
|
if (i < count)
|
||||||
{
|
return;
|
||||||
XChangeProperty(_glfw.x11.display, window->x11.handle,
|
|
||||||
_glfw.x11.NET_WM_STATE, XA_ATOM, 32,
|
XChangeProperty(_glfw.x11.display, window->x11.handle,
|
||||||
PropModeAppend,
|
_glfw.x11.NET_WM_STATE, XA_ATOM, 32,
|
||||||
(unsigned char*) &_glfw.x11.NET_WM_STATE_ABOVE,
|
PropModeAppend,
|
||||||
1);
|
(unsigned char*) &_glfw.x11.NET_WM_STATE_ABOVE,
|
||||||
}
|
1);
|
||||||
}
|
}
|
||||||
else
|
else if (states)
|
||||||
{
|
{
|
||||||
for (i = 0; i < count; i++)
|
for (i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
if (states[i] == _glfw.x11.NET_WM_STATE_ABOVE)
|
if (states[i] == _glfw.x11.NET_WM_STATE_ABOVE)
|
||||||
{
|
break;
|
||||||
states[i] = states[count - 1];
|
|
||||||
count--;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (i == count)
|
||||||
|
return;
|
||||||
|
|
||||||
|
states[i] = states[count - 1];
|
||||||
|
count--;
|
||||||
|
|
||||||
XChangeProperty(_glfw.x11.display, window->x11.handle,
|
XChangeProperty(_glfw.x11.display, window->x11.handle,
|
||||||
_glfw.x11.NET_WM_STATE, XA_ATOM, 32,
|
_glfw.x11.NET_WM_STATE, XA_ATOM, 32,
|
||||||
PropModeReplace, (unsigned char*) &states, count);
|
PropModeReplace, (unsigned char*) states, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
XFree(states);
|
if (states)
|
||||||
|
XFree(states);
|
||||||
}
|
}
|
||||||
|
|
||||||
XFlush(_glfw.x11.display);
|
XFlush(_glfw.x11.display);
|
||||||
|
@ -2737,10 +2810,7 @@ void _glfwPlatformWaitEventsTimeout(double timeout)
|
||||||
|
|
||||||
void _glfwPlatformPostEmptyEvent(void)
|
void _glfwPlatformPostEmptyEvent(void)
|
||||||
{
|
{
|
||||||
XEvent event;
|
XEvent event = { ClientMessage };
|
||||||
|
|
||||||
memset(&event, 0, sizeof(event));
|
|
||||||
event.type = ClientMessage;
|
|
||||||
event.xclient.window = _glfw.x11.helperWindowHandle;
|
event.xclient.window = _glfw.x11.helperWindowHandle;
|
||||||
event.xclient.format = 32; // Data is 32-bit longs
|
event.xclient.format = 32; // Data is 32-bit longs
|
||||||
event.xclient.message_type = _glfw.x11.NULL_;
|
event.xclient.message_type = _glfw.x11.NULL_;
|
||||||
|
@ -2797,7 +2867,9 @@ const char* _glfwPlatformGetScancodeName(int scancode)
|
||||||
if (!_glfw.x11.xkb.available)
|
if (!_glfw.x11.xkb.available)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
const KeySym keysym = XkbKeycodeToKeysym(_glfw.x11.display, scancode, 0, 0);
|
const int key = _glfw.x11.keycodes[scancode];
|
||||||
|
const KeySym keysym = XkbKeycodeToKeysym(_glfw.x11.display,
|
||||||
|
scancode, _glfw.x11.xkb.group, 0);
|
||||||
if (keysym == NoSymbol)
|
if (keysym == NoSymbol)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
@ -2805,12 +2877,12 @@ const char* _glfwPlatformGetScancodeName(int scancode)
|
||||||
if (ch == -1)
|
if (ch == -1)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
const size_t count = encodeUTF8(_glfw.x11.keyName, (unsigned int) ch);
|
const size_t count = encodeUTF8(_glfw.x11.keynames[key], (unsigned int) ch);
|
||||||
if (count == 0)
|
if (count == 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
_glfw.x11.keyName[count] = '\0';
|
_glfw.x11.keynames[key][count] = '\0';
|
||||||
return _glfw.x11.keyName;
|
return _glfw.x11.keynames[key];
|
||||||
}
|
}
|
||||||
|
|
||||||
int _glfwPlatformGetKeyScancode(int key)
|
int _glfwPlatformGetKeyScancode(int key)
|
||||||
|
|
|
@ -24,6 +24,8 @@
|
||||||
// distribution.
|
// distribution.
|
||||||
//
|
//
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
// It is fine to use C99 in this file because it will not be built with VS
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
link_libraries(glfw)
|
link_libraries(glfw)
|
||||||
|
|
||||||
include_directories(${glfw_INCLUDE_DIRS} "${GLFW_SOURCE_DIR}/deps")
|
include_directories("${GLFW_SOURCE_DIR}/deps")
|
||||||
|
|
||||||
if (MATH_LIBRARY)
|
if (MATH_LIBRARY)
|
||||||
link_libraries("${MATH_LIBRARY}")
|
link_libraries("${MATH_LIBRARY}")
|
||||||
|
@ -20,6 +20,17 @@ set(GETOPT "${GLFW_SOURCE_DIR}/deps/getopt.h"
|
||||||
set(TINYCTHREAD "${GLFW_SOURCE_DIR}/deps/tinycthread.h"
|
set(TINYCTHREAD "${GLFW_SOURCE_DIR}/deps/tinycthread.h"
|
||||||
"${GLFW_SOURCE_DIR}/deps/tinycthread.c")
|
"${GLFW_SOURCE_DIR}/deps/tinycthread.c")
|
||||||
|
|
||||||
|
if (${CMAKE_VERSION} VERSION_EQUAL "3.1.0" OR
|
||||||
|
${CMAKE_VERSION} VERSION_GREATER "3.1.0")
|
||||||
|
set(CMAKE_C_STANDARD 99)
|
||||||
|
else()
|
||||||
|
# Remove this fallback when removing support for CMake version less than 3.1
|
||||||
|
add_compile_options("$<$<C_COMPILER_ID:AppleClang>:-std=c99>"
|
||||||
|
"$<$<C_COMPILER_ID:Clang>:-std=c99>"
|
||||||
|
"$<$<C_COMPILER_ID:GNU>:-std=c99>")
|
||||||
|
|
||||||
|
endif()
|
||||||
|
|
||||||
add_executable(clipboard clipboard.c ${GETOPT} ${GLAD_GL})
|
add_executable(clipboard clipboard.c ${GETOPT} ${GLAD_GL})
|
||||||
add_executable(events events.c ${GETOPT} ${GLAD_GL})
|
add_executable(events events.c ${GETOPT} ${GLAD_GL})
|
||||||
add_executable(msaa msaa.c ${GETOPT} ${GLAD_GL})
|
add_executable(msaa msaa.c ${GETOPT} ${GLAD_GL})
|
||||||
|
@ -39,7 +50,7 @@ add_executable(tearing WIN32 MACOSX_BUNDLE tearing.c ${GLAD_GL})
|
||||||
add_executable(threads WIN32 MACOSX_BUNDLE threads.c ${TINYCTHREAD} ${GLAD_GL})
|
add_executable(threads WIN32 MACOSX_BUNDLE threads.c ${TINYCTHREAD} ${GLAD_GL})
|
||||||
add_executable(timeout WIN32 MACOSX_BUNDLE timeout.c ${GLAD_GL})
|
add_executable(timeout WIN32 MACOSX_BUNDLE timeout.c ${GLAD_GL})
|
||||||
add_executable(title WIN32 MACOSX_BUNDLE title.c ${GLAD_GL})
|
add_executable(title WIN32 MACOSX_BUNDLE title.c ${GLAD_GL})
|
||||||
add_executable(vulkan WIN32 vulkan.c ${ICON} ${GLAD_VULKAN})
|
add_executable(triangle-vulkan WIN32 triangle-vulkan.c ${GLAD_VULKAN})
|
||||||
add_executable(windows WIN32 MACOSX_BUNDLE windows.c ${GETOPT} ${GLAD_GL})
|
add_executable(windows WIN32 MACOSX_BUNDLE windows.c ${GETOPT} ${GLAD_GL})
|
||||||
|
|
||||||
target_link_libraries(empty "${CMAKE_THREAD_LIBS_INIT}")
|
target_link_libraries(empty "${CMAKE_THREAD_LIBS_INIT}")
|
||||||
|
@ -49,17 +60,17 @@ if (RT_LIBRARY)
|
||||||
target_link_libraries(threads "${RT_LIBRARY}")
|
target_link_libraries(threads "${RT_LIBRARY}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(WINDOWS_BINARIES empty gamma icon inputlag joysticks opacity tearing
|
set(GUI_ONLY_BINARIES empty gamma icon inputlag joysticks opacity tearing
|
||||||
threads timeout title vulkan windows)
|
threads timeout title triangle-vulkan windows)
|
||||||
set(CONSOLE_BINARIES clipboard events msaa glfwinfo iconify monitors reopen
|
set(CONSOLE_BINARIES clipboard events msaa glfwinfo iconify monitors reopen
|
||||||
cursor)
|
cursor)
|
||||||
|
|
||||||
set_target_properties(${WINDOWS_BINARIES} ${CONSOLE_BINARIES} PROPERTIES
|
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 for Windows subsystem executables
|
||||||
set_target_properties(${WINDOWS_BINARIES} ${CONSOLE_BINARIES} PROPERTIES
|
set_target_properties(${GUI_ONLY_BINARIES} PROPERTIES
|
||||||
LINK_FLAGS "/ENTRY:mainCRTStartup")
|
LINK_FLAGS "/ENTRY:mainCRTStartup")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@ -73,12 +84,11 @@ if (APPLE)
|
||||||
set_target_properties(threads PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Threads")
|
set_target_properties(threads PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Threads")
|
||||||
set_target_properties(timeout PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Timeout")
|
set_target_properties(timeout PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Timeout")
|
||||||
set_target_properties(title PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Title")
|
set_target_properties(title PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Title")
|
||||||
set_target_properties(windows PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Vulkan")
|
|
||||||
set_target_properties(windows PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Windows")
|
set_target_properties(windows PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Windows")
|
||||||
|
|
||||||
set_target_properties(${WINDOWS_BINARIES} ${CONSOLE_BINARIES} PROPERTIES
|
set_target_properties(${GUI_ONLY_BINARIES} PROPERTIES
|
||||||
MACOSX_BUNDLE_SHORT_VERSION_STRING ${GLFW_VERSION}
|
MACOSX_BUNDLE_SHORT_VERSION_STRING ${GLFW_VERSION}
|
||||||
MACOSX_BUNDLE_LONG_VERSION_STRING ${GLFW_VERSION_FULL}
|
MACOSX_BUNDLE_LONG_VERSION_STRING ${GLFW_VERSION}
|
||||||
MACOSX_BUNDLE_INFO_PLIST "${GLFW_SOURCE_DIR}/CMake/MacOSXBundleInfo.plist.in")
|
MACOSX_BUNDLE_INFO_PLIST "${GLFW_SOURCE_DIR}/CMake/MacOSXBundleInfo.plist.in")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
#include <glad/gl.h>
|
#include <glad/gl.h>
|
||||||
|
#define GLFW_INCLUDE_NONE
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
#include <glad/gl.h>
|
#include <glad/gl.h>
|
||||||
|
#define GLFW_INCLUDE_NONE
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
|
|
||||||
#if defined(_MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
#include "tinycthread.h"
|
#include "tinycthread.h"
|
||||||
|
|
||||||
#include <glad/gl.h>
|
#include <glad/gl.h>
|
||||||
|
#define GLFW_INCLUDE_NONE
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
#include <glad/gl.h>
|
#include <glad/gl.h>
|
||||||
|
#define GLFW_INCLUDE_NONE
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -174,7 +175,7 @@ static const char* get_key_name(int key)
|
||||||
case GLFW_KEY_KP_8: return "KEYPAD 8";
|
case GLFW_KEY_KP_8: return "KEYPAD 8";
|
||||||
case GLFW_KEY_KP_9: return "KEYPAD 9";
|
case GLFW_KEY_KP_9: return "KEYPAD 9";
|
||||||
case GLFW_KEY_KP_DIVIDE: return "KEYPAD DIVIDE";
|
case GLFW_KEY_KP_DIVIDE: return "KEYPAD DIVIDE";
|
||||||
case GLFW_KEY_KP_MULTIPLY: return "KEYPAD MULTPLY";
|
case GLFW_KEY_KP_MULTIPLY: return "KEYPAD MULTIPLY";
|
||||||
case GLFW_KEY_KP_SUBTRACT: return "KEYPAD SUBTRACT";
|
case GLFW_KEY_KP_SUBTRACT: return "KEYPAD SUBTRACT";
|
||||||
case GLFW_KEY_KP_ADD: return "KEYPAD ADD";
|
case GLFW_KEY_KP_ADD: return "KEYPAD ADD";
|
||||||
case GLFW_KEY_KP_DECIMAL: return "KEYPAD DECIMAL";
|
case GLFW_KEY_KP_DECIMAL: return "KEYPAD DECIMAL";
|
||||||
|
@ -252,17 +253,32 @@ static const char* get_mods_name(int mods)
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char* get_character_string(int codepoint)
|
static size_t encode_utf8(char* s, unsigned int ch)
|
||||||
{
|
{
|
||||||
// This assumes UTF-8, which is stupid
|
size_t count = 0;
|
||||||
static char result[6 + 1];
|
|
||||||
|
|
||||||
int length = wctomb(result, codepoint);
|
if (ch < 0x80)
|
||||||
if (length == -1)
|
s[count++] = (char) ch;
|
||||||
length = 0;
|
else if (ch < 0x800)
|
||||||
|
{
|
||||||
|
s[count++] = (ch >> 6) | 0xc0;
|
||||||
|
s[count++] = (ch & 0x3f) | 0x80;
|
||||||
|
}
|
||||||
|
else if (ch < 0x10000)
|
||||||
|
{
|
||||||
|
s[count++] = (ch >> 12) | 0xe0;
|
||||||
|
s[count++] = ((ch >> 6) & 0x3f) | 0x80;
|
||||||
|
s[count++] = (ch & 0x3f) | 0x80;
|
||||||
|
}
|
||||||
|
else if (ch < 0x110000)
|
||||||
|
{
|
||||||
|
s[count++] = (ch >> 18) | 0xf0;
|
||||||
|
s[count++] = ((ch >> 12) & 0x3f) | 0x80;
|
||||||
|
s[count++] = ((ch >> 6) & 0x3f) | 0x80;
|
||||||
|
s[count++] = (ch & 0x3f) | 0x80;
|
||||||
|
}
|
||||||
|
|
||||||
result[length] = '\0';
|
return count;
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void error_callback(int error, const char* description)
|
static void error_callback(int error, const char* description)
|
||||||
|
@ -424,12 +440,14 @@ static void key_callback(GLFWwindow* window, int key, int scancode, int action,
|
||||||
static void char_callback(GLFWwindow* window, unsigned int codepoint)
|
static void char_callback(GLFWwindow* window, unsigned int codepoint)
|
||||||
{
|
{
|
||||||
Slot* slot = glfwGetWindowUserPointer(window);
|
Slot* slot = glfwGetWindowUserPointer(window);
|
||||||
|
char string[5] = "";
|
||||||
|
|
||||||
|
encode_utf8(string, codepoint);
|
||||||
printf("%08x to %i at %0.3f: Character 0x%08x (%s) input\n",
|
printf("%08x to %i at %0.3f: Character 0x%08x (%s) input\n",
|
||||||
counter++, slot->number, glfwGetTime(), codepoint,
|
counter++, slot->number, glfwGetTime(), codepoint, string);
|
||||||
get_character_string(codepoint));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void drop_callback(GLFWwindow* window, int count, const char** paths)
|
static void drop_callback(GLFWwindow* window, int count, const char* paths[])
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
Slot* slot = glfwGetWindowUserPointer(window);
|
Slot* slot = glfwGetWindowUserPointer(window);
|
||||||
|
@ -499,8 +517,6 @@ int main(int argc, char** argv)
|
||||||
GLFWmonitor* monitor = NULL;
|
GLFWmonitor* monitor = NULL;
|
||||||
int ch, i, width, height, count = 1;
|
int ch, i, width, height, count = 1;
|
||||||
|
|
||||||
setlocale(LC_ALL, "");
|
|
||||||
|
|
||||||
glfwSetErrorCallback(error_callback);
|
glfwSetErrorCallback(error_callback);
|
||||||
|
|
||||||
if (!glfwInit())
|
if (!glfwInit())
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
#include <glad/gl.h>
|
#include <glad/gl.h>
|
||||||
|
#define GLFW_INCLUDE_NONE
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
|
|
||||||
#define NK_IMPLEMENTATION
|
#define NK_IMPLEMENTATION
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
|
|
||||||
#include <glad/gl.h>
|
#include <glad/gl.h>
|
||||||
#include <glad/vulkan.h>
|
#include <glad/vulkan.h>
|
||||||
|
#define GLFW_INCLUDE_NONE
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -358,7 +359,8 @@ int main(int argc, char** argv)
|
||||||
GLenum error;
|
GLenum error;
|
||||||
GLFWwindow* window;
|
GLFWwindow* window;
|
||||||
|
|
||||||
enum { CLIENT, CONTEXT, BEHAVIOR, DEBUG, FORWARD, HELP, EXTENSIONS, LAYERS,
|
enum { CLIENT, CONTEXT, BEHAVIOR, DEBUG_CONTEXT, FORWARD, HELP,
|
||||||
|
EXTENSIONS, LAYERS,
|
||||||
MAJOR, MINOR, PROFILE, ROBUSTNESS, VERSION,
|
MAJOR, MINOR, PROFILE, ROBUSTNESS, VERSION,
|
||||||
REDBITS, GREENBITS, BLUEBITS, ALPHABITS, DEPTHBITS, STENCILBITS,
|
REDBITS, GREENBITS, BLUEBITS, ALPHABITS, DEPTHBITS, STENCILBITS,
|
||||||
ACCUMREDBITS, ACCUMGREENBITS, ACCUMBLUEBITS, ACCUMALPHABITS,
|
ACCUMREDBITS, ACCUMGREENBITS, ACCUMBLUEBITS, ACCUMALPHABITS,
|
||||||
|
@ -369,7 +371,7 @@ int main(int argc, char** argv)
|
||||||
{ "behavior", 1, NULL, BEHAVIOR },
|
{ "behavior", 1, NULL, BEHAVIOR },
|
||||||
{ "client-api", 1, NULL, CLIENT },
|
{ "client-api", 1, NULL, CLIENT },
|
||||||
{ "context-api", 1, NULL, CONTEXT },
|
{ "context-api", 1, NULL, CONTEXT },
|
||||||
{ "debug", 0, NULL, DEBUG },
|
{ "debug", 0, NULL, DEBUG_CONTEXT },
|
||||||
{ "forward", 0, NULL, FORWARD },
|
{ "forward", 0, NULL, FORWARD },
|
||||||
{ "help", 0, NULL, HELP },
|
{ "help", 0, NULL, HELP },
|
||||||
{ "list-extensions", 0, NULL, EXTENSIONS },
|
{ "list-extensions", 0, NULL, EXTENSIONS },
|
||||||
|
@ -460,7 +462,7 @@ int main(int argc, char** argv)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'd':
|
case 'd':
|
||||||
case DEBUG:
|
case DEBUG_CONTEXT:
|
||||||
glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GLFW_TRUE);
|
glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GLFW_TRUE);
|
||||||
break;
|
break;
|
||||||
case 'f':
|
case 'f':
|
||||||
|
@ -809,6 +811,7 @@ int main(int argc, char** argv)
|
||||||
|
|
||||||
if (glfwVulkanSupported())
|
if (glfwVulkanSupported())
|
||||||
{
|
{
|
||||||
|
uint32_t loader_version = VK_API_VERSION_1_0;
|
||||||
uint32_t i, re_count, pd_count;
|
uint32_t i, re_count, pd_count;
|
||||||
const char** re;
|
const char** re;
|
||||||
VkApplicationInfo ai = {0};
|
VkApplicationInfo ai = {0};
|
||||||
|
@ -818,6 +821,17 @@ int main(int argc, char** argv)
|
||||||
|
|
||||||
gladLoadVulkanUserPtr(NULL, glad_vulkan_callback, NULL);
|
gladLoadVulkanUserPtr(NULL, glad_vulkan_callback, NULL);
|
||||||
|
|
||||||
|
if (vkEnumerateInstanceVersion)
|
||||||
|
{
|
||||||
|
uint32_t version;
|
||||||
|
if (vkEnumerateInstanceVersion(&version) == VK_SUCCESS)
|
||||||
|
loader_version = version;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("Vulkan loader API version: %i.%i\n",
|
||||||
|
VK_VERSION_MAJOR(loader_version),
|
||||||
|
VK_VERSION_MINOR(loader_version));
|
||||||
|
|
||||||
re = glfwGetRequiredInstanceExtensions(&re_count);
|
re = glfwGetRequiredInstanceExtensions(&re_count);
|
||||||
|
|
||||||
printf("Vulkan required instance extensions:");
|
printf("Vulkan required instance extensions:");
|
||||||
|
@ -838,10 +852,14 @@ int main(int argc, char** argv)
|
||||||
|
|
||||||
ai.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
|
ai.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
|
||||||
ai.pApplicationName = "glfwinfo";
|
ai.pApplicationName = "glfwinfo";
|
||||||
ai.applicationVersion = GLFW_VERSION_MAJOR;
|
ai.applicationVersion = VK_MAKE_VERSION(GLFW_VERSION_MAJOR,
|
||||||
ai.pEngineName = "GLFW";
|
GLFW_VERSION_MINOR,
|
||||||
ai.engineVersion = GLFW_VERSION_MAJOR;
|
GLFW_VERSION_REVISION);
|
||||||
ai.apiVersion = VK_API_VERSION_1_0;
|
|
||||||
|
if (loader_version >= VK_API_VERSION_1_1)
|
||||||
|
ai.apiVersion = VK_API_VERSION_1_1;
|
||||||
|
else
|
||||||
|
ai.apiVersion = VK_API_VERSION_1_0;
|
||||||
|
|
||||||
ici.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
|
ici.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
|
||||||
ici.pApplicationInfo = &ai;
|
ici.pApplicationInfo = &ai;
|
||||||
|
@ -879,9 +897,11 @@ int main(int argc, char** argv)
|
||||||
|
|
||||||
vkGetPhysicalDeviceProperties(pd[i], &pdp);
|
vkGetPhysicalDeviceProperties(pd[i], &pdp);
|
||||||
|
|
||||||
printf("Vulkan %s device: \"%s\"\n",
|
printf("Vulkan %s device: \"%s\" API version %i.%i\n",
|
||||||
get_device_type_name(pdp.deviceType),
|
get_device_type_name(pdp.deviceType),
|
||||||
pdp.deviceName);
|
pdp.deviceName,
|
||||||
|
VK_VERSION_MAJOR(pdp.apiVersion),
|
||||||
|
VK_VERSION_MINOR(pdp.apiVersion));
|
||||||
|
|
||||||
if (list_extensions)
|
if (list_extensions)
|
||||||
list_vulkan_device_extensions(instance, pd[i]);
|
list_vulkan_device_extensions(instance, pd[i]);
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
#include <glad/gl.h>
|
#include <glad/gl.h>
|
||||||
|
#define GLFW_INCLUDE_NONE
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
#include <glad/gl.h>
|
#include <glad/gl.h>
|
||||||
|
#define GLFW_INCLUDE_NONE
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
#include <glad/gl.h>
|
#include <glad/gl.h>
|
||||||
|
#define GLFW_INCLUDE_NONE
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
|
|
||||||
#define NK_IMPLEMENTATION
|
#define NK_IMPLEMENTATION
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
#include <glad/gl.h>
|
#include <glad/gl.h>
|
||||||
|
#define GLFW_INCLUDE_NONE
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
|
|
||||||
#define NK_IMPLEMENTATION
|
#define NK_IMPLEMENTATION
|
||||||
|
@ -85,7 +86,7 @@ static void joystick_callback(int jid, int event)
|
||||||
glfwRequestWindowAttention(window);
|
glfwRequestWindowAttention(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void drop_callback(GLFWwindow* window, int count, const char** paths)
|
static void drop_callback(GLFWwindow* window, int count, const char* paths[])
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
#include <glad/gl.h>
|
#include <glad/gl.h>
|
||||||
|
#define GLFW_INCLUDE_NONE
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -108,13 +109,13 @@ static void list_modes(GLFWmonitor* monitor)
|
||||||
glfwGetMonitorName(monitor),
|
glfwGetMonitorName(monitor),
|
||||||
glfwGetPrimaryMonitor() == monitor ? "primary" : "secondary");
|
glfwGetPrimaryMonitor() == monitor ? "primary" : "secondary");
|
||||||
printf("Current mode: %s\n", format_mode(mode));
|
printf("Current mode: %s\n", format_mode(mode));
|
||||||
printf("Virtual position: %i %i\n", x, y);
|
printf("Virtual position: %i, %i\n", x, y);
|
||||||
printf("Content scale: %f %f\n", xscale, yscale);
|
printf("Content scale: %f x %f\n", xscale, yscale);
|
||||||
|
|
||||||
printf("Physical size: %i x %i mm (%0.2f dpi)\n",
|
printf("Physical size: %i x %i mm (%0.2f dpi at %i x %i)\n",
|
||||||
width_mm, height_mm, mode->width * 25.4f / width_mm);
|
width_mm, height_mm, mode->width * 25.4f / width_mm, mode->width, mode->height);
|
||||||
printf("Monitor work area: pos=(%d,%d) size=(%dx%d)\n",
|
printf("Monitor work area: %i x %i starting at %i, %i\n",
|
||||||
workarea_x, workarea_y, workarea_width, workarea_height);
|
workarea_width, workarea_height, workarea_x, workarea_y);
|
||||||
|
|
||||||
printf("Modes:\n");
|
printf("Modes:\n");
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
#include <glad/gl.h>
|
#include <glad/gl.h>
|
||||||
|
#define GLFW_INCLUDE_NONE
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
|
|
||||||
#if defined(_MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
#include <glad/gl.h>
|
#include <glad/gl.h>
|
||||||
|
#define GLFW_INCLUDE_NONE
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
|
|
||||||
#define NK_IMPLEMENTATION
|
#define NK_IMPLEMENTATION
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
#include <glad/gl.h>
|
#include <glad/gl.h>
|
||||||
|
#define GLFW_INCLUDE_NONE
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
#include <glad/gl.h>
|
#include <glad/gl.h>
|
||||||
|
#define GLFW_INCLUDE_NONE
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -68,14 +69,6 @@ static int swap_tear;
|
||||||
static int swap_interval;
|
static int swap_interval;
|
||||||
static double frame_rate;
|
static double frame_rate;
|
||||||
|
|
||||||
static void usage(void)
|
|
||||||
{
|
|
||||||
printf("Usage: tearing [-f] [-h]\n");
|
|
||||||
printf("Options:\n");
|
|
||||||
printf(" -f use full screen\n");
|
|
||||||
printf(" -h show this help\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
static void update_window_title(GLFWwindow* window)
|
static void update_window_title(GLFWwindow* window)
|
||||||
{
|
{
|
||||||
char title[256];
|
char title[256];
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
#include "tinycthread.h"
|
#include "tinycthread.h"
|
||||||
|
|
||||||
#include <glad/gl.h>
|
#include <glad/gl.h>
|
||||||
|
#define GLFW_INCLUDE_NONE
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
#include <glad/gl.h>
|
#include <glad/gl.h>
|
||||||
|
#define GLFW_INCLUDE_NONE
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
#include <glad/gl.h>
|
#include <glad/gl.h>
|
||||||
|
#define GLFW_INCLUDE_NONE
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
|
@ -2177,6 +2177,7 @@ static void demo_resize(struct demo *demo) {
|
||||||
|
|
||||||
if (demo->setup_cmd) {
|
if (demo->setup_cmd) {
|
||||||
vkFreeCommandBuffers(demo->device, demo->cmd_pool, 1, &demo->setup_cmd);
|
vkFreeCommandBuffers(demo->device, demo->cmd_pool, 1, &demo->setup_cmd);
|
||||||
|
demo->setup_cmd = VK_NULL_HANDLE;
|
||||||
}
|
}
|
||||||
vkFreeCommandBuffers(demo->device, demo->cmd_pool, 1, &demo->draw_cmd);
|
vkFreeCommandBuffers(demo->device, demo->cmd_pool, 1, &demo->draw_cmd);
|
||||||
vkDestroyCommandPool(demo->device, demo->cmd_pool, NULL);
|
vkDestroyCommandPool(demo->device, demo->cmd_pool, NULL);
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user