mirror of
https://github.com/glfw/glfw.git
synced 2024-11-26 14:24:35 +00:00
Merge branch 'master' into multi-context-windows-merge-master
This commit is contained in:
commit
c97e3a657b
41
.github/workflows/build.yml
vendored
41
.github/workflows/build.yml
vendored
@ -31,8 +31,8 @@ jobs:
|
||||
- name: Build shared library
|
||||
run: cmake --build build-shared --parallel
|
||||
|
||||
build-linux-wayland-clang:
|
||||
name: Wayland (Linux, Clang)
|
||||
build-linux-full-clang:
|
||||
name: X11+Wayland (Linux, Clang)
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
CC: clang
|
||||
@ -42,38 +42,15 @@ jobs:
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
sudo apt update
|
||||
sudo apt install wayland-protocols libwayland-dev libxkbcommon-dev
|
||||
sudo apt install libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev libxext-dev wayland-protocols libwayland-dev libxkbcommon-dev
|
||||
|
||||
- name: Configure static library
|
||||
run: cmake -S . -B build-static -D GLFW_USE_WAYLAND=ON
|
||||
run: cmake -S . -B build-static -D GLFW_BUILD_WAYLAND=ON
|
||||
- name: Build static library
|
||||
run: cmake --build build-static --parallel
|
||||
|
||||
- name: Configure shared library
|
||||
run: cmake -S . -B build-shared -D GLFW_USE_WAYLAND=ON -D BUILD_SHARED_LIBS=ON
|
||||
- name: Build shared library
|
||||
run: cmake --build build-shared --parallel
|
||||
|
||||
build-linux-null-clang:
|
||||
name: Null (Linux, Clang)
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
CC: clang
|
||||
CFLAGS: -Werror
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
sudo apt update
|
||||
sudo apt install libosmesa6-dev
|
||||
|
||||
- name: Configure static library
|
||||
run: cmake -S . -B build-static -D GLFW_USE_OSMESA=ON
|
||||
- name: Build static library
|
||||
run: cmake --build build-static --parallel
|
||||
|
||||
- name: Configure shared library
|
||||
run: cmake -S . -B build-shared -D GLFW_USE_OSMESA=ON -D BUILD_SHARED_LIBS=ON
|
||||
run: cmake -S . -B build-shared -D GLFW_BUILD_WAYLAND=ON -D BUILD_SHARED_LIBS=ON
|
||||
- name: Build shared library
|
||||
run: cmake --build build-shared --parallel
|
||||
|
||||
@ -96,8 +73,8 @@ jobs:
|
||||
- name: Build shared library
|
||||
run: cmake --build build-shared --parallel
|
||||
|
||||
build-windows-win32-vs2019:
|
||||
name: Win32 (Windows, VS2019)
|
||||
build-windows-win32-vs2022:
|
||||
name: Win32 (Windows, VS2022)
|
||||
runs-on: windows-latest
|
||||
env:
|
||||
CFLAGS: /WX
|
||||
@ -105,12 +82,12 @@ jobs:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Configure static library
|
||||
run: cmake -S . -B build-static -G "Visual Studio 16 2019"
|
||||
run: cmake -S . -B build-static -G "Visual Studio 17 2022"
|
||||
- name: Build static library
|
||||
run: cmake --build build-static --parallel
|
||||
|
||||
- name: Configure shared library
|
||||
run: cmake -S . -B build-shared -G "Visual Studio 16 2019" -D BUILD_SHARED_LIBS=ON
|
||||
run: cmake -S . -B build-shared -G "Visual Studio 17 2022" -D BUILD_SHARED_LIBS=ON
|
||||
- name: Build shared library
|
||||
run: cmake --build build-shared --parallel
|
||||
|
||||
|
212
CMakeLists.txt
212
CMakeLists.txt
@ -27,17 +27,22 @@ option(GLFW_BUILD_EXAMPLES "Build the GLFW example programs" ${GLFW_STANDALONE})
|
||||
option(GLFW_BUILD_TESTS "Build the GLFW test programs" ${GLFW_STANDALONE})
|
||||
option(GLFW_BUILD_DOCS "Build the GLFW documentation" ON)
|
||||
option(GLFW_INSTALL "Generate installation target" ON)
|
||||
option(GLFW_VULKAN_STATIC "Assume the Vulkan loader is linked with the application" OFF)
|
||||
|
||||
include(GNUInstallDirs)
|
||||
include(CMakeDependentOption)
|
||||
|
||||
cmake_dependent_option(GLFW_USE_OSMESA "Use OSMesa for offscreen context creation" OFF
|
||||
"UNIX" OFF)
|
||||
if (GLFW_USE_OSMESA)
|
||||
message(FATAL_ERROR "GLFW_USE_OSMESA has been removed; set the GLFW_PLATFORM init hint")
|
||||
endif()
|
||||
|
||||
cmake_dependent_option(GLFW_BUILD_WIN32 "Build support for Win32" ON "WIN32" OFF)
|
||||
cmake_dependent_option(GLFW_BUILD_COCOA "Build support for Cocoa" ON "APPLE" OFF)
|
||||
cmake_dependent_option(GLFW_BUILD_X11 "Build support for X11" ON "UNIX;NOT APPLE" OFF)
|
||||
cmake_dependent_option(GLFW_BUILD_WAYLAND "Build support for Wayland"
|
||||
"${GLFW_USE_WAYLAND}" "UNIX;NOT APPLE" OFF)
|
||||
|
||||
cmake_dependent_option(GLFW_USE_HYBRID_HPG "Force use of high-performance GPU on hybrid systems" OFF
|
||||
"WIN32" OFF)
|
||||
cmake_dependent_option(GLFW_USE_WAYLAND "Use Wayland for window creation" OFF
|
||||
"UNIX;NOT APPLE" OFF)
|
||||
cmake_dependent_option(USE_MSVC_RUNTIME_LIBRARY_DLL "Use MSVC runtime library DLL" ON
|
||||
"MSVC" OFF)
|
||||
|
||||
@ -54,22 +59,6 @@ else()
|
||||
set(GLFW_BUILD_SHARED_LIBRARY ${BUILD_SHARED_LIBS})
|
||||
endif()
|
||||
|
||||
if (UNIX AND GLFW_BUILD_SHARED_LIBRARY)
|
||||
# On Unix-like systems, shared libraries can use the soname system.
|
||||
set(GLFW_LIB_NAME glfw)
|
||||
else()
|
||||
set(GLFW_LIB_NAME glfw3)
|
||||
endif()
|
||||
|
||||
if (GLFW_VULKAN_STATIC)
|
||||
if (GLFW_BUILD_SHARED_LIBRARY)
|
||||
# If you absolutely must do this, remove this line and add the Vulkan
|
||||
# loader static library via the CMAKE_SHARED_LINKER_FLAGS
|
||||
message(FATAL_ERROR "You are trying to link the Vulkan loader static library into the GLFW shared library")
|
||||
endif()
|
||||
set(_GLFW_VULKAN_STATIC 1)
|
||||
endif()
|
||||
|
||||
list(APPEND CMAKE_MODULE_PATH "${GLFW_SOURCE_DIR}/CMake/modules")
|
||||
|
||||
find_package(Threads REQUIRED)
|
||||
@ -79,6 +68,22 @@ if (GLFW_BUILD_DOCS)
|
||||
find_package(Doxygen)
|
||||
endif()
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# Report backend selection
|
||||
#--------------------------------------------------------------------
|
||||
if (GLFW_BUILD_WIN32)
|
||||
message(STATUS "Including Win32 support")
|
||||
endif()
|
||||
if (GLFW_BUILD_COCOA)
|
||||
message(STATUS "Including Cocoa support")
|
||||
endif()
|
||||
if (GLFW_BUILD_WAYLAND)
|
||||
message(STATUS "Including Wayland support")
|
||||
endif()
|
||||
if (GLFW_BUILD_X11)
|
||||
message(STATUS "Including X11 support")
|
||||
endif()
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# Apply Microsoft C runtime library option
|
||||
# This is here because it also applies to tests and examples
|
||||
@ -104,169 +109,6 @@ if (MSVC AND NOT USE_MSVC_RUNTIME_LIBRARY_DLL)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# Detect and select backend APIs
|
||||
#--------------------------------------------------------------------
|
||||
if (GLFW_USE_WAYLAND)
|
||||
set(_GLFW_WAYLAND 1)
|
||||
message(STATUS "Using Wayland for window creation")
|
||||
elseif (GLFW_USE_OSMESA)
|
||||
set(_GLFW_OSMESA 1)
|
||||
message(STATUS "Using OSMesa for headless context creation")
|
||||
elseif (WIN32)
|
||||
set(_GLFW_WIN32 1)
|
||||
message(STATUS "Using Win32 for window creation")
|
||||
elseif (APPLE)
|
||||
set(_GLFW_COCOA 1)
|
||||
message(STATUS "Using Cocoa for window creation")
|
||||
elseif (UNIX)
|
||||
set(_GLFW_X11 1)
|
||||
message(STATUS "Using X11 for window creation")
|
||||
else()
|
||||
message(FATAL_ERROR "No supported platform was detected")
|
||||
endif()
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# Find and add Unix math and time libraries
|
||||
#--------------------------------------------------------------------
|
||||
if (UNIX AND NOT APPLE)
|
||||
find_library(RT_LIBRARY rt)
|
||||
mark_as_advanced(RT_LIBRARY)
|
||||
if (RT_LIBRARY)
|
||||
list(APPEND glfw_LIBRARIES "${RT_LIBRARY}")
|
||||
list(APPEND glfw_PKG_LIBS "-lrt")
|
||||
endif()
|
||||
|
||||
find_library(MATH_LIBRARY m)
|
||||
mark_as_advanced(MATH_LIBRARY)
|
||||
if (MATH_LIBRARY)
|
||||
list(APPEND glfw_LIBRARIES "${MATH_LIBRARY}")
|
||||
list(APPEND glfw_PKG_LIBS "-lm")
|
||||
endif()
|
||||
|
||||
if (CMAKE_DL_LIBS)
|
||||
list(APPEND glfw_LIBRARIES "${CMAKE_DL_LIBS}")
|
||||
list(APPEND glfw_PKG_LIBS "-l${CMAKE_DL_LIBS}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# Use Win32 for window creation
|
||||
#--------------------------------------------------------------------
|
||||
if (_GLFW_WIN32)
|
||||
|
||||
list(APPEND glfw_PKG_LIBS "-lgdi32")
|
||||
|
||||
if (GLFW_USE_HYBRID_HPG)
|
||||
set(_GLFW_USE_HYBRID_HPG 1)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# Use X11 for window creation
|
||||
#--------------------------------------------------------------------
|
||||
if (_GLFW_X11)
|
||||
|
||||
find_package(X11 REQUIRED)
|
||||
|
||||
# Set up library and include paths
|
||||
list(APPEND glfw_INCLUDE_DIRS "${X11_X11_INCLUDE_PATH}")
|
||||
|
||||
# Check for XRandR (modern resolution switching and gamma control)
|
||||
if (NOT X11_Xrandr_INCLUDE_PATH)
|
||||
message(FATAL_ERROR "RandR headers not found; install libxrandr development package")
|
||||
endif()
|
||||
|
||||
# Check for Xinerama (legacy multi-monitor support)
|
||||
if (NOT X11_Xinerama_INCLUDE_PATH)
|
||||
message(FATAL_ERROR "Xinerama headers not found; install libxinerama development package")
|
||||
endif()
|
||||
|
||||
# Check for Xkb (X keyboard extension)
|
||||
if (NOT X11_Xkb_INCLUDE_PATH)
|
||||
message(FATAL_ERROR "XKB headers not found; install X11 development package")
|
||||
endif()
|
||||
|
||||
# Check for Xcursor (cursor creation from RGBA images)
|
||||
if (NOT X11_Xcursor_INCLUDE_PATH)
|
||||
message(FATAL_ERROR "Xcursor headers not found; install libxcursor development package")
|
||||
endif()
|
||||
|
||||
# Check for XInput (modern HID input)
|
||||
if (NOT X11_Xi_INCLUDE_PATH)
|
||||
message(FATAL_ERROR "XInput headers not found; install libxi development package")
|
||||
endif()
|
||||
|
||||
# Check for X Shape (custom window input shape)
|
||||
if (NOT X11_Xshape_INCLUDE_PATH)
|
||||
message(FATAL_ERROR "X Shape headers not found; install libxext development package")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# Use Wayland for window creation
|
||||
#--------------------------------------------------------------------
|
||||
if (_GLFW_WAYLAND)
|
||||
|
||||
include(FindPkgConfig)
|
||||
pkg_check_modules(Wayland REQUIRED
|
||||
wayland-client>=0.2.7
|
||||
wayland-cursor>=0.2.7
|
||||
wayland-egl>=0.2.7
|
||||
xkbcommon)
|
||||
|
||||
list(APPEND glfw_INCLUDE_DIRS "${Wayland_INCLUDE_DIRS}")
|
||||
|
||||
include(CheckIncludeFiles)
|
||||
include(CheckFunctionExists)
|
||||
check_include_files(xkbcommon/xkbcommon-compose.h HAVE_XKBCOMMON_COMPOSE_H)
|
||||
check_function_exists(memfd_create HAVE_MEMFD_CREATE)
|
||||
|
||||
if (NOT CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
find_package(EpollShim)
|
||||
if (EPOLLSHIM_FOUND)
|
||||
list(APPEND glfw_INCLUDE_DIRS "${EPOLLSHIM_INCLUDE_DIRS}")
|
||||
list(APPEND glfw_LIBRARIES "${EPOLLSHIM_LIBRARIES}")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# Use Cocoa for window creation and NSOpenGL for context creation
|
||||
#--------------------------------------------------------------------
|
||||
if (_GLFW_COCOA)
|
||||
|
||||
list(APPEND glfw_LIBRARIES
|
||||
"-framework Cocoa"
|
||||
"-framework IOKit"
|
||||
"-framework CoreFoundation")
|
||||
|
||||
set(glfw_PKG_DEPS "")
|
||||
set(glfw_PKG_LIBS "-framework Cocoa -framework IOKit -framework CoreFoundation")
|
||||
endif()
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# Add the Vulkan loader as a dependency if necessary
|
||||
#--------------------------------------------------------------------
|
||||
if (GLFW_VULKAN_STATIC)
|
||||
list(APPEND glfw_PKG_DEPS "vulkan")
|
||||
endif()
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# Export GLFW library dependencies
|
||||
#--------------------------------------------------------------------
|
||||
foreach(arg ${glfw_PKG_DEPS})
|
||||
string(APPEND deps " ${arg}")
|
||||
endforeach()
|
||||
foreach(arg ${glfw_PKG_LIBS})
|
||||
string(APPEND libs " ${arg}")
|
||||
endforeach()
|
||||
|
||||
set(GLFW_PKG_CONFIG_REQUIRES_PRIVATE "${deps}" CACHE INTERNAL
|
||||
"GLFW pkg-config Requires.private")
|
||||
set(GLFW_PKG_CONFIG_LIBS_PRIVATE "${libs}" CACHE INTERNAL
|
||||
"GLFW pkg-config Libs.private")
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# Create generated files
|
||||
#--------------------------------------------------------------------
|
||||
@ -283,8 +125,6 @@ write_basic_package_version_file(src/glfw3ConfigVersion.cmake
|
||||
VERSION ${GLFW_VERSION}
|
||||
COMPATIBILITY SameMajorVersion)
|
||||
|
||||
configure_file(CMake/glfw3.pc.in src/glfw3.pc @ONLY)
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# Add subdirectories
|
||||
#--------------------------------------------------------------------
|
||||
|
246
CONTRIBUTORS.md
Normal file
246
CONTRIBUTORS.md
Normal file
@ -0,0 +1,246 @@
|
||||
# Acknowledgements
|
||||
|
||||
GLFW exists because people around the world donated their time and lent their
|
||||
skills. This list only includes contributions to the main repository and
|
||||
excludes other invaluable contributions like language bindings and text and
|
||||
video tutorials.
|
||||
|
||||
- Bobyshev Alexander
|
||||
- Laurent Aphecetche
|
||||
- Matt Arsenault
|
||||
- ashishgamedev
|
||||
- David Avedissian
|
||||
- Luca Bacci
|
||||
- Keith Bauer
|
||||
- John Bartholomew
|
||||
- Coşku Baş
|
||||
- Niklas Behrens
|
||||
- Andrew Belt
|
||||
- Nevyn Bengtsson
|
||||
- Niklas Bergström
|
||||
- Denis Bernard
|
||||
- Doug Binks
|
||||
- blanco
|
||||
- Waris Boonyasiriwat
|
||||
- Kyle Brenneman
|
||||
- Rok Breulj
|
||||
- Kai Burjack
|
||||
- Martin Capitanio
|
||||
- Nicolas Caramelli
|
||||
- David Carlier
|
||||
- Arturo Castro
|
||||
- Chi-kwan Chan
|
||||
- TheChocolateOre
|
||||
- Joseph Chua
|
||||
- Ian Clarkson
|
||||
- Michał Cichoń
|
||||
- Lambert Clara
|
||||
- Anna Clarke
|
||||
- Josh Codd
|
||||
- Yaron Cohen-Tal
|
||||
- Omar Cornut
|
||||
- Andrew Corrigan
|
||||
- Bailey Cosier
|
||||
- Noel Cower
|
||||
- CuriouserThing
|
||||
- Jason Daly
|
||||
- Jarrod Davis
|
||||
- Olivier Delannoy
|
||||
- Paul R. Deppe
|
||||
- Michael Dickens
|
||||
- Роман Донченко
|
||||
- Mario Dorn
|
||||
- Wolfgang Draxinger
|
||||
- Jonathan Dummer
|
||||
- Ralph Eastwood
|
||||
- Fredrik Ehnbom
|
||||
- Robin Eklind
|
||||
- Jan Ekström
|
||||
- Siavash Eliasi
|
||||
- Ahmad Fatoum
|
||||
- Felipe Ferreira
|
||||
- Michael Fogleman
|
||||
- Jason Francis
|
||||
- Gerald Franz
|
||||
- Mário Freitas
|
||||
- GeO4d
|
||||
- Marcus Geelnard
|
||||
- ghuser404
|
||||
- Charles Giessen
|
||||
- Ryan C. Gordon
|
||||
- Stephen Gowen
|
||||
- Kovid Goyal
|
||||
- Kevin Grandemange
|
||||
- Eloi Marín Gratacós
|
||||
- Stefan Gustavson
|
||||
- Andrew Gutekanst
|
||||
- Stephen Gutekanst
|
||||
- Jonathan Hale
|
||||
- hdf89shfdfs
|
||||
- Sylvain Hellegouarch
|
||||
- Matthew Henry
|
||||
- heromyth
|
||||
- Lucas Hinderberger
|
||||
- Paul Holden
|
||||
- Warren Hu
|
||||
- Charles Huber
|
||||
- Brent Huisman
|
||||
- illustris
|
||||
- InKryption
|
||||
- IntellectualKitty
|
||||
- Aaron Jacobs
|
||||
- JannikGM
|
||||
- Erik S. V. Jansson
|
||||
- jjYBdx4IL
|
||||
- Toni Jovanoski
|
||||
- Arseny Kapoulkine
|
||||
- Cem Karan
|
||||
- Osman Keskin
|
||||
- Koray Kilinc
|
||||
- Josh Kilmer
|
||||
- Byunghoon Kim
|
||||
- Cameron King
|
||||
- Peter Knut
|
||||
- Christoph Kubisch
|
||||
- Yuri Kunde Schlesner
|
||||
- Rokas Kupstys
|
||||
- Konstantin Käfer
|
||||
- Eric Larson
|
||||
- Francis Lecavalier
|
||||
- Jong Won Lee
|
||||
- Robin Leffmann
|
||||
- Glenn Lewis
|
||||
- Shane Liesegang
|
||||
- Anders Lindqvist
|
||||
- Leon Linhart
|
||||
- Marco Lizza
|
||||
- Eyal Lotem
|
||||
- Aaron Loucks
|
||||
- Luflosi
|
||||
- lukect
|
||||
- Tristam MacDonald
|
||||
- Hans Mackowiak
|
||||
- Дмитри Малышев
|
||||
- Zbigniew Mandziejewicz
|
||||
- Adam Marcus
|
||||
- Célestin Marot
|
||||
- Kyle McDonald
|
||||
- David V. McKay
|
||||
- David Medlock
|
||||
- Bryce Mehring
|
||||
- Jonathan Mercier
|
||||
- Marcel Metz
|
||||
- Liam Middlebrook
|
||||
- Ave Milia
|
||||
- Jonathan Miller
|
||||
- Kenneth Miller
|
||||
- Bruce Mitchener
|
||||
- Jack Moffitt
|
||||
- Jeff Molofee
|
||||
- Alexander Monakov
|
||||
- Pierre Morel
|
||||
- Jon Morton
|
||||
- Pierre Moulon
|
||||
- Martins Mozeiko
|
||||
- Pascal Muetschard
|
||||
- Julian Møller
|
||||
- ndogxj
|
||||
- n3rdopolis
|
||||
- Kristian Nielsen
|
||||
- Kamil Nowakowski
|
||||
- onox
|
||||
- Denis Ovod
|
||||
- Ozzy
|
||||
- Andri Pálsson
|
||||
- luz paz
|
||||
- Peoro
|
||||
- Braden Pellett
|
||||
- Christopher Pelloux
|
||||
- Arturo J. Pérez
|
||||
- Vladimir Perminov
|
||||
- Anthony Pesch
|
||||
- Orson Peters
|
||||
- Emmanuel Gil Peyrot
|
||||
- Cyril Pichard
|
||||
- Keith Pitt
|
||||
- Stanislav Podgorskiy
|
||||
- Konstantin Podsvirov
|
||||
- Nathan Poirier
|
||||
- Alexandre Pretyman
|
||||
- Pablo Prietz
|
||||
- przemekmirek
|
||||
- pthom
|
||||
- Guillaume Racicot
|
||||
- Philip Rideout
|
||||
- Eddie Ringle
|
||||
- Max Risuhin
|
||||
- Jorge Rodriguez
|
||||
- Jari Ronkainen
|
||||
- Luca Rood
|
||||
- Ed Ropple
|
||||
- Aleksey Rybalkin
|
||||
- Mikko Rytkönen
|
||||
- Riku Salminen
|
||||
- Brandon Schaefer
|
||||
- Sebastian Schuberth
|
||||
- Christian Sdunek
|
||||
- Matt Sealey
|
||||
- Steve Sexton
|
||||
- Arkady Shapkin
|
||||
- Ali Sherief
|
||||
- Yoshiki Shibukawa
|
||||
- Dmitri Shuralyov
|
||||
- Joao da Silva
|
||||
- Daniel Sieger
|
||||
- Daniel Skorupski
|
||||
- Slemmie
|
||||
- Anthony Smith
|
||||
- Bradley Smith
|
||||
- Cliff Smolinsky
|
||||
- Patrick Snape
|
||||
- Erlend Sogge Heggen
|
||||
- Olivier Sohn
|
||||
- Julian Squires
|
||||
- Johannes Stein
|
||||
- Pontus Stenetorp
|
||||
- Michael Stocker
|
||||
- Justin Stoecker
|
||||
- Elviss Strazdins
|
||||
- Paul Sultana
|
||||
- Nathan Sweet
|
||||
- TTK-Bandit
|
||||
- Jared Tiala
|
||||
- Sergey Tikhomirov
|
||||
- Arthur Tombs
|
||||
- TronicLabs
|
||||
- Ioannis Tsakpinis
|
||||
- Samuli Tuomola
|
||||
- Matthew Turner
|
||||
- urraka
|
||||
- Elias Vanderstuyft
|
||||
- Stef Velzel
|
||||
- Jari Vetoniemi
|
||||
- Ricardo Vieira
|
||||
- Nicholas Vitovitch
|
||||
- Simon Voordouw
|
||||
- Corentin Wallez
|
||||
- Torsten Walluhn
|
||||
- Patrick Walton
|
||||
- Xo Wang
|
||||
- Jay Weisskopf
|
||||
- Frank Wille
|
||||
- Andy Williams
|
||||
- Joel Winarske
|
||||
- Richard A. Wilkes
|
||||
- Tatsuya Yatagawa
|
||||
- Ryogo Yoshimura
|
||||
- Lukas Zanner
|
||||
- Andrey Zholos
|
||||
- Aihui Zhu
|
||||
- Santi Zupancic
|
||||
- Jonas Ådahl
|
||||
- Lasse Öörni
|
||||
- Leonard König
|
||||
- All the unmentioned and anonymous contributors in the GLFW community, for bug
|
||||
reports, patches, feedback, testing and encouragement
|
||||
|
297
README.md
297
README.md
@ -39,6 +39,11 @@ you have used GLFW 2 in the past, there is a [transition
|
||||
guide](https://www.glfw.org/docs/latest/moving.html) for moving to the GLFW
|
||||
3 API.
|
||||
|
||||
GLFW exists because of the contributions of [many people](CONTRIBUTORS.md)
|
||||
around the world, whether by reporting bugs, providing community support, adding
|
||||
features, reviewing or testing code, debugging, proofreading docs, suggesting
|
||||
features or fixing bugs.
|
||||
|
||||
|
||||
## Compiling GLFW
|
||||
|
||||
@ -116,12 +121,21 @@ information on what to include when reporting a bug.
|
||||
|
||||
## Changelog
|
||||
|
||||
|
||||
- Added OpenGL and OpenGL ES user contexts for multiple window contexts via
|
||||
`GLFWusercontext`, `glfwCreateUserContext`, `glfwDestroyUserContext`,
|
||||
`glfwMakeUserContextCurrent`, `glfwGetCurrentUserContext` (#1687)
|
||||
`glfwMakeUserContextCurrent`, `glfwGetCurrentUserContext` (#1687)
|
||||
- Added `GLFW_PLATFORM` init hint for runtime platform selection (#1958)
|
||||
- Added `GLFW_ANY_PLATFORM`, `GLFW_PLATFORM_WIN32`, `GLFW_PLATFORM_COCOA`,
|
||||
`GLFW_PLATFORM_WAYLAND`, `GLFW_PLATFORM_X11` and `GLFW_PLATFORM_NULL` symbols to
|
||||
specify the desired platform (#1958)
|
||||
- Added `glfwGetPlatform` function to query what platform was selected (#1655,#1958)
|
||||
- Added `glfwPlatformSupported` function to query if a platform is supported
|
||||
(#1655,#1958)
|
||||
- Added `glfwInitAllocator` for setting a custom memory allocator (#544,#1628,#1947)
|
||||
- Added `GLFWallocator` struct and `GLFWallocatefun`, `GLFWreallocatefun` and
|
||||
`GLFWdeallocatefun` types (#544,#1628,#1947)
|
||||
- Added `glfwInitVulkanLoader` for using a non-default Vulkan loader (#1374,#1890)
|
||||
- Added `GLFW_RESIZE_NWSE_CURSOR`, `GLFW_RESIZE_NESW_CURSOR`,
|
||||
`GLFW_RESIZE_ALL_CURSOR` and `GLFW_NOT_ALLOWED_CURSOR` cursor shapes (#427)
|
||||
- Added `GLFW_RESIZE_EW_CURSOR` alias for `GLFW_HRESIZE_CURSOR` (#427)
|
||||
@ -129,12 +143,16 @@ information on what to include when reporting a bug.
|
||||
- Added `GLFW_POINTING_HAND_CURSOR` alias for `GLFW_HAND_CURSOR` (#427)
|
||||
- Added `GLFW_MOUSE_PASSTHROUGH` window hint for letting mouse input pass
|
||||
through the window (#1236,#1568)
|
||||
- Added `GLFW_PLATFORM_UNAVAILABLE` error for platform detection failures (#1958)
|
||||
- Added `GLFW_FEATURE_UNAVAILABLE` error for platform limitations (#1692)
|
||||
- Added `GLFW_FEATURE_UNIMPLEMENTED` error for incomplete backends (#1692)
|
||||
- Added `GLFW_ANGLE_PLATFORM_TYPE` init hint and `GLFW_ANGLE_PLATFORM_TYPE_*`
|
||||
values to select ANGLE backend (#1380)
|
||||
- Added `GLFW_X11_XCB_VULKAN_SURFACE` init hint for selecting X11 Vulkan
|
||||
surface extension (#1793)
|
||||
- Added `GLFW_BUILD_WIN32` CMake option for enabling Win32 support (#1958)
|
||||
- Added `GLFW_BUILD_COCOA` CMake option for enabling Cocoa support (#1958)
|
||||
- Added `GLFW_BUILD_X11` CMake option for enabling X11 support (#1958)
|
||||
- Added `GLFW_LIBRARY_TYPE` CMake variable for overriding the library type
|
||||
(#279,#1307,#1497,#1574,#1928)
|
||||
- Added `GLFW_PKG_CONFIG_REQUIRES_PRIVATE` and `GLFW_PKG_CONFIG_LIBS_PRIVATE` CMake
|
||||
@ -142,7 +160,11 @@ information on what to include when reporting a bug.
|
||||
- Made joystick subsystem initialize at first use (#1284,#1646)
|
||||
- Made `GLFW_DOUBLEBUFFER` a read-only window attribute
|
||||
- Updated the minimum required CMake version to 3.1
|
||||
- Updated gamepad mappings from upstream
|
||||
- Disabled tests and examples by default when built as a CMake subdirectory
|
||||
- Renamed `GLFW_USE_WAYLAND` CMake option to `GLFW_BUILD_WAYLAND` (#1958)
|
||||
- Removed `GLFW_USE_OSMESA` CMake option enabling the Null platform (#1958)
|
||||
- Removed CMake generated configuration header
|
||||
- Bugfix: The CMake config-file package used an absolute path and was not
|
||||
relocatable (#1470)
|
||||
- Bugfix: Video modes with a duplicate screen area were discarded (#1555,#1556)
|
||||
@ -153,6 +175,7 @@ information on what to include when reporting a bug.
|
||||
- Bugfix: Buffers were swapped at creation on single-buffered windows (#1873)
|
||||
- Bugfix: Gamepad mapping updates could spam `GLFW_INVALID_VALUE` due to
|
||||
incompatible controllers sharing hardware ID (#1763)
|
||||
- Bugfix: Native access functions for context handles did not check that the API matched
|
||||
- [Win32] Added the `GLFW_WIN32_KEYBOARD_MENU` window hint for enabling access
|
||||
to the window menu
|
||||
- [Win32] Added a version info resource to the GLFW DLL
|
||||
@ -183,6 +206,19 @@ information on what to include when reporting a bug.
|
||||
later (#1783,#1796)
|
||||
- [Win32] Bugfix: Compilation with LLVM for Windows failed (#1807,#1824,#1874)
|
||||
- [Win32] Bugfix: The foreground lock timeout was overridden, ignoring the user
|
||||
- [Win32] Bugfix: Content scale queries could fail silently (#1615)
|
||||
- [Win32] Bugfix: Content scales could have garbage values if monitor was recently
|
||||
disconnected (#1615)
|
||||
- [Win32] Bugfix: A window created maximized and undecorated would cover the whole
|
||||
monitor (#1806)
|
||||
- [Win32] Bugfix: The default restored window position was lost when creating a maximized
|
||||
window
|
||||
- [Win32] Bugfix: `glfwMaximizeWindow` would make a hidden window visible
|
||||
- [Win32] Bugfix: `Alt+PrtSc` would emit `GLFW_KEY_UNKNOWN` and a different
|
||||
scancode than `PrtSc` (#1993)
|
||||
- [Win32] Bugfix: `GLFW_KEY_PAUSE` scancode from `glfwGetKeyScancode` did not
|
||||
match event scancode (#1993)
|
||||
- [Win32] Bugfix: Instance-local operations used executable instance (#469,#1296,#1395)
|
||||
- [Cocoa] Added support for `VK_EXT_metal_surface` (#1619)
|
||||
- [Cocoa] Added locating the Vulkan loader at runtime in an application bundle
|
||||
- [Cocoa] Moved main menu creation to GLFW initialization time (#1649)
|
||||
@ -203,12 +239,17 @@ information on what to include when reporting a bug.
|
||||
could leak memory
|
||||
- [Cocoa] Bugfix: Objective-C files were compiled as C with CMake 3.19 (#1787)
|
||||
- [Cocoa] Bugfix: Duplicate video modes were not filtered out (#1830)
|
||||
- [Cocoa] Bugfix: Menubar was not clickable on macOS 10.15+ until it lost and
|
||||
- [Cocoa] Bugfix: Menu bar was not clickable on macOS 10.15+ until it lost and
|
||||
regained focus (#1648,#1802)
|
||||
- [Cocoa] Bugfix: Monitor name query could segfault on macOS 11 (#1809,#1833)
|
||||
- [Cocoa] Bugfix: The install name of the installed dylib was relative (#1504)
|
||||
- [Cocoa] Bugfix: The MoltenVK layer contents scale was updated only after
|
||||
related events were emitted
|
||||
- [Cocoa] Bugfix: Moving the cursor programmatically would freeze it for
|
||||
a fraction of a second (#1962)
|
||||
- [Cocoa] Bugfix: `kIOMasterPortDefault` was deprecated in macOS 12.0 (#1980)
|
||||
- [Cocoa] Bugfix: `kUTTypeURL` was deprecated in macOS 12.0 (#2003)
|
||||
- [Cocoa] Bugfix: A connected Apple AirPlay would emit a useless error (#1791)
|
||||
- [X11] Bugfix: The CMake files did not check for the XInput headers (#1480)
|
||||
- [X11] Bugfix: Key names were not updated when the keyboard layout changed
|
||||
(#1462,#1528)
|
||||
@ -231,13 +272,25 @@ information on what to include when reporting a bug.
|
||||
- [X11] Bugfix: XKB path used keysyms instead of physical locations for
|
||||
non-printable keys (#1598)
|
||||
- [X11] Bugfix: Function keys were mapped to `GLFW_KEY_UNKNOWN` for some layout
|
||||
combinaitons (#1598)
|
||||
combinations (#1598)
|
||||
- [X11] Bugfix: Keys pressed simultaneously with others were not always
|
||||
reported (#1112,#1415,#1472,#1616)
|
||||
- [X11] Bugfix: Some window attributes were not applied on leaving fullscreen
|
||||
(#1863)
|
||||
- [X11] Bugfix: Changing `GLFW_FLOATING` could leak memory
|
||||
- [X11] Bugfix: Icon pixel format conversion worked only by accident, relying on
|
||||
undefined behavior (#1986)
|
||||
- [X11] Bugfix: Dynamic loading on OpenBSD failed due to soname differences
|
||||
- [X11] Bugfix: Waiting for events would fail if file descriptor was too large
|
||||
(#2024)
|
||||
- [X11] Bugfix: Joystick events could lead to busy-waiting (#1872)
|
||||
- [X11] Bugfix: `glfwWaitEvents*` did not continue for joystick events
|
||||
- [X11] Bugfix: `glfwPostEmptyEvent` could be ignored due to race condition
|
||||
(#379,#1281,#1285,#2033)
|
||||
- [X11] Bugfix: Dynamic loading on NetBSD failed due to soname differences
|
||||
- [X11] Bugfix: Left shift of int constant relied on undefined behavior (#1951)
|
||||
- [Wayland] Added dynamic loading of all Wayland libraries
|
||||
- [Wayland] Added support for key names via xkbcommon
|
||||
- [Wayland] Removed support for `wl_shell` (#1443)
|
||||
- [Wayland] Bugfix: The `GLFW_HAND_CURSOR` shape used the wrong image (#1432)
|
||||
- [Wayland] Bugfix: `CLOCK_MONOTONIC` was not correctly enabled
|
||||
@ -245,13 +298,25 @@ information on what to include when reporting a bug.
|
||||
- [Wayland] Bugfix: Retrieving partial framebuffer size would segfault
|
||||
- [Wayland] Bugfix: Scrolling offsets were inverted compared to other platforms
|
||||
(#1463)
|
||||
- [Wayland] Bugfix: Client-Side Decorations were destroyed in the wrong worder
|
||||
- [Wayland] Bugfix: Client-Side Decorations were destroyed in the wrong order
|
||||
(#1798)
|
||||
- [Wayland] Bugfix: Monitors physical size could report zero (#1784,#1792)
|
||||
- [Wayland] Bugfix: Some keys were not repeating in Wayland (#1908)
|
||||
- [Wayland] Bugfix: Non-arrow cursors are offset from the hotspot (#1706,#1899)
|
||||
- [Wayland] Bugfix: The `O_CLOEXEC` flag was not defined on FreeBSD
|
||||
- [Wayland] Bugfix: Key repeat could lead to a race condition (#1710)
|
||||
- [Wayland] Bugfix: Activating a window would emit two input focus events
|
||||
- [Wayland] Bugfix: Disable key repeat mechanism when window loses input focus
|
||||
- [Wayland] Bugfix: Window hiding and showing did not work (#1492,#1731)
|
||||
- [Wayland] Bugfix: A key being repeated was not released when window lost focus
|
||||
- [Wayland] Bugfix: Showing a hidden window did not emit a window refresh event
|
||||
- [Wayland] Bugfix: Full screen window creation did not ignore `GLFW_VISIBLE`
|
||||
- [Wayland] Bugfix: Some keys were reported as wrong key or `GLFW_KEY_UNKNOWN`
|
||||
- [Wayland] Bugfix: Text input did not repeat along with key repeat
|
||||
- [Wayland] Bugfix: `glfwPostEmptyEvent` sometimes had no effect (#1520,#1521)
|
||||
- [POSIX] Removed use of deprecated function `gettimeofday`
|
||||
- [POSIX] Bugfix: `CLOCK_MONOTONIC` was not correctly tested for or enabled
|
||||
- [WGL] Disabled the DWM swap interval hack for Windows 8 and later (#1072)
|
||||
- [NSGL] Removed enforcement of forward-compatible flag for core contexts
|
||||
- [NSGL] Bugfix: `GLFW_COCOA_RETINA_FRAMEBUFFER` had no effect on newer
|
||||
macOS versions (#1442)
|
||||
@ -263,6 +328,7 @@ information on what to include when reporting a bug.
|
||||
- [EGL] Added ANGLE backend selection via `EGL_ANGLE_platform_angle` extension
|
||||
(#1380)
|
||||
- [EGL] Bugfix: The `GLFW_DOUBLEBUFFER` context attribute was ignored (#1843)
|
||||
- [GLX] Bugfix: Context creation failed if GLX 1.4 was not exported by GLX library
|
||||
|
||||
|
||||
## Contact
|
||||
@ -281,226 +347,3 @@ request, please file it in the
|
||||
Finally, if you're interested in helping out with the development of GLFW or
|
||||
porting it to your favorite platform, join us on the forum, GitHub or IRC.
|
||||
|
||||
|
||||
## Acknowledgements
|
||||
|
||||
GLFW exists because people around the world donated their time and lent their
|
||||
skills.
|
||||
|
||||
- Bobyshev Alexander
|
||||
- Laurent Aphecetche
|
||||
- Matt Arsenault
|
||||
- ashishgamedev
|
||||
- David Avedissian
|
||||
- Keith Bauer
|
||||
- John Bartholomew
|
||||
- Coşku Baş
|
||||
- Niklas Behrens
|
||||
- Andrew Belt
|
||||
- Nevyn Bengtsson
|
||||
- Niklas Bergström
|
||||
- Denis Bernard
|
||||
- Doug Binks
|
||||
- blanco
|
||||
- Waris Boonyasiriwat
|
||||
- Kyle Brenneman
|
||||
- Rok Breulj
|
||||
- Kai Burjack
|
||||
- Martin Capitanio
|
||||
- Nicolas Caramelli
|
||||
- David Carlier
|
||||
- Arturo Castro
|
||||
- Chi-kwan Chan
|
||||
- Joseph Chua
|
||||
- Ian Clarkson
|
||||
- Michał Cichoń
|
||||
- Lambert Clara
|
||||
- Anna Clarke
|
||||
- Yaron Cohen-Tal
|
||||
- Omar Cornut
|
||||
- Andrew Corrigan
|
||||
- Bailey Cosier
|
||||
- Noel Cower
|
||||
- CuriouserThing
|
||||
- Jason Daly
|
||||
- Jarrod Davis
|
||||
- Olivier Delannoy
|
||||
- Paul R. Deppe
|
||||
- Michael Dickens
|
||||
- Роман Донченко
|
||||
- Mario Dorn
|
||||
- Wolfgang Draxinger
|
||||
- Jonathan Dummer
|
||||
- Ralph Eastwood
|
||||
- Fredrik Ehnbom
|
||||
- Robin Eklind
|
||||
- Siavash Eliasi
|
||||
- Ahmad Fatoum
|
||||
- Felipe Ferreira
|
||||
- Michael Fogleman
|
||||
- Gerald Franz
|
||||
- Mário Freitas
|
||||
- GeO4d
|
||||
- Marcus Geelnard
|
||||
- Charles Giessen
|
||||
- Ryan C. Gordon
|
||||
- Stephen Gowen
|
||||
- Kovid Goyal
|
||||
- Eloi Marín Gratacós
|
||||
- Stefan Gustavson
|
||||
- Jonathan Hale
|
||||
- hdf89shfdfs
|
||||
- Sylvain Hellegouarch
|
||||
- Matthew Henry
|
||||
- heromyth
|
||||
- Lucas Hinderberger
|
||||
- Paul Holden
|
||||
- Warren Hu
|
||||
- Charles Huber
|
||||
- IntellectualKitty
|
||||
- Aaron Jacobs
|
||||
- Erik S. V. Jansson
|
||||
- Toni Jovanoski
|
||||
- Arseny Kapoulkine
|
||||
- Cem Karan
|
||||
- Osman Keskin
|
||||
- Koray Kilinc
|
||||
- Josh Kilmer
|
||||
- Byunghoon Kim
|
||||
- Cameron King
|
||||
- Peter Knut
|
||||
- Christoph Kubisch
|
||||
- Yuri Kunde Schlesner
|
||||
- Rokas Kupstys
|
||||
- Konstantin Käfer
|
||||
- Eric Larson
|
||||
- Francis Lecavalier
|
||||
- Jong Won Lee
|
||||
- Robin Leffmann
|
||||
- Glenn Lewis
|
||||
- Shane Liesegang
|
||||
- Anders Lindqvist
|
||||
- Leon Linhart
|
||||
- Marco Lizza
|
||||
- Eyal Lotem
|
||||
- Aaron Loucks
|
||||
- Luflosi
|
||||
- lukect
|
||||
- Tristam MacDonald
|
||||
- Hans Mackowiak
|
||||
- Дмитри Малышев
|
||||
- Zbigniew Mandziejewicz
|
||||
- Adam Marcus
|
||||
- Célestin Marot
|
||||
- Kyle McDonald
|
||||
- David V. McKay
|
||||
- David Medlock
|
||||
- Bryce Mehring
|
||||
- Jonathan Mercier
|
||||
- Marcel Metz
|
||||
- Liam Middlebrook
|
||||
- Ave Milia
|
||||
- Jonathan Miller
|
||||
- Kenneth Miller
|
||||
- Bruce Mitchener
|
||||
- Jack Moffitt
|
||||
- Jeff Molofee
|
||||
- Alexander Monakov
|
||||
- Pierre Morel
|
||||
- Jon Morton
|
||||
- Pierre Moulon
|
||||
- Martins Mozeiko
|
||||
- Julian Møller
|
||||
- ndogxj
|
||||
- n3rdopolis
|
||||
- Kristian Nielsen
|
||||
- Kamil Nowakowski
|
||||
- onox
|
||||
- Denis Ovod
|
||||
- Ozzy
|
||||
- Andri Pálsson
|
||||
- Peoro
|
||||
- Braden Pellett
|
||||
- Christopher Pelloux
|
||||
- Arturo J. Pérez
|
||||
- Vladimir Perminov
|
||||
- Anthony Pesch
|
||||
- Orson Peters
|
||||
- Emmanuel Gil Peyrot
|
||||
- Cyril Pichard
|
||||
- Keith Pitt
|
||||
- Stanislav Podgorskiy
|
||||
- Konstantin Podsvirov
|
||||
- Nathan Poirier
|
||||
- Alexandre Pretyman
|
||||
- Pablo Prietz
|
||||
- przemekmirek
|
||||
- pthom
|
||||
- Guillaume Racicot
|
||||
- Philip Rideout
|
||||
- Eddie Ringle
|
||||
- Max Risuhin
|
||||
- Jorge Rodriguez
|
||||
- Luca Rood
|
||||
- Ed Ropple
|
||||
- Aleksey Rybalkin
|
||||
- Mikko Rytkönen
|
||||
- Riku Salminen
|
||||
- Brandon Schaefer
|
||||
- Sebastian Schuberth
|
||||
- Christian Sdunek
|
||||
- Matt Sealey
|
||||
- Steve Sexton
|
||||
- Arkady Shapkin
|
||||
- Ali Sherief
|
||||
- Yoshiki Shibukawa
|
||||
- Dmitri Shuralyov
|
||||
- Daniel Skorupski
|
||||
- Anthony Smith
|
||||
- Bradley Smith
|
||||
- Cliff Smolinsky
|
||||
- Patrick Snape
|
||||
- Erlend Sogge Heggen
|
||||
- Julian Squires
|
||||
- Johannes Stein
|
||||
- Pontus Stenetorp
|
||||
- Michael Stocker
|
||||
- Justin Stoecker
|
||||
- Elviss Strazdins
|
||||
- Paul Sultana
|
||||
- Nathan Sweet
|
||||
- TTK-Bandit
|
||||
- Jared Tiala
|
||||
- Sergey Tikhomirov
|
||||
- Arthur Tombs
|
||||
- Ioannis Tsakpinis
|
||||
- Samuli Tuomola
|
||||
- Matthew Turner
|
||||
- urraka
|
||||
- Elias Vanderstuyft
|
||||
- Stef Velzel
|
||||
- Jari Vetoniemi
|
||||
- Ricardo Vieira
|
||||
- Nicholas Vitovitch
|
||||
- Simon Voordouw
|
||||
- Corentin Wallez
|
||||
- Torsten Walluhn
|
||||
- Patrick Walton
|
||||
- Xo Wang
|
||||
- Jay Weisskopf
|
||||
- Frank Wille
|
||||
- Andy Williams
|
||||
- Joel Winarske
|
||||
- Richard A. Wilkes
|
||||
- Tatsuya Yatagawa
|
||||
- Ryogo Yoshimura
|
||||
- Lukas Zanner
|
||||
- Andrey Zholos
|
||||
- Aihui Zhu
|
||||
- Santi Zupancic
|
||||
- Jonas Ådahl
|
||||
- Lasse Öörni
|
||||
- Leonard König
|
||||
- All the unmentioned and anonymous contributors in the GLFW community, for bug
|
||||
reports, patches, feedback, testing and encouragement
|
||||
|
||||
|
@ -93,14 +93,6 @@ ALLOW_UNICODE_NAMES = NO
|
||||
|
||||
OUTPUT_LANGUAGE = English
|
||||
|
||||
# The OUTPUT_TEXT_DIRECTION tag is used to specify the direction in which all
|
||||
# documentation generated by doxygen is written. Doxygen will use this
|
||||
# information to generate all generated output in the proper direction.
|
||||
# Possible values are: None, LTR, RTL and Context.
|
||||
# The default value is: None.
|
||||
|
||||
OUTPUT_TEXT_DIRECTION = None
|
||||
|
||||
# If the BRIEF_MEMBER_DESC tag is set to YES, doxygen will include brief member
|
||||
# descriptions after the members that are listed in the file and class
|
||||
# documentation (similar to Javadoc). Set to NO to disable this.
|
||||
@ -1811,16 +1803,6 @@ LATEX_BATCHMODE = NO
|
||||
|
||||
LATEX_HIDE_INDICES = NO
|
||||
|
||||
# If the LATEX_SOURCE_CODE tag is set to YES then doxygen will include source
|
||||
# code with syntax highlighting in the LaTeX output.
|
||||
#
|
||||
# Note that which sources are shown also depends on other settings such as
|
||||
# SOURCE_BROWSER.
|
||||
# The default value is: NO.
|
||||
# This tag requires that the tag GENERATE_LATEX is set to YES.
|
||||
|
||||
LATEX_SOURCE_CODE = NO
|
||||
|
||||
# The LATEX_BIB_STYLE tag can be used to specify the style to use for the
|
||||
# bibliography, e.g. plainnat, or ieeetr. See
|
||||
# https://en.wikipedia.org/wiki/BibTeX and \cite for more info.
|
||||
@ -1901,16 +1883,6 @@ RTF_STYLESHEET_FILE =
|
||||
|
||||
RTF_EXTENSIONS_FILE =
|
||||
|
||||
# If the RTF_SOURCE_CODE tag is set to YES then doxygen will include source code
|
||||
# with syntax highlighting in the RTF output.
|
||||
#
|
||||
# Note that which sources are shown also depends on other settings such as
|
||||
# SOURCE_BROWSER.
|
||||
# The default value is: NO.
|
||||
# This tag requires that the tag GENERATE_RTF is set to YES.
|
||||
|
||||
RTF_SOURCE_CODE = NO
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the man page output
|
||||
#---------------------------------------------------------------------------
|
||||
@ -2007,15 +1979,6 @@ GENERATE_DOCBOOK = NO
|
||||
|
||||
DOCBOOK_OUTPUT = docbook
|
||||
|
||||
# If the DOCBOOK_PROGRAMLISTING tag is set to YES, doxygen will include the
|
||||
# program listings (including syntax highlighting and cross-referencing
|
||||
# information) to the DOCBOOK output. Note that enabling this will significantly
|
||||
# increase the size of the DOCBOOK output.
|
||||
# The default value is: NO.
|
||||
# This tag requires that the tag GENERATE_DOCBOOK is set to YES.
|
||||
|
||||
DOCBOOK_PROGRAMLISTING = NO
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options for the AutoGen Definitions output
|
||||
#---------------------------------------------------------------------------
|
||||
@ -2204,15 +2167,6 @@ EXTERNAL_PAGES = YES
|
||||
# Configuration options related to the dot tool
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
# If the CLASS_DIAGRAMS tag is set to YES, doxygen will generate a class diagram
|
||||
# (in HTML and LaTeX) for classes with base or super classes. Setting the tag to
|
||||
# NO turns the diagrams off. Note that this option also works with HAVE_DOT
|
||||
# disabled, but it is recommended to install and use dot, since it yields more
|
||||
# powerful graphs.
|
||||
# The default value is: YES.
|
||||
|
||||
CLASS_DIAGRAMS = YES
|
||||
|
||||
# You can include diagrams made with dia in doxygen documentation. Doxygen will
|
||||
# then run dia to produce the diagram and insert it in the documentation. The
|
||||
# DIA_PATH tag allows you to specify the directory where the dia binary resides.
|
||||
|
@ -104,9 +104,8 @@ integration by libwayland-egl, and keyboard handling by
|
||||
from wayland-protocols to provide additional features if the compositor
|
||||
supports them.
|
||||
|
||||
GLFW uses xkbcommon 0.5.0 to provide compose key support. When it has been
|
||||
built against an older xkbcommon, the compose key will be disabled even if it
|
||||
has been configured in the compositor.
|
||||
GLFW uses xkbcommon 0.5.0 to provide key and text input support. Earlier
|
||||
versions are not supported.
|
||||
|
||||
GLFW uses the [xdg-shell
|
||||
protocol](https://cgit.freedesktop.org/wayland/wayland-protocols/tree/stable/xdg-shell/xdg-shell.xml)
|
||||
|
124
docs/compile.dox
124
docs/compile.dox
@ -10,8 +10,8 @@ build applications that use GLFW, see @ref build_guide.
|
||||
|
||||
@section compile_cmake Using CMake
|
||||
|
||||
@note GLFW behaves like most other libraries that use CMake so this guide mostly
|
||||
describes the basic configure/generate/compile sequence. If you are already
|
||||
GLFW behaves like most other libraries that use CMake so this guide mostly
|
||||
describes the standard configure, generate and compile sequence. If you are already
|
||||
familiar with this from other projects, you may want to focus on the @ref
|
||||
compile_deps and @ref compile_options sections for GLFW-specific information.
|
||||
|
||||
@ -40,7 +40,7 @@ all necessary dependencies for compiling GLFW, but on Unix-like systems like
|
||||
Linux and FreeBSD you will need a few extra packages.
|
||||
|
||||
|
||||
@subsubsection compile_deps_x11 Dependencies for X11 on Unix-like systems
|
||||
@subsubsection compile_deps_x11 Dependencies for X11
|
||||
|
||||
To compile GLFW for X11, you need to have the X11 development packages
|
||||
installed. They are not needed to build or run programs that use GLFW.
|
||||
@ -68,40 +68,47 @@ install the `xorgproto` package.
|
||||
pkg install xorgproto
|
||||
@endcode
|
||||
|
||||
On Cygwin the `xorgproto` package in the Devel section of the GUI installer will
|
||||
install the headers and other development related files for all of X11.
|
||||
On Cygwin the `libXcursor-devel`, `libXi-devel`, `libXinerama-devel`,
|
||||
`libXrandr-devel` and `libXrender-devel` packages in the Libs section of the GUI
|
||||
installer will install all the headers and other development related files GLFW
|
||||
requires for X11.
|
||||
|
||||
Once you have the required depdendencies, move on to @ref compile_generate.
|
||||
Once you have the required dependencies, move on to @ref compile_generate.
|
||||
|
||||
|
||||
@subsubsection compile_deps_wayland Dependencies for Wayland on Unix-like systems
|
||||
@subsubsection compile_deps_wayland Dependencies for Wayland and X11
|
||||
|
||||
To compile GLFW for Wayland, you need to have the Wayland and xkbcommon
|
||||
development packages installed. They are not needed to build or run programs
|
||||
that use GLFW.
|
||||
To compile GLFW for both Wayland and X11, you need to have the X11, Wayland and xkbcommon
|
||||
development packages installed. They are not needed to build or run programs that use
|
||||
GLFW. You will also need to set the @ref GLFW_BUILD_WAYLAND CMake option in the next
|
||||
step when generating build files.
|
||||
|
||||
On Debian and derivates like Ubuntu and Linux Mint you will need the
|
||||
`libwayland-dev`, `libxkbcommon-dev` and `wayland-protocols` packages.
|
||||
On Debian and derivates like Ubuntu and Linux Mint you will need the `libwayland-dev`,
|
||||
`libxkbcommon-dev` and `wayland-protocols` packages and the `xorg-dev` meta-package.
|
||||
These will pull in all other dependencies.
|
||||
|
||||
@code{.sh}
|
||||
sudo apt install libwayland-dev libxkbcommon-dev wayland-protocols
|
||||
sudo apt install libwayland-dev libxkbcommon-dev wayland-protocols xorg-dev
|
||||
@endcode
|
||||
|
||||
On Fedora and derivatives like Red Hat you will need the `wayland-devel`,
|
||||
`libxkbcommon-devel` and `wayland-protocols-devel` packages.
|
||||
`libxkbcommon-devel`, `wayland-protocols-devel`, `libXcursor-devel`, `libXi-devel`,
|
||||
`libXinerama-devel` and `libXrandr-devel` packages. These will pull in all other
|
||||
dependencies.
|
||||
|
||||
@code{.sh}
|
||||
sudo dnf install wayland-devel libxkbcommon-devel wayland-protocols-devel
|
||||
sudo dnf install wayland-devel libxkbcommon-devel wayland-protocols-devel libXcursor-devel libXi-devel libXinerama-devel libXrandr-devel
|
||||
@endcode
|
||||
|
||||
On FreeBSD you will need the `wayland`, `libxkbcommon` and `wayland-protocols`
|
||||
packages.
|
||||
On FreeBSD you will need the `wayland`, `libxkbcommon` and `wayland-protocols` packages.
|
||||
The X11 headers are installed along the end-user X11 packages, so if you have an X server
|
||||
running you should have the headers as well. If not, install the `xorgproto` package.
|
||||
|
||||
@code{.sh}
|
||||
pkg install wayland libxkbcommon wayland-protocols
|
||||
pkg install wayland libxkbcommon wayland-protocols xorgproto
|
||||
@endcode
|
||||
|
||||
Once you have the required depdendencies, move on to @ref compile_generate.
|
||||
Once you have the required dependencies, move on to @ref compile_generate.
|
||||
|
||||
|
||||
@subsection compile_generate Generating build files with CMake
|
||||
@ -126,7 +133,7 @@ A common pattern when building a single configuration is to have a build
|
||||
directory named `build` in the root of the source tree.
|
||||
|
||||
|
||||
@subsubsection compile_generate_gui Generating files with the CMake GUI
|
||||
@subsubsection compile_generate_gui Generating with the CMake GUI
|
||||
|
||||
Start the CMake GUI and set the paths to the source and build directories
|
||||
described above. Then press _Configure_ and _Generate_.
|
||||
@ -135,15 +142,15 @@ If you wish change any CMake variables in the list, press _Configure_ and then
|
||||
_Generate_ to have the new values take effect. The variable list will be
|
||||
populated after the first configure step.
|
||||
|
||||
By default GLFW will use X11 on Linux and other Unix-like systems other
|
||||
than macOS. To use Wayland instead, set the `GLFW_USE_WAYLAND` option in the
|
||||
GLFW section of the variable list, then apply the new value as described above.
|
||||
By default GLFW will use X11 on Linux and other Unix-like systems other than macOS. To
|
||||
include support for Wayland as well, set the @ref GLFW_BUILD_WAYLAND option in the GLFW
|
||||
section of the variable list, then apply the new value as described above.
|
||||
|
||||
Once you have generated the project files or makefiles for your chosen
|
||||
development environment, move on to @ref compile_compile.
|
||||
|
||||
|
||||
@subsubsection compile_generate_cli Generating files with the CMake command-line tool
|
||||
@subsubsection compile_generate_cli Generating with command-line CMake
|
||||
|
||||
To make a build directory, pass the source and build directories to the `cmake`
|
||||
command. These can be relative or absolute paths. The build directory is
|
||||
@ -170,10 +177,11 @@ cmake -S path/to/glfw -B path/to/build -G Xcode
|
||||
@endcode
|
||||
|
||||
By default GLFW will use X11 on Linux and other Unix-like systems other
|
||||
than macOS. To use Wayland instead, set the `GLFW_USE_WAYLAND` CMake option.
|
||||
than macOS. To also include support for Wayland, set the @ref GLFW_BUILD_WAYLAND CMake
|
||||
option.
|
||||
|
||||
@code{.sh}
|
||||
cmake -S path/to/glfw -B path/to/build -D GLFW_USE_WAYLAND=1
|
||||
cmake -S path/to/glfw -B path/to/build -D GLFW_BUILD_WAYLAND=1
|
||||
@endcode
|
||||
|
||||
Once you have generated the project files or makefiles for your chosen
|
||||
@ -267,12 +275,13 @@ __GLFW_BUILD_DOCS__ determines whether the GLFW documentation is built along
|
||||
with the library. This is enabled by default if
|
||||
[Doxygen](https://www.doxygen.nl/) is found by CMake during configuration.
|
||||
|
||||
@anchor GLFW_VULKAN_STATIC
|
||||
__GLFW_VULKAN_STATIC__ determines whether to use the Vulkan loader linked
|
||||
directly with the application. This is disabled by default.
|
||||
|
||||
@subsection compile_options_win32 Win32 specific CMake options
|
||||
|
||||
@subsection compile_options_win32 Windows specific CMake options
|
||||
@anchor GLFW_BUILD_WIN32
|
||||
__GLFW_BUILD_WIN32__ determines whether to include support for Win32 when compiling the
|
||||
library. This option is only available when compiling for Windows. This is enabled by
|
||||
default.
|
||||
|
||||
@anchor USE_MSVC_RUNTIME_LIBRARY_DLL
|
||||
__USE_MSVC_RUNTIME_LIBRARY_DLL__ determines whether to use the DLL version or the
|
||||
@ -292,12 +301,25 @@ will not work if GLFW is built as a DLL. This is disabled by default, letting
|
||||
the operating system and driver decide.
|
||||
|
||||
|
||||
@subsection compile_options_wayland Wayland specific CMake options
|
||||
@subsection compile_options_macos macOS specific CMake options
|
||||
|
||||
@anchor GLFW_USE_WAYLAND
|
||||
__GLFW_USE_WAYLAND__ determines whether to compile the library for Wayland.
|
||||
This option is only available on Linux and other Unix-like systems other than
|
||||
macOS. This is disabled by default.
|
||||
@anchor GLFW_BUILD_COCOA
|
||||
__GLFW_BUILD_COCOA__ determines whether to include support for Cocoa when compiling the
|
||||
library. This option is only available when compiling for macOS. This is enabled by
|
||||
default.
|
||||
|
||||
|
||||
@subsection compile_options_unix Unix-like system specific CMake options
|
||||
|
||||
@anchor GLFW_BUILD_WAYLAND
|
||||
__GLFW_BUILD_WAYLAND__ determines whether to include support for Wayland when compiling
|
||||
the library. This option is only available when compiling for Linux and other Unix-like
|
||||
systems other than macOS. This is disabled by default.
|
||||
|
||||
@anchor GLFW_BUILD_X11
|
||||
__GLFW_BUILD_X11__ determines whether to include support for X11 when compiling the
|
||||
library. This option is only available when compiling for Linux and other Unix-like
|
||||
systems other than macOS. This is enabled by default.
|
||||
|
||||
|
||||
@section compile_mingw_cross Cross-compilation with CMake and MinGW
|
||||
@ -335,34 +357,30 @@ For more details see the
|
||||
|
||||
@section compile_manual Compiling GLFW manually
|
||||
|
||||
If you wish to compile GLFW without its CMake build environment then you will
|
||||
have to do at least some of the platform detection yourself. GLFW needs
|
||||
a configuration macro to be defined in order to know what window system it is
|
||||
being compiled for and also has optional, platform-specific ones for various
|
||||
features.
|
||||
If you wish to compile GLFW without its CMake build environment then you will have to do
|
||||
at least some of the platform detection yourself. There are preprocessor macros for
|
||||
enabling support for the platforms (window systems) available. There are also optional,
|
||||
platform-specific macros for various features.
|
||||
|
||||
When building with CMake, the `glfw_config.h` configuration header is generated
|
||||
based on the current platform and CMake options. The GLFW CMake environment
|
||||
defines @b GLFW_USE_CONFIG_H, which causes this header to be included by
|
||||
`internal.h`. Without this macro, GLFW will expect the necessary configuration
|
||||
macros to be defined on the command-line.
|
||||
When building, GLFW will expect the necessary configuration macros to be defined
|
||||
on the command-line. The GLFW CMake files set these as private compile
|
||||
definitions on the GLFW target but if you compile the GLFW sources manually you
|
||||
will need to define them yourself.
|
||||
|
||||
The window creation API is used to create windows, handle input, monitors, gamma
|
||||
ramps and clipboard. The options are:
|
||||
The window system is used to create windows, handle input, monitors, gamma ramps and
|
||||
clipboard. The options are:
|
||||
|
||||
- @b _GLFW_COCOA to use the Cocoa frameworks
|
||||
- @b _GLFW_WIN32 to use the Win32 API
|
||||
- @b _GLFW_X11 to use the X Window System
|
||||
- @b _GLFW_WAYLAND to use the Wayland API (experimental and incomplete)
|
||||
- @b _GLFW_OSMESA to use the OSMesa API (headless and non-interactive)
|
||||
- @b _GLFW_WAYLAND to use the Wayland API (incomplete)
|
||||
|
||||
The @b _GLFW_WAYLAND and @b _GLFW_X11 macros may be combined and produces a library that
|
||||
attempts to detect the appropriate platform at initialization.
|
||||
|
||||
If you are building GLFW as a shared library / dynamic library / DLL then you
|
||||
must also define @b _GLFW_BUILD_DLL. Otherwise, you must not define it.
|
||||
|
||||
If you are linking the Vulkan loader directly with your application then you
|
||||
must also define @b _GLFW_VULKAN_STATIC. Otherwise, GLFW will attempt to use the
|
||||
external version.
|
||||
|
||||
If you are using a custom name for the Vulkan, EGL, GLX, OSMesa, OpenGL, GLESv1
|
||||
or GLESv2 library, you can override the default names by defining those you need
|
||||
of @b _GLFW_VULKAN_LIBRARY, @b _GLFW_EGL_LIBRARY, @b _GLFW_GLX_LIBRARY, @b
|
||||
|
File diff suppressed because one or more lines are too long
@ -1 +1,7 @@
|
||||
{"version":3,"sourceRoot":"","sources":["extra.scss"],"names":[],"mappings":"AA8EA,4GACI,gBACA,iBAGJ,yBACC,yDAGD,6HACC,sDAGD,yIACC,sDAGD,mBACI,WA9EuB,KA+EvB,iBAGJ,uBACC,MAzFoB,QA0FjB,iBAGJ,6UACC,gBAGD,mJACC,YAGD,yHACC,iBAGD,sBACC,gBAGD,4LACC,UAGD,yCACC,aAGD,kMACC,WAnHgC,QAsHjC,KACC,MA1HoB,QA6HrB,sDACC,MA/Ge,QAgHf,mBAGD,GACE,iBACA,eAGF,GACE,iBACA,gBACA,eAGF,GACE,iBACA,gBACA,eAGF,YACC,eACA,gBACA,gBACA,eACA,cAEA,aACA,mBACA,eACA,2BACA,mBACA,sBAGD,UACC,iBACA,mBACA,MA/J0B,KAgK1B,gBACA,qEAGD,YACC,qBACA,kBACA,YAGD,yBACC,WAGD,oCACC,iBACA,gBACA,cACA,MAlL0B,KAqL3B,YACC,eAGD,8CACC,qBAGD,mBACC,MA9L0B,KAiM3B,eACC,kBACA,YACA,eAGD,KACC,WAxM0B,KA2M3B,UACC,gBACA,cACA,eAGD,WACC,gBACA,cACA,eAGD,UACI,aAGJ,mBACI,iBACA,iBAGJ,WACC,gBACA,aACA,mBACA,eACA,2BACA,mBACA,sBAGD,mEACC,MA9OgC,QAiPjC,gCACC,MArPoB,QAwPrB,sCACC,MAjOoB,KAoOrB,yBACC,kBAGD,UACC,iBAGD,wBACC,gBACA,cACA,eACA,qBAGD,uDACC,gEACA,+BACA,+BACA,gBACA,MArPgB,KAwPjB,mBACC,MA5PoB,KA6PpB,aACA,kBACA,yBAGD,QACC,WACA,WAGD,WACC,iBAGD,WACC,mBAGD,WACC,cACA,eACA,qBAGD,oCACC,gEACA,kCACA,2BACA,MAlSe,QAmSf,yBACA,kBAGD,WACC,MA3QuB,QA8QxB,cACC,sBACA,2BACA,4BACA,mBAGD,cACC,sBACA,+BACA,8BACA,gBAGD,mCACC,wBACA,iBACA,sBACA,kBAGD,gIACC,MAxToB,KAyTpB,qBAGD,cACC,wBACA,iBACA,sBACA,kBAGD,iBACC,WACA,4EAGD,oCApSC,gEACA,kCACA,cACA,yBAqSD,wBAxSC,gEACA,kCACA,cACA,yBAySD,qBA5SC,gEACA,kCACA,cACA,yBA6SD,gBAhTC,gEACA,kCACA,cACA,yBAiTD,iGACC,kBACA,YACA,2BACA,aAGD,kRACC,cAGD,SACC,oBAGD,0BACC,mBACA,kBACA,YACA,YACA,cACA,2BACA,aAGD,+CACC,MA1YoB,QA6YrB,+BACC,cAGD,sBACC,cAGD,+CACC,cACA,iBAGD,mBACC,cAGD,KACC,aACA","file":"extra.css"}
|
||||
{
|
||||
"version": 3,
|
||||
"mappings": "AA8EA,2GAA4G,CAC3G,UAAU,CAAC,IAAI,CACf,WAAW,CAAC,IAAI,CAGjB,wBAAyB,CACxB,YAAY,CAAC,2CAAsD,CAGpE,4HAA6H,CAC5H,YAAY,CAAC,wCAAuD,CAGrE,wIAAyI,CACxI,YAAY,CAAC,wCAAuD,CAGrE,kBAAmB,CAClB,UAAU,CA9EgB,IAAa,CA+EvC,WAAW,CAAC,IAAI,CAGjB,sBAAuB,CACtB,KAAK,CAzFe,OAAa,CA0FjC,WAAW,CAAC,IAAI,CAGjB,4UAA6U,CAC5U,UAAU,CAAC,IAAI,CAGhB,kJAAmJ,CAClJ,MAAM,CAAC,IAAI,CAGZ,wHAAyH,CACxH,WAAW,CAAC,IAAI,CAGjB,qBAAsB,CACrB,UAAU,CAAC,IAAI,CAGhB,2LAA4L,CAC3L,OAAO,CAAC,CAAC,CAGV,wCAAyC,CACxC,OAAO,CAAC,IAAI,CAGb,iMAAkM,CACjM,UAAU,CApGW,OAA+B,CAuGrD,IAAK,CACJ,KAAK,CA1He,OAAa,CA6HlC,SAAU,CACN,SAAS,CAAE,IAAI,CACf,MAAM,CAAE,aAAa,CAGzB,qDAAsD,CACrD,KAAK,CApHU,OAAa,CAqH5B,aAAa,CAAC,IAAI,CAGnB,EAAG,CACF,WAAW,CAAC,KAAK,CACjB,SAAS,CAAC,IAAI,CAGf,EAAG,CACF,WAAW,CAAC,KAAK,CACjB,aAAa,CAAC,CAAC,CACf,SAAS,CAAC,IAAI,CAGf,EAAG,CACF,WAAW,CAAC,KAAK,CACjB,aAAa,CAAC,CAAC,CACf,SAAS,CAAC,IAAI,CAGf,WAAY,CACX,SAAS,CAAC,IAAI,CACd,UAAU,CAAC,IAAI,CACf,SAAS,CAAC,KAAK,CACf,OAAO,CAAC,MAAM,CACd,MAAM,CAAC,MAAM,CAEb,OAAO,CAAE,IAAI,CACb,cAAc,CAAE,GAAG,CACnB,SAAS,CAAE,IAAI,CACf,eAAe,CAAE,UAAU,CAC3B,WAAW,CAAE,MAAM,CACnB,aAAa,CAAE,OAAO,CAGvB,SAAU,CACT,WAAW,CAAC,IAAI,CAChB,aAAa,CAAC,IAAI,CAClB,KAAK,CApKqB,IAAa,CAqKvC,SAAS,CAAC,KAAK,CACf,UAAU,CAAC,yDAAyD,CAGrE,WAAY,CACX,eAAe,CAAC,IAAI,CACpB,MAAM,CAAC,UAAU,CACjB,KAAK,CAAC,KAAK,CAGZ,wBAAyB,CACxB,KAAK,CAAC,IAAI,CAGX,mCAAoC,CACnC,WAAW,CAAC,IAAI,CAChB,WAAW,CAAC,GAAG,CACf,OAAO,CAAC,KAAK,CACb,KAAK,CAvLqB,IAAa,CA0LxC,WAAY,CACX,YAAY,CAAE,CAAC,CAGhB,6CAA8C,CAC7C,UAAU,CAAC,SAAS,CAGrB,kBAAmB,CAClB,KAAK,CAnMqB,IAAa,CAsMxC,cAAe,CACd,UAAU,CAAC,MAAM,CACjB,OAAO,CAAC,GAAG,CACX,UAAU,CAAC,GAAG,CAGf,IAAK,CACJ,UAAU,CA7MgB,IAAa,CAgNxC,SAAU,CACT,SAAS,CAAC,KAAK,CACf,MAAM,CAAC,MAAM,CACb,SAAS,CAAC,IAAI,CAGf,UAAW,CACV,SAAS,CAAC,KAAK,CACf,MAAM,CAAC,MAAM,CACb,SAAS,CAAC,IAAI,CAGf,SAAU,CACT,OAAO,CAAC,IAAI,CAGb,kBAAmB,CAClB,WAAW,CAAC,IAAI,CAChB,WAAW,CAAC,IAAI,CAGjB,UAAW,CACV,UAAU,CAAC,IAAI,CACf,OAAO,CAAE,IAAI,CACb,cAAc,CAAE,GAAG,CACnB,SAAS,CAAE,IAAI,CACf,eAAe,CAAE,UAAU,CAC3B,WAAW,CAAE,MAAM,CACnB,aAAa,CAAE,OAAO,CAGvB,kEAAmE,CAClE,KAAK,CApOgB,OAA+B,CAuOrD,+BAAgC,CAC/B,KAAK,CA1Pe,OAAa,CA6PlC,qCAAsC,CACrC,KAAK,CA1NoB,IAAsB,CA6NhD,wBAA2B,CAC1B,MAAM,CAAE,UAAU,CAGnB,SAAU,CACT,UAAU,CAAC,KAAK,CAGjB,uBAAwB,CACvB,SAAS,CAAC,KAAK,CACf,MAAM,CAAC,MAAM,CACb,OAAO,CAAC,MAAM,CACd,UAAU,CAAC,SAA8B,CAG1C,sDAAuD,CACtD,UAAU,CAAC,iDAAoF,CAC/F,UAAU,CAAC,mBAAuC,CAClD,WAAW,CAAC,kBAAgD,CAC5D,UAAU,CAAC,IAAI,CACf,KAAK,CAlPa,IAAe,CAqPlC,kBAAmB,CAClB,KAAK,CArPoB,IAAsB,CAsP/C,OAAO,CAAC,IAAI,CACZ,aAAa,CAAC,GAAG,CACjB,gBAAgB,CAAC,OAAiC,CAGnD,OAAQ,CACP,KAAK,CAAC,KAAK,CACX,KAAK,CAAC,GAAG,CAGV,oCAAoC,CACnC,OAAQ,CACP,KAAK,CAAC,IAAI,CACV,KAAK,CAAC,OAAO,CACb,MAAM,CAAC,CAAC,EAIV,UAAW,CACV,SAAS,CAAC,MAAM,CAGjB,UAAW,CACV,YAAY,CAAC,KAAK,CAGnB,UAAW,CACV,SAAS,CAAC,GAAG,CACb,YAAY,CAAC,CAAC,CACd,eAAe,CAAC,IAAI,CAIjB,mCAAqB,CACjB,WAAW,CAAC,KAAK,CAIzB,mCAAoC,CACnC,UAAU,CAAC,oDAAgF,CAC3F,UAAU,CAAC,sBAAqC,CAChD,WAAW,CAAC,cAA8C,CAC1D,KAAK,CArTU,OAAa,CAsT5B,MAAM,CAAC,iBAAgC,CACvC,aAAa,CAAC,GAAG,CAGlB,UAAW,CACV,KAAK,CA9RkB,OAAgC,CAiSxD,aAAc,CACb,MAAM,CAAC,cAA+B,CACtC,sBAAsB,CAAC,GAAG,CAC1B,uBAAuB,CAAC,GAAG,CAC3B,aAAa,CAAC,IAAI,CAGnB,aAAc,CACb,MAAM,CAAC,cAA+B,CACtC,0BAA0B,CAAC,GAAG,CAC9B,yBAAyB,CAAC,GAAG,CAC7B,UAAU,CAAC,IAAI,CAGhB,kCAAmC,CAClC,eAAe,CAAC,OAAO,CACvB,cAAc,CAAC,CAAC,CAChB,MAAM,CAAC,cAA+B,CACtC,aAAa,CAAC,GAAG,CAGlB,+HAAgI,CAC/H,KAAK,CA/ToB,IAAsB,CAgU/C,eAAe,CAAC,IAAI,CAGrB,aAAc,CACb,eAAe,CAAC,OAAO,CACvB,cAAc,CAAC,CAAC,CAChB,MAAM,CAAC,cAA+B,CACtC,aAAa,CAAC,GAAG,CAGlB,gBAAiB,CAChB,MAAM,CAAC,GAAG,CACV,UAAU,CAAC,gEAAiH,CAG7H,mCAAoC,CAvTnC,UAAU,CAAC,oDAAuE,CAClF,UAAU,CAAC,sBAAsC,CACjD,KAAK,CAAC,OAAwB,CAC9B,MAAM,CAAC,iBAAmD,CAwT3D,uBAAwB,CA3TvB,UAAU,CAAC,oDAAuE,CAClF,UAAU,CAAC,sBAAsC,CACjD,KAAK,CAAC,OAAwB,CAC9B,MAAM,CAAC,iBAAmD,CA4T3D,oBAAqB,CA/TpB,UAAU,CAAC,oDAAuE,CAClF,UAAU,CAAC,sBAAsC,CACjD,KAAK,CAAC,OAAwB,CAC9B,MAAM,CAAC,iBAAmD,CAgU3D,eAAgB,CAnUf,UAAU,CAAC,oDAAuE,CAClF,UAAU,CAAC,sBAAsC,CACjD,KAAK,CAAC,OAAwB,CAC9B,MAAM,CAAC,iBAAmD,CAoU3D,gGAAiG,CAChG,aAAa,CAAC,GAAG,CACjB,OAAO,CAAC,GAAG,CACX,WAAW,CAAC,cAAwB,CACpC,MAAM,CAAC,KAAK,CAGb,iRAAkR,CACjR,KAAK,CAAC,OAAO,CAGd,QAAS,CACR,WAAW,CAAC,OAAO,CAGpB,yBAA0B,CACzB,UAAU,CAAC,OAAa,CACxB,aAAa,CAAC,GAAG,CACjB,MAAM,CAAC,IAAI,CACX,OAAO,CAAC,GAAG,CACX,QAAQ,CAAC,IAAI,CACb,WAAW,CAAC,cAAuB,CACnC,MAAM,CAAC,KAAK,CAGb,8CAA+C,CAC9C,KAAK,CA7Ze,OAAa,CAgalC,8BAA+B,CAC9B,KAAK,CAAC,OAAiB,CAGxB,qBAAsB,CACrB,KAAK,CAAC,OAAgB,CAGvB,8CAA+C,CAC9C,KAAK,CAAC,OAA+B,CACrC,WAAW,CAAC,IAAI,CAGjB,kBAAmB,CAClB,KAAK,CAAC,OAAiB,CAGxB,IAAK,CACJ,OAAO,CAAC,IAAI,CACZ,aAAa,CAAC,GAAG",
|
||||
"sources": ["extra.scss"],
|
||||
"names": [],
|
||||
"file": "extra.css"
|
||||
}
|
||||
|
@ -135,6 +135,11 @@ body {
|
||||
color:$default-text-color;
|
||||
}
|
||||
|
||||
div.title {
|
||||
font-size: 170%;
|
||||
margin: 1em 0 0.5em 0;
|
||||
}
|
||||
|
||||
h1,h2,h2.groupheader,h3,div.toc h3,h4,h5,h6,strong,em {
|
||||
color:$heading-color;
|
||||
border-bottom:none;
|
||||
@ -142,13 +147,13 @@ h1,h2,h2.groupheader,h3,div.toc h3,h4,h5,h6,strong,em {
|
||||
|
||||
h1 {
|
||||
padding-top:0.5em;
|
||||
font-size:180%;
|
||||
font-size:150%;
|
||||
}
|
||||
|
||||
h2 {
|
||||
padding-top:0.5em;
|
||||
margin-bottom:0;
|
||||
font-size:140%;
|
||||
font-size:130%;
|
||||
}
|
||||
|
||||
h3 {
|
||||
@ -293,8 +298,16 @@ dl.reflist dt a.el {
|
||||
}
|
||||
|
||||
div.toc {
|
||||
float:none;
|
||||
width:auto;
|
||||
float:right;
|
||||
width:35%;
|
||||
}
|
||||
|
||||
@media screen and (max-width:600px) {
|
||||
div.toc {
|
||||
float:none;
|
||||
width:inherit;
|
||||
margin:0;
|
||||
}
|
||||
}
|
||||
|
||||
div.toc h3 {
|
||||
@ -311,6 +324,12 @@ div.toc li {
|
||||
list-style-type:disc;
|
||||
}
|
||||
|
||||
div.toc {
|
||||
li.level2, li.level3 {
|
||||
margin-left:0.5em;
|
||||
}
|
||||
}
|
||||
|
||||
div.toc,.memproto,div.qindex,div.ah {
|
||||
background:linear-gradient(to bottom,$toc-background-color2 0%,$toc-background-color1 100%);
|
||||
box-shadow:inset 0 0 32px $toc-background-color1;
|
||||
|
@ -821,7 +821,7 @@ The second value is always the human-readable name of the gamepad.
|
||||
All subsequent values are in the form `<field>:<value>` and describe the layout
|
||||
of the mapping. These fields may not all be present and may occur in any order.
|
||||
|
||||
The button fields are `a`, `b`, `c`, `d`, `back`, `start`, `guide`, `dpup`,
|
||||
The button fields are `a`, `b`, `x`, `y`, `back`, `start`, `guide`, `dpup`,
|
||||
`dpright`, `dpdown`, `dpleft`, `leftshoulder`, `rightshoulder`, `leftstick` and
|
||||
`rightstick`.
|
||||
|
||||
|
@ -61,12 +61,21 @@ application-provided callbacks. It is also prohibited from modifying the
|
||||
platform-independent part of the internal structs. Instead, it calls the event
|
||||
interface when events interesting to GLFW are received.
|
||||
|
||||
The platform interface mirrors those parts of the public interface that needs to
|
||||
perform platform-specific operations on some or all platforms. The are also
|
||||
named the same except that the glfw function prefix is replaced by
|
||||
_glfwPlatform.
|
||||
The platform interface mostly mirrors those parts of the public interface that needs to
|
||||
perform platform-specific operations on some or all platforms.
|
||||
|
||||
Examples: `_glfwPlatformCreateWindow`
|
||||
The window system bits of the platform API is called through the `_GLFWplatform` struct of
|
||||
function pointers, to allow runtime selection of platform. This includes the window and
|
||||
context creation, input and event processing, monitor and Vulkan surface creation parts of
|
||||
GLFW. This is located in the global `_glfw` struct.
|
||||
|
||||
Examples: `_glfw.platform.createWindow`
|
||||
|
||||
The timer, threading and module loading bits of the platform API are plain functions with
|
||||
a `_glfwPlatform` prefix, as these things are independent of what window system is being
|
||||
used.
|
||||
|
||||
Examples: `_glfwPlatformGetTimerValue`
|
||||
|
||||
The platform interface also defines structs that contain platform-specific
|
||||
global and per-object state. Their names mirror those of the internal
|
||||
@ -104,8 +113,7 @@ Examples: `isValidElementForJoystick`
|
||||
@section internals_config Configuration macros
|
||||
|
||||
GLFW uses a number of configuration macros to select at compile time which
|
||||
interfaces and code paths to use. They are defined in the glfw_config.h header file,
|
||||
which is generated from the `glfw_config.h.in` file by CMake.
|
||||
interfaces and code paths to use. They are defined in the GLFW CMake target.
|
||||
|
||||
Configuration macros the same style as tokens in the public interface, except
|
||||
with a leading underscore.
|
||||
|
@ -30,10 +30,12 @@ successfully initialized, and only from the main thread.
|
||||
|
||||
- @ref glfwGetVersion
|
||||
- @ref glfwGetVersionString
|
||||
- @ref glfwPlatformSupported
|
||||
- @ref glfwGetError
|
||||
- @ref glfwSetErrorCallback
|
||||
- @ref glfwInitHint
|
||||
- @ref glfwInitAllocator
|
||||
- @ref glfwInitVulkanLoader
|
||||
- @ref glfwInit
|
||||
- @ref glfwTerminate
|
||||
|
||||
@ -89,6 +91,15 @@ Setting these hints requires no platform specific headers or functions.
|
||||
|
||||
@subsubsection init_hints_shared Shared init hints
|
||||
|
||||
@anchor GLFW_PLATFORM
|
||||
__GLFW_PLATFORM__ specifies the platform to use for windowing and input.
|
||||
Possible values are `GLFW_ANY_PLATFORM`, `GLFW_PLATFORM_WIN32`,
|
||||
`GLFW_PLATFORM_COCOA`, `GLFW_PLATFORM_X11`, `GLFW_PLATFORM_WAYLAND` and
|
||||
`GLFW_PLATFORM_NULL`. The default value is `GLFW_ANY_PLATFORM`, which will
|
||||
choose any platform the library includes support for except for the Null
|
||||
backend.
|
||||
|
||||
|
||||
@anchor GLFW_JOYSTICK_HAT_BUTTONS
|
||||
__GLFW_JOYSTICK_HAT_BUTTONS__ specifies whether to also expose joystick hats as
|
||||
buttons, for compatibility with earlier versions of GLFW that did not have @ref
|
||||
@ -137,6 +148,7 @@ the `VK_KHR_xlib_surface` extension. Possible values are `GLFW_TRUE` and
|
||||
|
||||
Initialization hint | Default value | Supported values
|
||||
-------------------------------- | ------------------------------- | ----------------
|
||||
@ref GLFW_PLATFORM | `GLFW_ANY_PLATFORM` | `GLFW_ANY_PLATFORM`, `GLFW_PLATFORM_WIN32`, `GLFW_PLATFORM_COCOA`, `GLFW_PLATFORM_X11`, `GLFW_PLATFORM_WAYLAND` or `GLFW_PLATFORM_NULL`
|
||||
@ref GLFW_JOYSTICK_HAT_BUTTONS | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE`
|
||||
@ref GLFW_ANGLE_PLATFORM_TYPE | `GLFW_ANGLE_PLATFORM_TYPE_NONE` | `GLFW_ANGLE_PLATFORM_TYPE_NONE`, `GLFW_ANGLE_PLATFORM_TYPE_OPENGL`, `GLFW_ANGLE_PLATFORM_TYPE_OPENGLES`, `GLFW_ANGLE_PLATFORM_TYPE_D3D9`, `GLFW_ANGLE_PLATFORM_TYPE_D3D11`, `GLFW_ANGLE_PLATFORM_TYPE_VULKAN` or `GLFW_ANGLE_PLATFORM_TYPE_METAL`
|
||||
@ref GLFW_COCOA_CHDIR_RESOURCES | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE`
|
||||
@ -144,6 +156,48 @@ Initialization hint | Default value | Supported v
|
||||
@ref GLFW_X11_XCB_VULKAN_SURFACE | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE`
|
||||
|
||||
|
||||
@subsection platform Runtime platform selection
|
||||
|
||||
GLFW can be compiled for more than one platform (window system) at once. This lets
|
||||
a single library binary support both X11 and Wayland on Linux and other Unix-like systems.
|
||||
|
||||
You can control platform selection via the @ref GLFW_PLATFORM initialization hint. By
|
||||
default this is set to @ref GLFW_ANY_PLATFORM, which will look for supported window
|
||||
systems in order of priority and select the first one it finds. It can also be set to any
|
||||
specific platform to have GLFW only look for that one.
|
||||
|
||||
@code
|
||||
glfwInitHint(GLFW_PLATFORM, GLFW_PLATFORM_X11);
|
||||
@endcode
|
||||
|
||||
This mechanism also provides the Null platform, which is always supported but needs to be
|
||||
explicitly requested. This platform is effectively a stub, emulating a window system on
|
||||
a single 1080p monitor, but will not interact with any actual window system.
|
||||
|
||||
@code
|
||||
glfwInitHint(GLFW_PLATFORM, GLFW_PLATFORM_NULL);
|
||||
@endcode
|
||||
|
||||
You can test whether a library binary was compiled with support for a specific platform
|
||||
with @ref glfwPlatformSupported.
|
||||
|
||||
@code
|
||||
if (glfwPlatformSupported(GLFW_PLATFORM_WAYLAND))
|
||||
glfwInitHint(GLFW_PLATFORM, GLFW_PLATFORM_WAYLAND);
|
||||
@endcode
|
||||
|
||||
Once GLFW has been initialized, you can query which platform was selected with @ref
|
||||
glfwGetPlatform.
|
||||
|
||||
@code
|
||||
int platform = glfwGetPlatform();
|
||||
@endcode
|
||||
|
||||
If you are using any [native access functions](@ref native), especially on Linux and other
|
||||
Unix-like systems, then you may need to check that you are calling the ones matching the
|
||||
selected platform.
|
||||
|
||||
|
||||
@subsection init_allocator Custom heap memory allocator
|
||||
|
||||
The heap memory allocator can be customized before initialization with @ref
|
||||
@ -437,6 +491,11 @@ Library version information may be queried from any thread.
|
||||
- @ref glfwGetVersion
|
||||
- @ref glfwGetVersionString
|
||||
|
||||
Platform information may be queried from any thread.
|
||||
|
||||
- @ref glfwPlatformSupported
|
||||
- @ref glfwGetPlatform
|
||||
|
||||
All Vulkan related functions may be called from any thread.
|
||||
|
||||
- @ref glfwVulkanSupported
|
||||
@ -529,17 +588,32 @@ __Do not use the version string__ to parse the GLFW library version. The @ref
|
||||
glfwGetVersion function already provides the version of the running library
|
||||
binary.
|
||||
|
||||
__Do not use the version string__ to parse what platforms are supported. The @ref
|
||||
glfwPlatformSupported function lets you query platform support.
|
||||
|
||||
__GLFW 3.4:__ The format of this string was changed to support the addition of
|
||||
[runtime platform selection](@ref platform).
|
||||
|
||||
The format of the string is as follows:
|
||||
- The version of GLFW
|
||||
- The name of the window system API
|
||||
- The name of the context creation API
|
||||
- Any additional options or APIs
|
||||
- For each supported platform:
|
||||
- The name of the window system API
|
||||
- The name of the window system specific context creation API, if applicable
|
||||
- The names of the always supported context creation APIs EGL and OSMesa
|
||||
- Any additional compile-time options, APIs and (on Windows) what compiler was used
|
||||
|
||||
For example, when compiling GLFW 3.0 with MinGW using the Win32 and WGL
|
||||
back ends, the version string may look something like this:
|
||||
For example, GLFW 3.4 compiled as a DLL for Windows with MinGW may have a version string
|
||||
like this:
|
||||
|
||||
@code
|
||||
3.0.0 Win32 WGL MinGW
|
||||
3.4.0 Win32 WGL Null EGL OSMesa MinGW DLL
|
||||
@endcode
|
||||
|
||||
While GLFW compiled as as static library for Linux with both Wayland and X11 enabled may
|
||||
have a version string like this:
|
||||
|
||||
@code
|
||||
3.4.0 Wayland X11 GLX Null EGL OSMesa monotonic
|
||||
@endcode
|
||||
|
||||
*/
|
||||
|
@ -9,6 +9,7 @@
|
||||
|
||||
@subsection features_34 New features in version 3.4
|
||||
|
||||
|
||||
@subsubsection context_user_34 Multiple window contexts
|
||||
|
||||
GLFW now provides the ability to create multiple OpenGL and OpenGL ES
|
||||
@ -18,6 +19,15 @@ destroyed using @ref glfwDestroyUserContext, and managed with
|
||||
@ref glfwMakeUserContextCurrent and @ref glfwGetCurrentUserContext.
|
||||
For more information see the [user context](@ref context_user) documentation.
|
||||
|
||||
|
||||
@subsubsection runtime_platform_34 Runtime platform selection
|
||||
|
||||
GLFW now supports being compiled for multiple backends and selecting between
|
||||
them at runtime with the @ref GLFW_PLATFORM init hint. After initialization the
|
||||
selected platform can be queried with @ref glfwGetPlatform. You can check if
|
||||
support for a given platform is compiled in with @ref glfwPlatformSupported.
|
||||
|
||||
|
||||
@subsubsection standard_cursors_34 More standard cursors
|
||||
|
||||
GLFW now provides the standard cursor shapes @ref GLFW_RESIZE_NWSE_CURSOR and
|
||||
@ -72,7 +82,23 @@ Alt-and-then-Space shortcuts. This may be useful for more GUI-oriented
|
||||
applications.
|
||||
|
||||
|
||||
@subsection caveats_34 Caveats for version 3.4
|
||||
@subsection caveats Caveats for version 3.4
|
||||
|
||||
@subsubsection native_34 Multiple sets of native access functions
|
||||
|
||||
Because GLFW now supports runtime selection of platform (window system), a library binary
|
||||
may export native access functions for multiple platforms. Starting with version 3.4 you
|
||||
must not assume that GLFW is running on a platform just because it exports native access
|
||||
functions for it. After initialization you can query the selected platform with @ref
|
||||
glfwGetPlatform.
|
||||
|
||||
|
||||
@subsubsection version_string_34 Version string format has been changed
|
||||
|
||||
Because GLFW now supports runtime selection of platform (window system), the version
|
||||
string returned by @ref glfwGetVersionString has been expanded. It now contains the names
|
||||
of all APIs for all the platforms that the library binary supports.
|
||||
|
||||
|
||||
@subsubsection joysticks_34 Joystick support is initialized on demand
|
||||
|
||||
@ -123,10 +149,39 @@ GLFW_TRANSPARENT_FRAMEBUFFER on Windows 7 if DWM transparency is off
|
||||
(the Transparency setting under Personalization > Window Color).
|
||||
|
||||
|
||||
@subsubsection emptyevents_34 Empty events on X11 no longer roundtrip to server
|
||||
|
||||
Events posted with @ref glfwPostEmptyEvent now use a separate unnamed pipe
|
||||
instead of sending an X11 client event to the helper window.
|
||||
|
||||
|
||||
@subsection deprecations_34 Deprecations in version 3.4
|
||||
|
||||
@subsection removals_34 Removals in 3.4
|
||||
|
||||
@subsubsection vulkan_static_34 GLFW_VULKAN_STATIC CMake option has been removed
|
||||
|
||||
This option was used to compile GLFW directly linked with the Vulkan loader, instead of
|
||||
using dynamic loading to get hold of `vkGetInstanceProcAddr` at initialization. This is
|
||||
now done by calling the @ref glfwInitVulkanLoader function before initialization.
|
||||
|
||||
If you need backward compatibility, this macro can still be defined for GLFW 3.4 and will
|
||||
have no effect. The call to @ref glfwInitVulkanLoader can be conditionally enabled in
|
||||
your code by checking the @ref GLFW_VERSION_MAJOR and @ref GLFW_VERSION_MINOR macros.
|
||||
|
||||
|
||||
@subsubsection osmesa_option_34 GLFW_USE_OSMESA CMake option has been removed
|
||||
|
||||
This option was used to compile GLFW for the Null platform. The Null platform is now
|
||||
always supported. To produce a library binary that only supports this platform, the way
|
||||
this CMake option used to do, you will instead need to disable the default platform for
|
||||
the target OS. This means setting the @ref GLFW_BUILD_WIN32, @ref GLFW_BUILD_COCOA or
|
||||
@ref GLFW_BUILD_X11 CMake option to false.
|
||||
|
||||
You can set all of them to false and the ones that don't apply for the target OS will be
|
||||
ignored.
|
||||
|
||||
|
||||
@subsubsection wl_shell_34 Support for the wl_shell protocol has been removed
|
||||
|
||||
Support for the wl_shell protocol has been removed and GLFW now only supports
|
||||
@ -139,6 +194,9 @@ then GLFW will fail to initialize.
|
||||
@subsubsection functions_34 New functions in version 3.4
|
||||
|
||||
- @ref glfwInitAllocator
|
||||
- @ref glfwGetPlatform
|
||||
- @ref glfwPlatformSupported
|
||||
- @ref glfwInitVulkanLoader
|
||||
|
||||
|
||||
@subsubsection types_34 New types in version 3.4
|
||||
@ -151,6 +209,14 @@ then GLFW will fail to initialize.
|
||||
|
||||
@subsubsection constants_34 New constants in version 3.4
|
||||
|
||||
- @ref GLFW_PLATFORM
|
||||
- @ref GLFW_ANY_PLATFORM
|
||||
- @ref GLFW_PLATFORM_WIN32
|
||||
- @ref GLFW_PLATFORM_COCOA
|
||||
- @ref GLFW_PLATFORM_WAYLAND
|
||||
- @ref GLFW_PLATFORM_X11
|
||||
- @ref GLFW_PLATFORM_NULL
|
||||
- @ref GLFW_PLATFORM_UNAVAILABLE
|
||||
- @ref GLFW_POINTING_HAND_CURSOR
|
||||
- @ref GLFW_RESIZE_EW_CURSOR
|
||||
- @ref GLFW_RESIZE_NS_CURSOR
|
||||
|
@ -29,28 +29,34 @@ are also guides for the other areas of the GLFW API.
|
||||
- @ref input_guide
|
||||
|
||||
|
||||
@section vulkan_loader Linking against the Vulkan loader
|
||||
@section vulkan_loader Finding the Vulkan loader
|
||||
|
||||
By default, GLFW will look for the Vulkan loader on demand at runtime via its
|
||||
standard name (`vulkan-1.dll` on Windows, `libvulkan.so.1` on Linux and other
|
||||
Unix-like systems and `libvulkan.1.dylib` on macOS). This means that GLFW does
|
||||
not need to be linked against the loader. However, it also means that if you
|
||||
are using the static library form of the Vulkan loader GLFW will either fail to
|
||||
find it or (worse) use the wrong one.
|
||||
GLFW itself does not ever need to be linked against the Vulkan loader.
|
||||
|
||||
The @ref GLFW_VULKAN_STATIC CMake option makes GLFW call the Vulkan loader
|
||||
directly instead of dynamically loading it at runtime. Not linking against the
|
||||
Vulkan loader will then be a compile-time error.
|
||||
By default, GLFW will load the Vulkan loader dynamically at runtime via its standard name:
|
||||
`vulkan-1.dll` on Windows, `libvulkan.so.1` on Linux and other Unix-like systems and
|
||||
`libvulkan.1.dylib` on macOS.
|
||||
|
||||
@macos Because the Vulkan loader and ICD are not installed globally on macOS,
|
||||
you need to set up the application bundle according to the LunarG SDK
|
||||
documentation. This is explained in more detail in the
|
||||
@macos GLFW will also look up and search the executable subdirectory of your application
|
||||
bundle.
|
||||
|
||||
If your code is using a Vulkan loader with a different name or in a non-standard location
|
||||
you will need to direct GLFW to it. Pass your version of `vkGetInstanceProcAddr` to @ref
|
||||
glfwInitVulkanLoader before initializing GLFW and it will use that function for all Vulkan
|
||||
entry point retrieval. This prevents GLFW from dynamically loading the Vulkan loader.
|
||||
|
||||
@code
|
||||
glfwInitVulkanLoader(vkGetInstanceProcAddr);
|
||||
@endcode
|
||||
|
||||
@macos To make your application be redistributable you will need to set up the application
|
||||
bundle according to the LunarG SDK documentation. This is explained in more detail in the
|
||||
[SDK documentation for macOS](https://vulkan.lunarg.com/doc/sdk/latest/mac/getting_started.html).
|
||||
|
||||
|
||||
@section vulkan_include Including the Vulkan and GLFW header files
|
||||
@section vulkan_include Including the Vulkan header file
|
||||
|
||||
To include the Vulkan header, define @ref GLFW_INCLUDE_VULKAN before including
|
||||
To have GLFW include the Vulkan header, define @ref GLFW_INCLUDE_VULKAN before including
|
||||
the GLFW header.
|
||||
|
||||
@code
|
||||
@ -66,8 +72,13 @@ your own custom Vulkan header then do this before the GLFW header.
|
||||
#include <GLFW/glfw3.h>
|
||||
@endcode
|
||||
|
||||
Unless a Vulkan header is included, either by the GLFW header or above it, any
|
||||
GLFW functions that take or return Vulkan types will not be declared.
|
||||
Unless a Vulkan header is included, either by the GLFW header or above it, the following
|
||||
GLFW functions will not be declared, as depend on Vulkan types.
|
||||
|
||||
- @ref glfwInitVulkanLoader
|
||||
- @ref glfwGetInstanceProcAddress
|
||||
- @ref glfwGetPhysicalDevicePresentationSupport
|
||||
- @ref glfwCreateWindowSurface
|
||||
|
||||
The `VK_USE_PLATFORM_*_KHR` macros do not need to be defined for the Vulkan part
|
||||
of GLFW to work. Define them only if you are using these extensions directly.
|
||||
|
@ -447,7 +447,7 @@ The no error mode for OpenGL and OpenGL ES is described in detail by the
|
||||
extension.
|
||||
|
||||
|
||||
@subsubsection window_hints_win32 Windows specific window hints
|
||||
@subsubsection window_hints_win32 Win32 specific hints
|
||||
|
||||
@anchor GLFW_WIN32_KEYBOARD_MENU_hint
|
||||
__GLFW_WIN32_KEYBOARD_MENU__ specifies whether to allow access to the window
|
||||
@ -455,7 +455,7 @@ menu via the Alt+Space and Alt-and-then-Space keyboard shortcuts. This is
|
||||
ignored on other platforms.
|
||||
|
||||
|
||||
@subsubsection window_hints_osx macOS specific window hints
|
||||
@subsubsection window_hints_osx macOS specific hints
|
||||
|
||||
@anchor GLFW_COCOA_RETINA_FRAMEBUFFER_hint
|
||||
__GLFW_COCOA_RETINA_FRAMEBUFFER__ specifies whether to use full resolution
|
||||
|
@ -2,7 +2,7 @@
|
||||
// This is an example program for the GLFW library
|
||||
//
|
||||
// The program uses a "split window" view, rendering four views of the
|
||||
// same scene in one window (e.g. uesful for 3D modelling software). This
|
||||
// same scene in one window (e.g. useful for 3D modelling software). This
|
||||
// demo uses scissors to separate the four different rendering areas from
|
||||
// each other.
|
||||
//
|
||||
|
@ -190,6 +190,9 @@ extern "C" {
|
||||
#else /*__APPLE__*/
|
||||
|
||||
#include <GL/glcorearb.h>
|
||||
#if defined(GLFW_INCLUDE_GLEXT)
|
||||
#include <GL/glext.h>
|
||||
#endif
|
||||
|
||||
#endif /*__APPLE__*/
|
||||
|
||||
@ -372,7 +375,7 @@ extern "C" {
|
||||
*
|
||||
* The naming of the key codes follow these rules:
|
||||
* - The US keyboard layout is used
|
||||
* - Names of printable alpha-numeric characters are used (e.g. "A", "R",
|
||||
* - Names of printable alphanumeric characters are used (e.g. "A", "R",
|
||||
* "3", etc.)
|
||||
* - For non-alphanumeric characters, Unicode:ish names are used (e.g.
|
||||
* "COMMA", "LEFT_SQUARE_BRACKET", etc.). Note that some names do not
|
||||
@ -717,7 +720,7 @@ extern "C" {
|
||||
* GLFW could not find support for the requested API on the system.
|
||||
*
|
||||
* @analysis The installed graphics driver does not support the requested
|
||||
* API, or does not support it via the chosen context creation backend.
|
||||
* API, or does not support it via the chosen context creation API.
|
||||
* Below are a few examples.
|
||||
*
|
||||
* @par
|
||||
@ -786,7 +789,7 @@ extern "C" {
|
||||
/*! @brief The specified cursor shape is not available.
|
||||
*
|
||||
* The specified standard cursor shape is not available, either because the
|
||||
* current system cursor theme does not provide it or because it is not
|
||||
* current platform cursor theme does not provide it or because it is not
|
||||
* available on the platform.
|
||||
*
|
||||
* @analysis Platform or system settings limitation. Pick another
|
||||
@ -821,6 +824,28 @@ extern "C" {
|
||||
* updating any existing out parameters.
|
||||
*/
|
||||
#define GLFW_FEATURE_UNIMPLEMENTED 0x0001000D
|
||||
/*! @brief Platform unavailable or no matching platform was found.
|
||||
*
|
||||
* If emitted during initialization, no matching platform was found. If @ref
|
||||
* GLFW_PLATFORM is set to `GLFW_ANY_PLATFORM`, GLFW could not detect any of the
|
||||
* platforms supported by this library binary, except for the Null platform. If set to
|
||||
* a specific platform, it is either not supported by this library binary or GLFW was not
|
||||
* able to detect it.
|
||||
*
|
||||
* If emitted by a native access function, GLFW was initialized for a different platform
|
||||
* than the function is for.
|
||||
*
|
||||
* @analysis Failure to detect any platform usually only happens on non-macOS Unix
|
||||
* systems, either when no window system is running or the program was run from
|
||||
* a terminal that does not have the necessary environment variables. Fall back to
|
||||
* a different platform if possible or notify the user that no usable platform was
|
||||
* detected.
|
||||
*
|
||||
* Failure to detect a specific platform may have the same cause as above or be because
|
||||
* support for that platform was not compiled in. Call @ref glfwPlatformSupported to
|
||||
* check whether a specific platform is supported by a library binary.
|
||||
*/
|
||||
#define GLFW_PLATFORM_UNAVAILABLE 0x0001000E
|
||||
/*! @} */
|
||||
|
||||
/*! @addtogroup window
|
||||
@ -1003,7 +1028,7 @@ extern "C" {
|
||||
* and [attribute](@ref GLFW_CONTEXT_VERSION_MINOR_attrib).
|
||||
*/
|
||||
#define GLFW_CONTEXT_VERSION_MINOR 0x00022003
|
||||
/*! @brief Context client API revision number hint and attribute.
|
||||
/*! @brief Context client API revision number attribute.
|
||||
*
|
||||
* Context client API revision number
|
||||
* [attribute](@ref GLFW_CONTEXT_REVISION_attrib).
|
||||
@ -1125,7 +1150,7 @@ extern "C" {
|
||||
* @brief Standard system cursor shapes.
|
||||
*
|
||||
* These are the [standard cursor shapes](@ref cursor_standard) that can be
|
||||
* requested from the window system.
|
||||
* requested from the platform (window system).
|
||||
*
|
||||
* @ingroup input
|
||||
* @{ */
|
||||
@ -1242,6 +1267,11 @@ extern "C" {
|
||||
* ANGLE rendering backend [init hint](@ref GLFW_ANGLE_PLATFORM_TYPE_hint).
|
||||
*/
|
||||
#define GLFW_ANGLE_PLATFORM_TYPE 0x00050002
|
||||
/*! @brief Platform selection init hint.
|
||||
*
|
||||
* Platform selection [init hint](@ref GLFW_PLATFORM).
|
||||
*/
|
||||
#define GLFW_PLATFORM 0x00050003
|
||||
/*! @brief macOS specific init hint.
|
||||
*
|
||||
* macOS specific [init hint](@ref GLFW_COCOA_CHDIR_RESOURCES_hint).
|
||||
@ -1259,6 +1289,20 @@ extern "C" {
|
||||
#define GLFW_X11_XCB_VULKAN_SURFACE 0x00052001
|
||||
/*! @} */
|
||||
|
||||
/*! @addtogroup init
|
||||
* @{ */
|
||||
/*! @brief Hint value that enables automatic platform selection.
|
||||
*
|
||||
* Hint value for @ref GLFW_PLATFORM that enables automatic platform selection.
|
||||
*/
|
||||
#define GLFW_ANY_PLATFORM 0x00060000
|
||||
#define GLFW_PLATFORM_WIN32 0x00060001
|
||||
#define GLFW_PLATFORM_COCOA 0x00060002
|
||||
#define GLFW_PLATFORM_WAYLAND 0x00060003
|
||||
#define GLFW_PLATFORM_X11 0x00060004
|
||||
#define GLFW_PLATFORM_NULL 0x00060005
|
||||
/*! @} */
|
||||
|
||||
#define GLFW_DONT_CARE -1
|
||||
|
||||
|
||||
@ -1782,7 +1826,7 @@ typedef void (* GLFWscrollfun)(GLFWwindow* window, double xoffset, double yoffse
|
||||
*
|
||||
* @param[in] window The window that received the event.
|
||||
* @param[in] key The [keyboard key](@ref keys) that was pressed or released.
|
||||
* @param[in] scancode The system-specific scancode of the key.
|
||||
* @param[in] scancode The platform-specific scancode of the key.
|
||||
* @param[in] action `GLFW_PRESS`, `GLFW_RELEASE` or `GLFW_REPEAT`. Future
|
||||
* releases may add more actions.
|
||||
* @param[in] mods Bit field describing which [modifier keys](@ref mods) were
|
||||
@ -2059,10 +2103,15 @@ typedef struct GLFWallocator
|
||||
* Additional calls to this function after successful initialization but before
|
||||
* termination will return `GLFW_TRUE` immediately.
|
||||
*
|
||||
* The @ref GLFW_PLATFORM init hint controls which platforms are considered during
|
||||
* initialization. This also depends on which platforms the library was compiled to
|
||||
* support.
|
||||
*
|
||||
* @return `GLFW_TRUE` if successful, or `GLFW_FALSE` if an
|
||||
* [error](@ref error_handling) occurred.
|
||||
*
|
||||
* @errors Possible errors include @ref GLFW_PLATFORM_ERROR.
|
||||
* @errors Possible errors include @ref GLFW_PLATFORM_UNAVAILABLE and @ref
|
||||
* GLFW_PLATFORM_ERROR.
|
||||
*
|
||||
* @remark @macos This function will change the current directory of the
|
||||
* application to the `Contents/Resources` subdirectory of the application's
|
||||
@ -2187,6 +2236,54 @@ GLFWAPI void glfwInitHint(int hint, int value);
|
||||
*/
|
||||
GLFWAPI void glfwInitAllocator(const GLFWallocator* allocator);
|
||||
|
||||
#if defined(VK_VERSION_1_0)
|
||||
|
||||
/*! @brief Sets the desired Vulkan `vkGetInstanceProcAddr` function.
|
||||
*
|
||||
* This function sets the `vkGetInstanceProcAddr` function that GLFW will use for all
|
||||
* Vulkan related entry point queries.
|
||||
*
|
||||
* This feature is mostly useful on macOS, if your copy of the Vulkan loader is in
|
||||
* a location where GLFW cannot find it through dynamic loading, or if you are still
|
||||
* using the static library version of the loader.
|
||||
*
|
||||
* If set to `NULL`, GLFW will try to load the Vulkan loader dynamically by its standard
|
||||
* name and get this function from there. This is the default behavior.
|
||||
*
|
||||
* The standard name of the loader is `vulkan-1.dll` on Windows, `libvulkan.so.1` on
|
||||
* Linux and other Unix-like systems and `libvulkan.1.dylib` on macOS. If your code is
|
||||
* also loading it via these names then you probably don't need to use this function.
|
||||
*
|
||||
* The function address you set is never reset by GLFW, but it only takes effect during
|
||||
* initialization. Once GLFW has been initialized, any updates will be ignored until the
|
||||
* library is terminated and initialized again.
|
||||
*
|
||||
* @param[in] loader The address of the function to use, or `NULL`.
|
||||
*
|
||||
* @par Loader function signature
|
||||
* @code
|
||||
* PFN_vkVoidFunction vkGetInstanceProcAddr(VkInstance instance, const char* name)
|
||||
* @endcode
|
||||
* For more information about this function, see the
|
||||
* [Vulkan Registry](https://www.khronos.org/registry/vulkan/).
|
||||
*
|
||||
* @errors None.
|
||||
*
|
||||
* @remark This function may be called before @ref glfwInit.
|
||||
*
|
||||
* @thread_safety This function must only be called from the main thread.
|
||||
*
|
||||
* @sa @ref vulkan_loader
|
||||
* @sa @ref glfwInit
|
||||
*
|
||||
* @since Added in version 3.4.
|
||||
*
|
||||
* @ingroup init
|
||||
*/
|
||||
GLFWAPI void glfwInitVulkanLoader(PFN_vkGetInstanceProcAddr loader);
|
||||
|
||||
#endif /*VK_VERSION_1_0*/
|
||||
|
||||
/*! @brief Retrieves the version of the GLFW library.
|
||||
*
|
||||
* This function retrieves the major, minor and revision numbers of the GLFW
|
||||
@ -2217,15 +2314,18 @@ GLFWAPI void glfwGetVersion(int* major, int* minor, int* rev);
|
||||
/*! @brief Returns a string describing the compile-time configuration.
|
||||
*
|
||||
* This function returns the compile-time generated
|
||||
* [version string](@ref intro_version_string) of the GLFW library binary. It
|
||||
* describes the version, platform, compiler and any platform-specific
|
||||
* compile-time options. It should not be confused with the OpenGL or OpenGL
|
||||
* ES version string, queried with `glGetString`.
|
||||
* [version string](@ref intro_version_string) of the GLFW library binary. It describes
|
||||
* the version, platforms, compiler and any platform or operating system specific
|
||||
* compile-time options. It should not be confused with the OpenGL or OpenGL ES version
|
||||
* string, queried with `glGetString`.
|
||||
*
|
||||
* __Do not use the version string__ to parse the GLFW library version. The
|
||||
* @ref glfwGetVersion function provides the version of the running library
|
||||
* binary in numerical format.
|
||||
*
|
||||
* __Do not use the version string__ to parse what platforms are supported. The @ref
|
||||
* glfwPlatformSupported function lets you query platform support.
|
||||
*
|
||||
* @return The ASCII encoded GLFW version string.
|
||||
*
|
||||
* @errors None.
|
||||
@ -2322,6 +2422,51 @@ GLFWAPI int glfwGetError(const char** description);
|
||||
*/
|
||||
GLFWAPI GLFWerrorfun glfwSetErrorCallback(GLFWerrorfun callback);
|
||||
|
||||
/*! @brief Returns the currently selected platform.
|
||||
*
|
||||
* This function returns the platform that was selected during initialization. The
|
||||
* returned value will be one of `GLFW_PLATFORM_WIN32`, `GLFW_PLATFORM_COCOA`,
|
||||
* `GLFW_PLATFORM_WAYLAND`, `GLFW_PLATFORM_X11` or `GLFW_PLATFORM_NULL`.
|
||||
*
|
||||
* @return The currently selected platform, or zero if an error occurred.
|
||||
*
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
|
||||
*
|
||||
* @thread_safety This function may be called from any thread.
|
||||
*
|
||||
* @sa @ref platform
|
||||
* @sa @ref glfwPlatformSupported
|
||||
*
|
||||
* @since Added in version 3.4.
|
||||
*
|
||||
* @ingroup init
|
||||
*/
|
||||
GLFWAPI int glfwGetPlatform(void);
|
||||
|
||||
/*! @brief Returns whether the library includes support for the specified platform.
|
||||
*
|
||||
* This function returns whether the library was compiled with support for the specified
|
||||
* platform. The platform must be one of `GLFW_PLATFORM_WIN32`, `GLFW_PLATFORM_COCOA`,
|
||||
* `GLFW_PLATFORM_WAYLAND`, `GLFW_PLATFORM_X11` or `GLFW_PLATFORM_NULL`.
|
||||
*
|
||||
* @param[in] platform The platform to query.
|
||||
* @return `GLFW_TRUE` if the platform is supported, or `GLFW_FALSE` otherwise.
|
||||
*
|
||||
* @errors Possible errors include @ref GLFW_INVALID_ENUM.
|
||||
*
|
||||
* @remark This function may be called before @ref glfwInit.
|
||||
*
|
||||
* @thread_safety This function may be called from any thread.
|
||||
*
|
||||
* @sa @ref platform
|
||||
* @sa @ref glfwGetPlatform
|
||||
*
|
||||
* @since Added in version 3.4.
|
||||
*
|
||||
* @ingroup init
|
||||
*/
|
||||
GLFWAPI int glfwPlatformSupported(int platform);
|
||||
|
||||
/*! @brief Returns the currently connected monitors.
|
||||
*
|
||||
* This function returns an array of handles for all currently connected
|
||||
@ -2405,7 +2550,7 @@ GLFWAPI void glfwGetMonitorPos(GLFWmonitor* monitor, int* xpos, int* ypos);
|
||||
* This function returns the position, in screen coordinates, of the upper-left
|
||||
* corner of the work area of the specified monitor along with the work area
|
||||
* size in screen coordinates. The work area is defined as the area of the
|
||||
* monitor not occluded by the operating system task bar where present. If no
|
||||
* monitor not occluded by the window system task bar where present. If no
|
||||
* task bar exists then the work area is the monitor resolution in screen
|
||||
* coordinates.
|
||||
*
|
||||
@ -2436,7 +2581,7 @@ GLFWAPI void glfwGetMonitorWorkarea(GLFWmonitor* monitor, int* xpos, int* ypos,
|
||||
* This function returns the size, in millimetres, of the display area of the
|
||||
* specified monitor.
|
||||
*
|
||||
* Some systems do not provide accurate monitor size information, either
|
||||
* Some platforms do not provide accurate monitor size information, either
|
||||
* because the monitor
|
||||
* [EDID](https://en.wikipedia.org/wiki/Extended_display_identification_data)
|
||||
* data is incorrect or because the driver does not report it accurately.
|
||||
@ -2452,8 +2597,8 @@ GLFWAPI void glfwGetMonitorWorkarea(GLFWmonitor* monitor, int* xpos, int* ypos,
|
||||
*
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
|
||||
*
|
||||
* @remark @win32 calculates the returned physical size from the
|
||||
* current resolution and system DPI instead of querying the monitor EDID data.
|
||||
* @remark @win32 On Windows 8 and earlier the physical size is calculated from
|
||||
* the current resolution and system DPI instead of querying the monitor EDID data.
|
||||
*
|
||||
* @thread_safety This function must only be called from the main thread.
|
||||
*
|
||||
@ -3125,7 +3270,8 @@ GLFWAPI void glfwSetWindowTitle(GLFWwindow* window, const char* title);
|
||||
* count is zero.
|
||||
*
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
|
||||
* GLFW_PLATFORM_ERROR and @ref GLFW_FEATURE_UNAVAILABLE (see remarks).
|
||||
* GLFW_INVALID_VALUE, @ref GLFW_PLATFORM_ERROR and @ref
|
||||
* GLFW_FEATURE_UNAVAILABLE (see remarks).
|
||||
*
|
||||
* @pointer_lifetime The specified image data is copied before this function
|
||||
* returns.
|
||||
@ -3450,7 +3596,7 @@ GLFWAPI void glfwGetWindowFrameSize(GLFWwindow* window, int* left, int* top, int
|
||||
* regardless of their DPI and scaling settings. This relies on the system DPI
|
||||
* and scaling settings being somewhat correct.
|
||||
*
|
||||
* On systems where each monitors can have its own content scale, the window
|
||||
* On platforms where each monitors can have its own content scale, the window
|
||||
* content scale will depend on which monitor the system considers the window
|
||||
* to be on.
|
||||
*
|
||||
@ -3631,6 +3777,11 @@ GLFWAPI void glfwMaximizeWindow(GLFWwindow* window);
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
|
||||
* GLFW_PLATFORM_ERROR.
|
||||
*
|
||||
* @remark @wayland Because Wayland wants every frame of the desktop to be
|
||||
* complete, this function does not immediately make the window visible.
|
||||
* Instead it will become visible the next time the window framebuffer is
|
||||
* updated after this call.
|
||||
*
|
||||
* @thread_safety This function must only be called from the main thread.
|
||||
*
|
||||
* @sa @ref window_hide
|
||||
@ -4754,8 +4905,8 @@ GLFWAPI void glfwSetCursorPos(GLFWwindow* window, double xpos, double ypos);
|
||||
* @return The handle of the created cursor, or `NULL` if an
|
||||
* [error](@ref error_handling) occurred.
|
||||
*
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
|
||||
* GLFW_PLATFORM_ERROR.
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
|
||||
* GLFW_INVALID_VALUE and @ref GLFW_PLATFORM_ERROR.
|
||||
*
|
||||
* @pointer_lifetime The specified image data is copied before this function
|
||||
* returns.
|
||||
@ -5570,6 +5721,8 @@ GLFWAPI int glfwUpdateGamepadMappings(const char* string);
|
||||
* joystick is not present, does not have a mapping or an
|
||||
* [error](@ref error_handling) occurred.
|
||||
*
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref GLFW_INVALID_ENUM.
|
||||
*
|
||||
* @pointer_lifetime The returned string is allocated and freed by GLFW. You
|
||||
* should not free it yourself. It is valid until the specified joystick is
|
||||
* disconnected, the gamepad mappings are updated or the library is terminated.
|
||||
@ -5659,8 +5812,8 @@ GLFWAPI void glfwSetClipboardString(GLFWwindow* window, const char* string);
|
||||
* @return The contents of the clipboard as a UTF-8 encoded string, or `NULL`
|
||||
* if an [error](@ref error_handling) occurred.
|
||||
*
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
|
||||
* GLFW_PLATFORM_ERROR.
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
|
||||
* GLFW_FORMAT_UNAVAILABLE and @ref GLFW_PLATFORM_ERROR.
|
||||
*
|
||||
* @pointer_lifetime The returned string is allocated and freed by GLFW. You
|
||||
* should not free it yourself. It is valid until the next call to @ref
|
||||
@ -5689,7 +5842,7 @@ GLFWAPI const char* glfwGetClipboardString(GLFWwindow* window);
|
||||
*
|
||||
* The resolution of the timer is system dependent, but is usually on the order
|
||||
* of a few micro- or nanoseconds. It uses the highest-resolution monotonic
|
||||
* time source on each supported platform.
|
||||
* time source on each operating system.
|
||||
*
|
||||
* @return The current time, in seconds, or zero if an
|
||||
* [error](@ref error_handling) occurred.
|
||||
@ -5906,7 +6059,7 @@ GLFWAPI void glfwSwapBuffers(GLFWwindow* window);
|
||||
* GLFW_NO_CURRENT_CONTEXT and @ref GLFW_PLATFORM_ERROR.
|
||||
*
|
||||
* @remark This function is not called during context creation, leaving the
|
||||
* swap interval set to whatever is the default on that platform. This is done
|
||||
* swap interval set to whatever is the default for that API. This is done
|
||||
* because some swap interval extensions used by GLFW do not allow the swap
|
||||
* interval to be reset to zero once it has been set to a non-zero value.
|
||||
*
|
||||
@ -6151,13 +6304,11 @@ GLFWAPI GLFWusercontext* glfwGetCurrentUserContext(void);
|
||||
* This function returns whether the Vulkan loader and any minimally functional
|
||||
* ICD have been found.
|
||||
*
|
||||
* The availability of a Vulkan loader and even an ICD does not by itself
|
||||
* guarantee that surface creation or even instance creation is possible.
|
||||
* For example, on Fermi systems Nvidia will install an ICD that provides no
|
||||
* actual Vulkan support. Call @ref glfwGetRequiredInstanceExtensions to check
|
||||
* whether the extensions necessary for Vulkan surface creation are available
|
||||
* and @ref glfwGetPhysicalDevicePresentationSupport to check whether a queue
|
||||
* family of a physical device supports image presentation.
|
||||
* The availability of a Vulkan loader and even an ICD does not by itself guarantee that
|
||||
* surface creation or even instance creation is possible. Call @ref
|
||||
* glfwGetRequiredInstanceExtensions to check whether the extensions necessary for Vulkan
|
||||
* surface creation are available and @ref glfwGetPhysicalDevicePresentationSupport to
|
||||
* check whether a queue family of a physical device supports image presentation.
|
||||
*
|
||||
* @return `GLFW_TRUE` if Vulkan is minimally available, or `GLFW_FALSE`
|
||||
* otherwise.
|
||||
@ -6203,9 +6354,6 @@ GLFWAPI int glfwVulkanSupported(void);
|
||||
* returned array, as it is an error to specify an extension more than once in
|
||||
* the `VkInstanceCreateInfo` struct.
|
||||
*
|
||||
* @remark @macos GLFW currently supports both the `VK_MVK_macos_surface` and
|
||||
* the newer `VK_EXT_metal_surface` extensions.
|
||||
*
|
||||
* @pointer_lifetime The returned array is allocated and freed by GLFW. You
|
||||
* should not free it yourself. It is guaranteed to be valid only until the
|
||||
* library is terminated.
|
||||
@ -6344,17 +6492,20 @@ GLFWAPI int glfwGetPhysicalDevicePresentationSupport(VkInstance instance, VkPhys
|
||||
* @ref glfwVulkanSupported and @ref glfwGetRequiredInstanceExtensions should
|
||||
* eliminate almost all occurrences of these errors.
|
||||
*
|
||||
* @remark @macos This function currently only supports the
|
||||
* `VK_MVK_macos_surface` extension from MoltenVK.
|
||||
* @remark @macos GLFW prefers the `VK_EXT_metal_surface` extension, with the
|
||||
* `VK_MVK_macos_surface` extension as a fallback. The name of the selected
|
||||
* extension, if any, is included in the array returned by @ref
|
||||
* glfwGetRequiredInstanceExtensions.
|
||||
*
|
||||
* @remark @macos This function creates and sets a `CAMetalLayer` instance for
|
||||
* the window content view, which is required for MoltenVK to function.
|
||||
*
|
||||
* @remark @x11 GLFW by default attempts to use the `VK_KHR_xcb_surface`
|
||||
* extension, if available. You can make it prefer the `VK_KHR_xlib_surface`
|
||||
* extension by setting the
|
||||
* @remark @x11 By default GLFW prefers the `VK_KHR_xcb_surface` extension,
|
||||
* with the `VK_KHR_xlib_surface` extension as a fallback. You can make
|
||||
* `VK_KHR_xlib_surface` the preferred extension by setting the
|
||||
* [GLFW_X11_XCB_VULKAN_SURFACE](@ref GLFW_X11_XCB_VULKAN_SURFACE_hint) init
|
||||
* hint.
|
||||
* hint. The name of the selected extension, if any, is included in the array
|
||||
* returned by @ref glfwGetRequiredInstanceExtensions.
|
||||
*
|
||||
* @thread_safety This function may be called from any thread. For
|
||||
* synchronization details of Vulkan objects, see the Vulkan specification.
|
||||
|
@ -82,9 +82,10 @@ extern "C" {
|
||||
*************************************************************************/
|
||||
|
||||
#if defined(GLFW_EXPOSE_NATIVE_WIN32) || defined(GLFW_EXPOSE_NATIVE_WGL)
|
||||
// This is a workaround for the fact that glfw3.h needs to export APIENTRY (for
|
||||
// example to allow applications to correctly declare a GL_KHR_debug callback)
|
||||
// but windows.h assumes no one will define APIENTRY before it does
|
||||
/* This is a workaround for the fact that glfw3.h needs to export APIENTRY (for
|
||||
* example to allow applications to correctly declare a GL_KHR_debug callback)
|
||||
* but windows.h assumes no one will define APIENTRY before it does
|
||||
*/
|
||||
#if defined(GLFW_APIENTRY_DEFINED)
|
||||
#undef APIENTRY
|
||||
#undef GLFW_APIENTRY_DEFINED
|
||||
@ -111,12 +112,22 @@ extern "C" {
|
||||
/* NSGL is declared by Cocoa.h */
|
||||
#endif
|
||||
#if defined(GLFW_EXPOSE_NATIVE_GLX)
|
||||
/* This is a workaround for the fact that glfw3.h defines GLAPIENTRY because by
|
||||
* default it also acts as an OpenGL header
|
||||
* However, glx.h will include gl.h, which will define it unconditionally
|
||||
*/
|
||||
#undef GLAPIENTRY
|
||||
#include <GL/glx.h>
|
||||
#endif
|
||||
#if defined(GLFW_EXPOSE_NATIVE_EGL)
|
||||
#include <EGL/egl.h>
|
||||
#endif
|
||||
#if defined(GLFW_EXPOSE_NATIVE_OSMESA)
|
||||
/* This is a workaround for the fact that glfw3.h defines GLAPIENTRY because by
|
||||
* default it also acts as an OpenGL header
|
||||
* However, osmesa.h will include gl.h, which will define it unconditionally
|
||||
*/
|
||||
#undef GLAPIENTRY
|
||||
#include <GL/osmesa.h>
|
||||
#endif
|
||||
|
||||
@ -132,6 +143,8 @@ extern "C" {
|
||||
* of the specified monitor, or `NULL` if an [error](@ref error_handling)
|
||||
* occurred.
|
||||
*
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
|
||||
*
|
||||
* @thread_safety This function may be called from any thread. Access is not
|
||||
* synchronized.
|
||||
*
|
||||
@ -147,6 +160,8 @@ GLFWAPI const char* glfwGetWin32Adapter(GLFWmonitor* monitor);
|
||||
* `\\.\DISPLAY1\Monitor0`) of the specified monitor, or `NULL` if an
|
||||
* [error](@ref error_handling) occurred.
|
||||
*
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
|
||||
*
|
||||
* @thread_safety This function may be called from any thread. Access is not
|
||||
* synchronized.
|
||||
*
|
||||
@ -161,6 +176,8 @@ GLFWAPI const char* glfwGetWin32Monitor(GLFWmonitor* monitor);
|
||||
* @return The `HWND` of the specified window, or `NULL` if an
|
||||
* [error](@ref error_handling) occurred.
|
||||
*
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
|
||||
*
|
||||
* @remark The `HDC` associated with the window can be queried with the
|
||||
* [GetDC](https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getdc)
|
||||
* function.
|
||||
@ -185,6 +202,9 @@ GLFWAPI HWND glfwGetWin32Window(GLFWwindow* window);
|
||||
* @return The `HGLRC` of the specified window, or `NULL` if an
|
||||
* [error](@ref error_handling) occurred.
|
||||
*
|
||||
* @errors Possible errors include @ref GLFW_NO_WINDOW_CONTEXT and @ref
|
||||
* GLFW_NOT_INITIALIZED.
|
||||
*
|
||||
* @remark The `HDC` associated with the window can be queried with the
|
||||
* [GetDC](https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getdc)
|
||||
* function.
|
||||
@ -209,6 +229,8 @@ GLFWAPI HGLRC glfwGetWGLContext(GLFWwindow* window);
|
||||
* @return The `CGDirectDisplayID` of the specified monitor, or
|
||||
* `kCGNullDirectDisplay` if an [error](@ref error_handling) occurred.
|
||||
*
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
|
||||
*
|
||||
* @thread_safety This function may be called from any thread. Access is not
|
||||
* synchronized.
|
||||
*
|
||||
@ -223,6 +245,8 @@ GLFWAPI CGDirectDisplayID glfwGetCocoaMonitor(GLFWmonitor* monitor);
|
||||
* @return The `NSWindow` of the specified window, or `nil` if an
|
||||
* [error](@ref error_handling) occurred.
|
||||
*
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
|
||||
*
|
||||
* @thread_safety This function may be called from any thread. Access is not
|
||||
* synchronized.
|
||||
*
|
||||
@ -239,6 +263,9 @@ GLFWAPI id glfwGetCocoaWindow(GLFWwindow* window);
|
||||
* @return The `NSOpenGLContext` of the specified window, or `nil` if an
|
||||
* [error](@ref error_handling) occurred.
|
||||
*
|
||||
* @errors Possible errors include @ref GLFW_NO_WINDOW_CONTEXT and @ref
|
||||
* GLFW_NOT_INITIALIZED.
|
||||
*
|
||||
* @thread_safety This function may be called from any thread. Access is not
|
||||
* synchronized.
|
||||
*
|
||||
@ -255,6 +282,8 @@ GLFWAPI id glfwGetNSGLContext(GLFWwindow* window);
|
||||
* @return The `Display` used by GLFW, or `NULL` if an
|
||||
* [error](@ref error_handling) occurred.
|
||||
*
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
|
||||
*
|
||||
* @thread_safety This function may be called from any thread. Access is not
|
||||
* synchronized.
|
||||
*
|
||||
@ -269,6 +298,8 @@ GLFWAPI Display* glfwGetX11Display(void);
|
||||
* @return The `RRCrtc` of the specified monitor, or `None` if an
|
||||
* [error](@ref error_handling) occurred.
|
||||
*
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
|
||||
*
|
||||
* @thread_safety This function may be called from any thread. Access is not
|
||||
* synchronized.
|
||||
*
|
||||
@ -283,6 +314,8 @@ GLFWAPI RRCrtc glfwGetX11Adapter(GLFWmonitor* monitor);
|
||||
* @return The `RROutput` of the specified monitor, or `None` if an
|
||||
* [error](@ref error_handling) occurred.
|
||||
*
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
|
||||
*
|
||||
* @thread_safety This function may be called from any thread. Access is not
|
||||
* synchronized.
|
||||
*
|
||||
@ -297,6 +330,8 @@ GLFWAPI RROutput glfwGetX11Monitor(GLFWmonitor* monitor);
|
||||
* @return The `Window` of the specified window, or `None` if an
|
||||
* [error](@ref error_handling) occurred.
|
||||
*
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
|
||||
*
|
||||
* @thread_safety This function may be called from any thread. Access is not
|
||||
* synchronized.
|
||||
*
|
||||
@ -363,6 +398,9 @@ GLFWAPI const char* glfwGetX11SelectionString(void);
|
||||
* @return The `GLXContext` of the specified window, or `NULL` if an
|
||||
* [error](@ref error_handling) occurred.
|
||||
*
|
||||
* @errors Possible errors include @ref GLFW_NO_WINDOW_CONTEXT and @ref
|
||||
* GLFW_NOT_INITIALIZED.
|
||||
*
|
||||
* @thread_safety This function may be called from any thread. Access is not
|
||||
* synchronized.
|
||||
*
|
||||
@ -377,6 +415,9 @@ GLFWAPI GLXContext glfwGetGLXContext(GLFWwindow* window);
|
||||
* @return The `GLXWindow` of the specified window, or `None` if an
|
||||
* [error](@ref error_handling) occurred.
|
||||
*
|
||||
* @errors Possible errors include @ref GLFW_NO_WINDOW_CONTEXT and @ref
|
||||
* GLFW_NOT_INITIALIZED.
|
||||
*
|
||||
* @thread_safety This function may be called from any thread. Access is not
|
||||
* synchronized.
|
||||
*
|
||||
@ -393,6 +434,8 @@ GLFWAPI GLXWindow glfwGetGLXWindow(GLFWwindow* window);
|
||||
* @return The `struct wl_display*` used by GLFW, or `NULL` if an
|
||||
* [error](@ref error_handling) occurred.
|
||||
*
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
|
||||
*
|
||||
* @thread_safety This function may be called from any thread. Access is not
|
||||
* synchronized.
|
||||
*
|
||||
@ -407,6 +450,8 @@ GLFWAPI struct wl_display* glfwGetWaylandDisplay(void);
|
||||
* @return The `struct wl_output*` of the specified monitor, or `NULL` if an
|
||||
* [error](@ref error_handling) occurred.
|
||||
*
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
|
||||
*
|
||||
* @thread_safety This function may be called from any thread. Access is not
|
||||
* synchronized.
|
||||
*
|
||||
@ -421,6 +466,8 @@ GLFWAPI struct wl_output* glfwGetWaylandMonitor(GLFWmonitor* monitor);
|
||||
* @return The main `struct wl_surface*` of the specified window, or `NULL` if
|
||||
* an [error](@ref error_handling) occurred.
|
||||
*
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
|
||||
*
|
||||
* @thread_safety This function may be called from any thread. Access is not
|
||||
* synchronized.
|
||||
*
|
||||
@ -437,6 +484,8 @@ GLFWAPI struct wl_surface* glfwGetWaylandWindow(GLFWwindow* window);
|
||||
* @return The `EGLDisplay` used by GLFW, or `EGL_NO_DISPLAY` if an
|
||||
* [error](@ref error_handling) occurred.
|
||||
*
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
|
||||
*
|
||||
* @thread_safety This function may be called from any thread. Access is not
|
||||
* synchronized.
|
||||
*
|
||||
@ -451,6 +500,9 @@ GLFWAPI EGLDisplay glfwGetEGLDisplay(void);
|
||||
* @return The `EGLContext` of the specified window, or `EGL_NO_CONTEXT` if an
|
||||
* [error](@ref error_handling) occurred.
|
||||
*
|
||||
* @errors Possible errors include @ref GLFW_NO_WINDOW_CONTEXT and @ref
|
||||
* GLFW_NOT_INITIALIZED.
|
||||
*
|
||||
* @thread_safety This function may be called from any thread. Access is not
|
||||
* synchronized.
|
||||
*
|
||||
@ -465,6 +517,9 @@ GLFWAPI EGLContext glfwGetEGLContext(GLFWwindow* window);
|
||||
* @return The `EGLSurface` of the specified window, or `EGL_NO_SURFACE` if an
|
||||
* [error](@ref error_handling) occurred.
|
||||
*
|
||||
* @errors Possible errors include @ref GLFW_NO_WINDOW_CONTEXT and @ref
|
||||
* GLFW_NOT_INITIALIZED.
|
||||
*
|
||||
* @thread_safety This function may be called from any thread. Access is not
|
||||
* synchronized.
|
||||
*
|
||||
@ -488,6 +543,9 @@ GLFWAPI EGLSurface glfwGetEGLSurface(GLFWwindow* window);
|
||||
* @return `GLFW_TRUE` if successful, or `GLFW_FALSE` if an
|
||||
* [error](@ref error_handling) occurred.
|
||||
*
|
||||
* @errors Possible errors include @ref GLFW_NO_WINDOW_CONTEXT and @ref
|
||||
* GLFW_NOT_INITIALIZED.
|
||||
*
|
||||
* @thread_safety This function may be called from any thread. Access is not
|
||||
* synchronized.
|
||||
*
|
||||
@ -509,6 +567,9 @@ GLFWAPI int glfwGetOSMesaColorBuffer(GLFWwindow* window, int* width, int* height
|
||||
* @return `GLFW_TRUE` if successful, or `GLFW_FALSE` if an
|
||||
* [error](@ref error_handling) occurred.
|
||||
*
|
||||
* @errors Possible errors include @ref GLFW_NO_WINDOW_CONTEXT and @ref
|
||||
* GLFW_NOT_INITIALIZED.
|
||||
*
|
||||
* @thread_safety This function may be called from any thread. Access is not
|
||||
* synchronized.
|
||||
*
|
||||
@ -523,6 +584,9 @@ GLFWAPI int glfwGetOSMesaDepthBuffer(GLFWwindow* window, int* width, int* height
|
||||
* @return The `OSMesaContext` of the specified window, or `NULL` if an
|
||||
* [error](@ref error_handling) occurred.
|
||||
*
|
||||
* @errors Possible errors include @ref GLFW_NO_WINDOW_CONTEXT and @ref
|
||||
* GLFW_NOT_INITIALIZED.
|
||||
*
|
||||
* @thread_safety This function may be called from any thread. Access is not
|
||||
* synchronized.
|
||||
*
|
||||
|
@ -2,8 +2,23 @@
|
||||
add_library(glfw ${GLFW_LIBRARY_TYPE}
|
||||
"${GLFW_SOURCE_DIR}/include/GLFW/glfw3.h"
|
||||
"${GLFW_SOURCE_DIR}/include/GLFW/glfw3native.h"
|
||||
internal.h mappings.h context.c init.c input.c monitor.c
|
||||
vulkan.c window.c)
|
||||
internal.h platform.h mappings.h
|
||||
context.c init.c input.c monitor.c platform.c vulkan.c window.c
|
||||
egl_context.c osmesa_context.c null_platform.h null_joystick.h
|
||||
null_init.c null_monitor.c null_window.c null_joystick.c)
|
||||
|
||||
# The time, thread and module code is shared between all backends on a given OS,
|
||||
# including the null backend, which still needs those bits to be functional
|
||||
if (APPLE)
|
||||
target_sources(glfw PRIVATE cocoa_time.h cocoa_time.c posix_thread.h
|
||||
posix_module.c posix_thread.c)
|
||||
elseif (WIN32)
|
||||
target_sources(glfw PRIVATE win32_time.h win32_thread.h win32_module.c
|
||||
win32_time.c win32_thread.c)
|
||||
else()
|
||||
target_sources(glfw PRIVATE posix_time.h posix_thread.h posix_module.c
|
||||
posix_time.c posix_thread.c)
|
||||
endif()
|
||||
|
||||
add_custom_target(update_mappings
|
||||
COMMAND "${CMAKE_COMMAND}" -P "${GLFW_SOURCE_DIR}/CMake/GenerateMappings.cmake" mappings.h.in mappings.h
|
||||
@ -14,48 +29,51 @@ add_custom_target(update_mappings
|
||||
|
||||
set_target_properties(update_mappings PROPERTIES FOLDER "GLFW3")
|
||||
|
||||
if (_GLFW_COCOA)
|
||||
target_sources(glfw PRIVATE cocoa_platform.h cocoa_joystick.h posix_thread.h
|
||||
nsgl_context.h egl_context.h osmesa_context.h
|
||||
cocoa_init.m cocoa_joystick.m cocoa_monitor.m
|
||||
cocoa_window.m cocoa_time.c posix_thread.c
|
||||
nsgl_context.m egl_context.c osmesa_context.c)
|
||||
elseif (_GLFW_WIN32)
|
||||
target_sources(glfw PRIVATE win32_platform.h win32_joystick.h wgl_context.h
|
||||
egl_context.h osmesa_context.h win32_init.c
|
||||
win32_joystick.c win32_monitor.c win32_time.c
|
||||
win32_thread.c win32_window.c wgl_context.c
|
||||
egl_context.c osmesa_context.c)
|
||||
elseif (_GLFW_X11)
|
||||
target_sources(glfw PRIVATE x11_platform.h xkb_unicode.h posix_time.h
|
||||
posix_thread.h glx_context.h egl_context.h
|
||||
osmesa_context.h x11_init.c x11_monitor.c
|
||||
x11_window.c xkb_unicode.c posix_time.c
|
||||
posix_thread.c glx_context.c egl_context.c
|
||||
osmesa_context.c)
|
||||
elseif (_GLFW_WAYLAND)
|
||||
target_sources(glfw PRIVATE wl_platform.h posix_time.h posix_thread.h
|
||||
xkb_unicode.h egl_context.h osmesa_context.h
|
||||
wl_init.c wl_monitor.c wl_window.c posix_time.c
|
||||
posix_thread.c xkb_unicode.c egl_context.c
|
||||
osmesa_context.c)
|
||||
elseif (_GLFW_OSMESA)
|
||||
target_sources(glfw PRIVATE null_platform.h null_joystick.h posix_time.h
|
||||
posix_thread.h osmesa_context.h null_init.c
|
||||
null_monitor.c null_window.c null_joystick.c
|
||||
posix_time.c posix_thread.c osmesa_context.c)
|
||||
if (GLFW_BUILD_COCOA)
|
||||
target_compile_definitions(glfw PRIVATE _GLFW_COCOA)
|
||||
target_sources(glfw PRIVATE cocoa_platform.h cocoa_joystick.h cocoa_init.m
|
||||
cocoa_joystick.m cocoa_monitor.m cocoa_window.m
|
||||
nsgl_context.m)
|
||||
endif()
|
||||
|
||||
if (_GLFW_X11 OR _GLFW_WAYLAND)
|
||||
if (GLFW_BUILD_WIN32)
|
||||
target_compile_definitions(glfw PRIVATE _GLFW_WIN32)
|
||||
target_sources(glfw PRIVATE win32_platform.h win32_joystick.h win32_init.c
|
||||
win32_joystick.c win32_monitor.c win32_window.c
|
||||
wgl_context.c)
|
||||
endif()
|
||||
|
||||
if (GLFW_BUILD_X11)
|
||||
target_compile_definitions(glfw PRIVATE _GLFW_X11)
|
||||
target_sources(glfw PRIVATE x11_platform.h xkb_unicode.h x11_init.c
|
||||
x11_monitor.c x11_window.c xkb_unicode.c
|
||||
glx_context.c)
|
||||
endif()
|
||||
|
||||
if (GLFW_BUILD_WAYLAND)
|
||||
target_compile_definitions(glfw PRIVATE _GLFW_WAYLAND)
|
||||
target_sources(glfw PRIVATE wl_platform.h xkb_unicode.h wl_init.c
|
||||
wl_monitor.c wl_window.c xkb_unicode.c)
|
||||
endif()
|
||||
|
||||
if (GLFW_BUILD_X11 OR GLFW_BUILD_WAYLAND)
|
||||
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
target_sources(glfw PRIVATE linux_joystick.h linux_joystick.c)
|
||||
else()
|
||||
target_sources(glfw PRIVATE null_joystick.h null_joystick.c)
|
||||
endif()
|
||||
target_sources(glfw PRIVATE posix_poll.h posix_poll.c)
|
||||
endif()
|
||||
|
||||
if (_GLFW_WAYLAND)
|
||||
if (GLFW_BUILD_WAYLAND)
|
||||
include(CheckIncludeFiles)
|
||||
include(CheckFunctionExists)
|
||||
check_function_exists(memfd_create HAVE_MEMFD_CREATE)
|
||||
if (HAVE_MEMFD_CREATE)
|
||||
target_compile_definitions(glfw PRIVATE HAVE_MEMFD_CREATE)
|
||||
endif()
|
||||
|
||||
find_program(WAYLAND_SCANNER_EXECUTABLE NAMES wayland-scanner)
|
||||
|
||||
include(FindPkgConfig)
|
||||
pkg_check_modules(WAYLAND_PROTOCOLS REQUIRED wayland-protocols>=1.15)
|
||||
pkg_get_variable(WAYLAND_PROTOCOLS_BASE wayland-protocols pkgdatadir)
|
||||
pkg_get_variable(WAYLAND_CLIENT_PKGDATADIR wayland-client pkgdatadir)
|
||||
@ -102,9 +120,12 @@ if (WIN32 AND GLFW_BUILD_SHARED_LIBRARY)
|
||||
target_sources(glfw PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/glfw.rc")
|
||||
endif()
|
||||
|
||||
configure_file(glfw_config.h.in glfw_config.h @ONLY)
|
||||
target_compile_definitions(glfw PRIVATE _GLFW_USE_CONFIG_H)
|
||||
target_sources(glfw PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/glfw_config.h")
|
||||
if (UNIX AND GLFW_BUILD_SHARED_LIBRARY)
|
||||
# On Unix-like systems, shared libraries can use the soname system.
|
||||
set(GLFW_LIB_NAME glfw)
|
||||
else()
|
||||
set(GLFW_LIB_NAME glfw3)
|
||||
endif()
|
||||
|
||||
set_target_properties(glfw PROPERTIES
|
||||
OUTPUT_NAME ${GLFW_LIB_NAME}
|
||||
@ -121,9 +142,8 @@ target_include_directories(glfw PUBLIC
|
||||
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>")
|
||||
target_include_directories(glfw PRIVATE
|
||||
"${GLFW_SOURCE_DIR}/src"
|
||||
"${GLFW_BINARY_DIR}/src"
|
||||
${glfw_INCLUDE_DIRS})
|
||||
target_link_libraries(glfw PRIVATE Threads::Threads ${glfw_LIBRARIES})
|
||||
"${GLFW_BINARY_DIR}/src")
|
||||
target_link_libraries(glfw PRIVATE Threads::Threads)
|
||||
|
||||
# Workaround for CMake not knowing about .m files before version 3.16
|
||||
if (CMAKE_VERSION VERSION_LESS "3.16" AND APPLE)
|
||||
@ -132,17 +152,116 @@ if (CMAKE_VERSION VERSION_LESS "3.16" AND APPLE)
|
||||
LANGUAGE C)
|
||||
endif()
|
||||
|
||||
if (GLFW_BUILD_WIN32)
|
||||
list(APPEND glfw_PKG_LIBS "-lgdi32")
|
||||
endif()
|
||||
|
||||
if (GLFW_BUILD_COCOA)
|
||||
target_link_libraries(glfw PRIVATE "-framework Cocoa"
|
||||
"-framework IOKit"
|
||||
"-framework CoreFoundation")
|
||||
|
||||
set(glfw_PKG_DEPS "")
|
||||
set(glfw_PKG_LIBS "-framework Cocoa -framework IOKit -framework CoreFoundation")
|
||||
endif()
|
||||
|
||||
if (GLFW_BUILD_WAYLAND)
|
||||
pkg_check_modules(Wayland REQUIRED
|
||||
wayland-client>=0.2.7
|
||||
wayland-cursor>=0.2.7
|
||||
wayland-egl>=0.2.7
|
||||
xkbcommon>=0.5.0)
|
||||
|
||||
target_include_directories(glfw PRIVATE ${Wayland_INCLUDE_DIRS})
|
||||
|
||||
if (NOT CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
find_package(EpollShim)
|
||||
if (EPOLLSHIM_FOUND)
|
||||
target_include_directories(glfw PRIVATE ${EPOLLSHIM_INCLUDE_DIRS})
|
||||
target_link_libraries(glfw PRIVATE ${EPOLLSHIM_LIBRARIES})
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (GLFW_BUILD_X11)
|
||||
find_package(X11 REQUIRED)
|
||||
target_include_directories(glfw PRIVATE "${X11_X11_INCLUDE_PATH}")
|
||||
|
||||
# Check for XRandR (modern resolution switching and gamma control)
|
||||
if (NOT X11_Xrandr_INCLUDE_PATH)
|
||||
message(FATAL_ERROR "RandR headers not found; install libxrandr development package")
|
||||
endif()
|
||||
target_include_directories(glfw PRIVATE "${X11_Xrandr_INCLUDE_PATH}")
|
||||
|
||||
# Check for Xinerama (legacy multi-monitor support)
|
||||
if (NOT X11_Xinerama_INCLUDE_PATH)
|
||||
message(FATAL_ERROR "Xinerama headers not found; install libxinerama development package")
|
||||
endif()
|
||||
target_include_directories(glfw PRIVATE "${X11_Xinerama_INCLUDE_PATH}")
|
||||
|
||||
# Check for Xkb (X keyboard extension)
|
||||
if (NOT X11_Xkb_INCLUDE_PATH)
|
||||
message(FATAL_ERROR "XKB headers not found; install X11 development package")
|
||||
endif()
|
||||
target_include_directories(glfw PRIVATE "${X11_Xkb_INCLUDE_PATH}")
|
||||
|
||||
# Check for Xcursor (cursor creation from RGBA images)
|
||||
if (NOT X11_Xcursor_INCLUDE_PATH)
|
||||
message(FATAL_ERROR "Xcursor headers not found; install libxcursor development package")
|
||||
endif()
|
||||
target_include_directories(glfw PRIVATE "${X11_Xcursor_INCLUDE_PATH}")
|
||||
|
||||
# Check for XInput (modern HID input)
|
||||
if (NOT X11_Xi_INCLUDE_PATH)
|
||||
message(FATAL_ERROR "XInput headers not found; install libxi development package")
|
||||
endif()
|
||||
target_include_directories(glfw PRIVATE "${X11_Xi_INCLUDE_PATH}")
|
||||
|
||||
# Check for X Shape (custom window input shape)
|
||||
if (NOT X11_Xshape_INCLUDE_PATH)
|
||||
message(FATAL_ERROR "X Shape headers not found; install libxext development package")
|
||||
endif()
|
||||
target_include_directories(glfw PRIVATE "${X11_Xshape_INCLUDE_PATH}")
|
||||
endif()
|
||||
|
||||
if (UNIX AND NOT APPLE)
|
||||
find_library(RT_LIBRARY rt)
|
||||
mark_as_advanced(RT_LIBRARY)
|
||||
if (RT_LIBRARY)
|
||||
target_link_libraries(glfw PRIVATE "${RT_LIBRARY}")
|
||||
list(APPEND glfw_PKG_LIBS "-lrt")
|
||||
endif()
|
||||
|
||||
find_library(MATH_LIBRARY m)
|
||||
mark_as_advanced(MATH_LIBRARY)
|
||||
if (MATH_LIBRARY)
|
||||
target_link_libraries(glfw PRIVATE "${MATH_LIBRARY}")
|
||||
list(APPEND glfw_PKG_LIBS "-lm")
|
||||
endif()
|
||||
|
||||
if (CMAKE_DL_LIBS)
|
||||
target_link_libraries(glfw PRIVATE "${CMAKE_DL_LIBS}")
|
||||
list(APPEND glfw_PKG_LIBS "-l${CMAKE_DL_LIBS}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Make GCC warn about declarations that VS 2010 and 2012 won't accept for all
|
||||
# source files that VS will build (Clang ignores this because we set -std=c99)
|
||||
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
|
||||
set_source_files_properties(context.c init.c input.c monitor.c vulkan.c
|
||||
window.c win32_init.c win32_joystick.c
|
||||
win32_monitor.c win32_time.c win32_thread.c
|
||||
win32_window.c wgl_context.c egl_context.c
|
||||
osmesa_context.c PROPERTIES
|
||||
set_source_files_properties(context.c init.c input.c monitor.c platform.c vulkan.c
|
||||
window.c null_init.c null_joystick.c null_monitor.c
|
||||
null_window.c win32_init.c win32_joystick.c win32_module.c
|
||||
win32_monitor.c win32_time.c win32_thread.c win32_window.c
|
||||
wgl_context.c egl_context.c osmesa_context.c PROPERTIES
|
||||
COMPILE_FLAGS -Wdeclaration-after-statement)
|
||||
endif()
|
||||
|
||||
if (WIN32)
|
||||
if (GLFW_USE_HYBRID_HPG)
|
||||
target_compile_definitions(glfw PRIVATE _GLFW_USE_HYBRID_HPG)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Enable a reasonable set of warnings
|
||||
# NOTE: The order matters here, Clang-CL matches both MSVC and Clang
|
||||
if (MSVC)
|
||||
@ -154,7 +273,7 @@ elseif (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR
|
||||
target_compile_options(glfw PRIVATE "-Wall")
|
||||
endif()
|
||||
|
||||
if (_GLFW_WIN32)
|
||||
if (GLFW_BUILD_WIN32)
|
||||
target_compile_definitions(glfw PRIVATE UNICODE _UNICODE)
|
||||
endif()
|
||||
|
||||
@ -196,7 +315,7 @@ if (MSVC90)
|
||||
endif()
|
||||
|
||||
# Workaround for -std=c99 on Linux disabling _DEFAULT_SOURCE (POSIX 2008 and more)
|
||||
if (_GLFW_X11 OR _GLFW_WAYLAND OR _GLFW_OSMESA)
|
||||
if (GLFW_BUILD_X11 OR GLFW_BUILD_WAYLAND)
|
||||
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
target_compile_definitions(glfw PRIVATE _DEFAULT_SOURCE)
|
||||
endif()
|
||||
@ -257,6 +376,20 @@ if (GLFW_BUILD_SHARED_LIBRARY)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
foreach(arg ${glfw_PKG_DEPS})
|
||||
string(APPEND deps " ${arg}")
|
||||
endforeach()
|
||||
foreach(arg ${glfw_PKG_LIBS})
|
||||
string(APPEND libs " ${arg}")
|
||||
endforeach()
|
||||
|
||||
set(GLFW_PKG_CONFIG_REQUIRES_PRIVATE "${deps}" CACHE INTERNAL
|
||||
"GLFW pkg-config Requires.private")
|
||||
set(GLFW_PKG_CONFIG_LIBS_PRIVATE "${libs}" CACHE INTERNAL
|
||||
"GLFW pkg-config Libs.private")
|
||||
|
||||
configure_file("${GLFW_SOURCE_DIR}/CMake/glfw3.pc.in" glfw3.pc @ONLY)
|
||||
|
||||
if (GLFW_INSTALL)
|
||||
install(TARGETS glfw
|
||||
EXPORT glfwTargets
|
||||
|
135
src/cocoa_init.m
135
src/cocoa_init.m
@ -75,7 +75,6 @@ static void changeToResourcesDirectory(void)
|
||||
//
|
||||
static void createMenuBar(void)
|
||||
{
|
||||
size_t i;
|
||||
NSString* appName = nil;
|
||||
NSDictionary* bundleInfo = [[NSBundle mainBundle] infoDictionary];
|
||||
NSString* nameKeys[] =
|
||||
@ -87,7 +86,7 @@ static void createMenuBar(void)
|
||||
|
||||
// Try to figure out what the calling application is called
|
||||
|
||||
for (i = 0; i < sizeof(nameKeys) / sizeof(nameKeys[0]); i++)
|
||||
for (size_t i = 0; i < sizeof(nameKeys) / sizeof(nameKeys[0]); i++)
|
||||
{
|
||||
id name = bundleInfo[nameKeys[i]];
|
||||
if (name &&
|
||||
@ -177,8 +176,6 @@ static void createMenuBar(void)
|
||||
//
|
||||
static void createKeyTables(void)
|
||||
{
|
||||
int scancode;
|
||||
|
||||
memset(_glfw.ns.keycodes, -1, sizeof(_glfw.ns.keycodes));
|
||||
memset(_glfw.ns.scancodes, -1, sizeof(_glfw.ns.scancodes));
|
||||
|
||||
@ -297,7 +294,7 @@ static void createKeyTables(void)
|
||||
_glfw.ns.keycodes[0x43] = GLFW_KEY_KP_MULTIPLY;
|
||||
_glfw.ns.keycodes[0x4E] = GLFW_KEY_KP_SUBTRACT;
|
||||
|
||||
for (scancode = 0; scancode < 256; scancode++)
|
||||
for (int scancode = 0; scancode < 256; scancode++)
|
||||
{
|
||||
// Store the reverse translation for faster key name lookup
|
||||
if (_glfw.ns.keycodes[scancode] >= 0)
|
||||
@ -307,7 +304,7 @@ static void createKeyTables(void)
|
||||
|
||||
// Retrieve Unicode data for the current keyboard layout
|
||||
//
|
||||
static GLFWbool updateUnicodeDataNS(void)
|
||||
static GLFWbool updateUnicodeData(void)
|
||||
{
|
||||
if (_glfw.ns.inputSource)
|
||||
{
|
||||
@ -377,7 +374,7 @@ static GLFWbool initializeTIS(void)
|
||||
_glfw.ns.tis.kPropertyUnicodeKeyLayoutData =
|
||||
*kPropertyUnicodeKeyLayoutData;
|
||||
|
||||
return updateUnicodeDataNS();
|
||||
return updateUnicodeData();
|
||||
}
|
||||
|
||||
@interface GLFWHelper : NSObject
|
||||
@ -387,7 +384,7 @@ static GLFWbool initializeTIS(void)
|
||||
|
||||
- (void)selectedKeyboardInputSourceChanged:(NSObject* )object
|
||||
{
|
||||
updateUnicodeDataNS();
|
||||
updateUnicodeData();
|
||||
}
|
||||
|
||||
- (void)doNothing:(id)object
|
||||
@ -403,9 +400,7 @@ static GLFWbool initializeTIS(void)
|
||||
|
||||
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender
|
||||
{
|
||||
_GLFWwindow* window;
|
||||
|
||||
for (window = _glfw.windowListHead; window; window = window->next)
|
||||
for (_GLFWwindow* window = _glfw.windowListHead; window; window = window->next)
|
||||
_glfwInputWindowCloseRequest(window);
|
||||
|
||||
return NSTerminateCancel;
|
||||
@ -413,15 +408,13 @@ static GLFWbool initializeTIS(void)
|
||||
|
||||
- (void)applicationDidChangeScreenParameters:(NSNotification *) notification
|
||||
{
|
||||
_GLFWwindow* window;
|
||||
|
||||
for (window = _glfw.windowListHead; window; window = window->next)
|
||||
for (_GLFWwindow* window = _glfw.windowListHead; window; window = window->next)
|
||||
{
|
||||
if (window->context.client != GLFW_NO_API)
|
||||
[window->context.nsgl.object update];
|
||||
}
|
||||
|
||||
_glfwPollMonitorsNS();
|
||||
_glfwPollMonitorsCocoa();
|
||||
}
|
||||
|
||||
- (void)applicationWillFinishLaunching:(NSNotification *)notification
|
||||
@ -444,16 +437,14 @@ static GLFWbool initializeTIS(void)
|
||||
|
||||
- (void)applicationDidFinishLaunching:(NSNotification *)notification
|
||||
{
|
||||
_glfwPlatformPostEmptyEvent();
|
||||
_glfwPostEmptyEventCocoa();
|
||||
[NSApp stop:nil];
|
||||
}
|
||||
|
||||
- (void)applicationDidHide:(NSNotification *)notification
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < _glfw.monitorCount; i++)
|
||||
_glfwRestoreVideoModeNS(_glfw.monitors[i]);
|
||||
for (int i = 0; i < _glfw.monitorCount; i++)
|
||||
_glfwRestoreVideoModeCocoa(_glfw.monitors[i]);
|
||||
}
|
||||
|
||||
@end // GLFWApplicationDelegate
|
||||
@ -463,7 +454,7 @@ static GLFWbool initializeTIS(void)
|
||||
////// GLFW internal API //////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void* _glfwLoadLocalVulkanLoaderNS(void)
|
||||
void* _glfwLoadLocalVulkanLoaderCocoa(void)
|
||||
{
|
||||
CFBundleRef bundle = CFBundleGetMainBundle();
|
||||
if (!bundle)
|
||||
@ -478,7 +469,7 @@ void* _glfwLoadLocalVulkanLoaderNS(void)
|
||||
void* handle = NULL;
|
||||
|
||||
if (CFURLGetFileSystemRepresentation(url, true, (UInt8*) path, sizeof(path) - 1))
|
||||
handle = _glfw_dlopen(path);
|
||||
handle = _glfwPlatformLoadModule(path);
|
||||
|
||||
CFRelease(url);
|
||||
return handle;
|
||||
@ -489,7 +480,90 @@ void* _glfwLoadLocalVulkanLoaderNS(void)
|
||||
////// GLFW platform API //////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int _glfwPlatformInit(void)
|
||||
GLFWbool _glfwConnectCocoa(int platformID, _GLFWplatform* platform)
|
||||
{
|
||||
const _GLFWplatform cocoa =
|
||||
{
|
||||
GLFW_PLATFORM_COCOA,
|
||||
_glfwInitCocoa,
|
||||
_glfwTerminateCocoa,
|
||||
_glfwGetCursorPosCocoa,
|
||||
_glfwSetCursorPosCocoa,
|
||||
_glfwSetCursorModeCocoa,
|
||||
_glfwSetRawMouseMotionCocoa,
|
||||
_glfwRawMouseMotionSupportedCocoa,
|
||||
_glfwCreateCursorCocoa,
|
||||
_glfwCreateStandardCursorCocoa,
|
||||
_glfwDestroyCursorCocoa,
|
||||
_glfwSetCursorCocoa,
|
||||
_glfwGetScancodeNameCocoa,
|
||||
_glfwGetKeyScancodeCocoa,
|
||||
_glfwSetClipboardStringCocoa,
|
||||
_glfwGetClipboardStringCocoa,
|
||||
_glfwInitJoysticksCocoa,
|
||||
_glfwTerminateJoysticksCocoa,
|
||||
_glfwPollJoystickCocoa,
|
||||
_glfwGetMappingNameCocoa,
|
||||
_glfwUpdateGamepadGUIDCocoa,
|
||||
_glfwFreeMonitorCocoa,
|
||||
_glfwGetMonitorPosCocoa,
|
||||
_glfwGetMonitorContentScaleCocoa,
|
||||
_glfwGetMonitorWorkareaCocoa,
|
||||
_glfwGetVideoModesCocoa,
|
||||
_glfwGetVideoModeCocoa,
|
||||
_glfwGetGammaRampCocoa,
|
||||
_glfwSetGammaRampCocoa,
|
||||
_glfwCreateWindowCocoa,
|
||||
_glfwDestroyWindowCocoa,
|
||||
_glfwSetWindowTitleCocoa,
|
||||
_glfwSetWindowIconCocoa,
|
||||
_glfwGetWindowPosCocoa,
|
||||
_glfwSetWindowPosCocoa,
|
||||
_glfwGetWindowSizeCocoa,
|
||||
_glfwSetWindowSizeCocoa,
|
||||
_glfwSetWindowSizeLimitsCocoa,
|
||||
_glfwSetWindowAspectRatioCocoa,
|
||||
_glfwGetFramebufferSizeCocoa,
|
||||
_glfwGetWindowFrameSizeCocoa,
|
||||
_glfwGetWindowContentScaleCocoa,
|
||||
_glfwIconifyWindowCocoa,
|
||||
_glfwRestoreWindowCocoa,
|
||||
_glfwMaximizeWindowCocoa,
|
||||
_glfwShowWindowCocoa,
|
||||
_glfwHideWindowCocoa,
|
||||
_glfwRequestWindowAttentionCocoa,
|
||||
_glfwFocusWindowCocoa,
|
||||
_glfwSetWindowMonitorCocoa,
|
||||
_glfwWindowFocusedCocoa,
|
||||
_glfwWindowIconifiedCocoa,
|
||||
_glfwWindowVisibleCocoa,
|
||||
_glfwWindowMaximizedCocoa,
|
||||
_glfwWindowHoveredCocoa,
|
||||
_glfwFramebufferTransparentCocoa,
|
||||
_glfwGetWindowOpacityCocoa,
|
||||
_glfwSetWindowResizableCocoa,
|
||||
_glfwSetWindowDecoratedCocoa,
|
||||
_glfwSetWindowFloatingCocoa,
|
||||
_glfwSetWindowOpacityCocoa,
|
||||
_glfwSetWindowMousePassthroughCocoa,
|
||||
_glfwPollEventsCocoa,
|
||||
_glfwWaitEventsCocoa,
|
||||
_glfwWaitEventsTimeoutCocoa,
|
||||
_glfwPostEmptyEventCocoa,
|
||||
_glfwCreateUserContextCocoa,
|
||||
_glfwGetEGLPlatformCocoa,
|
||||
_glfwGetEGLNativeDisplayCocoa,
|
||||
_glfwGetEGLNativeWindowCocoa,
|
||||
_glfwGetRequiredInstanceExtensionsCocoa,
|
||||
_glfwGetPhysicalDevicePresentationSupportCocoa,
|
||||
_glfwCreateWindowSurfaceCocoa,
|
||||
};
|
||||
|
||||
*platform = cocoa;
|
||||
return GLFW_TRUE;
|
||||
}
|
||||
|
||||
int _glfwInitCocoa(void)
|
||||
{
|
||||
@autoreleasepool {
|
||||
|
||||
@ -547,9 +621,7 @@ int _glfwPlatformInit(void)
|
||||
if (!initializeTIS())
|
||||
return GLFW_FALSE;
|
||||
|
||||
_glfwInitTimerNS();
|
||||
|
||||
_glfwPollMonitorsNS();
|
||||
_glfwPollMonitorsCocoa();
|
||||
|
||||
if (![[NSRunningApplication currentApplication] isFinishedLaunching])
|
||||
[NSApp run];
|
||||
@ -563,7 +635,7 @@ int _glfwPlatformInit(void)
|
||||
} // autoreleasepool
|
||||
}
|
||||
|
||||
void _glfwPlatformTerminate(void)
|
||||
void _glfwTerminateCocoa(void)
|
||||
{
|
||||
@autoreleasepool {
|
||||
|
||||
@ -609,12 +681,3 @@ void _glfwPlatformTerminate(void)
|
||||
} // autoreleasepool
|
||||
}
|
||||
|
||||
const char* _glfwPlatformGetVersionString(void)
|
||||
{
|
||||
return _GLFW_VERSION_NUMBER " Cocoa NSGL EGL OSMesa"
|
||||
#if defined(_GLFW_BUILD_DLL)
|
||||
" dynamic"
|
||||
#endif
|
||||
;
|
||||
}
|
||||
|
||||
|
@ -26,13 +26,11 @@
|
||||
|
||||
#include <IOKit/IOKitLib.h>
|
||||
#include <IOKit/IOCFPlugIn.h>
|
||||
#include <IOKit/hid/IOHIDLib.h>
|
||||
#include <IOKit/hid/IOHIDKeys.h>
|
||||
|
||||
#define _GLFW_PLATFORM_JOYSTICK_STATE _GLFWjoystickNS ns
|
||||
#define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE struct { int dummyJoystick; }
|
||||
#define GLFW_COCOA_JOYSTICK_STATE _GLFWjoystickNS ns;
|
||||
#define GLFW_COCOA_LIBRARY_JOYSTICK_STATE
|
||||
|
||||
#define _GLFW_PLATFORM_MAPPING_NAME "Mac OS X"
|
||||
#define GLFW_BUILD_COCOA_MAPPINGS
|
||||
|
||||
// Cocoa-specific per-joystick data
|
||||
@ -45,3 +43,9 @@ typedef struct _GLFWjoystickNS
|
||||
CFMutableArrayRef hats;
|
||||
} _GLFWjoystickNS;
|
||||
|
||||
GLFWbool _glfwInitJoysticksCocoa(void);
|
||||
void _glfwTerminateJoysticksCocoa(void);
|
||||
int _glfwPollJoystickCocoa(_GLFWjoystick* js, int mode);
|
||||
const char* _glfwGetMappingNameCocoa(void);
|
||||
void _glfwUpdateGamepadGUIDCocoa(char* guid);
|
||||
|
||||
|
@ -96,20 +96,18 @@ static CFComparisonResult compareElements(const void* fp,
|
||||
//
|
||||
static void closeJoystick(_GLFWjoystick* js)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (!js->present)
|
||||
return;
|
||||
|
||||
for (i = 0; i < CFArrayGetCount(js->ns.axes); i++)
|
||||
for (int i = 0; i < CFArrayGetCount(js->ns.axes); i++)
|
||||
_glfw_free((void*) CFArrayGetValueAtIndex(js->ns.axes, i));
|
||||
CFRelease(js->ns.axes);
|
||||
|
||||
for (i = 0; i < CFArrayGetCount(js->ns.buttons); i++)
|
||||
for (int i = 0; i < CFArrayGetCount(js->ns.buttons); i++)
|
||||
_glfw_free((void*) CFArrayGetValueAtIndex(js->ns.buttons, i));
|
||||
CFRelease(js->ns.buttons);
|
||||
|
||||
for (i = 0; i < CFArrayGetCount(js->ns.hats); i++)
|
||||
for (int i = 0; i < CFArrayGetCount(js->ns.hats); i++)
|
||||
_glfw_free((void*) CFArrayGetValueAtIndex(js->ns.hats, i));
|
||||
CFRelease(js->ns.hats);
|
||||
|
||||
@ -127,7 +125,6 @@ static void matchCallback(void* context,
|
||||
int jid;
|
||||
char name[256];
|
||||
char guid[33];
|
||||
CFIndex i;
|
||||
CFTypeRef property;
|
||||
uint32_t vendor = 0, product = 0, version = 0;
|
||||
_GLFWjoystick* js;
|
||||
@ -185,7 +182,7 @@ static void matchCallback(void* context,
|
||||
CFArrayRef elements =
|
||||
IOHIDDeviceCopyMatchingElements(device, NULL, kIOHIDOptionsTypeNone);
|
||||
|
||||
for (i = 0; i < CFArrayGetCount(elements); i++)
|
||||
for (CFIndex i = 0; i < CFArrayGetCount(elements); i++)
|
||||
{
|
||||
IOHIDElementRef native = (IOHIDElementRef)
|
||||
CFArrayGetValueAtIndex(elements, i);
|
||||
@ -290,9 +287,7 @@ static void removeCallback(void* context,
|
||||
void* sender,
|
||||
IOHIDDeviceRef device)
|
||||
{
|
||||
int jid;
|
||||
|
||||
for (jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++)
|
||||
for (int jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++)
|
||||
{
|
||||
if (_glfw.joysticks[jid].ns.device == device)
|
||||
{
|
||||
@ -307,7 +302,7 @@ static void removeCallback(void* context,
|
||||
////// GLFW platform API //////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
GLFWbool _glfwPlatformInitJoysticks(void)
|
||||
GLFWbool _glfwInitJoysticksCocoa(void)
|
||||
{
|
||||
CFMutableArrayRef matching;
|
||||
const long usages[] =
|
||||
@ -384,11 +379,9 @@ GLFWbool _glfwPlatformInitJoysticks(void)
|
||||
return GLFW_TRUE;
|
||||
}
|
||||
|
||||
void _glfwPlatformTerminateJoysticks(void)
|
||||
void _glfwTerminateJoysticksCocoa(void)
|
||||
{
|
||||
int jid;
|
||||
|
||||
for (jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++)
|
||||
for (int jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++)
|
||||
closeJoystick(_glfw.joysticks + jid);
|
||||
|
||||
if (_glfw.ns.hidManager)
|
||||
@ -399,13 +392,11 @@ void _glfwPlatformTerminateJoysticks(void)
|
||||
}
|
||||
|
||||
|
||||
int _glfwPlatformPollJoystick(_GLFWjoystick* js, int mode)
|
||||
int _glfwPollJoystickCocoa(_GLFWjoystick* js, int mode)
|
||||
{
|
||||
if (mode & _GLFW_POLL_AXES)
|
||||
{
|
||||
CFIndex i;
|
||||
|
||||
for (i = 0; i < CFArrayGetCount(js->ns.axes); i++)
|
||||
for (CFIndex i = 0; i < CFArrayGetCount(js->ns.axes); i++)
|
||||
{
|
||||
_GLFWjoyelementNS* axis = (_GLFWjoyelementNS*)
|
||||
CFArrayGetValueAtIndex(js->ns.axes, i);
|
||||
@ -430,9 +421,7 @@ int _glfwPlatformPollJoystick(_GLFWjoystick* js, int mode)
|
||||
|
||||
if (mode & _GLFW_POLL_BUTTONS)
|
||||
{
|
||||
CFIndex i;
|
||||
|
||||
for (i = 0; i < CFArrayGetCount(js->ns.buttons); i++)
|
||||
for (CFIndex i = 0; i < CFArrayGetCount(js->ns.buttons); i++)
|
||||
{
|
||||
_GLFWjoyelementNS* button = (_GLFWjoyelementNS*)
|
||||
CFArrayGetValueAtIndex(js->ns.buttons, i);
|
||||
@ -441,7 +430,7 @@ int _glfwPlatformPollJoystick(_GLFWjoystick* js, int mode)
|
||||
_glfwInputJoystickButton(js, (int) i, state);
|
||||
}
|
||||
|
||||
for (i = 0; i < CFArrayGetCount(js->ns.hats); i++)
|
||||
for (CFIndex i = 0; i < CFArrayGetCount(js->ns.hats); i++)
|
||||
{
|
||||
const int states[9] =
|
||||
{
|
||||
@ -469,7 +458,12 @@ int _glfwPlatformPollJoystick(_GLFWjoystick* js, int mode)
|
||||
return js->present;
|
||||
}
|
||||
|
||||
void _glfwPlatformUpdateGamepadGUID(char* guid)
|
||||
const char* _glfwGetMappingNameCocoa(void)
|
||||
{
|
||||
return "Mac OS X";
|
||||
}
|
||||
|
||||
void _glfwUpdateGamepadGUIDCocoa(char* guid)
|
||||
{
|
||||
if ((strncmp(guid + 4, "000000000000", 12) == 0) &&
|
||||
(strncmp(guid + 20, "000000000000", 12) == 0))
|
||||
|
@ -58,7 +58,7 @@ static char* getMonitorName(CGDirectDisplayID displayID, NSScreen* screen)
|
||||
io_service_t service;
|
||||
CFDictionaryRef info;
|
||||
|
||||
if (IOServiceGetMatchingServices(kIOMasterPortDefault,
|
||||
if (IOServiceGetMatchingServices(MACH_PORT_NULL,
|
||||
IOServiceMatching("IODisplayConnect"),
|
||||
&it) != 0)
|
||||
{
|
||||
@ -98,11 +98,7 @@ static char* getMonitorName(CGDirectDisplayID displayID, NSScreen* screen)
|
||||
IOObjectRelease(it);
|
||||
|
||||
if (!service)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"Cocoa: Failed to find service port for display");
|
||||
return _glfw_strdup("Display");
|
||||
}
|
||||
|
||||
CFDictionaryRef names =
|
||||
CFDictionaryGetValue(info, CFSTR(kDisplayProductName));
|
||||
@ -231,7 +227,7 @@ static double getFallbackRefreshRate(CGDirectDisplayID displayID)
|
||||
io_iterator_t it;
|
||||
io_service_t service;
|
||||
|
||||
if (IOServiceGetMatchingServices(kIOMasterPortDefault,
|
||||
if (IOServiceGetMatchingServices(MACH_PORT_NULL,
|
||||
IOServiceMatching("IOFramebuffer"),
|
||||
&it) != 0)
|
||||
{
|
||||
@ -297,7 +293,7 @@ static double getFallbackRefreshRate(CGDirectDisplayID displayID)
|
||||
|
||||
// Poll for changes in the set of connected monitors
|
||||
//
|
||||
void _glfwPollMonitorsNS(void)
|
||||
void _glfwPollMonitorsCocoa(void)
|
||||
{
|
||||
uint32_t displayCount;
|
||||
CGGetOnlineDisplayList(0, NULL, &displayCount);
|
||||
@ -385,10 +381,10 @@ void _glfwPollMonitorsNS(void)
|
||||
|
||||
// Change the current video mode
|
||||
//
|
||||
void _glfwSetVideoModeNS(_GLFWmonitor* monitor, const GLFWvidmode* desired)
|
||||
void _glfwSetVideoModeCocoa(_GLFWmonitor* monitor, const GLFWvidmode* desired)
|
||||
{
|
||||
GLFWvidmode current;
|
||||
_glfwPlatformGetVideoMode(monitor, ¤t);
|
||||
_glfwGetVideoModeCocoa(monitor, ¤t);
|
||||
|
||||
const GLFWvidmode* best = _glfwChooseVideoMode(monitor, desired);
|
||||
if (_glfwCompareVideoModes(¤t, best) == 0)
|
||||
@ -428,7 +424,7 @@ void _glfwSetVideoModeNS(_GLFWmonitor* monitor, const GLFWvidmode* desired)
|
||||
|
||||
// Restore the previously saved (original) video mode
|
||||
//
|
||||
void _glfwRestoreVideoModeNS(_GLFWmonitor* monitor)
|
||||
void _glfwRestoreVideoModeCocoa(_GLFWmonitor* monitor)
|
||||
{
|
||||
if (monitor->ns.previousMode)
|
||||
{
|
||||
@ -447,11 +443,11 @@ void _glfwRestoreVideoModeNS(_GLFWmonitor* monitor)
|
||||
////// GLFW platform API //////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void _glfwPlatformFreeMonitor(_GLFWmonitor* monitor)
|
||||
void _glfwFreeMonitorCocoa(_GLFWmonitor* monitor)
|
||||
{
|
||||
}
|
||||
|
||||
void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos)
|
||||
void _glfwGetMonitorPosCocoa(_GLFWmonitor* monitor, int* xpos, int* ypos)
|
||||
{
|
||||
@autoreleasepool {
|
||||
|
||||
@ -465,8 +461,8 @@ void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos)
|
||||
} // autoreleasepool
|
||||
}
|
||||
|
||||
void _glfwPlatformGetMonitorContentScale(_GLFWmonitor* monitor,
|
||||
float* xscale, float* yscale)
|
||||
void _glfwGetMonitorContentScaleCocoa(_GLFWmonitor* monitor,
|
||||
float* xscale, float* yscale)
|
||||
{
|
||||
@autoreleasepool {
|
||||
|
||||
@ -487,9 +483,9 @@ void _glfwPlatformGetMonitorContentScale(_GLFWmonitor* monitor,
|
||||
} // autoreleasepool
|
||||
}
|
||||
|
||||
void _glfwPlatformGetMonitorWorkarea(_GLFWmonitor* monitor,
|
||||
int* xpos, int* ypos,
|
||||
int* width, int* height)
|
||||
void _glfwGetMonitorWorkareaCocoa(_GLFWmonitor* monitor,
|
||||
int* xpos, int* ypos,
|
||||
int* width, int* height)
|
||||
{
|
||||
@autoreleasepool {
|
||||
|
||||
@ -504,7 +500,7 @@ void _glfwPlatformGetMonitorWorkarea(_GLFWmonitor* monitor,
|
||||
if (xpos)
|
||||
*xpos = frameRect.origin.x;
|
||||
if (ypos)
|
||||
*ypos = _glfwTransformYNS(frameRect.origin.y + frameRect.size.height - 1);
|
||||
*ypos = _glfwTransformYCocoa(frameRect.origin.y + frameRect.size.height - 1);
|
||||
if (width)
|
||||
*width = frameRect.size.width;
|
||||
if (height)
|
||||
@ -513,7 +509,7 @@ void _glfwPlatformGetMonitorWorkarea(_GLFWmonitor* monitor,
|
||||
} // autoreleasepool
|
||||
}
|
||||
|
||||
GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* count)
|
||||
GLFWvidmode* _glfwGetVideoModesCocoa(_GLFWmonitor* monitor, int* count)
|
||||
{
|
||||
@autoreleasepool {
|
||||
|
||||
@ -553,7 +549,7 @@ GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* count)
|
||||
} // autoreleasepool
|
||||
}
|
||||
|
||||
void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode *mode)
|
||||
void _glfwGetVideoModeCocoa(_GLFWmonitor* monitor, GLFWvidmode *mode)
|
||||
{
|
||||
@autoreleasepool {
|
||||
|
||||
@ -564,7 +560,7 @@ void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode *mode)
|
||||
} // autoreleasepool
|
||||
}
|
||||
|
||||
GLFWbool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
|
||||
GLFWbool _glfwGetGammaRampCocoa(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
|
||||
{
|
||||
@autoreleasepool {
|
||||
|
||||
@ -593,7 +589,7 @@ GLFWbool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
|
||||
} // autoreleasepool
|
||||
}
|
||||
|
||||
void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp)
|
||||
void _glfwSetGammaRampCocoa(_GLFWmonitor* monitor, const GLFWgammaramp* ramp)
|
||||
{
|
||||
@autoreleasepool {
|
||||
|
||||
|
@ -25,9 +25,9 @@
|
||||
//========================================================================
|
||||
|
||||
#include <stdint.h>
|
||||
#include <dlfcn.h>
|
||||
|
||||
#include <Carbon/Carbon.h>
|
||||
#include <IOKit/hid/IOHIDLib.h>
|
||||
|
||||
// NOTE: All of NSGL was deprecated in the 10.14 SDK
|
||||
// This disables the pointless warnings for every symbol we use
|
||||
@ -42,8 +42,15 @@ typedef void* id;
|
||||
#endif
|
||||
|
||||
// NOTE: Many Cocoa enum values have been renamed and we need to build across
|
||||
// SDK versions where one is unavailable or the other deprecated
|
||||
// We use the newer names in code and these macros to handle compatibility
|
||||
// SDK versions where one is unavailable or deprecated.
|
||||
// We use the newer names in code and replace them with the older names if
|
||||
// the base SDK does not provide the newer names.
|
||||
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED < 101400
|
||||
#define NSOpenGLContextParameterSwapInterval NSOpenGLCPSwapInterval
|
||||
#define NSOpenGLContextParameterSurfaceOpacity NSOpenGLCPSurfaceOpacity
|
||||
#endif
|
||||
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED < 101200
|
||||
#define NSBitmapFormatAlphaNonpremultiplied NSAlphaNonpremultipliedBitmapFormat
|
||||
#define NSEventMaskAny NSAnyEventMask
|
||||
@ -62,6 +69,15 @@ typedef void* id;
|
||||
#define NSWindowStyleMaskTitled NSTitledWindowMask
|
||||
#endif
|
||||
|
||||
// NOTE: Many Cocoa dynamically linked constants have been renamed and we need
|
||||
// to build across SDK versions where one is unavailable or deprecated.
|
||||
// We use the newer names in code and replace them with the older names if
|
||||
// the deployment target is older than the newer names.
|
||||
|
||||
#if MAC_OS_X_VERSION_MIN_REQUIRED < 101300
|
||||
#define NSPasteboardTypeURL NSURLPboardType
|
||||
#endif
|
||||
|
||||
typedef VkFlags VkMacOSSurfaceCreateFlagsMVK;
|
||||
typedef VkFlags VkMetalSurfaceCreateFlagsEXT;
|
||||
|
||||
@ -84,19 +100,14 @@ typedef struct VkMetalSurfaceCreateInfoEXT
|
||||
typedef VkResult (APIENTRY *PFN_vkCreateMacOSSurfaceMVK)(VkInstance,const VkMacOSSurfaceCreateInfoMVK*,const VkAllocationCallbacks*,VkSurfaceKHR*);
|
||||
typedef VkResult (APIENTRY *PFN_vkCreateMetalSurfaceEXT)(VkInstance,const VkMetalSurfaceCreateInfoEXT*,const VkAllocationCallbacks*,VkSurfaceKHR*);
|
||||
|
||||
#include "posix_thread.h"
|
||||
#include "cocoa_joystick.h"
|
||||
#include "nsgl_context.h"
|
||||
#define GLFW_COCOA_WINDOW_STATE _GLFWwindowNS ns;
|
||||
#define GLFW_COCOA_LIBRARY_WINDOW_STATE _GLFWlibraryNS ns;
|
||||
#define GLFW_COCOA_MONITOR_STATE _GLFWmonitorNS ns;
|
||||
#define GLFW_COCOA_CURSOR_STATE _GLFWcursorNS ns;
|
||||
|
||||
#define _glfw_dlopen(name) dlopen(name, RTLD_LAZY | RTLD_LOCAL)
|
||||
#define _glfw_dlclose(handle) dlclose(handle)
|
||||
#define _glfw_dlsym(handle, name) dlsym(handle, name)
|
||||
|
||||
#define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowNS ns
|
||||
#define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryNS ns
|
||||
#define _GLFW_PLATFORM_LIBRARY_TIMER_STATE _GLFWtimerNS ns
|
||||
#define _GLFW_PLATFORM_MONITOR_STATE _GLFWmonitorNS ns
|
||||
#define _GLFW_PLATFORM_CURSOR_STATE _GLFWcursorNS ns
|
||||
#define GLFW_NSGL_CONTEXT_STATE _GLFWcontextNSGL nsgl;
|
||||
#define GLFW_NSGL_LIBRARY_CONTEXT_STATE _GLFWlibraryNSGL nsgl;
|
||||
#define GLFW_NSGL_USER_CONTEXT_STATE _GLFWusercontextNSGL nsgl;
|
||||
|
||||
// HIToolbox.framework pointer typedefs
|
||||
#define kTISPropertyUnicodeKeyLayoutData _glfw.ns.tis.kPropertyUnicodeKeyLayoutData
|
||||
@ -108,6 +119,30 @@ typedef UInt8 (*PFN_LMGetKbdType)(void);
|
||||
#define LMGetKbdType _glfw.ns.tis.GetKbdType
|
||||
|
||||
|
||||
// NSGL-specific per-context data
|
||||
//
|
||||
typedef struct _GLFWcontextNSGL
|
||||
{
|
||||
id pixelFormat;
|
||||
id object;
|
||||
} _GLFWcontextNSGL;
|
||||
|
||||
// NSGL-specific global data
|
||||
//
|
||||
typedef struct _GLFWlibraryNSGL
|
||||
{
|
||||
// dlopen handle for OpenGL.framework (for glfwGetProcAddress)
|
||||
CFBundleRef framework;
|
||||
} _GLFWlibraryNSGL;
|
||||
|
||||
// NSGL-specific per usercontext data
|
||||
//
|
||||
typedef struct _GLFWusercontextNSGL
|
||||
{
|
||||
id object;
|
||||
|
||||
} _GLFWusercontextNSGL;
|
||||
|
||||
// Cocoa-specific per-window data
|
||||
//
|
||||
typedef struct _GLFWwindowNS
|
||||
@ -130,7 +165,6 @@ typedef struct _GLFWwindowNS
|
||||
// since the last cursor motion event was processed
|
||||
// This is kept to counteract Cocoa doing the same internally
|
||||
double cursorWarpDeltaX, cursorWarpDeltaY;
|
||||
|
||||
} _GLFWwindowNS;
|
||||
|
||||
// Cocoa-specific global data
|
||||
@ -164,7 +198,6 @@ typedef struct _GLFWlibraryNS
|
||||
PFN_LMGetKbdType GetKbdType;
|
||||
CFStringRef kPropertyUnicodeKeyLayoutData;
|
||||
} tis;
|
||||
|
||||
} _GLFWlibraryNS;
|
||||
|
||||
// Cocoa-specific per-monitor data
|
||||
@ -176,7 +209,6 @@ typedef struct _GLFWmonitorNS
|
||||
uint32_t unitNumber;
|
||||
id screen;
|
||||
double fallbackRefreshRate;
|
||||
|
||||
} _GLFWmonitorNS;
|
||||
|
||||
// Cocoa-specific per-cursor data
|
||||
@ -184,25 +216,98 @@ typedef struct _GLFWmonitorNS
|
||||
typedef struct _GLFWcursorNS
|
||||
{
|
||||
id object;
|
||||
|
||||
} _GLFWcursorNS;
|
||||
|
||||
// Cocoa-specific global timer data
|
||||
//
|
||||
typedef struct _GLFWtimerNS
|
||||
{
|
||||
uint64_t frequency;
|
||||
|
||||
} _GLFWtimerNS;
|
||||
GLFWbool _glfwConnectCocoa(int platformID, _GLFWplatform* platform);
|
||||
int _glfwInitCocoa(void);
|
||||
void _glfwTerminateCocoa(void);
|
||||
|
||||
int _glfwCreateWindowCocoa(_GLFWwindow* window, const _GLFWwndconfig* wndconfig, const _GLFWctxconfig* ctxconfig, const _GLFWfbconfig* fbconfig);
|
||||
void _glfwDestroyWindowCocoa(_GLFWwindow* window);
|
||||
void _glfwSetWindowTitleCocoa(_GLFWwindow* window, const char* title);
|
||||
void _glfwSetWindowIconCocoa(_GLFWwindow* window, int count, const GLFWimage* images);
|
||||
void _glfwGetWindowPosCocoa(_GLFWwindow* window, int* xpos, int* ypos);
|
||||
void _glfwSetWindowPosCocoa(_GLFWwindow* window, int xpos, int ypos);
|
||||
void _glfwGetWindowSizeCocoa(_GLFWwindow* window, int* width, int* height);
|
||||
void _glfwSetWindowSizeCocoa(_GLFWwindow* window, int width, int height);
|
||||
void _glfwSetWindowSizeLimitsCocoa(_GLFWwindow* window, int minwidth, int minheight, int maxwidth, int maxheight);
|
||||
void _glfwSetWindowAspectRatioCocoa(_GLFWwindow* window, int numer, int denom);
|
||||
void _glfwGetFramebufferSizeCocoa(_GLFWwindow* window, int* width, int* height);
|
||||
void _glfwGetWindowFrameSizeCocoa(_GLFWwindow* window, int* left, int* top, int* right, int* bottom);
|
||||
void _glfwGetWindowContentScaleCocoa(_GLFWwindow* window, float* xscale, float* yscale);
|
||||
void _glfwIconifyWindowCocoa(_GLFWwindow* window);
|
||||
void _glfwRestoreWindowCocoa(_GLFWwindow* window);
|
||||
void _glfwMaximizeWindowCocoa(_GLFWwindow* window);
|
||||
void _glfwShowWindowCocoa(_GLFWwindow* window);
|
||||
void _glfwHideWindowCocoa(_GLFWwindow* window);
|
||||
void _glfwRequestWindowAttentionCocoa(_GLFWwindow* window);
|
||||
void _glfwFocusWindowCocoa(_GLFWwindow* window);
|
||||
void _glfwSetWindowMonitorCocoa(_GLFWwindow* window, _GLFWmonitor* monitor, int xpos, int ypos, int width, int height, int refreshRate);
|
||||
int _glfwWindowFocusedCocoa(_GLFWwindow* window);
|
||||
int _glfwWindowIconifiedCocoa(_GLFWwindow* window);
|
||||
int _glfwWindowVisibleCocoa(_GLFWwindow* window);
|
||||
int _glfwWindowMaximizedCocoa(_GLFWwindow* window);
|
||||
int _glfwWindowHoveredCocoa(_GLFWwindow* window);
|
||||
int _glfwFramebufferTransparentCocoa(_GLFWwindow* window);
|
||||
void _glfwSetWindowResizableCocoa(_GLFWwindow* window, GLFWbool enabled);
|
||||
void _glfwSetWindowDecoratedCocoa(_GLFWwindow* window, GLFWbool enabled);
|
||||
void _glfwSetWindowFloatingCocoa(_GLFWwindow* window, GLFWbool enabled);
|
||||
float _glfwGetWindowOpacityCocoa(_GLFWwindow* window);
|
||||
void _glfwSetWindowOpacityCocoa(_GLFWwindow* window, float opacity);
|
||||
void _glfwSetWindowMousePassthroughCocoa(_GLFWwindow* window, GLFWbool enabled);
|
||||
|
||||
void _glfwInitTimerNS(void);
|
||||
void _glfwSetRawMouseMotionCocoa(_GLFWwindow *window, GLFWbool enabled);
|
||||
GLFWbool _glfwRawMouseMotionSupportedCocoa(void);
|
||||
|
||||
void _glfwPollMonitorsNS(void);
|
||||
void _glfwSetVideoModeNS(_GLFWmonitor* monitor, const GLFWvidmode* desired);
|
||||
void _glfwRestoreVideoModeNS(_GLFWmonitor* monitor);
|
||||
void _glfwPollEventsCocoa(void);
|
||||
void _glfwWaitEventsCocoa(void);
|
||||
void _glfwWaitEventsTimeoutCocoa(double timeout);
|
||||
void _glfwPostEmptyEventCocoa(void);
|
||||
|
||||
float _glfwTransformYNS(float y);
|
||||
void _glfwGetCursorPosCocoa(_GLFWwindow* window, double* xpos, double* ypos);
|
||||
void _glfwSetCursorPosCocoa(_GLFWwindow* window, double xpos, double ypos);
|
||||
void _glfwSetCursorModeCocoa(_GLFWwindow* window, int mode);
|
||||
const char* _glfwGetScancodeNameCocoa(int scancode);
|
||||
int _glfwGetKeyScancodeCocoa(int key);
|
||||
int _glfwCreateCursorCocoa(_GLFWcursor* cursor, const GLFWimage* image, int xhot, int yhot);
|
||||
int _glfwCreateStandardCursorCocoa(_GLFWcursor* cursor, int shape);
|
||||
void _glfwDestroyCursorCocoa(_GLFWcursor* cursor);
|
||||
void _glfwSetCursorCocoa(_GLFWwindow* window, _GLFWcursor* cursor);
|
||||
void _glfwSetClipboardStringCocoa(const char* string);
|
||||
const char* _glfwGetClipboardStringCocoa(void);
|
||||
|
||||
void* _glfwLoadLocalVulkanLoaderNS(void);
|
||||
EGLenum _glfwGetEGLPlatformCocoa(EGLint** attribs);
|
||||
EGLNativeDisplayType _glfwGetEGLNativeDisplayCocoa(void);
|
||||
EGLNativeWindowType _glfwGetEGLNativeWindowCocoa(_GLFWwindow* window);
|
||||
|
||||
void _glfwGetRequiredInstanceExtensionsCocoa(char** extensions);
|
||||
int _glfwGetPhysicalDevicePresentationSupportCocoa(VkInstance instance, VkPhysicalDevice device, uint32_t queuefamily);
|
||||
VkResult _glfwCreateWindowSurfaceCocoa(VkInstance instance, _GLFWwindow* window, const VkAllocationCallbacks* allocator, VkSurfaceKHR* surface);
|
||||
|
||||
void _glfwFreeMonitorCocoa(_GLFWmonitor* monitor);
|
||||
void _glfwGetMonitorPosCocoa(_GLFWmonitor* monitor, int* xpos, int* ypos);
|
||||
void _glfwGetMonitorContentScaleCocoa(_GLFWmonitor* monitor, float* xscale, float* yscale);
|
||||
void _glfwGetMonitorWorkareaCocoa(_GLFWmonitor* monitor, int* xpos, int* ypos, int* width, int* height);
|
||||
GLFWvidmode* _glfwGetVideoModesCocoa(_GLFWmonitor* monitor, int* count);
|
||||
void _glfwGetVideoModeCocoa(_GLFWmonitor* monitor, GLFWvidmode* mode);
|
||||
GLFWbool _glfwGetGammaRampCocoa(_GLFWmonitor* monitor, GLFWgammaramp* ramp);
|
||||
void _glfwSetGammaRampCocoa(_GLFWmonitor* monitor, const GLFWgammaramp* ramp);
|
||||
|
||||
void _glfwPollMonitorsCocoa(void);
|
||||
void _glfwSetVideoModeCocoa(_GLFWmonitor* monitor, const GLFWvidmode* desired);
|
||||
void _glfwRestoreVideoModeCocoa(_GLFWmonitor* monitor);
|
||||
|
||||
float _glfwTransformYCocoa(float y);
|
||||
|
||||
void* _glfwLoadLocalVulkanLoaderCocoa(void);
|
||||
|
||||
GLFWbool _glfwInitNSGL(void);
|
||||
void _glfwTerminateNSGL(void);
|
||||
GLFWbool _glfwCreateContextNSGL(_GLFWwindow* window,
|
||||
const _GLFWctxconfig* ctxconfig,
|
||||
const _GLFWfbconfig* fbconfig);
|
||||
void _glfwDestroyContextNSGL(_GLFWwindow* window);
|
||||
|
||||
_GLFWusercontext* _glfwCreateUserContextCocoa(_GLFWwindow* window);
|
||||
_GLFWusercontext* _glfwCreateUserContextNSGL(_GLFWwindow* window);
|
||||
|
@ -32,12 +32,10 @@
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
////// GLFW internal API //////
|
||||
////// GLFW platform API //////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Initialise timer
|
||||
//
|
||||
void _glfwInitTimerNS(void)
|
||||
void _glfwPlatformInitTimer(void)
|
||||
{
|
||||
mach_timebase_info_data_t info;
|
||||
mach_timebase_info(&info);
|
||||
@ -45,11 +43,6 @@ void _glfwInitTimerNS(void)
|
||||
_glfw.timer.ns.frequency = (info.denom * 1e9) / info.numer;
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
////// GLFW platform API //////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
uint64_t _glfwPlatformGetTimerValue(void)
|
||||
{
|
||||
return mach_absolute_time();
|
||||
|
35
src/cocoa_time.h
Normal file
35
src/cocoa_time.h
Normal file
@ -0,0 +1,35 @@
|
||||
//========================================================================
|
||||
// GLFW 3.4 macOS - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2009-2021 Camilla Löwy <elmindreda@glfw.org>
|
||||
//
|
||||
// This software is provided 'as-is', without any express or implied
|
||||
// warranty. In no event will the authors be held liable for any damages
|
||||
// arising from the use of this software.
|
||||
//
|
||||
// Permission is granted to anyone to use this software for any purpose,
|
||||
// including commercial applications, and to alter it and redistribute it
|
||||
// freely, subject to the following restrictions:
|
||||
//
|
||||
// 1. The origin of this software must not be misrepresented; you must not
|
||||
// claim that you wrote the original software. If you use this software
|
||||
// in a product, an acknowledgment in the product documentation would
|
||||
// be appreciated but is not required.
|
||||
//
|
||||
// 2. Altered source versions must be plainly marked as such, and must not
|
||||
// be misrepresented as being the original software.
|
||||
//
|
||||
// 3. This notice may not be removed or altered from any source
|
||||
// distribution.
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#define GLFW_COCOA_LIBRARY_TIMER_STATE _GLFWtimerNS ns;
|
||||
|
||||
// Cocoa-specific global timer data
|
||||
//
|
||||
typedef struct _GLFWtimerNS
|
||||
{
|
||||
uint64_t frequency;
|
||||
} _GLFWtimerNS;
|
||||
|
@ -105,19 +105,20 @@ static void updateCursorMode(_GLFWwindow* window)
|
||||
if (window->cursorMode == GLFW_CURSOR_DISABLED)
|
||||
{
|
||||
_glfw.ns.disabledCursorWindow = window;
|
||||
_glfwPlatformGetCursorPos(window,
|
||||
&_glfw.ns.restoreCursorPosX,
|
||||
&_glfw.ns.restoreCursorPosY);
|
||||
_glfwGetCursorPosCocoa(window,
|
||||
&_glfw.ns.restoreCursorPosX,
|
||||
&_glfw.ns.restoreCursorPosY);
|
||||
_glfwCenterCursorInContentArea(window);
|
||||
CGAssociateMouseAndMouseCursorPosition(false);
|
||||
}
|
||||
else if (_glfw.ns.disabledCursorWindow == window)
|
||||
{
|
||||
_glfw.ns.disabledCursorWindow = NULL;
|
||||
CGAssociateMouseAndMouseCursorPosition(true);
|
||||
_glfwPlatformSetCursorPos(window,
|
||||
_glfw.ns.restoreCursorPosX,
|
||||
_glfw.ns.restoreCursorPosY);
|
||||
_glfwSetCursorPosCocoa(window,
|
||||
_glfw.ns.restoreCursorPosX,
|
||||
_glfw.ns.restoreCursorPosY);
|
||||
// NOTE: The matching CGAssociateMouseAndMouseCursorPosition call is
|
||||
// made in _glfwSetCursorPosCocoa as part of a workaround
|
||||
}
|
||||
|
||||
if (cursorInContentArea(window))
|
||||
@ -128,10 +129,10 @@ static void updateCursorMode(_GLFWwindow* window)
|
||||
//
|
||||
static void acquireMonitor(_GLFWwindow* window)
|
||||
{
|
||||
_glfwSetVideoModeNS(window->monitor, &window->videoMode);
|
||||
_glfwSetVideoModeCocoa(window->monitor, &window->videoMode);
|
||||
const CGRect bounds = CGDisplayBounds(window->monitor->ns.displayID);
|
||||
const NSRect frame = NSMakeRect(bounds.origin.x,
|
||||
_glfwTransformYNS(bounds.origin.y + bounds.size.height - 1),
|
||||
_glfwTransformYCocoa(bounds.origin.y + bounds.size.height - 1),
|
||||
bounds.size.width,
|
||||
bounds.size.height);
|
||||
|
||||
@ -148,7 +149,7 @@ static void releaseMonitor(_GLFWwindow* window)
|
||||
return;
|
||||
|
||||
_glfwInputMonitorWindow(window->monitor, NULL);
|
||||
_glfwRestoreVideoModeNS(window->monitor);
|
||||
_glfwRestoreVideoModeCocoa(window->monitor);
|
||||
}
|
||||
|
||||
// Translates macOS key modifiers into GLFW ones
|
||||
@ -285,7 +286,7 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
|
||||
_glfwCenterCursorInContentArea(window);
|
||||
|
||||
int x, y;
|
||||
_glfwPlatformGetWindowPos(window, &x, &y);
|
||||
_glfwGetWindowPosCocoa(window, &x, &y);
|
||||
_glfwInputWindowPos(window, x, y);
|
||||
}
|
||||
|
||||
@ -317,7 +318,7 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
|
||||
- (void)windowDidResignKey:(NSNotification *)notification
|
||||
{
|
||||
if (window->monitor && window->autoIconify)
|
||||
_glfwPlatformIconifyWindow(window);
|
||||
_glfwIconifyWindowCocoa(window);
|
||||
|
||||
_glfwInputWindowFocus(window, GLFW_FALSE);
|
||||
}
|
||||
@ -360,9 +361,7 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
|
||||
markedText = [[NSMutableAttributedString alloc] init];
|
||||
|
||||
[self updateTrackingAreas];
|
||||
// NOTE: kUTTypeURL corresponds to NSPasteboardTypeURL but is available
|
||||
// on 10.7 without having been deprecated yet
|
||||
[self registerForDraggedTypes:@[(__bridge NSString*) kUTTypeURL]];
|
||||
[self registerForDraggedTypes:@[NSPasteboardTypeURL]];
|
||||
}
|
||||
|
||||
return self;
|
||||
@ -802,8 +801,8 @@ static GLFWbool createNativeWindow(_GLFWwindow* window,
|
||||
GLFWvidmode mode;
|
||||
int xpos, ypos;
|
||||
|
||||
_glfwPlatformGetVideoMode(window->monitor, &mode);
|
||||
_glfwPlatformGetMonitorPos(window->monitor, &xpos, &ypos);
|
||||
_glfwGetVideoModeCocoa(window->monitor, &mode);
|
||||
_glfwGetMonitorPosCocoa(window->monitor, &xpos, &ypos);
|
||||
|
||||
contentRect = NSMakeRect(xpos, ypos, mode.width, mode.height);
|
||||
}
|
||||
@ -871,8 +870,8 @@ static GLFWbool createNativeWindow(_GLFWwindow* window,
|
||||
[window->ns.object setTabbingMode:NSWindowTabbingModeDisallowed];
|
||||
#endif
|
||||
|
||||
_glfwPlatformGetWindowSize(window, &window->ns.width, &window->ns.height);
|
||||
_glfwPlatformGetFramebufferSize(window, &window->ns.fbWidth, &window->ns.fbHeight);
|
||||
_glfwGetWindowSizeCocoa(window, &window->ns.width, &window->ns.height);
|
||||
_glfwGetFramebufferSizeCocoa(window, &window->ns.fbWidth, &window->ns.fbHeight);
|
||||
|
||||
return GLFW_TRUE;
|
||||
}
|
||||
@ -884,7 +883,7 @@ static GLFWbool createNativeWindow(_GLFWwindow* window,
|
||||
|
||||
// Transforms a y-coordinate between the CG display and NS screen spaces
|
||||
//
|
||||
float _glfwTransformYNS(float y)
|
||||
float _glfwTransformYCocoa(float y)
|
||||
{
|
||||
return CGDisplayBounds(CGMainDisplayID()).size.height - y - 1;
|
||||
}
|
||||
@ -894,10 +893,10 @@ float _glfwTransformYNS(float y)
|
||||
////// GLFW platform API //////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int _glfwPlatformCreateWindow(_GLFWwindow* window,
|
||||
const _GLFWwndconfig* wndconfig,
|
||||
const _GLFWctxconfig* ctxconfig,
|
||||
const _GLFWfbconfig* fbconfig)
|
||||
int _glfwCreateWindowCocoa(_GLFWwindow* window,
|
||||
const _GLFWwndconfig* wndconfig,
|
||||
const _GLFWctxconfig* ctxconfig,
|
||||
const _GLFWfbconfig* fbconfig)
|
||||
{
|
||||
@autoreleasepool {
|
||||
|
||||
@ -936,8 +935,8 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
|
||||
|
||||
if (window->monitor)
|
||||
{
|
||||
_glfwPlatformShowWindow(window);
|
||||
_glfwPlatformFocusWindow(window);
|
||||
_glfwShowWindowCocoa(window);
|
||||
_glfwFocusWindowCocoa(window);
|
||||
acquireMonitor(window);
|
||||
}
|
||||
|
||||
@ -946,7 +945,7 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
|
||||
} // autoreleasepool
|
||||
}
|
||||
|
||||
void _glfwPlatformDestroyWindow(_GLFWwindow* window)
|
||||
void _glfwDestroyWindowCocoa(_GLFWwindow* window)
|
||||
{
|
||||
@autoreleasepool {
|
||||
|
||||
@ -972,12 +971,12 @@ void _glfwPlatformDestroyWindow(_GLFWwindow* window)
|
||||
window->ns.object = nil;
|
||||
|
||||
// HACK: Allow Cocoa to catch up before returning
|
||||
_glfwPlatformPollEvents();
|
||||
_glfwPollEventsCocoa();
|
||||
|
||||
} // autoreleasepool
|
||||
}
|
||||
|
||||
void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title)
|
||||
void _glfwSetWindowTitleCocoa(_GLFWwindow* window, const char* title)
|
||||
{
|
||||
@autoreleasepool {
|
||||
NSString* string = @(title);
|
||||
@ -988,14 +987,14 @@ void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title)
|
||||
} // autoreleasepool
|
||||
}
|
||||
|
||||
void _glfwPlatformSetWindowIcon(_GLFWwindow* window,
|
||||
int count, const GLFWimage* images)
|
||||
void _glfwSetWindowIconCocoa(_GLFWwindow* window,
|
||||
int count, const GLFWimage* images)
|
||||
{
|
||||
_glfwInputError(GLFW_FEATURE_UNAVAILABLE,
|
||||
"Cocoa: Regular windows do not have icons on macOS");
|
||||
}
|
||||
|
||||
void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos)
|
||||
void _glfwGetWindowPosCocoa(_GLFWwindow* window, int* xpos, int* ypos)
|
||||
{
|
||||
@autoreleasepool {
|
||||
|
||||
@ -1005,24 +1004,24 @@ void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos)
|
||||
if (xpos)
|
||||
*xpos = contentRect.origin.x;
|
||||
if (ypos)
|
||||
*ypos = _glfwTransformYNS(contentRect.origin.y + contentRect.size.height - 1);
|
||||
*ypos = _glfwTransformYCocoa(contentRect.origin.y + contentRect.size.height - 1);
|
||||
|
||||
} // autoreleasepool
|
||||
}
|
||||
|
||||
void _glfwPlatformSetWindowPos(_GLFWwindow* window, int x, int y)
|
||||
void _glfwSetWindowPosCocoa(_GLFWwindow* window, int x, int y)
|
||||
{
|
||||
@autoreleasepool {
|
||||
|
||||
const NSRect contentRect = [window->ns.view frame];
|
||||
const NSRect dummyRect = NSMakeRect(x, _glfwTransformYNS(y + contentRect.size.height - 1), 0, 0);
|
||||
const NSRect dummyRect = NSMakeRect(x, _glfwTransformYCocoa(y + contentRect.size.height - 1), 0, 0);
|
||||
const NSRect frameRect = [window->ns.object frameRectForContentRect:dummyRect];
|
||||
[window->ns.object setFrameOrigin:frameRect.origin];
|
||||
|
||||
} // autoreleasepool
|
||||
}
|
||||
|
||||
void _glfwPlatformGetWindowSize(_GLFWwindow* window, int* width, int* height)
|
||||
void _glfwGetWindowSizeCocoa(_GLFWwindow* window, int* width, int* height)
|
||||
{
|
||||
@autoreleasepool {
|
||||
|
||||
@ -1036,7 +1035,7 @@ void _glfwPlatformGetWindowSize(_GLFWwindow* window, int* width, int* height)
|
||||
} // autoreleasepool
|
||||
}
|
||||
|
||||
void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
|
||||
void _glfwSetWindowSizeCocoa(_GLFWwindow* window, int width, int height)
|
||||
{
|
||||
@autoreleasepool {
|
||||
|
||||
@ -1058,9 +1057,9 @@ void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
|
||||
} // autoreleasepool
|
||||
}
|
||||
|
||||
void _glfwPlatformSetWindowSizeLimits(_GLFWwindow* window,
|
||||
int minwidth, int minheight,
|
||||
int maxwidth, int maxheight)
|
||||
void _glfwSetWindowSizeLimitsCocoa(_GLFWwindow* window,
|
||||
int minwidth, int minheight,
|
||||
int maxwidth, int maxheight)
|
||||
{
|
||||
@autoreleasepool {
|
||||
|
||||
@ -1077,7 +1076,7 @@ void _glfwPlatformSetWindowSizeLimits(_GLFWwindow* window,
|
||||
} // autoreleasepool
|
||||
}
|
||||
|
||||
void _glfwPlatformSetWindowAspectRatio(_GLFWwindow* window, int numer, int denom)
|
||||
void _glfwSetWindowAspectRatioCocoa(_GLFWwindow* window, int numer, int denom)
|
||||
{
|
||||
@autoreleasepool {
|
||||
if (numer == GLFW_DONT_CARE || denom == GLFW_DONT_CARE)
|
||||
@ -1087,7 +1086,7 @@ void _glfwPlatformSetWindowAspectRatio(_GLFWwindow* window, int numer, int denom
|
||||
} // autoreleasepool
|
||||
}
|
||||
|
||||
void _glfwPlatformGetFramebufferSize(_GLFWwindow* window, int* width, int* height)
|
||||
void _glfwGetFramebufferSizeCocoa(_GLFWwindow* window, int* width, int* height)
|
||||
{
|
||||
@autoreleasepool {
|
||||
|
||||
@ -1102,9 +1101,9 @@ void _glfwPlatformGetFramebufferSize(_GLFWwindow* window, int* width, int* heigh
|
||||
} // autoreleasepool
|
||||
}
|
||||
|
||||
void _glfwPlatformGetWindowFrameSize(_GLFWwindow* window,
|
||||
int* left, int* top,
|
||||
int* right, int* bottom)
|
||||
void _glfwGetWindowFrameSizeCocoa(_GLFWwindow* window,
|
||||
int* left, int* top,
|
||||
int* right, int* bottom)
|
||||
{
|
||||
@autoreleasepool {
|
||||
|
||||
@ -1125,8 +1124,8 @@ void _glfwPlatformGetWindowFrameSize(_GLFWwindow* window,
|
||||
} // autoreleasepool
|
||||
}
|
||||
|
||||
void _glfwPlatformGetWindowContentScale(_GLFWwindow* window,
|
||||
float* xscale, float* yscale)
|
||||
void _glfwGetWindowContentScaleCocoa(_GLFWwindow* window,
|
||||
float* xscale, float* yscale)
|
||||
{
|
||||
@autoreleasepool {
|
||||
|
||||
@ -1141,14 +1140,14 @@ void _glfwPlatformGetWindowContentScale(_GLFWwindow* window,
|
||||
} // autoreleasepool
|
||||
}
|
||||
|
||||
void _glfwPlatformIconifyWindow(_GLFWwindow* window)
|
||||
void _glfwIconifyWindowCocoa(_GLFWwindow* window)
|
||||
{
|
||||
@autoreleasepool {
|
||||
[window->ns.object miniaturize:nil];
|
||||
} // autoreleasepool
|
||||
}
|
||||
|
||||
void _glfwPlatformRestoreWindow(_GLFWwindow* window)
|
||||
void _glfwRestoreWindowCocoa(_GLFWwindow* window)
|
||||
{
|
||||
@autoreleasepool {
|
||||
if ([window->ns.object isMiniaturized])
|
||||
@ -1158,7 +1157,7 @@ void _glfwPlatformRestoreWindow(_GLFWwindow* window)
|
||||
} // autoreleasepool
|
||||
}
|
||||
|
||||
void _glfwPlatformMaximizeWindow(_GLFWwindow* window)
|
||||
void _glfwMaximizeWindowCocoa(_GLFWwindow* window)
|
||||
{
|
||||
@autoreleasepool {
|
||||
if (![window->ns.object isZoomed])
|
||||
@ -1166,28 +1165,28 @@ void _glfwPlatformMaximizeWindow(_GLFWwindow* window)
|
||||
} // autoreleasepool
|
||||
}
|
||||
|
||||
void _glfwPlatformShowWindow(_GLFWwindow* window)
|
||||
void _glfwShowWindowCocoa(_GLFWwindow* window)
|
||||
{
|
||||
@autoreleasepool {
|
||||
[window->ns.object orderFront:nil];
|
||||
} // autoreleasepool
|
||||
}
|
||||
|
||||
void _glfwPlatformHideWindow(_GLFWwindow* window)
|
||||
void _glfwHideWindowCocoa(_GLFWwindow* window)
|
||||
{
|
||||
@autoreleasepool {
|
||||
[window->ns.object orderOut:nil];
|
||||
} // autoreleasepool
|
||||
}
|
||||
|
||||
void _glfwPlatformRequestWindowAttention(_GLFWwindow* window)
|
||||
void _glfwRequestWindowAttentionCocoa(_GLFWwindow* window)
|
||||
{
|
||||
@autoreleasepool {
|
||||
[NSApp requestUserAttention:NSInformationalRequest];
|
||||
} // autoreleasepool
|
||||
}
|
||||
|
||||
void _glfwPlatformFocusWindow(_GLFWwindow* window)
|
||||
void _glfwFocusWindowCocoa(_GLFWwindow* window)
|
||||
{
|
||||
@autoreleasepool {
|
||||
// Make us the active application
|
||||
@ -1199,11 +1198,11 @@ void _glfwPlatformFocusWindow(_GLFWwindow* window)
|
||||
} // autoreleasepool
|
||||
}
|
||||
|
||||
void _glfwPlatformSetWindowMonitor(_GLFWwindow* window,
|
||||
_GLFWmonitor* monitor,
|
||||
int xpos, int ypos,
|
||||
int width, int height,
|
||||
int refreshRate)
|
||||
void _glfwSetWindowMonitorCocoa(_GLFWwindow* window,
|
||||
_GLFWmonitor* monitor,
|
||||
int xpos, int ypos,
|
||||
int width, int height,
|
||||
int refreshRate)
|
||||
{
|
||||
@autoreleasepool {
|
||||
|
||||
@ -1217,7 +1216,7 @@ void _glfwPlatformSetWindowMonitor(_GLFWwindow* window,
|
||||
else
|
||||
{
|
||||
const NSRect contentRect =
|
||||
NSMakeRect(xpos, _glfwTransformYNS(ypos + height - 1), width, height);
|
||||
NSMakeRect(xpos, _glfwTransformYCocoa(ypos + height - 1), width, height);
|
||||
const NSRect frameRect =
|
||||
[window->ns.object frameRectForContentRect:contentRect
|
||||
styleMask:getStyleMask(window)];
|
||||
@ -1235,7 +1234,7 @@ void _glfwPlatformSetWindowMonitor(_GLFWwindow* window,
|
||||
|
||||
// HACK: Allow the state cached in Cocoa to catch up to reality
|
||||
// TODO: Solve this in a less terrible way
|
||||
_glfwPlatformPollEvents();
|
||||
_glfwPollEventsCocoa();
|
||||
|
||||
const NSUInteger styleMask = getStyleMask(window);
|
||||
[window->ns.object setStyleMask:styleMask];
|
||||
@ -1251,7 +1250,7 @@ void _glfwPlatformSetWindowMonitor(_GLFWwindow* window,
|
||||
}
|
||||
else
|
||||
{
|
||||
NSRect contentRect = NSMakeRect(xpos, _glfwTransformYNS(ypos + height - 1),
|
||||
NSRect contentRect = NSMakeRect(xpos, _glfwTransformYCocoa(ypos + height - 1),
|
||||
width, height);
|
||||
NSRect frameRect = [window->ns.object frameRectForContentRect:contentRect
|
||||
styleMask:styleMask];
|
||||
@ -1292,35 +1291,35 @@ void _glfwPlatformSetWindowMonitor(_GLFWwindow* window,
|
||||
} // autoreleasepool
|
||||
}
|
||||
|
||||
int _glfwPlatformWindowFocused(_GLFWwindow* window)
|
||||
int _glfwWindowFocusedCocoa(_GLFWwindow* window)
|
||||
{
|
||||
@autoreleasepool {
|
||||
return [window->ns.object isKeyWindow];
|
||||
} // autoreleasepool
|
||||
}
|
||||
|
||||
int _glfwPlatformWindowIconified(_GLFWwindow* window)
|
||||
int _glfwWindowIconifiedCocoa(_GLFWwindow* window)
|
||||
{
|
||||
@autoreleasepool {
|
||||
return [window->ns.object isMiniaturized];
|
||||
} // autoreleasepool
|
||||
}
|
||||
|
||||
int _glfwPlatformWindowVisible(_GLFWwindow* window)
|
||||
int _glfwWindowVisibleCocoa(_GLFWwindow* window)
|
||||
{
|
||||
@autoreleasepool {
|
||||
return [window->ns.object isVisible];
|
||||
} // autoreleasepool
|
||||
}
|
||||
|
||||
int _glfwPlatformWindowMaximized(_GLFWwindow* window)
|
||||
int _glfwWindowMaximizedCocoa(_GLFWwindow* window)
|
||||
{
|
||||
@autoreleasepool {
|
||||
return [window->ns.object isZoomed];
|
||||
} // autoreleasepool
|
||||
}
|
||||
|
||||
int _glfwPlatformWindowHovered(_GLFWwindow* window)
|
||||
int _glfwWindowHoveredCocoa(_GLFWwindow* window)
|
||||
{
|
||||
@autoreleasepool {
|
||||
|
||||
@ -1338,21 +1337,21 @@ int _glfwPlatformWindowHovered(_GLFWwindow* window)
|
||||
} // autoreleasepool
|
||||
}
|
||||
|
||||
int _glfwPlatformFramebufferTransparent(_GLFWwindow* window)
|
||||
int _glfwFramebufferTransparentCocoa(_GLFWwindow* window)
|
||||
{
|
||||
@autoreleasepool {
|
||||
return ![window->ns.object isOpaque] && ![window->ns.view isOpaque];
|
||||
} // autoreleasepool
|
||||
}
|
||||
|
||||
void _glfwPlatformSetWindowResizable(_GLFWwindow* window, GLFWbool enabled)
|
||||
void _glfwSetWindowResizableCocoa(_GLFWwindow* window, GLFWbool enabled)
|
||||
{
|
||||
@autoreleasepool {
|
||||
[window->ns.object setStyleMask:getStyleMask(window)];
|
||||
} // autoreleasepool
|
||||
}
|
||||
|
||||
void _glfwPlatformSetWindowDecorated(_GLFWwindow* window, GLFWbool enabled)
|
||||
void _glfwSetWindowDecoratedCocoa(_GLFWwindow* window, GLFWbool enabled)
|
||||
{
|
||||
@autoreleasepool {
|
||||
[window->ns.object setStyleMask:getStyleMask(window)];
|
||||
@ -1360,7 +1359,7 @@ void _glfwPlatformSetWindowDecorated(_GLFWwindow* window, GLFWbool enabled)
|
||||
} // autoreleasepool
|
||||
}
|
||||
|
||||
void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled)
|
||||
void _glfwSetWindowFloatingCocoa(_GLFWwindow* window, GLFWbool enabled)
|
||||
{
|
||||
@autoreleasepool {
|
||||
if (enabled)
|
||||
@ -1370,39 +1369,39 @@ void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled)
|
||||
} // autoreleasepool
|
||||
}
|
||||
|
||||
void _glfwPlatformSetWindowMousePassthrough(_GLFWwindow* window, GLFWbool enabled)
|
||||
void _glfwSetWindowMousePassthroughCocoa(_GLFWwindow* window, GLFWbool enabled)
|
||||
{
|
||||
@autoreleasepool {
|
||||
[window->ns.object setIgnoresMouseEvents:enabled];
|
||||
}
|
||||
}
|
||||
|
||||
float _glfwPlatformGetWindowOpacity(_GLFWwindow* window)
|
||||
float _glfwGetWindowOpacityCocoa(_GLFWwindow* window)
|
||||
{
|
||||
@autoreleasepool {
|
||||
return (float) [window->ns.object alphaValue];
|
||||
} // autoreleasepool
|
||||
}
|
||||
|
||||
void _glfwPlatformSetWindowOpacity(_GLFWwindow* window, float opacity)
|
||||
void _glfwSetWindowOpacityCocoa(_GLFWwindow* window, float opacity)
|
||||
{
|
||||
@autoreleasepool {
|
||||
[window->ns.object setAlphaValue:opacity];
|
||||
} // autoreleasepool
|
||||
}
|
||||
|
||||
void _glfwPlatformSetRawMouseMotion(_GLFWwindow *window, GLFWbool enabled)
|
||||
void _glfwSetRawMouseMotionCocoa(_GLFWwindow *window, GLFWbool enabled)
|
||||
{
|
||||
_glfwInputError(GLFW_FEATURE_UNIMPLEMENTED,
|
||||
"Cocoa: Raw mouse motion not yet implemented");
|
||||
}
|
||||
|
||||
GLFWbool _glfwPlatformRawMouseMotionSupported(void)
|
||||
GLFWbool _glfwRawMouseMotionSupportedCocoa(void)
|
||||
{
|
||||
return GLFW_FALSE;
|
||||
}
|
||||
|
||||
void _glfwPlatformPollEvents(void)
|
||||
void _glfwPollEventsCocoa(void)
|
||||
{
|
||||
@autoreleasepool {
|
||||
|
||||
@ -1421,7 +1420,7 @@ void _glfwPlatformPollEvents(void)
|
||||
} // autoreleasepool
|
||||
}
|
||||
|
||||
void _glfwPlatformWaitEvents(void)
|
||||
void _glfwWaitEventsCocoa(void)
|
||||
{
|
||||
@autoreleasepool {
|
||||
|
||||
@ -1434,12 +1433,12 @@ void _glfwPlatformWaitEvents(void)
|
||||
dequeue:YES];
|
||||
[NSApp sendEvent:event];
|
||||
|
||||
_glfwPlatformPollEvents();
|
||||
_glfwPollEventsCocoa();
|
||||
|
||||
} // autoreleasepool
|
||||
}
|
||||
|
||||
void _glfwPlatformWaitEventsTimeout(double timeout)
|
||||
void _glfwWaitEventsTimeoutCocoa(double timeout)
|
||||
{
|
||||
@autoreleasepool {
|
||||
|
||||
@ -1451,12 +1450,12 @@ void _glfwPlatformWaitEventsTimeout(double timeout)
|
||||
if (event)
|
||||
[NSApp sendEvent:event];
|
||||
|
||||
_glfwPlatformPollEvents();
|
||||
_glfwPollEventsCocoa();
|
||||
|
||||
} // autoreleasepool
|
||||
}
|
||||
|
||||
void _glfwPlatformPostEmptyEvent(void)
|
||||
void _glfwPostEmptyEventCocoa(void)
|
||||
{
|
||||
@autoreleasepool {
|
||||
|
||||
@ -1474,7 +1473,7 @@ void _glfwPlatformPostEmptyEvent(void)
|
||||
} // autoreleasepool
|
||||
}
|
||||
|
||||
void _glfwPlatformGetCursorPos(_GLFWwindow* window, double* xpos, double* ypos)
|
||||
void _glfwGetCursorPosCocoa(_GLFWwindow* window, double* xpos, double* ypos)
|
||||
{
|
||||
@autoreleasepool {
|
||||
|
||||
@ -1490,7 +1489,7 @@ void _glfwPlatformGetCursorPos(_GLFWwindow* window, double* xpos, double* ypos)
|
||||
} // autoreleasepool
|
||||
}
|
||||
|
||||
void _glfwPlatformSetCursorPos(_GLFWwindow* window, double x, double y)
|
||||
void _glfwSetCursorPosCocoa(_GLFWwindow* window, double x, double y)
|
||||
{
|
||||
@autoreleasepool {
|
||||
|
||||
@ -1515,21 +1514,26 @@ void _glfwPlatformSetCursorPos(_GLFWwindow* window, double x, double y)
|
||||
const NSPoint globalPoint = globalRect.origin;
|
||||
|
||||
CGWarpMouseCursorPosition(CGPointMake(globalPoint.x,
|
||||
_glfwTransformYNS(globalPoint.y)));
|
||||
_glfwTransformYCocoa(globalPoint.y)));
|
||||
}
|
||||
|
||||
// HACK: Calling this right after setting the cursor position prevents macOS
|
||||
// from freezing the cursor for a fraction of a second afterwards
|
||||
if (window->cursorMode != GLFW_CURSOR_DISABLED)
|
||||
CGAssociateMouseAndMouseCursorPosition(true);
|
||||
|
||||
} // autoreleasepool
|
||||
}
|
||||
|
||||
void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode)
|
||||
void _glfwSetCursorModeCocoa(_GLFWwindow* window, int mode)
|
||||
{
|
||||
@autoreleasepool {
|
||||
if (_glfwPlatformWindowFocused(window))
|
||||
if (_glfwWindowFocusedCocoa(window))
|
||||
updateCursorMode(window);
|
||||
} // autoreleasepool
|
||||
}
|
||||
|
||||
const char* _glfwPlatformGetScancodeName(int scancode)
|
||||
const char* _glfwGetScancodeNameCocoa(int scancode)
|
||||
{
|
||||
@autoreleasepool {
|
||||
|
||||
@ -1578,14 +1582,14 @@ const char* _glfwPlatformGetScancodeName(int scancode)
|
||||
} // autoreleasepool
|
||||
}
|
||||
|
||||
int _glfwPlatformGetKeyScancode(int key)
|
||||
int _glfwGetKeyScancodeCocoa(int key)
|
||||
{
|
||||
return _glfw.ns.scancodes[key];
|
||||
}
|
||||
|
||||
int _glfwPlatformCreateCursor(_GLFWcursor* cursor,
|
||||
const GLFWimage* image,
|
||||
int xhot, int yhot)
|
||||
int _glfwCreateCursorCocoa(_GLFWcursor* cursor,
|
||||
const GLFWimage* image,
|
||||
int xhot, int yhot)
|
||||
{
|
||||
@autoreleasepool {
|
||||
|
||||
@ -1627,7 +1631,7 @@ int _glfwPlatformCreateCursor(_GLFWcursor* cursor,
|
||||
} // autoreleasepool
|
||||
}
|
||||
|
||||
int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape)
|
||||
int _glfwCreateStandardCursorCocoa(_GLFWcursor* cursor, int shape)
|
||||
{
|
||||
@autoreleasepool {
|
||||
|
||||
@ -1701,7 +1705,7 @@ int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape)
|
||||
} // autoreleasepool
|
||||
}
|
||||
|
||||
void _glfwPlatformDestroyCursor(_GLFWcursor* cursor)
|
||||
void _glfwDestroyCursorCocoa(_GLFWcursor* cursor)
|
||||
{
|
||||
@autoreleasepool {
|
||||
if (cursor->ns.object)
|
||||
@ -1709,7 +1713,7 @@ void _glfwPlatformDestroyCursor(_GLFWcursor* cursor)
|
||||
} // autoreleasepool
|
||||
}
|
||||
|
||||
void _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor)
|
||||
void _glfwSetCursorCocoa(_GLFWwindow* window, _GLFWcursor* cursor)
|
||||
{
|
||||
@autoreleasepool {
|
||||
if (cursorInContentArea(window))
|
||||
@ -1717,7 +1721,7 @@ void _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor)
|
||||
} // autoreleasepool
|
||||
}
|
||||
|
||||
void _glfwPlatformSetClipboardString(const char* string)
|
||||
void _glfwSetClipboardStringCocoa(const char* string)
|
||||
{
|
||||
@autoreleasepool {
|
||||
NSPasteboard* pasteboard = [NSPasteboard generalPasteboard];
|
||||
@ -1726,7 +1730,7 @@ void _glfwPlatformSetClipboardString(const char* string)
|
||||
} // autoreleasepool
|
||||
}
|
||||
|
||||
const char* _glfwPlatformGetClipboardString(void)
|
||||
const char* _glfwGetClipboardStringCocoa(void)
|
||||
{
|
||||
@autoreleasepool {
|
||||
|
||||
@ -1755,7 +1759,7 @@ const char* _glfwPlatformGetClipboardString(void)
|
||||
} // autoreleasepool
|
||||
}
|
||||
|
||||
EGLenum _glfwPlatformGetEGLPlatform(EGLint** attribs)
|
||||
EGLenum _glfwGetEGLPlatformCocoa(EGLint** attribs)
|
||||
{
|
||||
if (_glfw.egl.ANGLE_platform_angle)
|
||||
{
|
||||
@ -1786,17 +1790,17 @@ EGLenum _glfwPlatformGetEGLPlatform(EGLint** attribs)
|
||||
return 0;
|
||||
}
|
||||
|
||||
EGLNativeDisplayType _glfwPlatformGetEGLNativeDisplay(void)
|
||||
EGLNativeDisplayType _glfwGetEGLNativeDisplayCocoa(void)
|
||||
{
|
||||
return EGL_DEFAULT_DISPLAY;
|
||||
}
|
||||
|
||||
EGLNativeWindowType _glfwPlatformGetEGLNativeWindow(_GLFWwindow* window)
|
||||
EGLNativeWindowType _glfwGetEGLNativeWindowCocoa(_GLFWwindow* window)
|
||||
{
|
||||
return window->ns.layer;
|
||||
}
|
||||
|
||||
void _glfwPlatformGetRequiredInstanceExtensions(char** extensions)
|
||||
void _glfwGetRequiredInstanceExtensionsCocoa(char** extensions)
|
||||
{
|
||||
if (_glfw.vk.KHR_surface && _glfw.vk.EXT_metal_surface)
|
||||
{
|
||||
@ -1810,17 +1814,17 @@ void _glfwPlatformGetRequiredInstanceExtensions(char** extensions)
|
||||
}
|
||||
}
|
||||
|
||||
int _glfwPlatformGetPhysicalDevicePresentationSupport(VkInstance instance,
|
||||
VkPhysicalDevice device,
|
||||
uint32_t queuefamily)
|
||||
int _glfwGetPhysicalDevicePresentationSupportCocoa(VkInstance instance,
|
||||
VkPhysicalDevice device,
|
||||
uint32_t queuefamily)
|
||||
{
|
||||
return GLFW_TRUE;
|
||||
}
|
||||
|
||||
VkResult _glfwPlatformCreateWindowSurface(VkInstance instance,
|
||||
_GLFWwindow* window,
|
||||
const VkAllocationCallbacks* allocator,
|
||||
VkSurfaceKHR* surface)
|
||||
VkResult _glfwCreateWindowSurfaceCocoa(VkInstance instance,
|
||||
_GLFWwindow* window,
|
||||
const VkAllocationCallbacks* allocator,
|
||||
VkSurfaceKHR* surface)
|
||||
{
|
||||
@autoreleasepool {
|
||||
|
||||
@ -1909,7 +1913,7 @@ VkResult _glfwPlatformCreateWindowSurface(VkInstance instance,
|
||||
}
|
||||
|
||||
|
||||
_GLFWusercontext* _glfwPlatformCreateUserContext(_GLFWwindow* window)
|
||||
_GLFWusercontext* _glfwCreateUserContextCocoa(_GLFWwindow* window)
|
||||
{
|
||||
if (window->context.nsgl.object)
|
||||
{
|
||||
@ -1936,6 +1940,14 @@ GLFWAPI id glfwGetCocoaWindow(GLFWwindow* handle)
|
||||
{
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(nil);
|
||||
|
||||
if (_glfw.platform.platformID != GLFW_PLATFORM_COCOA)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_UNAVAILABLE,
|
||||
"Cocoa: Platform not initialized");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return window->ns.object;
|
||||
}
|
||||
|
||||
|
@ -777,8 +777,7 @@ GLFWAPI GLFWusercontext* glfwCreateUserContext(GLFWwindow* handle)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
context = _glfwPlatformCreateUserContext(window);
|
||||
context = _glfw.platform.createUserContext(window);
|
||||
|
||||
return (GLFWusercontext*)context;
|
||||
}
|
||||
|
@ -123,6 +123,7 @@ static GLFWbool chooseEGLConfig(const _GLFWctxconfig* ctxconfig,
|
||||
continue;
|
||||
|
||||
#if defined(_GLFW_X11)
|
||||
if (_glfw.platform.platformID == GLFW_PLATFORM_X11)
|
||||
{
|
||||
XVisualInfo vi = {0};
|
||||
|
||||
@ -230,6 +231,15 @@ static void swapBuffersEGL(_GLFWwindow* window)
|
||||
return;
|
||||
}
|
||||
|
||||
#if defined(_GLFW_WAYLAND)
|
||||
if (_glfw.platform.platformID == GLFW_PLATFORM_WAYLAND)
|
||||
{
|
||||
// NOTE: Swapping buffers on a hidden window on Wayland makes it visible
|
||||
if (!window->wl.visible)
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
eglSwapBuffers(_glfw.egl.display, window->context.egl.surface);
|
||||
}
|
||||
|
||||
@ -256,8 +266,8 @@ static GLFWglproc getProcAddressEGL(const char* procname)
|
||||
|
||||
if (window->context.egl.client)
|
||||
{
|
||||
GLFWglproc proc = (GLFWglproc) _glfw_dlsym(window->context.egl.client,
|
||||
procname);
|
||||
GLFWglproc proc = (GLFWglproc)
|
||||
_glfwPlatformGetModuleSymbol(window->context.egl.client, procname);
|
||||
if (proc)
|
||||
return proc;
|
||||
}
|
||||
@ -267,15 +277,14 @@ static GLFWglproc getProcAddressEGL(const char* procname)
|
||||
|
||||
static void destroyContextEGL(_GLFWwindow* window)
|
||||
{
|
||||
#if defined(_GLFW_X11)
|
||||
// NOTE: Do not unload libGL.so.1 while the X11 display is still open,
|
||||
// as it will make XCloseDisplay segfault
|
||||
if (window->context.client != GLFW_OPENGL_API)
|
||||
#endif // _GLFW_X11
|
||||
if (_glfw.platform.platformID != GLFW_PLATFORM_X11 ||
|
||||
window->context.client != GLFW_OPENGL_API)
|
||||
{
|
||||
if (window->context.egl.client)
|
||||
{
|
||||
_glfw_dlclose(window->context.egl.client);
|
||||
_glfwPlatformFreeModule(window->context.egl.client);
|
||||
window->context.egl.client = NULL;
|
||||
}
|
||||
}
|
||||
@ -316,6 +325,8 @@ GLFWbool _glfwInitEGL(void)
|
||||
"libEGL.dylib",
|
||||
#elif defined(__CYGWIN__)
|
||||
"libEGL-1.so",
|
||||
#elif defined(__OpenBSD__) || defined(__NetBSD__)
|
||||
"libEGL.so",
|
||||
#else
|
||||
"libEGL.so.1",
|
||||
#endif
|
||||
@ -327,7 +338,7 @@ GLFWbool _glfwInitEGL(void)
|
||||
|
||||
for (i = 0; sonames[i]; i++)
|
||||
{
|
||||
_glfw.egl.handle = _glfw_dlopen(sonames[i]);
|
||||
_glfw.egl.handle = _glfwPlatformLoadModule(sonames[i]);
|
||||
if (_glfw.egl.handle)
|
||||
break;
|
||||
}
|
||||
@ -341,41 +352,41 @@ GLFWbool _glfwInitEGL(void)
|
||||
_glfw.egl.prefix = (strncmp(sonames[i], "lib", 3) == 0);
|
||||
|
||||
_glfw.egl.GetConfigAttrib = (PFN_eglGetConfigAttrib)
|
||||
_glfw_dlsym(_glfw.egl.handle, "eglGetConfigAttrib");
|
||||
_glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglGetConfigAttrib");
|
||||
_glfw.egl.GetConfigs = (PFN_eglGetConfigs)
|
||||
_glfw_dlsym(_glfw.egl.handle, "eglGetConfigs");
|
||||
_glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglGetConfigs");
|
||||
_glfw.egl.GetDisplay = (PFN_eglGetDisplay)
|
||||
_glfw_dlsym(_glfw.egl.handle, "eglGetDisplay");
|
||||
_glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglGetDisplay");
|
||||
_glfw.egl.GetError = (PFN_eglGetError)
|
||||
_glfw_dlsym(_glfw.egl.handle, "eglGetError");
|
||||
_glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglGetError");
|
||||
_glfw.egl.Initialize = (PFN_eglInitialize)
|
||||
_glfw_dlsym(_glfw.egl.handle, "eglInitialize");
|
||||
_glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglInitialize");
|
||||
_glfw.egl.Terminate = (PFN_eglTerminate)
|
||||
_glfw_dlsym(_glfw.egl.handle, "eglTerminate");
|
||||
_glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglTerminate");
|
||||
_glfw.egl.BindAPI = (PFN_eglBindAPI)
|
||||
_glfw_dlsym(_glfw.egl.handle, "eglBindAPI");
|
||||
_glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglBindAPI");
|
||||
_glfw.egl.CreateContext = (PFN_eglCreateContext)
|
||||
_glfw_dlsym(_glfw.egl.handle, "eglCreateContext");
|
||||
_glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglCreateContext");
|
||||
_glfw.egl.DestroySurface = (PFN_eglDestroySurface)
|
||||
_glfw_dlsym(_glfw.egl.handle, "eglDestroySurface");
|
||||
_glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglDestroySurface");
|
||||
_glfw.egl.DestroyContext = (PFN_eglDestroyContext)
|
||||
_glfw_dlsym(_glfw.egl.handle, "eglDestroyContext");
|
||||
_glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglDestroyContext");
|
||||
_glfw.egl.CreateWindowSurface = (PFN_eglCreateWindowSurface)
|
||||
_glfw_dlsym(_glfw.egl.handle, "eglCreateWindowSurface");
|
||||
_glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglCreateWindowSurface");
|
||||
_glfw.egl.MakeCurrent = (PFN_eglMakeCurrent)
|
||||
_glfw_dlsym(_glfw.egl.handle, "eglMakeCurrent");
|
||||
_glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglMakeCurrent");
|
||||
_glfw.egl.SwapBuffers = (PFN_eglSwapBuffers)
|
||||
_glfw_dlsym(_glfw.egl.handle, "eglSwapBuffers");
|
||||
_glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglSwapBuffers");
|
||||
_glfw.egl.SwapInterval = (PFN_eglSwapInterval)
|
||||
_glfw_dlsym(_glfw.egl.handle, "eglSwapInterval");
|
||||
_glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglSwapInterval");
|
||||
_glfw.egl.QueryString = (PFN_eglQueryString)
|
||||
_glfw_dlsym(_glfw.egl.handle, "eglQueryString");
|
||||
_glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglQueryString");
|
||||
_glfw.egl.GetProcAddress = (PFN_eglGetProcAddress)
|
||||
_glfw_dlsym(_glfw.egl.handle, "eglGetProcAddress");
|
||||
_glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglGetProcAddress");
|
||||
_glfw.egl.CreatePbufferSurface = (PFN_eglCreatePbufferSurface)
|
||||
_glfw_dlsym(_glfw.egl.handle, "eglCreatePbufferSurface");
|
||||
_glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglCreatePbufferSurface");
|
||||
_glfw.egl.ChooseConfig = (PFN_eglChooseConfig)
|
||||
_glfw_dlsym(_glfw.egl.handle, "eglChooseConfig");
|
||||
_glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglChooseConfig");
|
||||
|
||||
if (!_glfw.egl.GetConfigAttrib ||
|
||||
!_glfw.egl.GetConfigs ||
|
||||
@ -435,16 +446,16 @@ GLFWbool _glfwInitEGL(void)
|
||||
eglGetProcAddress("eglCreatePlatformWindowSurfaceEXT");
|
||||
}
|
||||
|
||||
_glfw.egl.platform = _glfwPlatformGetEGLPlatform(&attribs);
|
||||
_glfw.egl.platform = _glfw.platform.getEGLPlatform(&attribs);
|
||||
if (_glfw.egl.platform)
|
||||
{
|
||||
_glfw.egl.display =
|
||||
eglGetPlatformDisplayEXT(_glfw.egl.platform,
|
||||
_glfwPlatformGetEGLNativeDisplay(),
|
||||
_glfw.platform.getEGLNativeDisplay(),
|
||||
attribs);
|
||||
}
|
||||
else
|
||||
_glfw.egl.display = eglGetDisplay(_glfwPlatformGetEGLNativeDisplay());
|
||||
_glfw.egl.display = eglGetDisplay(_glfw.platform.getEGLNativeDisplay());
|
||||
|
||||
_glfw_free(attribs);
|
||||
|
||||
@ -478,6 +489,8 @@ GLFWbool _glfwInitEGL(void)
|
||||
extensionSupportedEGL("EGL_KHR_get_all_proc_addresses");
|
||||
_glfw.egl.KHR_context_flush_control =
|
||||
extensionSupportedEGL("EGL_KHR_context_flush_control");
|
||||
_glfw.egl.EXT_present_opaque =
|
||||
extensionSupportedEGL("EGL_EXT_present_opaque");
|
||||
|
||||
return GLFW_TRUE;
|
||||
}
|
||||
@ -494,12 +507,12 @@ void _glfwTerminateEGL(void)
|
||||
|
||||
if (_glfw.egl.handle)
|
||||
{
|
||||
_glfw_dlclose(_glfw.egl.handle);
|
||||
_glfwPlatformFreeModule(_glfw.egl.handle);
|
||||
_glfw.egl.handle = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
#define setAttrib(a, v) \
|
||||
#define SET_ATTRIB(a, v) \
|
||||
{ \
|
||||
assert(((size_t) index + 1) < sizeof(attribs) / sizeof(attribs[0])); \
|
||||
attribs[index++] = a; \
|
||||
@ -568,13 +581,13 @@ GLFWbool _glfwCreateContextForConfigEGL(EGLConfig eglConfig,
|
||||
{
|
||||
if (ctxconfig->robustness == GLFW_NO_RESET_NOTIFICATION)
|
||||
{
|
||||
setAttrib(EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR,
|
||||
EGL_NO_RESET_NOTIFICATION_KHR);
|
||||
SET_ATTRIB(EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR,
|
||||
EGL_NO_RESET_NOTIFICATION_KHR);
|
||||
}
|
||||
else if (ctxconfig->robustness == GLFW_LOSE_CONTEXT_ON_RESET)
|
||||
{
|
||||
setAttrib(EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR,
|
||||
EGL_LOSE_CONTEXT_ON_RESET_KHR);
|
||||
SET_ATTRIB(EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR,
|
||||
EGL_LOSE_CONTEXT_ON_RESET_KHR);
|
||||
}
|
||||
|
||||
flags |= EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR;
|
||||
@ -583,42 +596,42 @@ GLFWbool _glfwCreateContextForConfigEGL(EGLConfig eglConfig,
|
||||
if (ctxconfig->noerror)
|
||||
{
|
||||
if (_glfw.egl.KHR_create_context_no_error)
|
||||
setAttrib(EGL_CONTEXT_OPENGL_NO_ERROR_KHR, GLFW_TRUE);
|
||||
SET_ATTRIB(EGL_CONTEXT_OPENGL_NO_ERROR_KHR, GLFW_TRUE);
|
||||
}
|
||||
|
||||
if (ctxconfig->major != 1 || ctxconfig->minor != 0)
|
||||
{
|
||||
setAttrib(EGL_CONTEXT_MAJOR_VERSION_KHR, ctxconfig->major);
|
||||
setAttrib(EGL_CONTEXT_MINOR_VERSION_KHR, ctxconfig->minor);
|
||||
SET_ATTRIB(EGL_CONTEXT_MAJOR_VERSION_KHR, ctxconfig->major);
|
||||
SET_ATTRIB(EGL_CONTEXT_MINOR_VERSION_KHR, ctxconfig->minor);
|
||||
}
|
||||
|
||||
if (mask)
|
||||
setAttrib(EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR, mask);
|
||||
SET_ATTRIB(EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR, mask);
|
||||
|
||||
if (flags)
|
||||
setAttrib(EGL_CONTEXT_FLAGS_KHR, flags);
|
||||
SET_ATTRIB(EGL_CONTEXT_FLAGS_KHR, flags);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ctxconfig->client == GLFW_OPENGL_ES_API)
|
||||
setAttrib(EGL_CONTEXT_CLIENT_VERSION, ctxconfig->major);
|
||||
SET_ATTRIB(EGL_CONTEXT_CLIENT_VERSION, ctxconfig->major);
|
||||
}
|
||||
|
||||
if (_glfw.egl.KHR_context_flush_control)
|
||||
{
|
||||
if (ctxconfig->release == GLFW_RELEASE_BEHAVIOR_NONE)
|
||||
{
|
||||
setAttrib(EGL_CONTEXT_RELEASE_BEHAVIOR_KHR,
|
||||
EGL_CONTEXT_RELEASE_BEHAVIOR_NONE_KHR);
|
||||
SET_ATTRIB(EGL_CONTEXT_RELEASE_BEHAVIOR_KHR,
|
||||
EGL_CONTEXT_RELEASE_BEHAVIOR_NONE_KHR);
|
||||
}
|
||||
else if (ctxconfig->release == GLFW_RELEASE_BEHAVIOR_FLUSH)
|
||||
{
|
||||
setAttrib(EGL_CONTEXT_RELEASE_BEHAVIOR_KHR,
|
||||
EGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_KHR);
|
||||
SET_ATTRIB(EGL_CONTEXT_RELEASE_BEHAVIOR_KHR,
|
||||
EGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_KHR);
|
||||
}
|
||||
}
|
||||
|
||||
setAttrib(EGL_NONE, EGL_NONE);
|
||||
SET_ATTRIB(EGL_NONE, EGL_NONE);
|
||||
|
||||
*context = eglCreateContext(_glfw.egl.display, eglConfig, share, attribs);
|
||||
|
||||
@ -659,15 +672,18 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window,
|
||||
if (fbconfig->sRGB)
|
||||
{
|
||||
if (_glfw.egl.KHR_gl_colorspace)
|
||||
setAttrib(EGL_GL_COLORSPACE_KHR, EGL_GL_COLORSPACE_SRGB_KHR);
|
||||
SET_ATTRIB(EGL_GL_COLORSPACE_KHR, EGL_GL_COLORSPACE_SRGB_KHR);
|
||||
}
|
||||
|
||||
if (!fbconfig->doublebuffer)
|
||||
setAttrib(EGL_RENDER_BUFFER, EGL_SINGLE_BUFFER);
|
||||
SET_ATTRIB(EGL_RENDER_BUFFER, EGL_SINGLE_BUFFER);
|
||||
|
||||
setAttrib(EGL_NONE, EGL_NONE);
|
||||
if (_glfw.egl.EXT_present_opaque)
|
||||
SET_ATTRIB(EGL_PRESENT_OPAQUE_EXT, !fbconfig->transparent);
|
||||
|
||||
native = _glfwPlatformGetEGLNativeWindow(window);
|
||||
SET_ATTRIB(EGL_NONE, EGL_NONE);
|
||||
|
||||
native = _glfw.platform.getEGLNativeWindow(window);
|
||||
// HACK: ANGLE does not implement eglCreatePlatformWindowSurfaceEXT
|
||||
// despite reporting EGL_EXT_platform_base
|
||||
if (_glfw.egl.platform && _glfw.egl.platform != EGL_PLATFORM_ANGLE_ANGLE)
|
||||
@ -704,6 +720,8 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window,
|
||||
"libGLES_CM.dll",
|
||||
#elif defined(_GLFW_COCOA)
|
||||
"libGLESv1_CM.dylib",
|
||||
#elif defined(__OpenBSD__) || defined(__NetBSD__)
|
||||
"libGLESv1_CM.so",
|
||||
#else
|
||||
"libGLESv1_CM.so.1",
|
||||
"libGLES_CM.so.1",
|
||||
@ -721,6 +739,8 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window,
|
||||
"libGLESv2.dylib",
|
||||
#elif defined(__CYGWIN__)
|
||||
"libGLESv2-2.so",
|
||||
#elif defined(__OpenBSD__) || defined(__NetBSD__)
|
||||
"libGLESv2.so",
|
||||
#else
|
||||
"libGLESv2.so.2",
|
||||
#endif
|
||||
@ -732,6 +752,8 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window,
|
||||
_GLFW_OPENGL_LIBRARY,
|
||||
#elif defined(_GLFW_WIN32)
|
||||
#elif defined(_GLFW_COCOA)
|
||||
#elif defined(__OpenBSD__) || defined(__NetBSD__)
|
||||
"libGL.so",
|
||||
#else
|
||||
"libGL.so.1",
|
||||
#endif
|
||||
@ -755,7 +777,7 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window,
|
||||
if (_glfw.egl.prefix != (strncmp(sonames[i], "lib", 3) == 0))
|
||||
continue;
|
||||
|
||||
window->context.egl.client = _glfw_dlopen(sonames[i]);
|
||||
window->context.egl.client = _glfwPlatformLoadModule(sonames[i]);
|
||||
if (window->context.egl.client)
|
||||
break;
|
||||
}
|
||||
@ -778,7 +800,7 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window,
|
||||
return GLFW_TRUE;
|
||||
}
|
||||
|
||||
#undef setAttrib
|
||||
#undef SET_ATTRIB
|
||||
|
||||
// Returns the Visual and depth of the chosen EGLConfig
|
||||
//
|
||||
@ -926,7 +948,7 @@ GLFWAPI EGLContext glfwGetEGLContext(GLFWwindow* handle)
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(EGL_NO_CONTEXT);
|
||||
|
||||
if (window->context.client == GLFW_NO_API)
|
||||
if (window->context.source != GLFW_EGL_CONTEXT_API)
|
||||
{
|
||||
_glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL);
|
||||
return EGL_NO_CONTEXT;
|
||||
@ -940,7 +962,7 @@ GLFWAPI EGLSurface glfwGetEGLSurface(GLFWwindow* handle)
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(EGL_NO_SURFACE);
|
||||
|
||||
if (window->context.client == GLFW_NO_API)
|
||||
if (window->context.source != GLFW_EGL_CONTEXT_API)
|
||||
{
|
||||
_glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL);
|
||||
return EGL_NO_SURFACE;
|
||||
|
@ -1,250 +0,0 @@
|
||||
//========================================================================
|
||||
// GLFW 3.4 EGL - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2002-2006 Marcus Geelnard
|
||||
// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>
|
||||
//
|
||||
// This software is provided 'as-is', without any express or implied
|
||||
// warranty. In no event will the authors be held liable for any damages
|
||||
// arising from the use of this software.
|
||||
//
|
||||
// Permission is granted to anyone to use this software for any purpose,
|
||||
// including commercial applications, and to alter it and redistribute it
|
||||
// freely, subject to the following restrictions:
|
||||
//
|
||||
// 1. The origin of this software must not be misrepresented; you must not
|
||||
// claim that you wrote the original software. If you use this software
|
||||
// in a product, an acknowledgment in the product documentation would
|
||||
// be appreciated but is not required.
|
||||
//
|
||||
// 2. Altered source versions must be plainly marked as such, and must not
|
||||
// be misrepresented as being the original software.
|
||||
//
|
||||
// 3. This notice may not be removed or altered from any source
|
||||
// distribution.
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#if defined(_GLFW_WIN32)
|
||||
#define EGLAPIENTRY __stdcall
|
||||
#else
|
||||
#define EGLAPIENTRY
|
||||
#endif
|
||||
|
||||
#define EGL_SUCCESS 0x3000
|
||||
#define EGL_NOT_INITIALIZED 0x3001
|
||||
#define EGL_BAD_ACCESS 0x3002
|
||||
#define EGL_BAD_ALLOC 0x3003
|
||||
#define EGL_BAD_ATTRIBUTE 0x3004
|
||||
#define EGL_BAD_CONFIG 0x3005
|
||||
#define EGL_BAD_CONTEXT 0x3006
|
||||
#define EGL_BAD_CURRENT_SURFACE 0x3007
|
||||
#define EGL_BAD_DISPLAY 0x3008
|
||||
#define EGL_BAD_MATCH 0x3009
|
||||
#define EGL_BAD_NATIVE_PIXMAP 0x300a
|
||||
#define EGL_BAD_NATIVE_WINDOW 0x300b
|
||||
#define EGL_BAD_PARAMETER 0x300c
|
||||
#define EGL_BAD_SURFACE 0x300d
|
||||
#define EGL_CONTEXT_LOST 0x300e
|
||||
#define EGL_COLOR_BUFFER_TYPE 0x303f
|
||||
#define EGL_RGB_BUFFER 0x308e
|
||||
#define EGL_SURFACE_TYPE 0x3033
|
||||
#define EGL_WINDOW_BIT 0x0004
|
||||
#define EGL_RENDERABLE_TYPE 0x3040
|
||||
#define EGL_OPENGL_ES_BIT 0x0001
|
||||
#define EGL_OPENGL_ES2_BIT 0x0004
|
||||
#define EGL_OPENGL_BIT 0x0008
|
||||
#define EGL_ALPHA_SIZE 0x3021
|
||||
#define EGL_BLUE_SIZE 0x3022
|
||||
#define EGL_GREEN_SIZE 0x3023
|
||||
#define EGL_RED_SIZE 0x3024
|
||||
#define EGL_DEPTH_SIZE 0x3025
|
||||
#define EGL_STENCIL_SIZE 0x3026
|
||||
#define EGL_SAMPLES 0x3031
|
||||
#define EGL_OPENGL_ES_API 0x30a0
|
||||
#define EGL_OPENGL_API 0x30a2
|
||||
#define EGL_NONE 0x3038
|
||||
#define EGL_RENDER_BUFFER 0x3086
|
||||
#define EGL_SINGLE_BUFFER 0x3085
|
||||
#define EGL_EXTENSIONS 0x3055
|
||||
#define EGL_CONTEXT_CLIENT_VERSION 0x3098
|
||||
#define EGL_NATIVE_VISUAL_ID 0x302e
|
||||
#define EGL_NO_SURFACE ((EGLSurface) 0)
|
||||
#define EGL_NO_DISPLAY ((EGLDisplay) 0)
|
||||
#define EGL_NO_CONTEXT ((EGLContext) 0)
|
||||
#define EGL_DEFAULT_DISPLAY ((EGLNativeDisplayType) 0)
|
||||
#define EGL_PBUFFER_BIT 0x0001
|
||||
#define EGL_HEIGHT 0x3056
|
||||
#define EGL_WIDTH 0x3057
|
||||
|
||||
#define EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR 0x00000002
|
||||
#define EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR 0x00000001
|
||||
#define EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR 0x00000002
|
||||
#define EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR 0x00000001
|
||||
#define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR 0x31bd
|
||||
#define EGL_NO_RESET_NOTIFICATION_KHR 0x31be
|
||||
#define EGL_LOSE_CONTEXT_ON_RESET_KHR 0x31bf
|
||||
#define EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR 0x00000004
|
||||
#define EGL_CONTEXT_MAJOR_VERSION_KHR 0x3098
|
||||
#define EGL_CONTEXT_MINOR_VERSION_KHR 0x30fb
|
||||
#define EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR 0x30fd
|
||||
#define EGL_CONTEXT_FLAGS_KHR 0x30fc
|
||||
#define EGL_CONTEXT_OPENGL_NO_ERROR_KHR 0x31b3
|
||||
#define EGL_GL_COLORSPACE_KHR 0x309d
|
||||
#define EGL_GL_COLORSPACE_SRGB_KHR 0x3089
|
||||
#define EGL_CONTEXT_RELEASE_BEHAVIOR_KHR 0x2097
|
||||
#define EGL_CONTEXT_RELEASE_BEHAVIOR_NONE_KHR 0
|
||||
#define EGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_KHR 0x2098
|
||||
#define EGL_PLATFORM_X11_EXT 0x31d5
|
||||
#define EGL_PLATFORM_WAYLAND_EXT 0x31d8
|
||||
#define EGL_PLATFORM_ANGLE_ANGLE 0x3202
|
||||
#define EGL_PLATFORM_ANGLE_TYPE_ANGLE 0x3203
|
||||
#define EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE 0x320d
|
||||
#define EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE 0x320e
|
||||
#define EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE 0x3207
|
||||
#define EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE 0x3208
|
||||
#define EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE 0x3450
|
||||
#define EGL_PLATFORM_ANGLE_TYPE_METAL_ANGLE 0x3489
|
||||
#define EGL_PLATFORM_ANGLE_NATIVE_PLATFORM_TYPE_ANGLE 0x348f
|
||||
|
||||
typedef int EGLint;
|
||||
typedef unsigned int EGLBoolean;
|
||||
typedef unsigned int EGLenum;
|
||||
typedef void* EGLConfig;
|
||||
typedef void* EGLContext;
|
||||
typedef void* EGLDisplay;
|
||||
typedef void* EGLSurface;
|
||||
|
||||
typedef void* EGLNativeDisplayType;
|
||||
typedef void* EGLNativeWindowType;
|
||||
|
||||
// EGL function pointer typedefs
|
||||
typedef EGLBoolean (EGLAPIENTRY * PFN_eglGetConfigAttrib)(EGLDisplay,EGLConfig,EGLint,EGLint*);
|
||||
typedef EGLBoolean (EGLAPIENTRY * PFN_eglGetConfigs)(EGLDisplay,EGLConfig*,EGLint,EGLint*);
|
||||
typedef EGLDisplay (EGLAPIENTRY * PFN_eglGetDisplay)(EGLNativeDisplayType);
|
||||
typedef EGLint (EGLAPIENTRY * PFN_eglGetError)(void);
|
||||
typedef EGLBoolean (EGLAPIENTRY * PFN_eglInitialize)(EGLDisplay,EGLint*,EGLint*);
|
||||
typedef EGLBoolean (EGLAPIENTRY * PFN_eglTerminate)(EGLDisplay);
|
||||
typedef EGLBoolean (EGLAPIENTRY * PFN_eglBindAPI)(EGLenum);
|
||||
typedef EGLContext (EGLAPIENTRY * PFN_eglCreateContext)(EGLDisplay,EGLConfig,EGLContext,const EGLint*);
|
||||
typedef EGLBoolean (EGLAPIENTRY * PFN_eglDestroySurface)(EGLDisplay,EGLSurface);
|
||||
typedef EGLBoolean (EGLAPIENTRY * PFN_eglDestroyContext)(EGLDisplay,EGLContext);
|
||||
typedef EGLSurface (EGLAPIENTRY * PFN_eglCreateWindowSurface)(EGLDisplay,EGLConfig,EGLNativeWindowType,const EGLint*);
|
||||
typedef EGLBoolean (EGLAPIENTRY * PFN_eglMakeCurrent)(EGLDisplay,EGLSurface,EGLSurface,EGLContext);
|
||||
typedef EGLBoolean (EGLAPIENTRY * PFN_eglSwapBuffers)(EGLDisplay,EGLSurface);
|
||||
typedef EGLBoolean (EGLAPIENTRY * PFN_eglSwapInterval)(EGLDisplay,EGLint);
|
||||
typedef const char* (EGLAPIENTRY * PFN_eglQueryString)(EGLDisplay,EGLint);
|
||||
typedef GLFWglproc (EGLAPIENTRY * PFN_eglGetProcAddress)(const char*);
|
||||
typedef EGLSurface (EGLAPIENTRY * PFN_eglCreatePbufferSurface)(EGLDisplay,EGLConfig,const EGLint*);
|
||||
typedef EGLBoolean (EGLAPIENTRY * PFN_eglChooseConfig)(EGLDisplay,EGLint const*,EGLConfig*,EGLint,EGLint*);
|
||||
#define eglGetConfigAttrib _glfw.egl.GetConfigAttrib
|
||||
#define eglGetConfigs _glfw.egl.GetConfigs
|
||||
#define eglGetDisplay _glfw.egl.GetDisplay
|
||||
#define eglGetError _glfw.egl.GetError
|
||||
#define eglInitialize _glfw.egl.Initialize
|
||||
#define eglTerminate _glfw.egl.Terminate
|
||||
#define eglBindAPI _glfw.egl.BindAPI
|
||||
#define eglCreateContext _glfw.egl.CreateContext
|
||||
#define eglDestroySurface _glfw.egl.DestroySurface
|
||||
#define eglDestroyContext _glfw.egl.DestroyContext
|
||||
#define eglCreateWindowSurface _glfw.egl.CreateWindowSurface
|
||||
#define eglMakeCurrent _glfw.egl.MakeCurrent
|
||||
#define eglSwapBuffers _glfw.egl.SwapBuffers
|
||||
#define eglSwapInterval _glfw.egl.SwapInterval
|
||||
#define eglQueryString _glfw.egl.QueryString
|
||||
#define eglGetProcAddress _glfw.egl.GetProcAddress
|
||||
#define eglCreatePbufferSurface _glfw.egl.CreatePbufferSurface
|
||||
#define eglChooseConfig _glfw.egl.ChooseConfig
|
||||
|
||||
typedef EGLDisplay (EGLAPIENTRY * PFNEGLGETPLATFORMDISPLAYEXTPROC)(EGLenum,void*,const EGLint*);
|
||||
typedef EGLSurface (EGLAPIENTRY * PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC)(EGLDisplay,EGLConfig,void*,const EGLint*);
|
||||
#define eglGetPlatformDisplayEXT _glfw.egl.GetPlatformDisplayEXT
|
||||
#define eglCreatePlatformWindowSurfaceEXT _glfw.egl.CreatePlatformWindowSurfaceEXT
|
||||
|
||||
// EGL-specific per-context data
|
||||
//
|
||||
typedef struct _GLFWcontextEGL
|
||||
{
|
||||
EGLConfig config;
|
||||
EGLContext handle;
|
||||
EGLSurface surface;
|
||||
|
||||
void* client;
|
||||
|
||||
} _GLFWcontextEGL;
|
||||
|
||||
// EGL-specific per user context data
|
||||
//
|
||||
typedef struct _GLFWusercontextEGL
|
||||
{
|
||||
EGLContext handle;
|
||||
EGLSurface surface;
|
||||
|
||||
} _GLFWusercontextEGL;
|
||||
|
||||
|
||||
// EGL-specific global data
|
||||
//
|
||||
typedef struct _GLFWlibraryEGL
|
||||
{
|
||||
EGLenum platform;
|
||||
EGLDisplay display;
|
||||
EGLint major, minor;
|
||||
GLFWbool prefix;
|
||||
|
||||
GLFWbool KHR_create_context;
|
||||
GLFWbool KHR_create_context_no_error;
|
||||
GLFWbool KHR_gl_colorspace;
|
||||
GLFWbool KHR_get_all_proc_addresses;
|
||||
GLFWbool KHR_context_flush_control;
|
||||
GLFWbool EXT_client_extensions;
|
||||
GLFWbool EXT_platform_base;
|
||||
GLFWbool EXT_platform_x11;
|
||||
GLFWbool EXT_platform_wayland;
|
||||
GLFWbool ANGLE_platform_angle;
|
||||
GLFWbool ANGLE_platform_angle_opengl;
|
||||
GLFWbool ANGLE_platform_angle_d3d;
|
||||
GLFWbool ANGLE_platform_angle_vulkan;
|
||||
GLFWbool ANGLE_platform_angle_metal;
|
||||
|
||||
void* handle;
|
||||
|
||||
PFN_eglGetConfigAttrib GetConfigAttrib;
|
||||
PFN_eglGetConfigs GetConfigs;
|
||||
PFN_eglGetDisplay GetDisplay;
|
||||
PFN_eglGetError GetError;
|
||||
PFN_eglInitialize Initialize;
|
||||
PFN_eglTerminate Terminate;
|
||||
PFN_eglBindAPI BindAPI;
|
||||
PFN_eglCreateContext CreateContext;
|
||||
PFN_eglDestroySurface DestroySurface;
|
||||
PFN_eglDestroyContext DestroyContext;
|
||||
PFN_eglCreateWindowSurface CreateWindowSurface;
|
||||
PFN_eglMakeCurrent MakeCurrent;
|
||||
PFN_eglSwapBuffers SwapBuffers;
|
||||
PFN_eglSwapInterval SwapInterval;
|
||||
PFN_eglQueryString QueryString;
|
||||
PFN_eglGetProcAddress GetProcAddress;
|
||||
PFN_eglCreatePbufferSurface CreatePbufferSurface;
|
||||
PFN_eglChooseConfig ChooseConfig;
|
||||
|
||||
PFNEGLGETPLATFORMDISPLAYEXTPROC GetPlatformDisplayEXT;
|
||||
PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC CreatePlatformWindowSurfaceEXT;
|
||||
|
||||
} _GLFWlibraryEGL;
|
||||
|
||||
|
||||
GLFWbool _glfwInitEGL(void);
|
||||
void _glfwTerminateEGL(void);
|
||||
GLFWbool _glfwCreateContextEGL(_GLFWwindow* window,
|
||||
const _GLFWctxconfig* ctxconfig,
|
||||
const _GLFWfbconfig* fbconfig);
|
||||
_GLFWusercontext* _glfwCreateUserContextEGL(_GLFWwindow* window);
|
||||
|
||||
#if defined(_GLFW_X11)
|
||||
GLFWbool _glfwChooseVisualEGL(const _GLFWwndconfig* wndconfig,
|
||||
const _GLFWctxconfig* ctxconfig,
|
||||
const _GLFWfbconfig* fbconfig,
|
||||
Visual** visual, int* depth);
|
||||
#endif /*_GLFW_X11*/
|
||||
|
@ -1,58 +0,0 @@
|
||||
//========================================================================
|
||||
// GLFW 3.4 - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2010-2016 Camilla Löwy <elmindreda@glfw.org>
|
||||
//
|
||||
// This software is provided 'as-is', without any express or implied
|
||||
// warranty. In no event will the authors be held liable for any damages
|
||||
// arising from the use of this software.
|
||||
//
|
||||
// Permission is granted to anyone to use this software for any purpose,
|
||||
// including commercial applications, and to alter it and redistribute it
|
||||
// freely, subject to the following restrictions:
|
||||
//
|
||||
// 1. The origin of this software must not be misrepresented; you must not
|
||||
// claim that you wrote the original software. If you use this software
|
||||
// in a product, an acknowledgment in the product documentation would
|
||||
// be appreciated but is not required.
|
||||
//
|
||||
// 2. Altered source versions must be plainly marked as such, and must not
|
||||
// be misrepresented as being the original software.
|
||||
//
|
||||
// 3. This notice may not be removed or altered from any source
|
||||
// distribution.
|
||||
//
|
||||
//========================================================================
|
||||
// As glfw_config.h.in, this file is used by CMake to produce the
|
||||
// glfw_config.h configuration header file. If you are adding a feature
|
||||
// requiring conditional compilation, this is where to add the macro.
|
||||
//========================================================================
|
||||
// As glfw_config.h, this file defines compile-time option macros for a
|
||||
// specific platform and development environment. If you are using the
|
||||
// GLFW CMake files, modify glfw_config.h.in instead of this file. If you
|
||||
// are using your own build system, make this file define the appropriate
|
||||
// macros in whatever way is suitable.
|
||||
//========================================================================
|
||||
|
||||
// Define this to 1 if building GLFW for X11
|
||||
#cmakedefine _GLFW_X11
|
||||
// Define this to 1 if building GLFW for Win32
|
||||
#cmakedefine _GLFW_WIN32
|
||||
// Define this to 1 if building GLFW for Cocoa
|
||||
#cmakedefine _GLFW_COCOA
|
||||
// Define this to 1 if building GLFW for Wayland
|
||||
#cmakedefine _GLFW_WAYLAND
|
||||
// Define this to 1 if building GLFW for OSMesa
|
||||
#cmakedefine _GLFW_OSMESA
|
||||
|
||||
// Define this to 1 to use Vulkan loader linked statically into application
|
||||
#cmakedefine _GLFW_VULKAN_STATIC
|
||||
|
||||
// Define this to 1 to force use of high-performance GPU on hybrid systems
|
||||
#cmakedefine _GLFW_USE_HYBRID_HPG
|
||||
|
||||
// Define this to 1 if xkbcommon supports the compose key
|
||||
#cmakedefine HAVE_XKBCOMMON_COMPOSE_H
|
||||
// Define this to 1 if the libc supports memfd_create()
|
||||
#cmakedefine HAVE_MEMFD_CREATE
|
||||
|
@ -55,7 +55,7 @@ static GLFWbool chooseGLXFBConfig(const _GLFWfbconfig* desired,
|
||||
GLXFBConfig* nativeConfigs;
|
||||
_GLFWfbconfig* usableConfigs;
|
||||
const _GLFWfbconfig* closest;
|
||||
int i, nativeCount, usableCount;
|
||||
int nativeCount, usableCount;
|
||||
const char* vendor;
|
||||
GLFWbool trustWindowBit = GLFW_TRUE;
|
||||
|
||||
@ -76,7 +76,7 @@ static GLFWbool chooseGLXFBConfig(const _GLFWfbconfig* desired,
|
||||
usableConfigs = _glfw_calloc(nativeCount, sizeof(_GLFWfbconfig));
|
||||
usableCount = 0;
|
||||
|
||||
for (i = 0; i < nativeCount; i++)
|
||||
for (int i = 0; i < nativeCount; i++)
|
||||
{
|
||||
const GLXFBConfig n = nativeConfigs[i];
|
||||
_GLFWfbconfig* u = usableConfigs + usableCount;
|
||||
@ -226,7 +226,7 @@ static GLFWglproc getProcAddressGLX(const char* procname)
|
||||
else if (_glfw.glx.GetProcAddressARB)
|
||||
return _glfw.glx.GetProcAddressARB((const GLubyte*) procname);
|
||||
else
|
||||
return _glfw_dlsym(_glfw.glx.handle, procname);
|
||||
return _glfwPlatformGetModuleSymbol(_glfw.glx.handle, procname);
|
||||
}
|
||||
|
||||
static void destroyContextGLX(_GLFWwindow* window)
|
||||
@ -253,13 +253,14 @@ static void destroyContextGLX(_GLFWwindow* window)
|
||||
//
|
||||
GLFWbool _glfwInitGLX(void)
|
||||
{
|
||||
int i;
|
||||
const char* sonames[] =
|
||||
{
|
||||
#if defined(_GLFW_GLX_LIBRARY)
|
||||
_GLFW_GLX_LIBRARY,
|
||||
#elif defined(__CYGWIN__)
|
||||
"libGL-1.so",
|
||||
#elif defined(__OpenBSD__) || defined(__NetBSD__)
|
||||
"libGL.so",
|
||||
#else
|
||||
"libGL.so.1",
|
||||
"libGL.so",
|
||||
@ -270,9 +271,9 @@ GLFWbool _glfwInitGLX(void)
|
||||
if (_glfw.glx.handle)
|
||||
return GLFW_TRUE;
|
||||
|
||||
for (i = 0; sonames[i]; i++)
|
||||
for (int i = 0; sonames[i]; i++)
|
||||
{
|
||||
_glfw.glx.handle = _glfw_dlopen(sonames[i]);
|
||||
_glfw.glx.handle = _glfwPlatformLoadModule(sonames[i]);
|
||||
if (_glfw.glx.handle)
|
||||
break;
|
||||
}
|
||||
@ -283,36 +284,32 @@ GLFWbool _glfwInitGLX(void)
|
||||
return GLFW_FALSE;
|
||||
}
|
||||
|
||||
_glfw.glx.GetFBConfigs =
|
||||
_glfw_dlsym(_glfw.glx.handle, "glXGetFBConfigs");
|
||||
_glfw.glx.GetFBConfigAttrib =
|
||||
_glfw_dlsym(_glfw.glx.handle, "glXGetFBConfigAttrib");
|
||||
_glfw.glx.GetClientString =
|
||||
_glfw_dlsym(_glfw.glx.handle, "glXGetClientString");
|
||||
_glfw.glx.QueryExtension =
|
||||
_glfw_dlsym(_glfw.glx.handle, "glXQueryExtension");
|
||||
_glfw.glx.QueryVersion =
|
||||
_glfw_dlsym(_glfw.glx.handle, "glXQueryVersion");
|
||||
_glfw.glx.DestroyContext =
|
||||
_glfw_dlsym(_glfw.glx.handle, "glXDestroyContext");
|
||||
_glfw.glx.MakeCurrent =
|
||||
_glfw_dlsym(_glfw.glx.handle, "glXMakeCurrent");
|
||||
_glfw.glx.SwapBuffers =
|
||||
_glfw_dlsym(_glfw.glx.handle, "glXSwapBuffers");
|
||||
_glfw.glx.QueryExtensionsString =
|
||||
_glfw_dlsym(_glfw.glx.handle, "glXQueryExtensionsString");
|
||||
_glfw.glx.CreateNewContext =
|
||||
_glfw_dlsym(_glfw.glx.handle, "glXCreateNewContext");
|
||||
_glfw.glx.CreateWindow =
|
||||
_glfw_dlsym(_glfw.glx.handle, "glXCreateWindow");
|
||||
_glfw.glx.DestroyWindow =
|
||||
_glfw_dlsym(_glfw.glx.handle, "glXDestroyWindow");
|
||||
_glfw.glx.GetProcAddress =
|
||||
_glfw_dlsym(_glfw.glx.handle, "glXGetProcAddress");
|
||||
_glfw.glx.GetProcAddressARB =
|
||||
_glfw_dlsym(_glfw.glx.handle, "glXGetProcAddressARB");
|
||||
_glfw.glx.GetVisualFromFBConfig =
|
||||
_glfw_dlsym(_glfw.glx.handle, "glXGetVisualFromFBConfig");
|
||||
_glfw.glx.GetFBConfigs = (PFNGLXGETFBCONFIGSPROC)
|
||||
_glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXGetFBConfigs");
|
||||
_glfw.glx.GetFBConfigAttrib = (PFNGLXGETFBCONFIGATTRIBPROC)
|
||||
_glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXGetFBConfigAttrib");
|
||||
_glfw.glx.GetClientString = (PFNGLXGETCLIENTSTRINGPROC)
|
||||
_glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXGetClientString");
|
||||
_glfw.glx.QueryExtension = (PFNGLXQUERYEXTENSIONPROC)
|
||||
_glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXQueryExtension");
|
||||
_glfw.glx.QueryVersion = (PFNGLXQUERYVERSIONPROC)
|
||||
_glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXQueryVersion");
|
||||
_glfw.glx.DestroyContext = (PFNGLXDESTROYCONTEXTPROC)
|
||||
_glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXDestroyContext");
|
||||
_glfw.glx.MakeCurrent = (PFNGLXMAKECURRENTPROC)
|
||||
_glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXMakeCurrent");
|
||||
_glfw.glx.SwapBuffers = (PFNGLXSWAPBUFFERSPROC)
|
||||
_glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXSwapBuffers");
|
||||
_glfw.glx.QueryExtensionsString = (PFNGLXQUERYEXTENSIONSSTRINGPROC)
|
||||
_glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXQueryExtensionsString");
|
||||
_glfw.glx.CreateNewContext = (PFNGLXCREATENEWCONTEXTPROC)
|
||||
_glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXCreateNewContext");
|
||||
_glfw.glx.CreateWindow = (PFNGLXCREATEWINDOWPROC)
|
||||
_glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXCreateWindow");
|
||||
_glfw.glx.DestroyWindow = (PFNGLXDESTROYWINDOWPROC)
|
||||
_glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXDestroyWindow");
|
||||
_glfw.glx.GetVisualFromFBConfig = (PFNGLXGETVISUALFROMFBCONFIGPROC)
|
||||
_glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXGetVisualFromFBConfig");
|
||||
|
||||
if (!_glfw.glx.GetFBConfigs ||
|
||||
!_glfw.glx.GetFBConfigAttrib ||
|
||||
@ -326,8 +323,6 @@ GLFWbool _glfwInitGLX(void)
|
||||
!_glfw.glx.CreateNewContext ||
|
||||
!_glfw.glx.CreateWindow ||
|
||||
!_glfw.glx.DestroyWindow ||
|
||||
!_glfw.glx.GetProcAddress ||
|
||||
!_glfw.glx.GetProcAddressARB ||
|
||||
!_glfw.glx.GetVisualFromFBConfig)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
@ -335,6 +330,12 @@ GLFWbool _glfwInitGLX(void)
|
||||
return GLFW_FALSE;
|
||||
}
|
||||
|
||||
// NOTE: Unlike GLX 1.3 entry points these are not required to be present
|
||||
_glfw.glx.GetProcAddress = (PFNGLXGETPROCADDRESSPROC)
|
||||
_glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXGetProcAddress");
|
||||
_glfw.glx.GetProcAddressARB = (PFNGLXGETPROCADDRESSPROC)
|
||||
_glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXGetProcAddressARB");
|
||||
|
||||
if (!glXQueryExtension(_glfw.x11.display,
|
||||
&_glfw.glx.errorBase,
|
||||
&_glfw.glx.eventBase))
|
||||
@ -425,16 +426,16 @@ GLFWbool _glfwInitGLX(void)
|
||||
void _glfwTerminateGLX(void)
|
||||
{
|
||||
// NOTE: This function must not call any X11 functions, as it is called
|
||||
// after XCloseDisplay (see _glfwPlatformTerminate for details)
|
||||
// after XCloseDisplay (see _glfwTerminateX11 for details)
|
||||
|
||||
if (_glfw.glx.handle)
|
||||
{
|
||||
_glfw_dlclose(_glfw.glx.handle);
|
||||
_glfwPlatformFreeModule(_glfw.glx.handle);
|
||||
_glfw.glx.handle = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
#define setAttrib(a, v) \
|
||||
#define SET_ATTRIB(a, v) \
|
||||
{ \
|
||||
assert(((size_t) index + 1) < sizeof(attribs) / sizeof(attribs[0])); \
|
||||
attribs[index++] = a; \
|
||||
@ -515,13 +516,13 @@ GLFWbool _glfwCreateContextForFBGLX(_GLFWwindow* window,
|
||||
{
|
||||
if (ctxconfig->robustness == GLFW_NO_RESET_NOTIFICATION)
|
||||
{
|
||||
setAttrib(GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB,
|
||||
GLX_NO_RESET_NOTIFICATION_ARB);
|
||||
SET_ATTRIB(GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB,
|
||||
GLX_NO_RESET_NOTIFICATION_ARB);
|
||||
}
|
||||
else if (ctxconfig->robustness == GLFW_LOSE_CONTEXT_ON_RESET)
|
||||
{
|
||||
setAttrib(GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB,
|
||||
GLX_LOSE_CONTEXT_ON_RESET_ARB);
|
||||
SET_ATTRIB(GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB,
|
||||
GLX_LOSE_CONTEXT_ON_RESET_ARB);
|
||||
}
|
||||
|
||||
flags |= GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB;
|
||||
@ -534,13 +535,13 @@ GLFWbool _glfwCreateContextForFBGLX(_GLFWwindow* window,
|
||||
{
|
||||
if (ctxconfig->release == GLFW_RELEASE_BEHAVIOR_NONE)
|
||||
{
|
||||
setAttrib(GLX_CONTEXT_RELEASE_BEHAVIOR_ARB,
|
||||
GLX_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB);
|
||||
SET_ATTRIB(GLX_CONTEXT_RELEASE_BEHAVIOR_ARB,
|
||||
GLX_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB);
|
||||
}
|
||||
else if (ctxconfig->release == GLFW_RELEASE_BEHAVIOR_FLUSH)
|
||||
{
|
||||
setAttrib(GLX_CONTEXT_RELEASE_BEHAVIOR_ARB,
|
||||
GLX_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB);
|
||||
SET_ATTRIB(GLX_CONTEXT_RELEASE_BEHAVIOR_ARB,
|
||||
GLX_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -548,7 +549,7 @@ GLFWbool _glfwCreateContextForFBGLX(_GLFWwindow* window,
|
||||
if (ctxconfig->noerror)
|
||||
{
|
||||
if (_glfw.glx.ARB_create_context_no_error)
|
||||
setAttrib(GLX_CONTEXT_OPENGL_NO_ERROR_ARB, GLFW_TRUE);
|
||||
SET_ATTRIB(GLX_CONTEXT_OPENGL_NO_ERROR_ARB, GLFW_TRUE);
|
||||
}
|
||||
|
||||
// NOTE: Only request an explicitly versioned context when necessary, as
|
||||
@ -556,17 +557,17 @@ GLFWbool _glfwCreateContextForFBGLX(_GLFWwindow* window,
|
||||
// highest version supported by the driver
|
||||
if (ctxconfig->major != 1 || ctxconfig->minor != 0)
|
||||
{
|
||||
setAttrib(GLX_CONTEXT_MAJOR_VERSION_ARB, ctxconfig->major);
|
||||
setAttrib(GLX_CONTEXT_MINOR_VERSION_ARB, ctxconfig->minor);
|
||||
SET_ATTRIB(GLX_CONTEXT_MAJOR_VERSION_ARB, ctxconfig->major);
|
||||
SET_ATTRIB(GLX_CONTEXT_MINOR_VERSION_ARB, ctxconfig->minor);
|
||||
}
|
||||
|
||||
if (mask)
|
||||
setAttrib(GLX_CONTEXT_PROFILE_MASK_ARB, mask);
|
||||
SET_ATTRIB(GLX_CONTEXT_PROFILE_MASK_ARB, mask);
|
||||
|
||||
if (flags)
|
||||
setAttrib(GLX_CONTEXT_FLAGS_ARB, flags);
|
||||
SET_ATTRIB(GLX_CONTEXT_FLAGS_ARB, flags);
|
||||
|
||||
setAttrib(None, None);
|
||||
SET_ATTRIB(None, None);
|
||||
|
||||
*context =
|
||||
_glfw.glx.CreateContextAttribsARB(_glfw.x11.display,
|
||||
@ -645,7 +646,7 @@ GLFWbool _glfwCreateContextGLX(_GLFWwindow* window,
|
||||
return GLFW_TRUE;
|
||||
}
|
||||
|
||||
#undef setAttrib
|
||||
#undef SET_ATTRIB
|
||||
|
||||
// Returns the Visual and depth of the chosen GLXFBConfig
|
||||
//
|
||||
@ -731,7 +732,13 @@ GLFWAPI GLXContext glfwGetGLXContext(GLFWwindow* handle)
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||
|
||||
if (window->context.client == GLFW_NO_API)
|
||||
if (_glfw.platform.platformID != GLFW_PLATFORM_X11)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_UNAVAILABLE, "GLX: Platform not initialized");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (window->context.source != GLFW_NATIVE_CONTEXT_API)
|
||||
{
|
||||
_glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL);
|
||||
return NULL;
|
||||
@ -745,7 +752,13 @@ GLFWAPI GLXWindow glfwGetGLXWindow(GLFWwindow* handle)
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(None);
|
||||
|
||||
if (window->context.client == GLFW_NO_API)
|
||||
if (_glfw.platform.platformID != GLFW_PLATFORM_X11)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_UNAVAILABLE, "GLX: Platform not initialized");
|
||||
return None;
|
||||
}
|
||||
|
||||
if (window->context.source != GLFW_NATIVE_CONTEXT_API)
|
||||
{
|
||||
_glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL);
|
||||
return None;
|
||||
|
@ -1,192 +0,0 @@
|
||||
//========================================================================
|
||||
// GLFW 3.4 GLX - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2002-2006 Marcus Geelnard
|
||||
// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>
|
||||
//
|
||||
// This software is provided 'as-is', without any express or implied
|
||||
// warranty. In no event will the authors be held liable for any damages
|
||||
// arising from the use of this software.
|
||||
//
|
||||
// Permission is granted to anyone to use this software for any purpose,
|
||||
// including commercial applications, and to alter it and redistribute it
|
||||
// freely, subject to the following restrictions:
|
||||
//
|
||||
// 1. The origin of this software must not be misrepresented; you must not
|
||||
// claim that you wrote the original software. If you use this software
|
||||
// in a product, an acknowledgment in the product documentation would
|
||||
// be appreciated but is not required.
|
||||
//
|
||||
// 2. Altered source versions must be plainly marked as such, and must not
|
||||
// be misrepresented as being the original software.
|
||||
//
|
||||
// 3. This notice may not be removed or altered from any source
|
||||
// distribution.
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#define GLX_VENDOR 1
|
||||
#define GLX_RGBA_BIT 0x00000001
|
||||
#define GLX_WINDOW_BIT 0x00000001
|
||||
#define GLX_DRAWABLE_TYPE 0x8010
|
||||
#define GLX_RENDER_TYPE 0x8011
|
||||
#define GLX_RGBA_TYPE 0x8014
|
||||
#define GLX_DOUBLEBUFFER 5
|
||||
#define GLX_STEREO 6
|
||||
#define GLX_AUX_BUFFERS 7
|
||||
#define GLX_RED_SIZE 8
|
||||
#define GLX_GREEN_SIZE 9
|
||||
#define GLX_BLUE_SIZE 10
|
||||
#define GLX_ALPHA_SIZE 11
|
||||
#define GLX_DEPTH_SIZE 12
|
||||
#define GLX_STENCIL_SIZE 13
|
||||
#define GLX_ACCUM_RED_SIZE 14
|
||||
#define GLX_ACCUM_GREEN_SIZE 15
|
||||
#define GLX_ACCUM_BLUE_SIZE 16
|
||||
#define GLX_ACCUM_ALPHA_SIZE 17
|
||||
#define GLX_SAMPLES 0x186a1
|
||||
#define GLX_VISUAL_ID 0x800b
|
||||
|
||||
#define GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20b2
|
||||
#define GLX_CONTEXT_DEBUG_BIT_ARB 0x00000001
|
||||
#define GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002
|
||||
#define GLX_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001
|
||||
#define GLX_CONTEXT_PROFILE_MASK_ARB 0x9126
|
||||
#define GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x00000002
|
||||
#define GLX_CONTEXT_MAJOR_VERSION_ARB 0x2091
|
||||
#define GLX_CONTEXT_MINOR_VERSION_ARB 0x2092
|
||||
#define GLX_CONTEXT_FLAGS_ARB 0x2094
|
||||
#define GLX_CONTEXT_ES2_PROFILE_BIT_EXT 0x00000004
|
||||
#define GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB 0x00000004
|
||||
#define GLX_LOSE_CONTEXT_ON_RESET_ARB 0x8252
|
||||
#define GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB 0x8256
|
||||
#define GLX_NO_RESET_NOTIFICATION_ARB 0x8261
|
||||
#define GLX_CONTEXT_RELEASE_BEHAVIOR_ARB 0x2097
|
||||
#define GLX_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB 0
|
||||
#define GLX_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB 0x2098
|
||||
#define GLX_CONTEXT_OPENGL_NO_ERROR_ARB 0x31b3
|
||||
|
||||
typedef XID GLXWindow;
|
||||
typedef XID GLXDrawable;
|
||||
typedef struct __GLXFBConfig* GLXFBConfig;
|
||||
typedef struct __GLXcontext* GLXContext;
|
||||
typedef void (*__GLXextproc)(void);
|
||||
|
||||
typedef int (*PFNGLXGETFBCONFIGATTRIBPROC)(Display*,GLXFBConfig,int,int*);
|
||||
typedef const char* (*PFNGLXGETCLIENTSTRINGPROC)(Display*,int);
|
||||
typedef Bool (*PFNGLXQUERYEXTENSIONPROC)(Display*,int*,int*);
|
||||
typedef Bool (*PFNGLXQUERYVERSIONPROC)(Display*,int*,int*);
|
||||
typedef void (*PFNGLXDESTROYCONTEXTPROC)(Display*,GLXContext);
|
||||
typedef Bool (*PFNGLXMAKECURRENTPROC)(Display*,GLXDrawable,GLXContext);
|
||||
typedef void (*PFNGLXSWAPBUFFERSPROC)(Display*,GLXDrawable);
|
||||
typedef const char* (*PFNGLXQUERYEXTENSIONSSTRINGPROC)(Display*,int);
|
||||
typedef GLXFBConfig* (*PFNGLXGETFBCONFIGSPROC)(Display*,int,int*);
|
||||
typedef GLXContext (*PFNGLXCREATENEWCONTEXTPROC)(Display*,GLXFBConfig,int,GLXContext,Bool);
|
||||
typedef __GLXextproc (* PFNGLXGETPROCADDRESSPROC)(const GLubyte *procName);
|
||||
typedef void (*PFNGLXSWAPINTERVALEXTPROC)(Display*,GLXDrawable,int);
|
||||
typedef XVisualInfo* (*PFNGLXGETVISUALFROMFBCONFIGPROC)(Display*,GLXFBConfig);
|
||||
typedef GLXWindow (*PFNGLXCREATEWINDOWPROC)(Display*,GLXFBConfig,Window,const int*);
|
||||
typedef void (*PFNGLXDESTROYWINDOWPROC)(Display*,GLXWindow);
|
||||
|
||||
typedef int (*PFNGLXSWAPINTERVALMESAPROC)(int);
|
||||
typedef int (*PFNGLXSWAPINTERVALSGIPROC)(int);
|
||||
typedef GLXContext (*PFNGLXCREATECONTEXTATTRIBSARBPROC)(Display*,GLXFBConfig,GLXContext,Bool,const int*);
|
||||
|
||||
// libGL.so function pointer typedefs
|
||||
#define glXGetFBConfigs _glfw.glx.GetFBConfigs
|
||||
#define glXGetFBConfigAttrib _glfw.glx.GetFBConfigAttrib
|
||||
#define glXGetClientString _glfw.glx.GetClientString
|
||||
#define glXQueryExtension _glfw.glx.QueryExtension
|
||||
#define glXQueryVersion _glfw.glx.QueryVersion
|
||||
#define glXDestroyContext _glfw.glx.DestroyContext
|
||||
#define glXMakeCurrent _glfw.glx.MakeCurrent
|
||||
#define glXSwapBuffers _glfw.glx.SwapBuffers
|
||||
#define glXQueryExtensionsString _glfw.glx.QueryExtensionsString
|
||||
#define glXCreateNewContext _glfw.glx.CreateNewContext
|
||||
#define glXGetVisualFromFBConfig _glfw.glx.GetVisualFromFBConfig
|
||||
#define glXCreateWindow _glfw.glx.CreateWindow
|
||||
#define glXDestroyWindow _glfw.glx.DestroyWindow
|
||||
|
||||
#define _GLFW_PLATFORM_CONTEXT_STATE _GLFWcontextGLX glx
|
||||
#define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE _GLFWlibraryGLX glx
|
||||
#define _GLFW_PLATFORM_USER_CONTEXT_STATE _GLFWusercontextGLX glx
|
||||
|
||||
|
||||
// GLX-specific per-context data
|
||||
//
|
||||
typedef struct _GLFWcontextGLX
|
||||
{
|
||||
GLXFBConfig fbconfig;
|
||||
GLXContext handle;
|
||||
GLXWindow window;
|
||||
|
||||
} _GLFWcontextGLX;
|
||||
|
||||
// GLX-specific per user context data
|
||||
//
|
||||
typedef struct _GLFWusercontextGLX
|
||||
{
|
||||
GLXContext handle;
|
||||
} _GLFWusercontextGLX;
|
||||
|
||||
// GLX-specific global data
|
||||
//
|
||||
typedef struct _GLFWlibraryGLX
|
||||
{
|
||||
int major, minor;
|
||||
int eventBase;
|
||||
int errorBase;
|
||||
|
||||
// dlopen handle for libGL.so.1
|
||||
void* handle;
|
||||
|
||||
// GLX 1.3 functions
|
||||
PFNGLXGETFBCONFIGSPROC GetFBConfigs;
|
||||
PFNGLXGETFBCONFIGATTRIBPROC GetFBConfigAttrib;
|
||||
PFNGLXGETCLIENTSTRINGPROC GetClientString;
|
||||
PFNGLXQUERYEXTENSIONPROC QueryExtension;
|
||||
PFNGLXQUERYVERSIONPROC QueryVersion;
|
||||
PFNGLXDESTROYCONTEXTPROC DestroyContext;
|
||||
PFNGLXMAKECURRENTPROC MakeCurrent;
|
||||
PFNGLXSWAPBUFFERSPROC SwapBuffers;
|
||||
PFNGLXQUERYEXTENSIONSSTRINGPROC QueryExtensionsString;
|
||||
PFNGLXCREATENEWCONTEXTPROC CreateNewContext;
|
||||
PFNGLXGETVISUALFROMFBCONFIGPROC GetVisualFromFBConfig;
|
||||
PFNGLXCREATEWINDOWPROC CreateWindow;
|
||||
PFNGLXDESTROYWINDOWPROC DestroyWindow;
|
||||
|
||||
// GLX 1.4 and extension functions
|
||||
PFNGLXGETPROCADDRESSPROC GetProcAddress;
|
||||
PFNGLXGETPROCADDRESSPROC GetProcAddressARB;
|
||||
PFNGLXSWAPINTERVALSGIPROC SwapIntervalSGI;
|
||||
PFNGLXSWAPINTERVALEXTPROC SwapIntervalEXT;
|
||||
PFNGLXSWAPINTERVALMESAPROC SwapIntervalMESA;
|
||||
PFNGLXCREATECONTEXTATTRIBSARBPROC CreateContextAttribsARB;
|
||||
GLFWbool SGI_swap_control;
|
||||
GLFWbool EXT_swap_control;
|
||||
GLFWbool MESA_swap_control;
|
||||
GLFWbool ARB_multisample;
|
||||
GLFWbool ARB_framebuffer_sRGB;
|
||||
GLFWbool EXT_framebuffer_sRGB;
|
||||
GLFWbool ARB_create_context;
|
||||
GLFWbool ARB_create_context_profile;
|
||||
GLFWbool ARB_create_context_robustness;
|
||||
GLFWbool EXT_create_context_es2_profile;
|
||||
GLFWbool ARB_create_context_no_error;
|
||||
GLFWbool ARB_context_flush_control;
|
||||
|
||||
} _GLFWlibraryGLX;
|
||||
|
||||
|
||||
GLFWbool _glfwInitGLX(void);
|
||||
void _glfwTerminateGLX(void);
|
||||
GLFWbool _glfwCreateContextGLX(_GLFWwindow* window,
|
||||
const _GLFWctxconfig* ctxconfig,
|
||||
const _GLFWfbconfig* fbconfig);
|
||||
void _glfwDestroyContextGLX(_GLFWwindow* window);
|
||||
GLFWbool _glfwChooseVisualGLX(const _GLFWwndconfig* wndconfig,
|
||||
const _GLFWctxconfig* ctxconfig,
|
||||
const _GLFWfbconfig* fbconfig,
|
||||
Visual** visual, int* depth);
|
||||
_GLFWusercontext* _glfwCreateUserContextGLX(_GLFWwindow* window);
|
||||
|
84
src/init.c
84
src/init.c
@ -36,16 +36,15 @@
|
||||
#include <assert.h>
|
||||
|
||||
|
||||
// The global variables below comprise all mutable global data in GLFW
|
||||
//
|
||||
// Any other global variable is a bug
|
||||
// NOTE: The global variables below comprise all mutable global data in GLFW
|
||||
// Any other mutable global variable is a bug
|
||||
|
||||
// Global state shared between compilation units of GLFW
|
||||
// This contains all mutable state shared between compilation units of GLFW
|
||||
//
|
||||
_GLFWlibrary _glfw = { GLFW_FALSE };
|
||||
|
||||
// These are outside of _glfw so they can be used before initialization and
|
||||
// after termination
|
||||
// after termination without special handling when _glfw is cleared to zero
|
||||
//
|
||||
static _GLFWerror _glfwMainThreadError;
|
||||
static GLFWerrorfun _glfwErrorCallback;
|
||||
@ -54,6 +53,8 @@ static _GLFWinitconfig _glfwInitHints =
|
||||
{
|
||||
GLFW_TRUE, // hat buttons
|
||||
GLFW_ANGLE_PLATFORM_TYPE_NONE, // ANGLE backend
|
||||
GLFW_ANY_PLATFORM, // preferred platform
|
||||
NULL, // vkGetInstanceProcAddr function
|
||||
{
|
||||
GLFW_TRUE, // macOS menu bar
|
||||
GLFW_TRUE // macOS bundle chdir
|
||||
@ -102,7 +103,7 @@ static void terminate(void)
|
||||
{
|
||||
_GLFWmonitor* monitor = _glfw.monitors[i];
|
||||
if (monitor->originalRamp.size)
|
||||
_glfwPlatformSetGammaRamp(monitor, &monitor->originalRamp);
|
||||
_glfw.platform.setGammaRamp(monitor, &monitor->originalRamp);
|
||||
_glfwFreeMonitor(monitor);
|
||||
}
|
||||
|
||||
@ -115,8 +116,8 @@ static void terminate(void)
|
||||
_glfw.mappingCount = 0;
|
||||
|
||||
_glfwTerminateVulkan();
|
||||
_glfwPlatformTerminateJoysticks();
|
||||
_glfwPlatformTerminate();
|
||||
_glfw.platform.terminateJoysticks();
|
||||
_glfw.platform.terminate();
|
||||
|
||||
_glfw.initialized = GLFW_FALSE;
|
||||
|
||||
@ -140,6 +141,37 @@ static void terminate(void)
|
||||
////// GLFW internal API //////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Encode a Unicode code point to a UTF-8 stream
|
||||
// Based on cutef8 by Jeff Bezanson (Public Domain)
|
||||
//
|
||||
size_t _glfwEncodeUTF8(char* s, uint32_t codepoint)
|
||||
{
|
||||
size_t count = 0;
|
||||
|
||||
if (codepoint < 0x80)
|
||||
s[count++] = (char) codepoint;
|
||||
else if (codepoint < 0x800)
|
||||
{
|
||||
s[count++] = (codepoint >> 6) | 0xc0;
|
||||
s[count++] = (codepoint & 0x3f) | 0x80;
|
||||
}
|
||||
else if (codepoint < 0x10000)
|
||||
{
|
||||
s[count++] = (codepoint >> 12) | 0xe0;
|
||||
s[count++] = ((codepoint >> 6) & 0x3f) | 0x80;
|
||||
s[count++] = (codepoint & 0x3f) | 0x80;
|
||||
}
|
||||
else if (codepoint < 0x110000)
|
||||
{
|
||||
s[count++] = (codepoint >> 18) | 0xf0;
|
||||
s[count++] = ((codepoint >> 12) & 0x3f) | 0x80;
|
||||
s[count++] = ((codepoint >> 6) & 0x3f) | 0x80;
|
||||
s[count++] = (codepoint & 0x3f) | 0x80;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
char* _glfw_strdup(const char* source)
|
||||
{
|
||||
const size_t length = strlen(source);
|
||||
@ -148,6 +180,16 @@ char* _glfw_strdup(const char* source)
|
||||
return result;
|
||||
}
|
||||
|
||||
int _glfw_min(int a, int b)
|
||||
{
|
||||
return a < b ? a : b;
|
||||
}
|
||||
|
||||
int _glfw_max(int a, int b)
|
||||
{
|
||||
return a > b ? a : b;
|
||||
}
|
||||
|
||||
float _glfw_fminf(float a, float b)
|
||||
{
|
||||
if (a != a)
|
||||
@ -275,6 +317,8 @@ void _glfwInputError(int code, const char* format, ...)
|
||||
strcpy(description, "The requested feature cannot be implemented for this platform");
|
||||
else if (code == GLFW_FEATURE_UNIMPLEMENTED)
|
||||
strcpy(description, "The requested feature has not yet been implemented for this platform");
|
||||
else if (code == GLFW_PLATFORM_UNAVAILABLE)
|
||||
strcpy(description, "The requested platform is unavailable");
|
||||
else
|
||||
strcpy(description, "ERROR: UNKNOWN GLFW ERROR");
|
||||
}
|
||||
@ -323,7 +367,10 @@ GLFWAPI int glfwInit(void)
|
||||
_glfw.allocator.deallocate = defaultDeallocate;
|
||||
}
|
||||
|
||||
if (!_glfwPlatformInit())
|
||||
if (!_glfwSelectPlatform(_glfw.hints.init.platformID, &_glfw.platform))
|
||||
return GLFW_FALSE;
|
||||
|
||||
if (!_glfw.platform.init())
|
||||
{
|
||||
terminate();
|
||||
return GLFW_FALSE;
|
||||
@ -342,9 +389,11 @@ GLFWAPI int glfwInit(void)
|
||||
|
||||
_glfwInitGamepadMappings();
|
||||
|
||||
_glfw.initialized = GLFW_TRUE;
|
||||
_glfwPlatformInitTimer();
|
||||
_glfw.timer.offset = _glfwPlatformGetTimerValue();
|
||||
|
||||
_glfw.initialized = GLFW_TRUE;
|
||||
|
||||
glfwDefaultWindowHints();
|
||||
return GLFW_TRUE;
|
||||
}
|
||||
@ -367,6 +416,9 @@ GLFWAPI void glfwInitHint(int hint, int value)
|
||||
case GLFW_ANGLE_PLATFORM_TYPE:
|
||||
_glfwInitHints.angleType = value;
|
||||
return;
|
||||
case GLFW_PLATFORM:
|
||||
_glfwInitHints.platformID = value;
|
||||
return;
|
||||
case GLFW_COCOA_CHDIR_RESOURCES:
|
||||
_glfwInitHints.ns.chdir = value;
|
||||
return;
|
||||
@ -395,6 +447,11 @@ GLFWAPI void glfwInitAllocator(const GLFWallocator* allocator)
|
||||
memset(&_glfwInitAllocator, 0, sizeof(GLFWallocator));
|
||||
}
|
||||
|
||||
GLFWAPI void glfwInitVulkanLoader(PFN_vkGetInstanceProcAddr loader)
|
||||
{
|
||||
_glfwInitHints.vulkanLoader = loader;
|
||||
}
|
||||
|
||||
GLFWAPI void glfwGetVersion(int* major, int* minor, int* rev)
|
||||
{
|
||||
if (major != NULL)
|
||||
@ -405,11 +462,6 @@ GLFWAPI void glfwGetVersion(int* major, int* minor, int* rev)
|
||||
*rev = GLFW_VERSION_REVISION;
|
||||
}
|
||||
|
||||
GLFWAPI const char* glfwGetVersionString(void)
|
||||
{
|
||||
return _glfwPlatformGetVersionString();
|
||||
}
|
||||
|
||||
GLFWAPI int glfwGetError(const char** description)
|
||||
{
|
||||
_GLFWerror* error;
|
||||
@ -436,7 +488,7 @@ GLFWAPI int glfwGetError(const char** description)
|
||||
|
||||
GLFWAPI GLFWerrorfun glfwSetErrorCallback(GLFWerrorfun cbfun)
|
||||
{
|
||||
_GLFW_SWAP_POINTERS(_glfwErrorCallback, cbfun);
|
||||
_GLFW_SWAP(GLFWerrorfun, _glfwErrorCallback, cbfun);
|
||||
return cbfun;
|
||||
}
|
||||
|
||||
|
228
src/input.c
228
src/input.c
@ -50,9 +50,9 @@ static GLFWbool initJoysticks(void)
|
||||
{
|
||||
if (!_glfw.joysticksInitialized)
|
||||
{
|
||||
if (!_glfwPlatformInitJoysticks())
|
||||
if (!_glfw.platform.initJoysticks())
|
||||
{
|
||||
_glfwPlatformTerminateJoysticks();
|
||||
_glfw.platform.terminateJoysticks();
|
||||
return GLFW_FALSE;
|
||||
}
|
||||
}
|
||||
@ -234,8 +234,9 @@ static GLFWbool parseMapping(_GLFWmapping* mapping, const char* string)
|
||||
}
|
||||
else
|
||||
{
|
||||
length = strlen(_GLFW_PLATFORM_MAPPING_NAME);
|
||||
if (strncmp(c, _GLFW_PLATFORM_MAPPING_NAME, length) != 0)
|
||||
const char* name = _glfw.platform.getMappingName();
|
||||
length = strlen(name);
|
||||
if (strncmp(c, name, length) != 0)
|
||||
return GLFW_FALSE;
|
||||
}
|
||||
|
||||
@ -252,7 +253,7 @@ static GLFWbool parseMapping(_GLFWmapping* mapping, const char* string)
|
||||
mapping->guid[i] += 'a' - 'A';
|
||||
}
|
||||
|
||||
_glfwPlatformUpdateGamepadGUID(mapping->guid);
|
||||
_glfw.platform.updateGamepadGUID(mapping->guid);
|
||||
return GLFW_TRUE;
|
||||
}
|
||||
|
||||
@ -294,7 +295,7 @@ void _glfwInputKey(_GLFWwindow* window, int key, int scancode, int action, int m
|
||||
// Notifies shared code of a Unicode codepoint input event
|
||||
// The 'plain' parameter determines whether to emit a regular character event
|
||||
//
|
||||
void _glfwInputChar(_GLFWwindow* window, unsigned int codepoint, int mods, GLFWbool plain)
|
||||
void _glfwInputChar(_GLFWwindow* window, uint32_t codepoint, int mods, GLFWbool plain)
|
||||
{
|
||||
if (codepoint < 32 || (codepoint > 126 && codepoint < 160))
|
||||
return;
|
||||
@ -480,8 +481,8 @@ void _glfwCenterCursorInContentArea(_GLFWwindow* window)
|
||||
{
|
||||
int width, height;
|
||||
|
||||
_glfwPlatformGetWindowSize(window, &width, &height);
|
||||
_glfwPlatformSetCursorPos(window, width / 2.0, height / 2.0);
|
||||
_glfw.platform.getWindowSize(window, &width, &height);
|
||||
_glfw.platform.setCursorPos(window, width / 2.0, height / 2.0);
|
||||
}
|
||||
|
||||
|
||||
@ -521,96 +522,108 @@ GLFWAPI void glfwSetInputMode(GLFWwindow* handle, int mode, int value)
|
||||
|
||||
_GLFW_REQUIRE_INIT();
|
||||
|
||||
if (mode == GLFW_CURSOR)
|
||||
switch (mode)
|
||||
{
|
||||
if (value != GLFW_CURSOR_NORMAL &&
|
||||
value != GLFW_CURSOR_HIDDEN &&
|
||||
value != GLFW_CURSOR_DISABLED)
|
||||
case GLFW_CURSOR:
|
||||
{
|
||||
_glfwInputError(GLFW_INVALID_ENUM,
|
||||
"Invalid cursor mode 0x%08X",
|
||||
value);
|
||||
return;
|
||||
}
|
||||
|
||||
if (window->cursorMode == value)
|
||||
return;
|
||||
|
||||
window->cursorMode = value;
|
||||
|
||||
_glfwPlatformGetCursorPos(window,
|
||||
&window->virtualCursorPosX,
|
||||
&window->virtualCursorPosY);
|
||||
_glfwPlatformSetCursorMode(window, value);
|
||||
}
|
||||
else if (mode == GLFW_STICKY_KEYS)
|
||||
{
|
||||
value = value ? GLFW_TRUE : GLFW_FALSE;
|
||||
if (window->stickyKeys == value)
|
||||
return;
|
||||
|
||||
if (!value)
|
||||
{
|
||||
int i;
|
||||
|
||||
// Release all sticky keys
|
||||
for (i = 0; i <= GLFW_KEY_LAST; i++)
|
||||
if (value != GLFW_CURSOR_NORMAL &&
|
||||
value != GLFW_CURSOR_HIDDEN &&
|
||||
value != GLFW_CURSOR_DISABLED)
|
||||
{
|
||||
if (window->keys[i] == _GLFW_STICK)
|
||||
window->keys[i] = GLFW_RELEASE;
|
||||
_glfwInputError(GLFW_INVALID_ENUM,
|
||||
"Invalid cursor mode 0x%08X",
|
||||
value);
|
||||
return;
|
||||
}
|
||||
|
||||
if (window->cursorMode == value)
|
||||
return;
|
||||
|
||||
window->cursorMode = value;
|
||||
|
||||
_glfw.platform.getCursorPos(window,
|
||||
&window->virtualCursorPosX,
|
||||
&window->virtualCursorPosY);
|
||||
_glfw.platform.setCursorMode(window, value);
|
||||
return;
|
||||
}
|
||||
|
||||
window->stickyKeys = value;
|
||||
}
|
||||
else if (mode == GLFW_STICKY_MOUSE_BUTTONS)
|
||||
{
|
||||
value = value ? GLFW_TRUE : GLFW_FALSE;
|
||||
if (window->stickyMouseButtons == value)
|
||||
return;
|
||||
|
||||
if (!value)
|
||||
case GLFW_STICKY_KEYS:
|
||||
{
|
||||
int i;
|
||||
value = value ? GLFW_TRUE : GLFW_FALSE;
|
||||
if (window->stickyKeys == value)
|
||||
return;
|
||||
|
||||
// Release all sticky mouse buttons
|
||||
for (i = 0; i <= GLFW_MOUSE_BUTTON_LAST; i++)
|
||||
if (!value)
|
||||
{
|
||||
if (window->mouseButtons[i] == _GLFW_STICK)
|
||||
window->mouseButtons[i] = GLFW_RELEASE;
|
||||
int i;
|
||||
|
||||
// Release all sticky keys
|
||||
for (i = 0; i <= GLFW_KEY_LAST; i++)
|
||||
{
|
||||
if (window->keys[i] == _GLFW_STICK)
|
||||
window->keys[i] = GLFW_RELEASE;
|
||||
}
|
||||
}
|
||||
|
||||
window->stickyKeys = value;
|
||||
return;
|
||||
}
|
||||
|
||||
window->stickyMouseButtons = value;
|
||||
}
|
||||
else if (mode == GLFW_LOCK_KEY_MODS)
|
||||
{
|
||||
window->lockKeyMods = value ? GLFW_TRUE : GLFW_FALSE;
|
||||
}
|
||||
else if (mode == GLFW_RAW_MOUSE_MOTION)
|
||||
{
|
||||
if (!_glfwPlatformRawMouseMotionSupported())
|
||||
case GLFW_STICKY_MOUSE_BUTTONS:
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"Raw mouse motion is not supported on this system");
|
||||
value = value ? GLFW_TRUE : GLFW_FALSE;
|
||||
if (window->stickyMouseButtons == value)
|
||||
return;
|
||||
|
||||
if (!value)
|
||||
{
|
||||
int i;
|
||||
|
||||
// Release all sticky mouse buttons
|
||||
for (i = 0; i <= GLFW_MOUSE_BUTTON_LAST; i++)
|
||||
{
|
||||
if (window->mouseButtons[i] == _GLFW_STICK)
|
||||
window->mouseButtons[i] = GLFW_RELEASE;
|
||||
}
|
||||
}
|
||||
|
||||
window->stickyMouseButtons = value;
|
||||
return;
|
||||
}
|
||||
|
||||
value = value ? GLFW_TRUE : GLFW_FALSE;
|
||||
if (window->rawMouseMotion == value)
|
||||
case GLFW_LOCK_KEY_MODS:
|
||||
{
|
||||
window->lockKeyMods = value ? GLFW_TRUE : GLFW_FALSE;
|
||||
return;
|
||||
}
|
||||
|
||||
window->rawMouseMotion = value;
|
||||
_glfwPlatformSetRawMouseMotion(window, value);
|
||||
case GLFW_RAW_MOUSE_MOTION:
|
||||
{
|
||||
if (!_glfw.platform.rawMouseMotionSupported())
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"Raw mouse motion is not supported on this system");
|
||||
return;
|
||||
}
|
||||
|
||||
value = value ? GLFW_TRUE : GLFW_FALSE;
|
||||
if (window->rawMouseMotion == value)
|
||||
return;
|
||||
|
||||
window->rawMouseMotion = value;
|
||||
_glfw.platform.setRawMouseMotion(window, value);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
_glfwInputError(GLFW_INVALID_ENUM, "Invalid input mode 0x%08X", mode);
|
||||
|
||||
_glfwInputError(GLFW_INVALID_ENUM, "Invalid input mode 0x%08X", mode);
|
||||
}
|
||||
|
||||
GLFWAPI int glfwRawMouseMotionSupported(void)
|
||||
{
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(GLFW_FALSE);
|
||||
return _glfwPlatformRawMouseMotionSupported();
|
||||
return _glfw.platform.rawMouseMotionSupported();
|
||||
}
|
||||
|
||||
GLFWAPI const char* glfwGetKeyName(int key, int scancode)
|
||||
@ -626,10 +639,10 @@ GLFWAPI const char* glfwGetKeyName(int key, int scancode)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
scancode = _glfwPlatformGetKeyScancode(key);
|
||||
scancode = _glfw.platform.getKeyScancode(key);
|
||||
}
|
||||
|
||||
return _glfwPlatformGetScancodeName(scancode);
|
||||
return _glfw.platform.getScancodeName(scancode);
|
||||
}
|
||||
|
||||
GLFWAPI int glfwGetKeyScancode(int key)
|
||||
@ -642,7 +655,7 @@ GLFWAPI int glfwGetKeyScancode(int key)
|
||||
return GLFW_RELEASE;
|
||||
}
|
||||
|
||||
return _glfwPlatformGetKeyScancode(key);
|
||||
return _glfw.platform.getKeyScancode(key);
|
||||
}
|
||||
|
||||
GLFWAPI int glfwGetKey(GLFWwindow* handle, int key)
|
||||
@ -711,7 +724,7 @@ GLFWAPI void glfwGetCursorPos(GLFWwindow* handle, double* xpos, double* ypos)
|
||||
*ypos = window->virtualCursorPosY;
|
||||
}
|
||||
else
|
||||
_glfwPlatformGetCursorPos(window, xpos, ypos);
|
||||
_glfw.platform.getCursorPos(window, xpos, ypos);
|
||||
}
|
||||
|
||||
GLFWAPI void glfwSetCursorPos(GLFWwindow* handle, double xpos, double ypos)
|
||||
@ -730,7 +743,7 @@ GLFWAPI void glfwSetCursorPos(GLFWwindow* handle, double xpos, double ypos)
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_glfwPlatformWindowFocused(window))
|
||||
if (!_glfw.platform.windowFocused(window))
|
||||
return;
|
||||
|
||||
if (window->cursorMode == GLFW_CURSOR_DISABLED)
|
||||
@ -742,7 +755,7 @@ GLFWAPI void glfwSetCursorPos(GLFWwindow* handle, double xpos, double ypos)
|
||||
else
|
||||
{
|
||||
// Update system cursor position
|
||||
_glfwPlatformSetCursorPos(window, xpos, ypos);
|
||||
_glfw.platform.setCursorPos(window, xpos, ypos);
|
||||
}
|
||||
}
|
||||
|
||||
@ -751,14 +764,21 @@ GLFWAPI GLFWcursor* glfwCreateCursor(const GLFWimage* image, int xhot, int yhot)
|
||||
_GLFWcursor* cursor;
|
||||
|
||||
assert(image != NULL);
|
||||
assert(image->pixels != NULL);
|
||||
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||
|
||||
if (image->width <= 0 || image->height <= 0)
|
||||
{
|
||||
_glfwInputError(GLFW_INVALID_VALUE, "Invalid image dimensions for cursor");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
cursor = _glfw_calloc(1, sizeof(_GLFWcursor));
|
||||
cursor->next = _glfw.cursorListHead;
|
||||
_glfw.cursorListHead = cursor;
|
||||
|
||||
if (!_glfwPlatformCreateCursor(cursor, image, xhot, yhot))
|
||||
if (!_glfw.platform.createCursor(cursor, image, xhot, yhot))
|
||||
{
|
||||
glfwDestroyCursor((GLFWcursor*) cursor);
|
||||
return NULL;
|
||||
@ -792,7 +812,7 @@ GLFWAPI GLFWcursor* glfwCreateStandardCursor(int shape)
|
||||
cursor->next = _glfw.cursorListHead;
|
||||
_glfw.cursorListHead = cursor;
|
||||
|
||||
if (!_glfwPlatformCreateStandardCursor(cursor, shape))
|
||||
if (!_glfw.platform.createStandardCursor(cursor, shape))
|
||||
{
|
||||
glfwDestroyCursor((GLFWcursor*) cursor);
|
||||
return NULL;
|
||||
@ -821,7 +841,7 @@ GLFWAPI void glfwDestroyCursor(GLFWcursor* handle)
|
||||
}
|
||||
}
|
||||
|
||||
_glfwPlatformDestroyCursor(cursor);
|
||||
_glfw.platform.destroyCursor(cursor);
|
||||
|
||||
// Unlink cursor from global linked list
|
||||
{
|
||||
@ -846,7 +866,7 @@ GLFWAPI void glfwSetCursor(GLFWwindow* windowHandle, GLFWcursor* cursorHandle)
|
||||
|
||||
window->cursor = cursor;
|
||||
|
||||
_glfwPlatformSetCursor(window, cursor);
|
||||
_glfw.platform.setCursor(window, cursor);
|
||||
}
|
||||
|
||||
GLFWAPI GLFWkeyfun glfwSetKeyCallback(GLFWwindow* handle, GLFWkeyfun cbfun)
|
||||
@ -855,7 +875,7 @@ GLFWAPI GLFWkeyfun glfwSetKeyCallback(GLFWwindow* handle, GLFWkeyfun cbfun)
|
||||
assert(window != NULL);
|
||||
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||
_GLFW_SWAP_POINTERS(window->callbacks.key, cbfun);
|
||||
_GLFW_SWAP(GLFWkeyfun, window->callbacks.key, cbfun);
|
||||
return cbfun;
|
||||
}
|
||||
|
||||
@ -865,7 +885,7 @@ GLFWAPI GLFWcharfun glfwSetCharCallback(GLFWwindow* handle, GLFWcharfun cbfun)
|
||||
assert(window != NULL);
|
||||
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||
_GLFW_SWAP_POINTERS(window->callbacks.character, cbfun);
|
||||
_GLFW_SWAP(GLFWcharfun, window->callbacks.character, cbfun);
|
||||
return cbfun;
|
||||
}
|
||||
|
||||
@ -875,7 +895,7 @@ GLFWAPI GLFWcharmodsfun glfwSetCharModsCallback(GLFWwindow* handle, GLFWcharmods
|
||||
assert(window != NULL);
|
||||
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||
_GLFW_SWAP_POINTERS(window->callbacks.charmods, cbfun);
|
||||
_GLFW_SWAP(GLFWcharmodsfun, window->callbacks.charmods, cbfun);
|
||||
return cbfun;
|
||||
}
|
||||
|
||||
@ -886,7 +906,7 @@ GLFWAPI GLFWmousebuttonfun glfwSetMouseButtonCallback(GLFWwindow* handle,
|
||||
assert(window != NULL);
|
||||
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||
_GLFW_SWAP_POINTERS(window->callbacks.mouseButton, cbfun);
|
||||
_GLFW_SWAP(GLFWmousebuttonfun, window->callbacks.mouseButton, cbfun);
|
||||
return cbfun;
|
||||
}
|
||||
|
||||
@ -897,7 +917,7 @@ GLFWAPI GLFWcursorposfun glfwSetCursorPosCallback(GLFWwindow* handle,
|
||||
assert(window != NULL);
|
||||
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||
_GLFW_SWAP_POINTERS(window->callbacks.cursorPos, cbfun);
|
||||
_GLFW_SWAP(GLFWcursorposfun, window->callbacks.cursorPos, cbfun);
|
||||
return cbfun;
|
||||
}
|
||||
|
||||
@ -908,7 +928,7 @@ GLFWAPI GLFWcursorenterfun glfwSetCursorEnterCallback(GLFWwindow* handle,
|
||||
assert(window != NULL);
|
||||
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||
_GLFW_SWAP_POINTERS(window->callbacks.cursorEnter, cbfun);
|
||||
_GLFW_SWAP(GLFWcursorenterfun, window->callbacks.cursorEnter, cbfun);
|
||||
return cbfun;
|
||||
}
|
||||
|
||||
@ -919,7 +939,7 @@ GLFWAPI GLFWscrollfun glfwSetScrollCallback(GLFWwindow* handle,
|
||||
assert(window != NULL);
|
||||
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||
_GLFW_SWAP_POINTERS(window->callbacks.scroll, cbfun);
|
||||
_GLFW_SWAP(GLFWscrollfun, window->callbacks.scroll, cbfun);
|
||||
return cbfun;
|
||||
}
|
||||
|
||||
@ -929,7 +949,7 @@ GLFWAPI GLFWdropfun glfwSetDropCallback(GLFWwindow* handle, GLFWdropfun cbfun)
|
||||
assert(window != NULL);
|
||||
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||
_GLFW_SWAP_POINTERS(window->callbacks.drop, cbfun);
|
||||
_GLFW_SWAP(GLFWdropfun, window->callbacks.drop, cbfun);
|
||||
return cbfun;
|
||||
}
|
||||
|
||||
@ -955,7 +975,7 @@ GLFWAPI int glfwJoystickPresent(int jid)
|
||||
if (!js->present)
|
||||
return GLFW_FALSE;
|
||||
|
||||
return _glfwPlatformPollJoystick(js, _GLFW_POLL_PRESENCE);
|
||||
return _glfw.platform.pollJoystick(js, _GLFW_POLL_PRESENCE);
|
||||
}
|
||||
|
||||
GLFWAPI const float* glfwGetJoystickAxes(int jid, int* count)
|
||||
@ -983,7 +1003,7 @@ GLFWAPI const float* glfwGetJoystickAxes(int jid, int* count)
|
||||
if (!js->present)
|
||||
return NULL;
|
||||
|
||||
if (!_glfwPlatformPollJoystick(js, _GLFW_POLL_AXES))
|
||||
if (!_glfw.platform.pollJoystick(js, _GLFW_POLL_AXES))
|
||||
return NULL;
|
||||
|
||||
*count = js->axisCount;
|
||||
@ -1015,7 +1035,7 @@ GLFWAPI const unsigned char* glfwGetJoystickButtons(int jid, int* count)
|
||||
if (!js->present)
|
||||
return NULL;
|
||||
|
||||
if (!_glfwPlatformPollJoystick(js, _GLFW_POLL_BUTTONS))
|
||||
if (!_glfw.platform.pollJoystick(js, _GLFW_POLL_BUTTONS))
|
||||
return NULL;
|
||||
|
||||
if (_glfw.hints.init.hatButtons)
|
||||
@ -1051,7 +1071,7 @@ GLFWAPI const unsigned char* glfwGetJoystickHats(int jid, int* count)
|
||||
if (!js->present)
|
||||
return NULL;
|
||||
|
||||
if (!_glfwPlatformPollJoystick(js, _GLFW_POLL_BUTTONS))
|
||||
if (!_glfw.platform.pollJoystick(js, _GLFW_POLL_BUTTONS))
|
||||
return NULL;
|
||||
|
||||
*count = js->hatCount;
|
||||
@ -1080,7 +1100,7 @@ GLFWAPI const char* glfwGetJoystickName(int jid)
|
||||
if (!js->present)
|
||||
return NULL;
|
||||
|
||||
if (!_glfwPlatformPollJoystick(js, _GLFW_POLL_PRESENCE))
|
||||
if (!_glfw.platform.pollJoystick(js, _GLFW_POLL_PRESENCE))
|
||||
return NULL;
|
||||
|
||||
return js->name;
|
||||
@ -1108,7 +1128,7 @@ GLFWAPI const char* glfwGetJoystickGUID(int jid)
|
||||
if (!js->present)
|
||||
return NULL;
|
||||
|
||||
if (!_glfwPlatformPollJoystick(js, _GLFW_POLL_PRESENCE))
|
||||
if (!_glfw.platform.pollJoystick(js, _GLFW_POLL_PRESENCE))
|
||||
return NULL;
|
||||
|
||||
return js->guid;
|
||||
@ -1153,7 +1173,7 @@ GLFWAPI GLFWjoystickfun glfwSetJoystickCallback(GLFWjoystickfun cbfun)
|
||||
if (!initJoysticks())
|
||||
return NULL;
|
||||
|
||||
_GLFW_SWAP_POINTERS(_glfw.callbacks.joystick, cbfun);
|
||||
_GLFW_SWAP(GLFWjoystickfun, _glfw.callbacks.joystick, cbfun);
|
||||
return cbfun;
|
||||
}
|
||||
|
||||
@ -1239,7 +1259,7 @@ GLFWAPI int glfwJoystickIsGamepad(int jid)
|
||||
if (!js->present)
|
||||
return GLFW_FALSE;
|
||||
|
||||
if (!_glfwPlatformPollJoystick(js, _GLFW_POLL_PRESENCE))
|
||||
if (!_glfw.platform.pollJoystick(js, _GLFW_POLL_PRESENCE))
|
||||
return GLFW_FALSE;
|
||||
|
||||
return js->mapping != NULL;
|
||||
@ -1267,7 +1287,7 @@ GLFWAPI const char* glfwGetGamepadName(int jid)
|
||||
if (!js->present)
|
||||
return NULL;
|
||||
|
||||
if (!_glfwPlatformPollJoystick(js, _GLFW_POLL_PRESENCE))
|
||||
if (!_glfw.platform.pollJoystick(js, _GLFW_POLL_PRESENCE))
|
||||
return NULL;
|
||||
|
||||
if (!js->mapping)
|
||||
@ -1302,7 +1322,7 @@ GLFWAPI int glfwGetGamepadState(int jid, GLFWgamepadstate* state)
|
||||
if (!js->present)
|
||||
return GLFW_FALSE;
|
||||
|
||||
if (!_glfwPlatformPollJoystick(js, _GLFW_POLL_ALL))
|
||||
if (!_glfw.platform.pollJoystick(js, _GLFW_POLL_ALL))
|
||||
return GLFW_FALSE;
|
||||
|
||||
if (!js->mapping)
|
||||
@ -1367,13 +1387,13 @@ GLFWAPI void glfwSetClipboardString(GLFWwindow* handle, const char* string)
|
||||
assert(string != NULL);
|
||||
|
||||
_GLFW_REQUIRE_INIT();
|
||||
_glfwPlatformSetClipboardString(string);
|
||||
_glfw.platform.setClipboardString(string);
|
||||
}
|
||||
|
||||
GLFWAPI const char* glfwGetClipboardString(GLFWwindow* handle)
|
||||
{
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||
return _glfwPlatformGetClipboardString();
|
||||
return _glfw.platform.getClipboardString();
|
||||
}
|
||||
|
||||
GLFWAPI double glfwGetTime(void)
|
||||
|
607
src/internal.h
607
src/internal.h
@ -59,6 +59,7 @@
|
||||
#define _GLFW_MESSAGE_SIZE 1024
|
||||
|
||||
typedef int GLFWbool;
|
||||
typedef void (*GLFWproc)(void);
|
||||
|
||||
typedef struct _GLFWerror _GLFWerror;
|
||||
typedef struct _GLFWinitconfig _GLFWinitconfig;
|
||||
@ -67,6 +68,7 @@ typedef struct _GLFWctxconfig _GLFWctxconfig;
|
||||
typedef struct _GLFWfbconfig _GLFWfbconfig;
|
||||
typedef struct _GLFWcontext _GLFWcontext;
|
||||
typedef struct _GLFWwindow _GLFWwindow;
|
||||
typedef struct _GLFWplatform _GLFWplatform;
|
||||
typedef struct _GLFWlibrary _GLFWlibrary;
|
||||
typedef struct _GLFWmonitor _GLFWmonitor;
|
||||
typedef struct _GLFWcursor _GLFWcursor;
|
||||
@ -77,15 +79,6 @@ typedef struct _GLFWtls _GLFWtls;
|
||||
typedef struct _GLFWmutex _GLFWmutex;
|
||||
typedef struct _GLFWusercontext _GLFWusercontext;
|
||||
|
||||
typedef void (* _GLFWmakecontextcurrentfun)(_GLFWwindow*);
|
||||
typedef void (* _GLFWswapbuffersfun)(_GLFWwindow*);
|
||||
typedef void (* _GLFWswapintervalfun)(int);
|
||||
typedef int (* _GLFWextensionsupportedfun)(const char*);
|
||||
typedef GLFWglproc (* _GLFWgetprocaddressfun)(const char*);
|
||||
typedef void (* _GLFWdestroycontextfun)(_GLFWwindow*);
|
||||
typedef void (* _GLFWmakeusercontextcurrentfun)(_GLFWusercontext* context);
|
||||
typedef void (* _GLFWdestroyusercontextfun)(_GLFWusercontext* context);
|
||||
|
||||
#define GL_VERSION 0x1f02
|
||||
#define GL_NONE 0
|
||||
#define GL_COLOR_BUFFER_BIT 0x00004000
|
||||
@ -116,6 +109,172 @@ typedef const GLubyte* (APIENTRY * PFNGLGETSTRINGPROC)(GLenum);
|
||||
typedef void (APIENTRY * PFNGLGETINTEGERVPROC)(GLenum,GLint*);
|
||||
typedef const GLubyte* (APIENTRY * PFNGLGETSTRINGIPROC)(GLenum,GLuint);
|
||||
|
||||
#if defined(_GLFW_WIN32)
|
||||
#define EGLAPIENTRY __stdcall
|
||||
#else
|
||||
#define EGLAPIENTRY
|
||||
#endif
|
||||
|
||||
#define EGL_SUCCESS 0x3000
|
||||
#define EGL_NOT_INITIALIZED 0x3001
|
||||
#define EGL_BAD_ACCESS 0x3002
|
||||
#define EGL_BAD_ALLOC 0x3003
|
||||
#define EGL_BAD_ATTRIBUTE 0x3004
|
||||
#define EGL_BAD_CONFIG 0x3005
|
||||
#define EGL_BAD_CONTEXT 0x3006
|
||||
#define EGL_BAD_CURRENT_SURFACE 0x3007
|
||||
#define EGL_BAD_DISPLAY 0x3008
|
||||
#define EGL_BAD_MATCH 0x3009
|
||||
#define EGL_BAD_NATIVE_PIXMAP 0x300a
|
||||
#define EGL_BAD_NATIVE_WINDOW 0x300b
|
||||
#define EGL_BAD_PARAMETER 0x300c
|
||||
#define EGL_BAD_SURFACE 0x300d
|
||||
#define EGL_CONTEXT_LOST 0x300e
|
||||
#define EGL_COLOR_BUFFER_TYPE 0x303f
|
||||
#define EGL_RGB_BUFFER 0x308e
|
||||
#define EGL_SURFACE_TYPE 0x3033
|
||||
#define EGL_WINDOW_BIT 0x0004
|
||||
#define EGL_RENDERABLE_TYPE 0x3040
|
||||
#define EGL_OPENGL_ES_BIT 0x0001
|
||||
#define EGL_OPENGL_ES2_BIT 0x0004
|
||||
#define EGL_OPENGL_BIT 0x0008
|
||||
#define EGL_ALPHA_SIZE 0x3021
|
||||
#define EGL_BLUE_SIZE 0x3022
|
||||
#define EGL_GREEN_SIZE 0x3023
|
||||
#define EGL_RED_SIZE 0x3024
|
||||
#define EGL_DEPTH_SIZE 0x3025
|
||||
#define EGL_STENCIL_SIZE 0x3026
|
||||
#define EGL_SAMPLES 0x3031
|
||||
#define EGL_OPENGL_ES_API 0x30a0
|
||||
#define EGL_OPENGL_API 0x30a2
|
||||
#define EGL_NONE 0x3038
|
||||
#define EGL_RENDER_BUFFER 0x3086
|
||||
#define EGL_SINGLE_BUFFER 0x3085
|
||||
#define EGL_EXTENSIONS 0x3055
|
||||
#define EGL_CONTEXT_CLIENT_VERSION 0x3098
|
||||
#define EGL_NATIVE_VISUAL_ID 0x302e
|
||||
#define EGL_NO_SURFACE ((EGLSurface) 0)
|
||||
#define EGL_NO_DISPLAY ((EGLDisplay) 0)
|
||||
#define EGL_NO_CONTEXT ((EGLContext) 0)
|
||||
#define EGL_DEFAULT_DISPLAY ((EGLNativeDisplayType) 0)
|
||||
#define EGL_PBUFFER_BIT 0x0001
|
||||
#define EGL_HEIGHT 0x3056
|
||||
#define EGL_WIDTH 0x3057
|
||||
|
||||
#define EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR 0x00000002
|
||||
#define EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR 0x00000001
|
||||
#define EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR 0x00000002
|
||||
#define EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR 0x00000001
|
||||
#define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR 0x31bd
|
||||
#define EGL_NO_RESET_NOTIFICATION_KHR 0x31be
|
||||
#define EGL_LOSE_CONTEXT_ON_RESET_KHR 0x31bf
|
||||
#define EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR 0x00000004
|
||||
#define EGL_CONTEXT_MAJOR_VERSION_KHR 0x3098
|
||||
#define EGL_CONTEXT_MINOR_VERSION_KHR 0x30fb
|
||||
#define EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR 0x30fd
|
||||
#define EGL_CONTEXT_FLAGS_KHR 0x30fc
|
||||
#define EGL_CONTEXT_OPENGL_NO_ERROR_KHR 0x31b3
|
||||
#define EGL_GL_COLORSPACE_KHR 0x309d
|
||||
#define EGL_GL_COLORSPACE_SRGB_KHR 0x3089
|
||||
#define EGL_CONTEXT_RELEASE_BEHAVIOR_KHR 0x2097
|
||||
#define EGL_CONTEXT_RELEASE_BEHAVIOR_NONE_KHR 0
|
||||
#define EGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_KHR 0x2098
|
||||
#define EGL_PLATFORM_X11_EXT 0x31d5
|
||||
#define EGL_PLATFORM_WAYLAND_EXT 0x31d8
|
||||
#define EGL_PRESENT_OPAQUE_EXT 0x31df
|
||||
#define EGL_PLATFORM_ANGLE_ANGLE 0x3202
|
||||
#define EGL_PLATFORM_ANGLE_TYPE_ANGLE 0x3203
|
||||
#define EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE 0x320d
|
||||
#define EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE 0x320e
|
||||
#define EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE 0x3207
|
||||
#define EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE 0x3208
|
||||
#define EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE 0x3450
|
||||
#define EGL_PLATFORM_ANGLE_TYPE_METAL_ANGLE 0x3489
|
||||
#define EGL_PLATFORM_ANGLE_NATIVE_PLATFORM_TYPE_ANGLE 0x348f
|
||||
|
||||
typedef int EGLint;
|
||||
typedef unsigned int EGLBoolean;
|
||||
typedef unsigned int EGLenum;
|
||||
typedef void* EGLConfig;
|
||||
typedef void* EGLContext;
|
||||
typedef void* EGLDisplay;
|
||||
typedef void* EGLSurface;
|
||||
|
||||
typedef void* EGLNativeDisplayType;
|
||||
typedef void* EGLNativeWindowType;
|
||||
|
||||
// EGL function pointer typedefs
|
||||
typedef EGLBoolean (EGLAPIENTRY * PFN_eglGetConfigAttrib)(EGLDisplay,EGLConfig,EGLint,EGLint*);
|
||||
typedef EGLBoolean (EGLAPIENTRY * PFN_eglGetConfigs)(EGLDisplay,EGLConfig*,EGLint,EGLint*);
|
||||
typedef EGLDisplay (EGLAPIENTRY * PFN_eglGetDisplay)(EGLNativeDisplayType);
|
||||
typedef EGLint (EGLAPIENTRY * PFN_eglGetError)(void);
|
||||
typedef EGLBoolean (EGLAPIENTRY * PFN_eglInitialize)(EGLDisplay,EGLint*,EGLint*);
|
||||
typedef EGLBoolean (EGLAPIENTRY * PFN_eglTerminate)(EGLDisplay);
|
||||
typedef EGLBoolean (EGLAPIENTRY * PFN_eglBindAPI)(EGLenum);
|
||||
typedef EGLContext (EGLAPIENTRY * PFN_eglCreateContext)(EGLDisplay,EGLConfig,EGLContext,const EGLint*);
|
||||
typedef EGLBoolean (EGLAPIENTRY * PFN_eglDestroySurface)(EGLDisplay,EGLSurface);
|
||||
typedef EGLBoolean (EGLAPIENTRY * PFN_eglDestroyContext)(EGLDisplay,EGLContext);
|
||||
typedef EGLSurface (EGLAPIENTRY * PFN_eglCreateWindowSurface)(EGLDisplay,EGLConfig,EGLNativeWindowType,const EGLint*);
|
||||
typedef EGLBoolean (EGLAPIENTRY * PFN_eglMakeCurrent)(EGLDisplay,EGLSurface,EGLSurface,EGLContext);
|
||||
typedef EGLBoolean (EGLAPIENTRY * PFN_eglSwapBuffers)(EGLDisplay,EGLSurface);
|
||||
typedef EGLBoolean (EGLAPIENTRY * PFN_eglSwapInterval)(EGLDisplay,EGLint);
|
||||
typedef const char* (EGLAPIENTRY * PFN_eglQueryString)(EGLDisplay,EGLint);
|
||||
typedef GLFWglproc (EGLAPIENTRY * PFN_eglGetProcAddress)(const char*);
|
||||
typedef EGLSurface (EGLAPIENTRY * PFN_eglCreatePbufferSurface)(EGLDisplay,EGLConfig,const EGLint*);
|
||||
typedef EGLBoolean (EGLAPIENTRY * PFN_eglChooseConfig)(EGLDisplay,EGLint const*,EGLConfig*,EGLint,EGLint*);
|
||||
#define eglGetConfigAttrib _glfw.egl.GetConfigAttrib
|
||||
#define eglGetConfigs _glfw.egl.GetConfigs
|
||||
#define eglGetDisplay _glfw.egl.GetDisplay
|
||||
#define eglGetError _glfw.egl.GetError
|
||||
#define eglInitialize _glfw.egl.Initialize
|
||||
#define eglTerminate _glfw.egl.Terminate
|
||||
#define eglBindAPI _glfw.egl.BindAPI
|
||||
#define eglCreateContext _glfw.egl.CreateContext
|
||||
#define eglDestroySurface _glfw.egl.DestroySurface
|
||||
#define eglDestroyContext _glfw.egl.DestroyContext
|
||||
#define eglCreateWindowSurface _glfw.egl.CreateWindowSurface
|
||||
#define eglMakeCurrent _glfw.egl.MakeCurrent
|
||||
#define eglSwapBuffers _glfw.egl.SwapBuffers
|
||||
#define eglSwapInterval _glfw.egl.SwapInterval
|
||||
#define eglQueryString _glfw.egl.QueryString
|
||||
#define eglGetProcAddress _glfw.egl.GetProcAddress
|
||||
#define eglCreatePbufferSurface _glfw.egl.CreatePbufferSurface
|
||||
#define eglChooseConfig _glfw.egl.ChooseConfig
|
||||
|
||||
typedef EGLDisplay (EGLAPIENTRY * PFNEGLGETPLATFORMDISPLAYEXTPROC)(EGLenum,void*,const EGLint*);
|
||||
typedef EGLSurface (EGLAPIENTRY * PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC)(EGLDisplay,EGLConfig,void*,const EGLint*);
|
||||
#define eglGetPlatformDisplayEXT _glfw.egl.GetPlatformDisplayEXT
|
||||
#define eglCreatePlatformWindowSurfaceEXT _glfw.egl.CreatePlatformWindowSurfaceEXT
|
||||
|
||||
#define OSMESA_RGBA 0x1908
|
||||
#define OSMESA_FORMAT 0x22
|
||||
#define OSMESA_DEPTH_BITS 0x30
|
||||
#define OSMESA_STENCIL_BITS 0x31
|
||||
#define OSMESA_ACCUM_BITS 0x32
|
||||
#define OSMESA_PROFILE 0x33
|
||||
#define OSMESA_CORE_PROFILE 0x34
|
||||
#define OSMESA_COMPAT_PROFILE 0x35
|
||||
#define OSMESA_CONTEXT_MAJOR_VERSION 0x36
|
||||
#define OSMESA_CONTEXT_MINOR_VERSION 0x37
|
||||
|
||||
typedef void* OSMesaContext;
|
||||
typedef void (*OSMESAproc)(void);
|
||||
|
||||
typedef OSMesaContext (GLAPIENTRY * PFN_OSMesaCreateContextExt)(GLenum,GLint,GLint,GLint,OSMesaContext);
|
||||
typedef OSMesaContext (GLAPIENTRY * PFN_OSMesaCreateContextAttribs)(const int*,OSMesaContext);
|
||||
typedef void (GLAPIENTRY * PFN_OSMesaDestroyContext)(OSMesaContext);
|
||||
typedef int (GLAPIENTRY * PFN_OSMesaMakeCurrent)(OSMesaContext,void*,int,int,int);
|
||||
typedef int (GLAPIENTRY * PFN_OSMesaGetColorBuffer)(OSMesaContext,int*,int*,int*,void**);
|
||||
typedef int (GLAPIENTRY * PFN_OSMesaGetDepthBuffer)(OSMesaContext,int*,int*,int*,void**);
|
||||
typedef GLFWglproc (GLAPIENTRY * PFN_OSMesaGetProcAddress)(const char*);
|
||||
#define OSMesaCreateContextExt _glfw.osmesa.CreateContextExt
|
||||
#define OSMesaCreateContextAttribs _glfw.osmesa.CreateContextAttribs
|
||||
#define OSMesaDestroyContext _glfw.osmesa.DestroyContext
|
||||
#define OSMesaMakeCurrent _glfw.osmesa.MakeCurrent
|
||||
#define OSMesaGetColorBuffer _glfw.osmesa.GetColorBuffer
|
||||
#define OSMesaGetDepthBuffer _glfw.osmesa.GetDepthBuffer
|
||||
#define OSMesaGetProcAddress _glfw.osmesa.GetProcAddress
|
||||
|
||||
#define VK_NULL_HANDLE 0
|
||||
|
||||
typedef void* VkInstance;
|
||||
@ -173,32 +332,11 @@ typedef struct VkExtensionProperties
|
||||
|
||||
typedef void (APIENTRY * PFN_vkVoidFunction)(void);
|
||||
|
||||
#if defined(_GLFW_VULKAN_STATIC)
|
||||
PFN_vkVoidFunction vkGetInstanceProcAddr(VkInstance,const char*);
|
||||
VkResult vkEnumerateInstanceExtensionProperties(const char*,uint32_t*,VkExtensionProperties*);
|
||||
#else
|
||||
typedef PFN_vkVoidFunction (APIENTRY * PFN_vkGetInstanceProcAddr)(VkInstance,const char*);
|
||||
typedef VkResult (APIENTRY * PFN_vkEnumerateInstanceExtensionProperties)(const char*,uint32_t*,VkExtensionProperties*);
|
||||
#define vkEnumerateInstanceExtensionProperties _glfw.vk.EnumerateInstanceExtensionProperties
|
||||
#define vkGetInstanceProcAddr _glfw.vk.GetInstanceProcAddr
|
||||
#endif
|
||||
typedef PFN_vkVoidFunction (APIENTRY * PFN_vkGetInstanceProcAddr)(VkInstance,const char*);
|
||||
typedef VkResult (APIENTRY * PFN_vkEnumerateInstanceExtensionProperties)(const char*,uint32_t*,VkExtensionProperties*);
|
||||
#define vkGetInstanceProcAddr _glfw.vk.GetInstanceProcAddr
|
||||
|
||||
#if defined(_GLFW_COCOA)
|
||||
#include "cocoa_platform.h"
|
||||
#elif defined(_GLFW_WIN32)
|
||||
#include "win32_platform.h"
|
||||
#elif defined(_GLFW_X11)
|
||||
#include "x11_platform.h"
|
||||
#elif defined(_GLFW_WAYLAND)
|
||||
#include "wl_platform.h"
|
||||
#elif defined(_GLFW_OSMESA)
|
||||
#include "null_platform.h"
|
||||
#else
|
||||
#error "No supported window creation API selected"
|
||||
#endif
|
||||
|
||||
#include "egl_context.h"
|
||||
#include "osmesa_context.h"
|
||||
#include "platform.h"
|
||||
|
||||
// Constructs a version number string from the public header macros
|
||||
#define _GLFW_CONCAT_VERSION(m, n, r) #m "." #n "." #r
|
||||
@ -222,12 +360,12 @@ typedef void (APIENTRY * PFN_vkVoidFunction)(void);
|
||||
}
|
||||
|
||||
// Swaps the provided pointers
|
||||
#define _GLFW_SWAP_POINTERS(x, y) \
|
||||
{ \
|
||||
void* t; \
|
||||
t = x; \
|
||||
x = y; \
|
||||
y = t; \
|
||||
#define _GLFW_SWAP(type, x, y) \
|
||||
{ \
|
||||
type t; \
|
||||
t = x; \
|
||||
x = y; \
|
||||
y = t; \
|
||||
}
|
||||
|
||||
// Per-thread error structure
|
||||
@ -247,6 +385,8 @@ struct _GLFWinitconfig
|
||||
{
|
||||
GLFWbool hatButtons;
|
||||
int angleType;
|
||||
int platformID;
|
||||
PFN_vkGetInstanceProcAddr vulkanLoader;
|
||||
struct {
|
||||
GLFWbool menubar;
|
||||
GLFWbool chdir;
|
||||
@ -360,19 +500,29 @@ struct _GLFWcontext
|
||||
PFNGLGETINTEGERVPROC GetIntegerv;
|
||||
PFNGLGETSTRINGPROC GetString;
|
||||
|
||||
_GLFWmakecontextcurrentfun makeCurrent;
|
||||
_GLFWswapbuffersfun swapBuffers;
|
||||
_GLFWswapintervalfun swapInterval;
|
||||
_GLFWextensionsupportedfun extensionSupported;
|
||||
_GLFWgetprocaddressfun getProcAddress;
|
||||
_GLFWdestroycontextfun destroy;
|
||||
void (*makeCurrent)(_GLFWwindow*);
|
||||
void (*swapBuffers)(_GLFWwindow*);
|
||||
void (*swapInterval)(int);
|
||||
int (*extensionSupported)(const char*);
|
||||
GLFWglproc (*getProcAddress)(const char*);
|
||||
void (*destroy)(_GLFWwindow*);
|
||||
|
||||
// This is defined in the context API's context.h
|
||||
_GLFW_PLATFORM_CONTEXT_STATE;
|
||||
// This is defined in egl_context.h
|
||||
_GLFWcontextEGL egl;
|
||||
// This is defined in osmesa_context.h
|
||||
_GLFWcontextOSMesa osmesa;
|
||||
struct {
|
||||
EGLConfig config;
|
||||
EGLContext handle;
|
||||
EGLSurface surface;
|
||||
void* client;
|
||||
} egl;
|
||||
|
||||
struct {
|
||||
OSMesaContext handle;
|
||||
int width;
|
||||
int height;
|
||||
void* buffer;
|
||||
} osmesa;
|
||||
|
||||
// This is defined in platform.h
|
||||
GLFW_PLATFORM_CONTEXT_STATE
|
||||
};
|
||||
|
||||
|
||||
@ -382,15 +532,20 @@ struct _GLFWusercontext
|
||||
{
|
||||
_GLFWwindow* window;
|
||||
|
||||
// This is defined in the context API's context.h
|
||||
_GLFW_PLATFORM_USER_CONTEXT_STATE;
|
||||
// This is defined in egl_context.h
|
||||
_GLFWusercontextEGL egl;
|
||||
// This is defined in osmesa_context.h
|
||||
_GLFWusercontextOSMesa osmesa;
|
||||
void (*makeCurrent)(_GLFWusercontext* context);
|
||||
void (*destroy)(_GLFWusercontext* context);
|
||||
|
||||
_GLFWmakeusercontextcurrentfun makeCurrent;
|
||||
_GLFWdestroyusercontextfun destroy;
|
||||
struct {
|
||||
EGLContext handle;
|
||||
EGLSurface surface;
|
||||
} egl;
|
||||
|
||||
struct {
|
||||
OSMesaContext handle;
|
||||
} osmesa;
|
||||
|
||||
// This is defined in platform.h
|
||||
GLFW_PLATFORM_USER_CONTEXT_STATE
|
||||
};
|
||||
|
||||
// Window and context structure
|
||||
@ -449,8 +604,8 @@ struct _GLFWwindow
|
||||
GLFWdropfun drop;
|
||||
} callbacks;
|
||||
|
||||
// This is defined in the window API's platform.h
|
||||
_GLFW_PLATFORM_WINDOW_STATE;
|
||||
// This is defined in platform.h
|
||||
GLFW_PLATFORM_WINDOW_STATE
|
||||
};
|
||||
|
||||
// Monitor structure
|
||||
@ -473,8 +628,8 @@ struct _GLFWmonitor
|
||||
GLFWgammaramp originalRamp;
|
||||
GLFWgammaramp currentRamp;
|
||||
|
||||
// This is defined in the window API's platform.h
|
||||
_GLFW_PLATFORM_MONITOR_STATE;
|
||||
// This is defined in platform.h
|
||||
GLFW_PLATFORM_MONITOR_STATE
|
||||
};
|
||||
|
||||
// Cursor structure
|
||||
@ -482,9 +637,8 @@ struct _GLFWmonitor
|
||||
struct _GLFWcursor
|
||||
{
|
||||
_GLFWcursor* next;
|
||||
|
||||
// This is defined in the window API's platform.h
|
||||
_GLFW_PLATFORM_CURSOR_STATE;
|
||||
// This is defined in platform.h
|
||||
GLFW_PLATFORM_CURSOR_STATE
|
||||
};
|
||||
|
||||
// Gamepad mapping element structure
|
||||
@ -523,24 +677,109 @@ struct _GLFWjoystick
|
||||
char guid[33];
|
||||
_GLFWmapping* mapping;
|
||||
|
||||
// This is defined in the joystick API's joystick.h
|
||||
_GLFW_PLATFORM_JOYSTICK_STATE;
|
||||
// This is defined in platform.h
|
||||
GLFW_PLATFORM_JOYSTICK_STATE
|
||||
};
|
||||
|
||||
// Thread local storage structure
|
||||
//
|
||||
struct _GLFWtls
|
||||
{
|
||||
// This is defined in the platform's thread.h
|
||||
_GLFW_PLATFORM_TLS_STATE;
|
||||
// This is defined in platform.h
|
||||
GLFW_PLATFORM_TLS_STATE
|
||||
};
|
||||
|
||||
// Mutex structure
|
||||
//
|
||||
struct _GLFWmutex
|
||||
{
|
||||
// This is defined in the platform's thread.h
|
||||
_GLFW_PLATFORM_MUTEX_STATE;
|
||||
// This is defined in platform.h
|
||||
GLFW_PLATFORM_MUTEX_STATE
|
||||
};
|
||||
|
||||
// Platform API structure
|
||||
//
|
||||
struct _GLFWplatform
|
||||
{
|
||||
int platformID;
|
||||
// init
|
||||
GLFWbool (*init)(void);
|
||||
void (*terminate)(void);
|
||||
// input
|
||||
void (*getCursorPos)(_GLFWwindow*,double*,double*);
|
||||
void (*setCursorPos)(_GLFWwindow*,double,double);
|
||||
void (*setCursorMode)(_GLFWwindow*,int);
|
||||
void (*setRawMouseMotion)(_GLFWwindow*,GLFWbool);
|
||||
GLFWbool (*rawMouseMotionSupported)(void);
|
||||
int (*createCursor)(_GLFWcursor*,const GLFWimage*,int,int);
|
||||
int (*createStandardCursor)(_GLFWcursor*,int);
|
||||
void (*destroyCursor)(_GLFWcursor*);
|
||||
void (*setCursor)(_GLFWwindow*,_GLFWcursor*);
|
||||
const char* (*getScancodeName)(int);
|
||||
int (*getKeyScancode)(int);
|
||||
void (*setClipboardString)(const char*);
|
||||
const char* (*getClipboardString)(void);
|
||||
GLFWbool (*initJoysticks)(void);
|
||||
void (*terminateJoysticks)(void);
|
||||
int (*pollJoystick)(_GLFWjoystick*,int);
|
||||
const char* (*getMappingName)(void);
|
||||
void (*updateGamepadGUID)(char*);
|
||||
// monitor
|
||||
void (*freeMonitor)(_GLFWmonitor*);
|
||||
void (*getMonitorPos)(_GLFWmonitor*,int*,int*);
|
||||
void (*getMonitorContentScale)(_GLFWmonitor*,float*,float*);
|
||||
void (*getMonitorWorkarea)(_GLFWmonitor*,int*,int*,int*,int*);
|
||||
GLFWvidmode* (*getVideoModes)(_GLFWmonitor*,int*);
|
||||
void (*getVideoMode)(_GLFWmonitor*,GLFWvidmode*);
|
||||
GLFWbool (*getGammaRamp)(_GLFWmonitor*,GLFWgammaramp*);
|
||||
void (*setGammaRamp)(_GLFWmonitor*,const GLFWgammaramp*);
|
||||
// window
|
||||
int (*createWindow)(_GLFWwindow*,const _GLFWwndconfig*,const _GLFWctxconfig*,const _GLFWfbconfig*);
|
||||
void (*destroyWindow)(_GLFWwindow*);
|
||||
void (*setWindowTitle)(_GLFWwindow*,const char*);
|
||||
void (*setWindowIcon)(_GLFWwindow*,int,const GLFWimage*);
|
||||
void (*getWindowPos)(_GLFWwindow*,int*,int*);
|
||||
void (*setWindowPos)(_GLFWwindow*,int,int);
|
||||
void (*getWindowSize)(_GLFWwindow*,int*,int*);
|
||||
void (*setWindowSize)(_GLFWwindow*,int,int);
|
||||
void (*setWindowSizeLimits)(_GLFWwindow*,int,int,int,int);
|
||||
void (*setWindowAspectRatio)(_GLFWwindow*,int,int);
|
||||
void (*getFramebufferSize)(_GLFWwindow*,int*,int*);
|
||||
void (*getWindowFrameSize)(_GLFWwindow*,int*,int*,int*,int*);
|
||||
void (*getWindowContentScale)(_GLFWwindow*,float*,float*);
|
||||
void (*iconifyWindow)(_GLFWwindow*);
|
||||
void (*restoreWindow)(_GLFWwindow*);
|
||||
void (*maximizeWindow)(_GLFWwindow*);
|
||||
void (*showWindow)(_GLFWwindow*);
|
||||
void (*hideWindow)(_GLFWwindow*);
|
||||
void (*requestWindowAttention)(_GLFWwindow*);
|
||||
void (*focusWindow)(_GLFWwindow*);
|
||||
void (*setWindowMonitor)(_GLFWwindow*,_GLFWmonitor*,int,int,int,int,int);
|
||||
int (*windowFocused)(_GLFWwindow*);
|
||||
int (*windowIconified)(_GLFWwindow*);
|
||||
int (*windowVisible)(_GLFWwindow*);
|
||||
int (*windowMaximized)(_GLFWwindow*);
|
||||
int (*windowHovered)(_GLFWwindow*);
|
||||
int (*framebufferTransparent)(_GLFWwindow*);
|
||||
float (*getWindowOpacity)(_GLFWwindow*);
|
||||
void (*setWindowResizable)(_GLFWwindow*,GLFWbool);
|
||||
void (*setWindowDecorated)(_GLFWwindow*,GLFWbool);
|
||||
void (*setWindowFloating)(_GLFWwindow*,GLFWbool);
|
||||
void (*setWindowOpacity)(_GLFWwindow*,float);
|
||||
void (*setWindowMousePassthrough)(_GLFWwindow*,GLFWbool);
|
||||
void (*pollEvents)(void);
|
||||
void (*waitEvents)(void);
|
||||
void (*waitEventsTimeout)(double);
|
||||
void (*postEmptyEvent)(void);
|
||||
_GLFWusercontext* (*createUserContext)(_GLFWwindow*);
|
||||
// EGL
|
||||
EGLenum (*getEGLPlatform)(EGLint**);
|
||||
EGLNativeDisplayType (*getEGLNativeDisplay)(void);
|
||||
EGLNativeWindowType (*getEGLNativeWindow)(_GLFWwindow*);
|
||||
// vulkan
|
||||
void (*getRequiredInstanceExtensions)(char**);
|
||||
int (*getPhysicalDevicePresentationSupport)(VkInstance,VkPhysicalDevice,uint32_t);
|
||||
VkResult (*createWindowSurface)(VkInstance,_GLFWwindow*,const VkAllocationCallbacks*,VkSurfaceKHR*);
|
||||
};
|
||||
|
||||
// Library global data
|
||||
@ -550,6 +789,8 @@ struct _GLFWlibrary
|
||||
GLFWbool initialized;
|
||||
GLFWallocator allocator;
|
||||
|
||||
_GLFWplatform platform;
|
||||
|
||||
struct {
|
||||
_GLFWinitconfig init;
|
||||
_GLFWfbconfig framebuffer;
|
||||
@ -577,30 +818,82 @@ struct _GLFWlibrary
|
||||
|
||||
struct {
|
||||
uint64_t offset;
|
||||
// This is defined in the platform's time.h
|
||||
_GLFW_PLATFORM_LIBRARY_TIMER_STATE;
|
||||
// This is defined in platform.h
|
||||
GLFW_PLATFORM_LIBRARY_TIMER_STATE
|
||||
} timer;
|
||||
|
||||
struct {
|
||||
EGLenum platform;
|
||||
EGLDisplay display;
|
||||
EGLint major, minor;
|
||||
GLFWbool prefix;
|
||||
|
||||
GLFWbool KHR_create_context;
|
||||
GLFWbool KHR_create_context_no_error;
|
||||
GLFWbool KHR_gl_colorspace;
|
||||
GLFWbool KHR_get_all_proc_addresses;
|
||||
GLFWbool KHR_context_flush_control;
|
||||
GLFWbool EXT_client_extensions;
|
||||
GLFWbool EXT_platform_base;
|
||||
GLFWbool EXT_platform_x11;
|
||||
GLFWbool EXT_platform_wayland;
|
||||
GLFWbool EXT_present_opaque;
|
||||
GLFWbool ANGLE_platform_angle;
|
||||
GLFWbool ANGLE_platform_angle_opengl;
|
||||
GLFWbool ANGLE_platform_angle_d3d;
|
||||
GLFWbool ANGLE_platform_angle_vulkan;
|
||||
GLFWbool ANGLE_platform_angle_metal;
|
||||
|
||||
void* handle;
|
||||
|
||||
PFN_eglGetConfigAttrib GetConfigAttrib;
|
||||
PFN_eglGetConfigs GetConfigs;
|
||||
PFN_eglGetDisplay GetDisplay;
|
||||
PFN_eglGetError GetError;
|
||||
PFN_eglInitialize Initialize;
|
||||
PFN_eglTerminate Terminate;
|
||||
PFN_eglBindAPI BindAPI;
|
||||
PFN_eglCreateContext CreateContext;
|
||||
PFN_eglDestroySurface DestroySurface;
|
||||
PFN_eglDestroyContext DestroyContext;
|
||||
PFN_eglCreateWindowSurface CreateWindowSurface;
|
||||
PFN_eglMakeCurrent MakeCurrent;
|
||||
PFN_eglSwapBuffers SwapBuffers;
|
||||
PFN_eglSwapInterval SwapInterval;
|
||||
PFN_eglQueryString QueryString;
|
||||
PFN_eglGetProcAddress GetProcAddress;
|
||||
PFN_eglCreatePbufferSurface CreatePbufferSurface;
|
||||
PFN_eglChooseConfig ChooseConfig;
|
||||
|
||||
PFNEGLGETPLATFORMDISPLAYEXTPROC GetPlatformDisplayEXT;
|
||||
PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC CreatePlatformWindowSurfaceEXT;
|
||||
} egl;
|
||||
|
||||
struct {
|
||||
void* handle;
|
||||
|
||||
PFN_OSMesaCreateContextExt CreateContextExt;
|
||||
PFN_OSMesaCreateContextAttribs CreateContextAttribs;
|
||||
PFN_OSMesaDestroyContext DestroyContext;
|
||||
PFN_OSMesaMakeCurrent MakeCurrent;
|
||||
PFN_OSMesaGetColorBuffer GetColorBuffer;
|
||||
PFN_OSMesaGetDepthBuffer GetDepthBuffer;
|
||||
PFN_OSMesaGetProcAddress GetProcAddress;
|
||||
|
||||
} osmesa;
|
||||
|
||||
struct {
|
||||
GLFWbool available;
|
||||
void* handle;
|
||||
char* extensions[2];
|
||||
#if !defined(_GLFW_VULKAN_STATIC)
|
||||
PFN_vkEnumerateInstanceExtensionProperties EnumerateInstanceExtensionProperties;
|
||||
PFN_vkGetInstanceProcAddr GetInstanceProcAddr;
|
||||
#endif
|
||||
GLFWbool KHR_surface;
|
||||
#if defined(_GLFW_WIN32)
|
||||
GLFWbool KHR_win32_surface;
|
||||
#elif defined(_GLFW_COCOA)
|
||||
GLFWbool MVK_macos_surface;
|
||||
GLFWbool EXT_metal_surface;
|
||||
#elif defined(_GLFW_X11)
|
||||
GLFWbool KHR_xlib_surface;
|
||||
GLFWbool KHR_xcb_surface;
|
||||
#elif defined(_GLFW_WAYLAND)
|
||||
GLFWbool KHR_wayland_surface;
|
||||
#endif
|
||||
} vk;
|
||||
|
||||
struct {
|
||||
@ -608,16 +901,10 @@ struct _GLFWlibrary
|
||||
GLFWjoystickfun joystick;
|
||||
} callbacks;
|
||||
|
||||
// This is defined in the window API's platform.h
|
||||
_GLFW_PLATFORM_LIBRARY_WINDOW_STATE;
|
||||
// This is defined in the context API's context.h
|
||||
_GLFW_PLATFORM_LIBRARY_CONTEXT_STATE;
|
||||
// This is defined in the platform's joystick.h
|
||||
_GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE;
|
||||
// This is defined in egl_context.h
|
||||
_GLFWlibraryEGL egl;
|
||||
// This is defined in osmesa_context.h
|
||||
_GLFWlibraryOSMesa osmesa;
|
||||
// These are defined in platform.h
|
||||
GLFW_PLATFORM_LIBRARY_WINDOW_STATE
|
||||
GLFW_PLATFORM_LIBRARY_CONTEXT_STATE
|
||||
GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE
|
||||
};
|
||||
|
||||
// Global state shared between compilation units of GLFW
|
||||
@ -629,110 +916,10 @@ extern _GLFWlibrary _glfw;
|
||||
////// GLFW platform API //////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int _glfwPlatformInit(void);
|
||||
void _glfwPlatformTerminate(void);
|
||||
const char* _glfwPlatformGetVersionString(void);
|
||||
|
||||
void _glfwPlatformGetCursorPos(_GLFWwindow* window, double* xpos, double* ypos);
|
||||
void _glfwPlatformSetCursorPos(_GLFWwindow* window, double xpos, double ypos);
|
||||
void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode);
|
||||
void _glfwPlatformSetRawMouseMotion(_GLFWwindow *window, GLFWbool enabled);
|
||||
GLFWbool _glfwPlatformRawMouseMotionSupported(void);
|
||||
int _glfwPlatformCreateCursor(_GLFWcursor* cursor,
|
||||
const GLFWimage* image, int xhot, int yhot);
|
||||
int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape);
|
||||
void _glfwPlatformDestroyCursor(_GLFWcursor* cursor);
|
||||
void _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor);
|
||||
|
||||
const char* _glfwPlatformGetScancodeName(int scancode);
|
||||
int _glfwPlatformGetKeyScancode(int key);
|
||||
|
||||
void _glfwPlatformFreeMonitor(_GLFWmonitor* monitor);
|
||||
void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos);
|
||||
void _glfwPlatformGetMonitorContentScale(_GLFWmonitor* monitor,
|
||||
float* xscale, float* yscale);
|
||||
void _glfwPlatformGetMonitorWorkarea(_GLFWmonitor* monitor, int* xpos, int* ypos, int *width, int *height);
|
||||
GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* count);
|
||||
void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode);
|
||||
GLFWbool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp);
|
||||
void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp);
|
||||
|
||||
void _glfwPlatformSetClipboardString(const char* string);
|
||||
const char* _glfwPlatformGetClipboardString(void);
|
||||
|
||||
GLFWbool _glfwPlatformInitJoysticks(void);
|
||||
void _glfwPlatformTerminateJoysticks(void);
|
||||
int _glfwPlatformPollJoystick(_GLFWjoystick* js, int mode);
|
||||
void _glfwPlatformUpdateGamepadGUID(char* guid);
|
||||
|
||||
void _glfwPlatformInitTimer(void);
|
||||
uint64_t _glfwPlatformGetTimerValue(void);
|
||||
uint64_t _glfwPlatformGetTimerFrequency(void);
|
||||
|
||||
int _glfwPlatformCreateWindow(_GLFWwindow* window,
|
||||
const _GLFWwndconfig* wndconfig,
|
||||
const _GLFWctxconfig* ctxconfig,
|
||||
const _GLFWfbconfig* fbconfig);
|
||||
void _glfwPlatformDestroyWindow(_GLFWwindow* window);
|
||||
void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title);
|
||||
void _glfwPlatformSetWindowIcon(_GLFWwindow* window,
|
||||
int count, const GLFWimage* images);
|
||||
void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos);
|
||||
void _glfwPlatformSetWindowPos(_GLFWwindow* window, int xpos, int ypos);
|
||||
void _glfwPlatformGetWindowSize(_GLFWwindow* window, int* width, int* height);
|
||||
void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height);
|
||||
void _glfwPlatformSetWindowSizeLimits(_GLFWwindow* window,
|
||||
int minwidth, int minheight,
|
||||
int maxwidth, int maxheight);
|
||||
void _glfwPlatformSetWindowAspectRatio(_GLFWwindow* window, int numer, int denom);
|
||||
void _glfwPlatformGetFramebufferSize(_GLFWwindow* window, int* width, int* height);
|
||||
void _glfwPlatformGetWindowFrameSize(_GLFWwindow* window,
|
||||
int* left, int* top,
|
||||
int* right, int* bottom);
|
||||
void _glfwPlatformGetWindowContentScale(_GLFWwindow* window,
|
||||
float* xscale, float* yscale);
|
||||
void _glfwPlatformIconifyWindow(_GLFWwindow* window);
|
||||
void _glfwPlatformRestoreWindow(_GLFWwindow* window);
|
||||
void _glfwPlatformMaximizeWindow(_GLFWwindow* window);
|
||||
void _glfwPlatformShowWindow(_GLFWwindow* window);
|
||||
void _glfwPlatformHideWindow(_GLFWwindow* window);
|
||||
void _glfwPlatformRequestWindowAttention(_GLFWwindow* window);
|
||||
void _glfwPlatformFocusWindow(_GLFWwindow* window);
|
||||
void _glfwPlatformSetWindowMonitor(_GLFWwindow* window, _GLFWmonitor* monitor,
|
||||
int xpos, int ypos, int width, int height,
|
||||
int refreshRate);
|
||||
int _glfwPlatformWindowFocused(_GLFWwindow* window);
|
||||
int _glfwPlatformWindowIconified(_GLFWwindow* window);
|
||||
int _glfwPlatformWindowVisible(_GLFWwindow* window);
|
||||
int _glfwPlatformWindowMaximized(_GLFWwindow* window);
|
||||
int _glfwPlatformWindowHovered(_GLFWwindow* window);
|
||||
int _glfwPlatformFramebufferTransparent(_GLFWwindow* window);
|
||||
float _glfwPlatformGetWindowOpacity(_GLFWwindow* window);
|
||||
void _glfwPlatformSetWindowResizable(_GLFWwindow* window, GLFWbool enabled);
|
||||
void _glfwPlatformSetWindowDecorated(_GLFWwindow* window, GLFWbool enabled);
|
||||
void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled);
|
||||
void _glfwPlatformSetWindowMousePassthrough(_GLFWwindow* window, GLFWbool enabled);
|
||||
void _glfwPlatformSetWindowOpacity(_GLFWwindow* window, float opacity);
|
||||
|
||||
void _glfwPlatformPollEvents(void);
|
||||
void _glfwPlatformWaitEvents(void);
|
||||
void _glfwPlatformWaitEventsTimeout(double timeout);
|
||||
void _glfwPlatformPostEmptyEvent(void);
|
||||
|
||||
_GLFWusercontext* _glfwPlatformCreateUserContext(_GLFWwindow* window);
|
||||
|
||||
EGLenum _glfwPlatformGetEGLPlatform(EGLint** attribs);
|
||||
EGLNativeDisplayType _glfwPlatformGetEGLNativeDisplay(void);
|
||||
EGLNativeWindowType _glfwPlatformGetEGLNativeWindow(_GLFWwindow* window);
|
||||
|
||||
void _glfwPlatformGetRequiredInstanceExtensions(char** extensions);
|
||||
int _glfwPlatformGetPhysicalDevicePresentationSupport(VkInstance instance,
|
||||
VkPhysicalDevice device,
|
||||
uint32_t queuefamily);
|
||||
VkResult _glfwPlatformCreateWindowSurface(VkInstance instance,
|
||||
_GLFWwindow* window,
|
||||
const VkAllocationCallbacks* allocator,
|
||||
VkSurfaceKHR* surface);
|
||||
|
||||
GLFWbool _glfwPlatformCreateTls(_GLFWtls* tls);
|
||||
void _glfwPlatformDestroyTls(_GLFWtls* tls);
|
||||
void* _glfwPlatformGetTls(_GLFWtls* tls);
|
||||
@ -743,6 +930,10 @@ void _glfwPlatformDestroyMutex(_GLFWmutex* mutex);
|
||||
void _glfwPlatformLockMutex(_GLFWmutex* mutex);
|
||||
void _glfwPlatformUnlockMutex(_GLFWmutex* mutex);
|
||||
|
||||
void* _glfwPlatformLoadModule(const char* path);
|
||||
void _glfwPlatformFreeModule(void* module);
|
||||
GLFWproc _glfwPlatformGetModuleSymbol(void* module, const char* name);
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
////// GLFW event API //////
|
||||
@ -763,7 +954,7 @@ void _glfwInputWindowMonitor(_GLFWwindow* window, _GLFWmonitor* monitor);
|
||||
void _glfwInputKey(_GLFWwindow* window,
|
||||
int key, int scancode, int action, int mods);
|
||||
void _glfwInputChar(_GLFWwindow* window,
|
||||
unsigned int codepoint, int mods, GLFWbool plain);
|
||||
uint32_t codepoint, int mods, GLFWbool plain);
|
||||
void _glfwInputScroll(_GLFWwindow* window, double xoffset, double yoffset);
|
||||
void _glfwInputMouseClick(_GLFWwindow* window, int button, int action, int mods);
|
||||
void _glfwInputCursorPos(_GLFWwindow* window, double xpos, double ypos);
|
||||
@ -789,6 +980,8 @@ void _glfwInputError(int code, const char* format, ...);
|
||||
////// GLFW internal API //////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
GLFWbool _glfwSelectPlatform(int platformID, _GLFWplatform* platform);
|
||||
|
||||
GLFWbool _glfwStringInExtensionString(const char* string, const char* extensions);
|
||||
const _GLFWfbconfig* _glfwChooseFBConfig(const _GLFWfbconfig* desired,
|
||||
const _GLFWfbconfig* alternatives,
|
||||
@ -815,11 +1008,35 @@ _GLFWjoystick* _glfwAllocJoystick(const char* name,
|
||||
void _glfwFreeJoystick(_GLFWjoystick* js);
|
||||
void _glfwCenterCursorInContentArea(_GLFWwindow* window);
|
||||
|
||||
GLFWbool _glfwInitEGL(void);
|
||||
void _glfwTerminateEGL(void);
|
||||
GLFWbool _glfwCreateContextEGL(_GLFWwindow* window,
|
||||
const _GLFWctxconfig* ctxconfig,
|
||||
const _GLFWfbconfig* fbconfig);
|
||||
_GLFWusercontext* _glfwCreateUserContextEGL(_GLFWwindow* window);
|
||||
#if defined(_GLFW_X11)
|
||||
GLFWbool _glfwChooseVisualEGL(const _GLFWwndconfig* wndconfig,
|
||||
const _GLFWctxconfig* ctxconfig,
|
||||
const _GLFWfbconfig* fbconfig,
|
||||
Visual** visual, int* depth);
|
||||
#endif /*_GLFW_X11*/
|
||||
|
||||
GLFWbool _glfwInitOSMesa(void);
|
||||
void _glfwTerminateOSMesa(void);
|
||||
GLFWbool _glfwCreateContextOSMesa(_GLFWwindow* window,
|
||||
const _GLFWctxconfig* ctxconfig,
|
||||
const _GLFWfbconfig* fbconfig);
|
||||
_GLFWusercontext* _glfwCreateUserContextOSMesa(_GLFWwindow* window);
|
||||
|
||||
GLFWbool _glfwInitVulkan(int mode);
|
||||
void _glfwTerminateVulkan(void);
|
||||
const char* _glfwGetVulkanResultString(VkResult result);
|
||||
|
||||
size_t _glfwEncodeUTF8(char* s, uint32_t codepoint);
|
||||
|
||||
char* _glfw_strdup(const char* source);
|
||||
int _glfw_min(int a, int b);
|
||||
int _glfw_max(int a, int b);
|
||||
float _glfw_fminf(float a, float b);
|
||||
float _glfw_fmaxf(float a, float b);
|
||||
|
||||
|
@ -307,7 +307,7 @@ void _glfwDetectJoystickConnectionLinux(void)
|
||||
////// GLFW platform API //////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
GLFWbool _glfwPlatformInitJoysticks(void)
|
||||
GLFWbool _glfwInitJoysticksLinux(void)
|
||||
{
|
||||
const char* dirname = "/dev/input";
|
||||
|
||||
@ -361,11 +361,9 @@ GLFWbool _glfwPlatformInitJoysticks(void)
|
||||
return GLFW_TRUE;
|
||||
}
|
||||
|
||||
void _glfwPlatformTerminateJoysticks(void)
|
||||
void _glfwTerminateJoysticksLinux(void)
|
||||
{
|
||||
int jid;
|
||||
|
||||
for (jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++)
|
||||
for (int jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++)
|
||||
{
|
||||
_GLFWjoystick* js = _glfw.joysticks + jid;
|
||||
if (js->present)
|
||||
@ -382,7 +380,7 @@ void _glfwPlatformTerminateJoysticks(void)
|
||||
}
|
||||
}
|
||||
|
||||
int _glfwPlatformPollJoystick(_GLFWjoystick* js, int mode)
|
||||
int _glfwPollJoystickLinux(_GLFWjoystick* js, int mode)
|
||||
{
|
||||
// Read all queued events (non-blocking)
|
||||
for (;;)
|
||||
@ -422,7 +420,12 @@ int _glfwPlatformPollJoystick(_GLFWjoystick* js, int mode)
|
||||
return js->present;
|
||||
}
|
||||
|
||||
void _glfwPlatformUpdateGamepadGUID(char* guid)
|
||||
const char* _glfwGetMappingNameLinux(void)
|
||||
{
|
||||
return "Linux";
|
||||
}
|
||||
|
||||
void _glfwUpdateGamepadGUIDLinux(char* guid)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -28,10 +28,9 @@
|
||||
#include <linux/limits.h>
|
||||
#include <regex.h>
|
||||
|
||||
#define _GLFW_PLATFORM_JOYSTICK_STATE _GLFWjoystickLinux linjs
|
||||
#define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE _GLFWlibraryLinux linjs
|
||||
#define GLFW_LINUX_JOYSTICK_STATE _GLFWjoystickLinux linjs;
|
||||
#define GLFW_LINUX_LIBRARY_JOYSTICK_STATE _GLFWlibraryLinux linjs;
|
||||
|
||||
#define _GLFW_PLATFORM_MAPPING_NAME "Linux"
|
||||
#define GLFW_BUILD_LINUX_MAPPINGS
|
||||
|
||||
// Linux-specific joystick data
|
||||
@ -58,3 +57,9 @@ typedef struct _GLFWlibraryLinux
|
||||
|
||||
void _glfwDetectJoystickConnectionLinux(void);
|
||||
|
||||
GLFWbool _glfwInitJoysticksLinux(void);
|
||||
void _glfwTerminateJoysticksLinux(void);
|
||||
int _glfwPollJoystickLinux(_GLFWjoystick* js, int mode);
|
||||
const char* _glfwGetMappingNameLinux(void);
|
||||
void _glfwUpdateGamepadGUIDLinux(char* guid);
|
||||
|
||||
|
@ -74,7 +74,7 @@ static GLFWbool refreshVideoModes(_GLFWmonitor* monitor)
|
||||
if (monitor->modes)
|
||||
return GLFW_TRUE;
|
||||
|
||||
modes = _glfwPlatformGetVideoModes(monitor, &modeCount);
|
||||
modes = _glfw.platform.getVideoModes(monitor, &modeCount);
|
||||
if (!modes)
|
||||
return GLFW_FALSE;
|
||||
|
||||
@ -123,10 +123,10 @@ void _glfwInputMonitor(_GLFWmonitor* monitor, int action, int placement)
|
||||
if (window->monitor == monitor)
|
||||
{
|
||||
int width, height, xoff, yoff;
|
||||
_glfwPlatformGetWindowSize(window, &width, &height);
|
||||
_glfwPlatformSetWindowMonitor(window, NULL, 0, 0, width, height, 0);
|
||||
_glfwPlatformGetWindowFrameSize(window, &xoff, &yoff, NULL, NULL);
|
||||
_glfwPlatformSetWindowPos(window, xoff, yoff);
|
||||
_glfw.platform.getWindowSize(window, &width, &height);
|
||||
_glfw.platform.setWindowMonitor(window, NULL, 0, 0, width, height, 0);
|
||||
_glfw.platform.getWindowFrameSize(window, &xoff, &yoff, NULL, NULL);
|
||||
_glfw.platform.setWindowPos(window, xoff, yoff);
|
||||
}
|
||||
}
|
||||
|
||||
@ -183,7 +183,7 @@ void _glfwFreeMonitor(_GLFWmonitor* monitor)
|
||||
if (monitor == NULL)
|
||||
return;
|
||||
|
||||
_glfwPlatformFreeMonitor(monitor);
|
||||
_glfw.platform.freeMonitor(monitor);
|
||||
|
||||
_glfwFreeGammaArrays(&monitor->originalRamp);
|
||||
_glfwFreeGammaArrays(&monitor->currentRamp);
|
||||
@ -332,7 +332,7 @@ GLFWAPI void glfwGetMonitorPos(GLFWmonitor* handle, int* xpos, int* ypos)
|
||||
|
||||
_GLFW_REQUIRE_INIT();
|
||||
|
||||
_glfwPlatformGetMonitorPos(monitor, xpos, ypos);
|
||||
_glfw.platform.getMonitorPos(monitor, xpos, ypos);
|
||||
}
|
||||
|
||||
GLFWAPI void glfwGetMonitorWorkarea(GLFWmonitor* handle,
|
||||
@ -353,7 +353,7 @@ GLFWAPI void glfwGetMonitorWorkarea(GLFWmonitor* handle,
|
||||
|
||||
_GLFW_REQUIRE_INIT();
|
||||
|
||||
_glfwPlatformGetMonitorWorkarea(monitor, xpos, ypos, width, height);
|
||||
_glfw.platform.getMonitorWorkarea(monitor, xpos, ypos, width, height);
|
||||
}
|
||||
|
||||
GLFWAPI void glfwGetMonitorPhysicalSize(GLFWmonitor* handle, int* widthMM, int* heightMM)
|
||||
@ -386,7 +386,7 @@ GLFWAPI void glfwGetMonitorContentScale(GLFWmonitor* handle,
|
||||
*yscale = 0.f;
|
||||
|
||||
_GLFW_REQUIRE_INIT();
|
||||
_glfwPlatformGetMonitorContentScale(monitor, xscale, yscale);
|
||||
_glfw.platform.getMonitorContentScale(monitor, xscale, yscale);
|
||||
}
|
||||
|
||||
GLFWAPI const char* glfwGetMonitorName(GLFWmonitor* handle)
|
||||
@ -419,7 +419,7 @@ GLFWAPI void* glfwGetMonitorUserPointer(GLFWmonitor* handle)
|
||||
GLFWAPI GLFWmonitorfun glfwSetMonitorCallback(GLFWmonitorfun cbfun)
|
||||
{
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||
_GLFW_SWAP_POINTERS(_glfw.callbacks.monitor, cbfun);
|
||||
_GLFW_SWAP(GLFWmonitorfun, _glfw.callbacks.monitor, cbfun);
|
||||
return cbfun;
|
||||
}
|
||||
|
||||
@ -447,7 +447,7 @@ GLFWAPI const GLFWvidmode* glfwGetVideoMode(GLFWmonitor* handle)
|
||||
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||
|
||||
_glfwPlatformGetVideoMode(monitor, &monitor->currentMode);
|
||||
_glfw.platform.getVideoMode(monitor, &monitor->currentMode);
|
||||
return &monitor->currentMode;
|
||||
}
|
||||
|
||||
@ -506,7 +506,7 @@ GLFWAPI const GLFWgammaramp* glfwGetGammaRamp(GLFWmonitor* handle)
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||
|
||||
_glfwFreeGammaArrays(&monitor->currentRamp);
|
||||
if (!_glfwPlatformGetGammaRamp(monitor, &monitor->currentRamp))
|
||||
if (!_glfw.platform.getGammaRamp(monitor, &monitor->currentRamp))
|
||||
return NULL;
|
||||
|
||||
return &monitor->currentRamp;
|
||||
@ -534,10 +534,10 @@ GLFWAPI void glfwSetGammaRamp(GLFWmonitor* handle, const GLFWgammaramp* ramp)
|
||||
|
||||
if (!monitor->originalRamp.size)
|
||||
{
|
||||
if (!_glfwPlatformGetGammaRamp(monitor, &monitor->originalRamp))
|
||||
if (!_glfw.platform.getGammaRamp(monitor, &monitor->originalRamp))
|
||||
return;
|
||||
}
|
||||
|
||||
_glfwPlatformSetGammaRamp(monitor, ramp);
|
||||
_glfw.platform.setGammaRamp(monitor, ramp);
|
||||
}
|
||||
|
||||
|
@ -1,76 +0,0 @@
|
||||
//========================================================================
|
||||
// GLFW 3.4 macOS - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2009-2019 Camilla Löwy <elmindreda@glfw.org>
|
||||
//
|
||||
// This software is provided 'as-is', without any express or implied
|
||||
// warranty. In no event will the authors be held liable for any damages
|
||||
// arising from the use of this software.
|
||||
//
|
||||
// Permission is granted to anyone to use this software for any purpose,
|
||||
// including commercial applications, and to alter it and redistribute it
|
||||
// freely, subject to the following restrictions:
|
||||
//
|
||||
// 1. The origin of this software must not be misrepresented; you must not
|
||||
// claim that you wrote the original software. If you use this software
|
||||
// in a product, an acknowledgment in the product documentation would
|
||||
// be appreciated but is not required.
|
||||
//
|
||||
// 2. Altered source versions must be plainly marked as such, and must not
|
||||
// be misrepresented as being the original software.
|
||||
//
|
||||
// 3. This notice may not be removed or altered from any source
|
||||
// distribution.
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
// NOTE: Many Cocoa enum values have been renamed and we need to build across
|
||||
// SDK versions where one is unavailable or the other deprecated
|
||||
// We use the newer names in code and these macros to handle compatibility
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED < 101400
|
||||
#define NSOpenGLContextParameterSwapInterval NSOpenGLCPSwapInterval
|
||||
#define NSOpenGLContextParameterSurfaceOpacity NSOpenGLCPSurfaceOpacity
|
||||
#endif
|
||||
|
||||
#define _GLFW_PLATFORM_CONTEXT_STATE _GLFWcontextNSGL nsgl
|
||||
#define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE _GLFWlibraryNSGL nsgl
|
||||
#define _GLFW_PLATFORM_USER_CONTEXT_STATE _GLFWusercontextNSGL nsgl
|
||||
|
||||
#include <stdatomic.h>
|
||||
|
||||
|
||||
// NSGL-specific per-context data
|
||||
//
|
||||
typedef struct _GLFWcontextNSGL
|
||||
{
|
||||
id pixelFormat;
|
||||
id object;
|
||||
|
||||
} _GLFWcontextNSGL;
|
||||
|
||||
// NSGL-specific per user context data
|
||||
//
|
||||
typedef struct _GLFWusercontextNSGL
|
||||
{
|
||||
id object;
|
||||
|
||||
} _GLFWusercontextNSGL;
|
||||
|
||||
// NSGL-specific global data
|
||||
//
|
||||
typedef struct _GLFWlibraryNSGL
|
||||
{
|
||||
// dlopen handle for OpenGL.framework (for glfwGetProcAddress)
|
||||
CFBundleRef framework;
|
||||
|
||||
} _GLFWlibraryNSGL;
|
||||
|
||||
|
||||
GLFWbool _glfwInitNSGL(void);
|
||||
void _glfwTerminateNSGL(void);
|
||||
GLFWbool _glfwCreateContextNSGL(_GLFWwindow* window,
|
||||
const _GLFWctxconfig* ctxconfig,
|
||||
const _GLFWfbconfig* fbconfig);
|
||||
void _glfwDestroyContextNSGL(_GLFWwindow* window);
|
||||
_GLFWusercontext* _glfwCreateUserContextNSGL(_GLFWwindow* window);
|
||||
|
@ -188,45 +188,45 @@ GLFWbool _glfwCreateContextNSGL(_GLFWwindow* window,
|
||||
// No-error contexts (GL_KHR_no_error) are not yet supported by macOS but
|
||||
// are not a hard constraint, so ignore and continue
|
||||
|
||||
#define addAttrib(a) \
|
||||
#define ADD_ATTRIB(a) \
|
||||
{ \
|
||||
assert((size_t) index < sizeof(attribs) / sizeof(attribs[0])); \
|
||||
attribs[index++] = a; \
|
||||
}
|
||||
#define setAttrib(a, v) { addAttrib(a); addAttrib(v); }
|
||||
#define SET_ATTRIB(a, v) { ADD_ATTRIB(a); ADD_ATTRIB(v); }
|
||||
|
||||
NSOpenGLPixelFormatAttribute attribs[40];
|
||||
int index = 0;
|
||||
|
||||
addAttrib(NSOpenGLPFAAccelerated);
|
||||
addAttrib(NSOpenGLPFAClosestPolicy);
|
||||
ADD_ATTRIB(NSOpenGLPFAAccelerated);
|
||||
ADD_ATTRIB(NSOpenGLPFAClosestPolicy);
|
||||
|
||||
if (ctxconfig->nsgl.offline)
|
||||
{
|
||||
addAttrib(NSOpenGLPFAAllowOfflineRenderers);
|
||||
ADD_ATTRIB(NSOpenGLPFAAllowOfflineRenderers);
|
||||
// NOTE: This replaces the NSSupportsAutomaticGraphicsSwitching key in
|
||||
// Info.plist for unbundled applications
|
||||
// HACK: This assumes that NSOpenGLPixelFormat will remain
|
||||
// a straightforward wrapper of its CGL counterpart
|
||||
addAttrib(kCGLPFASupportsAutomaticGraphicsSwitching);
|
||||
ADD_ATTRIB(kCGLPFASupportsAutomaticGraphicsSwitching);
|
||||
}
|
||||
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101000
|
||||
if (ctxconfig->major >= 4)
|
||||
{
|
||||
setAttrib(NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion4_1Core);
|
||||
SET_ATTRIB(NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion4_1Core);
|
||||
}
|
||||
else
|
||||
#endif /*MAC_OS_X_VERSION_MAX_ALLOWED*/
|
||||
if (ctxconfig->major >= 3)
|
||||
{
|
||||
setAttrib(NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion3_2Core);
|
||||
SET_ATTRIB(NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion3_2Core);
|
||||
}
|
||||
|
||||
if (ctxconfig->major <= 2)
|
||||
{
|
||||
if (fbconfig->auxBuffers != GLFW_DONT_CARE)
|
||||
setAttrib(NSOpenGLPFAAuxBuffers, fbconfig->auxBuffers);
|
||||
SET_ATTRIB(NSOpenGLPFAAuxBuffers, fbconfig->auxBuffers);
|
||||
|
||||
if (fbconfig->accumRedBits != GLFW_DONT_CARE &&
|
||||
fbconfig->accumGreenBits != GLFW_DONT_CARE &&
|
||||
@ -238,7 +238,7 @@ GLFWbool _glfwCreateContextNSGL(_GLFWwindow* window,
|
||||
fbconfig->accumBlueBits +
|
||||
fbconfig->accumAlphaBits;
|
||||
|
||||
setAttrib(NSOpenGLPFAAccumSize, accumBits);
|
||||
SET_ATTRIB(NSOpenGLPFAAccumSize, accumBits);
|
||||
}
|
||||
}
|
||||
|
||||
@ -256,17 +256,17 @@ GLFWbool _glfwCreateContextNSGL(_GLFWwindow* window,
|
||||
else if (colorBits < 15)
|
||||
colorBits = 15;
|
||||
|
||||
setAttrib(NSOpenGLPFAColorSize, colorBits);
|
||||
SET_ATTRIB(NSOpenGLPFAColorSize, colorBits);
|
||||
}
|
||||
|
||||
if (fbconfig->alphaBits != GLFW_DONT_CARE)
|
||||
setAttrib(NSOpenGLPFAAlphaSize, fbconfig->alphaBits);
|
||||
SET_ATTRIB(NSOpenGLPFAAlphaSize, fbconfig->alphaBits);
|
||||
|
||||
if (fbconfig->depthBits != GLFW_DONT_CARE)
|
||||
setAttrib(NSOpenGLPFADepthSize, fbconfig->depthBits);
|
||||
SET_ATTRIB(NSOpenGLPFADepthSize, fbconfig->depthBits);
|
||||
|
||||
if (fbconfig->stencilBits != GLFW_DONT_CARE)
|
||||
setAttrib(NSOpenGLPFAStencilSize, fbconfig->stencilBits);
|
||||
SET_ATTRIB(NSOpenGLPFAStencilSize, fbconfig->stencilBits);
|
||||
|
||||
if (fbconfig->stereo)
|
||||
{
|
||||
@ -275,33 +275,33 @@ GLFWbool _glfwCreateContextNSGL(_GLFWwindow* window,
|
||||
"NSGL: Stereo rendering is deprecated");
|
||||
return GLFW_FALSE;
|
||||
#else
|
||||
addAttrib(NSOpenGLPFAStereo);
|
||||
ADD_ATTRIB(NSOpenGLPFAStereo);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (fbconfig->doublebuffer)
|
||||
addAttrib(NSOpenGLPFADoubleBuffer);
|
||||
ADD_ATTRIB(NSOpenGLPFADoubleBuffer);
|
||||
|
||||
if (fbconfig->samples != GLFW_DONT_CARE)
|
||||
{
|
||||
if (fbconfig->samples == 0)
|
||||
{
|
||||
setAttrib(NSOpenGLPFASampleBuffers, 0);
|
||||
SET_ATTRIB(NSOpenGLPFASampleBuffers, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
setAttrib(NSOpenGLPFASampleBuffers, 1);
|
||||
setAttrib(NSOpenGLPFASamples, fbconfig->samples);
|
||||
SET_ATTRIB(NSOpenGLPFASampleBuffers, 1);
|
||||
SET_ATTRIB(NSOpenGLPFASamples, fbconfig->samples);
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE: All NSOpenGLPixelFormats on the relevant cards support sRGB
|
||||
// framebuffer, so there's no need (and no way) to request it
|
||||
|
||||
addAttrib(0);
|
||||
ADD_ATTRIB(0);
|
||||
|
||||
#undef addAttrib
|
||||
#undef setAttrib
|
||||
#undef ADD_ATTRIB
|
||||
#undef SET_ATTRIB
|
||||
|
||||
window->context.nsgl.pixelFormat =
|
||||
[[NSOpenGLPixelFormat alloc] initWithAttributes:attribs];
|
||||
@ -403,7 +403,14 @@ GLFWAPI id glfwGetNSGLContext(GLFWwindow* handle)
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(nil);
|
||||
|
||||
if (window->context.client == GLFW_NO_API)
|
||||
if (_glfw.platform.platformID != GLFW_PLATFORM_COCOA)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_UNAVAILABLE,
|
||||
"NSGL: Platform not initialized");
|
||||
return nil;
|
||||
}
|
||||
|
||||
if (window->context.source != GLFW_NATIVE_CONTEXT_API)
|
||||
{
|
||||
_glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL);
|
||||
return nil;
|
||||
|
@ -36,22 +36,98 @@
|
||||
////// GLFW platform API //////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int _glfwPlatformInit(void)
|
||||
GLFWbool _glfwConnectNull(int platformID, _GLFWplatform* platform)
|
||||
{
|
||||
_glfwInitTimerPOSIX();
|
||||
_glfwPollMonitorsNull();
|
||||
const _GLFWplatform null =
|
||||
{
|
||||
GLFW_PLATFORM_NULL,
|
||||
_glfwInitNull,
|
||||
_glfwTerminateNull,
|
||||
_glfwGetCursorPosNull,
|
||||
_glfwSetCursorPosNull,
|
||||
_glfwSetCursorModeNull,
|
||||
_glfwSetRawMouseMotionNull,
|
||||
_glfwRawMouseMotionSupportedNull,
|
||||
_glfwCreateCursorNull,
|
||||
_glfwCreateStandardCursorNull,
|
||||
_glfwDestroyCursorNull,
|
||||
_glfwSetCursorNull,
|
||||
_glfwGetScancodeNameNull,
|
||||
_glfwGetKeyScancodeNull,
|
||||
_glfwSetClipboardStringNull,
|
||||
_glfwGetClipboardStringNull,
|
||||
_glfwInitJoysticksNull,
|
||||
_glfwTerminateJoysticksNull,
|
||||
_glfwPollJoystickNull,
|
||||
_glfwGetMappingNameNull,
|
||||
_glfwUpdateGamepadGUIDNull,
|
||||
_glfwFreeMonitorNull,
|
||||
_glfwGetMonitorPosNull,
|
||||
_glfwGetMonitorContentScaleNull,
|
||||
_glfwGetMonitorWorkareaNull,
|
||||
_glfwGetVideoModesNull,
|
||||
_glfwGetVideoModeNull,
|
||||
_glfwGetGammaRampNull,
|
||||
_glfwSetGammaRampNull,
|
||||
_glfwCreateWindowNull,
|
||||
_glfwDestroyWindowNull,
|
||||
_glfwSetWindowTitleNull,
|
||||
_glfwSetWindowIconNull,
|
||||
_glfwGetWindowPosNull,
|
||||
_glfwSetWindowPosNull,
|
||||
_glfwGetWindowSizeNull,
|
||||
_glfwSetWindowSizeNull,
|
||||
_glfwSetWindowSizeLimitsNull,
|
||||
_glfwSetWindowAspectRatioNull,
|
||||
_glfwGetFramebufferSizeNull,
|
||||
_glfwGetWindowFrameSizeNull,
|
||||
_glfwGetWindowContentScaleNull,
|
||||
_glfwIconifyWindowNull,
|
||||
_glfwRestoreWindowNull,
|
||||
_glfwMaximizeWindowNull,
|
||||
_glfwShowWindowNull,
|
||||
_glfwHideWindowNull,
|
||||
_glfwRequestWindowAttentionNull,
|
||||
_glfwFocusWindowNull,
|
||||
_glfwSetWindowMonitorNull,
|
||||
_glfwWindowFocusedNull,
|
||||
_glfwWindowIconifiedNull,
|
||||
_glfwWindowVisibleNull,
|
||||
_glfwWindowMaximizedNull,
|
||||
_glfwWindowHoveredNull,
|
||||
_glfwFramebufferTransparentNull,
|
||||
_glfwGetWindowOpacityNull,
|
||||
_glfwSetWindowResizableNull,
|
||||
_glfwSetWindowDecoratedNull,
|
||||
_glfwSetWindowFloatingNull,
|
||||
_glfwSetWindowOpacityNull,
|
||||
_glfwSetWindowMousePassthroughNull,
|
||||
_glfwPollEventsNull,
|
||||
_glfwWaitEventsNull,
|
||||
_glfwWaitEventsTimeoutNull,
|
||||
_glfwPostEmptyEventNull,
|
||||
_glfwGetEGLPlatformNull,
|
||||
_glfwGetEGLNativeDisplayNull,
|
||||
_glfwGetEGLNativeWindowNull,
|
||||
_glfwGetRequiredInstanceExtensionsNull,
|
||||
_glfwGetPhysicalDevicePresentationSupportNull,
|
||||
_glfwCreateWindowSurfaceNull,
|
||||
};
|
||||
|
||||
*platform = null;
|
||||
return GLFW_TRUE;
|
||||
}
|
||||
|
||||
void _glfwPlatformTerminate(void)
|
||||
int _glfwInitNull(void)
|
||||
{
|
||||
_glfw_free(_glfw.null.clipboardString);
|
||||
_glfwPollMonitorsNull();
|
||||
return GLFW_TRUE;
|
||||
}
|
||||
|
||||
void _glfwTerminateNull(void)
|
||||
{
|
||||
free(_glfw.null.clipboardString);
|
||||
_glfwTerminateOSMesa();
|
||||
}
|
||||
|
||||
const char* _glfwPlatformGetVersionString(void)
|
||||
{
|
||||
return _GLFW_VERSION_NUMBER " null OSMesa";
|
||||
_glfwTerminateEGL();
|
||||
}
|
||||
|
||||
|
@ -33,21 +33,26 @@
|
||||
////// GLFW platform API //////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
GLFWbool _glfwPlatformInitJoysticks(void)
|
||||
GLFWbool _glfwInitJoysticksNull(void)
|
||||
{
|
||||
return GLFW_TRUE;
|
||||
}
|
||||
|
||||
void _glfwPlatformTerminateJoysticks(void)
|
||||
void _glfwTerminateJoysticksNull(void)
|
||||
{
|
||||
}
|
||||
|
||||
int _glfwPlatformPollJoystick(_GLFWjoystick* js, int mode)
|
||||
int _glfwPollJoystickNull(_GLFWjoystick* js, int mode)
|
||||
{
|
||||
return GLFW_FALSE;
|
||||
}
|
||||
|
||||
void _glfwPlatformUpdateGamepadGUID(char* guid)
|
||||
const char* _glfwGetMappingNameNull(void)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
void _glfwUpdateGamepadGUIDNull(char* guid)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -24,8 +24,9 @@
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#define _GLFW_PLATFORM_JOYSTICK_STATE struct { int dummyJoystick; }
|
||||
#define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE struct { int dummyLibraryJoystick; }
|
||||
|
||||
#define _GLFW_PLATFORM_MAPPING_NAME ""
|
||||
GLFWbool _glfwInitJoysticksNull(void);
|
||||
void _glfwTerminateJoysticksNull(void);
|
||||
int _glfwPollJoystickNull(_GLFWjoystick* js, int mode);
|
||||
const char* _glfwGetMappingNameNull(void);
|
||||
void _glfwUpdateGamepadGUIDNull(char* guid);
|
||||
|
||||
|
@ -65,12 +65,12 @@ void _glfwPollMonitorsNull(void)
|
||||
////// GLFW platform API //////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void _glfwPlatformFreeMonitor(_GLFWmonitor* monitor)
|
||||
void _glfwFreeMonitorNull(_GLFWmonitor* monitor)
|
||||
{
|
||||
_glfwFreeGammaArrays(&monitor->null.ramp);
|
||||
}
|
||||
|
||||
void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos)
|
||||
void _glfwGetMonitorPosNull(_GLFWmonitor* monitor, int* xpos, int* ypos)
|
||||
{
|
||||
if (xpos)
|
||||
*xpos = 0;
|
||||
@ -78,8 +78,8 @@ void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos)
|
||||
*ypos = 0;
|
||||
}
|
||||
|
||||
void _glfwPlatformGetMonitorContentScale(_GLFWmonitor* monitor,
|
||||
float* xscale, float* yscale)
|
||||
void _glfwGetMonitorContentScaleNull(_GLFWmonitor* monitor,
|
||||
float* xscale, float* yscale)
|
||||
{
|
||||
if (xscale)
|
||||
*xscale = 1.f;
|
||||
@ -87,9 +87,9 @@ void _glfwPlatformGetMonitorContentScale(_GLFWmonitor* monitor,
|
||||
*yscale = 1.f;
|
||||
}
|
||||
|
||||
void _glfwPlatformGetMonitorWorkarea(_GLFWmonitor* monitor,
|
||||
int* xpos, int* ypos,
|
||||
int* width, int* height)
|
||||
void _glfwGetMonitorWorkareaNull(_GLFWmonitor* monitor,
|
||||
int* xpos, int* ypos,
|
||||
int* width, int* height)
|
||||
{
|
||||
const GLFWvidmode mode = getVideoMode();
|
||||
|
||||
@ -103,7 +103,7 @@ void _glfwPlatformGetMonitorWorkarea(_GLFWmonitor* monitor,
|
||||
*height = mode.height - 10;
|
||||
}
|
||||
|
||||
GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* found)
|
||||
GLFWvidmode* _glfwGetVideoModesNull(_GLFWmonitor* monitor, int* found)
|
||||
{
|
||||
GLFWvidmode* mode = _glfw_calloc(1, sizeof(GLFWvidmode));
|
||||
*mode = getVideoMode();
|
||||
@ -111,18 +111,20 @@ GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* found)
|
||||
return mode;
|
||||
}
|
||||
|
||||
void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode)
|
||||
void _glfwGetVideoModeNull(_GLFWmonitor* monitor, GLFWvidmode* mode)
|
||||
{
|
||||
*mode = getVideoMode();
|
||||
}
|
||||
|
||||
GLFWbool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
|
||||
GLFWbool _glfwGetGammaRampNull(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
|
||||
{
|
||||
if (!monitor->null.ramp.size)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
_glfwAllocGammaArrays(&monitor->null.ramp, 256);
|
||||
|
||||
for (unsigned int i = 0; i < monitor->null.ramp.size; i++)
|
||||
for (i = 0; i < monitor->null.ramp.size; i++)
|
||||
{
|
||||
const float gamma = 2.2f;
|
||||
float value;
|
||||
@ -143,7 +145,7 @@ GLFWbool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
|
||||
return GLFW_TRUE;
|
||||
}
|
||||
|
||||
void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp)
|
||||
void _glfwSetGammaRampNull(_GLFWmonitor* monitor, const GLFWgammaramp* ramp)
|
||||
{
|
||||
if (monitor->null.ramp.size != ramp->size)
|
||||
{
|
||||
|
@ -25,30 +25,14 @@
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#include <dlfcn.h>
|
||||
#define GLFW_NULL_WINDOW_STATE _GLFWwindowNull null;
|
||||
#define GLFW_NULL_LIBRARY_WINDOW_STATE _GLFWlibraryNull null;
|
||||
#define GLFW_NULL_MONITOR_STATE _GLFWmonitorNull null;
|
||||
|
||||
#define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowNull null
|
||||
#define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryNull null
|
||||
#define _GLFW_PLATFORM_MONITOR_STATE _GLFWmonitorNull null
|
||||
|
||||
#define _GLFW_PLATFORM_CONTEXT_STATE struct { int dummyContext; }
|
||||
#define _GLFW_PLATFORM_CURSOR_STATE struct { int dummyCursor; }
|
||||
#define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE struct { int dummyLibraryContext; }
|
||||
#define _GLFW_PLATFORM_USER_CONTEXT_STATE struct { int dummyUserContext; }
|
||||
|
||||
#include "posix_time.h"
|
||||
#include "posix_thread.h"
|
||||
#include "null_joystick.h"
|
||||
|
||||
#if defined(_GLFW_WIN32)
|
||||
#define _glfw_dlopen(name) LoadLibraryA(name)
|
||||
#define _glfw_dlclose(handle) FreeLibrary((HMODULE) handle)
|
||||
#define _glfw_dlsym(handle, name) GetProcAddress((HMODULE) handle, name)
|
||||
#else
|
||||
#define _glfw_dlopen(name) dlopen(name, RTLD_LAZY | RTLD_LOCAL)
|
||||
#define _glfw_dlclose(handle) dlclose(handle)
|
||||
#define _glfw_dlsym(handle, name) dlsym(handle, name)
|
||||
#endif
|
||||
#define GLFW_NULL_CONTEXT_STATE
|
||||
#define GLFW_NULL_CURSOR_STATE
|
||||
#define GLFW_NULL_LIBRARY_CONTEXT_STATE
|
||||
#define GLFW_NULL_USER_CONTEXT_STATE
|
||||
|
||||
// Null-specific per-window data
|
||||
//
|
||||
@ -88,3 +72,78 @@ typedef struct _GLFWlibraryNull
|
||||
|
||||
void _glfwPollMonitorsNull(void);
|
||||
|
||||
GLFWbool _glfwConnectNull(int platformID, _GLFWplatform* platform);
|
||||
int _glfwInitNull(void);
|
||||
void _glfwTerminateNull(void);
|
||||
|
||||
void _glfwFreeMonitorNull(_GLFWmonitor* monitor);
|
||||
void _glfwGetMonitorPosNull(_GLFWmonitor* monitor, int* xpos, int* ypos);
|
||||
void _glfwGetMonitorContentScaleNull(_GLFWmonitor* monitor, float* xscale, float* yscale);
|
||||
void _glfwGetMonitorWorkareaNull(_GLFWmonitor* monitor, int* xpos, int* ypos, int* width, int* height);
|
||||
GLFWvidmode* _glfwGetVideoModesNull(_GLFWmonitor* monitor, int* found);
|
||||
void _glfwGetVideoModeNull(_GLFWmonitor* monitor, GLFWvidmode* mode);
|
||||
GLFWbool _glfwGetGammaRampNull(_GLFWmonitor* monitor, GLFWgammaramp* ramp);
|
||||
void _glfwSetGammaRampNull(_GLFWmonitor* monitor, const GLFWgammaramp* ramp);
|
||||
|
||||
int _glfwCreateWindowNull(_GLFWwindow* window, const _GLFWwndconfig* wndconfig, const _GLFWctxconfig* ctxconfig, const _GLFWfbconfig* fbconfig);
|
||||
void _glfwDestroyWindowNull(_GLFWwindow* window);
|
||||
void _glfwSetWindowTitleNull(_GLFWwindow* window, const char* title);
|
||||
void _glfwSetWindowIconNull(_GLFWwindow* window, int count, const GLFWimage* images);
|
||||
void _glfwSetWindowMonitorNull(_GLFWwindow* window, _GLFWmonitor* monitor, int xpos, int ypos, int width, int height, int refreshRate);
|
||||
void _glfwGetWindowPosNull(_GLFWwindow* window, int* xpos, int* ypos);
|
||||
void _glfwSetWindowPosNull(_GLFWwindow* window, int xpos, int ypos);
|
||||
void _glfwGetWindowSizeNull(_GLFWwindow* window, int* width, int* height);
|
||||
void _glfwSetWindowSizeNull(_GLFWwindow* window, int width, int height);
|
||||
void _glfwSetWindowSizeLimitsNull(_GLFWwindow* window, int minwidth, int minheight, int maxwidth, int maxheight);
|
||||
void _glfwSetWindowAspectRatioNull(_GLFWwindow* window, int n, int d);
|
||||
void _glfwGetFramebufferSizeNull(_GLFWwindow* window, int* width, int* height);
|
||||
void _glfwGetWindowFrameSizeNull(_GLFWwindow* window, int* left, int* top, int* right, int* bottom);
|
||||
void _glfwGetWindowContentScaleNull(_GLFWwindow* window, float* xscale, float* yscale);
|
||||
void _glfwIconifyWindowNull(_GLFWwindow* window);
|
||||
void _glfwRestoreWindowNull(_GLFWwindow* window);
|
||||
void _glfwMaximizeWindowNull(_GLFWwindow* window);
|
||||
int _glfwWindowMaximizedNull(_GLFWwindow* window);
|
||||
int _glfwWindowHoveredNull(_GLFWwindow* window);
|
||||
int _glfwFramebufferTransparentNull(_GLFWwindow* window);
|
||||
void _glfwSetWindowResizableNull(_GLFWwindow* window, GLFWbool enabled);
|
||||
void _glfwSetWindowDecoratedNull(_GLFWwindow* window, GLFWbool enabled);
|
||||
void _glfwSetWindowFloatingNull(_GLFWwindow* window, GLFWbool enabled);
|
||||
void _glfwSetWindowMousePassthroughNull(_GLFWwindow* window, GLFWbool enabled);
|
||||
float _glfwGetWindowOpacityNull(_GLFWwindow* window);
|
||||
void _glfwSetWindowOpacityNull(_GLFWwindow* window, float opacity);
|
||||
void _glfwSetRawMouseMotionNull(_GLFWwindow *window, GLFWbool enabled);
|
||||
GLFWbool _glfwRawMouseMotionSupportedNull(void);
|
||||
void _glfwShowWindowNull(_GLFWwindow* window);
|
||||
void _glfwRequestWindowAttentionNull(_GLFWwindow* window);
|
||||
void _glfwRequestWindowAttentionNull(_GLFWwindow* window);
|
||||
void _glfwHideWindowNull(_GLFWwindow* window);
|
||||
void _glfwFocusWindowNull(_GLFWwindow* window);
|
||||
int _glfwWindowFocusedNull(_GLFWwindow* window);
|
||||
int _glfwWindowIconifiedNull(_GLFWwindow* window);
|
||||
int _glfwWindowVisibleNull(_GLFWwindow* window);
|
||||
void _glfwPollEventsNull(void);
|
||||
void _glfwWaitEventsNull(void);
|
||||
void _glfwWaitEventsTimeoutNull(double timeout);
|
||||
void _glfwPostEmptyEventNull(void);
|
||||
void _glfwGetCursorPosNull(_GLFWwindow* window, double* xpos, double* ypos);
|
||||
void _glfwSetCursorPosNull(_GLFWwindow* window, double x, double y);
|
||||
void _glfwSetCursorModeNull(_GLFWwindow* window, int mode);
|
||||
int _glfwCreateCursorNull(_GLFWcursor* cursor, const GLFWimage* image, int xhot, int yhot);
|
||||
int _glfwCreateStandardCursorNull(_GLFWcursor* cursor, int shape);
|
||||
void _glfwDestroyCursorNull(_GLFWcursor* cursor);
|
||||
void _glfwSetCursorNull(_GLFWwindow* window, _GLFWcursor* cursor);
|
||||
void _glfwSetClipboardStringNull(const char* string);
|
||||
const char* _glfwGetClipboardStringNull(void);
|
||||
const char* _glfwGetScancodeNameNull(int scancode);
|
||||
int _glfwGetKeyScancodeNull(int key);
|
||||
|
||||
EGLenum _glfwGetEGLPlatformNull(EGLint** attribs);
|
||||
EGLNativeDisplayType _glfwGetEGLNativeDisplayNull(void);
|
||||
EGLNativeWindowType _glfwGetEGLNativeWindowNull(_GLFWwindow* window);
|
||||
|
||||
void _glfwGetRequiredInstanceExtensionsNull(char** extensions);
|
||||
int _glfwGetPhysicalDevicePresentationSupportNull(VkInstance instance, VkPhysicalDevice device, uint32_t queuefamily);
|
||||
VkResult _glfwCreateWindowSurfaceNull(VkInstance instance, _GLFWwindow* window, const VkAllocationCallbacks* allocator, VkSurfaceKHR* surface);
|
||||
|
||||
void _glfwPollMonitorsNull(void);
|
||||
|
||||
|
@ -39,24 +39,24 @@ static void applySizeLimits(_GLFWwindow* window, int* width, int* height)
|
||||
*height = (int) (*width / ratio);
|
||||
}
|
||||
|
||||
if (window->minwidth != GLFW_DONT_CARE && *width < window->minwidth)
|
||||
*width = window->minwidth;
|
||||
else if (window->maxwidth != GLFW_DONT_CARE && *width > window->maxwidth)
|
||||
*width = window->maxwidth;
|
||||
if (window->minwidth != GLFW_DONT_CARE)
|
||||
*width = _glfw_max(*width, window->minwidth);
|
||||
else if (window->maxwidth != GLFW_DONT_CARE)
|
||||
*width = _glfw_min(*width, window->maxwidth);
|
||||
|
||||
if (window->minheight != GLFW_DONT_CARE && *height < window->minheight)
|
||||
*height = window->minheight;
|
||||
else if (window->maxheight != GLFW_DONT_CARE && *height > window->maxheight)
|
||||
*height = window->maxheight;
|
||||
if (window->minheight != GLFW_DONT_CARE)
|
||||
*height = _glfw_min(*height, window->minheight);
|
||||
else if (window->maxheight != GLFW_DONT_CARE)
|
||||
*height = _glfw_max(*height, window->maxheight);
|
||||
}
|
||||
|
||||
static void fitToMonitor(_GLFWwindow* window)
|
||||
{
|
||||
GLFWvidmode mode;
|
||||
_glfwPlatformGetVideoMode(window->monitor, &mode);
|
||||
_glfwPlatformGetMonitorPos(window->monitor,
|
||||
&window->null.xpos,
|
||||
&window->null.ypos);
|
||||
_glfwGetVideoModeNull(window->monitor, &mode);
|
||||
_glfwGetMonitorPosNull(window->monitor,
|
||||
&window->null.xpos,
|
||||
&window->null.ypos);
|
||||
window->null.width = mode.width;
|
||||
window->null.height = mode.height;
|
||||
}
|
||||
@ -103,10 +103,10 @@ static int createNativeWindow(_GLFWwindow* window,
|
||||
////// GLFW platform API //////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int _glfwPlatformCreateWindow(_GLFWwindow* window,
|
||||
const _GLFWwndconfig* wndconfig,
|
||||
const _GLFWctxconfig* ctxconfig,
|
||||
const _GLFWfbconfig* fbconfig)
|
||||
int _glfwCreateWindowNull(_GLFWwindow* window,
|
||||
const _GLFWwndconfig* wndconfig,
|
||||
const _GLFWctxconfig* ctxconfig,
|
||||
const _GLFWfbconfig* fbconfig)
|
||||
{
|
||||
if (!createNativeWindow(window, wndconfig, fbconfig))
|
||||
return GLFW_FALSE;
|
||||
@ -121,24 +121,26 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
|
||||
if (!_glfwCreateContextOSMesa(window, ctxconfig, fbconfig))
|
||||
return GLFW_FALSE;
|
||||
}
|
||||
else
|
||||
else if (ctxconfig->source == GLFW_EGL_CONTEXT_API)
|
||||
{
|
||||
_glfwInputError(GLFW_API_UNAVAILABLE, "Null: EGL not available");
|
||||
return GLFW_FALSE;
|
||||
if (!_glfwInitEGL())
|
||||
return GLFW_FALSE;
|
||||
if (!_glfwCreateContextEGL(window, ctxconfig, fbconfig))
|
||||
return GLFW_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (window->monitor)
|
||||
{
|
||||
_glfwPlatformShowWindow(window);
|
||||
_glfwPlatformFocusWindow(window);
|
||||
_glfwShowWindowNull(window);
|
||||
_glfwFocusWindowNull(window);
|
||||
acquireMonitor(window);
|
||||
}
|
||||
|
||||
return GLFW_TRUE;
|
||||
}
|
||||
|
||||
void _glfwPlatformDestroyWindow(_GLFWwindow* window)
|
||||
void _glfwDestroyWindowNull(_GLFWwindow* window)
|
||||
{
|
||||
if (window->monitor)
|
||||
releaseMonitor(window);
|
||||
@ -150,27 +152,26 @@ void _glfwPlatformDestroyWindow(_GLFWwindow* window)
|
||||
window->context.destroy(window);
|
||||
}
|
||||
|
||||
void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title)
|
||||
void _glfwSetWindowTitleNull(_GLFWwindow* window, const char* title)
|
||||
{
|
||||
}
|
||||
|
||||
void _glfwPlatformSetWindowIcon(_GLFWwindow* window, int count,
|
||||
const GLFWimage* images)
|
||||
void _glfwSetWindowIconNull(_GLFWwindow* window, int count, const GLFWimage* images)
|
||||
{
|
||||
}
|
||||
|
||||
void _glfwPlatformSetWindowMonitor(_GLFWwindow* window,
|
||||
_GLFWmonitor* monitor,
|
||||
int xpos, int ypos,
|
||||
int width, int height,
|
||||
int refreshRate)
|
||||
void _glfwSetWindowMonitorNull(_GLFWwindow* window,
|
||||
_GLFWmonitor* monitor,
|
||||
int xpos, int ypos,
|
||||
int width, int height,
|
||||
int refreshRate)
|
||||
{
|
||||
if (window->monitor == monitor)
|
||||
{
|
||||
if (!monitor)
|
||||
{
|
||||
_glfwPlatformSetWindowPos(window, xpos, ypos);
|
||||
_glfwPlatformSetWindowSize(window, width, height);
|
||||
_glfwSetWindowPosNull(window, xpos, ypos);
|
||||
_glfwSetWindowSizeNull(window, width, height);
|
||||
}
|
||||
|
||||
return;
|
||||
@ -189,12 +190,12 @@ void _glfwPlatformSetWindowMonitor(_GLFWwindow* window,
|
||||
}
|
||||
else
|
||||
{
|
||||
_glfwPlatformSetWindowPos(window, xpos, ypos);
|
||||
_glfwPlatformSetWindowSize(window, width, height);
|
||||
_glfwSetWindowPosNull(window, xpos, ypos);
|
||||
_glfwSetWindowSizeNull(window, width, height);
|
||||
}
|
||||
}
|
||||
|
||||
void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos)
|
||||
void _glfwGetWindowPosNull(_GLFWwindow* window, int* xpos, int* ypos)
|
||||
{
|
||||
if (xpos)
|
||||
*xpos = window->null.xpos;
|
||||
@ -202,7 +203,7 @@ void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos)
|
||||
*ypos = window->null.ypos;
|
||||
}
|
||||
|
||||
void _glfwPlatformSetWindowPos(_GLFWwindow* window, int xpos, int ypos)
|
||||
void _glfwSetWindowPosNull(_GLFWwindow* window, int xpos, int ypos)
|
||||
{
|
||||
if (window->monitor)
|
||||
return;
|
||||
@ -215,7 +216,7 @@ void _glfwPlatformSetWindowPos(_GLFWwindow* window, int xpos, int ypos)
|
||||
}
|
||||
}
|
||||
|
||||
void _glfwPlatformGetWindowSize(_GLFWwindow* window, int* width, int* height)
|
||||
void _glfwGetWindowSizeNull(_GLFWwindow* window, int* width, int* height)
|
||||
{
|
||||
if (width)
|
||||
*width = window->null.width;
|
||||
@ -223,7 +224,7 @@ void _glfwPlatformGetWindowSize(_GLFWwindow* window, int* width, int* height)
|
||||
*height = window->null.height;
|
||||
}
|
||||
|
||||
void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
|
||||
void _glfwSetWindowSizeNull(_GLFWwindow* window, int width, int height)
|
||||
{
|
||||
if (window->monitor)
|
||||
return;
|
||||
@ -237,25 +238,25 @@ void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
|
||||
}
|
||||
}
|
||||
|
||||
void _glfwPlatformSetWindowSizeLimits(_GLFWwindow* window,
|
||||
int minwidth, int minheight,
|
||||
int maxwidth, int maxheight)
|
||||
void _glfwSetWindowSizeLimitsNull(_GLFWwindow* window,
|
||||
int minwidth, int minheight,
|
||||
int maxwidth, int maxheight)
|
||||
{
|
||||
int width = window->null.width;
|
||||
int height = window->null.height;
|
||||
applySizeLimits(window, &width, &height);
|
||||
_glfwPlatformSetWindowSize(window, width, height);
|
||||
_glfwSetWindowSizeNull(window, width, height);
|
||||
}
|
||||
|
||||
void _glfwPlatformSetWindowAspectRatio(_GLFWwindow* window, int n, int d)
|
||||
void _glfwSetWindowAspectRatioNull(_GLFWwindow* window, int n, int d)
|
||||
{
|
||||
int width = window->null.width;
|
||||
int height = window->null.height;
|
||||
applySizeLimits(window, &width, &height);
|
||||
_glfwPlatformSetWindowSize(window, width, height);
|
||||
_glfwSetWindowSizeNull(window, width, height);
|
||||
}
|
||||
|
||||
void _glfwPlatformGetFramebufferSize(_GLFWwindow* window, int* width, int* height)
|
||||
void _glfwGetFramebufferSizeNull(_GLFWwindow* window, int* width, int* height)
|
||||
{
|
||||
if (width)
|
||||
*width = window->null.width;
|
||||
@ -263,9 +264,9 @@ void _glfwPlatformGetFramebufferSize(_GLFWwindow* window, int* width, int* heigh
|
||||
*height = window->null.height;
|
||||
}
|
||||
|
||||
void _glfwPlatformGetWindowFrameSize(_GLFWwindow* window,
|
||||
int* left, int* top,
|
||||
int* right, int* bottom)
|
||||
void _glfwGetWindowFrameSizeNull(_GLFWwindow* window,
|
||||
int* left, int* top,
|
||||
int* right, int* bottom)
|
||||
{
|
||||
if (window->null.decorated && !window->monitor)
|
||||
{
|
||||
@ -291,8 +292,7 @@ void _glfwPlatformGetWindowFrameSize(_GLFWwindow* window,
|
||||
}
|
||||
}
|
||||
|
||||
void _glfwPlatformGetWindowContentScale(_GLFWwindow* window,
|
||||
float* xscale, float* yscale)
|
||||
void _glfwGetWindowContentScaleNull(_GLFWwindow* window, float* xscale, float* yscale)
|
||||
{
|
||||
if (xscale)
|
||||
*xscale = 1.f;
|
||||
@ -300,7 +300,7 @@ void _glfwPlatformGetWindowContentScale(_GLFWwindow* window,
|
||||
*yscale = 1.f;
|
||||
}
|
||||
|
||||
void _glfwPlatformIconifyWindow(_GLFWwindow* window)
|
||||
void _glfwIconifyWindowNull(_GLFWwindow* window)
|
||||
{
|
||||
if (_glfw.null.focusedWindow == window)
|
||||
{
|
||||
@ -318,7 +318,7 @@ void _glfwPlatformIconifyWindow(_GLFWwindow* window)
|
||||
}
|
||||
}
|
||||
|
||||
void _glfwPlatformRestoreWindow(_GLFWwindow* window)
|
||||
void _glfwRestoreWindowNull(_GLFWwindow* window)
|
||||
{
|
||||
if (window->null.iconified)
|
||||
{
|
||||
@ -335,7 +335,7 @@ void _glfwPlatformRestoreWindow(_GLFWwindow* window)
|
||||
}
|
||||
}
|
||||
|
||||
void _glfwPlatformMaximizeWindow(_GLFWwindow* window)
|
||||
void _glfwMaximizeWindowNull(_GLFWwindow* window)
|
||||
{
|
||||
if (!window->null.maximized)
|
||||
{
|
||||
@ -344,12 +344,12 @@ void _glfwPlatformMaximizeWindow(_GLFWwindow* window)
|
||||
}
|
||||
}
|
||||
|
||||
int _glfwPlatformWindowMaximized(_GLFWwindow* window)
|
||||
int _glfwWindowMaximizedNull(_GLFWwindow* window)
|
||||
{
|
||||
return window->null.maximized;
|
||||
}
|
||||
|
||||
int _glfwPlatformWindowHovered(_GLFWwindow* window)
|
||||
int _glfwWindowHoveredNull(_GLFWwindow* window)
|
||||
{
|
||||
return _glfw.null.xcursor >= window->null.xpos &&
|
||||
_glfw.null.ycursor >= window->null.ypos &&
|
||||
@ -357,59 +357,59 @@ int _glfwPlatformWindowHovered(_GLFWwindow* window)
|
||||
_glfw.null.ycursor <= window->null.ypos + window->null.height - 1;
|
||||
}
|
||||
|
||||
int _glfwPlatformFramebufferTransparent(_GLFWwindow* window)
|
||||
int _glfwFramebufferTransparentNull(_GLFWwindow* window)
|
||||
{
|
||||
return window->null.transparent;
|
||||
}
|
||||
|
||||
void _glfwPlatformSetWindowResizable(_GLFWwindow* window, GLFWbool enabled)
|
||||
void _glfwSetWindowResizableNull(_GLFWwindow* window, GLFWbool enabled)
|
||||
{
|
||||
window->null.resizable = enabled;
|
||||
}
|
||||
|
||||
void _glfwPlatformSetWindowDecorated(_GLFWwindow* window, GLFWbool enabled)
|
||||
void _glfwSetWindowDecoratedNull(_GLFWwindow* window, GLFWbool enabled)
|
||||
{
|
||||
window->null.decorated = enabled;
|
||||
}
|
||||
|
||||
void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled)
|
||||
void _glfwSetWindowFloatingNull(_GLFWwindow* window, GLFWbool enabled)
|
||||
{
|
||||
window->null.floating = enabled;
|
||||
}
|
||||
|
||||
void _glfwPlatformSetWindowMousePassthrough(_GLFWwindow* window, GLFWbool enabled)
|
||||
void _glfwSetWindowMousePassthroughNull(_GLFWwindow* window, GLFWbool enabled)
|
||||
{
|
||||
}
|
||||
|
||||
float _glfwPlatformGetWindowOpacity(_GLFWwindow* window)
|
||||
float _glfwGetWindowOpacityNull(_GLFWwindow* window)
|
||||
{
|
||||
return window->null.opacity;
|
||||
}
|
||||
|
||||
void _glfwPlatformSetWindowOpacity(_GLFWwindow* window, float opacity)
|
||||
void _glfwSetWindowOpacityNull(_GLFWwindow* window, float opacity)
|
||||
{
|
||||
window->null.opacity = opacity;
|
||||
}
|
||||
|
||||
void _glfwPlatformSetRawMouseMotion(_GLFWwindow *window, GLFWbool enabled)
|
||||
void _glfwSetRawMouseMotionNull(_GLFWwindow *window, GLFWbool enabled)
|
||||
{
|
||||
}
|
||||
|
||||
GLFWbool _glfwPlatformRawMouseMotionSupported(void)
|
||||
GLFWbool _glfwRawMouseMotionSupportedNull(void)
|
||||
{
|
||||
return GLFW_TRUE;
|
||||
}
|
||||
|
||||
void _glfwPlatformShowWindow(_GLFWwindow* window)
|
||||
void _glfwShowWindowNull(_GLFWwindow* window)
|
||||
{
|
||||
window->null.visible = GLFW_TRUE;
|
||||
}
|
||||
|
||||
void _glfwPlatformRequestWindowAttention(_GLFWwindow* window)
|
||||
void _glfwRequestWindowAttentionNull(_GLFWwindow* window)
|
||||
{
|
||||
}
|
||||
|
||||
void _glfwPlatformHideWindow(_GLFWwindow* window)
|
||||
void _glfwHideWindowNull(_GLFWwindow* window)
|
||||
{
|
||||
if (_glfw.null.focusedWindow == window)
|
||||
{
|
||||
@ -420,59 +420,61 @@ void _glfwPlatformHideWindow(_GLFWwindow* window)
|
||||
window->null.visible = GLFW_FALSE;
|
||||
}
|
||||
|
||||
void _glfwPlatformFocusWindow(_GLFWwindow* window)
|
||||
void _glfwFocusWindowNull(_GLFWwindow* window)
|
||||
{
|
||||
_GLFWwindow* previous;
|
||||
|
||||
if (_glfw.null.focusedWindow == window)
|
||||
return;
|
||||
|
||||
if (!window->null.visible)
|
||||
return;
|
||||
|
||||
_GLFWwindow* previous = _glfw.null.focusedWindow;
|
||||
previous = _glfw.null.focusedWindow;
|
||||
_glfw.null.focusedWindow = window;
|
||||
|
||||
if (previous)
|
||||
{
|
||||
_glfwInputWindowFocus(previous, GLFW_FALSE);
|
||||
if (previous->monitor && previous->autoIconify)
|
||||
_glfwPlatformIconifyWindow(previous);
|
||||
_glfwIconifyWindowNull(previous);
|
||||
}
|
||||
|
||||
_glfwInputWindowFocus(window, GLFW_TRUE);
|
||||
}
|
||||
|
||||
int _glfwPlatformWindowFocused(_GLFWwindow* window)
|
||||
int _glfwWindowFocusedNull(_GLFWwindow* window)
|
||||
{
|
||||
return _glfw.null.focusedWindow == window;
|
||||
}
|
||||
|
||||
int _glfwPlatformWindowIconified(_GLFWwindow* window)
|
||||
int _glfwWindowIconifiedNull(_GLFWwindow* window)
|
||||
{
|
||||
return window->null.iconified;
|
||||
}
|
||||
|
||||
int _glfwPlatformWindowVisible(_GLFWwindow* window)
|
||||
int _glfwWindowVisibleNull(_GLFWwindow* window)
|
||||
{
|
||||
return window->null.visible;
|
||||
}
|
||||
|
||||
void _glfwPlatformPollEvents(void)
|
||||
void _glfwPollEventsNull(void)
|
||||
{
|
||||
}
|
||||
|
||||
void _glfwPlatformWaitEvents(void)
|
||||
void _glfwWaitEventsNull(void)
|
||||
{
|
||||
}
|
||||
|
||||
void _glfwPlatformWaitEventsTimeout(double timeout)
|
||||
void _glfwWaitEventsTimeoutNull(double timeout)
|
||||
{
|
||||
}
|
||||
|
||||
void _glfwPlatformPostEmptyEvent(void)
|
||||
void _glfwPostEmptyEventNull(void)
|
||||
{
|
||||
}
|
||||
|
||||
void _glfwPlatformGetCursorPos(_GLFWwindow* window, double* xpos, double* ypos)
|
||||
void _glfwGetCursorPosNull(_GLFWwindow* window, double* xpos, double* ypos)
|
||||
{
|
||||
if (xpos)
|
||||
*xpos = _glfw.null.xcursor - window->null.xpos;
|
||||
@ -480,49 +482,64 @@ void _glfwPlatformGetCursorPos(_GLFWwindow* window, double* xpos, double* ypos)
|
||||
*ypos = _glfw.null.ycursor - window->null.ypos;
|
||||
}
|
||||
|
||||
void _glfwPlatformSetCursorPos(_GLFWwindow* window, double x, double y)
|
||||
void _glfwSetCursorPosNull(_GLFWwindow* window, double x, double y)
|
||||
{
|
||||
_glfw.null.xcursor = window->null.xpos + (int) x;
|
||||
_glfw.null.ycursor = window->null.ypos + (int) y;
|
||||
}
|
||||
|
||||
void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode)
|
||||
void _glfwSetCursorModeNull(_GLFWwindow* window, int mode)
|
||||
{
|
||||
}
|
||||
|
||||
int _glfwPlatformCreateCursor(_GLFWcursor* cursor,
|
||||
const GLFWimage* image,
|
||||
int xhot, int yhot)
|
||||
int _glfwCreateCursorNull(_GLFWcursor* cursor,
|
||||
const GLFWimage* image,
|
||||
int xhot, int yhot)
|
||||
{
|
||||
return GLFW_TRUE;
|
||||
}
|
||||
|
||||
int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape)
|
||||
int _glfwCreateStandardCursorNull(_GLFWcursor* cursor, int shape)
|
||||
{
|
||||
return GLFW_TRUE;
|
||||
}
|
||||
|
||||
void _glfwPlatformDestroyCursor(_GLFWcursor* cursor)
|
||||
void _glfwDestroyCursorNull(_GLFWcursor* cursor)
|
||||
{
|
||||
}
|
||||
|
||||
void _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor)
|
||||
void _glfwSetCursorNull(_GLFWwindow* window, _GLFWcursor* cursor)
|
||||
{
|
||||
}
|
||||
|
||||
void _glfwPlatformSetClipboardString(const char* string)
|
||||
void _glfwSetClipboardStringNull(const char* string)
|
||||
{
|
||||
char* copy = _glfw_strdup(string);
|
||||
_glfw_free(_glfw.null.clipboardString);
|
||||
_glfw.null.clipboardString = copy;
|
||||
}
|
||||
|
||||
const char* _glfwPlatformGetClipboardString(void)
|
||||
const char* _glfwGetClipboardStringNull(void)
|
||||
{
|
||||
return _glfw.null.clipboardString;
|
||||
}
|
||||
|
||||
const char* _glfwPlatformGetScancodeName(int scancode)
|
||||
EGLenum _glfwGetEGLPlatformNull(EGLint** attribs)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
EGLNativeDisplayType _glfwGetEGLNativeDisplayNull(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
EGLNativeWindowType _glfwGetEGLNativeWindowNull(_GLFWwindow* window)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char* _glfwGetScancodeNameNull(int scancode)
|
||||
{
|
||||
if (scancode < GLFW_KEY_SPACE || scancode > GLFW_KEY_LAST)
|
||||
{
|
||||
@ -649,26 +666,26 @@ const char* _glfwPlatformGetScancodeName(int scancode)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int _glfwPlatformGetKeyScancode(int key)
|
||||
int _glfwGetKeyScancodeNull(int key)
|
||||
{
|
||||
return key;
|
||||
}
|
||||
|
||||
void _glfwPlatformGetRequiredInstanceExtensions(char** extensions)
|
||||
void _glfwGetRequiredInstanceExtensionsNull(char** extensions)
|
||||
{
|
||||
}
|
||||
|
||||
int _glfwPlatformGetPhysicalDevicePresentationSupport(VkInstance instance,
|
||||
VkPhysicalDevice device,
|
||||
uint32_t queuefamily)
|
||||
int _glfwGetPhysicalDevicePresentationSupportNull(VkInstance instance,
|
||||
VkPhysicalDevice device,
|
||||
uint32_t queuefamily)
|
||||
{
|
||||
return GLFW_FALSE;
|
||||
}
|
||||
|
||||
VkResult _glfwPlatformCreateWindowSurface(VkInstance instance,
|
||||
_GLFWwindow* window,
|
||||
const VkAllocationCallbacks* allocator,
|
||||
VkSurfaceKHR* surface)
|
||||
VkResult _glfwCreateWindowSurfaceNull(VkInstance instance,
|
||||
_GLFWwindow* window,
|
||||
const VkAllocationCallbacks* allocator,
|
||||
VkSurfaceKHR* surface)
|
||||
{
|
||||
// This seems like the most appropriate error to return here
|
||||
return VK_ERROR_EXTENSION_NOT_PRESENT;
|
||||
|
@ -39,7 +39,7 @@ static void makeContextCurrentOSMesa(_GLFWwindow* window)
|
||||
if (window)
|
||||
{
|
||||
int width, height;
|
||||
_glfwPlatformGetFramebufferSize(window, &width, &height);
|
||||
_glfw.platform.getFramebufferSize(window, &width, &height);
|
||||
|
||||
// Check to see if we need to allocate a new buffer
|
||||
if ((window->context.osmesa.buffer == NULL) ||
|
||||
@ -124,6 +124,8 @@ GLFWbool _glfwInitOSMesa(void)
|
||||
"libOSMesa.8.dylib",
|
||||
#elif defined(__CYGWIN__)
|
||||
"libOSMesa-8.so",
|
||||
#elif defined(__OpenBSD__) || defined(__NetBSD__)
|
||||
"libOSMesa.so",
|
||||
#else
|
||||
"libOSMesa.so.8",
|
||||
"libOSMesa.so.6",
|
||||
@ -136,7 +138,7 @@ GLFWbool _glfwInitOSMesa(void)
|
||||
|
||||
for (i = 0; sonames[i]; i++)
|
||||
{
|
||||
_glfw.osmesa.handle = _glfw_dlopen(sonames[i]);
|
||||
_glfw.osmesa.handle = _glfwPlatformLoadModule(sonames[i]);
|
||||
if (_glfw.osmesa.handle)
|
||||
break;
|
||||
}
|
||||
@ -148,19 +150,19 @@ GLFWbool _glfwInitOSMesa(void)
|
||||
}
|
||||
|
||||
_glfw.osmesa.CreateContextExt = (PFN_OSMesaCreateContextExt)
|
||||
_glfw_dlsym(_glfw.osmesa.handle, "OSMesaCreateContextExt");
|
||||
_glfwPlatformGetModuleSymbol(_glfw.osmesa.handle, "OSMesaCreateContextExt");
|
||||
_glfw.osmesa.CreateContextAttribs = (PFN_OSMesaCreateContextAttribs)
|
||||
_glfw_dlsym(_glfw.osmesa.handle, "OSMesaCreateContextAttribs");
|
||||
_glfwPlatformGetModuleSymbol(_glfw.osmesa.handle, "OSMesaCreateContextAttribs");
|
||||
_glfw.osmesa.DestroyContext = (PFN_OSMesaDestroyContext)
|
||||
_glfw_dlsym(_glfw.osmesa.handle, "OSMesaDestroyContext");
|
||||
_glfwPlatformGetModuleSymbol(_glfw.osmesa.handle, "OSMesaDestroyContext");
|
||||
_glfw.osmesa.MakeCurrent = (PFN_OSMesaMakeCurrent)
|
||||
_glfw_dlsym(_glfw.osmesa.handle, "OSMesaMakeCurrent");
|
||||
_glfwPlatformGetModuleSymbol(_glfw.osmesa.handle, "OSMesaMakeCurrent");
|
||||
_glfw.osmesa.GetColorBuffer = (PFN_OSMesaGetColorBuffer)
|
||||
_glfw_dlsym(_glfw.osmesa.handle, "OSMesaGetColorBuffer");
|
||||
_glfwPlatformGetModuleSymbol(_glfw.osmesa.handle, "OSMesaGetColorBuffer");
|
||||
_glfw.osmesa.GetDepthBuffer = (PFN_OSMesaGetDepthBuffer)
|
||||
_glfw_dlsym(_glfw.osmesa.handle, "OSMesaGetDepthBuffer");
|
||||
_glfwPlatformGetModuleSymbol(_glfw.osmesa.handle, "OSMesaGetDepthBuffer");
|
||||
_glfw.osmesa.GetProcAddress = (PFN_OSMesaGetProcAddress)
|
||||
_glfw_dlsym(_glfw.osmesa.handle, "OSMesaGetProcAddress");
|
||||
_glfwPlatformGetModuleSymbol(_glfw.osmesa.handle, "OSMesaGetProcAddress");
|
||||
|
||||
if (!_glfw.osmesa.CreateContextExt ||
|
||||
!_glfw.osmesa.DestroyContext ||
|
||||
@ -183,12 +185,12 @@ void _glfwTerminateOSMesa(void)
|
||||
{
|
||||
if (_glfw.osmesa.handle)
|
||||
{
|
||||
_glfw_dlclose(_glfw.osmesa.handle);
|
||||
_glfwPlatformFreeModule(_glfw.osmesa.handle);
|
||||
_glfw.osmesa.handle = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
#define setAttrib(a, v) \
|
||||
#define SET_ATTRIB(a, v) \
|
||||
{ \
|
||||
assert(((size_t) index + 1) < sizeof(attribs) / sizeof(attribs[0])); \
|
||||
attribs[index++] = a; \
|
||||
@ -219,24 +221,24 @@ GLFWbool _glfwCreateContextForConfigOSMesa(const _GLFWctxconfig* ctxconfig,
|
||||
{
|
||||
int index = 0, attribs[40];
|
||||
|
||||
setAttrib(OSMESA_FORMAT, OSMESA_RGBA);
|
||||
setAttrib(OSMESA_DEPTH_BITS, fbconfig->depthBits);
|
||||
setAttrib(OSMESA_STENCIL_BITS, fbconfig->stencilBits);
|
||||
setAttrib(OSMESA_ACCUM_BITS, accumBits);
|
||||
SET_ATTRIB(OSMESA_FORMAT, OSMESA_RGBA);
|
||||
SET_ATTRIB(OSMESA_DEPTH_BITS, fbconfig->depthBits);
|
||||
SET_ATTRIB(OSMESA_STENCIL_BITS, fbconfig->stencilBits);
|
||||
SET_ATTRIB(OSMESA_ACCUM_BITS, accumBits);
|
||||
|
||||
if (ctxconfig->profile == GLFW_OPENGL_CORE_PROFILE)
|
||||
{
|
||||
setAttrib(OSMESA_PROFILE, OSMESA_CORE_PROFILE);
|
||||
SET_ATTRIB(OSMESA_PROFILE, OSMESA_CORE_PROFILE);
|
||||
}
|
||||
else if (ctxconfig->profile == GLFW_OPENGL_COMPAT_PROFILE)
|
||||
{
|
||||
setAttrib(OSMESA_PROFILE, OSMESA_COMPAT_PROFILE);
|
||||
SET_ATTRIB(OSMESA_PROFILE, OSMESA_COMPAT_PROFILE);
|
||||
}
|
||||
|
||||
if (ctxconfig->major != 1 || ctxconfig->minor != 0)
|
||||
{
|
||||
setAttrib(OSMESA_CONTEXT_MAJOR_VERSION, ctxconfig->major);
|
||||
setAttrib(OSMESA_CONTEXT_MINOR_VERSION, ctxconfig->minor);
|
||||
SET_ATTRIB(OSMESA_CONTEXT_MAJOR_VERSION, ctxconfig->major);
|
||||
SET_ATTRIB(OSMESA_CONTEXT_MINOR_VERSION, ctxconfig->minor);
|
||||
}
|
||||
|
||||
if (ctxconfig->forward)
|
||||
@ -246,7 +248,7 @@ GLFWbool _glfwCreateContextForConfigOSMesa(const _GLFWctxconfig* ctxconfig,
|
||||
return GLFW_FALSE;
|
||||
}
|
||||
|
||||
setAttrib(0, 0);
|
||||
SET_ATTRIB(0, 0);
|
||||
|
||||
*context =
|
||||
OSMesaCreateContextAttribs(attribs, share);
|
||||
@ -351,6 +353,8 @@ _GLFWusercontext* _glfwCreateUserContextOSMesa(_GLFWwindow* window)
|
||||
return context;
|
||||
}
|
||||
|
||||
#undef SET_ATTRIB
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
////// GLFW native API //////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@ -365,6 +369,12 @@ GLFWAPI int glfwGetOSMesaColorBuffer(GLFWwindow* handle, int* width,
|
||||
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(GLFW_FALSE);
|
||||
|
||||
if (window->context.source != GLFW_OSMESA_CONTEXT_API)
|
||||
{
|
||||
_glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL);
|
||||
return GLFW_FALSE;
|
||||
}
|
||||
|
||||
if (!OSMesaGetColorBuffer(window->context.osmesa.handle,
|
||||
&mesaWidth, &mesaHeight,
|
||||
&mesaFormat, &mesaBuffer))
|
||||
@ -398,6 +408,12 @@ GLFWAPI int glfwGetOSMesaDepthBuffer(GLFWwindow* handle,
|
||||
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(GLFW_FALSE);
|
||||
|
||||
if (window->context.source != GLFW_OSMESA_CONTEXT_API)
|
||||
{
|
||||
_glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL);
|
||||
return GLFW_FALSE;
|
||||
}
|
||||
|
||||
if (!OSMesaGetDepthBuffer(window->context.osmesa.handle,
|
||||
&mesaWidth, &mesaHeight,
|
||||
&mesaBytes, &mesaBuffer))
|
||||
@ -424,7 +440,7 @@ GLFWAPI OSMesaContext glfwGetOSMesaContext(GLFWwindow* handle)
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||
|
||||
if (window->context.client == GLFW_NO_API)
|
||||
if (window->context.source != GLFW_OSMESA_CONTEXT_API)
|
||||
{
|
||||
_glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL);
|
||||
return NULL;
|
||||
|
@ -1,97 +0,0 @@
|
||||
//========================================================================
|
||||
// GLFW 3.4 OSMesa - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2016 Google Inc.
|
||||
// Copyright (c) 2016-2017 Camilla Löwy <elmindreda@glfw.org>
|
||||
//
|
||||
// This software is provided 'as-is', without any express or implied
|
||||
// warranty. In no event will the authors be held liable for any damages
|
||||
// arising from the use of this software.
|
||||
//
|
||||
// Permission is granted to anyone to use this software for any purpose,
|
||||
// including commercial applications, and to alter it and redistribute it
|
||||
// freely, subject to the following restrictions:
|
||||
//
|
||||
// 1. The origin of this software must not be misrepresented; you must not
|
||||
// claim that you wrote the original software. If you use this software
|
||||
// in a product, an acknowledgment in the product documentation would
|
||||
// be appreciated but is not required.
|
||||
//
|
||||
// 2. Altered source versions must be plainly marked as such, and must not
|
||||
// be misrepresented as being the original software.
|
||||
//
|
||||
// 3. This notice may not be removed or altered from any source
|
||||
// distribution.
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#define OSMESA_RGBA 0x1908
|
||||
#define OSMESA_FORMAT 0x22
|
||||
#define OSMESA_DEPTH_BITS 0x30
|
||||
#define OSMESA_STENCIL_BITS 0x31
|
||||
#define OSMESA_ACCUM_BITS 0x32
|
||||
#define OSMESA_PROFILE 0x33
|
||||
#define OSMESA_CORE_PROFILE 0x34
|
||||
#define OSMESA_COMPAT_PROFILE 0x35
|
||||
#define OSMESA_CONTEXT_MAJOR_VERSION 0x36
|
||||
#define OSMESA_CONTEXT_MINOR_VERSION 0x37
|
||||
|
||||
typedef void* OSMesaContext;
|
||||
typedef void (*OSMESAproc)(void);
|
||||
|
||||
typedef OSMesaContext (GLAPIENTRY * PFN_OSMesaCreateContextExt)(GLenum,GLint,GLint,GLint,OSMesaContext);
|
||||
typedef OSMesaContext (GLAPIENTRY * PFN_OSMesaCreateContextAttribs)(const int*,OSMesaContext);
|
||||
typedef void (GLAPIENTRY * PFN_OSMesaDestroyContext)(OSMesaContext);
|
||||
typedef int (GLAPIENTRY * PFN_OSMesaMakeCurrent)(OSMesaContext,void*,int,int,int);
|
||||
typedef int (GLAPIENTRY * PFN_OSMesaGetColorBuffer)(OSMesaContext,int*,int*,int*,void**);
|
||||
typedef int (GLAPIENTRY * PFN_OSMesaGetDepthBuffer)(OSMesaContext,int*,int*,int*,void**);
|
||||
typedef GLFWglproc (GLAPIENTRY * PFN_OSMesaGetProcAddress)(const char*);
|
||||
#define OSMesaCreateContextExt _glfw.osmesa.CreateContextExt
|
||||
#define OSMesaCreateContextAttribs _glfw.osmesa.CreateContextAttribs
|
||||
#define OSMesaDestroyContext _glfw.osmesa.DestroyContext
|
||||
#define OSMesaMakeCurrent _glfw.osmesa.MakeCurrent
|
||||
#define OSMesaGetColorBuffer _glfw.osmesa.GetColorBuffer
|
||||
#define OSMesaGetDepthBuffer _glfw.osmesa.GetDepthBuffer
|
||||
#define OSMesaGetProcAddress _glfw.osmesa.GetProcAddress
|
||||
|
||||
// OSMesa-specific per-context data
|
||||
//
|
||||
typedef struct _GLFWcontextOSMesa
|
||||
{
|
||||
OSMesaContext handle;
|
||||
int width;
|
||||
int height;
|
||||
void* buffer;
|
||||
|
||||
} _GLFWcontextOSMesa;
|
||||
|
||||
// OSMesa-specific per user context data
|
||||
//
|
||||
typedef struct _GLFWusercontextOSMesa
|
||||
{
|
||||
OSMesaContext handle;
|
||||
} _GLFWusercontextOSMesa;
|
||||
|
||||
// OSMesa-specific global data
|
||||
//
|
||||
typedef struct _GLFWlibraryOSMesa
|
||||
{
|
||||
void* handle;
|
||||
|
||||
PFN_OSMesaCreateContextExt CreateContextExt;
|
||||
PFN_OSMesaCreateContextAttribs CreateContextAttribs;
|
||||
PFN_OSMesaDestroyContext DestroyContext;
|
||||
PFN_OSMesaMakeCurrent MakeCurrent;
|
||||
PFN_OSMesaGetColorBuffer GetColorBuffer;
|
||||
PFN_OSMesaGetDepthBuffer GetDepthBuffer;
|
||||
PFN_OSMesaGetProcAddress GetProcAddress;
|
||||
|
||||
} _GLFWlibraryOSMesa;
|
||||
|
||||
|
||||
GLFWbool _glfwInitOSMesa(void);
|
||||
void _glfwTerminateOSMesa(void);
|
||||
GLFWbool _glfwCreateContextOSMesa(_GLFWwindow* window,
|
||||
const _GLFWctxconfig* ctxconfig,
|
||||
const _GLFWfbconfig* fbconfig);
|
||||
_GLFWusercontext* _glfwCreateUserContextOSMesa(_GLFWwindow* window);
|
189
src/platform.c
Normal file
189
src/platform.c
Normal file
@ -0,0 +1,189 @@
|
||||
//========================================================================
|
||||
// GLFW 3.4 - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2002-2006 Marcus Geelnard
|
||||
// Copyright (c) 2006-2018 Camilla Löwy <elmindreda@glfw.org>
|
||||
//
|
||||
// This software is provided 'as-is', without any express or implied
|
||||
// warranty. In no event will the authors be held liable for any damages
|
||||
// arising from the use of this software.
|
||||
//
|
||||
// Permission is granted to anyone to use this software for any purpose,
|
||||
// including commercial applications, and to alter it and redistribute it
|
||||
// freely, subject to the following restrictions:
|
||||
//
|
||||
// 1. The origin of this software must not be misrepresented; you must not
|
||||
// claim that you wrote the original software. If you use this software
|
||||
// in a product, an acknowledgment in the product documentation would
|
||||
// be appreciated but is not required.
|
||||
//
|
||||
// 2. Altered source versions must be plainly marked as such, and must not
|
||||
// be misrepresented as being the original software.
|
||||
//
|
||||
// 3. This notice may not be removed or altered from any source
|
||||
// distribution.
|
||||
//
|
||||
//========================================================================
|
||||
// Please use C89 style variable declarations in this file because VS 2010
|
||||
//========================================================================
|
||||
|
||||
#include "internal.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
////// GLFW internal API //////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static const struct
|
||||
{
|
||||
int ID;
|
||||
GLFWbool (*connect)(int,_GLFWplatform*);
|
||||
} supportedPlatforms[] =
|
||||
{
|
||||
#if defined(_GLFW_WIN32)
|
||||
{ GLFW_PLATFORM_WIN32, _glfwConnectWin32 },
|
||||
#endif
|
||||
#if defined(_GLFW_COCOA)
|
||||
{ GLFW_PLATFORM_COCOA, _glfwConnectCocoa },
|
||||
#endif
|
||||
#if defined(_GLFW_X11)
|
||||
{ GLFW_PLATFORM_X11, _glfwConnectX11 },
|
||||
#endif
|
||||
#if defined(_GLFW_WAYLAND)
|
||||
{ GLFW_PLATFORM_WAYLAND, _glfwConnectWayland },
|
||||
#endif
|
||||
};
|
||||
|
||||
GLFWbool _glfwSelectPlatform(int desiredID, _GLFWplatform* platform)
|
||||
{
|
||||
const size_t count = sizeof(supportedPlatforms) / sizeof(supportedPlatforms[0]);
|
||||
size_t i;
|
||||
|
||||
if (desiredID != GLFW_ANY_PLATFORM &&
|
||||
desiredID != GLFW_PLATFORM_WIN32 &&
|
||||
desiredID != GLFW_PLATFORM_COCOA &&
|
||||
desiredID != GLFW_PLATFORM_WAYLAND &&
|
||||
desiredID != GLFW_PLATFORM_X11 &&
|
||||
desiredID != GLFW_PLATFORM_NULL)
|
||||
{
|
||||
_glfwInputError(GLFW_INVALID_ENUM, "Invalid platform ID 0x%08X", desiredID);
|
||||
return GLFW_FALSE;
|
||||
}
|
||||
|
||||
// Only allow the Null platform if specifically requested
|
||||
if (desiredID == GLFW_PLATFORM_NULL)
|
||||
return _glfwConnectNull(desiredID, platform);
|
||||
else if (count == 0)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_UNAVAILABLE, "This binary only supports the Null platform");
|
||||
return GLFW_FALSE;
|
||||
}
|
||||
|
||||
if (desiredID == GLFW_ANY_PLATFORM)
|
||||
{
|
||||
// If there is exactly one platform available for auto-selection, let it emit the
|
||||
// error on failure as the platform-specific error description may be more helpful
|
||||
if (count == 1)
|
||||
return supportedPlatforms[0].connect(supportedPlatforms[0].ID, platform);
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
if (supportedPlatforms[i].connect(desiredID, platform))
|
||||
return GLFW_TRUE;
|
||||
}
|
||||
|
||||
_glfwInputError(GLFW_PLATFORM_UNAVAILABLE, "Failed to detect any supported platform");
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
if (supportedPlatforms[i].ID == desiredID)
|
||||
return supportedPlatforms[i].connect(desiredID, platform);
|
||||
}
|
||||
|
||||
_glfwInputError(GLFW_PLATFORM_UNAVAILABLE, "The requested platform is not supported");
|
||||
}
|
||||
|
||||
return GLFW_FALSE;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
////// GLFW public API //////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
GLFWAPI int glfwGetPlatform(void)
|
||||
{
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(0);
|
||||
return _glfw.platform.platformID;
|
||||
}
|
||||
|
||||
GLFWAPI int glfwPlatformSupported(int platformID)
|
||||
{
|
||||
const size_t count = sizeof(supportedPlatforms) / sizeof(supportedPlatforms[0]);
|
||||
size_t i;
|
||||
|
||||
if (platformID != GLFW_PLATFORM_WIN32 &&
|
||||
platformID != GLFW_PLATFORM_COCOA &&
|
||||
platformID != GLFW_PLATFORM_WAYLAND &&
|
||||
platformID != GLFW_PLATFORM_X11 &&
|
||||
platformID != GLFW_PLATFORM_NULL)
|
||||
{
|
||||
_glfwInputError(GLFW_INVALID_ENUM, "Invalid platform ID 0x%08X", platformID);
|
||||
return GLFW_FALSE;
|
||||
}
|
||||
|
||||
if (platformID == GLFW_PLATFORM_NULL)
|
||||
return GLFW_TRUE;
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
if (platformID == supportedPlatforms[i].ID)
|
||||
return GLFW_TRUE;
|
||||
}
|
||||
|
||||
return GLFW_FALSE;
|
||||
}
|
||||
|
||||
GLFWAPI const char* glfwGetVersionString(void)
|
||||
{
|
||||
return _GLFW_VERSION_NUMBER
|
||||
#if defined(_GLFW_WIN32)
|
||||
" Win32 WGL"
|
||||
#endif
|
||||
#if defined(_GLFW_COCOA)
|
||||
" Cocoa NSGL"
|
||||
#endif
|
||||
#if defined(_GLFW_WAYLAND)
|
||||
" Wayland"
|
||||
#endif
|
||||
#if defined(_GLFW_X11)
|
||||
" X11 GLX"
|
||||
#endif
|
||||
" Null"
|
||||
" EGL"
|
||||
" OSMesa"
|
||||
#if defined(__MINGW64_VERSION_MAJOR)
|
||||
" MinGW-w64"
|
||||
#elif defined(__MINGW32__)
|
||||
" MinGW"
|
||||
#elif defined(_MSC_VER)
|
||||
" VisualC"
|
||||
#endif
|
||||
#if defined(_GLFW_USE_HYBRID_HPG) || defined(_GLFW_USE_OPTIMUS_HPG)
|
||||
" hybrid-GPU"
|
||||
#endif
|
||||
#if defined(_POSIX_MONOTONIC_CLOCK)
|
||||
" monotonic"
|
||||
#endif
|
||||
#if defined(_GLFW_BUILD_DLL)
|
||||
#if defined(_WIN32)
|
||||
" DLL"
|
||||
#elif defined(__APPLE__)
|
||||
" dynamic"
|
||||
#else
|
||||
" shared"
|
||||
#endif
|
||||
#endif
|
||||
;
|
||||
}
|
||||
|
186
src/platform.h
Normal file
186
src/platform.h
Normal file
@ -0,0 +1,186 @@
|
||||
//========================================================================
|
||||
// GLFW 3.4 - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2002-2006 Marcus Geelnard
|
||||
// Copyright (c) 2006-2018 Camilla Löwy <elmindreda@glfw.org>
|
||||
//
|
||||
// This software is provided 'as-is', without any express or implied
|
||||
// warranty. In no event will the authors be held liable for any damages
|
||||
// arising from the use of this software.
|
||||
//
|
||||
// Permission is granted to anyone to use this software for any purpose,
|
||||
// including commercial applications, and to alter it and redistribute it
|
||||
// freely, subject to the following restrictions:
|
||||
//
|
||||
// 1. The origin of this software must not be misrepresented; you must not
|
||||
// claim that you wrote the original software. If you use this software
|
||||
// in a product, an acknowledgment in the product documentation would
|
||||
// be appreciated but is not required.
|
||||
//
|
||||
// 2. Altered source versions must be plainly marked as such, and must not
|
||||
// be misrepresented as being the original software.
|
||||
//
|
||||
// 3. This notice may not be removed or altered from any source
|
||||
// distribution.
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#include "null_platform.h"
|
||||
|
||||
#if defined(_GLFW_WIN32)
|
||||
#include "win32_platform.h"
|
||||
#else
|
||||
#define GLFW_WIN32_WINDOW_STATE
|
||||
#define GLFW_WIN32_MONITOR_STATE
|
||||
#define GLFW_WIN32_CURSOR_STATE
|
||||
#define GLFW_WIN32_LIBRARY_WINDOW_STATE
|
||||
#define GLFW_WGL_CONTEXT_STATE
|
||||
#define GLFW_WGL_LIBRARY_CONTEXT_STATE
|
||||
#define GLFW_WGL_USER_CONTEXT_STATE
|
||||
#endif
|
||||
|
||||
#if defined(_GLFW_COCOA)
|
||||
#include "cocoa_platform.h"
|
||||
#else
|
||||
#define GLFW_COCOA_WINDOW_STATE
|
||||
#define GLFW_COCOA_MONITOR_STATE
|
||||
#define GLFW_COCOA_CURSOR_STATE
|
||||
#define GLFW_COCOA_LIBRARY_WINDOW_STATE
|
||||
#define GLFW_NSGL_CONTEXT_STATE
|
||||
#define GLFW_NSGL_LIBRARY_CONTEXT_STATE
|
||||
#define GLFW_NSGL_USER_CONTEXT_STATE
|
||||
#endif
|
||||
|
||||
#if defined(_GLFW_WAYLAND)
|
||||
#include "wl_platform.h"
|
||||
#else
|
||||
#define GLFW_WAYLAND_WINDOW_STATE
|
||||
#define GLFW_WAYLAND_MONITOR_STATE
|
||||
#define GLFW_WAYLAND_CURSOR_STATE
|
||||
#define GLFW_WAYLAND_LIBRARY_WINDOW_STATE
|
||||
#endif
|
||||
|
||||
#if defined(_GLFW_X11)
|
||||
#include "x11_platform.h"
|
||||
#else
|
||||
#define GLFW_X11_WINDOW_STATE
|
||||
#define GLFW_X11_MONITOR_STATE
|
||||
#define GLFW_X11_CURSOR_STATE
|
||||
#define GLFW_X11_LIBRARY_WINDOW_STATE
|
||||
#define GLFW_GLX_CONTEXT_STATE
|
||||
#define GLFW_GLX_LIBRARY_CONTEXT_STATE
|
||||
#define GLFW_GLX_USER_CONTEXT_STATE
|
||||
#endif
|
||||
|
||||
#include "null_joystick.h"
|
||||
|
||||
#if defined(_GLFW_WIN32)
|
||||
#include "win32_joystick.h"
|
||||
#else
|
||||
#define GLFW_WIN32_JOYSTICK_STATE
|
||||
#define GLFW_WIN32_LIBRARY_JOYSTICK_STATE
|
||||
#endif
|
||||
|
||||
#if defined(_GLFW_COCOA)
|
||||
#include "cocoa_joystick.h"
|
||||
#else
|
||||
#define GLFW_COCOA_JOYSTICK_STATE
|
||||
#define GLFW_COCOA_LIBRARY_JOYSTICK_STATE
|
||||
#endif
|
||||
|
||||
#if (defined(_GLFW_X11) || defined(_GLFW_WAYLAND)) && defined(__linux__)
|
||||
#include "linux_joystick.h"
|
||||
#else
|
||||
#define GLFW_LINUX_JOYSTICK_STATE
|
||||
#define GLFW_LINUX_LIBRARY_JOYSTICK_STATE
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32)
|
||||
#include "win32_thread.h"
|
||||
#define GLFW_POSIX_TLS_STATE
|
||||
#define GLFW_POSIX_MUTEX_STATE
|
||||
#else
|
||||
#include "posix_thread.h"
|
||||
#define GLFW_WIN32_TLS_STATE
|
||||
#define GLFW_WIN32_MUTEX_STATE
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32)
|
||||
#include "win32_time.h"
|
||||
#define GLFW_POSIX_LIBRARY_TIMER_STATE
|
||||
#define GLFW_COCOA_LIBRARY_TIMER_STATE
|
||||
#elif defined(__APPLE__)
|
||||
#include "cocoa_time.h"
|
||||
#define GLFW_WIN32_LIBRARY_TIMER_STATE
|
||||
#define GLFW_POSIX_LIBRARY_TIMER_STATE
|
||||
#else
|
||||
#include "posix_time.h"
|
||||
#define GLFW_WIN32_LIBRARY_TIMER_STATE
|
||||
#define GLFW_COCOA_LIBRARY_TIMER_STATE
|
||||
#endif
|
||||
|
||||
#define GLFW_PLATFORM_WINDOW_STATE \
|
||||
GLFW_WIN32_WINDOW_STATE \
|
||||
GLFW_COCOA_WINDOW_STATE \
|
||||
GLFW_WAYLAND_WINDOW_STATE \
|
||||
GLFW_X11_WINDOW_STATE \
|
||||
GLFW_NULL_WINDOW_STATE \
|
||||
|
||||
#define GLFW_PLATFORM_MONITOR_STATE \
|
||||
GLFW_WIN32_MONITOR_STATE \
|
||||
GLFW_COCOA_MONITOR_STATE \
|
||||
GLFW_WAYLAND_MONITOR_STATE \
|
||||
GLFW_X11_MONITOR_STATE \
|
||||
GLFW_NULL_MONITOR_STATE \
|
||||
|
||||
#define GLFW_PLATFORM_CURSOR_STATE \
|
||||
GLFW_WIN32_CURSOR_STATE \
|
||||
GLFW_COCOA_CURSOR_STATE \
|
||||
GLFW_WAYLAND_CURSOR_STATE \
|
||||
GLFW_X11_CURSOR_STATE \
|
||||
GLFW_NULL_CURSOR_STATE \
|
||||
|
||||
#define GLFW_PLATFORM_JOYSTICK_STATE \
|
||||
GLFW_WIN32_JOYSTICK_STATE \
|
||||
GLFW_COCOA_JOYSTICK_STATE \
|
||||
GLFW_LINUX_JOYSTICK_STATE
|
||||
|
||||
#define GLFW_PLATFORM_TLS_STATE \
|
||||
GLFW_WIN32_TLS_STATE \
|
||||
GLFW_POSIX_TLS_STATE \
|
||||
|
||||
#define GLFW_PLATFORM_MUTEX_STATE \
|
||||
GLFW_WIN32_MUTEX_STATE \
|
||||
GLFW_POSIX_MUTEX_STATE \
|
||||
|
||||
#define GLFW_PLATFORM_LIBRARY_WINDOW_STATE \
|
||||
GLFW_WIN32_LIBRARY_WINDOW_STATE \
|
||||
GLFW_COCOA_LIBRARY_WINDOW_STATE \
|
||||
GLFW_WAYLAND_LIBRARY_WINDOW_STATE \
|
||||
GLFW_X11_LIBRARY_WINDOW_STATE \
|
||||
GLFW_NULL_LIBRARY_WINDOW_STATE \
|
||||
|
||||
#define GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE \
|
||||
GLFW_WIN32_LIBRARY_JOYSTICK_STATE \
|
||||
GLFW_COCOA_LIBRARY_JOYSTICK_STATE \
|
||||
GLFW_LINUX_LIBRARY_JOYSTICK_STATE
|
||||
|
||||
#define GLFW_PLATFORM_LIBRARY_TIMER_STATE \
|
||||
GLFW_WIN32_LIBRARY_TIMER_STATE \
|
||||
GLFW_COCOA_LIBRARY_TIMER_STATE \
|
||||
GLFW_POSIX_LIBRARY_TIMER_STATE \
|
||||
|
||||
#define GLFW_PLATFORM_CONTEXT_STATE \
|
||||
GLFW_WGL_CONTEXT_STATE \
|
||||
GLFW_NSGL_CONTEXT_STATE \
|
||||
GLFW_GLX_CONTEXT_STATE
|
||||
|
||||
#define GLFW_PLATFORM_LIBRARY_CONTEXT_STATE \
|
||||
GLFW_WGL_LIBRARY_CONTEXT_STATE \
|
||||
GLFW_NSGL_LIBRARY_CONTEXT_STATE \
|
||||
GLFW_GLX_LIBRARY_CONTEXT_STATE
|
||||
|
||||
#define GLFW_PLATFORM_USER_CONTEXT_STATE \
|
||||
GLFW_WGL_USER_CONTEXT_STATE \
|
||||
GLFW_NSGL_USER_CONTEXT_STATE \
|
||||
GLFW_GLX_USER_CONTEXT_STATE
|
51
src/posix_module.c
Normal file
51
src/posix_module.c
Normal file
@ -0,0 +1,51 @@
|
||||
//========================================================================
|
||||
// GLFW 3.4 POSIX - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2021 Camilla Löwy <elmindreda@glfw.org>
|
||||
//
|
||||
// This software is provided 'as-is', without any express or implied
|
||||
// warranty. In no event will the authors be held liable for any damages
|
||||
// arising from the use of this software.
|
||||
//
|
||||
// Permission is granted to anyone to use this software for any purpose,
|
||||
// including commercial applications, and to alter it and redistribute it
|
||||
// freely, subject to the following restrictions:
|
||||
//
|
||||
// 1. The origin of this software must not be misrepresented; you must not
|
||||
// claim that you wrote the original software. If you use this software
|
||||
// in a product, an acknowledgment in the product documentation would
|
||||
// be appreciated but is not required.
|
||||
//
|
||||
// 2. Altered source versions must be plainly marked as such, and must not
|
||||
// be misrepresented as being the original software.
|
||||
//
|
||||
// 3. This notice may not be removed or altered from any source
|
||||
// distribution.
|
||||
//
|
||||
//========================================================================
|
||||
// It is fine to use C99 in this file because it will not be built with VS
|
||||
//========================================================================
|
||||
|
||||
#include "internal.h"
|
||||
|
||||
#include <dlfcn.h>
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
////// GLFW platform API //////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void* _glfwPlatformLoadModule(const char* path)
|
||||
{
|
||||
return dlopen(path, RTLD_LAZY | RTLD_LOCAL);
|
||||
}
|
||||
|
||||
void _glfwPlatformFreeModule(void* module)
|
||||
{
|
||||
dlclose(module);
|
||||
}
|
||||
|
||||
GLFWproc _glfwPlatformGetModuleSymbol(void* module, const char* name)
|
||||
{
|
||||
return dlsym(module, name);
|
||||
}
|
||||
|
81
src/posix_poll.c
Normal file
81
src/posix_poll.c
Normal file
@ -0,0 +1,81 @@
|
||||
//========================================================================
|
||||
// GLFW 3.4 POSIX - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2022 Camilla Löwy <elmindreda@glfw.org>
|
||||
//
|
||||
// This software is provided 'as-is', without any express or implied
|
||||
// warranty. In no event will the authors be held liable for any damages
|
||||
// arising from the use of this software.
|
||||
//
|
||||
// Permission is granted to anyone to use this software for any purpose,
|
||||
// including commercial applications, and to alter it and redistribute it
|
||||
// freely, subject to the following restrictions:
|
||||
//
|
||||
// 1. The origin of this software must not be misrepresented; you must not
|
||||
// claim that you wrote the original software. If you use this software
|
||||
// in a product, an acknowledgment in the product documentation would
|
||||
// be appreciated but is not required.
|
||||
//
|
||||
// 2. Altered source versions must be plainly marked as such, and must not
|
||||
// be misrepresented as being the original software.
|
||||
//
|
||||
// 3. This notice may not be removed or altered from any source
|
||||
// distribution.
|
||||
//
|
||||
//========================================================================
|
||||
// It is fine to use C99 in this file because it will not be built with VS
|
||||
//========================================================================
|
||||
|
||||
#define _GNU_SOURCE
|
||||
|
||||
#include "internal.h"
|
||||
|
||||
#include <signal.h>
|
||||
#include <time.h>
|
||||
#include <errno.h>
|
||||
|
||||
GLFWbool _glfwPollPOSIX(struct pollfd* fds, nfds_t count, double* timeout)
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
if (timeout)
|
||||
{
|
||||
const uint64_t base = _glfwPlatformGetTimerValue();
|
||||
|
||||
#if defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__CYGWIN__)
|
||||
const time_t seconds = (time_t) *timeout;
|
||||
const long nanoseconds = (long) ((*timeout - seconds) * 1e9);
|
||||
const struct timespec ts = { seconds, nanoseconds };
|
||||
const int result = ppoll(fds, count, &ts, NULL);
|
||||
#elif defined(__NetBSD__)
|
||||
const time_t seconds = (time_t) *timeout;
|
||||
const long nanoseconds = (long) ((*timeout - seconds) * 1e9);
|
||||
const struct timespec ts = { seconds, nanoseconds };
|
||||
const int result = pollts(fds, count, &ts, NULL);
|
||||
#else
|
||||
const int milliseconds = (int) (*timeout * 1e3);
|
||||
const int result = poll(fds, count, milliseconds);
|
||||
#endif
|
||||
const int error = errno; // clock_gettime may overwrite our error
|
||||
|
||||
*timeout -= (_glfwPlatformGetTimerValue() - base) /
|
||||
(double) _glfwPlatformGetTimerFrequency();
|
||||
|
||||
if (result > 0)
|
||||
return GLFW_TRUE;
|
||||
else if (result == -1 && error != EINTR && error != EAGAIN)
|
||||
return GLFW_FALSE;
|
||||
else if (*timeout <= 0.0)
|
||||
return GLFW_FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
const int result = poll(fds, count, -1);
|
||||
if (result > 0)
|
||||
return GLFW_TRUE;
|
||||
else if (result == -1 && errno != EINTR && errno != EAGAIN)
|
||||
return GLFW_FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
32
src/posix_poll.h
Normal file
32
src/posix_poll.h
Normal file
@ -0,0 +1,32 @@
|
||||
//========================================================================
|
||||
// GLFW 3.4 POSIX - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2022 Camilla Löwy <elmindreda@glfw.org>
|
||||
//
|
||||
// This software is provided 'as-is', without any express or implied
|
||||
// warranty. In no event will the authors be held liable for any damages
|
||||
// arising from the use of this software.
|
||||
//
|
||||
// Permission is granted to anyone to use this software for any purpose,
|
||||
// including commercial applications, and to alter it and redistribute it
|
||||
// freely, subject to the following restrictions:
|
||||
//
|
||||
// 1. The origin of this software must not be misrepresented; you must not
|
||||
// claim that you wrote the original software. If you use this software
|
||||
// in a product, an acknowledgment in the product documentation would
|
||||
// be appreciated but is not required.
|
||||
//
|
||||
// 2. Altered source versions must be plainly marked as such, and must not
|
||||
// be misrepresented as being the original software.
|
||||
//
|
||||
// 3. This notice may not be removed or altered from any source
|
||||
// distribution.
|
||||
//
|
||||
//========================================================================
|
||||
// It is fine to use C99 in this file because it will not be built with VS
|
||||
//========================================================================
|
||||
|
||||
#include <poll.h>
|
||||
|
||||
GLFWbool _glfwPollPOSIX(struct pollfd* fds, nfds_t count, double* timeout);
|
||||
|
@ -27,8 +27,8 @@
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
#define _GLFW_PLATFORM_TLS_STATE _GLFWtlsPOSIX posix
|
||||
#define _GLFW_PLATFORM_MUTEX_STATE _GLFWmutexPOSIX posix
|
||||
#define GLFW_POSIX_TLS_STATE _GLFWtlsPOSIX posix;
|
||||
#define GLFW_POSIX_MUTEX_STATE _GLFWmutexPOSIX posix;
|
||||
|
||||
|
||||
// POSIX-specific thread local storage data
|
||||
@ -37,7 +37,6 @@ typedef struct _GLFWtlsPOSIX
|
||||
{
|
||||
GLFWbool allocated;
|
||||
pthread_key_t key;
|
||||
|
||||
} _GLFWtlsPOSIX;
|
||||
|
||||
// POSIX-specific mutex data
|
||||
@ -46,6 +45,5 @@ typedef struct _GLFWmutexPOSIX
|
||||
{
|
||||
GLFWbool allocated;
|
||||
pthread_mutex_t handle;
|
||||
|
||||
} _GLFWmutexPOSIX;
|
||||
|
||||
|
@ -34,12 +34,10 @@
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
////// GLFW internal API //////
|
||||
////// GLFW platform API //////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Initialise timer
|
||||
//
|
||||
void _glfwInitTimerPOSIX(void)
|
||||
void _glfwPlatformInitTimer(void)
|
||||
{
|
||||
_glfw.timer.posix.clock = CLOCK_REALTIME;
|
||||
_glfw.timer.posix.frequency = 1000000000;
|
||||
@ -51,11 +49,6 @@ void _glfwInitTimerPOSIX(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
////// GLFW platform API //////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
uint64_t _glfwPlatformGetTimerValue(void)
|
||||
{
|
||||
struct timespec ts;
|
||||
|
@ -25,7 +25,7 @@
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#define _GLFW_PLATFORM_LIBRARY_TIMER_STATE _GLFWtimerPOSIX posix
|
||||
#define GLFW_POSIX_LIBRARY_TIMER_STATE _GLFWtimerPOSIX posix;
|
||||
|
||||
#include <stdint.h>
|
||||
#include <time.h>
|
||||
@ -37,9 +37,5 @@ typedef struct _GLFWtimerPOSIX
|
||||
{
|
||||
clockid_t clock;
|
||||
uint64_t frequency;
|
||||
|
||||
} _GLFWtimerPOSIX;
|
||||
|
||||
|
||||
void _glfwInitTimerPOSIX(void);
|
||||
|
||||
|
90
src/vulkan.c
90
src/vulkan.c
@ -45,45 +45,52 @@ GLFWbool _glfwInitVulkan(int mode)
|
||||
{
|
||||
VkResult err;
|
||||
VkExtensionProperties* ep;
|
||||
PFN_vkEnumerateInstanceExtensionProperties vkEnumerateInstanceExtensionProperties;
|
||||
uint32_t i, count;
|
||||
|
||||
if (_glfw.vk.available)
|
||||
return GLFW_TRUE;
|
||||
|
||||
#if !defined(_GLFW_VULKAN_STATIC)
|
||||
if (_glfw.hints.init.vulkanLoader)
|
||||
_glfw.vk.GetInstanceProcAddr = _glfw.hints.init.vulkanLoader;
|
||||
else
|
||||
{
|
||||
#if defined(_GLFW_VULKAN_LIBRARY)
|
||||
_glfw.vk.handle = _glfw_dlopen(_GLFW_VULKAN_LIBRARY);
|
||||
_glfw.vk.handle = _glfwPlatformLoadModule(_GLFW_VULKAN_LIBRARY);
|
||||
#elif defined(_GLFW_WIN32)
|
||||
_glfw.vk.handle = _glfw_dlopen("vulkan-1.dll");
|
||||
_glfw.vk.handle = _glfwPlatformLoadModule("vulkan-1.dll");
|
||||
#elif defined(_GLFW_COCOA)
|
||||
_glfw.vk.handle = _glfw_dlopen("libvulkan.1.dylib");
|
||||
if (!_glfw.vk.handle)
|
||||
_glfw.vk.handle = _glfwLoadLocalVulkanLoaderNS();
|
||||
_glfw.vk.handle = _glfwPlatformLoadModule("libvulkan.1.dylib");
|
||||
if (!_glfw.vk.handle)
|
||||
_glfw.vk.handle = _glfwLoadLocalVulkanLoaderCocoa();
|
||||
#elif defined(__OpenBSD__) || defined(__NetBSD__)
|
||||
_glfw.vk.handle = _glfwPlatformLoadModule("libvulkan.so");
|
||||
#else
|
||||
_glfw.vk.handle = _glfw_dlopen("libvulkan.so.1");
|
||||
_glfw.vk.handle = _glfwPlatformLoadModule("libvulkan.so.1");
|
||||
#endif
|
||||
if (!_glfw.vk.handle)
|
||||
{
|
||||
if (mode == _GLFW_REQUIRE_LOADER)
|
||||
_glfwInputError(GLFW_API_UNAVAILABLE, "Vulkan: Loader not found");
|
||||
if (!_glfw.vk.handle)
|
||||
{
|
||||
if (mode == _GLFW_REQUIRE_LOADER)
|
||||
_glfwInputError(GLFW_API_UNAVAILABLE, "Vulkan: Loader not found");
|
||||
|
||||
return GLFW_FALSE;
|
||||
return GLFW_FALSE;
|
||||
}
|
||||
|
||||
_glfw.vk.GetInstanceProcAddr = (PFN_vkGetInstanceProcAddr)
|
||||
_glfwPlatformGetModuleSymbol(_glfw.vk.handle, "vkGetInstanceProcAddr");
|
||||
if (!_glfw.vk.GetInstanceProcAddr)
|
||||
{
|
||||
_glfwInputError(GLFW_API_UNAVAILABLE,
|
||||
"Vulkan: Loader does not export vkGetInstanceProcAddr");
|
||||
|
||||
_glfwTerminateVulkan();
|
||||
return GLFW_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
_glfw.vk.GetInstanceProcAddr = (PFN_vkGetInstanceProcAddr)
|
||||
_glfw_dlsym(_glfw.vk.handle, "vkGetInstanceProcAddr");
|
||||
if (!_glfw.vk.GetInstanceProcAddr)
|
||||
{
|
||||
_glfwInputError(GLFW_API_UNAVAILABLE,
|
||||
"Vulkan: Loader does not export vkGetInstanceProcAddr");
|
||||
|
||||
_glfwTerminateVulkan();
|
||||
return GLFW_FALSE;
|
||||
}
|
||||
|
||||
_glfw.vk.EnumerateInstanceExtensionProperties = (PFN_vkEnumerateInstanceExtensionProperties)
|
||||
vkEnumerateInstanceExtensionProperties = (PFN_vkEnumerateInstanceExtensionProperties)
|
||||
vkGetInstanceProcAddr(NULL, "vkEnumerateInstanceExtensionProperties");
|
||||
if (!_glfw.vk.EnumerateInstanceExtensionProperties)
|
||||
if (!vkEnumerateInstanceExtensionProperties)
|
||||
{
|
||||
_glfwInputError(GLFW_API_UNAVAILABLE,
|
||||
"Vulkan: Failed to retrieve vkEnumerateInstanceExtensionProperties");
|
||||
@ -91,7 +98,6 @@ GLFWbool _glfwInitVulkan(int mode)
|
||||
_glfwTerminateVulkan();
|
||||
return GLFW_FALSE;
|
||||
}
|
||||
#endif // _GLFW_VULKAN_STATIC
|
||||
|
||||
err = vkEnumerateInstanceExtensionProperties(NULL, &count, NULL);
|
||||
if (err)
|
||||
@ -126,40 +132,33 @@ GLFWbool _glfwInitVulkan(int mode)
|
||||
{
|
||||
if (strcmp(ep[i].extensionName, "VK_KHR_surface") == 0)
|
||||
_glfw.vk.KHR_surface = GLFW_TRUE;
|
||||
#if defined(_GLFW_WIN32)
|
||||
else if (strcmp(ep[i].extensionName, "VK_KHR_win32_surface") == 0)
|
||||
_glfw.vk.KHR_win32_surface = GLFW_TRUE;
|
||||
#elif defined(_GLFW_COCOA)
|
||||
else if (strcmp(ep[i].extensionName, "VK_MVK_macos_surface") == 0)
|
||||
_glfw.vk.MVK_macos_surface = GLFW_TRUE;
|
||||
else if (strcmp(ep[i].extensionName, "VK_EXT_metal_surface") == 0)
|
||||
_glfw.vk.EXT_metal_surface = GLFW_TRUE;
|
||||
#elif defined(_GLFW_X11)
|
||||
else if (strcmp(ep[i].extensionName, "VK_KHR_xlib_surface") == 0)
|
||||
_glfw.vk.KHR_xlib_surface = GLFW_TRUE;
|
||||
else if (strcmp(ep[i].extensionName, "VK_KHR_xcb_surface") == 0)
|
||||
_glfw.vk.KHR_xcb_surface = GLFW_TRUE;
|
||||
#elif defined(_GLFW_WAYLAND)
|
||||
else if (strcmp(ep[i].extensionName, "VK_KHR_wayland_surface") == 0)
|
||||
_glfw.vk.KHR_wayland_surface = GLFW_TRUE;
|
||||
#endif
|
||||
}
|
||||
|
||||
_glfw_free(ep);
|
||||
|
||||
_glfw.vk.available = GLFW_TRUE;
|
||||
|
||||
_glfwPlatformGetRequiredInstanceExtensions(_glfw.vk.extensions);
|
||||
_glfw.platform.getRequiredInstanceExtensions(_glfw.vk.extensions);
|
||||
|
||||
return GLFW_TRUE;
|
||||
}
|
||||
|
||||
void _glfwTerminateVulkan(void)
|
||||
{
|
||||
#if !defined(_GLFW_VULKAN_STATIC)
|
||||
if (_glfw.vk.handle)
|
||||
_glfw_dlclose(_glfw.vk.handle);
|
||||
#endif
|
||||
_glfwPlatformFreeModule(_glfw.vk.handle);
|
||||
}
|
||||
|
||||
const char* _glfwGetVulkanResultString(VkResult result)
|
||||
@ -257,17 +256,16 @@ GLFWAPI GLFWvkproc glfwGetInstanceProcAddress(VkInstance instance,
|
||||
if (!_glfwInitVulkan(_GLFW_REQUIRE_LOADER))
|
||||
return NULL;
|
||||
|
||||
// NOTE: Vulkan 1.0 and 1.1 vkGetInstanceProcAddr cannot return itself
|
||||
if (strcmp(procname, "vkGetInstanceProcAddr") == 0)
|
||||
return (GLFWvkproc) vkGetInstanceProcAddr;
|
||||
|
||||
proc = (GLFWvkproc) vkGetInstanceProcAddr(instance, procname);
|
||||
#if defined(_GLFW_VULKAN_STATIC)
|
||||
if (!proc)
|
||||
{
|
||||
if (strcmp(procname, "vkGetInstanceProcAddr") == 0)
|
||||
return (GLFWvkproc) vkGetInstanceProcAddr;
|
||||
if (_glfw.vk.handle)
|
||||
proc = (GLFWvkproc) _glfwPlatformGetModuleSymbol(_glfw.vk.handle, procname);
|
||||
}
|
||||
#else
|
||||
if (!proc)
|
||||
proc = (GLFWvkproc) _glfw_dlsym(_glfw.vk.handle, procname);
|
||||
#endif
|
||||
|
||||
return proc;
|
||||
}
|
||||
@ -291,9 +289,9 @@ GLFWAPI int glfwGetPhysicalDevicePresentationSupport(VkInstance instance,
|
||||
return GLFW_FALSE;
|
||||
}
|
||||
|
||||
return _glfwPlatformGetPhysicalDevicePresentationSupport(instance,
|
||||
device,
|
||||
queuefamily);
|
||||
return _glfw.platform.getPhysicalDevicePresentationSupport(instance,
|
||||
device,
|
||||
queuefamily);
|
||||
}
|
||||
|
||||
GLFWAPI VkResult glfwCreateWindowSurface(VkInstance instance,
|
||||
@ -327,6 +325,6 @@ GLFWAPI VkResult glfwCreateWindowSurface(VkInstance instance,
|
||||
return VK_ERROR_NATIVE_WINDOW_IN_USE_KHR;
|
||||
}
|
||||
|
||||
return _glfwPlatformCreateWindowSurface(instance, window, allocator, surface);
|
||||
return _glfw.platform.createWindowSurface(instance, window, allocator, surface);
|
||||
}
|
||||
|
||||
|
@ -34,10 +34,10 @@
|
||||
|
||||
// Return the value corresponding to the specified attribute
|
||||
//
|
||||
static int findPixelFormatAttribValue(const int* attribs,
|
||||
int attribCount,
|
||||
const int* values,
|
||||
int attrib)
|
||||
static int findPixelFormatAttribValueWGL(const int* attribs,
|
||||
int attribCount,
|
||||
const int* values,
|
||||
int attrib)
|
||||
{
|
||||
int i;
|
||||
|
||||
@ -52,19 +52,19 @@ static int findPixelFormatAttribValue(const int* attribs,
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define addAttrib(a) \
|
||||
#define ADD_ATTRIB(a) \
|
||||
{ \
|
||||
assert((size_t) attribCount < sizeof(attribs) / sizeof(attribs[0])); \
|
||||
attribs[attribCount++] = a; \
|
||||
}
|
||||
#define findAttribValue(a) \
|
||||
findPixelFormatAttribValue(attribs, attribCount, values, a)
|
||||
#define FIND_ATTRIB_VALUE(a) \
|
||||
findPixelFormatAttribValueWGL(attribs, attribCount, values, a)
|
||||
|
||||
// Return a list of available and usable framebuffer configs
|
||||
//
|
||||
static int choosePixelFormat(_GLFWwindow* window,
|
||||
const _GLFWctxconfig* ctxconfig,
|
||||
const _GLFWfbconfig* fbconfig)
|
||||
static int choosePixelFormatWGL(_GLFWwindow* window,
|
||||
const _GLFWctxconfig* ctxconfig,
|
||||
const _GLFWfbconfig* fbconfig)
|
||||
{
|
||||
_GLFWfbconfig* usableConfigs;
|
||||
const _GLFWfbconfig* closest;
|
||||
@ -84,41 +84,41 @@ static int choosePixelFormat(_GLFWwindow* window,
|
||||
return 0;
|
||||
}
|
||||
|
||||
addAttrib(WGL_SUPPORT_OPENGL_ARB);
|
||||
addAttrib(WGL_DRAW_TO_WINDOW_ARB);
|
||||
addAttrib(WGL_PIXEL_TYPE_ARB);
|
||||
addAttrib(WGL_ACCELERATION_ARB);
|
||||
addAttrib(WGL_RED_BITS_ARB);
|
||||
addAttrib(WGL_RED_SHIFT_ARB);
|
||||
addAttrib(WGL_GREEN_BITS_ARB);
|
||||
addAttrib(WGL_GREEN_SHIFT_ARB);
|
||||
addAttrib(WGL_BLUE_BITS_ARB);
|
||||
addAttrib(WGL_BLUE_SHIFT_ARB);
|
||||
addAttrib(WGL_ALPHA_BITS_ARB);
|
||||
addAttrib(WGL_ALPHA_SHIFT_ARB);
|
||||
addAttrib(WGL_DEPTH_BITS_ARB);
|
||||
addAttrib(WGL_STENCIL_BITS_ARB);
|
||||
addAttrib(WGL_ACCUM_BITS_ARB);
|
||||
addAttrib(WGL_ACCUM_RED_BITS_ARB);
|
||||
addAttrib(WGL_ACCUM_GREEN_BITS_ARB);
|
||||
addAttrib(WGL_ACCUM_BLUE_BITS_ARB);
|
||||
addAttrib(WGL_ACCUM_ALPHA_BITS_ARB);
|
||||
addAttrib(WGL_AUX_BUFFERS_ARB);
|
||||
addAttrib(WGL_STEREO_ARB);
|
||||
addAttrib(WGL_DOUBLE_BUFFER_ARB);
|
||||
ADD_ATTRIB(WGL_SUPPORT_OPENGL_ARB);
|
||||
ADD_ATTRIB(WGL_DRAW_TO_WINDOW_ARB);
|
||||
ADD_ATTRIB(WGL_PIXEL_TYPE_ARB);
|
||||
ADD_ATTRIB(WGL_ACCELERATION_ARB);
|
||||
ADD_ATTRIB(WGL_RED_BITS_ARB);
|
||||
ADD_ATTRIB(WGL_RED_SHIFT_ARB);
|
||||
ADD_ATTRIB(WGL_GREEN_BITS_ARB);
|
||||
ADD_ATTRIB(WGL_GREEN_SHIFT_ARB);
|
||||
ADD_ATTRIB(WGL_BLUE_BITS_ARB);
|
||||
ADD_ATTRIB(WGL_BLUE_SHIFT_ARB);
|
||||
ADD_ATTRIB(WGL_ALPHA_BITS_ARB);
|
||||
ADD_ATTRIB(WGL_ALPHA_SHIFT_ARB);
|
||||
ADD_ATTRIB(WGL_DEPTH_BITS_ARB);
|
||||
ADD_ATTRIB(WGL_STENCIL_BITS_ARB);
|
||||
ADD_ATTRIB(WGL_ACCUM_BITS_ARB);
|
||||
ADD_ATTRIB(WGL_ACCUM_RED_BITS_ARB);
|
||||
ADD_ATTRIB(WGL_ACCUM_GREEN_BITS_ARB);
|
||||
ADD_ATTRIB(WGL_ACCUM_BLUE_BITS_ARB);
|
||||
ADD_ATTRIB(WGL_ACCUM_ALPHA_BITS_ARB);
|
||||
ADD_ATTRIB(WGL_AUX_BUFFERS_ARB);
|
||||
ADD_ATTRIB(WGL_STEREO_ARB);
|
||||
ADD_ATTRIB(WGL_DOUBLE_BUFFER_ARB);
|
||||
|
||||
if (_glfw.wgl.ARB_multisample)
|
||||
addAttrib(WGL_SAMPLES_ARB);
|
||||
ADD_ATTRIB(WGL_SAMPLES_ARB);
|
||||
|
||||
if (ctxconfig->client == GLFW_OPENGL_API)
|
||||
{
|
||||
if (_glfw.wgl.ARB_framebuffer_sRGB || _glfw.wgl.EXT_framebuffer_sRGB)
|
||||
addAttrib(WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB);
|
||||
ADD_ATTRIB(WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_glfw.wgl.EXT_colorspace)
|
||||
addAttrib(WGL_COLORSPACE_EXT);
|
||||
ADD_ATTRIB(WGL_COLORSPACE_EXT);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -152,48 +152,48 @@ static int choosePixelFormat(_GLFWwindow* window,
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!findAttribValue(WGL_SUPPORT_OPENGL_ARB) ||
|
||||
!findAttribValue(WGL_DRAW_TO_WINDOW_ARB))
|
||||
if (!FIND_ATTRIB_VALUE(WGL_SUPPORT_OPENGL_ARB) ||
|
||||
!FIND_ATTRIB_VALUE(WGL_DRAW_TO_WINDOW_ARB))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (findAttribValue(WGL_PIXEL_TYPE_ARB) != WGL_TYPE_RGBA_ARB)
|
||||
if (FIND_ATTRIB_VALUE(WGL_PIXEL_TYPE_ARB) != WGL_TYPE_RGBA_ARB)
|
||||
continue;
|
||||
|
||||
if (findAttribValue(WGL_ACCELERATION_ARB) == WGL_NO_ACCELERATION_ARB)
|
||||
if (FIND_ATTRIB_VALUE(WGL_ACCELERATION_ARB) == WGL_NO_ACCELERATION_ARB)
|
||||
continue;
|
||||
|
||||
if (findAttribValue(WGL_DOUBLE_BUFFER_ARB) != fbconfig->doublebuffer)
|
||||
if (FIND_ATTRIB_VALUE(WGL_DOUBLE_BUFFER_ARB) != fbconfig->doublebuffer)
|
||||
continue;
|
||||
|
||||
u->redBits = findAttribValue(WGL_RED_BITS_ARB);
|
||||
u->greenBits = findAttribValue(WGL_GREEN_BITS_ARB);
|
||||
u->blueBits = findAttribValue(WGL_BLUE_BITS_ARB);
|
||||
u->alphaBits = findAttribValue(WGL_ALPHA_BITS_ARB);
|
||||
u->redBits = FIND_ATTRIB_VALUE(WGL_RED_BITS_ARB);
|
||||
u->greenBits = FIND_ATTRIB_VALUE(WGL_GREEN_BITS_ARB);
|
||||
u->blueBits = FIND_ATTRIB_VALUE(WGL_BLUE_BITS_ARB);
|
||||
u->alphaBits = FIND_ATTRIB_VALUE(WGL_ALPHA_BITS_ARB);
|
||||
|
||||
u->depthBits = findAttribValue(WGL_DEPTH_BITS_ARB);
|
||||
u->stencilBits = findAttribValue(WGL_STENCIL_BITS_ARB);
|
||||
u->depthBits = FIND_ATTRIB_VALUE(WGL_DEPTH_BITS_ARB);
|
||||
u->stencilBits = FIND_ATTRIB_VALUE(WGL_STENCIL_BITS_ARB);
|
||||
|
||||
u->accumRedBits = findAttribValue(WGL_ACCUM_RED_BITS_ARB);
|
||||
u->accumGreenBits = findAttribValue(WGL_ACCUM_GREEN_BITS_ARB);
|
||||
u->accumBlueBits = findAttribValue(WGL_ACCUM_BLUE_BITS_ARB);
|
||||
u->accumAlphaBits = findAttribValue(WGL_ACCUM_ALPHA_BITS_ARB);
|
||||
u->accumRedBits = FIND_ATTRIB_VALUE(WGL_ACCUM_RED_BITS_ARB);
|
||||
u->accumGreenBits = FIND_ATTRIB_VALUE(WGL_ACCUM_GREEN_BITS_ARB);
|
||||
u->accumBlueBits = FIND_ATTRIB_VALUE(WGL_ACCUM_BLUE_BITS_ARB);
|
||||
u->accumAlphaBits = FIND_ATTRIB_VALUE(WGL_ACCUM_ALPHA_BITS_ARB);
|
||||
|
||||
u->auxBuffers = findAttribValue(WGL_AUX_BUFFERS_ARB);
|
||||
u->auxBuffers = FIND_ATTRIB_VALUE(WGL_AUX_BUFFERS_ARB);
|
||||
|
||||
if (findAttribValue(WGL_STEREO_ARB))
|
||||
if (FIND_ATTRIB_VALUE(WGL_STEREO_ARB))
|
||||
u->stereo = GLFW_TRUE;
|
||||
|
||||
if (_glfw.wgl.ARB_multisample)
|
||||
u->samples = findAttribValue(WGL_SAMPLES_ARB);
|
||||
u->samples = FIND_ATTRIB_VALUE(WGL_SAMPLES_ARB);
|
||||
|
||||
if (ctxconfig->client == GLFW_OPENGL_API)
|
||||
{
|
||||
if (_glfw.wgl.ARB_framebuffer_sRGB ||
|
||||
_glfw.wgl.EXT_framebuffer_sRGB)
|
||||
{
|
||||
if (findAttribValue(WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB))
|
||||
if (FIND_ATTRIB_VALUE(WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB))
|
||||
u->sRGB = GLFW_TRUE;
|
||||
}
|
||||
}
|
||||
@ -201,7 +201,7 @@ static int choosePixelFormat(_GLFWwindow* window,
|
||||
{
|
||||
if (_glfw.wgl.EXT_colorspace)
|
||||
{
|
||||
if (findAttribValue(WGL_COLORSPACE_EXT) == WGL_COLORSPACE_SRGB_EXT)
|
||||
if (FIND_ATTRIB_VALUE(WGL_COLORSPACE_EXT) == WGL_COLORSPACE_SRGB_EXT)
|
||||
u->sRGB = GLFW_TRUE;
|
||||
}
|
||||
}
|
||||
@ -290,8 +290,8 @@ static int choosePixelFormat(_GLFWwindow* window,
|
||||
return pixelFormat;
|
||||
}
|
||||
|
||||
#undef addAttrib
|
||||
#undef findAttribValue
|
||||
#undef ADD_ATTRIB
|
||||
#undef FIND_ATTRIB_VALUE
|
||||
|
||||
static void makeContextCurrentWGL(_GLFWwindow* window)
|
||||
{
|
||||
@ -322,14 +322,12 @@ static void swapBuffersWGL(_GLFWwindow* window)
|
||||
{
|
||||
if (!window->monitor)
|
||||
{
|
||||
if (IsWindowsVistaOrGreater())
|
||||
// HACK: Use DwmFlush when desktop composition is enabled on Windows Vista and 7
|
||||
if (!IsWindows8OrGreater() && IsWindowsVistaOrGreater())
|
||||
{
|
||||
// DWM Composition is always enabled on Win8+
|
||||
BOOL enabled = IsWindows8OrGreater();
|
||||
BOOL enabled = FALSE;
|
||||
|
||||
// HACK: Use DwmFlush when desktop composition is enabled
|
||||
if (enabled ||
|
||||
(SUCCEEDED(DwmIsCompositionEnabled(&enabled)) && enabled))
|
||||
if (SUCCEEDED(DwmIsCompositionEnabled(&enabled)) && enabled)
|
||||
{
|
||||
int count = abs(window->context.wgl.interval);
|
||||
while (count--)
|
||||
@ -349,15 +347,13 @@ static void swapIntervalWGL(int interval)
|
||||
|
||||
if (!window->monitor)
|
||||
{
|
||||
if (IsWindowsVistaOrGreater())
|
||||
// HACK: Disable WGL swap interval when desktop composition is enabled on Windows
|
||||
// Vista and 7 to avoid interfering with DWM vsync
|
||||
if (!IsWindows8OrGreater() && IsWindowsVistaOrGreater())
|
||||
{
|
||||
// DWM Composition is always enabled on Win8+
|
||||
BOOL enabled = IsWindows8OrGreater();
|
||||
BOOL enabled = FALSE;
|
||||
|
||||
// HACK: Disable WGL swap interval when desktop composition is enabled to
|
||||
// avoid interfering with DWM vsync
|
||||
if (enabled ||
|
||||
(SUCCEEDED(DwmIsCompositionEnabled(&enabled)) && enabled))
|
||||
if (SUCCEEDED(DwmIsCompositionEnabled(&enabled)) && enabled)
|
||||
interval = 0;
|
||||
}
|
||||
}
|
||||
@ -387,7 +383,7 @@ static GLFWglproc getProcAddressWGL(const char* procname)
|
||||
if (proc)
|
||||
return proc;
|
||||
|
||||
return (GLFWglproc) GetProcAddress(_glfw.wgl.instance, procname);
|
||||
return (GLFWglproc) _glfwPlatformGetModuleSymbol(_glfw.wgl.instance, procname);
|
||||
}
|
||||
|
||||
static void destroyContextWGL(_GLFWwindow* window)
|
||||
@ -399,11 +395,6 @@ static void destroyContextWGL(_GLFWwindow* window)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
////// GLFW internal API //////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Initialize WGL
|
||||
//
|
||||
GLFWbool _glfwInitWGL(void)
|
||||
@ -415,7 +406,7 @@ GLFWbool _glfwInitWGL(void)
|
||||
if (_glfw.wgl.instance)
|
||||
return GLFW_TRUE;
|
||||
|
||||
_glfw.wgl.instance = LoadLibraryA("opengl32.dll");
|
||||
_glfw.wgl.instance = _glfwPlatformLoadModule("opengl32.dll");
|
||||
if (!_glfw.wgl.instance)
|
||||
{
|
||||
_glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
|
||||
@ -424,19 +415,19 @@ GLFWbool _glfwInitWGL(void)
|
||||
}
|
||||
|
||||
_glfw.wgl.CreateContext = (PFN_wglCreateContext)
|
||||
GetProcAddress(_glfw.wgl.instance, "wglCreateContext");
|
||||
_glfwPlatformGetModuleSymbol(_glfw.wgl.instance, "wglCreateContext");
|
||||
_glfw.wgl.DeleteContext = (PFN_wglDeleteContext)
|
||||
GetProcAddress(_glfw.wgl.instance, "wglDeleteContext");
|
||||
_glfwPlatformGetModuleSymbol(_glfw.wgl.instance, "wglDeleteContext");
|
||||
_glfw.wgl.GetProcAddress = (PFN_wglGetProcAddress)
|
||||
GetProcAddress(_glfw.wgl.instance, "wglGetProcAddress");
|
||||
_glfwPlatformGetModuleSymbol(_glfw.wgl.instance, "wglGetProcAddress");
|
||||
_glfw.wgl.GetCurrentDC = (PFN_wglGetCurrentDC)
|
||||
GetProcAddress(_glfw.wgl.instance, "wglGetCurrentDC");
|
||||
_glfwPlatformGetModuleSymbol(_glfw.wgl.instance, "wglGetCurrentDC");
|
||||
_glfw.wgl.GetCurrentContext = (PFN_wglGetCurrentContext)
|
||||
GetProcAddress(_glfw.wgl.instance, "wglGetCurrentContext");
|
||||
_glfwPlatformGetModuleSymbol(_glfw.wgl.instance, "wglGetCurrentContext");
|
||||
_glfw.wgl.MakeCurrent = (PFN_wglMakeCurrent)
|
||||
GetProcAddress(_glfw.wgl.instance, "wglMakeCurrent");
|
||||
_glfwPlatformGetModuleSymbol(_glfw.wgl.instance, "wglMakeCurrent");
|
||||
_glfw.wgl.ShareLists = (PFN_wglShareLists)
|
||||
GetProcAddress(_glfw.wgl.instance, "wglShareLists");
|
||||
_glfwPlatformGetModuleSymbol(_glfw.wgl.instance, "wglShareLists");
|
||||
|
||||
// NOTE: A dummy context has to be created for opengl32.dll to load the
|
||||
// OpenGL ICD, from which we can then query WGL extensions
|
||||
@ -529,10 +520,10 @@ GLFWbool _glfwInitWGL(void)
|
||||
void _glfwTerminateWGL(void)
|
||||
{
|
||||
if (_glfw.wgl.instance)
|
||||
FreeLibrary(_glfw.wgl.instance);
|
||||
_glfwPlatformFreeModule(_glfw.wgl.instance);
|
||||
}
|
||||
|
||||
#define setAttrib(a, v) \
|
||||
#define SET_ATTRIB(a, v) \
|
||||
{ \
|
||||
assert(((size_t) index + 1) < sizeof(attribs) / sizeof(attribs[0])); \
|
||||
attribs[index++] = a; \
|
||||
@ -550,7 +541,6 @@ GLFWbool _glfwCreateContextForDCWGL(HDC dc, const _GLFWctxconfig* ctxconfig, HGL
|
||||
if (ctxconfig->share)
|
||||
share = ctxconfig->share->context.wgl.handle;
|
||||
|
||||
|
||||
if (ctxconfig->client == GLFW_OPENGL_API)
|
||||
{
|
||||
if (ctxconfig->forward)
|
||||
@ -611,13 +601,13 @@ GLFWbool _glfwCreateContextForDCWGL(HDC dc, const _GLFWctxconfig* ctxconfig, HGL
|
||||
{
|
||||
if (ctxconfig->robustness == GLFW_NO_RESET_NOTIFICATION)
|
||||
{
|
||||
setAttrib(WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB,
|
||||
WGL_NO_RESET_NOTIFICATION_ARB);
|
||||
SET_ATTRIB(WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB,
|
||||
WGL_NO_RESET_NOTIFICATION_ARB);
|
||||
}
|
||||
else if (ctxconfig->robustness == GLFW_LOSE_CONTEXT_ON_RESET)
|
||||
{
|
||||
setAttrib(WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB,
|
||||
WGL_LOSE_CONTEXT_ON_RESET_ARB);
|
||||
SET_ATTRIB(WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB,
|
||||
WGL_LOSE_CONTEXT_ON_RESET_ARB);
|
||||
}
|
||||
|
||||
flags |= WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB;
|
||||
@ -630,13 +620,13 @@ GLFWbool _glfwCreateContextForDCWGL(HDC dc, const _GLFWctxconfig* ctxconfig, HGL
|
||||
{
|
||||
if (ctxconfig->release == GLFW_RELEASE_BEHAVIOR_NONE)
|
||||
{
|
||||
setAttrib(WGL_CONTEXT_RELEASE_BEHAVIOR_ARB,
|
||||
WGL_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB);
|
||||
SET_ATTRIB(WGL_CONTEXT_RELEASE_BEHAVIOR_ARB,
|
||||
WGL_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB);
|
||||
}
|
||||
else if (ctxconfig->release == GLFW_RELEASE_BEHAVIOR_FLUSH)
|
||||
{
|
||||
setAttrib(WGL_CONTEXT_RELEASE_BEHAVIOR_ARB,
|
||||
WGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB);
|
||||
SET_ATTRIB(WGL_CONTEXT_RELEASE_BEHAVIOR_ARB,
|
||||
WGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -644,7 +634,7 @@ GLFWbool _glfwCreateContextForDCWGL(HDC dc, const _GLFWctxconfig* ctxconfig, HGL
|
||||
if (ctxconfig->noerror)
|
||||
{
|
||||
if (_glfw.wgl.ARB_create_context_no_error)
|
||||
setAttrib(WGL_CONTEXT_OPENGL_NO_ERROR_ARB, GLFW_TRUE);
|
||||
SET_ATTRIB(WGL_CONTEXT_OPENGL_NO_ERROR_ARB, GLFW_TRUE);
|
||||
}
|
||||
|
||||
// NOTE: Only request an explicitly versioned context when necessary, as
|
||||
@ -652,17 +642,17 @@ GLFWbool _glfwCreateContextForDCWGL(HDC dc, const _GLFWctxconfig* ctxconfig, HGL
|
||||
// highest version supported by the driver
|
||||
if (ctxconfig->major != 1 || ctxconfig->minor != 0)
|
||||
{
|
||||
setAttrib(WGL_CONTEXT_MAJOR_VERSION_ARB, ctxconfig->major);
|
||||
setAttrib(WGL_CONTEXT_MINOR_VERSION_ARB, ctxconfig->minor);
|
||||
SET_ATTRIB(WGL_CONTEXT_MAJOR_VERSION_ARB, ctxconfig->major);
|
||||
SET_ATTRIB(WGL_CONTEXT_MINOR_VERSION_ARB, ctxconfig->minor);
|
||||
}
|
||||
|
||||
if (flags)
|
||||
setAttrib(WGL_CONTEXT_FLAGS_ARB, flags);
|
||||
SET_ATTRIB(WGL_CONTEXT_FLAGS_ARB, flags);
|
||||
|
||||
if (mask)
|
||||
setAttrib(WGL_CONTEXT_PROFILE_MASK_ARB, mask);
|
||||
SET_ATTRIB(WGL_CONTEXT_PROFILE_MASK_ARB, mask);
|
||||
|
||||
setAttrib(0, 0);
|
||||
SET_ATTRIB(0, 0);
|
||||
|
||||
*context =
|
||||
wglCreateContextAttribsARB(dc, share, attribs);
|
||||
@ -755,7 +745,7 @@ GLFWbool _glfwCreateContextWGL(_GLFWwindow* window,
|
||||
return GLFW_FALSE;
|
||||
}
|
||||
|
||||
pixelFormat = choosePixelFormat(window, ctxconfig, fbconfig);
|
||||
pixelFormat = choosePixelFormatWGL(window, ctxconfig, fbconfig);
|
||||
if (!pixelFormat)
|
||||
return GLFW_FALSE;
|
||||
|
||||
@ -789,8 +779,6 @@ GLFWbool _glfwCreateContextWGL(_GLFWwindow* window,
|
||||
return GLFW_TRUE;
|
||||
}
|
||||
|
||||
#undef setAttrib
|
||||
|
||||
static void _glfwMakeUserContextCurrentWGL(_GLFWusercontext* context)
|
||||
{
|
||||
if(!wglMakeCurrent(context->window->context.wgl.dc,context->wgl.handle))
|
||||
@ -838,13 +826,21 @@ _GLFWusercontext* _glfwCreateUserContextWGL(_GLFWwindow* window)
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
////// GLFW native API //////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
#undef SET_ATTRIB
|
||||
|
||||
GLFWAPI HGLRC glfwGetWGLContext(GLFWwindow* handle)
|
||||
{
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||
|
||||
if (window->context.client == GLFW_NO_API)
|
||||
if (_glfw.platform.platformID != GLFW_PLATFORM_WIN32)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_UNAVAILABLE,
|
||||
"WGL: Platform not initialized");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (window->context.source != GLFW_NATIVE_CONTEXT_API)
|
||||
{
|
||||
_glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL);
|
||||
return NULL;
|
||||
|
@ -1,170 +0,0 @@
|
||||
//========================================================================
|
||||
// GLFW 3.4 WGL - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2002-2006 Marcus Geelnard
|
||||
// Copyright (c) 2006-2018 Camilla Löwy <elmindreda@glfw.org>
|
||||
//
|
||||
// This software is provided 'as-is', without any express or implied
|
||||
// warranty. In no event will the authors be held liable for any damages
|
||||
// arising from the use of this software.
|
||||
//
|
||||
// Permission is granted to anyone to use this software for any purpose,
|
||||
// including commercial applications, and to alter it and redistribute it
|
||||
// freely, subject to the following restrictions:
|
||||
//
|
||||
// 1. The origin of this software must not be misrepresented; you must not
|
||||
// claim that you wrote the original software. If you use this software
|
||||
// in a product, an acknowledgment in the product documentation would
|
||||
// be appreciated but is not required.
|
||||
//
|
||||
// 2. Altered source versions must be plainly marked as such, and must not
|
||||
// be misrepresented as being the original software.
|
||||
//
|
||||
// 3. This notice may not be removed or altered from any source
|
||||
// distribution.
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#define WGL_NUMBER_PIXEL_FORMATS_ARB 0x2000
|
||||
#define WGL_SUPPORT_OPENGL_ARB 0x2010
|
||||
#define WGL_DRAW_TO_WINDOW_ARB 0x2001
|
||||
#define WGL_PIXEL_TYPE_ARB 0x2013
|
||||
#define WGL_TYPE_RGBA_ARB 0x202b
|
||||
#define WGL_ACCELERATION_ARB 0x2003
|
||||
#define WGL_NO_ACCELERATION_ARB 0x2025
|
||||
#define WGL_RED_BITS_ARB 0x2015
|
||||
#define WGL_RED_SHIFT_ARB 0x2016
|
||||
#define WGL_GREEN_BITS_ARB 0x2017
|
||||
#define WGL_GREEN_SHIFT_ARB 0x2018
|
||||
#define WGL_BLUE_BITS_ARB 0x2019
|
||||
#define WGL_BLUE_SHIFT_ARB 0x201a
|
||||
#define WGL_ALPHA_BITS_ARB 0x201b
|
||||
#define WGL_ALPHA_SHIFT_ARB 0x201c
|
||||
#define WGL_ACCUM_BITS_ARB 0x201d
|
||||
#define WGL_ACCUM_RED_BITS_ARB 0x201e
|
||||
#define WGL_ACCUM_GREEN_BITS_ARB 0x201f
|
||||
#define WGL_ACCUM_BLUE_BITS_ARB 0x2020
|
||||
#define WGL_ACCUM_ALPHA_BITS_ARB 0x2021
|
||||
#define WGL_DEPTH_BITS_ARB 0x2022
|
||||
#define WGL_STENCIL_BITS_ARB 0x2023
|
||||
#define WGL_AUX_BUFFERS_ARB 0x2024
|
||||
#define WGL_STEREO_ARB 0x2012
|
||||
#define WGL_DOUBLE_BUFFER_ARB 0x2011
|
||||
#define WGL_SAMPLES_ARB 0x2042
|
||||
#define WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20a9
|
||||
#define WGL_CONTEXT_DEBUG_BIT_ARB 0x00000001
|
||||
#define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x00000002
|
||||
#define WGL_CONTEXT_PROFILE_MASK_ARB 0x9126
|
||||
#define WGL_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001
|
||||
#define WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002
|
||||
#define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091
|
||||
#define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092
|
||||
#define WGL_CONTEXT_FLAGS_ARB 0x2094
|
||||
#define WGL_CONTEXT_ES2_PROFILE_BIT_EXT 0x00000004
|
||||
#define WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB 0x00000004
|
||||
#define WGL_LOSE_CONTEXT_ON_RESET_ARB 0x8252
|
||||
#define WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB 0x8256
|
||||
#define WGL_NO_RESET_NOTIFICATION_ARB 0x8261
|
||||
#define WGL_CONTEXT_RELEASE_BEHAVIOR_ARB 0x2097
|
||||
#define WGL_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB 0
|
||||
#define WGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB 0x2098
|
||||
#define WGL_CONTEXT_OPENGL_NO_ERROR_ARB 0x31b3
|
||||
#define WGL_COLORSPACE_EXT 0x309d
|
||||
#define WGL_COLORSPACE_SRGB_EXT 0x3089
|
||||
|
||||
#define ERROR_INVALID_VERSION_ARB 0x2095
|
||||
#define ERROR_INVALID_PROFILE_ARB 0x2096
|
||||
#define ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB 0x2054
|
||||
|
||||
// WGL extension pointer typedefs
|
||||
typedef BOOL (WINAPI * PFNWGLSWAPINTERVALEXTPROC)(int);
|
||||
typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVARBPROC)(HDC,int,int,UINT,const int*,int*);
|
||||
typedef const char* (WINAPI * PFNWGLGETEXTENSIONSSTRINGEXTPROC)(void);
|
||||
typedef const char* (WINAPI * PFNWGLGETEXTENSIONSSTRINGARBPROC)(HDC);
|
||||
typedef HGLRC (WINAPI * PFNWGLCREATECONTEXTATTRIBSARBPROC)(HDC,HGLRC,const int*);
|
||||
#define wglSwapIntervalEXT _glfw.wgl.SwapIntervalEXT
|
||||
#define wglGetPixelFormatAttribivARB _glfw.wgl.GetPixelFormatAttribivARB
|
||||
#define wglGetExtensionsStringEXT _glfw.wgl.GetExtensionsStringEXT
|
||||
#define wglGetExtensionsStringARB _glfw.wgl.GetExtensionsStringARB
|
||||
#define wglCreateContextAttribsARB _glfw.wgl.CreateContextAttribsARB
|
||||
|
||||
// opengl32.dll function pointer typedefs
|
||||
typedef HGLRC (WINAPI * PFN_wglCreateContext)(HDC);
|
||||
typedef BOOL (WINAPI * PFN_wglDeleteContext)(HGLRC);
|
||||
typedef PROC (WINAPI * PFN_wglGetProcAddress)(LPCSTR);
|
||||
typedef HDC (WINAPI * PFN_wglGetCurrentDC)(void);
|
||||
typedef HGLRC (WINAPI * PFN_wglGetCurrentContext)(void);
|
||||
typedef BOOL (WINAPI * PFN_wglMakeCurrent)(HDC,HGLRC);
|
||||
typedef BOOL (WINAPI * PFN_wglShareLists)(HGLRC,HGLRC);
|
||||
#define wglCreateContext _glfw.wgl.CreateContext
|
||||
#define wglDeleteContext _glfw.wgl.DeleteContext
|
||||
#define wglGetProcAddress _glfw.wgl.GetProcAddress
|
||||
#define wglGetCurrentDC _glfw.wgl.GetCurrentDC
|
||||
#define wglGetCurrentContext _glfw.wgl.GetCurrentContext
|
||||
#define wglMakeCurrent _glfw.wgl.MakeCurrent
|
||||
#define wglShareLists _glfw.wgl.ShareLists
|
||||
|
||||
#define _GLFW_PLATFORM_CONTEXT_STATE _GLFWcontextWGL wgl
|
||||
#define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE _GLFWlibraryWGL wgl
|
||||
#define _GLFW_PLATFORM_USER_CONTEXT_STATE _GLFWusercontextWGL wgl
|
||||
|
||||
|
||||
// WGL-specific per-context data
|
||||
//
|
||||
typedef struct _GLFWcontextWGL
|
||||
{
|
||||
HDC dc;
|
||||
HGLRC handle;
|
||||
int interval;
|
||||
|
||||
} _GLFWcontextWGL;
|
||||
|
||||
// WGL-specific user context data
|
||||
//
|
||||
typedef struct _GLFWusercontextWGL
|
||||
{
|
||||
HGLRC handle;
|
||||
} _GLFWusercontextWGL;
|
||||
|
||||
// WGL-specific global data
|
||||
//
|
||||
typedef struct _GLFWlibraryWGL
|
||||
{
|
||||
HINSTANCE instance;
|
||||
PFN_wglCreateContext CreateContext;
|
||||
PFN_wglDeleteContext DeleteContext;
|
||||
PFN_wglGetProcAddress GetProcAddress;
|
||||
PFN_wglGetCurrentDC GetCurrentDC;
|
||||
PFN_wglGetCurrentContext GetCurrentContext;
|
||||
PFN_wglMakeCurrent MakeCurrent;
|
||||
PFN_wglShareLists ShareLists;
|
||||
|
||||
PFNWGLSWAPINTERVALEXTPROC SwapIntervalEXT;
|
||||
PFNWGLGETPIXELFORMATATTRIBIVARBPROC GetPixelFormatAttribivARB;
|
||||
PFNWGLGETEXTENSIONSSTRINGEXTPROC GetExtensionsStringEXT;
|
||||
PFNWGLGETEXTENSIONSSTRINGARBPROC GetExtensionsStringARB;
|
||||
PFNWGLCREATECONTEXTATTRIBSARBPROC CreateContextAttribsARB;
|
||||
GLFWbool EXT_swap_control;
|
||||
GLFWbool EXT_colorspace;
|
||||
GLFWbool ARB_multisample;
|
||||
GLFWbool ARB_framebuffer_sRGB;
|
||||
GLFWbool EXT_framebuffer_sRGB;
|
||||
GLFWbool ARB_pixel_format;
|
||||
GLFWbool ARB_create_context;
|
||||
GLFWbool ARB_create_context_profile;
|
||||
GLFWbool EXT_create_context_es2_profile;
|
||||
GLFWbool ARB_create_context_robustness;
|
||||
GLFWbool ARB_create_context_no_error;
|
||||
GLFWbool ARB_context_flush_control;
|
||||
|
||||
} _GLFWlibraryWGL;
|
||||
|
||||
GLFWbool _glfwInitWGL(void);
|
||||
void _glfwTerminateWGL(void);
|
||||
GLFWbool _glfwCreateContextWGL(_GLFWwindow* window,
|
||||
const _GLFWctxconfig* ctxconfig,
|
||||
const _GLFWfbconfig* fbconfig);
|
||||
_GLFWusercontext* _glfwCreateUserContextWGL(_GLFWwindow* window);
|
||||
|
||||
|
||||
|
191
src/win32_init.c
191
src/win32_init.c
@ -71,18 +71,17 @@ BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID reserved)
|
||||
//
|
||||
static GLFWbool loadLibraries(void)
|
||||
{
|
||||
_glfw.win32.winmm.instance = LoadLibraryA("winmm.dll");
|
||||
if (!_glfw.win32.winmm.instance)
|
||||
if (!GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS |
|
||||
GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
|
||||
(const WCHAR*) &_glfw,
|
||||
(HMODULE*) &_glfw.win32.instance))
|
||||
{
|
||||
_glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
|
||||
"Win32: Failed to load winmm.dll");
|
||||
"Win32: Failed to retrieve own module handle");
|
||||
return GLFW_FALSE;
|
||||
}
|
||||
|
||||
_glfw.win32.winmm.GetTime = (PFN_timeGetTime)
|
||||
GetProcAddress(_glfw.win32.winmm.instance, "timeGetTime");
|
||||
|
||||
_glfw.win32.user32.instance = LoadLibraryA("user32.dll");
|
||||
_glfw.win32.user32.instance = _glfwPlatformLoadModule("user32.dll");
|
||||
if (!_glfw.win32.user32.instance)
|
||||
{
|
||||
_glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
|
||||
@ -91,23 +90,25 @@ static GLFWbool loadLibraries(void)
|
||||
}
|
||||
|
||||
_glfw.win32.user32.SetProcessDPIAware_ = (PFN_SetProcessDPIAware)
|
||||
GetProcAddress(_glfw.win32.user32.instance, "SetProcessDPIAware");
|
||||
_glfwPlatformGetModuleSymbol(_glfw.win32.user32.instance, "SetProcessDPIAware");
|
||||
_glfw.win32.user32.ChangeWindowMessageFilterEx_ = (PFN_ChangeWindowMessageFilterEx)
|
||||
GetProcAddress(_glfw.win32.user32.instance, "ChangeWindowMessageFilterEx");
|
||||
_glfwPlatformGetModuleSymbol(_glfw.win32.user32.instance, "ChangeWindowMessageFilterEx");
|
||||
_glfw.win32.user32.EnableNonClientDpiScaling_ = (PFN_EnableNonClientDpiScaling)
|
||||
GetProcAddress(_glfw.win32.user32.instance, "EnableNonClientDpiScaling");
|
||||
_glfwPlatformGetModuleSymbol(_glfw.win32.user32.instance, "EnableNonClientDpiScaling");
|
||||
_glfw.win32.user32.SetProcessDpiAwarenessContext_ = (PFN_SetProcessDpiAwarenessContext)
|
||||
GetProcAddress(_glfw.win32.user32.instance, "SetProcessDpiAwarenessContext");
|
||||
_glfwPlatformGetModuleSymbol(_glfw.win32.user32.instance, "SetProcessDpiAwarenessContext");
|
||||
_glfw.win32.user32.GetDpiForWindow_ = (PFN_GetDpiForWindow)
|
||||
GetProcAddress(_glfw.win32.user32.instance, "GetDpiForWindow");
|
||||
_glfwPlatformGetModuleSymbol(_glfw.win32.user32.instance, "GetDpiForWindow");
|
||||
_glfw.win32.user32.AdjustWindowRectExForDpi_ = (PFN_AdjustWindowRectExForDpi)
|
||||
GetProcAddress(_glfw.win32.user32.instance, "AdjustWindowRectExForDpi");
|
||||
_glfwPlatformGetModuleSymbol(_glfw.win32.user32.instance, "AdjustWindowRectExForDpi");
|
||||
_glfw.win32.user32.GetSystemMetricsForDpi_ = (PFN_GetSystemMetricsForDpi)
|
||||
_glfwPlatformGetModuleSymbol(_glfw.win32.user32.instance, "GetSystemMetricsForDpi");
|
||||
|
||||
_glfw.win32.dinput8.instance = LoadLibraryA("dinput8.dll");
|
||||
_glfw.win32.dinput8.instance = _glfwPlatformLoadModule("dinput8.dll");
|
||||
if (_glfw.win32.dinput8.instance)
|
||||
{
|
||||
_glfw.win32.dinput8.Create = (PFN_DirectInput8Create)
|
||||
GetProcAddress(_glfw.win32.dinput8.instance, "DirectInput8Create");
|
||||
_glfwPlatformGetModuleSymbol(_glfw.win32.dinput8.instance, "DirectInput8Create");
|
||||
}
|
||||
|
||||
{
|
||||
@ -124,46 +125,46 @@ static GLFWbool loadLibraries(void)
|
||||
|
||||
for (i = 0; names[i]; i++)
|
||||
{
|
||||
_glfw.win32.xinput.instance = LoadLibraryA(names[i]);
|
||||
_glfw.win32.xinput.instance = _glfwPlatformLoadModule(names[i]);
|
||||
if (_glfw.win32.xinput.instance)
|
||||
{
|
||||
_glfw.win32.xinput.GetCapabilities = (PFN_XInputGetCapabilities)
|
||||
GetProcAddress(_glfw.win32.xinput.instance, "XInputGetCapabilities");
|
||||
_glfwPlatformGetModuleSymbol(_glfw.win32.xinput.instance, "XInputGetCapabilities");
|
||||
_glfw.win32.xinput.GetState = (PFN_XInputGetState)
|
||||
GetProcAddress(_glfw.win32.xinput.instance, "XInputGetState");
|
||||
_glfwPlatformGetModuleSymbol(_glfw.win32.xinput.instance, "XInputGetState");
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_glfw.win32.dwmapi.instance = LoadLibraryA("dwmapi.dll");
|
||||
_glfw.win32.dwmapi.instance = _glfwPlatformLoadModule("dwmapi.dll");
|
||||
if (_glfw.win32.dwmapi.instance)
|
||||
{
|
||||
_glfw.win32.dwmapi.IsCompositionEnabled = (PFN_DwmIsCompositionEnabled)
|
||||
GetProcAddress(_glfw.win32.dwmapi.instance, "DwmIsCompositionEnabled");
|
||||
_glfwPlatformGetModuleSymbol(_glfw.win32.dwmapi.instance, "DwmIsCompositionEnabled");
|
||||
_glfw.win32.dwmapi.Flush = (PFN_DwmFlush)
|
||||
GetProcAddress(_glfw.win32.dwmapi.instance, "DwmFlush");
|
||||
_glfwPlatformGetModuleSymbol(_glfw.win32.dwmapi.instance, "DwmFlush");
|
||||
_glfw.win32.dwmapi.EnableBlurBehindWindow = (PFN_DwmEnableBlurBehindWindow)
|
||||
GetProcAddress(_glfw.win32.dwmapi.instance, "DwmEnableBlurBehindWindow");
|
||||
_glfwPlatformGetModuleSymbol(_glfw.win32.dwmapi.instance, "DwmEnableBlurBehindWindow");
|
||||
_glfw.win32.dwmapi.GetColorizationColor = (PFN_DwmGetColorizationColor)
|
||||
GetProcAddress(_glfw.win32.dwmapi.instance, "DwmGetColorizationColor");
|
||||
_glfwPlatformGetModuleSymbol(_glfw.win32.dwmapi.instance, "DwmGetColorizationColor");
|
||||
}
|
||||
|
||||
_glfw.win32.shcore.instance = LoadLibraryA("shcore.dll");
|
||||
_glfw.win32.shcore.instance = _glfwPlatformLoadModule("shcore.dll");
|
||||
if (_glfw.win32.shcore.instance)
|
||||
{
|
||||
_glfw.win32.shcore.SetProcessDpiAwareness_ = (PFN_SetProcessDpiAwareness)
|
||||
GetProcAddress(_glfw.win32.shcore.instance, "SetProcessDpiAwareness");
|
||||
_glfwPlatformGetModuleSymbol(_glfw.win32.shcore.instance, "SetProcessDpiAwareness");
|
||||
_glfw.win32.shcore.GetDpiForMonitor_ = (PFN_GetDpiForMonitor)
|
||||
GetProcAddress(_glfw.win32.shcore.instance, "GetDpiForMonitor");
|
||||
_glfwPlatformGetModuleSymbol(_glfw.win32.shcore.instance, "GetDpiForMonitor");
|
||||
}
|
||||
|
||||
_glfw.win32.ntdll.instance = LoadLibraryA("ntdll.dll");
|
||||
_glfw.win32.ntdll.instance = _glfwPlatformLoadModule("ntdll.dll");
|
||||
if (_glfw.win32.ntdll.instance)
|
||||
{
|
||||
_glfw.win32.ntdll.RtlVerifyVersionInfo_ = (PFN_RtlVerifyVersionInfo)
|
||||
GetProcAddress(_glfw.win32.ntdll.instance, "RtlVerifyVersionInfo");
|
||||
_glfwPlatformGetModuleSymbol(_glfw.win32.ntdll.instance, "RtlVerifyVersionInfo");
|
||||
}
|
||||
|
||||
return GLFW_TRUE;
|
||||
@ -174,25 +175,22 @@ static GLFWbool loadLibraries(void)
|
||||
static void freeLibraries(void)
|
||||
{
|
||||
if (_glfw.win32.xinput.instance)
|
||||
FreeLibrary(_glfw.win32.xinput.instance);
|
||||
_glfwPlatformFreeModule(_glfw.win32.xinput.instance);
|
||||
|
||||
if (_glfw.win32.dinput8.instance)
|
||||
FreeLibrary(_glfw.win32.dinput8.instance);
|
||||
|
||||
if (_glfw.win32.winmm.instance)
|
||||
FreeLibrary(_glfw.win32.winmm.instance);
|
||||
_glfwPlatformFreeModule(_glfw.win32.dinput8.instance);
|
||||
|
||||
if (_glfw.win32.user32.instance)
|
||||
FreeLibrary(_glfw.win32.user32.instance);
|
||||
_glfwPlatformFreeModule(_glfw.win32.user32.instance);
|
||||
|
||||
if (_glfw.win32.dwmapi.instance)
|
||||
FreeLibrary(_glfw.win32.dwmapi.instance);
|
||||
_glfwPlatformFreeModule(_glfw.win32.dwmapi.instance);
|
||||
|
||||
if (_glfw.win32.shcore.instance)
|
||||
FreeLibrary(_glfw.win32.shcore.instance);
|
||||
_glfwPlatformFreeModule(_glfw.win32.shcore.instance);
|
||||
|
||||
if (_glfw.win32.ntdll.instance)
|
||||
FreeLibrary(_glfw.win32.ntdll.instance);
|
||||
_glfwPlatformFreeModule(_glfw.win32.ntdll.instance);
|
||||
}
|
||||
|
||||
// Create key code translation tables
|
||||
@ -265,7 +263,6 @@ static void createKeyTables(void)
|
||||
_glfw.win32.keycodes[0x151] = GLFW_KEY_PAGE_DOWN;
|
||||
_glfw.win32.keycodes[0x149] = GLFW_KEY_PAGE_UP;
|
||||
_glfw.win32.keycodes[0x045] = GLFW_KEY_PAUSE;
|
||||
_glfw.win32.keycodes[0x146] = GLFW_KEY_PAUSE;
|
||||
_glfw.win32.keycodes[0x039] = GLFW_KEY_SPACE;
|
||||
_glfw.win32.keycodes[0x00F] = GLFW_KEY_TAB;
|
||||
_glfw.win32.keycodes[0x03A] = GLFW_KEY_CAPS_LOCK;
|
||||
@ -347,7 +344,7 @@ static GLFWbool createHelperWindow(void)
|
||||
WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
|
||||
0, 0, 1, 1,
|
||||
NULL, NULL,
|
||||
GetModuleHandleW(NULL),
|
||||
_glfw.win32.instance,
|
||||
NULL);
|
||||
|
||||
if (!_glfw.win32.helperWindowHandle)
|
||||
@ -497,7 +494,7 @@ void _glfwUpdateKeyNamesWin32(void)
|
||||
vk = vks[key - GLFW_KEY_KP_0];
|
||||
}
|
||||
else
|
||||
vk = MapVirtualKey(scancode, MAPVK_VSC_TO_VK);
|
||||
vk = MapVirtualKeyW(scancode, MAPVK_VSC_TO_VK);
|
||||
|
||||
length = ToUnicode(vk, scancode, state,
|
||||
chars, sizeof(chars) / sizeof(WCHAR),
|
||||
@ -520,7 +517,8 @@ void _glfwUpdateKeyNamesWin32(void)
|
||||
}
|
||||
}
|
||||
|
||||
// Replacement for IsWindowsVersionOrGreater as MinGW lacks versionhelpers.h
|
||||
// Replacement for IsWindowsVersionOrGreater, as we cannot rely on the
|
||||
// application having a correct embedded manifest
|
||||
//
|
||||
BOOL _glfwIsWindowsVersionOrGreaterWin32(WORD major, WORD minor, WORD sp)
|
||||
{
|
||||
@ -550,12 +548,90 @@ BOOL _glfwIsWindows10BuildOrGreaterWin32(WORD build)
|
||||
return RtlVerifyVersionInfo(&osvi, mask, cond) == 0;
|
||||
}
|
||||
|
||||
GLFWbool _glfwConnectWin32(int platformID, _GLFWplatform* platform)
|
||||
{
|
||||
const _GLFWplatform win32 =
|
||||
{
|
||||
GLFW_PLATFORM_WIN32,
|
||||
_glfwInitWin32,
|
||||
_glfwTerminateWin32,
|
||||
_glfwGetCursorPosWin32,
|
||||
_glfwSetCursorPosWin32,
|
||||
_glfwSetCursorModeWin32,
|
||||
_glfwSetRawMouseMotionWin32,
|
||||
_glfwRawMouseMotionSupportedWin32,
|
||||
_glfwCreateCursorWin32,
|
||||
_glfwCreateStandardCursorWin32,
|
||||
_glfwDestroyCursorWin32,
|
||||
_glfwSetCursorWin32,
|
||||
_glfwGetScancodeNameWin32,
|
||||
_glfwGetKeyScancodeWin32,
|
||||
_glfwSetClipboardStringWin32,
|
||||
_glfwGetClipboardStringWin32,
|
||||
_glfwInitJoysticksWin32,
|
||||
_glfwTerminateJoysticksWin32,
|
||||
_glfwPollJoystickWin32,
|
||||
_glfwGetMappingNameWin32,
|
||||
_glfwUpdateGamepadGUIDWin32,
|
||||
_glfwFreeMonitorWin32,
|
||||
_glfwGetMonitorPosWin32,
|
||||
_glfwGetMonitorContentScaleWin32,
|
||||
_glfwGetMonitorWorkareaWin32,
|
||||
_glfwGetVideoModesWin32,
|
||||
_glfwGetVideoModeWin32,
|
||||
_glfwGetGammaRampWin32,
|
||||
_glfwSetGammaRampWin32,
|
||||
_glfwCreateWindowWin32,
|
||||
_glfwDestroyWindowWin32,
|
||||
_glfwSetWindowTitleWin32,
|
||||
_glfwSetWindowIconWin32,
|
||||
_glfwGetWindowPosWin32,
|
||||
_glfwSetWindowPosWin32,
|
||||
_glfwGetWindowSizeWin32,
|
||||
_glfwSetWindowSizeWin32,
|
||||
_glfwSetWindowSizeLimitsWin32,
|
||||
_glfwSetWindowAspectRatioWin32,
|
||||
_glfwGetFramebufferSizeWin32,
|
||||
_glfwGetWindowFrameSizeWin32,
|
||||
_glfwGetWindowContentScaleWin32,
|
||||
_glfwIconifyWindowWin32,
|
||||
_glfwRestoreWindowWin32,
|
||||
_glfwMaximizeWindowWin32,
|
||||
_glfwShowWindowWin32,
|
||||
_glfwHideWindowWin32,
|
||||
_glfwRequestWindowAttentionWin32,
|
||||
_glfwFocusWindowWin32,
|
||||
_glfwSetWindowMonitorWin32,
|
||||
_glfwWindowFocusedWin32,
|
||||
_glfwWindowIconifiedWin32,
|
||||
_glfwWindowVisibleWin32,
|
||||
_glfwWindowMaximizedWin32,
|
||||
_glfwWindowHoveredWin32,
|
||||
_glfwFramebufferTransparentWin32,
|
||||
_glfwGetWindowOpacityWin32,
|
||||
_glfwSetWindowResizableWin32,
|
||||
_glfwSetWindowDecoratedWin32,
|
||||
_glfwSetWindowFloatingWin32,
|
||||
_glfwSetWindowOpacityWin32,
|
||||
_glfwSetWindowMousePassthroughWin32,
|
||||
_glfwPollEventsWin32,
|
||||
_glfwWaitEventsWin32,
|
||||
_glfwWaitEventsTimeoutWin32,
|
||||
_glfwPostEmptyEventWin32,
|
||||
_glfwCreateUserContextWin32,
|
||||
_glfwGetEGLPlatformWin32,
|
||||
_glfwGetEGLNativeDisplayWin32,
|
||||
_glfwGetEGLNativeWindowWin32,
|
||||
_glfwGetRequiredInstanceExtensionsWin32,
|
||||
_glfwGetPhysicalDevicePresentationSupportWin32,
|
||||
_glfwCreateWindowSurfaceWin32,
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
////// GLFW platform API //////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
*platform = win32;
|
||||
return GLFW_TRUE;
|
||||
}
|
||||
|
||||
int _glfwPlatformInit(void)
|
||||
int _glfwInitWin32(void)
|
||||
{
|
||||
if (!loadLibraries())
|
||||
return GLFW_FALSE;
|
||||
@ -563,7 +639,7 @@ int _glfwPlatformInit(void)
|
||||
createKeyTables();
|
||||
_glfwUpdateKeyNamesWin32();
|
||||
|
||||
if (_glfwIsWindows10CreatorsUpdateOrGreaterWin32())
|
||||
if (_glfwIsWindows10Version1703OrGreaterWin32())
|
||||
SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2);
|
||||
else if (IsWindows8Point1OrGreater())
|
||||
SetProcessDpiAwareness(PROCESS_PER_MONITOR_DPI_AWARE);
|
||||
@ -576,13 +652,11 @@ int _glfwPlatformInit(void)
|
||||
if (!createHelperWindow())
|
||||
return GLFW_FALSE;
|
||||
|
||||
_glfwInitTimerWin32();
|
||||
|
||||
_glfwPollMonitorsWin32();
|
||||
return GLFW_TRUE;
|
||||
}
|
||||
|
||||
void _glfwPlatformTerminate(void)
|
||||
void _glfwTerminateWin32(void)
|
||||
{
|
||||
if (_glfw.win32.deviceNotificationHandle)
|
||||
UnregisterDeviceNotification(_glfw.win32.deviceNotificationHandle);
|
||||
@ -601,22 +675,3 @@ void _glfwPlatformTerminate(void)
|
||||
freeLibraries();
|
||||
}
|
||||
|
||||
const char* _glfwPlatformGetVersionString(void)
|
||||
{
|
||||
return _GLFW_VERSION_NUMBER " Win32 WGL EGL OSMesa"
|
||||
#if defined(__MINGW64_VERSION_MAJOR)
|
||||
" MinGW-w64"
|
||||
#elif defined(__MINGW32__)
|
||||
" MinGW"
|
||||
#elif defined(_MSC_VER)
|
||||
" VisualC"
|
||||
#endif
|
||||
#if defined(_GLFW_USE_HYBRID_HPG) || defined(_GLFW_USE_OPTIMUS_HPG)
|
||||
" hybrid-GPU"
|
||||
#endif
|
||||
#if defined(_GLFW_BUILD_DLL)
|
||||
" DLL"
|
||||
#endif
|
||||
;
|
||||
}
|
||||
|
||||
|
@ -561,7 +561,7 @@ void _glfwDetectJoystickDisconnectionWin32(void)
|
||||
{
|
||||
_GLFWjoystick* js = _glfw.joysticks + jid;
|
||||
if (js->present)
|
||||
_glfwPlatformPollJoystick(js, _GLFW_POLL_PRESENCE);
|
||||
_glfwPollJoystickWin32(js, _GLFW_POLL_PRESENCE);
|
||||
}
|
||||
}
|
||||
|
||||
@ -570,11 +570,11 @@ void _glfwDetectJoystickDisconnectionWin32(void)
|
||||
////// GLFW platform API //////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
GLFWbool _glfwPlatformInitJoysticks(void)
|
||||
GLFWbool _glfwInitJoysticksWin32(void)
|
||||
{
|
||||
if (_glfw.win32.dinput8.instance)
|
||||
{
|
||||
if (FAILED(DirectInput8Create(GetModuleHandle(NULL),
|
||||
if (FAILED(DirectInput8Create(_glfw.win32.instance,
|
||||
DIRECTINPUT_VERSION,
|
||||
&IID_IDirectInput8W,
|
||||
(void**) &_glfw.win32.dinput8.api,
|
||||
@ -590,7 +590,7 @@ GLFWbool _glfwPlatformInitJoysticks(void)
|
||||
return GLFW_TRUE;
|
||||
}
|
||||
|
||||
void _glfwPlatformTerminateJoysticks(void)
|
||||
void _glfwTerminateJoysticksWin32(void)
|
||||
{
|
||||
int jid;
|
||||
|
||||
@ -601,7 +601,7 @@ void _glfwPlatformTerminateJoysticks(void)
|
||||
IDirectInput8_Release(_glfw.win32.dinput8.api);
|
||||
}
|
||||
|
||||
int _glfwPlatformPollJoystick(_GLFWjoystick* js, int mode)
|
||||
int _glfwPollJoystickWin32(_GLFWjoystick* js, int mode)
|
||||
{
|
||||
if (js->win32.device)
|
||||
{
|
||||
@ -740,7 +740,12 @@ int _glfwPlatformPollJoystick(_GLFWjoystick* js, int mode)
|
||||
return GLFW_TRUE;
|
||||
}
|
||||
|
||||
void _glfwPlatformUpdateGamepadGUID(char* guid)
|
||||
const char* _glfwGetMappingNameWin32(void)
|
||||
{
|
||||
return "Windows";
|
||||
}
|
||||
|
||||
void _glfwUpdateGamepadGUIDWin32(char* guid)
|
||||
{
|
||||
if (strcmp(guid + 20, "504944564944") == 0)
|
||||
{
|
||||
|
@ -24,10 +24,9 @@
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#define _GLFW_PLATFORM_JOYSTICK_STATE _GLFWjoystickWin32 win32
|
||||
#define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE struct { int dummyLibraryJoystick; }
|
||||
#define GLFW_WIN32_JOYSTICK_STATE _GLFWjoystickWin32 win32;
|
||||
#define GLFW_WIN32_LIBRARY_JOYSTICK_STATE
|
||||
|
||||
#define _GLFW_PLATFORM_MAPPING_NAME "Windows"
|
||||
#define GLFW_BUILD_WIN32_MAPPINGS
|
||||
|
||||
// Joystick element (axis, button or slider)
|
||||
|
49
src/win32_module.c
Normal file
49
src/win32_module.c
Normal file
@ -0,0 +1,49 @@
|
||||
//========================================================================
|
||||
// GLFW 3.4 Win32 - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2021 Camilla Löwy <elmindreda@glfw.org>
|
||||
//
|
||||
// This software is provided 'as-is', without any express or implied
|
||||
// warranty. In no event will the authors be held liable for any damages
|
||||
// arising from the use of this software.
|
||||
//
|
||||
// Permission is granted to anyone to use this software for any purpose,
|
||||
// including commercial applications, and to alter it and redistribute it
|
||||
// freely, subject to the following restrictions:
|
||||
//
|
||||
// 1. The origin of this software must not be misrepresented; you must not
|
||||
// claim that you wrote the original software. If you use this software
|
||||
// in a product, an acknowledgment in the product documentation would
|
||||
// be appreciated but is not required.
|
||||
//
|
||||
// 2. Altered source versions must be plainly marked as such, and must not
|
||||
// be misrepresented as being the original software.
|
||||
//
|
||||
// 3. This notice may not be removed or altered from any source
|
||||
// distribution.
|
||||
//
|
||||
//========================================================================
|
||||
// Please use C89 style variable declarations in this file because VS 2010
|
||||
//========================================================================
|
||||
|
||||
#include "internal.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
////// GLFW platform API //////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void* _glfwPlatformLoadModule(const char* path)
|
||||
{
|
||||
return LoadLibraryA(path);
|
||||
}
|
||||
|
||||
void _glfwPlatformFreeModule(void* module)
|
||||
{
|
||||
FreeLibrary((HMODULE) module);
|
||||
}
|
||||
|
||||
GLFWproc _glfwPlatformGetModuleSymbol(void* module, const char* name)
|
||||
{
|
||||
return (GLFWproc) GetProcAddress((HMODULE) module, name);
|
||||
}
|
||||
|
@ -253,7 +253,7 @@ void _glfwSetVideoModeWin32(_GLFWmonitor* monitor, const GLFWvidmode* desired)
|
||||
LONG result;
|
||||
|
||||
best = _glfwChooseVideoMode(monitor, desired);
|
||||
_glfwPlatformGetVideoMode(monitor, ¤t);
|
||||
_glfwGetVideoModeWin32(monitor, ¤t);
|
||||
if (_glfwCompareVideoModes(¤t, best) == 0)
|
||||
return;
|
||||
|
||||
@ -313,12 +313,23 @@ void _glfwRestoreVideoModeWin32(_GLFWmonitor* monitor)
|
||||
}
|
||||
}
|
||||
|
||||
void _glfwGetMonitorContentScaleWin32(HMONITOR handle, float* xscale, float* yscale)
|
||||
void _glfwGetHMONITORContentScaleWin32(HMONITOR handle, float* xscale, float* yscale)
|
||||
{
|
||||
UINT xdpi, ydpi;
|
||||
|
||||
if (xscale)
|
||||
*xscale = 0.f;
|
||||
if (yscale)
|
||||
*yscale = 0.f;
|
||||
|
||||
if (IsWindows8Point1OrGreater())
|
||||
GetDpiForMonitor(handle, MDT_EFFECTIVE_DPI, &xdpi, &ydpi);
|
||||
{
|
||||
if (GetDpiForMonitor(handle, MDT_EFFECTIVE_DPI, &xdpi, &ydpi) != S_OK)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR, "Win32: Failed to query monitor DPI");
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
const HDC dc = GetDC(NULL);
|
||||
@ -338,11 +349,11 @@ void _glfwGetMonitorContentScaleWin32(HMONITOR handle, float* xscale, float* ysc
|
||||
////// GLFW platform API //////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void _glfwPlatformFreeMonitor(_GLFWmonitor* monitor)
|
||||
void _glfwFreeMonitorWin32(_GLFWmonitor* monitor)
|
||||
{
|
||||
}
|
||||
|
||||
void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos)
|
||||
void _glfwGetMonitorPosWin32(_GLFWmonitor* monitor, int* xpos, int* ypos)
|
||||
{
|
||||
DEVMODEW dm;
|
||||
ZeroMemory(&dm, sizeof(dm));
|
||||
@ -359,18 +370,18 @@ void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos)
|
||||
*ypos = dm.dmPosition.y;
|
||||
}
|
||||
|
||||
void _glfwPlatformGetMonitorContentScale(_GLFWmonitor* monitor,
|
||||
float* xscale, float* yscale)
|
||||
void _glfwGetMonitorContentScaleWin32(_GLFWmonitor* monitor,
|
||||
float* xscale, float* yscale)
|
||||
{
|
||||
_glfwGetMonitorContentScaleWin32(monitor->win32.handle, xscale, yscale);
|
||||
_glfwGetHMONITORContentScaleWin32(monitor->win32.handle, xscale, yscale);
|
||||
}
|
||||
|
||||
void _glfwPlatformGetMonitorWorkarea(_GLFWmonitor* monitor,
|
||||
int* xpos, int* ypos,
|
||||
int* width, int* height)
|
||||
void _glfwGetMonitorWorkareaWin32(_GLFWmonitor* monitor,
|
||||
int* xpos, int* ypos,
|
||||
int* width, int* height)
|
||||
{
|
||||
MONITORINFO mi = { sizeof(mi) };
|
||||
GetMonitorInfo(monitor->win32.handle, &mi);
|
||||
GetMonitorInfoW(monitor->win32.handle, &mi);
|
||||
|
||||
if (xpos)
|
||||
*xpos = mi.rcWork.left;
|
||||
@ -382,7 +393,7 @@ void _glfwPlatformGetMonitorWorkarea(_GLFWmonitor* monitor,
|
||||
*height = mi.rcWork.bottom - mi.rcWork.top;
|
||||
}
|
||||
|
||||
GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* count)
|
||||
GLFWvidmode* _glfwGetVideoModesWin32(_GLFWmonitor* monitor, int* count)
|
||||
{
|
||||
int modeIndex = 0, size = 0;
|
||||
GLFWvidmode* result = NULL;
|
||||
@ -452,14 +463,14 @@ GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* count)
|
||||
{
|
||||
// HACK: Report the current mode if no valid modes were found
|
||||
result = _glfw_calloc(1, sizeof(GLFWvidmode));
|
||||
_glfwPlatformGetVideoMode(monitor, result);
|
||||
_glfwGetVideoModeWin32(monitor, result);
|
||||
*count = 1;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode)
|
||||
void _glfwGetVideoModeWin32(_GLFWmonitor* monitor, GLFWvidmode* mode)
|
||||
{
|
||||
DEVMODEW dm;
|
||||
ZeroMemory(&dm, sizeof(dm));
|
||||
@ -476,7 +487,7 @@ void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode)
|
||||
&mode->blueBits);
|
||||
}
|
||||
|
||||
GLFWbool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
|
||||
GLFWbool _glfwGetGammaRampWin32(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
|
||||
{
|
||||
HDC dc;
|
||||
WORD values[3][256];
|
||||
@ -494,7 +505,7 @@ GLFWbool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
|
||||
return GLFW_TRUE;
|
||||
}
|
||||
|
||||
void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp)
|
||||
void _glfwSetGammaRampWin32(_GLFWmonitor* monitor, const GLFWgammaramp* ramp)
|
||||
{
|
||||
HDC dc;
|
||||
WORD values[3][256];
|
||||
|
@ -162,7 +162,9 @@ typedef enum
|
||||
#define DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 ((HANDLE) -4)
|
||||
#endif /*DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2*/
|
||||
|
||||
// HACK: Define versionhelpers.h functions manually as MinGW lacks the header
|
||||
// Replacement for versionhelpers.h macros, as we cannot rely on the
|
||||
// application having a correct embedded manifest
|
||||
//
|
||||
#define IsWindowsVistaOrGreater() \
|
||||
_glfwIsWindowsVersionOrGreaterWin32(HIBYTE(_WIN32_WINNT_VISTA), \
|
||||
LOBYTE(_WIN32_WINNT_VISTA), 0)
|
||||
@ -176,9 +178,11 @@ typedef enum
|
||||
_glfwIsWindowsVersionOrGreaterWin32(HIBYTE(_WIN32_WINNT_WINBLUE), \
|
||||
LOBYTE(_WIN32_WINNT_WINBLUE), 0)
|
||||
|
||||
#define _glfwIsWindows10AnniversaryUpdateOrGreaterWin32() \
|
||||
// Windows 10 Anniversary Update
|
||||
#define _glfwIsWindows10Version1607OrGreaterWin32() \
|
||||
_glfwIsWindows10BuildOrGreaterWin32(14393)
|
||||
#define _glfwIsWindows10CreatorsUpdateOrGreaterWin32() \
|
||||
// Windows 10 Creators Update
|
||||
#define _glfwIsWindows10Version1703OrGreaterWin32() \
|
||||
_glfwIsWindows10BuildOrGreaterWin32(15063)
|
||||
|
||||
// HACK: Define macros that some xinput.h variants don't
|
||||
@ -215,9 +219,56 @@ typedef enum
|
||||
#define DIDFT_OPTIONAL 0x80000000
|
||||
#endif
|
||||
|
||||
// winmm.dll function pointer typedefs
|
||||
typedef DWORD (WINAPI * PFN_timeGetTime)(void);
|
||||
#define timeGetTime _glfw.win32.winmm.GetTime
|
||||
#define WGL_NUMBER_PIXEL_FORMATS_ARB 0x2000
|
||||
#define WGL_SUPPORT_OPENGL_ARB 0x2010
|
||||
#define WGL_DRAW_TO_WINDOW_ARB 0x2001
|
||||
#define WGL_PIXEL_TYPE_ARB 0x2013
|
||||
#define WGL_TYPE_RGBA_ARB 0x202b
|
||||
#define WGL_ACCELERATION_ARB 0x2003
|
||||
#define WGL_NO_ACCELERATION_ARB 0x2025
|
||||
#define WGL_RED_BITS_ARB 0x2015
|
||||
#define WGL_RED_SHIFT_ARB 0x2016
|
||||
#define WGL_GREEN_BITS_ARB 0x2017
|
||||
#define WGL_GREEN_SHIFT_ARB 0x2018
|
||||
#define WGL_BLUE_BITS_ARB 0x2019
|
||||
#define WGL_BLUE_SHIFT_ARB 0x201a
|
||||
#define WGL_ALPHA_BITS_ARB 0x201b
|
||||
#define WGL_ALPHA_SHIFT_ARB 0x201c
|
||||
#define WGL_ACCUM_BITS_ARB 0x201d
|
||||
#define WGL_ACCUM_RED_BITS_ARB 0x201e
|
||||
#define WGL_ACCUM_GREEN_BITS_ARB 0x201f
|
||||
#define WGL_ACCUM_BLUE_BITS_ARB 0x2020
|
||||
#define WGL_ACCUM_ALPHA_BITS_ARB 0x2021
|
||||
#define WGL_DEPTH_BITS_ARB 0x2022
|
||||
#define WGL_STENCIL_BITS_ARB 0x2023
|
||||
#define WGL_AUX_BUFFERS_ARB 0x2024
|
||||
#define WGL_STEREO_ARB 0x2012
|
||||
#define WGL_DOUBLE_BUFFER_ARB 0x2011
|
||||
#define WGL_SAMPLES_ARB 0x2042
|
||||
#define WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20a9
|
||||
#define WGL_CONTEXT_DEBUG_BIT_ARB 0x00000001
|
||||
#define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x00000002
|
||||
#define WGL_CONTEXT_PROFILE_MASK_ARB 0x9126
|
||||
#define WGL_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001
|
||||
#define WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002
|
||||
#define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091
|
||||
#define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092
|
||||
#define WGL_CONTEXT_FLAGS_ARB 0x2094
|
||||
#define WGL_CONTEXT_ES2_PROFILE_BIT_EXT 0x00000004
|
||||
#define WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB 0x00000004
|
||||
#define WGL_LOSE_CONTEXT_ON_RESET_ARB 0x8252
|
||||
#define WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB 0x8256
|
||||
#define WGL_NO_RESET_NOTIFICATION_ARB 0x8261
|
||||
#define WGL_CONTEXT_RELEASE_BEHAVIOR_ARB 0x2097
|
||||
#define WGL_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB 0
|
||||
#define WGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB 0x2098
|
||||
#define WGL_CONTEXT_OPENGL_NO_ERROR_ARB 0x31b3
|
||||
#define WGL_COLORSPACE_EXT 0x309d
|
||||
#define WGL_COLORSPACE_SRGB_EXT 0x3089
|
||||
|
||||
#define ERROR_INVALID_VERSION_ARB 0x2095
|
||||
#define ERROR_INVALID_PROFILE_ARB 0x2096
|
||||
#define ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB 0x2054
|
||||
|
||||
// xinput.dll function pointer typedefs
|
||||
typedef DWORD (WINAPI * PFN_XInputGetCapabilities)(DWORD,DWORD,XINPUT_CAPABILITIES*);
|
||||
@ -236,12 +287,14 @@ typedef BOOL (WINAPI * PFN_EnableNonClientDpiScaling)(HWND);
|
||||
typedef BOOL (WINAPI * PFN_SetProcessDpiAwarenessContext)(HANDLE);
|
||||
typedef UINT (WINAPI * PFN_GetDpiForWindow)(HWND);
|
||||
typedef BOOL (WINAPI * PFN_AdjustWindowRectExForDpi)(LPRECT,DWORD,BOOL,DWORD,UINT);
|
||||
typedef int (WINAPI * PFN_GetSystemMetricsForDpi)(int,UINT);
|
||||
#define SetProcessDPIAware _glfw.win32.user32.SetProcessDPIAware_
|
||||
#define ChangeWindowMessageFilterEx _glfw.win32.user32.ChangeWindowMessageFilterEx_
|
||||
#define EnableNonClientDpiScaling _glfw.win32.user32.EnableNonClientDpiScaling_
|
||||
#define SetProcessDpiAwarenessContext _glfw.win32.user32.SetProcessDpiAwarenessContext_
|
||||
#define GetDpiForWindow _glfw.win32.user32.GetDpiForWindow_
|
||||
#define AdjustWindowRectExForDpi _glfw.win32.user32.AdjustWindowRectExForDpi_
|
||||
#define GetSystemMetricsForDpi _glfw.win32.user32.GetSystemMetricsForDpi_
|
||||
|
||||
// dwmapi.dll function pointer typedefs
|
||||
typedef HRESULT (WINAPI * PFN_DwmIsCompositionEnabled)(BOOL*);
|
||||
@ -263,6 +316,34 @@ typedef HRESULT (WINAPI * PFN_GetDpiForMonitor)(HMONITOR,MONITOR_DPI_TYPE,UINT*,
|
||||
typedef LONG (WINAPI * PFN_RtlVerifyVersionInfo)(OSVERSIONINFOEXW*,ULONG,ULONGLONG);
|
||||
#define RtlVerifyVersionInfo _glfw.win32.ntdll.RtlVerifyVersionInfo_
|
||||
|
||||
// WGL extension pointer typedefs
|
||||
typedef BOOL (WINAPI * PFNWGLSWAPINTERVALEXTPROC)(int);
|
||||
typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVARBPROC)(HDC,int,int,UINT,const int*,int*);
|
||||
typedef const char* (WINAPI * PFNWGLGETEXTENSIONSSTRINGEXTPROC)(void);
|
||||
typedef const char* (WINAPI * PFNWGLGETEXTENSIONSSTRINGARBPROC)(HDC);
|
||||
typedef HGLRC (WINAPI * PFNWGLCREATECONTEXTATTRIBSARBPROC)(HDC,HGLRC,const int*);
|
||||
#define wglSwapIntervalEXT _glfw.wgl.SwapIntervalEXT
|
||||
#define wglGetPixelFormatAttribivARB _glfw.wgl.GetPixelFormatAttribivARB
|
||||
#define wglGetExtensionsStringEXT _glfw.wgl.GetExtensionsStringEXT
|
||||
#define wglGetExtensionsStringARB _glfw.wgl.GetExtensionsStringARB
|
||||
#define wglCreateContextAttribsARB _glfw.wgl.CreateContextAttribsARB
|
||||
|
||||
// opengl32.dll function pointer typedefs
|
||||
typedef HGLRC (WINAPI * PFN_wglCreateContext)(HDC);
|
||||
typedef BOOL (WINAPI * PFN_wglDeleteContext)(HGLRC);
|
||||
typedef PROC (WINAPI * PFN_wglGetProcAddress)(LPCSTR);
|
||||
typedef HDC (WINAPI * PFN_wglGetCurrentDC)(void);
|
||||
typedef HGLRC (WINAPI * PFN_wglGetCurrentContext)(void);
|
||||
typedef BOOL (WINAPI * PFN_wglMakeCurrent)(HDC,HGLRC);
|
||||
typedef BOOL (WINAPI * PFN_wglShareLists)(HGLRC,HGLRC);
|
||||
#define wglCreateContext _glfw.wgl.CreateContext
|
||||
#define wglDeleteContext _glfw.wgl.DeleteContext
|
||||
#define wglGetProcAddress _glfw.wgl.GetProcAddress
|
||||
#define wglGetCurrentDC _glfw.wgl.GetCurrentDC
|
||||
#define wglGetCurrentContext _glfw.wgl.GetCurrentContext
|
||||
#define wglMakeCurrent _glfw.wgl.MakeCurrent
|
||||
#define wglShareLists _glfw.wgl.ShareLists
|
||||
|
||||
typedef VkFlags VkWin32SurfaceCreateFlagsKHR;
|
||||
|
||||
typedef struct VkWin32SurfaceCreateInfoKHR
|
||||
@ -277,26 +358,69 @@ typedef struct VkWin32SurfaceCreateInfoKHR
|
||||
typedef VkResult (APIENTRY *PFN_vkCreateWin32SurfaceKHR)(VkInstance,const VkWin32SurfaceCreateInfoKHR*,const VkAllocationCallbacks*,VkSurfaceKHR*);
|
||||
typedef VkBool32 (APIENTRY *PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR)(VkPhysicalDevice,uint32_t);
|
||||
|
||||
#include "win32_joystick.h"
|
||||
#include "wgl_context.h"
|
||||
|
||||
#if !defined(_GLFW_WNDCLASSNAME)
|
||||
#define _GLFW_WNDCLASSNAME L"GLFW30"
|
||||
#endif
|
||||
|
||||
#define _glfw_dlopen(name) LoadLibraryA(name)
|
||||
#define _glfw_dlclose(handle) FreeLibrary((HMODULE) handle)
|
||||
#define _glfw_dlsym(handle, name) GetProcAddress((HMODULE) handle, name)
|
||||
#define GLFW_WIN32_WINDOW_STATE _GLFWwindowWin32 win32;
|
||||
#define GLFW_WIN32_LIBRARY_WINDOW_STATE _GLFWlibraryWin32 win32;
|
||||
#define GLFW_WIN32_MONITOR_STATE _GLFWmonitorWin32 win32;
|
||||
#define GLFW_WIN32_CURSOR_STATE _GLFWcursorWin32 win32;
|
||||
|
||||
#define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowWin32 win32
|
||||
#define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryWin32 win32
|
||||
#define _GLFW_PLATFORM_LIBRARY_TIMER_STATE _GLFWtimerWin32 win32
|
||||
#define _GLFW_PLATFORM_MONITOR_STATE _GLFWmonitorWin32 win32
|
||||
#define _GLFW_PLATFORM_CURSOR_STATE _GLFWcursorWin32 win32
|
||||
#define _GLFW_PLATFORM_TLS_STATE _GLFWtlsWin32 win32
|
||||
#define _GLFW_PLATFORM_MUTEX_STATE _GLFWmutexWin32 win32
|
||||
#define GLFW_WGL_CONTEXT_STATE _GLFWcontextWGL wgl;
|
||||
#define GLFW_WGL_LIBRARY_CONTEXT_STATE _GLFWlibraryWGL wgl;
|
||||
#define GLFW_WGL_USER_CONTEXT_STATE _GLFWusercontextWGL wgl;
|
||||
|
||||
|
||||
// WGL-specific per-context data
|
||||
//
|
||||
typedef struct _GLFWcontextWGL
|
||||
{
|
||||
HDC dc;
|
||||
HGLRC handle;
|
||||
int interval;
|
||||
} _GLFWcontextWGL;
|
||||
|
||||
// WGL-specific global data
|
||||
//
|
||||
typedef struct _GLFWlibraryWGL
|
||||
{
|
||||
HINSTANCE instance;
|
||||
PFN_wglCreateContext CreateContext;
|
||||
PFN_wglDeleteContext DeleteContext;
|
||||
PFN_wglGetProcAddress GetProcAddress;
|
||||
PFN_wglGetCurrentDC GetCurrentDC;
|
||||
PFN_wglGetCurrentContext GetCurrentContext;
|
||||
PFN_wglMakeCurrent MakeCurrent;
|
||||
PFN_wglShareLists ShareLists;
|
||||
|
||||
PFNWGLSWAPINTERVALEXTPROC SwapIntervalEXT;
|
||||
PFNWGLGETPIXELFORMATATTRIBIVARBPROC GetPixelFormatAttribivARB;
|
||||
PFNWGLGETEXTENSIONSSTRINGEXTPROC GetExtensionsStringEXT;
|
||||
PFNWGLGETEXTENSIONSSTRINGARBPROC GetExtensionsStringARB;
|
||||
PFNWGLCREATECONTEXTATTRIBSARBPROC CreateContextAttribsARB;
|
||||
GLFWbool EXT_swap_control;
|
||||
GLFWbool EXT_colorspace;
|
||||
GLFWbool ARB_multisample;
|
||||
GLFWbool ARB_framebuffer_sRGB;
|
||||
GLFWbool EXT_framebuffer_sRGB;
|
||||
GLFWbool ARB_pixel_format;
|
||||
GLFWbool ARB_create_context;
|
||||
GLFWbool ARB_create_context_profile;
|
||||
GLFWbool EXT_create_context_es2_profile;
|
||||
GLFWbool ARB_create_context_robustness;
|
||||
GLFWbool ARB_create_context_no_error;
|
||||
GLFWbool ARB_context_flush_control;
|
||||
} _GLFWlibraryWGL;
|
||||
|
||||
// WGL-specific per-usercontext data
|
||||
//
|
||||
typedef struct _GLFWusercontextWGL
|
||||
{
|
||||
HDC dc;
|
||||
HGLRC handle;
|
||||
} _GLFWusercontextWGL;
|
||||
|
||||
// Win32-specific per-window data
|
||||
//
|
||||
typedef struct _GLFWwindowWin32
|
||||
@ -319,15 +443,15 @@ typedef struct _GLFWwindowWin32
|
||||
|
||||
// The last received cursor position, regardless of source
|
||||
int lastCursorPosX, lastCursorPosY;
|
||||
// The last recevied high surrogate when decoding pairs of UTF-16 messages
|
||||
// The last received high surrogate when decoding pairs of UTF-16 messages
|
||||
WCHAR highSurrogate;
|
||||
|
||||
} _GLFWwindowWin32;
|
||||
|
||||
// Win32-specific global data
|
||||
//
|
||||
typedef struct _GLFWlibraryWin32
|
||||
{
|
||||
HINSTANCE instance;
|
||||
HWND helperWindowHandle;
|
||||
HDEVNOTIFY deviceNotificationHandle;
|
||||
int acquiredMonitorCount;
|
||||
@ -343,11 +467,6 @@ typedef struct _GLFWlibraryWin32
|
||||
int rawInputSize;
|
||||
UINT mouseTrailSize;
|
||||
|
||||
struct {
|
||||
HINSTANCE instance;
|
||||
PFN_timeGetTime GetTime;
|
||||
} winmm;
|
||||
|
||||
struct {
|
||||
HINSTANCE instance;
|
||||
PFN_DirectInput8Create Create;
|
||||
@ -368,6 +487,7 @@ typedef struct _GLFWlibraryWin32
|
||||
PFN_SetProcessDpiAwarenessContext SetProcessDpiAwarenessContext_;
|
||||
PFN_GetDpiForWindow GetDpiForWindow_;
|
||||
PFN_AdjustWindowRectExForDpi AdjustWindowRectExForDpi_;
|
||||
PFN_GetSystemMetricsForDpi GetSystemMetricsForDpi_;
|
||||
} user32;
|
||||
|
||||
struct {
|
||||
@ -388,7 +508,6 @@ typedef struct _GLFWlibraryWin32
|
||||
HINSTANCE instance;
|
||||
PFN_RtlVerifyVersionInfo RtlVerifyVersionInfo_;
|
||||
} ntdll;
|
||||
|
||||
} _GLFWlibraryWin32;
|
||||
|
||||
// Win32-specific per-monitor data
|
||||
@ -403,7 +522,6 @@ typedef struct _GLFWmonitorWin32
|
||||
char publicDisplayName[32];
|
||||
GLFWbool modesPruned;
|
||||
GLFWbool modeChanged;
|
||||
|
||||
} _GLFWmonitorWin32;
|
||||
|
||||
// Win32-specific per-cursor data
|
||||
@ -411,36 +529,12 @@ typedef struct _GLFWmonitorWin32
|
||||
typedef struct _GLFWcursorWin32
|
||||
{
|
||||
HCURSOR handle;
|
||||
|
||||
} _GLFWcursorWin32;
|
||||
|
||||
// Win32-specific global timer data
|
||||
//
|
||||
typedef struct _GLFWtimerWin32
|
||||
{
|
||||
GLFWbool hasPC;
|
||||
uint64_t frequency;
|
||||
|
||||
} _GLFWtimerWin32;
|
||||
|
||||
// Win32-specific thread local storage data
|
||||
//
|
||||
typedef struct _GLFWtlsWin32
|
||||
{
|
||||
GLFWbool allocated;
|
||||
DWORD index;
|
||||
|
||||
} _GLFWtlsWin32;
|
||||
|
||||
// Win32-specific mutex data
|
||||
//
|
||||
typedef struct _GLFWmutexWin32
|
||||
{
|
||||
GLFWbool allocated;
|
||||
CRITICAL_SECTION section;
|
||||
|
||||
} _GLFWmutexWin32;
|
||||
|
||||
GLFWbool _glfwConnectWin32(int platformID, _GLFWplatform* platform);
|
||||
int _glfwInitWin32(void);
|
||||
void _glfwTerminateWin32(void);
|
||||
|
||||
GLFWbool _glfwRegisterWindowClassWin32(void);
|
||||
void _glfwUnregisterWindowClassWin32(void);
|
||||
@ -452,10 +546,93 @@ BOOL _glfwIsWindows10BuildOrGreaterWin32(WORD build);
|
||||
void _glfwInputErrorWin32(int error, const char* description);
|
||||
void _glfwUpdateKeyNamesWin32(void);
|
||||
|
||||
void _glfwInitTimerWin32(void);
|
||||
|
||||
void _glfwPollMonitorsWin32(void);
|
||||
void _glfwSetVideoModeWin32(_GLFWmonitor* monitor, const GLFWvidmode* desired);
|
||||
void _glfwRestoreVideoModeWin32(_GLFWmonitor* monitor);
|
||||
void _glfwGetMonitorContentScaleWin32(HMONITOR handle, float* xscale, float* yscale);
|
||||
void _glfwGetHMONITORContentScaleWin32(HMONITOR handle, float* xscale, float* yscale);
|
||||
|
||||
int _glfwCreateWindowWin32(_GLFWwindow* window, const _GLFWwndconfig* wndconfig, const _GLFWctxconfig* ctxconfig, const _GLFWfbconfig* fbconfig);
|
||||
void _glfwDestroyWindowWin32(_GLFWwindow* window);
|
||||
void _glfwSetWindowTitleWin32(_GLFWwindow* window, const char* title);
|
||||
void _glfwSetWindowIconWin32(_GLFWwindow* window, int count, const GLFWimage* images);
|
||||
void _glfwGetWindowPosWin32(_GLFWwindow* window, int* xpos, int* ypos);
|
||||
void _glfwSetWindowPosWin32(_GLFWwindow* window, int xpos, int ypos);
|
||||
void _glfwGetWindowSizeWin32(_GLFWwindow* window, int* width, int* height);
|
||||
void _glfwSetWindowSizeWin32(_GLFWwindow* window, int width, int height);
|
||||
void _glfwSetWindowSizeLimitsWin32(_GLFWwindow* window, int minwidth, int minheight, int maxwidth, int maxheight);
|
||||
void _glfwSetWindowAspectRatioWin32(_GLFWwindow* window, int numer, int denom);
|
||||
void _glfwGetFramebufferSizeWin32(_GLFWwindow* window, int* width, int* height);
|
||||
void _glfwGetWindowFrameSizeWin32(_GLFWwindow* window, int* left, int* top, int* right, int* bottom);
|
||||
void _glfwGetWindowContentScaleWin32(_GLFWwindow* window, float* xscale, float* yscale);
|
||||
void _glfwIconifyWindowWin32(_GLFWwindow* window);
|
||||
void _glfwRestoreWindowWin32(_GLFWwindow* window);
|
||||
void _glfwMaximizeWindowWin32(_GLFWwindow* window);
|
||||
void _glfwShowWindowWin32(_GLFWwindow* window);
|
||||
void _glfwHideWindowWin32(_GLFWwindow* window);
|
||||
void _glfwRequestWindowAttentionWin32(_GLFWwindow* window);
|
||||
void _glfwFocusWindowWin32(_GLFWwindow* window);
|
||||
void _glfwSetWindowMonitorWin32(_GLFWwindow* window, _GLFWmonitor* monitor, int xpos, int ypos, int width, int height, int refreshRate);
|
||||
int _glfwWindowFocusedWin32(_GLFWwindow* window);
|
||||
int _glfwWindowIconifiedWin32(_GLFWwindow* window);
|
||||
int _glfwWindowVisibleWin32(_GLFWwindow* window);
|
||||
int _glfwWindowMaximizedWin32(_GLFWwindow* window);
|
||||
int _glfwWindowHoveredWin32(_GLFWwindow* window);
|
||||
int _glfwFramebufferTransparentWin32(_GLFWwindow* window);
|
||||
void _glfwSetWindowResizableWin32(_GLFWwindow* window, GLFWbool enabled);
|
||||
void _glfwSetWindowDecoratedWin32(_GLFWwindow* window, GLFWbool enabled);
|
||||
void _glfwSetWindowFloatingWin32(_GLFWwindow* window, GLFWbool enabled);
|
||||
void _glfwSetWindowMousePassthroughWin32(_GLFWwindow* window, GLFWbool enabled);
|
||||
float _glfwGetWindowOpacityWin32(_GLFWwindow* window);
|
||||
void _glfwSetWindowOpacityWin32(_GLFWwindow* window, float opacity);
|
||||
|
||||
void _glfwSetRawMouseMotionWin32(_GLFWwindow *window, GLFWbool enabled);
|
||||
GLFWbool _glfwRawMouseMotionSupportedWin32(void);
|
||||
|
||||
void _glfwPollEventsWin32(void);
|
||||
void _glfwWaitEventsWin32(void);
|
||||
void _glfwWaitEventsTimeoutWin32(double timeout);
|
||||
void _glfwPostEmptyEventWin32(void);
|
||||
|
||||
void _glfwGetCursorPosWin32(_GLFWwindow* window, double* xpos, double* ypos);
|
||||
void _glfwSetCursorPosWin32(_GLFWwindow* window, double xpos, double ypos);
|
||||
void _glfwSetCursorModeWin32(_GLFWwindow* window, int mode);
|
||||
const char* _glfwGetScancodeNameWin32(int scancode);
|
||||
int _glfwGetKeyScancodeWin32(int key);
|
||||
int _glfwCreateCursorWin32(_GLFWcursor* cursor, const GLFWimage* image, int xhot, int yhot);
|
||||
int _glfwCreateStandardCursorWin32(_GLFWcursor* cursor, int shape);
|
||||
void _glfwDestroyCursorWin32(_GLFWcursor* cursor);
|
||||
void _glfwSetCursorWin32(_GLFWwindow* window, _GLFWcursor* cursor);
|
||||
void _glfwSetClipboardStringWin32(const char* string);
|
||||
const char* _glfwGetClipboardStringWin32(void);
|
||||
|
||||
EGLenum _glfwGetEGLPlatformWin32(EGLint** attribs);
|
||||
EGLNativeDisplayType _glfwGetEGLNativeDisplayWin32(void);
|
||||
EGLNativeWindowType _glfwGetEGLNativeWindowWin32(_GLFWwindow* window);
|
||||
|
||||
void _glfwGetRequiredInstanceExtensionsWin32(char** extensions);
|
||||
int _glfwGetPhysicalDevicePresentationSupportWin32(VkInstance instance, VkPhysicalDevice device, uint32_t queuefamily);
|
||||
VkResult _glfwCreateWindowSurfaceWin32(VkInstance instance, _GLFWwindow* window, const VkAllocationCallbacks* allocator, VkSurfaceKHR* surface);
|
||||
|
||||
void _glfwFreeMonitorWin32(_GLFWmonitor* monitor);
|
||||
void _glfwGetMonitorPosWin32(_GLFWmonitor* monitor, int* xpos, int* ypos);
|
||||
void _glfwGetMonitorContentScaleWin32(_GLFWmonitor* monitor, float* xscale, float* yscale);
|
||||
void _glfwGetMonitorWorkareaWin32(_GLFWmonitor* monitor, int* xpos, int* ypos, int* width, int* height);
|
||||
GLFWvidmode* _glfwGetVideoModesWin32(_GLFWmonitor* monitor, int* count);
|
||||
void _glfwGetVideoModeWin32(_GLFWmonitor* monitor, GLFWvidmode* mode);
|
||||
GLFWbool _glfwGetGammaRampWin32(_GLFWmonitor* monitor, GLFWgammaramp* ramp);
|
||||
void _glfwSetGammaRampWin32(_GLFWmonitor* monitor, const GLFWgammaramp* ramp);
|
||||
|
||||
GLFWbool _glfwInitJoysticksWin32(void);
|
||||
void _glfwTerminateJoysticksWin32(void);
|
||||
int _glfwPollJoystickWin32(_GLFWjoystick* js, int mode);
|
||||
const char* _glfwGetMappingNameWin32(void);
|
||||
void _glfwUpdateGamepadGUIDWin32(char* guid);
|
||||
|
||||
GLFWbool _glfwInitWGL(void);
|
||||
void _glfwTerminateWGL(void);
|
||||
GLFWbool _glfwCreateContextWGL(_GLFWwindow* window,
|
||||
const _GLFWctxconfig* ctxconfig,
|
||||
const _GLFWfbconfig* fbconfig);
|
||||
|
||||
_GLFWusercontext* _glfwCreateUserContextWin32(_GLFWwindow* window);
|
||||
_GLFWusercontext* _glfwCreateUserContextWGL(_GLFWwindow* window);
|
||||
|
@ -43,8 +43,7 @@ GLFWbool _glfwPlatformCreateTls(_GLFWtls* tls)
|
||||
tls->win32.index = TlsAlloc();
|
||||
if (tls->win32.index == TLS_OUT_OF_INDEXES)
|
||||
{
|
||||
_glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
|
||||
"Win32: Failed to allocate TLS index");
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR, "Win32: Failed to allocate TLS index");
|
||||
return GLFW_FALSE;
|
||||
}
|
||||
|
||||
|
48
src/win32_thread.h
Normal file
48
src/win32_thread.h
Normal file
@ -0,0 +1,48 @@
|
||||
//========================================================================
|
||||
// GLFW 3.4 Win32 - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2002-2006 Marcus Geelnard
|
||||
// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>
|
||||
//
|
||||
// This software is provided 'as-is', without any express or implied
|
||||
// warranty. In no event will the authors be held liable for any damages
|
||||
// arising from the use of this software.
|
||||
//
|
||||
// Permission is granted to anyone to use this software for any purpose,
|
||||
// including commercial applications, and to alter it and redistribute it
|
||||
// freely, subject to the following restrictions:
|
||||
//
|
||||
// 1. The origin of this software must not be misrepresented; you must not
|
||||
// claim that you wrote the original software. If you use this software
|
||||
// in a product, an acknowledgment in the product documentation would
|
||||
// be appreciated but is not required.
|
||||
//
|
||||
// 2. Altered source versions must be plainly marked as such, and must not
|
||||
// be misrepresented as being the original software.
|
||||
//
|
||||
// 3. This notice may not be removed or altered from any source
|
||||
// distribution.
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#define GLFW_WIN32_TLS_STATE _GLFWtlsWin32 win32;
|
||||
#define GLFW_WIN32_MUTEX_STATE _GLFWmutexWin32 win32;
|
||||
|
||||
// Win32-specific thread local storage data
|
||||
//
|
||||
typedef struct _GLFWtlsWin32
|
||||
{
|
||||
GLFWbool allocated;
|
||||
DWORD index;
|
||||
} _GLFWtlsWin32;
|
||||
|
||||
// Win32-specific mutex data
|
||||
//
|
||||
typedef struct _GLFWmutexWin32
|
||||
{
|
||||
GLFWbool allocated;
|
||||
CRITICAL_SECTION section;
|
||||
} _GLFWmutexWin32;
|
||||
|
@ -30,43 +30,20 @@
|
||||
#include "internal.h"
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
////// GLFW internal API //////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Initialise timer
|
||||
//
|
||||
void _glfwInitTimerWin32(void)
|
||||
{
|
||||
uint64_t frequency;
|
||||
|
||||
if (QueryPerformanceFrequency((LARGE_INTEGER*) &frequency))
|
||||
{
|
||||
_glfw.timer.win32.hasPC = GLFW_TRUE;
|
||||
_glfw.timer.win32.frequency = frequency;
|
||||
}
|
||||
else
|
||||
{
|
||||
_glfw.timer.win32.hasPC = GLFW_FALSE;
|
||||
_glfw.timer.win32.frequency = 1000;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
////// GLFW platform API //////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void _glfwPlatformInitTimer(void)
|
||||
{
|
||||
QueryPerformanceFrequency((LARGE_INTEGER*) &_glfw.timer.win32.frequency);
|
||||
}
|
||||
|
||||
uint64_t _glfwPlatformGetTimerValue(void)
|
||||
{
|
||||
if (_glfw.timer.win32.hasPC)
|
||||
{
|
||||
uint64_t value;
|
||||
QueryPerformanceCounter((LARGE_INTEGER*) &value);
|
||||
return value;
|
||||
}
|
||||
else
|
||||
return (uint64_t) timeGetTime();
|
||||
uint64_t value;
|
||||
QueryPerformanceCounter((LARGE_INTEGER*) &value);
|
||||
return value;
|
||||
}
|
||||
|
||||
uint64_t _glfwPlatformGetTimerFrequency(void)
|
||||
|
38
src/win32_time.h
Normal file
38
src/win32_time.h
Normal file
@ -0,0 +1,38 @@
|
||||
//========================================================================
|
||||
// GLFW 3.4 Win32 - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2002-2006 Marcus Geelnard
|
||||
// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>
|
||||
//
|
||||
// This software is provided 'as-is', without any express or implied
|
||||
// warranty. In no event will the authors be held liable for any damages
|
||||
// arising from the use of this software.
|
||||
//
|
||||
// Permission is granted to anyone to use this software for any purpose,
|
||||
// including commercial applications, and to alter it and redistribute it
|
||||
// freely, subject to the following restrictions:
|
||||
//
|
||||
// 1. The origin of this software must not be misrepresented; you must not
|
||||
// claim that you wrote the original software. If you use this software
|
||||
// in a product, an acknowledgment in the product documentation would
|
||||
// be appreciated but is not required.
|
||||
//
|
||||
// 2. Altered source versions must be plainly marked as such, and must not
|
||||
// be misrepresented as being the original software.
|
||||
//
|
||||
// 3. This notice may not be removed or altered from any source
|
||||
// distribution.
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#define GLFW_WIN32_LIBRARY_TIMER_STATE _GLFWtimerWin32 win32;
|
||||
|
||||
// Win32-specific global timer data
|
||||
//
|
||||
typedef struct _GLFWtimerWin32
|
||||
{
|
||||
uint64_t frequency;
|
||||
} _GLFWtimerWin32;
|
||||
|
@ -97,8 +97,7 @@ static const GLFWimage* chooseImage(int count, const GLFWimage* images,
|
||||
|
||||
// Creates an RGBA icon or cursor
|
||||
//
|
||||
static HICON createIcon(const GLFWimage* image,
|
||||
int xhot, int yhot, GLFWbool icon)
|
||||
static HICON createIcon(const GLFWimage* image, int xhot, int yhot, GLFWbool icon)
|
||||
{
|
||||
int i;
|
||||
HDC dc;
|
||||
@ -194,7 +193,7 @@ static void getFullWindowSize(DWORD style, DWORD exStyle,
|
||||
{
|
||||
RECT rect = { 0, 0, contentWidth, contentHeight };
|
||||
|
||||
if (_glfwIsWindows10AnniversaryUpdateOrGreaterWin32())
|
||||
if (_glfwIsWindows10Version1607OrGreaterWin32())
|
||||
AdjustWindowRectExForDpi(&rect, style, FALSE, exStyle, dpi);
|
||||
else
|
||||
AdjustWindowRectEx(&rect, style, FALSE, exStyle);
|
||||
@ -211,7 +210,7 @@ static void applyAspectRatio(_GLFWwindow* window, int edge, RECT* area)
|
||||
UINT dpi = USER_DEFAULT_SCREEN_DPI;
|
||||
const float ratio = (float) window->numer / (float) window->denom;
|
||||
|
||||
if (_glfwIsWindows10AnniversaryUpdateOrGreaterWin32())
|
||||
if (_glfwIsWindows10Version1607OrGreaterWin32())
|
||||
dpi = GetDpiForWindow(window->win32.handle);
|
||||
|
||||
getFullWindowSize(getWindowStyle(window), getWindowExStyle(window),
|
||||
@ -297,9 +296,9 @@ static void disableRawMouseMotion(_GLFWwindow* window)
|
||||
static void disableCursor(_GLFWwindow* window)
|
||||
{
|
||||
_glfw.win32.disabledCursorWindow = window;
|
||||
_glfwPlatformGetCursorPos(window,
|
||||
&_glfw.win32.restoreCursorPosX,
|
||||
&_glfw.win32.restoreCursorPosY);
|
||||
_glfwGetCursorPosWin32(window,
|
||||
&_glfw.win32.restoreCursorPosX,
|
||||
&_glfw.win32.restoreCursorPosY);
|
||||
updateCursorImage(window);
|
||||
_glfwCenterCursorInContentArea(window);
|
||||
updateClipRect(window);
|
||||
@ -317,9 +316,9 @@ static void enableCursor(_GLFWwindow* window)
|
||||
|
||||
_glfw.win32.disabledCursorWindow = NULL;
|
||||
updateClipRect(NULL);
|
||||
_glfwPlatformSetCursorPos(window,
|
||||
_glfw.win32.restoreCursorPosX,
|
||||
_glfw.win32.restoreCursorPosY);
|
||||
_glfwSetCursorPosWin32(window,
|
||||
_glfw.win32.restoreCursorPosX,
|
||||
_glfw.win32.restoreCursorPosY);
|
||||
updateCursorImage(window);
|
||||
}
|
||||
|
||||
@ -354,7 +353,7 @@ static void updateWindowStyles(const _GLFWwindow* window)
|
||||
|
||||
GetClientRect(window->win32.handle, &rect);
|
||||
|
||||
if (_glfwIsWindows10AnniversaryUpdateOrGreaterWin32())
|
||||
if (_glfwIsWindows10Version1607OrGreaterWin32())
|
||||
{
|
||||
AdjustWindowRectExForDpi(&rect, style, FALSE,
|
||||
getWindowExStyle(window),
|
||||
@ -434,7 +433,7 @@ static int getKeyMods(void)
|
||||
static void fitToMonitor(_GLFWwindow* window)
|
||||
{
|
||||
MONITORINFO mi = { sizeof(mi) };
|
||||
GetMonitorInfo(window->monitor->win32.handle, &mi);
|
||||
GetMonitorInfoW(window->monitor->win32.handle, &mi);
|
||||
SetWindowPos(window->win32.handle, HWND_TOPMOST,
|
||||
mi.rcMonitor.left,
|
||||
mi.rcMonitor.top,
|
||||
@ -453,8 +452,8 @@ static void acquireMonitor(_GLFWwindow* window)
|
||||
|
||||
// HACK: When mouse trails are enabled the cursor becomes invisible when
|
||||
// the OpenGL ICD switches to page flipping
|
||||
SystemParametersInfo(SPI_GETMOUSETRAILS, 0, &_glfw.win32.mouseTrailSize, 0);
|
||||
SystemParametersInfo(SPI_SETMOUSETRAILS, 0, 0, 0);
|
||||
SystemParametersInfoW(SPI_GETMOUSETRAILS, 0, &_glfw.win32.mouseTrailSize, 0);
|
||||
SystemParametersInfoW(SPI_SETMOUSETRAILS, 0, 0, 0);
|
||||
}
|
||||
|
||||
if (!window->monitor->window)
|
||||
@ -477,17 +476,66 @@ static void releaseMonitor(_GLFWwindow* window)
|
||||
SetThreadExecutionState(ES_CONTINUOUS);
|
||||
|
||||
// HACK: Restore mouse trail length saved in acquireMonitor
|
||||
SystemParametersInfo(SPI_SETMOUSETRAILS, _glfw.win32.mouseTrailSize, 0, 0);
|
||||
SystemParametersInfoW(SPI_SETMOUSETRAILS, _glfw.win32.mouseTrailSize, 0, 0);
|
||||
}
|
||||
|
||||
_glfwInputMonitorWindow(window->monitor, NULL);
|
||||
_glfwRestoreVideoModeWin32(window->monitor);
|
||||
}
|
||||
|
||||
// Manually maximize the window, for when SW_MAXIMIZE cannot be used
|
||||
//
|
||||
static void maximizeWindowManually(_GLFWwindow* window)
|
||||
{
|
||||
RECT rect;
|
||||
DWORD style;
|
||||
MONITORINFO mi = { sizeof(mi) };
|
||||
|
||||
GetMonitorInfoW(MonitorFromWindow(window->win32.handle,
|
||||
MONITOR_DEFAULTTONEAREST), &mi);
|
||||
|
||||
rect = mi.rcWork;
|
||||
|
||||
if (window->maxwidth != GLFW_DONT_CARE && window->maxheight != GLFW_DONT_CARE)
|
||||
{
|
||||
rect.right = _glfw_min(rect.right, rect.left + window->maxwidth);
|
||||
rect.bottom = _glfw_min(rect.bottom, rect.top + window->maxheight);
|
||||
}
|
||||
|
||||
style = GetWindowLongW(window->win32.handle, GWL_STYLE);
|
||||
style |= WS_MAXIMIZE;
|
||||
SetWindowLongW(window->win32.handle, GWL_STYLE, style);
|
||||
|
||||
if (window->decorated)
|
||||
{
|
||||
const DWORD exStyle = GetWindowLongW(window->win32.handle, GWL_EXSTYLE);
|
||||
|
||||
if (_glfwIsWindows10Version1607OrGreaterWin32())
|
||||
{
|
||||
const UINT dpi = GetDpiForWindow(window->win32.handle);
|
||||
AdjustWindowRectExForDpi(&rect, style, FALSE, exStyle, dpi);
|
||||
OffsetRect(&rect, 0, GetSystemMetricsForDpi(SM_CYCAPTION, dpi));
|
||||
}
|
||||
else
|
||||
{
|
||||
AdjustWindowRectEx(&rect, style, FALSE, exStyle);
|
||||
OffsetRect(&rect, 0, GetSystemMetrics(SM_CYCAPTION));
|
||||
}
|
||||
|
||||
rect.bottom = _glfw_min(rect.bottom, mi.rcWork.bottom);
|
||||
}
|
||||
|
||||
SetWindowPos(window->win32.handle, HWND_TOP,
|
||||
rect.left,
|
||||
rect.top,
|
||||
rect.right - rect.left,
|
||||
rect.bottom - rect.top,
|
||||
SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED);
|
||||
}
|
||||
|
||||
// Window callback function (handles window messages)
|
||||
//
|
||||
static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
|
||||
WPARAM wParam, LPARAM lParam)
|
||||
static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
_GLFWwindow* window = GetPropW(hWnd, L"GLFW");
|
||||
if (!window)
|
||||
@ -499,7 +547,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
|
||||
{
|
||||
case WM_NCCREATE:
|
||||
{
|
||||
if (_glfwIsWindows10AnniversaryUpdateOrGreaterWin32())
|
||||
if (_glfwIsWindows10Version1607OrGreaterWin32())
|
||||
{
|
||||
const CREATESTRUCTW* cs = (const CREATESTRUCTW*) lParam;
|
||||
const _GLFWwndconfig* wndconfig = cs->lpCreateParams;
|
||||
@ -595,7 +643,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
|
||||
enableCursor(window);
|
||||
|
||||
if (window->monitor && window->autoIconify)
|
||||
_glfwPlatformIconifyWindow(window);
|
||||
_glfwIconifyWindowWin32(window);
|
||||
|
||||
_glfwInputWindowFocus(window, GLFW_FALSE);
|
||||
return 0;
|
||||
@ -649,7 +697,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
|
||||
window->win32.highSurrogate = (WCHAR) wParam;
|
||||
else
|
||||
{
|
||||
unsigned int codepoint = 0;
|
||||
uint32_t codepoint = 0;
|
||||
|
||||
if (wParam >= 0xdc00 && wParam <= 0xdfff)
|
||||
{
|
||||
@ -683,7 +731,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
_glfwInputChar(window, (unsigned int) wParam, getKeyMods(), GLFW_TRUE);
|
||||
_glfwInputChar(window, (uint32_t) wParam, getKeyMods(), GLFW_TRUE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -704,6 +752,14 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
|
||||
scancode = MapVirtualKeyW((UINT) wParam, MAPVK_VK_TO_VSC);
|
||||
}
|
||||
|
||||
// HACK: Alt+PrtSc has a different scancode than just PrtSc
|
||||
if (scancode == 0x54)
|
||||
scancode = 0x137;
|
||||
|
||||
// HACK: Ctrl+Pause has a different scancode than just Pause
|
||||
if (scancode == 0x146)
|
||||
scancode = 0x45;
|
||||
|
||||
key = _glfw.win32.keycodes[scancode];
|
||||
|
||||
// The Ctrl keys require special handling
|
||||
@ -755,7 +811,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
|
||||
{
|
||||
// HACK: Release both Shift keys on Shift up event, as when both
|
||||
// are pressed the first release does not emit any event
|
||||
// NOTE: The other half of this is in _glfwPlatformPollEvents
|
||||
// NOTE: The other half of this is in _glfwPollEventsWin32
|
||||
_glfwInputKey(window, GLFW_KEY_LEFT_SHIFT, scancode, action, mods);
|
||||
_glfwInputKey(window, GLFW_KEY_RIGHT_SHIFT, scancode, action, mods);
|
||||
}
|
||||
@ -1045,7 +1101,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
|
||||
if (window->monitor)
|
||||
break;
|
||||
|
||||
if (_glfwIsWindows10AnniversaryUpdateOrGreaterWin32())
|
||||
if (_glfwIsWindows10Version1607OrGreaterWin32())
|
||||
dpi = GetDpiForWindow(window->win32.handle);
|
||||
|
||||
getFullWindowSize(getWindowStyle(window), getWindowExStyle(window),
|
||||
@ -1073,7 +1129,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
|
||||
|
||||
ZeroMemory(&mi, sizeof(mi));
|
||||
mi.cbSize = sizeof(mi);
|
||||
GetMonitorInfo(mh, &mi);
|
||||
GetMonitorInfoW(mh, &mi);
|
||||
|
||||
mmi->ptMaxPosition.x = mi.rcWork.left - mi.rcMonitor.left;
|
||||
mmi->ptMaxPosition.y = mi.rcWork.top - mi.rcMonitor.top;
|
||||
@ -1120,7 +1176,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
|
||||
break;
|
||||
|
||||
// Adjust the window size to keep the content area size constant
|
||||
if (_glfwIsWindows10CreatorsUpdateOrGreaterWin32())
|
||||
if (_glfwIsWindows10Version1703OrGreaterWin32())
|
||||
{
|
||||
RECT source = {0}, target = {0};
|
||||
SIZE* size = (SIZE*) lParam;
|
||||
@ -1151,7 +1207,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
|
||||
// need it to compensate for non-client area scaling
|
||||
if (!window->monitor &&
|
||||
(window->win32.scaleToMonitor ||
|
||||
_glfwIsWindows10CreatorsUpdateOrGreaterWin32()))
|
||||
_glfwIsWindows10Version1703OrGreaterWin32()))
|
||||
{
|
||||
RECT* suggested = (RECT*) lParam;
|
||||
SetWindowPos(window->win32.handle, HWND_TOP,
|
||||
@ -1233,8 +1289,8 @@ static int createNativeWindow(_GLFWwindow* window,
|
||||
// NOTE: This window placement is temporary and approximate, as the
|
||||
// correct position and size cannot be known until the monitor
|
||||
// video mode has been picked in _glfwSetVideoModeWin32
|
||||
_glfwPlatformGetMonitorPos(window->monitor, &xpos, &ypos);
|
||||
_glfwPlatformGetVideoMode(window->monitor, &mode);
|
||||
_glfwGetMonitorPosWin32(window->monitor, &xpos, &ypos);
|
||||
_glfwGetVideoModeWin32(window->monitor, &mode);
|
||||
fullWidth = mode.width;
|
||||
fullHeight = mode.height;
|
||||
}
|
||||
@ -1265,7 +1321,7 @@ static int createNativeWindow(_GLFWwindow* window,
|
||||
fullWidth, fullHeight,
|
||||
NULL, // No parent window
|
||||
NULL, // No window menu
|
||||
GetModuleHandleW(NULL),
|
||||
_glfw.win32.instance,
|
||||
(LPVOID) wndconfig);
|
||||
|
||||
_glfw_free(wideTitle);
|
||||
@ -1292,26 +1348,31 @@ static int createNativeWindow(_GLFWwindow* window,
|
||||
window->win32.scaleToMonitor = wndconfig->scaleToMonitor;
|
||||
window->win32.keymenu = wndconfig->win32.keymenu;
|
||||
|
||||
// Adjust window rect to account for DPI scaling of the window frame and
|
||||
// (if enabled) DPI scaling of the content area
|
||||
// This cannot be done until we know what monitor the window was placed on
|
||||
if (!window->monitor)
|
||||
{
|
||||
RECT rect = { 0, 0, wndconfig->width, wndconfig->height };
|
||||
WINDOWPLACEMENT wp = { sizeof(wp) };
|
||||
const HMONITOR mh = MonitorFromWindow(window->win32.handle,
|
||||
MONITOR_DEFAULTTONEAREST);
|
||||
|
||||
// Adjust window rect to account for DPI scaling of the window frame and
|
||||
// (if enabled) DPI scaling of the content area
|
||||
// This cannot be done until we know what monitor the window was placed on
|
||||
// Only update the restored window rect as the window may be maximized
|
||||
|
||||
if (wndconfig->scaleToMonitor)
|
||||
{
|
||||
float xscale, yscale;
|
||||
_glfwPlatformGetWindowContentScale(window, &xscale, &yscale);
|
||||
rect.right = (int) (rect.right * xscale);
|
||||
rect.bottom = (int) (rect.bottom * yscale);
|
||||
_glfwGetHMONITORContentScaleWin32(mh, &xscale, &yscale);
|
||||
|
||||
if (xscale > 0.f && yscale > 0.f)
|
||||
{
|
||||
rect.right = (int) (rect.right * xscale);
|
||||
rect.bottom = (int) (rect.bottom * yscale);
|
||||
}
|
||||
}
|
||||
|
||||
ClientToScreen(window->win32.handle, (POINT*) &rect.left);
|
||||
ClientToScreen(window->win32.handle, (POINT*) &rect.right);
|
||||
|
||||
if (_glfwIsWindows10AnniversaryUpdateOrGreaterWin32())
|
||||
if (_glfwIsWindows10Version1607OrGreaterWin32())
|
||||
{
|
||||
AdjustWindowRectExForDpi(&rect, style, FALSE, exStyle,
|
||||
GetDpiForWindow(window->win32.handle));
|
||||
@ -1319,11 +1380,30 @@ static int createNativeWindow(_GLFWwindow* window,
|
||||
else
|
||||
AdjustWindowRectEx(&rect, style, FALSE, exStyle);
|
||||
|
||||
// Only update the restored window rect as the window may be maximized
|
||||
GetWindowPlacement(window->win32.handle, &wp);
|
||||
OffsetRect(&rect,
|
||||
wp.rcNormalPosition.left - rect.left,
|
||||
wp.rcNormalPosition.top - rect.top);
|
||||
|
||||
wp.rcNormalPosition = rect;
|
||||
wp.showCmd = SW_HIDE;
|
||||
SetWindowPlacement(window->win32.handle, &wp);
|
||||
|
||||
// Adjust rect of maximized undecorated window, because by default Windows will
|
||||
// make such a window cover the whole monitor instead of its workarea
|
||||
|
||||
if (wndconfig->maximized && !wndconfig->decorated)
|
||||
{
|
||||
MONITORINFO mi = { sizeof(mi) };
|
||||
GetMonitorInfoW(mh, &mi);
|
||||
|
||||
SetWindowPos(window->win32.handle, HWND_TOP,
|
||||
mi.rcWork.left,
|
||||
mi.rcWork.top,
|
||||
mi.rcWork.right - mi.rcWork.left,
|
||||
mi.rcWork.bottom - mi.rcWork.top,
|
||||
SWP_NOACTIVATE | SWP_NOZORDER);
|
||||
}
|
||||
}
|
||||
|
||||
DragAcceptFiles(window->win32.handle, TRUE);
|
||||
@ -1334,16 +1414,11 @@ static int createNativeWindow(_GLFWwindow* window,
|
||||
window->win32.transparent = GLFW_TRUE;
|
||||
}
|
||||
|
||||
_glfwPlatformGetWindowSize(window, &window->win32.width, &window->win32.height);
|
||||
_glfwGetWindowSizeWin32(window, &window->win32.width, &window->win32.height);
|
||||
|
||||
return GLFW_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
////// GLFW internal API //////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Registers the GLFW window class
|
||||
//
|
||||
GLFWbool _glfwRegisterWindowClassWin32(void)
|
||||
@ -1354,7 +1429,7 @@ GLFWbool _glfwRegisterWindowClassWin32(void)
|
||||
wc.cbSize = sizeof(wc);
|
||||
wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
|
||||
wc.lpfnWndProc = (WNDPROC) windowProc;
|
||||
wc.hInstance = GetModuleHandleW(NULL);
|
||||
wc.hInstance = _glfw.win32.instance;
|
||||
wc.hCursor = LoadCursorW(NULL, IDC_ARROW);
|
||||
wc.lpszClassName = _GLFW_WNDCLASSNAME;
|
||||
|
||||
@ -1384,18 +1459,13 @@ GLFWbool _glfwRegisterWindowClassWin32(void)
|
||||
//
|
||||
void _glfwUnregisterWindowClassWin32(void)
|
||||
{
|
||||
UnregisterClassW(_GLFW_WNDCLASSNAME, GetModuleHandleW(NULL));
|
||||
UnregisterClassW(_GLFW_WNDCLASSNAME, _glfw.win32.instance);
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
////// GLFW platform API //////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int _glfwPlatformCreateWindow(_GLFWwindow* window,
|
||||
const _GLFWwndconfig* wndconfig,
|
||||
const _GLFWctxconfig* ctxconfig,
|
||||
const _GLFWfbconfig* fbconfig)
|
||||
int _glfwCreateWindowWin32(_GLFWwindow* window,
|
||||
const _GLFWwndconfig* wndconfig,
|
||||
const _GLFWctxconfig* ctxconfig,
|
||||
const _GLFWfbconfig* fbconfig)
|
||||
{
|
||||
if (!createNativeWindow(window, wndconfig, fbconfig))
|
||||
return GLFW_FALSE;
|
||||
@ -1427,8 +1497,8 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
|
||||
|
||||
if (window->monitor)
|
||||
{
|
||||
_glfwPlatformShowWindow(window);
|
||||
_glfwPlatformFocusWindow(window);
|
||||
_glfwShowWindowWin32(window);
|
||||
_glfwFocusWindowWin32(window);
|
||||
acquireMonitor(window);
|
||||
fitToMonitor(window);
|
||||
}
|
||||
@ -1436,7 +1506,7 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
|
||||
return GLFW_TRUE;
|
||||
}
|
||||
|
||||
void _glfwPlatformDestroyWindow(_GLFWwindow* window)
|
||||
void _glfwDestroyWindowWin32(_GLFWwindow* window)
|
||||
{
|
||||
if (window->monitor)
|
||||
releaseMonitor(window);
|
||||
@ -1461,7 +1531,7 @@ void _glfwPlatformDestroyWindow(_GLFWwindow* window)
|
||||
DestroyIcon(window->win32.smallIcon);
|
||||
}
|
||||
|
||||
void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title)
|
||||
void _glfwSetWindowTitleWin32(_GLFWwindow* window, const char* title)
|
||||
{
|
||||
WCHAR* wideTitle = _glfwCreateWideStringFromUTF8Win32(title);
|
||||
if (!wideTitle)
|
||||
@ -1471,8 +1541,7 @@ void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title)
|
||||
_glfw_free(wideTitle);
|
||||
}
|
||||
|
||||
void _glfwPlatformSetWindowIcon(_GLFWwindow* window,
|
||||
int count, const GLFWimage* images)
|
||||
void _glfwSetWindowIconWin32(_GLFWwindow* window, int count, const GLFWimage* images)
|
||||
{
|
||||
HICON bigIcon = NULL, smallIcon = NULL;
|
||||
|
||||
@ -1494,8 +1563,8 @@ void _glfwPlatformSetWindowIcon(_GLFWwindow* window,
|
||||
smallIcon = (HICON) GetClassLongPtrW(window->win32.handle, GCLP_HICONSM);
|
||||
}
|
||||
|
||||
SendMessage(window->win32.handle, WM_SETICON, ICON_BIG, (LPARAM) bigIcon);
|
||||
SendMessage(window->win32.handle, WM_SETICON, ICON_SMALL, (LPARAM) smallIcon);
|
||||
SendMessageW(window->win32.handle, WM_SETICON, ICON_BIG, (LPARAM) bigIcon);
|
||||
SendMessageW(window->win32.handle, WM_SETICON, ICON_SMALL, (LPARAM) smallIcon);
|
||||
|
||||
if (window->win32.bigIcon)
|
||||
DestroyIcon(window->win32.bigIcon);
|
||||
@ -1510,7 +1579,7 @@ void _glfwPlatformSetWindowIcon(_GLFWwindow* window,
|
||||
}
|
||||
}
|
||||
|
||||
void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos)
|
||||
void _glfwGetWindowPosWin32(_GLFWwindow* window, int* xpos, int* ypos)
|
||||
{
|
||||
POINT pos = { 0, 0 };
|
||||
ClientToScreen(window->win32.handle, &pos);
|
||||
@ -1521,11 +1590,11 @@ void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos)
|
||||
*ypos = pos.y;
|
||||
}
|
||||
|
||||
void _glfwPlatformSetWindowPos(_GLFWwindow* window, int xpos, int ypos)
|
||||
void _glfwSetWindowPosWin32(_GLFWwindow* window, int xpos, int ypos)
|
||||
{
|
||||
RECT rect = { xpos, ypos, xpos, ypos };
|
||||
|
||||
if (_glfwIsWindows10AnniversaryUpdateOrGreaterWin32())
|
||||
if (_glfwIsWindows10Version1607OrGreaterWin32())
|
||||
{
|
||||
AdjustWindowRectExForDpi(&rect, getWindowStyle(window),
|
||||
FALSE, getWindowExStyle(window),
|
||||
@ -1541,7 +1610,7 @@ void _glfwPlatformSetWindowPos(_GLFWwindow* window, int xpos, int ypos)
|
||||
SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOSIZE);
|
||||
}
|
||||
|
||||
void _glfwPlatformGetWindowSize(_GLFWwindow* window, int* width, int* height)
|
||||
void _glfwGetWindowSizeWin32(_GLFWwindow* window, int* width, int* height)
|
||||
{
|
||||
RECT area;
|
||||
GetClientRect(window->win32.handle, &area);
|
||||
@ -1552,7 +1621,7 @@ void _glfwPlatformGetWindowSize(_GLFWwindow* window, int* width, int* height)
|
||||
*height = area.bottom;
|
||||
}
|
||||
|
||||
void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
|
||||
void _glfwSetWindowSizeWin32(_GLFWwindow* window, int width, int height)
|
||||
{
|
||||
if (window->monitor)
|
||||
{
|
||||
@ -1566,7 +1635,7 @@ void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
|
||||
{
|
||||
RECT rect = { 0, 0, width, height };
|
||||
|
||||
if (_glfwIsWindows10AnniversaryUpdateOrGreaterWin32())
|
||||
if (_glfwIsWindows10Version1607OrGreaterWin32())
|
||||
{
|
||||
AdjustWindowRectExForDpi(&rect, getWindowStyle(window),
|
||||
FALSE, getWindowExStyle(window),
|
||||
@ -1584,9 +1653,9 @@ void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
|
||||
}
|
||||
}
|
||||
|
||||
void _glfwPlatformSetWindowSizeLimits(_GLFWwindow* window,
|
||||
int minwidth, int minheight,
|
||||
int maxwidth, int maxheight)
|
||||
void _glfwSetWindowSizeLimitsWin32(_GLFWwindow* window,
|
||||
int minwidth, int minheight,
|
||||
int maxwidth, int maxheight)
|
||||
{
|
||||
RECT area;
|
||||
|
||||
@ -1603,7 +1672,7 @@ void _glfwPlatformSetWindowSizeLimits(_GLFWwindow* window,
|
||||
area.bottom - area.top, TRUE);
|
||||
}
|
||||
|
||||
void _glfwPlatformSetWindowAspectRatio(_GLFWwindow* window, int numer, int denom)
|
||||
void _glfwSetWindowAspectRatioWin32(_GLFWwindow* window, int numer, int denom)
|
||||
{
|
||||
RECT area;
|
||||
|
||||
@ -1618,22 +1687,22 @@ void _glfwPlatformSetWindowAspectRatio(_GLFWwindow* window, int numer, int denom
|
||||
area.bottom - area.top, TRUE);
|
||||
}
|
||||
|
||||
void _glfwPlatformGetFramebufferSize(_GLFWwindow* window, int* width, int* height)
|
||||
void _glfwGetFramebufferSizeWin32(_GLFWwindow* window, int* width, int* height)
|
||||
{
|
||||
_glfwPlatformGetWindowSize(window, width, height);
|
||||
_glfwGetWindowSizeWin32(window, width, height);
|
||||
}
|
||||
|
||||
void _glfwPlatformGetWindowFrameSize(_GLFWwindow* window,
|
||||
int* left, int* top,
|
||||
int* right, int* bottom)
|
||||
void _glfwGetWindowFrameSizeWin32(_GLFWwindow* window,
|
||||
int* left, int* top,
|
||||
int* right, int* bottom)
|
||||
{
|
||||
RECT rect;
|
||||
int width, height;
|
||||
|
||||
_glfwPlatformGetWindowSize(window, &width, &height);
|
||||
_glfwGetWindowSizeWin32(window, &width, &height);
|
||||
SetRect(&rect, 0, 0, width, height);
|
||||
|
||||
if (_glfwIsWindows10AnniversaryUpdateOrGreaterWin32())
|
||||
if (_glfwIsWindows10Version1607OrGreaterWin32())
|
||||
{
|
||||
AdjustWindowRectExForDpi(&rect, getWindowStyle(window),
|
||||
FALSE, getWindowExStyle(window),
|
||||
@ -1655,56 +1724,58 @@ void _glfwPlatformGetWindowFrameSize(_GLFWwindow* window,
|
||||
*bottom = rect.bottom - height;
|
||||
}
|
||||
|
||||
void _glfwPlatformGetWindowContentScale(_GLFWwindow* window,
|
||||
float* xscale, float* yscale)
|
||||
void _glfwGetWindowContentScaleWin32(_GLFWwindow* window, float* xscale, float* yscale)
|
||||
{
|
||||
const HANDLE handle = MonitorFromWindow(window->win32.handle,
|
||||
MONITOR_DEFAULTTONEAREST);
|
||||
_glfwGetMonitorContentScaleWin32(handle, xscale, yscale);
|
||||
_glfwGetHMONITORContentScaleWin32(handle, xscale, yscale);
|
||||
}
|
||||
|
||||
void _glfwPlatformIconifyWindow(_GLFWwindow* window)
|
||||
void _glfwIconifyWindowWin32(_GLFWwindow* window)
|
||||
{
|
||||
ShowWindow(window->win32.handle, SW_MINIMIZE);
|
||||
}
|
||||
|
||||
void _glfwPlatformRestoreWindow(_GLFWwindow* window)
|
||||
void _glfwRestoreWindowWin32(_GLFWwindow* window)
|
||||
{
|
||||
ShowWindow(window->win32.handle, SW_RESTORE);
|
||||
}
|
||||
|
||||
void _glfwPlatformMaximizeWindow(_GLFWwindow* window)
|
||||
void _glfwMaximizeWindowWin32(_GLFWwindow* window)
|
||||
{
|
||||
ShowWindow(window->win32.handle, SW_MAXIMIZE);
|
||||
if (IsWindowVisible(window->win32.handle))
|
||||
ShowWindow(window->win32.handle, SW_MAXIMIZE);
|
||||
else
|
||||
maximizeWindowManually(window);
|
||||
}
|
||||
|
||||
void _glfwPlatformShowWindow(_GLFWwindow* window)
|
||||
void _glfwShowWindowWin32(_GLFWwindow* window)
|
||||
{
|
||||
ShowWindow(window->win32.handle, SW_SHOWNA);
|
||||
}
|
||||
|
||||
void _glfwPlatformHideWindow(_GLFWwindow* window)
|
||||
void _glfwHideWindowWin32(_GLFWwindow* window)
|
||||
{
|
||||
ShowWindow(window->win32.handle, SW_HIDE);
|
||||
}
|
||||
|
||||
void _glfwPlatformRequestWindowAttention(_GLFWwindow* window)
|
||||
void _glfwRequestWindowAttentionWin32(_GLFWwindow* window)
|
||||
{
|
||||
FlashWindow(window->win32.handle, TRUE);
|
||||
}
|
||||
|
||||
void _glfwPlatformFocusWindow(_GLFWwindow* window)
|
||||
void _glfwFocusWindowWin32(_GLFWwindow* window)
|
||||
{
|
||||
BringWindowToTop(window->win32.handle);
|
||||
SetForegroundWindow(window->win32.handle);
|
||||
SetFocus(window->win32.handle);
|
||||
}
|
||||
|
||||
void _glfwPlatformSetWindowMonitor(_GLFWwindow* window,
|
||||
_GLFWmonitor* monitor,
|
||||
int xpos, int ypos,
|
||||
int width, int height,
|
||||
int refreshRate)
|
||||
void _glfwSetWindowMonitorWin32(_GLFWwindow* window,
|
||||
_GLFWmonitor* monitor,
|
||||
int xpos, int ypos,
|
||||
int width, int height,
|
||||
int refreshRate)
|
||||
{
|
||||
if (window->monitor == monitor)
|
||||
{
|
||||
@ -1720,7 +1791,7 @@ void _glfwPlatformSetWindowMonitor(_GLFWwindow* window,
|
||||
{
|
||||
RECT rect = { xpos, ypos, xpos + width, ypos + height };
|
||||
|
||||
if (_glfwIsWindows10AnniversaryUpdateOrGreaterWin32())
|
||||
if (_glfwIsWindows10Version1607OrGreaterWin32())
|
||||
{
|
||||
AdjustWindowRectExForDpi(&rect, getWindowStyle(window),
|
||||
FALSE, getWindowExStyle(window),
|
||||
@ -1762,7 +1833,7 @@ void _glfwPlatformSetWindowMonitor(_GLFWwindow* window,
|
||||
|
||||
acquireMonitor(window);
|
||||
|
||||
GetMonitorInfo(window->monitor->win32.handle, &mi);
|
||||
GetMonitorInfoW(window->monitor->win32.handle, &mi);
|
||||
SetWindowPos(window->win32.handle, HWND_TOPMOST,
|
||||
mi.rcMonitor.left,
|
||||
mi.rcMonitor.top,
|
||||
@ -1791,7 +1862,7 @@ void _glfwPlatformSetWindowMonitor(_GLFWwindow* window,
|
||||
else
|
||||
after = HWND_NOTOPMOST;
|
||||
|
||||
if (_glfwIsWindows10AnniversaryUpdateOrGreaterWin32())
|
||||
if (_glfwIsWindows10Version1607OrGreaterWin32())
|
||||
{
|
||||
AdjustWindowRectExForDpi(&rect, getWindowStyle(window),
|
||||
FALSE, getWindowExStyle(window),
|
||||
@ -1810,32 +1881,32 @@ void _glfwPlatformSetWindowMonitor(_GLFWwindow* window,
|
||||
}
|
||||
}
|
||||
|
||||
int _glfwPlatformWindowFocused(_GLFWwindow* window)
|
||||
int _glfwWindowFocusedWin32(_GLFWwindow* window)
|
||||
{
|
||||
return window->win32.handle == GetActiveWindow();
|
||||
}
|
||||
|
||||
int _glfwPlatformWindowIconified(_GLFWwindow* window)
|
||||
int _glfwWindowIconifiedWin32(_GLFWwindow* window)
|
||||
{
|
||||
return IsIconic(window->win32.handle);
|
||||
}
|
||||
|
||||
int _glfwPlatformWindowVisible(_GLFWwindow* window)
|
||||
int _glfwWindowVisibleWin32(_GLFWwindow* window)
|
||||
{
|
||||
return IsWindowVisible(window->win32.handle);
|
||||
}
|
||||
|
||||
int _glfwPlatformWindowMaximized(_GLFWwindow* window)
|
||||
int _glfwWindowMaximizedWin32(_GLFWwindow* window)
|
||||
{
|
||||
return IsZoomed(window->win32.handle);
|
||||
}
|
||||
|
||||
int _glfwPlatformWindowHovered(_GLFWwindow* window)
|
||||
int _glfwWindowHoveredWin32(_GLFWwindow* window)
|
||||
{
|
||||
return cursorInContentArea(window);
|
||||
}
|
||||
|
||||
int _glfwPlatformFramebufferTransparent(_GLFWwindow* window)
|
||||
int _glfwFramebufferTransparentWin32(_GLFWwindow* window)
|
||||
{
|
||||
BOOL composition, opaque;
|
||||
DWORD color;
|
||||
@ -1862,24 +1933,24 @@ int _glfwPlatformFramebufferTransparent(_GLFWwindow* window)
|
||||
return GLFW_TRUE;
|
||||
}
|
||||
|
||||
void _glfwPlatformSetWindowResizable(_GLFWwindow* window, GLFWbool enabled)
|
||||
void _glfwSetWindowResizableWin32(_GLFWwindow* window, GLFWbool enabled)
|
||||
{
|
||||
updateWindowStyles(window);
|
||||
}
|
||||
|
||||
void _glfwPlatformSetWindowDecorated(_GLFWwindow* window, GLFWbool enabled)
|
||||
void _glfwSetWindowDecoratedWin32(_GLFWwindow* window, GLFWbool enabled)
|
||||
{
|
||||
updateWindowStyles(window);
|
||||
}
|
||||
|
||||
void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled)
|
||||
void _glfwSetWindowFloatingWin32(_GLFWwindow* window, GLFWbool enabled)
|
||||
{
|
||||
const HWND after = enabled ? HWND_TOPMOST : HWND_NOTOPMOST;
|
||||
SetWindowPos(window->win32.handle, after, 0, 0, 0, 0,
|
||||
SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
|
||||
}
|
||||
|
||||
void _glfwPlatformSetWindowMousePassthrough(_GLFWwindow* window, GLFWbool enabled)
|
||||
void _glfwSetWindowMousePassthroughWin32(_GLFWwindow* window, GLFWbool enabled)
|
||||
{
|
||||
COLORREF key = 0;
|
||||
BYTE alpha = 0;
|
||||
@ -1909,7 +1980,7 @@ void _glfwPlatformSetWindowMousePassthrough(_GLFWwindow* window, GLFWbool enable
|
||||
SetLayeredWindowAttributes(window->win32.handle, key, alpha, flags);
|
||||
}
|
||||
|
||||
float _glfwPlatformGetWindowOpacity(_GLFWwindow* window)
|
||||
float _glfwGetWindowOpacityWin32(_GLFWwindow* window)
|
||||
{
|
||||
BYTE alpha;
|
||||
DWORD flags;
|
||||
@ -1924,7 +1995,7 @@ float _glfwPlatformGetWindowOpacity(_GLFWwindow* window)
|
||||
return 1.f;
|
||||
}
|
||||
|
||||
void _glfwPlatformSetWindowOpacity(_GLFWwindow* window, float opacity)
|
||||
void _glfwSetWindowOpacityWin32(_GLFWwindow* window, float opacity)
|
||||
{
|
||||
LONG exStyle = GetWindowLongW(window->win32.handle, GWL_EXSTYLE);
|
||||
if (opacity < 1.f || (exStyle & WS_EX_TRANSPARENT))
|
||||
@ -1945,7 +2016,7 @@ void _glfwPlatformSetWindowOpacity(_GLFWwindow* window, float opacity)
|
||||
}
|
||||
}
|
||||
|
||||
void _glfwPlatformSetRawMouseMotion(_GLFWwindow *window, GLFWbool enabled)
|
||||
void _glfwSetRawMouseMotionWin32(_GLFWwindow *window, GLFWbool enabled)
|
||||
{
|
||||
if (_glfw.win32.disabledCursorWindow != window)
|
||||
return;
|
||||
@ -1956,12 +2027,12 @@ void _glfwPlatformSetRawMouseMotion(_GLFWwindow *window, GLFWbool enabled)
|
||||
disableRawMouseMotion(window);
|
||||
}
|
||||
|
||||
GLFWbool _glfwPlatformRawMouseMotionSupported(void)
|
||||
GLFWbool _glfwRawMouseMotionSupportedWin32(void)
|
||||
{
|
||||
return GLFW_TRUE;
|
||||
}
|
||||
|
||||
void _glfwPlatformPollEvents(void)
|
||||
void _glfwPollEventsWin32(void)
|
||||
{
|
||||
MSG msg;
|
||||
HWND handle;
|
||||
@ -2031,38 +2102,38 @@ void _glfwPlatformPollEvents(void)
|
||||
if (window)
|
||||
{
|
||||
int width, height;
|
||||
_glfwPlatformGetWindowSize(window, &width, &height);
|
||||
_glfwGetWindowSizeWin32(window, &width, &height);
|
||||
|
||||
// NOTE: Re-center the cursor only if it has moved since the last call,
|
||||
// to avoid breaking glfwWaitEvents with WM_MOUSEMOVE
|
||||
if (window->win32.lastCursorPosX != width / 2 ||
|
||||
window->win32.lastCursorPosY != height / 2)
|
||||
{
|
||||
_glfwPlatformSetCursorPos(window, width / 2, height / 2);
|
||||
_glfwSetCursorPosWin32(window, width / 2, height / 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void _glfwPlatformWaitEvents(void)
|
||||
void _glfwWaitEventsWin32(void)
|
||||
{
|
||||
WaitMessage();
|
||||
|
||||
_glfwPlatformPollEvents();
|
||||
_glfwPollEventsWin32();
|
||||
}
|
||||
|
||||
void _glfwPlatformWaitEventsTimeout(double timeout)
|
||||
void _glfwWaitEventsTimeoutWin32(double timeout)
|
||||
{
|
||||
MsgWaitForMultipleObjects(0, NULL, FALSE, (DWORD) (timeout * 1e3), QS_ALLEVENTS);
|
||||
|
||||
_glfwPlatformPollEvents();
|
||||
_glfwPollEventsWin32();
|
||||
}
|
||||
|
||||
void _glfwPlatformPostEmptyEvent(void)
|
||||
void _glfwPostEmptyEventWin32(void)
|
||||
{
|
||||
PostMessage(_glfw.win32.helperWindowHandle, WM_NULL, 0, 0);
|
||||
PostMessageW(_glfw.win32.helperWindowHandle, WM_NULL, 0, 0);
|
||||
}
|
||||
|
||||
void _glfwPlatformGetCursorPos(_GLFWwindow* window, double* xpos, double* ypos)
|
||||
void _glfwGetCursorPosWin32(_GLFWwindow* window, double* xpos, double* ypos)
|
||||
{
|
||||
POINT pos;
|
||||
|
||||
@ -2077,7 +2148,7 @@ void _glfwPlatformGetCursorPos(_GLFWwindow* window, double* xpos, double* ypos)
|
||||
}
|
||||
}
|
||||
|
||||
void _glfwPlatformSetCursorPos(_GLFWwindow* window, double xpos, double ypos)
|
||||
void _glfwSetCursorPosWin32(_GLFWwindow* window, double xpos, double ypos)
|
||||
{
|
||||
POINT pos = { (int) xpos, (int) ypos };
|
||||
|
||||
@ -2089,11 +2160,11 @@ void _glfwPlatformSetCursorPos(_GLFWwindow* window, double xpos, double ypos)
|
||||
SetCursorPos(pos.x, pos.y);
|
||||
}
|
||||
|
||||
void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode)
|
||||
void _glfwSetCursorModeWin32(_GLFWwindow* window, int mode)
|
||||
{
|
||||
if (mode == GLFW_CURSOR_DISABLED)
|
||||
{
|
||||
if (_glfwPlatformWindowFocused(window))
|
||||
if (_glfwWindowFocusedWin32(window))
|
||||
disableCursor(window);
|
||||
}
|
||||
else if (_glfw.win32.disabledCursorWindow == window)
|
||||
@ -2102,7 +2173,7 @@ void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode)
|
||||
updateCursorImage(window);
|
||||
}
|
||||
|
||||
const char* _glfwPlatformGetScancodeName(int scancode)
|
||||
const char* _glfwGetScancodeNameWin32(int scancode)
|
||||
{
|
||||
if (scancode < 0 || scancode > (KF_EXTENDED | 0xff) ||
|
||||
_glfw.win32.keycodes[scancode] == GLFW_KEY_UNKNOWN)
|
||||
@ -2114,14 +2185,14 @@ const char* _glfwPlatformGetScancodeName(int scancode)
|
||||
return _glfw.win32.keynames[_glfw.win32.keycodes[scancode]];
|
||||
}
|
||||
|
||||
int _glfwPlatformGetKeyScancode(int key)
|
||||
int _glfwGetKeyScancodeWin32(int key)
|
||||
{
|
||||
return _glfw.win32.scancodes[key];
|
||||
}
|
||||
|
||||
int _glfwPlatformCreateCursor(_GLFWcursor* cursor,
|
||||
const GLFWimage* image,
|
||||
int xhot, int yhot)
|
||||
int _glfwCreateCursorWin32(_GLFWcursor* cursor,
|
||||
const GLFWimage* image,
|
||||
int xhot, int yhot)
|
||||
{
|
||||
cursor->win32.handle = (HCURSOR) createIcon(image, xhot, yhot, GLFW_FALSE);
|
||||
if (!cursor->win32.handle)
|
||||
@ -2130,7 +2201,7 @@ int _glfwPlatformCreateCursor(_GLFWcursor* cursor,
|
||||
return GLFW_TRUE;
|
||||
}
|
||||
|
||||
int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape)
|
||||
int _glfwCreateStandardCursorWin32(_GLFWcursor* cursor, int shape)
|
||||
{
|
||||
int id = 0;
|
||||
|
||||
@ -2184,19 +2255,19 @@ int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape)
|
||||
return GLFW_TRUE;
|
||||
}
|
||||
|
||||
void _glfwPlatformDestroyCursor(_GLFWcursor* cursor)
|
||||
void _glfwDestroyCursorWin32(_GLFWcursor* cursor)
|
||||
{
|
||||
if (cursor->win32.handle)
|
||||
DestroyIcon((HICON) cursor->win32.handle);
|
||||
}
|
||||
|
||||
void _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor)
|
||||
void _glfwSetCursorWin32(_GLFWwindow* window, _GLFWcursor* cursor)
|
||||
{
|
||||
if (cursorInContentArea(window))
|
||||
updateCursorImage(window);
|
||||
}
|
||||
|
||||
void _glfwPlatformSetClipboardString(const char* string)
|
||||
void _glfwSetClipboardStringWin32(const char* string)
|
||||
{
|
||||
int characterCount;
|
||||
HANDLE object;
|
||||
@ -2239,7 +2310,7 @@ void _glfwPlatformSetClipboardString(const char* string)
|
||||
CloseClipboard();
|
||||
}
|
||||
|
||||
const char* _glfwPlatformGetClipboardString(void)
|
||||
const char* _glfwGetClipboardStringWin32(void)
|
||||
{
|
||||
HANDLE object;
|
||||
WCHAR* buffer;
|
||||
@ -2278,7 +2349,7 @@ const char* _glfwPlatformGetClipboardString(void)
|
||||
return _glfw.win32.clipboardString;
|
||||
}
|
||||
|
||||
EGLenum _glfwPlatformGetEGLPlatform(EGLint** attribs)
|
||||
EGLenum _glfwGetEGLPlatformWin32(EGLint** attribs)
|
||||
{
|
||||
if (_glfw.egl.ANGLE_platform_angle)
|
||||
{
|
||||
@ -2319,17 +2390,17 @@ EGLenum _glfwPlatformGetEGLPlatform(EGLint** attribs)
|
||||
return 0;
|
||||
}
|
||||
|
||||
EGLNativeDisplayType _glfwPlatformGetEGLNativeDisplay(void)
|
||||
EGLNativeDisplayType _glfwGetEGLNativeDisplayWin32(void)
|
||||
{
|
||||
return GetDC(_glfw.win32.helperWindowHandle);
|
||||
}
|
||||
|
||||
EGLNativeWindowType _glfwPlatformGetEGLNativeWindow(_GLFWwindow* window)
|
||||
EGLNativeWindowType _glfwGetEGLNativeWindowWin32(_GLFWwindow* window)
|
||||
{
|
||||
return window->win32.handle;
|
||||
}
|
||||
|
||||
void _glfwPlatformGetRequiredInstanceExtensions(char** extensions)
|
||||
void _glfwGetRequiredInstanceExtensionsWin32(char** extensions)
|
||||
{
|
||||
if (!_glfw.vk.KHR_surface || !_glfw.vk.KHR_win32_surface)
|
||||
return;
|
||||
@ -2338,9 +2409,9 @@ void _glfwPlatformGetRequiredInstanceExtensions(char** extensions)
|
||||
extensions[1] = "VK_KHR_win32_surface";
|
||||
}
|
||||
|
||||
int _glfwPlatformGetPhysicalDevicePresentationSupport(VkInstance instance,
|
||||
VkPhysicalDevice device,
|
||||
uint32_t queuefamily)
|
||||
int _glfwGetPhysicalDevicePresentationSupportWin32(VkInstance instance,
|
||||
VkPhysicalDevice device,
|
||||
uint32_t queuefamily)
|
||||
{
|
||||
PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR
|
||||
vkGetPhysicalDeviceWin32PresentationSupportKHR =
|
||||
@ -2356,10 +2427,10 @@ int _glfwPlatformGetPhysicalDevicePresentationSupport(VkInstance instance,
|
||||
return vkGetPhysicalDeviceWin32PresentationSupportKHR(device, queuefamily);
|
||||
}
|
||||
|
||||
VkResult _glfwPlatformCreateWindowSurface(VkInstance instance,
|
||||
_GLFWwindow* window,
|
||||
const VkAllocationCallbacks* allocator,
|
||||
VkSurfaceKHR* surface)
|
||||
VkResult _glfwCreateWindowSurfaceWin32(VkInstance instance,
|
||||
_GLFWwindow* window,
|
||||
const VkAllocationCallbacks* allocator,
|
||||
VkSurfaceKHR* surface)
|
||||
{
|
||||
VkResult err;
|
||||
VkWin32SurfaceCreateInfoKHR sci;
|
||||
@ -2376,7 +2447,7 @@ VkResult _glfwPlatformCreateWindowSurface(VkInstance instance,
|
||||
|
||||
memset(&sci, 0, sizeof(sci));
|
||||
sci.sType = VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR;
|
||||
sci.hinstance = GetModuleHandle(NULL);
|
||||
sci.hinstance = _glfw.win32.instance;
|
||||
sci.hwnd = window->win32.handle;
|
||||
|
||||
err = vkCreateWin32SurfaceKHR(instance, &sci, allocator, surface);
|
||||
@ -2390,7 +2461,7 @@ VkResult _glfwPlatformCreateWindowSurface(VkInstance instance,
|
||||
return err;
|
||||
}
|
||||
|
||||
_GLFWusercontext* _glfwPlatformCreateUserContext(_GLFWwindow* window)
|
||||
_GLFWusercontext* _glfwCreateUserContextWin32(_GLFWwindow* window)
|
||||
{
|
||||
if (window->context.wgl.handle)
|
||||
{
|
||||
@ -2416,6 +2487,14 @@ GLFWAPI HWND glfwGetWin32Window(GLFWwindow* handle)
|
||||
{
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||
|
||||
if (_glfw.platform.platformID != GLFW_PLATFORM_WIN32)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_UNAVAILABLE,
|
||||
"Win32: Platform not initialized");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return window->win32.handle;
|
||||
}
|
||||
|
||||
|
183
src/window.c
183
src/window.c
@ -55,7 +55,7 @@ void _glfwInputWindowFocus(_GLFWwindow* window, GLFWbool focused)
|
||||
{
|
||||
if (window->keys[key] == GLFW_PRESS)
|
||||
{
|
||||
const int scancode = _glfwPlatformGetKeyScancode(key);
|
||||
const int scancode = _glfw.platform.getKeyScancode(key);
|
||||
_glfwInputKey(window, key, scancode, GLFW_RELEASE, 0);
|
||||
}
|
||||
}
|
||||
@ -216,7 +216,7 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height,
|
||||
window->denom = GLFW_DONT_CARE;
|
||||
|
||||
// Open the actual window and create its context
|
||||
if (!_glfwPlatformCreateWindow(window, &wndconfig, &ctxconfig, &fbconfig))
|
||||
if (!_glfw.platform.createWindow(window, &wndconfig, &ctxconfig, &fbconfig))
|
||||
{
|
||||
glfwDestroyWindow((GLFWwindow*) window);
|
||||
return NULL;
|
||||
@ -232,7 +232,7 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height,
|
||||
}
|
||||
|
||||
if (wndconfig.mousePassthrough)
|
||||
_glfwPlatformSetWindowMousePassthrough(window, GLFW_TRUE);
|
||||
_glfw.platform.setWindowMousePassthrough(window, GLFW_TRUE);
|
||||
|
||||
if (window->monitor)
|
||||
{
|
||||
@ -243,9 +243,9 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height,
|
||||
{
|
||||
if (wndconfig.visible)
|
||||
{
|
||||
_glfwPlatformShowWindow(window);
|
||||
_glfw.platform.showWindow(window);
|
||||
if (wndconfig.focused)
|
||||
_glfwPlatformFocusWindow(window);
|
||||
_glfw.platform.focusWindow(window);
|
||||
}
|
||||
}
|
||||
|
||||
@ -468,7 +468,7 @@ GLFWAPI void glfwDestroyWindow(GLFWwindow* handle)
|
||||
if (window == _glfwPlatformGetTls(&_glfw.contextSlot))
|
||||
glfwMakeContextCurrent(NULL);
|
||||
|
||||
_glfwPlatformDestroyWindow(window);
|
||||
_glfw.platform.destroyWindow(window);
|
||||
|
||||
// Unlink window from global linked list
|
||||
{
|
||||
@ -508,19 +508,40 @@ GLFWAPI void glfwSetWindowTitle(GLFWwindow* handle, const char* title)
|
||||
assert(title != NULL);
|
||||
|
||||
_GLFW_REQUIRE_INIT();
|
||||
_glfwPlatformSetWindowTitle(window, title);
|
||||
_glfw.platform.setWindowTitle(window, title);
|
||||
}
|
||||
|
||||
GLFWAPI void glfwSetWindowIcon(GLFWwindow* handle,
|
||||
int count, const GLFWimage* images)
|
||||
{
|
||||
int i;
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
|
||||
assert(window != NULL);
|
||||
assert(count >= 0);
|
||||
assert(count == 0 || images != NULL);
|
||||
|
||||
_GLFW_REQUIRE_INIT();
|
||||
_glfwPlatformSetWindowIcon(window, count, images);
|
||||
|
||||
if (count < 0)
|
||||
{
|
||||
_glfwInputError(GLFW_INVALID_VALUE, "Invalid image count for window icon");
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
assert(images[i].pixels != NULL);
|
||||
|
||||
if (images[i].width <= 0 || images[i].height <= 0)
|
||||
{
|
||||
_glfwInputError(GLFW_INVALID_VALUE,
|
||||
"Invalid image dimensions for window icon");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
_glfw.platform.setWindowIcon(window, count, images);
|
||||
}
|
||||
|
||||
GLFWAPI void glfwGetWindowPos(GLFWwindow* handle, int* xpos, int* ypos)
|
||||
@ -534,7 +555,7 @@ GLFWAPI void glfwGetWindowPos(GLFWwindow* handle, int* xpos, int* ypos)
|
||||
*ypos = 0;
|
||||
|
||||
_GLFW_REQUIRE_INIT();
|
||||
_glfwPlatformGetWindowPos(window, xpos, ypos);
|
||||
_glfw.platform.getWindowPos(window, xpos, ypos);
|
||||
}
|
||||
|
||||
GLFWAPI void glfwSetWindowPos(GLFWwindow* handle, int xpos, int ypos)
|
||||
@ -547,7 +568,7 @@ GLFWAPI void glfwSetWindowPos(GLFWwindow* handle, int xpos, int ypos)
|
||||
if (window->monitor)
|
||||
return;
|
||||
|
||||
_glfwPlatformSetWindowPos(window, xpos, ypos);
|
||||
_glfw.platform.setWindowPos(window, xpos, ypos);
|
||||
}
|
||||
|
||||
GLFWAPI void glfwGetWindowSize(GLFWwindow* handle, int* width, int* height)
|
||||
@ -561,7 +582,7 @@ GLFWAPI void glfwGetWindowSize(GLFWwindow* handle, int* width, int* height)
|
||||
*height = 0;
|
||||
|
||||
_GLFW_REQUIRE_INIT();
|
||||
_glfwPlatformGetWindowSize(window, width, height);
|
||||
_glfw.platform.getWindowSize(window, width, height);
|
||||
}
|
||||
|
||||
GLFWAPI void glfwSetWindowSize(GLFWwindow* handle, int width, int height)
|
||||
@ -576,7 +597,7 @@ GLFWAPI void glfwSetWindowSize(GLFWwindow* handle, int width, int height)
|
||||
window->videoMode.width = width;
|
||||
window->videoMode.height = height;
|
||||
|
||||
_glfwPlatformSetWindowSize(window, width, height);
|
||||
_glfw.platform.setWindowSize(window, width, height);
|
||||
}
|
||||
|
||||
GLFWAPI void glfwSetWindowSizeLimits(GLFWwindow* handle,
|
||||
@ -619,9 +640,9 @@ GLFWAPI void glfwSetWindowSizeLimits(GLFWwindow* handle,
|
||||
if (window->monitor || !window->resizable)
|
||||
return;
|
||||
|
||||
_glfwPlatformSetWindowSizeLimits(window,
|
||||
minwidth, minheight,
|
||||
maxwidth, maxheight);
|
||||
_glfw.platform.setWindowSizeLimits(window,
|
||||
minwidth, minheight,
|
||||
maxwidth, maxheight);
|
||||
}
|
||||
|
||||
GLFWAPI void glfwSetWindowAspectRatio(GLFWwindow* handle, int numer, int denom)
|
||||
@ -650,7 +671,7 @@ GLFWAPI void glfwSetWindowAspectRatio(GLFWwindow* handle, int numer, int denom)
|
||||
if (window->monitor || !window->resizable)
|
||||
return;
|
||||
|
||||
_glfwPlatformSetWindowAspectRatio(window, numer, denom);
|
||||
_glfw.platform.setWindowAspectRatio(window, numer, denom);
|
||||
}
|
||||
|
||||
GLFWAPI void glfwGetFramebufferSize(GLFWwindow* handle, int* width, int* height)
|
||||
@ -664,7 +685,7 @@ GLFWAPI void glfwGetFramebufferSize(GLFWwindow* handle, int* width, int* height)
|
||||
*height = 0;
|
||||
|
||||
_GLFW_REQUIRE_INIT();
|
||||
_glfwPlatformGetFramebufferSize(window, width, height);
|
||||
_glfw.platform.getFramebufferSize(window, width, height);
|
||||
}
|
||||
|
||||
GLFWAPI void glfwGetWindowFrameSize(GLFWwindow* handle,
|
||||
@ -684,7 +705,7 @@ GLFWAPI void glfwGetWindowFrameSize(GLFWwindow* handle,
|
||||
*bottom = 0;
|
||||
|
||||
_GLFW_REQUIRE_INIT();
|
||||
_glfwPlatformGetWindowFrameSize(window, left, top, right, bottom);
|
||||
_glfw.platform.getWindowFrameSize(window, left, top, right, bottom);
|
||||
}
|
||||
|
||||
GLFWAPI void glfwGetWindowContentScale(GLFWwindow* handle,
|
||||
@ -699,7 +720,7 @@ GLFWAPI void glfwGetWindowContentScale(GLFWwindow* handle,
|
||||
*yscale = 0.f;
|
||||
|
||||
_GLFW_REQUIRE_INIT();
|
||||
_glfwPlatformGetWindowContentScale(window, xscale, yscale);
|
||||
_glfw.platform.getWindowContentScale(window, xscale, yscale);
|
||||
}
|
||||
|
||||
GLFWAPI float glfwGetWindowOpacity(GLFWwindow* handle)
|
||||
@ -708,7 +729,7 @@ GLFWAPI float glfwGetWindowOpacity(GLFWwindow* handle)
|
||||
assert(window != NULL);
|
||||
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(1.f);
|
||||
return _glfwPlatformGetWindowOpacity(window);
|
||||
return _glfw.platform.getWindowOpacity(window);
|
||||
}
|
||||
|
||||
GLFWAPI void glfwSetWindowOpacity(GLFWwindow* handle, float opacity)
|
||||
@ -727,7 +748,7 @@ GLFWAPI void glfwSetWindowOpacity(GLFWwindow* handle, float opacity)
|
||||
return;
|
||||
}
|
||||
|
||||
_glfwPlatformSetWindowOpacity(window, opacity);
|
||||
_glfw.platform.setWindowOpacity(window, opacity);
|
||||
}
|
||||
|
||||
GLFWAPI void glfwIconifyWindow(GLFWwindow* handle)
|
||||
@ -736,7 +757,7 @@ GLFWAPI void glfwIconifyWindow(GLFWwindow* handle)
|
||||
assert(window != NULL);
|
||||
|
||||
_GLFW_REQUIRE_INIT();
|
||||
_glfwPlatformIconifyWindow(window);
|
||||
_glfw.platform.iconifyWindow(window);
|
||||
}
|
||||
|
||||
GLFWAPI void glfwRestoreWindow(GLFWwindow* handle)
|
||||
@ -745,7 +766,7 @@ GLFWAPI void glfwRestoreWindow(GLFWwindow* handle)
|
||||
assert(window != NULL);
|
||||
|
||||
_GLFW_REQUIRE_INIT();
|
||||
_glfwPlatformRestoreWindow(window);
|
||||
_glfw.platform.restoreWindow(window);
|
||||
}
|
||||
|
||||
GLFWAPI void glfwMaximizeWindow(GLFWwindow* handle)
|
||||
@ -758,7 +779,7 @@ GLFWAPI void glfwMaximizeWindow(GLFWwindow* handle)
|
||||
if (window->monitor)
|
||||
return;
|
||||
|
||||
_glfwPlatformMaximizeWindow(window);
|
||||
_glfw.platform.maximizeWindow(window);
|
||||
}
|
||||
|
||||
GLFWAPI void glfwShowWindow(GLFWwindow* handle)
|
||||
@ -771,10 +792,10 @@ GLFWAPI void glfwShowWindow(GLFWwindow* handle)
|
||||
if (window->monitor)
|
||||
return;
|
||||
|
||||
_glfwPlatformShowWindow(window);
|
||||
_glfw.platform.showWindow(window);
|
||||
|
||||
if (window->focusOnShow)
|
||||
_glfwPlatformFocusWindow(window);
|
||||
_glfw.platform.focusWindow(window);
|
||||
}
|
||||
|
||||
GLFWAPI void glfwRequestWindowAttention(GLFWwindow* handle)
|
||||
@ -784,7 +805,7 @@ GLFWAPI void glfwRequestWindowAttention(GLFWwindow* handle)
|
||||
|
||||
_GLFW_REQUIRE_INIT();
|
||||
|
||||
_glfwPlatformRequestWindowAttention(window);
|
||||
_glfw.platform.requestWindowAttention(window);
|
||||
}
|
||||
|
||||
GLFWAPI void glfwHideWindow(GLFWwindow* handle)
|
||||
@ -797,7 +818,7 @@ GLFWAPI void glfwHideWindow(GLFWwindow* handle)
|
||||
if (window->monitor)
|
||||
return;
|
||||
|
||||
_glfwPlatformHideWindow(window);
|
||||
_glfw.platform.hideWindow(window);
|
||||
}
|
||||
|
||||
GLFWAPI void glfwFocusWindow(GLFWwindow* handle)
|
||||
@ -807,7 +828,7 @@ GLFWAPI void glfwFocusWindow(GLFWwindow* handle)
|
||||
|
||||
_GLFW_REQUIRE_INIT();
|
||||
|
||||
_glfwPlatformFocusWindow(window);
|
||||
_glfw.platform.focusWindow(window);
|
||||
}
|
||||
|
||||
GLFWAPI int glfwGetWindowAttrib(GLFWwindow* handle, int attrib)
|
||||
@ -820,21 +841,21 @@ GLFWAPI int glfwGetWindowAttrib(GLFWwindow* handle, int attrib)
|
||||
switch (attrib)
|
||||
{
|
||||
case GLFW_FOCUSED:
|
||||
return _glfwPlatformWindowFocused(window);
|
||||
return _glfw.platform.windowFocused(window);
|
||||
case GLFW_ICONIFIED:
|
||||
return _glfwPlatformWindowIconified(window);
|
||||
return _glfw.platform.windowIconified(window);
|
||||
case GLFW_VISIBLE:
|
||||
return _glfwPlatformWindowVisible(window);
|
||||
return _glfw.platform.windowVisible(window);
|
||||
case GLFW_MAXIMIZED:
|
||||
return _glfwPlatformWindowMaximized(window);
|
||||
return _glfw.platform.windowMaximized(window);
|
||||
case GLFW_HOVERED:
|
||||
return _glfwPlatformWindowHovered(window);
|
||||
return _glfw.platform.windowHovered(window);
|
||||
case GLFW_FOCUS_ON_SHOW:
|
||||
return window->focusOnShow;
|
||||
case GLFW_MOUSE_PASSTHROUGH:
|
||||
return window->mousePassthrough;
|
||||
case GLFW_TRANSPARENT_FRAMEBUFFER:
|
||||
return _glfwPlatformFramebufferTransparent(window);
|
||||
return _glfw.platform.framebufferTransparent(window);
|
||||
case GLFW_RESIZABLE:
|
||||
return window->resizable;
|
||||
case GLFW_DECORATED:
|
||||
@ -882,35 +903,41 @@ GLFWAPI void glfwSetWindowAttrib(GLFWwindow* handle, int attrib, int value)
|
||||
|
||||
value = value ? GLFW_TRUE : GLFW_FALSE;
|
||||
|
||||
if (attrib == GLFW_AUTO_ICONIFY)
|
||||
window->autoIconify = value;
|
||||
else if (attrib == GLFW_RESIZABLE)
|
||||
switch (attrib)
|
||||
{
|
||||
window->resizable = value;
|
||||
if (!window->monitor)
|
||||
_glfwPlatformSetWindowResizable(window, value);
|
||||
case GLFW_AUTO_ICONIFY:
|
||||
window->autoIconify = value;
|
||||
return;
|
||||
|
||||
case GLFW_RESIZABLE:
|
||||
window->resizable = value;
|
||||
if (!window->monitor)
|
||||
_glfw.platform.setWindowResizable(window, value);
|
||||
return;
|
||||
|
||||
case GLFW_DECORATED:
|
||||
window->decorated = value;
|
||||
if (!window->monitor)
|
||||
_glfw.platform.setWindowDecorated(window, value);
|
||||
return;
|
||||
|
||||
case GLFW_FLOATING:
|
||||
window->floating = value;
|
||||
if (!window->monitor)
|
||||
_glfw.platform.setWindowFloating(window, value);
|
||||
return;
|
||||
|
||||
case GLFW_FOCUS_ON_SHOW:
|
||||
window->focusOnShow = value;
|
||||
return;
|
||||
|
||||
case GLFW_MOUSE_PASSTHROUGH:
|
||||
window->mousePassthrough = value;
|
||||
_glfw.platform.setWindowMousePassthrough(window, value);
|
||||
return;
|
||||
}
|
||||
else if (attrib == GLFW_DECORATED)
|
||||
{
|
||||
window->decorated = value;
|
||||
if (!window->monitor)
|
||||
_glfwPlatformSetWindowDecorated(window, value);
|
||||
}
|
||||
else if (attrib == GLFW_FLOATING)
|
||||
{
|
||||
window->floating = value;
|
||||
if (!window->monitor)
|
||||
_glfwPlatformSetWindowFloating(window, value);
|
||||
}
|
||||
else if (attrib == GLFW_FOCUS_ON_SHOW)
|
||||
window->focusOnShow = value;
|
||||
else if (attrib == GLFW_MOUSE_PASSTHROUGH)
|
||||
{
|
||||
window->mousePassthrough = value;
|
||||
_glfwPlatformSetWindowMousePassthrough(window, value);
|
||||
}
|
||||
else
|
||||
_glfwInputError(GLFW_INVALID_ENUM, "Invalid window attribute 0x%08X", attrib);
|
||||
|
||||
_glfwInputError(GLFW_INVALID_ENUM, "Invalid window attribute 0x%08X", attrib);
|
||||
}
|
||||
|
||||
GLFWAPI GLFWmonitor* glfwGetWindowMonitor(GLFWwindow* handle)
|
||||
@ -956,9 +983,9 @@ GLFWAPI void glfwSetWindowMonitor(GLFWwindow* wh,
|
||||
window->videoMode.height = height;
|
||||
window->videoMode.refreshRate = refreshRate;
|
||||
|
||||
_glfwPlatformSetWindowMonitor(window, monitor,
|
||||
xpos, ypos, width, height,
|
||||
refreshRate);
|
||||
_glfw.platform.setWindowMonitor(window, monitor,
|
||||
xpos, ypos, width, height,
|
||||
refreshRate);
|
||||
}
|
||||
|
||||
GLFWAPI void glfwSetWindowUserPointer(GLFWwindow* handle, void* pointer)
|
||||
@ -986,7 +1013,7 @@ GLFWAPI GLFWwindowposfun glfwSetWindowPosCallback(GLFWwindow* handle,
|
||||
assert(window != NULL);
|
||||
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||
_GLFW_SWAP_POINTERS(window->callbacks.pos, cbfun);
|
||||
_GLFW_SWAP(GLFWwindowposfun, window->callbacks.pos, cbfun);
|
||||
return cbfun;
|
||||
}
|
||||
|
||||
@ -997,7 +1024,7 @@ GLFWAPI GLFWwindowsizefun glfwSetWindowSizeCallback(GLFWwindow* handle,
|
||||
assert(window != NULL);
|
||||
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||
_GLFW_SWAP_POINTERS(window->callbacks.size, cbfun);
|
||||
_GLFW_SWAP(GLFWwindowsizefun, window->callbacks.size, cbfun);
|
||||
return cbfun;
|
||||
}
|
||||
|
||||
@ -1008,7 +1035,7 @@ GLFWAPI GLFWwindowclosefun glfwSetWindowCloseCallback(GLFWwindow* handle,
|
||||
assert(window != NULL);
|
||||
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||
_GLFW_SWAP_POINTERS(window->callbacks.close, cbfun);
|
||||
_GLFW_SWAP(GLFWwindowclosefun, window->callbacks.close, cbfun);
|
||||
return cbfun;
|
||||
}
|
||||
|
||||
@ -1019,7 +1046,7 @@ GLFWAPI GLFWwindowrefreshfun glfwSetWindowRefreshCallback(GLFWwindow* handle,
|
||||
assert(window != NULL);
|
||||
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||
_GLFW_SWAP_POINTERS(window->callbacks.refresh, cbfun);
|
||||
_GLFW_SWAP(GLFWwindowrefreshfun, window->callbacks.refresh, cbfun);
|
||||
return cbfun;
|
||||
}
|
||||
|
||||
@ -1030,7 +1057,7 @@ GLFWAPI GLFWwindowfocusfun glfwSetWindowFocusCallback(GLFWwindow* handle,
|
||||
assert(window != NULL);
|
||||
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||
_GLFW_SWAP_POINTERS(window->callbacks.focus, cbfun);
|
||||
_GLFW_SWAP(GLFWwindowfocusfun, window->callbacks.focus, cbfun);
|
||||
return cbfun;
|
||||
}
|
||||
|
||||
@ -1041,7 +1068,7 @@ GLFWAPI GLFWwindowiconifyfun glfwSetWindowIconifyCallback(GLFWwindow* handle,
|
||||
assert(window != NULL);
|
||||
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||
_GLFW_SWAP_POINTERS(window->callbacks.iconify, cbfun);
|
||||
_GLFW_SWAP(GLFWwindowiconifyfun, window->callbacks.iconify, cbfun);
|
||||
return cbfun;
|
||||
}
|
||||
|
||||
@ -1052,7 +1079,7 @@ GLFWAPI GLFWwindowmaximizefun glfwSetWindowMaximizeCallback(GLFWwindow* handle,
|
||||
assert(window != NULL);
|
||||
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||
_GLFW_SWAP_POINTERS(window->callbacks.maximize, cbfun);
|
||||
_GLFW_SWAP(GLFWwindowmaximizefun, window->callbacks.maximize, cbfun);
|
||||
return cbfun;
|
||||
}
|
||||
|
||||
@ -1063,7 +1090,7 @@ GLFWAPI GLFWframebuffersizefun glfwSetFramebufferSizeCallback(GLFWwindow* handle
|
||||
assert(window != NULL);
|
||||
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||
_GLFW_SWAP_POINTERS(window->callbacks.fbsize, cbfun);
|
||||
_GLFW_SWAP(GLFWframebuffersizefun, window->callbacks.fbsize, cbfun);
|
||||
return cbfun;
|
||||
}
|
||||
|
||||
@ -1074,20 +1101,20 @@ GLFWAPI GLFWwindowcontentscalefun glfwSetWindowContentScaleCallback(GLFWwindow*
|
||||
assert(window != NULL);
|
||||
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||
_GLFW_SWAP_POINTERS(window->callbacks.scale, cbfun);
|
||||
_GLFW_SWAP(GLFWwindowcontentscalefun, window->callbacks.scale, cbfun);
|
||||
return cbfun;
|
||||
}
|
||||
|
||||
GLFWAPI void glfwPollEvents(void)
|
||||
{
|
||||
_GLFW_REQUIRE_INIT();
|
||||
_glfwPlatformPollEvents();
|
||||
_glfw.platform.pollEvents();
|
||||
}
|
||||
|
||||
GLFWAPI void glfwWaitEvents(void)
|
||||
{
|
||||
_GLFW_REQUIRE_INIT();
|
||||
_glfwPlatformWaitEvents();
|
||||
_glfw.platform.waitEvents();
|
||||
}
|
||||
|
||||
GLFWAPI void glfwWaitEventsTimeout(double timeout)
|
||||
@ -1103,12 +1130,12 @@ GLFWAPI void glfwWaitEventsTimeout(double timeout)
|
||||
return;
|
||||
}
|
||||
|
||||
_glfwPlatformWaitEventsTimeout(timeout);
|
||||
_glfw.platform.waitEventsTimeout(timeout);
|
||||
}
|
||||
|
||||
GLFWAPI void glfwPostEmptyEvent(void)
|
||||
{
|
||||
_GLFW_REQUIRE_INIT();
|
||||
_glfwPlatformPostEmptyEvent();
|
||||
_glfw.platform.postEmptyEvent();
|
||||
}
|
||||
|
||||
|
421
src/wl_init.c
421
src/wl_init.c
@ -57,11 +57,6 @@
|
||||
#include "wayland-idle-inhibit-unstable-v1-client-protocol-code.h"
|
||||
|
||||
|
||||
static inline int min(int n1, int n2)
|
||||
{
|
||||
return n1 < n2 ? n1 : n2;
|
||||
}
|
||||
|
||||
static _GLFWwindow* findWindowFromDecorationSurface(struct wl_surface* surface,
|
||||
int* which)
|
||||
{
|
||||
@ -123,7 +118,7 @@ static void pointerHandleEnter(void* data,
|
||||
|
||||
window->wl.hovered = GLFW_TRUE;
|
||||
|
||||
_glfwPlatformSetCursor(window, window->wl.currentCursor);
|
||||
_glfwSetCursorWayland(window, window->wl.currentCursor);
|
||||
_glfwInputCursorEnter(window, GLFW_TRUE);
|
||||
}
|
||||
|
||||
@ -207,12 +202,12 @@ static void pointerHandleMotion(void* data,
|
||||
return;
|
||||
x = wl_fixed_to_double(sx);
|
||||
y = wl_fixed_to_double(sy);
|
||||
window->wl.cursorPosX = x;
|
||||
window->wl.cursorPosY = y;
|
||||
|
||||
switch (window->wl.decorations.focus)
|
||||
{
|
||||
case mainWindow:
|
||||
window->wl.cursorPosX = x;
|
||||
window->wl.cursorPosY = y;
|
||||
_glfwInputCursorPos(window, x, y);
|
||||
_glfw.wl.cursorPreviousName = NULL;
|
||||
return;
|
||||
@ -272,9 +267,7 @@ static void pointerHandleButton(void* data,
|
||||
if (window->wl.cursorPosY < _GLFW_DECORATION_WIDTH)
|
||||
edges = XDG_TOPLEVEL_RESIZE_EDGE_TOP;
|
||||
else
|
||||
{
|
||||
xdg_toplevel_move(window->wl.xdg.toplevel, _glfw.wl.seat, serial);
|
||||
}
|
||||
break;
|
||||
case leftDecoration:
|
||||
if (window->wl.cursorPosY < _GLFW_DECORATION_WIDTH)
|
||||
@ -303,6 +296,7 @@ static void pointerHandleButton(void* data,
|
||||
{
|
||||
xdg_toplevel_resize(window->wl.xdg.toplevel, _glfw.wl.seat,
|
||||
serial, edges);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (button == BTN_RIGHT)
|
||||
@ -378,11 +372,8 @@ static void keyboardHandleKeymap(void* data,
|
||||
{
|
||||
struct xkb_keymap* keymap;
|
||||
struct xkb_state* state;
|
||||
|
||||
#ifdef HAVE_XKBCOMMON_COMPOSE_H
|
||||
struct xkb_compose_table* composeTable;
|
||||
struct xkb_compose_state* composeState;
|
||||
#endif
|
||||
|
||||
char* mapStr;
|
||||
const char* locale;
|
||||
@ -431,7 +422,6 @@ static void keyboardHandleKeymap(void* data,
|
||||
if (!locale)
|
||||
locale = "C";
|
||||
|
||||
#ifdef HAVE_XKBCOMMON_COMPOSE_H
|
||||
composeTable =
|
||||
xkb_compose_table_new_from_locale(_glfw.wl.xkb.context, locale,
|
||||
XKB_COMPOSE_COMPILE_NO_FLAGS);
|
||||
@ -451,7 +441,6 @@ static void keyboardHandleKeymap(void* data,
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"Wayland: Failed to create XKB compose table");
|
||||
}
|
||||
#endif
|
||||
|
||||
xkb_keymap_unref(_glfw.wl.xkb.keymap);
|
||||
xkb_state_unref(_glfw.wl.xkb.state);
|
||||
@ -505,20 +494,22 @@ static void keyboardHandleLeave(void* data,
|
||||
if (!window)
|
||||
return;
|
||||
|
||||
struct itimerspec timer = {};
|
||||
timerfd_settime(_glfw.wl.timerfd, 0, &timer, NULL);
|
||||
|
||||
_glfw.wl.serial = serial;
|
||||
_glfw.wl.keyboardFocus = NULL;
|
||||
_glfwInputWindowFocus(window, GLFW_FALSE);
|
||||
}
|
||||
|
||||
static int toGLFWKeyCode(uint32_t key)
|
||||
static int translateKey(uint32_t scancode)
|
||||
{
|
||||
if (key < sizeof(_glfw.wl.keycodes) / sizeof(_glfw.wl.keycodes[0]))
|
||||
return _glfw.wl.keycodes[key];
|
||||
if (scancode < sizeof(_glfw.wl.keycodes) / sizeof(_glfw.wl.keycodes[0]))
|
||||
return _glfw.wl.keycodes[scancode];
|
||||
|
||||
return GLFW_KEY_UNKNOWN;
|
||||
}
|
||||
|
||||
#ifdef HAVE_XKBCOMMON_COMPOSE_H
|
||||
static xkb_keysym_t composeSymbol(xkb_keysym_t sym)
|
||||
{
|
||||
if (sym == XKB_KEY_NoSymbol || !_glfw.wl.xkb.composeState)
|
||||
@ -538,77 +529,65 @@ static xkb_keysym_t composeSymbol(xkb_keysym_t sym)
|
||||
return sym;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static GLFWbool inputChar(_GLFWwindow* window, uint32_t key)
|
||||
GLFWbool _glfwInputTextWayland(_GLFWwindow* window, uint32_t scancode)
|
||||
{
|
||||
uint32_t code, numSyms;
|
||||
long cp;
|
||||
const xkb_keysym_t *syms;
|
||||
xkb_keysym_t sym;
|
||||
const xkb_keysym_t* keysyms;
|
||||
const xkb_keycode_t keycode = scancode + 8;
|
||||
|
||||
code = key + 8;
|
||||
numSyms = xkb_state_key_get_syms(_glfw.wl.xkb.state, code, &syms);
|
||||
|
||||
if (numSyms == 1)
|
||||
if (xkb_state_key_get_syms(_glfw.wl.xkb.state, keycode, &keysyms) == 1)
|
||||
{
|
||||
#ifdef HAVE_XKBCOMMON_COMPOSE_H
|
||||
sym = composeSymbol(syms[0]);
|
||||
#else
|
||||
sym = syms[0];
|
||||
#endif
|
||||
cp = _glfwKeySym2Unicode(sym);
|
||||
if (cp != -1)
|
||||
const xkb_keysym_t keysym = composeSymbol(keysyms[0]);
|
||||
const uint32_t codepoint = _glfwKeySym2Unicode(keysym);
|
||||
if (codepoint != GLFW_INVALID_CODEPOINT)
|
||||
{
|
||||
const int mods = _glfw.wl.xkb.modifiers;
|
||||
const int plain = !(mods & (GLFW_MOD_CONTROL | GLFW_MOD_ALT));
|
||||
_glfwInputChar(window, cp, mods, plain);
|
||||
_glfwInputChar(window, codepoint, mods, plain);
|
||||
}
|
||||
}
|
||||
|
||||
return xkb_keymap_key_repeats(_glfw.wl.xkb.keymap, code);
|
||||
return xkb_keymap_key_repeats(_glfw.wl.xkb.keymap, keycode);
|
||||
}
|
||||
|
||||
static void keyboardHandleKey(void* data,
|
||||
struct wl_keyboard* keyboard,
|
||||
uint32_t serial,
|
||||
uint32_t time,
|
||||
uint32_t key,
|
||||
uint32_t scancode,
|
||||
uint32_t state)
|
||||
{
|
||||
int keyCode;
|
||||
int action;
|
||||
_GLFWwindow* window = _glfw.wl.keyboardFocus;
|
||||
GLFWbool shouldRepeat;
|
||||
struct itimerspec timer = {};
|
||||
|
||||
if (!window)
|
||||
return;
|
||||
|
||||
keyCode = toGLFWKeyCode(key);
|
||||
action = state == WL_KEYBOARD_KEY_STATE_PRESSED
|
||||
? GLFW_PRESS : GLFW_RELEASE;
|
||||
const int key = translateKey(scancode);
|
||||
const int action =
|
||||
state == WL_KEYBOARD_KEY_STATE_PRESSED ? GLFW_PRESS : GLFW_RELEASE;
|
||||
|
||||
_glfw.wl.serial = serial;
|
||||
_glfwInputKey(window, keyCode, key, action,
|
||||
_glfw.wl.xkb.modifiers);
|
||||
_glfwInputKey(window, key, scancode, action, _glfw.wl.xkb.modifiers);
|
||||
|
||||
struct itimerspec timer = {};
|
||||
|
||||
if (action == GLFW_PRESS)
|
||||
{
|
||||
shouldRepeat = inputChar(window, key);
|
||||
const GLFWbool shouldRepeat = _glfwInputTextWayland(window, scancode);
|
||||
|
||||
if (shouldRepeat && _glfw.wl.keyboardRepeatRate > 0)
|
||||
{
|
||||
_glfw.wl.keyboardLastKey = keyCode;
|
||||
_glfw.wl.keyboardLastScancode = key;
|
||||
_glfw.wl.keyboardLastKey = key;
|
||||
_glfw.wl.keyboardLastScancode = scancode;
|
||||
if (_glfw.wl.keyboardRepeatRate > 1)
|
||||
timer.it_interval.tv_nsec = 1000000000 / _glfw.wl.keyboardRepeatRate;
|
||||
else
|
||||
timer.it_interval.tv_sec = 1;
|
||||
|
||||
timer.it_value.tv_sec = _glfw.wl.keyboardRepeatDelay / 1000;
|
||||
timer.it_value.tv_nsec = (_glfw.wl.keyboardRepeatDelay % 1000) * 1000000;
|
||||
}
|
||||
}
|
||||
|
||||
timerfd_settime(_glfw.wl.timerfd, 0, &timer, NULL);
|
||||
}
|
||||
|
||||
@ -620,9 +599,6 @@ static void keyboardHandleModifiers(void* data,
|
||||
uint32_t modsLocked,
|
||||
uint32_t group)
|
||||
{
|
||||
xkb_mod_mask_t mask;
|
||||
unsigned int modifiers = 0;
|
||||
|
||||
_glfw.wl.serial = serial;
|
||||
|
||||
if (!_glfw.wl.xkb.keymap)
|
||||
@ -636,24 +612,29 @@ static void keyboardHandleModifiers(void* data,
|
||||
0,
|
||||
group);
|
||||
|
||||
mask = xkb_state_serialize_mods(_glfw.wl.xkb.state,
|
||||
XKB_STATE_MODS_DEPRESSED |
|
||||
XKB_STATE_LAYOUT_DEPRESSED |
|
||||
XKB_STATE_MODS_LATCHED |
|
||||
XKB_STATE_LAYOUT_LATCHED);
|
||||
const xkb_mod_mask_t mask =
|
||||
xkb_state_serialize_mods(_glfw.wl.xkb.state,
|
||||
XKB_STATE_MODS_DEPRESSED |
|
||||
XKB_STATE_LAYOUT_DEPRESSED |
|
||||
XKB_STATE_MODS_LATCHED |
|
||||
XKB_STATE_LAYOUT_LATCHED);
|
||||
|
||||
unsigned int mods = 0;
|
||||
|
||||
if (mask & _glfw.wl.xkb.controlMask)
|
||||
modifiers |= GLFW_MOD_CONTROL;
|
||||
mods |= GLFW_MOD_CONTROL;
|
||||
if (mask & _glfw.wl.xkb.altMask)
|
||||
modifiers |= GLFW_MOD_ALT;
|
||||
mods |= GLFW_MOD_ALT;
|
||||
if (mask & _glfw.wl.xkb.shiftMask)
|
||||
modifiers |= GLFW_MOD_SHIFT;
|
||||
mods |= GLFW_MOD_SHIFT;
|
||||
if (mask & _glfw.wl.xkb.superMask)
|
||||
modifiers |= GLFW_MOD_SUPER;
|
||||
mods |= GLFW_MOD_SUPER;
|
||||
if (mask & _glfw.wl.xkb.capsLockMask)
|
||||
modifiers |= GLFW_MOD_CAPS_LOCK;
|
||||
mods |= GLFW_MOD_CAPS_LOCK;
|
||||
if (mask & _glfw.wl.xkb.numLockMask)
|
||||
modifiers |= GLFW_MOD_NUM_LOCK;
|
||||
_glfw.wl.xkb.modifiers = modifiers;
|
||||
mods |= GLFW_MOD_NUM_LOCK;
|
||||
|
||||
_glfw.wl.xkb.modifiers = mods;
|
||||
}
|
||||
|
||||
#ifdef WL_KEYBOARD_REPEAT_INFO_SINCE_VERSION
|
||||
@ -802,7 +783,7 @@ static void registryHandleGlobal(void* data,
|
||||
{
|
||||
if (strcmp(interface, "wl_compositor") == 0)
|
||||
{
|
||||
_glfw.wl.compositorVersion = min(3, version);
|
||||
_glfw.wl.compositorVersion = _glfw_min(3, version);
|
||||
_glfw.wl.compositor =
|
||||
wl_registry_bind(registry, name, &wl_compositor_interface,
|
||||
_glfw.wl.compositorVersion);
|
||||
@ -825,7 +806,7 @@ static void registryHandleGlobal(void* data,
|
||||
{
|
||||
if (!_glfw.wl.seat)
|
||||
{
|
||||
_glfw.wl.seatVersion = min(4, version);
|
||||
_glfw.wl.seatVersion = _glfw_min(4, version);
|
||||
_glfw.wl.seat =
|
||||
wl_registry_bind(registry, name, &wl_seat_interface,
|
||||
_glfw.wl.seatVersion);
|
||||
@ -886,10 +867,9 @@ static void registryHandleGlobalRemove(void *data,
|
||||
struct wl_registry *registry,
|
||||
uint32_t name)
|
||||
{
|
||||
int i;
|
||||
_GLFWmonitor* monitor;
|
||||
|
||||
for (i = 0; i < _glfw.monitorCount; ++i)
|
||||
for (int i = 0; i < _glfw.monitorCount; ++i)
|
||||
{
|
||||
monitor = _glfw.monitors[i];
|
||||
if (monitor->wl.name == name)
|
||||
@ -910,8 +890,6 @@ static const struct wl_registry_listener registryListener = {
|
||||
//
|
||||
static void createKeyTables(void)
|
||||
{
|
||||
int scancode;
|
||||
|
||||
memset(_glfw.wl.keycodes, -1, sizeof(_glfw.wl.keycodes));
|
||||
memset(_glfw.wl.scancodes, -1, sizeof(_glfw.wl.scancodes));
|
||||
|
||||
@ -973,7 +951,7 @@ static void createKeyTables(void)
|
||||
_glfw.wl.keycodes[KEY_RIGHTALT] = GLFW_KEY_RIGHT_ALT;
|
||||
_glfw.wl.keycodes[KEY_LEFTMETA] = GLFW_KEY_LEFT_SUPER;
|
||||
_glfw.wl.keycodes[KEY_RIGHTMETA] = GLFW_KEY_RIGHT_SUPER;
|
||||
_glfw.wl.keycodes[KEY_MENU] = GLFW_KEY_MENU;
|
||||
_glfw.wl.keycodes[KEY_COMPOSE] = GLFW_KEY_MENU;
|
||||
_glfw.wl.keycodes[KEY_NUMLOCK] = GLFW_KEY_NUM_LOCK;
|
||||
_glfw.wl.keycodes[KEY_CAPSLOCK] = GLFW_KEY_CAPS_LOCK;
|
||||
_glfw.wl.keycodes[KEY_PRINT] = GLFW_KEY_PRINT_SCREEN;
|
||||
@ -1016,7 +994,7 @@ static void createKeyTables(void)
|
||||
_glfw.wl.keycodes[KEY_F23] = GLFW_KEY_F23;
|
||||
_glfw.wl.keycodes[KEY_F24] = GLFW_KEY_F24;
|
||||
_glfw.wl.keycodes[KEY_KPSLASH] = GLFW_KEY_KP_DIVIDE;
|
||||
_glfw.wl.keycodes[KEY_KPDOT] = GLFW_KEY_KP_MULTIPLY;
|
||||
_glfw.wl.keycodes[KEY_KPASTERISK] = GLFW_KEY_KP_MULTIPLY;
|
||||
_glfw.wl.keycodes[KEY_KPMINUS] = GLFW_KEY_KP_SUBTRACT;
|
||||
_glfw.wl.keycodes[KEY_KPPLUS] = GLFW_KEY_KP_ADD;
|
||||
_glfw.wl.keycodes[KEY_KP0] = GLFW_KEY_KP_0;
|
||||
@ -1029,11 +1007,12 @@ static void createKeyTables(void)
|
||||
_glfw.wl.keycodes[KEY_KP7] = GLFW_KEY_KP_7;
|
||||
_glfw.wl.keycodes[KEY_KP8] = GLFW_KEY_KP_8;
|
||||
_glfw.wl.keycodes[KEY_KP9] = GLFW_KEY_KP_9;
|
||||
_glfw.wl.keycodes[KEY_KPCOMMA] = GLFW_KEY_KP_DECIMAL;
|
||||
_glfw.wl.keycodes[KEY_KPDOT] = GLFW_KEY_KP_DECIMAL;
|
||||
_glfw.wl.keycodes[KEY_KPEQUAL] = GLFW_KEY_KP_EQUAL;
|
||||
_glfw.wl.keycodes[KEY_KPENTER] = GLFW_KEY_KP_ENTER;
|
||||
_glfw.wl.keycodes[KEY_102ND] = GLFW_KEY_WORLD_2;
|
||||
|
||||
for (scancode = 0; scancode < 256; scancode++)
|
||||
for (int scancode = 0; scancode < 256; scancode++)
|
||||
{
|
||||
if (_glfw.wl.keycodes[scancode] > 0)
|
||||
_glfw.wl.scancodes[_glfw.wl.keycodes[scancode]] = scancode;
|
||||
@ -1045,7 +1024,136 @@ static void createKeyTables(void)
|
||||
////// GLFW platform API //////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int _glfwPlatformInit(void)
|
||||
GLFWbool _glfwConnectWayland(int platformID, _GLFWplatform* platform)
|
||||
{
|
||||
const _GLFWplatform wayland =
|
||||
{
|
||||
GLFW_PLATFORM_WAYLAND,
|
||||
_glfwInitWayland,
|
||||
_glfwTerminateWayland,
|
||||
_glfwGetCursorPosWayland,
|
||||
_glfwSetCursorPosWayland,
|
||||
_glfwSetCursorModeWayland,
|
||||
_glfwSetRawMouseMotionWayland,
|
||||
_glfwRawMouseMotionSupportedWayland,
|
||||
_glfwCreateCursorWayland,
|
||||
_glfwCreateStandardCursorWayland,
|
||||
_glfwDestroyCursorWayland,
|
||||
_glfwSetCursorWayland,
|
||||
_glfwGetScancodeNameWayland,
|
||||
_glfwGetKeyScancodeWayland,
|
||||
_glfwSetClipboardStringWayland,
|
||||
_glfwGetClipboardStringWayland,
|
||||
#if defined(__linux__)
|
||||
_glfwInitJoysticksLinux,
|
||||
_glfwTerminateJoysticksLinux,
|
||||
_glfwPollJoystickLinux,
|
||||
_glfwGetMappingNameLinux,
|
||||
_glfwUpdateGamepadGUIDLinux,
|
||||
#else
|
||||
_glfwInitJoysticksNull,
|
||||
_glfwTerminateJoysticksNull,
|
||||
_glfwPollJoystickNull,
|
||||
_glfwGetMappingNameNull,
|
||||
_glfwUpdateGamepadGUIDNull,
|
||||
#endif
|
||||
_glfwFreeMonitorWayland,
|
||||
_glfwGetMonitorPosWayland,
|
||||
_glfwGetMonitorContentScaleWayland,
|
||||
_glfwGetMonitorWorkareaWayland,
|
||||
_glfwGetVideoModesWayland,
|
||||
_glfwGetVideoModeWayland,
|
||||
_glfwGetGammaRampWayland,
|
||||
_glfwSetGammaRampWayland,
|
||||
_glfwCreateWindowWayland,
|
||||
_glfwDestroyWindowWayland,
|
||||
_glfwSetWindowTitleWayland,
|
||||
_glfwSetWindowIconWayland,
|
||||
_glfwGetWindowPosWayland,
|
||||
_glfwSetWindowPosWayland,
|
||||
_glfwGetWindowSizeWayland,
|
||||
_glfwSetWindowSizeWayland,
|
||||
_glfwSetWindowSizeLimitsWayland,
|
||||
_glfwSetWindowAspectRatioWayland,
|
||||
_glfwGetFramebufferSizeWayland,
|
||||
_glfwGetWindowFrameSizeWayland,
|
||||
_glfwGetWindowContentScaleWayland,
|
||||
_glfwIconifyWindowWayland,
|
||||
_glfwRestoreWindowWayland,
|
||||
_glfwMaximizeWindowWayland,
|
||||
_glfwShowWindowWayland,
|
||||
_glfwHideWindowWayland,
|
||||
_glfwRequestWindowAttentionWayland,
|
||||
_glfwFocusWindowWayland,
|
||||
_glfwSetWindowMonitorWayland,
|
||||
_glfwWindowFocusedWayland,
|
||||
_glfwWindowIconifiedWayland,
|
||||
_glfwWindowVisibleWayland,
|
||||
_glfwWindowMaximizedWayland,
|
||||
_glfwWindowHoveredWayland,
|
||||
_glfwFramebufferTransparentWayland,
|
||||
_glfwGetWindowOpacityWayland,
|
||||
_glfwSetWindowResizableWayland,
|
||||
_glfwSetWindowDecoratedWayland,
|
||||
_glfwSetWindowFloatingWayland,
|
||||
_glfwSetWindowOpacityWayland,
|
||||
_glfwSetWindowMousePassthroughWayland,
|
||||
_glfwPollEventsWayland,
|
||||
_glfwWaitEventsWayland,
|
||||
_glfwWaitEventsTimeoutWayland,
|
||||
_glfwPostEmptyEventWayland,
|
||||
_glfwGetEGLPlatformWayland,
|
||||
_glfwGetEGLNativeDisplayWayland,
|
||||
_glfwGetEGLNativeWindowWayland,
|
||||
_glfwGetRequiredInstanceExtensionsWayland,
|
||||
_glfwGetPhysicalDevicePresentationSupportWayland,
|
||||
_glfwCreateWindowSurfaceWayland,
|
||||
};
|
||||
|
||||
void* module = _glfwPlatformLoadModule("libwayland-client.so.0");
|
||||
if (!module)
|
||||
{
|
||||
if (platformID == GLFW_PLATFORM_WAYLAND)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"Wayland: Failed to open libwayland-client");
|
||||
}
|
||||
|
||||
return GLFW_FALSE;
|
||||
}
|
||||
|
||||
PFN_wl_display_connect wl_display_connect = (PFN_wl_display_connect)
|
||||
_glfwPlatformGetModuleSymbol(module, "wl_display_connect");
|
||||
if (!wl_display_connect)
|
||||
{
|
||||
if (platformID == GLFW_PLATFORM_WAYLAND)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"Wayland: Failed to load libwayland-client entry point");
|
||||
}
|
||||
|
||||
_glfwPlatformFreeModule(module);
|
||||
return GLFW_FALSE;
|
||||
}
|
||||
|
||||
struct wl_display* display = wl_display_connect(NULL);
|
||||
if (!display)
|
||||
{
|
||||
if (platformID == GLFW_PLATFORM_WAYLAND)
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR, "Wayland: Failed to connect to display");
|
||||
|
||||
_glfwPlatformFreeModule(module);
|
||||
return GLFW_FALSE;
|
||||
}
|
||||
|
||||
_glfw.wl.display = display;
|
||||
_glfw.wl.client.handle = module;
|
||||
|
||||
*platform = wayland;
|
||||
return GLFW_TRUE;
|
||||
}
|
||||
|
||||
int _glfwInitWayland(void)
|
||||
{
|
||||
const char *cursorTheme;
|
||||
const char *cursorSizeStr;
|
||||
@ -1053,56 +1161,45 @@ int _glfwPlatformInit(void)
|
||||
long cursorSizeLong;
|
||||
int cursorSize;
|
||||
|
||||
_glfw.wl.client.handle = _glfw_dlopen("libwayland-client.so.0");
|
||||
if (!_glfw.wl.client.handle)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"Wayland: Failed to open libwayland-client");
|
||||
return GLFW_FALSE;
|
||||
}
|
||||
|
||||
_glfw.wl.client.display_flush = (PFN_wl_display_flush)
|
||||
_glfw_dlsym(_glfw.wl.client.handle, "wl_display_flush");
|
||||
_glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_display_flush");
|
||||
_glfw.wl.client.display_cancel_read = (PFN_wl_display_cancel_read)
|
||||
_glfw_dlsym(_glfw.wl.client.handle, "wl_display_cancel_read");
|
||||
_glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_display_cancel_read");
|
||||
_glfw.wl.client.display_dispatch_pending = (PFN_wl_display_dispatch_pending)
|
||||
_glfw_dlsym(_glfw.wl.client.handle, "wl_display_dispatch_pending");
|
||||
_glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_display_dispatch_pending");
|
||||
_glfw.wl.client.display_read_events = (PFN_wl_display_read_events)
|
||||
_glfw_dlsym(_glfw.wl.client.handle, "wl_display_read_events");
|
||||
_glfw.wl.client.display_connect = (PFN_wl_display_connect)
|
||||
_glfw_dlsym(_glfw.wl.client.handle, "wl_display_connect");
|
||||
_glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_display_read_events");
|
||||
_glfw.wl.client.display_disconnect = (PFN_wl_display_disconnect)
|
||||
_glfw_dlsym(_glfw.wl.client.handle, "wl_display_disconnect");
|
||||
_glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_display_disconnect");
|
||||
_glfw.wl.client.display_roundtrip = (PFN_wl_display_roundtrip)
|
||||
_glfw_dlsym(_glfw.wl.client.handle, "wl_display_roundtrip");
|
||||
_glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_display_roundtrip");
|
||||
_glfw.wl.client.display_get_fd = (PFN_wl_display_get_fd)
|
||||
_glfw_dlsym(_glfw.wl.client.handle, "wl_display_get_fd");
|
||||
_glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_display_get_fd");
|
||||
_glfw.wl.client.display_prepare_read = (PFN_wl_display_prepare_read)
|
||||
_glfw_dlsym(_glfw.wl.client.handle, "wl_display_prepare_read");
|
||||
_glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_display_prepare_read");
|
||||
_glfw.wl.client.proxy_marshal = (PFN_wl_proxy_marshal)
|
||||
_glfw_dlsym(_glfw.wl.client.handle, "wl_proxy_marshal");
|
||||
_glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_proxy_marshal");
|
||||
_glfw.wl.client.proxy_add_listener = (PFN_wl_proxy_add_listener)
|
||||
_glfw_dlsym(_glfw.wl.client.handle, "wl_proxy_add_listener");
|
||||
_glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_proxy_add_listener");
|
||||
_glfw.wl.client.proxy_destroy = (PFN_wl_proxy_destroy)
|
||||
_glfw_dlsym(_glfw.wl.client.handle, "wl_proxy_destroy");
|
||||
_glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_proxy_destroy");
|
||||
_glfw.wl.client.proxy_marshal_constructor = (PFN_wl_proxy_marshal_constructor)
|
||||
_glfw_dlsym(_glfw.wl.client.handle, "wl_proxy_marshal_constructor");
|
||||
_glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_proxy_marshal_constructor");
|
||||
_glfw.wl.client.proxy_marshal_constructor_versioned = (PFN_wl_proxy_marshal_constructor_versioned)
|
||||
_glfw_dlsym(_glfw.wl.client.handle, "wl_proxy_marshal_constructor_versioned");
|
||||
_glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_proxy_marshal_constructor_versioned");
|
||||
_glfw.wl.client.proxy_get_user_data = (PFN_wl_proxy_get_user_data)
|
||||
_glfw_dlsym(_glfw.wl.client.handle, "wl_proxy_get_user_data");
|
||||
_glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_proxy_get_user_data");
|
||||
_glfw.wl.client.proxy_set_user_data = (PFN_wl_proxy_set_user_data)
|
||||
_glfw_dlsym(_glfw.wl.client.handle, "wl_proxy_set_user_data");
|
||||
_glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_proxy_set_user_data");
|
||||
_glfw.wl.client.proxy_get_version = (PFN_wl_proxy_get_version)
|
||||
_glfw_dlsym(_glfw.wl.client.handle, "wl_proxy_get_version");
|
||||
_glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_proxy_get_version");
|
||||
_glfw.wl.client.proxy_marshal_flags = (PFN_wl_proxy_marshal_flags)
|
||||
_glfw_dlsym(_glfw.wl.client.handle, "wl_proxy_marshal_flags");
|
||||
_glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_proxy_marshal_flags");
|
||||
|
||||
if (!_glfw.wl.client.display_flush ||
|
||||
!_glfw.wl.client.display_cancel_read ||
|
||||
!_glfw.wl.client.display_dispatch_pending ||
|
||||
!_glfw.wl.client.display_read_events ||
|
||||
!_glfw.wl.client.display_connect ||
|
||||
!_glfw.wl.client.display_disconnect ||
|
||||
!_glfw.wl.client.display_roundtrip ||
|
||||
!_glfw.wl.client.display_get_fd ||
|
||||
@ -1120,7 +1217,7 @@ int _glfwPlatformInit(void)
|
||||
return GLFW_FALSE;
|
||||
}
|
||||
|
||||
_glfw.wl.cursor.handle = _glfw_dlopen("libwayland-cursor.so.0");
|
||||
_glfw.wl.cursor.handle = _glfwPlatformLoadModule("libwayland-cursor.so.0");
|
||||
if (!_glfw.wl.cursor.handle)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
@ -1129,15 +1226,15 @@ int _glfwPlatformInit(void)
|
||||
}
|
||||
|
||||
_glfw.wl.cursor.theme_load = (PFN_wl_cursor_theme_load)
|
||||
_glfw_dlsym(_glfw.wl.cursor.handle, "wl_cursor_theme_load");
|
||||
_glfwPlatformGetModuleSymbol(_glfw.wl.cursor.handle, "wl_cursor_theme_load");
|
||||
_glfw.wl.cursor.theme_destroy = (PFN_wl_cursor_theme_destroy)
|
||||
_glfw_dlsym(_glfw.wl.cursor.handle, "wl_cursor_theme_destroy");
|
||||
_glfwPlatformGetModuleSymbol(_glfw.wl.cursor.handle, "wl_cursor_theme_destroy");
|
||||
_glfw.wl.cursor.theme_get_cursor = (PFN_wl_cursor_theme_get_cursor)
|
||||
_glfw_dlsym(_glfw.wl.cursor.handle, "wl_cursor_theme_get_cursor");
|
||||
_glfwPlatformGetModuleSymbol(_glfw.wl.cursor.handle, "wl_cursor_theme_get_cursor");
|
||||
_glfw.wl.cursor.image_get_buffer = (PFN_wl_cursor_image_get_buffer)
|
||||
_glfw_dlsym(_glfw.wl.cursor.handle, "wl_cursor_image_get_buffer");
|
||||
_glfwPlatformGetModuleSymbol(_glfw.wl.cursor.handle, "wl_cursor_image_get_buffer");
|
||||
|
||||
_glfw.wl.egl.handle = _glfw_dlopen("libwayland-egl.so.1");
|
||||
_glfw.wl.egl.handle = _glfwPlatformLoadModule("libwayland-egl.so.1");
|
||||
if (!_glfw.wl.egl.handle)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
@ -1146,13 +1243,13 @@ int _glfwPlatformInit(void)
|
||||
}
|
||||
|
||||
_glfw.wl.egl.window_create = (PFN_wl_egl_window_create)
|
||||
_glfw_dlsym(_glfw.wl.egl.handle, "wl_egl_window_create");
|
||||
_glfwPlatformGetModuleSymbol(_glfw.wl.egl.handle, "wl_egl_window_create");
|
||||
_glfw.wl.egl.window_destroy = (PFN_wl_egl_window_destroy)
|
||||
_glfw_dlsym(_glfw.wl.egl.handle, "wl_egl_window_destroy");
|
||||
_glfwPlatformGetModuleSymbol(_glfw.wl.egl.handle, "wl_egl_window_destroy");
|
||||
_glfw.wl.egl.window_resize = (PFN_wl_egl_window_resize)
|
||||
_glfw_dlsym(_glfw.wl.egl.handle, "wl_egl_window_resize");
|
||||
_glfwPlatformGetModuleSymbol(_glfw.wl.egl.handle, "wl_egl_window_resize");
|
||||
|
||||
_glfw.wl.xkb.handle = _glfw_dlopen("libxkbcommon.so.0");
|
||||
_glfw.wl.xkb.handle = _glfwPlatformLoadModule("libxkbcommon.so.0");
|
||||
if (!_glfw.wl.xkb.handle)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
@ -1161,52 +1258,45 @@ int _glfwPlatformInit(void)
|
||||
}
|
||||
|
||||
_glfw.wl.xkb.context_new = (PFN_xkb_context_new)
|
||||
_glfw_dlsym(_glfw.wl.xkb.handle, "xkb_context_new");
|
||||
_glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_context_new");
|
||||
_glfw.wl.xkb.context_unref = (PFN_xkb_context_unref)
|
||||
_glfw_dlsym(_glfw.wl.xkb.handle, "xkb_context_unref");
|
||||
_glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_context_unref");
|
||||
_glfw.wl.xkb.keymap_new_from_string = (PFN_xkb_keymap_new_from_string)
|
||||
_glfw_dlsym(_glfw.wl.xkb.handle, "xkb_keymap_new_from_string");
|
||||
_glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_keymap_new_from_string");
|
||||
_glfw.wl.xkb.keymap_unref = (PFN_xkb_keymap_unref)
|
||||
_glfw_dlsym(_glfw.wl.xkb.handle, "xkb_keymap_unref");
|
||||
_glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_keymap_unref");
|
||||
_glfw.wl.xkb.keymap_mod_get_index = (PFN_xkb_keymap_mod_get_index)
|
||||
_glfw_dlsym(_glfw.wl.xkb.handle, "xkb_keymap_mod_get_index");
|
||||
_glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_keymap_mod_get_index");
|
||||
_glfw.wl.xkb.keymap_key_repeats = (PFN_xkb_keymap_key_repeats)
|
||||
_glfw_dlsym(_glfw.wl.xkb.handle, "xkb_keymap_key_repeats");
|
||||
_glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_keymap_key_repeats");
|
||||
_glfw.wl.xkb.keymap_key_get_syms_by_level = (PFN_xkb_keymap_key_get_syms_by_level)
|
||||
_glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_keymap_key_get_syms_by_level");
|
||||
_glfw.wl.xkb.state_new = (PFN_xkb_state_new)
|
||||
_glfw_dlsym(_glfw.wl.xkb.handle, "xkb_state_new");
|
||||
_glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_state_new");
|
||||
_glfw.wl.xkb.state_unref = (PFN_xkb_state_unref)
|
||||
_glfw_dlsym(_glfw.wl.xkb.handle, "xkb_state_unref");
|
||||
_glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_state_unref");
|
||||
_glfw.wl.xkb.state_key_get_syms = (PFN_xkb_state_key_get_syms)
|
||||
_glfw_dlsym(_glfw.wl.xkb.handle, "xkb_state_key_get_syms");
|
||||
_glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_state_key_get_syms");
|
||||
_glfw.wl.xkb.state_update_mask = (PFN_xkb_state_update_mask)
|
||||
_glfw_dlsym(_glfw.wl.xkb.handle, "xkb_state_update_mask");
|
||||
_glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_state_update_mask");
|
||||
_glfw.wl.xkb.state_serialize_mods = (PFN_xkb_state_serialize_mods)
|
||||
_glfw_dlsym(_glfw.wl.xkb.handle, "xkb_state_serialize_mods");
|
||||
|
||||
#ifdef HAVE_XKBCOMMON_COMPOSE_H
|
||||
_glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_state_serialize_mods");
|
||||
_glfw.wl.xkb.state_key_get_layout = (PFN_xkb_state_key_get_layout)
|
||||
_glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_state_key_get_layout");
|
||||
_glfw.wl.xkb.compose_table_new_from_locale = (PFN_xkb_compose_table_new_from_locale)
|
||||
_glfw_dlsym(_glfw.wl.xkb.handle, "xkb_compose_table_new_from_locale");
|
||||
_glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_compose_table_new_from_locale");
|
||||
_glfw.wl.xkb.compose_table_unref = (PFN_xkb_compose_table_unref)
|
||||
_glfw_dlsym(_glfw.wl.xkb.handle, "xkb_compose_table_unref");
|
||||
_glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_compose_table_unref");
|
||||
_glfw.wl.xkb.compose_state_new = (PFN_xkb_compose_state_new)
|
||||
_glfw_dlsym(_glfw.wl.xkb.handle, "xkb_compose_state_new");
|
||||
_glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_compose_state_new");
|
||||
_glfw.wl.xkb.compose_state_unref = (PFN_xkb_compose_state_unref)
|
||||
_glfw_dlsym(_glfw.wl.xkb.handle, "xkb_compose_state_unref");
|
||||
_glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_compose_state_unref");
|
||||
_glfw.wl.xkb.compose_state_feed = (PFN_xkb_compose_state_feed)
|
||||
_glfw_dlsym(_glfw.wl.xkb.handle, "xkb_compose_state_feed");
|
||||
_glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_compose_state_feed");
|
||||
_glfw.wl.xkb.compose_state_get_status = (PFN_xkb_compose_state_get_status)
|
||||
_glfw_dlsym(_glfw.wl.xkb.handle, "xkb_compose_state_get_status");
|
||||
_glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_compose_state_get_status");
|
||||
_glfw.wl.xkb.compose_state_get_one_sym = (PFN_xkb_compose_state_get_one_sym)
|
||||
_glfw_dlsym(_glfw.wl.xkb.handle, "xkb_compose_state_get_one_sym");
|
||||
#endif
|
||||
|
||||
_glfw.wl.display = wl_display_connect(NULL);
|
||||
if (!_glfw.wl.display)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"Wayland: Failed to connect to display");
|
||||
return GLFW_FALSE;
|
||||
}
|
||||
_glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_compose_state_get_one_sym");
|
||||
|
||||
_glfw.wl.registry = wl_display_get_registry(_glfw.wl.display);
|
||||
wl_registry_add_listener(_glfw.wl.registry, ®istryListener, NULL);
|
||||
@ -1227,11 +1317,9 @@ int _glfwPlatformInit(void)
|
||||
// Sync so we got all initial output events
|
||||
wl_display_roundtrip(_glfw.wl.display);
|
||||
|
||||
_glfwInitTimerPOSIX();
|
||||
|
||||
_glfw.wl.timerfd = -1;
|
||||
if (_glfw.wl.seatVersion >= 4)
|
||||
_glfw.wl.timerfd = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC);
|
||||
_glfw.wl.timerfd = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC | TFD_NONBLOCK);
|
||||
|
||||
if (!_glfw.wl.wmBase)
|
||||
{
|
||||
@ -1265,7 +1353,7 @@ int _glfwPlatformInit(void)
|
||||
wl_cursor_theme_load(cursorTheme, 2 * cursorSize, _glfw.wl.shm);
|
||||
_glfw.wl.cursorSurface =
|
||||
wl_compositor_create_surface(_glfw.wl.compositor);
|
||||
_glfw.wl.cursorTimerfd = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC);
|
||||
_glfw.wl.cursorTimerfd = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC | TFD_NONBLOCK);
|
||||
}
|
||||
|
||||
if (_glfw.wl.seat && _glfw.wl.dataDeviceManager)
|
||||
@ -1274,32 +1362,31 @@ int _glfwPlatformInit(void)
|
||||
wl_data_device_manager_get_data_device(_glfw.wl.dataDeviceManager,
|
||||
_glfw.wl.seat);
|
||||
wl_data_device_add_listener(_glfw.wl.dataDevice, &dataDeviceListener, NULL);
|
||||
_glfw.wl.clipboardString = _glfw_calloc(4096, 1);
|
||||
|
||||
_glfw.wl.clipboardSize = 4096;
|
||||
_glfw.wl.clipboardString = _glfw_calloc(_glfw.wl.clipboardSize, 1);
|
||||
if (!_glfw.wl.clipboardString)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
_glfwInputError(GLFW_OUT_OF_MEMORY,
|
||||
"Wayland: Unable to allocate clipboard memory");
|
||||
return GLFW_FALSE;
|
||||
}
|
||||
_glfw.wl.clipboardSize = 4096;
|
||||
}
|
||||
|
||||
return GLFW_TRUE;
|
||||
}
|
||||
|
||||
void _glfwPlatformTerminate(void)
|
||||
void _glfwTerminateWayland(void)
|
||||
{
|
||||
_glfwTerminateEGL();
|
||||
if (_glfw.wl.egl.handle)
|
||||
{
|
||||
_glfw_dlclose(_glfw.wl.egl.handle);
|
||||
_glfwPlatformFreeModule(_glfw.wl.egl.handle);
|
||||
_glfw.wl.egl.handle = NULL;
|
||||
}
|
||||
|
||||
#ifdef HAVE_XKBCOMMON_COMPOSE_H
|
||||
if (_glfw.wl.xkb.composeState)
|
||||
xkb_compose_state_unref(_glfw.wl.xkb.composeState);
|
||||
#endif
|
||||
if (_glfw.wl.xkb.keymap)
|
||||
xkb_keymap_unref(_glfw.wl.xkb.keymap);
|
||||
if (_glfw.wl.xkb.state)
|
||||
@ -1308,7 +1395,7 @@ void _glfwPlatformTerminate(void)
|
||||
xkb_context_unref(_glfw.wl.xkb.context);
|
||||
if (_glfw.wl.xkb.handle)
|
||||
{
|
||||
_glfw_dlclose(_glfw.wl.xkb.handle);
|
||||
_glfwPlatformFreeModule(_glfw.wl.xkb.handle);
|
||||
_glfw.wl.xkb.handle = NULL;
|
||||
}
|
||||
|
||||
@ -1318,7 +1405,7 @@ void _glfwPlatformTerminate(void)
|
||||
wl_cursor_theme_destroy(_glfw.wl.cursorThemeHiDPI);
|
||||
if (_glfw.wl.cursor.handle)
|
||||
{
|
||||
_glfw_dlclose(_glfw.wl.cursor.handle);
|
||||
_glfwPlatformFreeModule(_glfw.wl.cursor.handle);
|
||||
_glfw.wl.cursor.handle = NULL;
|
||||
}
|
||||
|
||||
@ -1369,21 +1456,7 @@ void _glfwPlatformTerminate(void)
|
||||
if (_glfw.wl.cursorTimerfd >= 0)
|
||||
close(_glfw.wl.cursorTimerfd);
|
||||
|
||||
if (_glfw.wl.clipboardString)
|
||||
_glfw_free(_glfw.wl.clipboardString);
|
||||
if (_glfw.wl.clipboardSendString)
|
||||
_glfw_free(_glfw.wl.clipboardSendString);
|
||||
_glfw_free(_glfw.wl.clipboardString);
|
||||
_glfw_free(_glfw.wl.clipboardSendString);
|
||||
}
|
||||
|
||||
const char* _glfwPlatformGetVersionString(void)
|
||||
{
|
||||
return _GLFW_VERSION_NUMBER " Wayland EGL OSMesa"
|
||||
#if defined(_POSIX_MONOTONIC_CLOCK)
|
||||
" monotonic"
|
||||
#endif
|
||||
" evdev"
|
||||
#if defined(_GLFW_BUILD_DLL)
|
||||
" shared"
|
||||
#endif
|
||||
;
|
||||
}
|
||||
|
@ -157,13 +157,13 @@ void _glfwAddOutputWayland(uint32_t name, uint32_t version)
|
||||
////// GLFW platform API //////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void _glfwPlatformFreeMonitor(_GLFWmonitor* monitor)
|
||||
void _glfwFreeMonitorWayland(_GLFWmonitor* monitor)
|
||||
{
|
||||
if (monitor->wl.output)
|
||||
wl_output_destroy(monitor->wl.output);
|
||||
}
|
||||
|
||||
void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos)
|
||||
void _glfwGetMonitorPosWayland(_GLFWmonitor* monitor, int* xpos, int* ypos)
|
||||
{
|
||||
if (xpos)
|
||||
*xpos = monitor->wl.x;
|
||||
@ -171,8 +171,8 @@ void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos)
|
||||
*ypos = monitor->wl.y;
|
||||
}
|
||||
|
||||
void _glfwPlatformGetMonitorContentScale(_GLFWmonitor* monitor,
|
||||
float* xscale, float* yscale)
|
||||
void _glfwGetMonitorContentScaleWayland(_GLFWmonitor* monitor,
|
||||
float* xscale, float* yscale)
|
||||
{
|
||||
if (xscale)
|
||||
*xscale = (float) monitor->wl.scale;
|
||||
@ -180,9 +180,9 @@ void _glfwPlatformGetMonitorContentScale(_GLFWmonitor* monitor,
|
||||
*yscale = (float) monitor->wl.scale;
|
||||
}
|
||||
|
||||
void _glfwPlatformGetMonitorWorkarea(_GLFWmonitor* monitor,
|
||||
int* xpos, int* ypos,
|
||||
int* width, int* height)
|
||||
void _glfwGetMonitorWorkareaWayland(_GLFWmonitor* monitor,
|
||||
int* xpos, int* ypos,
|
||||
int* width, int* height)
|
||||
{
|
||||
if (xpos)
|
||||
*xpos = monitor->wl.x;
|
||||
@ -194,26 +194,25 @@ void _glfwPlatformGetMonitorWorkarea(_GLFWmonitor* monitor,
|
||||
*height = monitor->modes[monitor->wl.currentMode].height;
|
||||
}
|
||||
|
||||
GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* found)
|
||||
GLFWvidmode* _glfwGetVideoModesWayland(_GLFWmonitor* monitor, int* found)
|
||||
{
|
||||
*found = monitor->modeCount;
|
||||
return monitor->modes;
|
||||
}
|
||||
|
||||
void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode)
|
||||
void _glfwGetVideoModeWayland(_GLFWmonitor* monitor, GLFWvidmode* mode)
|
||||
{
|
||||
*mode = monitor->modes[monitor->wl.currentMode];
|
||||
}
|
||||
|
||||
GLFWbool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
|
||||
GLFWbool _glfwGetGammaRampWayland(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
|
||||
{
|
||||
_glfwInputError(GLFW_FEATURE_UNAVAILABLE,
|
||||
"Wayland: Gamma ramp access is not available");
|
||||
return GLFW_FALSE;
|
||||
}
|
||||
|
||||
void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor,
|
||||
const GLFWgammaramp* ramp)
|
||||
void _glfwSetGammaRampWayland(_GLFWmonitor* monitor, const GLFWgammaramp* ramp)
|
||||
{
|
||||
_glfwInputError(GLFW_FEATURE_UNAVAILABLE,
|
||||
"Wayland: Gamma ramp access is not available");
|
||||
|
@ -26,10 +26,7 @@
|
||||
|
||||
#include <wayland-client-core.h>
|
||||
#include <xkbcommon/xkbcommon.h>
|
||||
#ifdef HAVE_XKBCOMMON_COMPOSE_H
|
||||
#include <xkbcommon/xkbcommon-compose.h>
|
||||
#endif
|
||||
#include <dlfcn.h>
|
||||
|
||||
typedef VkFlags VkWaylandSurfaceCreateFlagsKHR;
|
||||
|
||||
@ -45,14 +42,8 @@ typedef struct VkWaylandSurfaceCreateInfoKHR
|
||||
typedef VkResult (APIENTRY *PFN_vkCreateWaylandSurfaceKHR)(VkInstance,const VkWaylandSurfaceCreateInfoKHR*,const VkAllocationCallbacks*,VkSurfaceKHR*);
|
||||
typedef VkBool32 (APIENTRY *PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR)(VkPhysicalDevice,uint32_t,struct wl_display*);
|
||||
|
||||
#include "posix_thread.h"
|
||||
#include "posix_time.h"
|
||||
#ifdef __linux__
|
||||
#include "linux_joystick.h"
|
||||
#else
|
||||
#include "null_joystick.h"
|
||||
#endif
|
||||
#include "xkb_unicode.h"
|
||||
#include "posix_poll.h"
|
||||
|
||||
typedef int (* PFN_wl_display_flush)(struct wl_display *display);
|
||||
typedef void (* PFN_wl_display_cancel_read)(struct wl_display *display);
|
||||
@ -76,7 +67,6 @@ typedef struct wl_proxy* (* PFN_wl_proxy_marshal_flags)(struct wl_proxy*,uint32_
|
||||
#define wl_display_cancel_read _glfw.wl.client.display_cancel_read
|
||||
#define wl_display_dispatch_pending _glfw.wl.client.display_dispatch_pending
|
||||
#define wl_display_read_events _glfw.wl.client.display_read_events
|
||||
#define wl_display_connect _glfw.wl.client.display_connect
|
||||
#define wl_display_disconnect _glfw.wl.client.display_disconnect
|
||||
#define wl_display_roundtrip _glfw.wl.client.display_roundtrip
|
||||
#define wl_display_get_fd _glfw.wl.client.display_get_fd
|
||||
@ -133,18 +123,10 @@ struct wl_shm;
|
||||
#define xdg_toplevel_interface _glfw_xdg_toplevel_interface
|
||||
#define xdg_wm_base_interface _glfw_xdg_wm_base_interface
|
||||
|
||||
#define _glfw_dlopen(name) dlopen(name, RTLD_LAZY | RTLD_LOCAL)
|
||||
#define _glfw_dlclose(handle) dlclose(handle)
|
||||
#define _glfw_dlsym(handle, name) dlsym(handle, name)
|
||||
|
||||
#define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowWayland wl
|
||||
#define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryWayland wl
|
||||
#define _GLFW_PLATFORM_MONITOR_STATE _GLFWmonitorWayland wl
|
||||
#define _GLFW_PLATFORM_CURSOR_STATE _GLFWcursorWayland wl
|
||||
|
||||
#define _GLFW_PLATFORM_CONTEXT_STATE struct { int dummyContext; }
|
||||
#define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE struct { int dummyLibraryContext; }
|
||||
#define _GLFW_PLATFORM_USER_CONTEXT_STATE struct { int dummyUserContext; }
|
||||
#define GLFW_WAYLAND_WINDOW_STATE _GLFWwindowWayland wl;
|
||||
#define GLFW_WAYLAND_LIBRARY_WINDOW_STATE _GLFWlibraryWayland wl;
|
||||
#define GLFW_WAYLAND_MONITOR_STATE _GLFWmonitorWayland wl;
|
||||
#define GLFW_WAYLAND_CURSOR_STATE _GLFWcursorWayland wl;
|
||||
|
||||
struct wl_cursor_image {
|
||||
uint32_t width;
|
||||
@ -180,24 +162,27 @@ typedef struct xkb_keymap* (* PFN_xkb_keymap_new_from_string)(struct xkb_context
|
||||
typedef void (* PFN_xkb_keymap_unref)(struct xkb_keymap*);
|
||||
typedef xkb_mod_index_t (* PFN_xkb_keymap_mod_get_index)(struct xkb_keymap*, const char*);
|
||||
typedef int (* PFN_xkb_keymap_key_repeats)(struct xkb_keymap*, xkb_keycode_t);
|
||||
typedef int (* PFN_xkb_keymap_key_get_syms_by_level)(struct xkb_keymap*,xkb_keycode_t,xkb_layout_index_t,xkb_level_index_t,const xkb_keysym_t**);
|
||||
typedef struct xkb_state* (* PFN_xkb_state_new)(struct xkb_keymap*);
|
||||
typedef void (* PFN_xkb_state_unref)(struct xkb_state*);
|
||||
typedef int (* PFN_xkb_state_key_get_syms)(struct xkb_state*, xkb_keycode_t, const xkb_keysym_t**);
|
||||
typedef enum xkb_state_component (* PFN_xkb_state_update_mask)(struct xkb_state*, xkb_mod_mask_t, xkb_mod_mask_t, xkb_mod_mask_t, xkb_layout_index_t, xkb_layout_index_t, xkb_layout_index_t);
|
||||
typedef xkb_mod_mask_t (* PFN_xkb_state_serialize_mods)(struct xkb_state*, enum xkb_state_component);
|
||||
typedef xkb_layout_index_t (* PFN_xkb_state_key_get_layout)(struct xkb_state*,xkb_keycode_t);
|
||||
#define xkb_context_new _glfw.wl.xkb.context_new
|
||||
#define xkb_context_unref _glfw.wl.xkb.context_unref
|
||||
#define xkb_keymap_new_from_string _glfw.wl.xkb.keymap_new_from_string
|
||||
#define xkb_keymap_unref _glfw.wl.xkb.keymap_unref
|
||||
#define xkb_keymap_mod_get_index _glfw.wl.xkb.keymap_mod_get_index
|
||||
#define xkb_keymap_key_repeats _glfw.wl.xkb.keymap_key_repeats
|
||||
#define xkb_keymap_key_get_syms_by_level _glfw.wl.xkb.keymap_key_get_syms_by_level
|
||||
#define xkb_state_new _glfw.wl.xkb.state_new
|
||||
#define xkb_state_unref _glfw.wl.xkb.state_unref
|
||||
#define xkb_state_key_get_syms _glfw.wl.xkb.state_key_get_syms
|
||||
#define xkb_state_update_mask _glfw.wl.xkb.state_update_mask
|
||||
#define xkb_state_serialize_mods _glfw.wl.xkb.state_serialize_mods
|
||||
#define xkb_state_key_get_layout _glfw.wl.xkb.state_key_get_layout
|
||||
|
||||
#ifdef HAVE_XKBCOMMON_COMPOSE_H
|
||||
typedef struct xkb_compose_table* (* PFN_xkb_compose_table_new_from_locale)(struct xkb_context*, const char*, enum xkb_compose_compile_flags);
|
||||
typedef void (* PFN_xkb_compose_table_unref)(struct xkb_compose_table*);
|
||||
typedef struct xkb_compose_state* (* PFN_xkb_compose_state_new)(struct xkb_compose_table*, enum xkb_compose_state_flags);
|
||||
@ -212,7 +197,6 @@ typedef xkb_keysym_t (* PFN_xkb_compose_state_get_one_sym)(struct xkb_compose_st
|
||||
#define xkb_compose_state_feed _glfw.wl.xkb.compose_state_feed
|
||||
#define xkb_compose_state_get_status _glfw.wl.xkb.compose_state_get_status
|
||||
#define xkb_compose_state_get_one_sym _glfw.wl.xkb.compose_state_get_one_sym
|
||||
#endif
|
||||
|
||||
#define _GLFW_DECORATION_WIDTH 4
|
||||
#define _GLFW_DECORATION_TOP 24
|
||||
@ -226,7 +210,6 @@ typedef enum _GLFWdecorationSideWayland
|
||||
leftDecoration,
|
||||
rightDecoration,
|
||||
bottomDecoration,
|
||||
|
||||
} _GLFWdecorationSideWayland;
|
||||
|
||||
typedef struct _GLFWdecorationWayland
|
||||
@ -234,7 +217,6 @@ typedef struct _GLFWdecorationWayland
|
||||
struct wl_surface* surface;
|
||||
struct wl_subsurface* subsurface;
|
||||
struct wp_viewport* viewport;
|
||||
|
||||
} _GLFWdecorationWayland;
|
||||
|
||||
// Wayland-specific per-window data
|
||||
@ -283,7 +265,6 @@ typedef struct _GLFWwindowWayland
|
||||
_GLFWdecorationWayland top, left, right, bottom;
|
||||
int focus;
|
||||
} decorations;
|
||||
|
||||
} _GLFWwindowWayland;
|
||||
|
||||
// Wayland-specific global data
|
||||
@ -331,6 +312,7 @@ typedef struct _GLFWlibraryWayland
|
||||
int timerfd;
|
||||
short int keycodes[256];
|
||||
short int scancodes[GLFW_KEY_LAST + 1];
|
||||
char keynames[GLFW_KEY_LAST + 1][5];
|
||||
|
||||
struct {
|
||||
void* handle;
|
||||
@ -338,9 +320,7 @@ typedef struct _GLFWlibraryWayland
|
||||
struct xkb_keymap* keymap;
|
||||
struct xkb_state* state;
|
||||
|
||||
#ifdef HAVE_XKBCOMMON_COMPOSE_H
|
||||
struct xkb_compose_state* composeState;
|
||||
#endif
|
||||
|
||||
xkb_mod_mask_t controlMask;
|
||||
xkb_mod_mask_t altMask;
|
||||
@ -356,13 +336,14 @@ typedef struct _GLFWlibraryWayland
|
||||
PFN_xkb_keymap_unref keymap_unref;
|
||||
PFN_xkb_keymap_mod_get_index keymap_mod_get_index;
|
||||
PFN_xkb_keymap_key_repeats keymap_key_repeats;
|
||||
PFN_xkb_keymap_key_get_syms_by_level keymap_key_get_syms_by_level;
|
||||
PFN_xkb_state_new state_new;
|
||||
PFN_xkb_state_unref state_unref;
|
||||
PFN_xkb_state_key_get_syms state_key_get_syms;
|
||||
PFN_xkb_state_update_mask state_update_mask;
|
||||
PFN_xkb_state_serialize_mods state_serialize_mods;
|
||||
PFN_xkb_state_key_get_layout state_key_get_layout;
|
||||
|
||||
#ifdef HAVE_XKBCOMMON_COMPOSE_H
|
||||
PFN_xkb_compose_table_new_from_locale compose_table_new_from_locale;
|
||||
PFN_xkb_compose_table_unref compose_table_unref;
|
||||
PFN_xkb_compose_state_new compose_state_new;
|
||||
@ -370,7 +351,6 @@ typedef struct _GLFWlibraryWayland
|
||||
PFN_xkb_compose_state_feed compose_state_feed;
|
||||
PFN_xkb_compose_state_get_status compose_state_get_status;
|
||||
PFN_xkb_compose_state_get_one_sym compose_state_get_one_sym;
|
||||
#endif
|
||||
} xkb;
|
||||
|
||||
_GLFWwindow* pointerFocus;
|
||||
@ -382,7 +362,6 @@ typedef struct _GLFWlibraryWayland
|
||||
PFN_wl_display_cancel_read display_cancel_read;
|
||||
PFN_wl_display_dispatch_pending display_dispatch_pending;
|
||||
PFN_wl_display_read_events display_read_events;
|
||||
PFN_wl_display_connect display_connect;
|
||||
PFN_wl_display_disconnect display_disconnect;
|
||||
PFN_wl_display_roundtrip display_roundtrip;
|
||||
PFN_wl_display_get_fd display_get_fd;
|
||||
@ -414,7 +393,6 @@ typedef struct _GLFWlibraryWayland
|
||||
PFN_wl_egl_window_destroy window_destroy;
|
||||
PFN_wl_egl_window_resize window_resize;
|
||||
} egl;
|
||||
|
||||
} _GLFWlibraryWayland;
|
||||
|
||||
// Wayland-specific per-monitor data
|
||||
@ -428,7 +406,6 @@ typedef struct _GLFWmonitorWayland
|
||||
int x;
|
||||
int y;
|
||||
int scale;
|
||||
|
||||
} _GLFWmonitorWayland;
|
||||
|
||||
// Wayland-specific per-cursor data
|
||||
@ -443,6 +420,81 @@ typedef struct _GLFWcursorWayland
|
||||
int currentImage;
|
||||
} _GLFWcursorWayland;
|
||||
|
||||
GLFWbool _glfwConnectWayland(int platformID, _GLFWplatform* platform);
|
||||
int _glfwInitWayland(void);
|
||||
void _glfwTerminateWayland(void);
|
||||
|
||||
int _glfwCreateWindowWayland(_GLFWwindow* window, const _GLFWwndconfig* wndconfig, const _GLFWctxconfig* ctxconfig, const _GLFWfbconfig* fbconfig);
|
||||
void _glfwDestroyWindowWayland(_GLFWwindow* window);
|
||||
void _glfwSetWindowTitleWayland(_GLFWwindow* window, const char* title);
|
||||
void _glfwSetWindowIconWayland(_GLFWwindow* window, int count, const GLFWimage* images);
|
||||
void _glfwGetWindowPosWayland(_GLFWwindow* window, int* xpos, int* ypos);
|
||||
void _glfwSetWindowPosWayland(_GLFWwindow* window, int xpos, int ypos);
|
||||
void _glfwGetWindowSizeWayland(_GLFWwindow* window, int* width, int* height);
|
||||
void _glfwSetWindowSizeWayland(_GLFWwindow* window, int width, int height);
|
||||
void _glfwSetWindowSizeLimitsWayland(_GLFWwindow* window, int minwidth, int minheight, int maxwidth, int maxheight);
|
||||
void _glfwSetWindowAspectRatioWayland(_GLFWwindow* window, int numer, int denom);
|
||||
void _glfwGetFramebufferSizeWayland(_GLFWwindow* window, int* width, int* height);
|
||||
void _glfwGetWindowFrameSizeWayland(_GLFWwindow* window, int* left, int* top, int* right, int* bottom);
|
||||
void _glfwGetWindowContentScaleWayland(_GLFWwindow* window, float* xscale, float* yscale);
|
||||
void _glfwIconifyWindowWayland(_GLFWwindow* window);
|
||||
void _glfwRestoreWindowWayland(_GLFWwindow* window);
|
||||
void _glfwMaximizeWindowWayland(_GLFWwindow* window);
|
||||
void _glfwShowWindowWayland(_GLFWwindow* window);
|
||||
void _glfwHideWindowWayland(_GLFWwindow* window);
|
||||
void _glfwRequestWindowAttentionWayland(_GLFWwindow* window);
|
||||
void _glfwFocusWindowWayland(_GLFWwindow* window);
|
||||
void _glfwSetWindowMonitorWayland(_GLFWwindow* window, _GLFWmonitor* monitor, int xpos, int ypos, int width, int height, int refreshRate);
|
||||
int _glfwWindowFocusedWayland(_GLFWwindow* window);
|
||||
int _glfwWindowIconifiedWayland(_GLFWwindow* window);
|
||||
int _glfwWindowVisibleWayland(_GLFWwindow* window);
|
||||
int _glfwWindowMaximizedWayland(_GLFWwindow* window);
|
||||
int _glfwWindowHoveredWayland(_GLFWwindow* window);
|
||||
int _glfwFramebufferTransparentWayland(_GLFWwindow* window);
|
||||
void _glfwSetWindowResizableWayland(_GLFWwindow* window, GLFWbool enabled);
|
||||
void _glfwSetWindowDecoratedWayland(_GLFWwindow* window, GLFWbool enabled);
|
||||
void _glfwSetWindowFloatingWayland(_GLFWwindow* window, GLFWbool enabled);
|
||||
float _glfwGetWindowOpacityWayland(_GLFWwindow* window);
|
||||
void _glfwSetWindowOpacityWayland(_GLFWwindow* window, float opacity);
|
||||
void _glfwSetWindowMousePassthroughWayland(_GLFWwindow* window, GLFWbool enabled);
|
||||
|
||||
void _glfwSetRawMouseMotionWayland(_GLFWwindow *window, GLFWbool enabled);
|
||||
GLFWbool _glfwRawMouseMotionSupportedWayland(void);
|
||||
|
||||
void _glfwPollEventsWayland(void);
|
||||
void _glfwWaitEventsWayland(void);
|
||||
void _glfwWaitEventsTimeoutWayland(double timeout);
|
||||
void _glfwPostEmptyEventWayland(void);
|
||||
|
||||
void _glfwGetCursorPosWayland(_GLFWwindow* window, double* xpos, double* ypos);
|
||||
void _glfwSetCursorPosWayland(_GLFWwindow* window, double xpos, double ypos);
|
||||
void _glfwSetCursorModeWayland(_GLFWwindow* window, int mode);
|
||||
const char* _glfwGetScancodeNameWayland(int scancode);
|
||||
int _glfwGetKeyScancodeWayland(int key);
|
||||
int _glfwCreateCursorWayland(_GLFWcursor* cursor, const GLFWimage* image, int xhot, int yhot);
|
||||
int _glfwCreateStandardCursorWayland(_GLFWcursor* cursor, int shape);
|
||||
void _glfwDestroyCursorWayland(_GLFWcursor* cursor);
|
||||
void _glfwSetCursorWayland(_GLFWwindow* window, _GLFWcursor* cursor);
|
||||
void _glfwSetClipboardStringWayland(const char* string);
|
||||
const char* _glfwGetClipboardStringWayland(void);
|
||||
|
||||
EGLenum _glfwGetEGLPlatformWayland(EGLint** attribs);
|
||||
EGLNativeDisplayType _glfwGetEGLNativeDisplayWayland(void);
|
||||
EGLNativeWindowType _glfwGetEGLNativeWindowWayland(_GLFWwindow* window);
|
||||
|
||||
void _glfwGetRequiredInstanceExtensionsWayland(char** extensions);
|
||||
int _glfwGetPhysicalDevicePresentationSupportWayland(VkInstance instance, VkPhysicalDevice device, uint32_t queuefamily);
|
||||
VkResult _glfwCreateWindowSurfaceWayland(VkInstance instance, _GLFWwindow* window, const VkAllocationCallbacks* allocator, VkSurfaceKHR* surface);
|
||||
|
||||
void _glfwFreeMonitorWayland(_GLFWmonitor* monitor);
|
||||
void _glfwGetMonitorPosWayland(_GLFWmonitor* monitor, int* xpos, int* ypos);
|
||||
void _glfwGetMonitorContentScaleWayland(_GLFWmonitor* monitor, float* xscale, float* yscale);
|
||||
void _glfwGetMonitorWorkareaWayland(_GLFWmonitor* monitor, int* xpos, int* ypos, int* width, int* height);
|
||||
GLFWvidmode* _glfwGetVideoModesWayland(_GLFWmonitor* monitor, int* count);
|
||||
void _glfwGetVideoModeWayland(_GLFWmonitor* monitor, GLFWvidmode* mode);
|
||||
GLFWbool _glfwGetGammaRampWayland(_GLFWmonitor* monitor, GLFWgammaramp* ramp);
|
||||
void _glfwSetGammaRampWayland(_GLFWmonitor* monitor, const GLFWgammaramp* ramp);
|
||||
|
||||
void _glfwAddOutputWayland(uint32_t name, uint32_t version);
|
||||
GLFWbool _glfwInputTextWayland(_GLFWwindow* window, uint32_t scancode);
|
||||
|
||||
|
499
src/wl_window.c
499
src/wl_window.c
@ -144,9 +144,8 @@ static struct wl_buffer* createShmBuffer(const GLFWimage* image)
|
||||
int stride = image->width * 4;
|
||||
int length = image->width * image->height * 4;
|
||||
void* data;
|
||||
int fd, i;
|
||||
|
||||
fd = createAnonymousFile(length);
|
||||
const int fd = createAnonymousFile(length);
|
||||
if (fd < 0)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
@ -169,7 +168,7 @@ static struct wl_buffer* createShmBuffer(const GLFWimage* image)
|
||||
close(fd);
|
||||
unsigned char* source = (unsigned char*) image->pixels;
|
||||
unsigned char* target = data;
|
||||
for (i = 0; i < image->width * image->height; i++, source += 4)
|
||||
for (int i = 0; i < image->width * image->height; i++, source += 4)
|
||||
{
|
||||
unsigned int alpha = source[3];
|
||||
|
||||
@ -346,27 +345,21 @@ static void resizeWindow(_GLFWwindow* window)
|
||||
|
||||
static void checkScaleChange(_GLFWwindow* window)
|
||||
{
|
||||
int scale = 1;
|
||||
int i;
|
||||
int monitorScale;
|
||||
|
||||
// Check if we will be able to set the buffer scale or not.
|
||||
if (_glfw.wl.compositorVersion < 3)
|
||||
return;
|
||||
|
||||
// Get the scale factor from the highest scale monitor.
|
||||
for (i = 0; i < window->wl.monitorsCount; ++i)
|
||||
{
|
||||
monitorScale = window->wl.monitors[i]->wl.scale;
|
||||
if (scale < monitorScale)
|
||||
scale = monitorScale;
|
||||
}
|
||||
int maxScale = 1;
|
||||
|
||||
for (int i = 0; i < window->wl.monitorsCount; i++)
|
||||
maxScale = _glfw_max(window->wl.monitors[i]->wl.scale, maxScale);
|
||||
|
||||
// Only change the framebuffer size if the scale changed.
|
||||
if (scale != window->wl.scale)
|
||||
if (window->wl.scale != maxScale)
|
||||
{
|
||||
window->wl.scale = scale;
|
||||
wl_surface_set_buffer_scale(window->wl.surface, scale);
|
||||
window->wl.scale = maxScale;
|
||||
wl_surface_set_buffer_scale(window->wl.surface, maxScale);
|
||||
resizeWindow(window);
|
||||
}
|
||||
}
|
||||
@ -397,10 +390,9 @@ static void surfaceHandleLeave(void *data,
|
||||
{
|
||||
_GLFWwindow* window = data;
|
||||
_GLFWmonitor* monitor = wl_output_get_user_data(output);
|
||||
GLFWbool found;
|
||||
int i;
|
||||
GLFWbool found = GLFW_FALSE;
|
||||
|
||||
for (i = 0, found = GLFW_FALSE; i < window->wl.monitorsCount - 1; ++i)
|
||||
for (int i = 0; i < window->wl.monitorsCount - 1; ++i)
|
||||
{
|
||||
if (monitor == window->wl.monitors[i])
|
||||
found = GLFW_TRUE;
|
||||
@ -435,35 +427,6 @@ static void setIdleInhibitor(_GLFWwindow* window, GLFWbool enable)
|
||||
}
|
||||
}
|
||||
|
||||
static GLFWbool createSurface(_GLFWwindow* window,
|
||||
const _GLFWwndconfig* wndconfig)
|
||||
{
|
||||
window->wl.surface = wl_compositor_create_surface(_glfw.wl.compositor);
|
||||
if (!window->wl.surface)
|
||||
return GLFW_FALSE;
|
||||
|
||||
wl_surface_add_listener(window->wl.surface,
|
||||
&surfaceListener,
|
||||
window);
|
||||
|
||||
wl_surface_set_user_data(window->wl.surface, window);
|
||||
|
||||
window->wl.native = wl_egl_window_create(window->wl.surface,
|
||||
wndconfig->width,
|
||||
wndconfig->height);
|
||||
if (!window->wl.native)
|
||||
return GLFW_FALSE;
|
||||
|
||||
window->wl.width = wndconfig->width;
|
||||
window->wl.height = wndconfig->height;
|
||||
window->wl.scale = 1;
|
||||
|
||||
if (!window->wl.transparent)
|
||||
setOpaqueRegion(window);
|
||||
|
||||
return GLFW_TRUE;
|
||||
}
|
||||
|
||||
static void setFullscreen(_GLFWwindow* window, _GLFWmonitor* monitor,
|
||||
int refreshRate)
|
||||
{
|
||||
@ -526,7 +489,7 @@ static void xdgToplevelHandleConfigure(void* data,
|
||||
}
|
||||
|
||||
_glfwInputWindowSize(window, width, height);
|
||||
_glfwPlatformSetWindowSize(window, width, height);
|
||||
_glfwSetWindowSizeWayland(window, width, height);
|
||||
_glfwInputWindowDamage(window);
|
||||
}
|
||||
|
||||
@ -534,13 +497,12 @@ static void xdgToplevelHandleConfigure(void* data,
|
||||
{
|
||||
if (!activated || !fullscreen)
|
||||
{
|
||||
_glfwPlatformIconifyWindow(window);
|
||||
_glfwIconifyWindowWayland(window);
|
||||
window->wl.wasFullscreen = GLFW_FALSE;
|
||||
}
|
||||
}
|
||||
if (fullscreen && activated)
|
||||
window->wl.wasFullscreen = GLFW_TRUE;
|
||||
_glfwInputWindowFocus(window, activated);
|
||||
}
|
||||
|
||||
static void xdgToplevelHandleClose(void* data,
|
||||
@ -648,6 +610,46 @@ static GLFWbool createXdgSurface(_GLFWwindow* window)
|
||||
return GLFW_TRUE;
|
||||
}
|
||||
|
||||
static GLFWbool createSurface(_GLFWwindow* window,
|
||||
const _GLFWwndconfig* wndconfig,
|
||||
const _GLFWfbconfig* fbconfig)
|
||||
{
|
||||
window->wl.surface = wl_compositor_create_surface(_glfw.wl.compositor);
|
||||
if (!window->wl.surface)
|
||||
return GLFW_FALSE;
|
||||
|
||||
wl_surface_add_listener(window->wl.surface,
|
||||
&surfaceListener,
|
||||
window);
|
||||
|
||||
wl_surface_set_user_data(window->wl.surface, window);
|
||||
|
||||
window->wl.native = wl_egl_window_create(window->wl.surface,
|
||||
wndconfig->width,
|
||||
wndconfig->height);
|
||||
if (!window->wl.native)
|
||||
return GLFW_FALSE;
|
||||
|
||||
window->wl.width = wndconfig->width;
|
||||
window->wl.height = wndconfig->height;
|
||||
window->wl.scale = 1;
|
||||
window->wl.title = _glfw_strdup(wndconfig->title);
|
||||
|
||||
window->wl.transparent = fbconfig->transparent;
|
||||
if (!window->wl.transparent)
|
||||
setOpaqueRegion(window);
|
||||
|
||||
if (window->monitor || wndconfig->visible)
|
||||
{
|
||||
if (!createXdgSurface(window))
|
||||
return GLFW_FALSE;
|
||||
|
||||
window->wl.visible = GLFW_TRUE;
|
||||
}
|
||||
|
||||
return GLFW_TRUE;
|
||||
}
|
||||
|
||||
static void setCursorImage(_GLFWwindow* window,
|
||||
_GLFWcursorWayland* cursorWayland)
|
||||
{
|
||||
@ -710,93 +712,115 @@ static void incrementCursorImage(_GLFWwindow* window)
|
||||
}
|
||||
}
|
||||
|
||||
static void handleEvents(int timeout)
|
||||
static GLFWbool flushDisplay(void)
|
||||
{
|
||||
struct wl_display* display = _glfw.wl.display;
|
||||
struct pollfd fds[] = {
|
||||
{ wl_display_get_fd(display), POLLIN },
|
||||
while (wl_display_flush(_glfw.wl.display) == -1)
|
||||
{
|
||||
if (errno != EAGAIN)
|
||||
return GLFW_FALSE;
|
||||
|
||||
struct pollfd fd = { wl_display_get_fd(_glfw.wl.display), POLLOUT };
|
||||
|
||||
while (poll(&fd, 1, -1) == -1)
|
||||
{
|
||||
if (errno != EINTR && errno != EAGAIN)
|
||||
return GLFW_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return GLFW_TRUE;
|
||||
}
|
||||
|
||||
static void handleEvents(double* timeout)
|
||||
{
|
||||
GLFWbool event = GLFW_FALSE;
|
||||
struct pollfd fds[] =
|
||||
{
|
||||
{ wl_display_get_fd(_glfw.wl.display), POLLIN },
|
||||
{ _glfw.wl.timerfd, POLLIN },
|
||||
{ _glfw.wl.cursorTimerfd, POLLIN },
|
||||
};
|
||||
ssize_t read_ret;
|
||||
uint64_t repeats, i;
|
||||
|
||||
while (wl_display_prepare_read(display) != 0)
|
||||
wl_display_dispatch_pending(display);
|
||||
|
||||
// If an error different from EAGAIN happens, we have likely been
|
||||
// disconnected from the Wayland session, try to handle that the best we
|
||||
// can.
|
||||
if (wl_display_flush(display) < 0 && errno != EAGAIN)
|
||||
while (!event)
|
||||
{
|
||||
_GLFWwindow* window = _glfw.windowListHead;
|
||||
while (window)
|
||||
while (wl_display_prepare_read(_glfw.wl.display) != 0)
|
||||
wl_display_dispatch_pending(_glfw.wl.display);
|
||||
|
||||
// If an error other than EAGAIN happens, we have likely been disconnected
|
||||
// from the Wayland session; try to handle that the best we can.
|
||||
if (!flushDisplay())
|
||||
{
|
||||
_glfwInputWindowCloseRequest(window);
|
||||
window = window->next;
|
||||
}
|
||||
wl_display_cancel_read(display);
|
||||
return;
|
||||
}
|
||||
wl_display_cancel_read(_glfw.wl.display);
|
||||
|
||||
_GLFWwindow* window = _glfw.windowListHead;
|
||||
while (window)
|
||||
{
|
||||
_glfwInputWindowCloseRequest(window);
|
||||
window = window->next;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_glfwPollPOSIX(fds, 3, timeout))
|
||||
{
|
||||
wl_display_cancel_read(_glfw.wl.display);
|
||||
return;
|
||||
}
|
||||
|
||||
if (poll(fds, 3, timeout) > 0)
|
||||
{
|
||||
if (fds[0].revents & POLLIN)
|
||||
{
|
||||
wl_display_read_events(display);
|
||||
wl_display_dispatch_pending(display);
|
||||
wl_display_read_events(_glfw.wl.display);
|
||||
if (wl_display_dispatch_pending(_glfw.wl.display) > 0)
|
||||
event = GLFW_TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
wl_display_cancel_read(display);
|
||||
}
|
||||
wl_display_cancel_read(_glfw.wl.display);
|
||||
|
||||
if (fds[1].revents & POLLIN)
|
||||
{
|
||||
read_ret = read(_glfw.wl.timerfd, &repeats, sizeof(repeats));
|
||||
if (read_ret != 8)
|
||||
return;
|
||||
uint64_t repeats;
|
||||
|
||||
if (_glfw.wl.keyboardFocus)
|
||||
if (read(_glfw.wl.timerfd, &repeats, sizeof(repeats)) == 8)
|
||||
{
|
||||
for (i = 0; i < repeats; ++i)
|
||||
for (uint64_t i = 0; i < repeats; i++)
|
||||
{
|
||||
_glfwInputKey(_glfw.wl.keyboardFocus,
|
||||
_glfw.wl.keyboardLastKey,
|
||||
_glfw.wl.keyboardLastScancode,
|
||||
GLFW_REPEAT,
|
||||
GLFW_PRESS,
|
||||
_glfw.wl.xkb.modifiers);
|
||||
_glfwInputTextWayland(_glfw.wl.keyboardFocus,
|
||||
_glfw.wl.keyboardLastScancode);
|
||||
}
|
||||
|
||||
event = GLFW_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if (fds[2].revents & POLLIN)
|
||||
{
|
||||
read_ret = read(_glfw.wl.cursorTimerfd, &repeats, sizeof(repeats));
|
||||
if (read_ret != 8)
|
||||
return;
|
||||
uint64_t repeats;
|
||||
|
||||
incrementCursorImage(_glfw.wl.pointerFocus);
|
||||
if (read(_glfw.wl.cursorTimerfd, &repeats, sizeof(repeats)) == 8)
|
||||
{
|
||||
incrementCursorImage(_glfw.wl.pointerFocus);
|
||||
event = GLFW_TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
wl_display_cancel_read(display);
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
////// GLFW platform API //////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int _glfwPlatformCreateWindow(_GLFWwindow* window,
|
||||
const _GLFWwndconfig* wndconfig,
|
||||
const _GLFWctxconfig* ctxconfig,
|
||||
const _GLFWfbconfig* fbconfig)
|
||||
int _glfwCreateWindowWayland(_GLFWwindow* window,
|
||||
const _GLFWwndconfig* wndconfig,
|
||||
const _GLFWctxconfig* ctxconfig,
|
||||
const _GLFWfbconfig* fbconfig)
|
||||
{
|
||||
window->wl.transparent = fbconfig->transparent;
|
||||
|
||||
if (!createSurface(window, wndconfig))
|
||||
if (!createSurface(window, wndconfig, fbconfig))
|
||||
return GLFW_FALSE;
|
||||
|
||||
if (ctxconfig->client != GLFW_NO_API)
|
||||
@ -818,33 +842,10 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
|
||||
}
|
||||
}
|
||||
|
||||
if (wndconfig->title)
|
||||
window->wl.title = _glfw_strdup(wndconfig->title);
|
||||
|
||||
if (wndconfig->visible)
|
||||
{
|
||||
if (!createXdgSurface(window))
|
||||
return GLFW_FALSE;
|
||||
|
||||
window->wl.visible = GLFW_TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
window->wl.xdg.surface = NULL;
|
||||
window->wl.xdg.toplevel = NULL;
|
||||
window->wl.visible = GLFW_FALSE;
|
||||
}
|
||||
|
||||
window->wl.currentCursor = NULL;
|
||||
|
||||
window->wl.monitors = _glfw_calloc(1, sizeof(_GLFWmonitor*));
|
||||
window->wl.monitorsCount = 0;
|
||||
window->wl.monitorsSize = 1;
|
||||
|
||||
return GLFW_TRUE;
|
||||
}
|
||||
|
||||
void _glfwPlatformDestroyWindow(_GLFWwindow* window)
|
||||
void _glfwDestroyWindowWayland(_GLFWwindow* window)
|
||||
{
|
||||
if (window == _glfw.wl.pointerFocus)
|
||||
{
|
||||
@ -886,7 +887,7 @@ void _glfwPlatformDestroyWindow(_GLFWwindow* window)
|
||||
_glfw_free(window->wl.monitors);
|
||||
}
|
||||
|
||||
void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title)
|
||||
void _glfwSetWindowTitleWayland(_GLFWwindow* window, const char* title)
|
||||
{
|
||||
if (window->wl.title)
|
||||
_glfw_free(window->wl.title);
|
||||
@ -895,14 +896,14 @@ void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title)
|
||||
xdg_toplevel_set_title(window->wl.xdg.toplevel, title);
|
||||
}
|
||||
|
||||
void _glfwPlatformSetWindowIcon(_GLFWwindow* window,
|
||||
int count, const GLFWimage* images)
|
||||
void _glfwSetWindowIconWayland(_GLFWwindow* window,
|
||||
int count, const GLFWimage* images)
|
||||
{
|
||||
_glfwInputError(GLFW_FEATURE_UNAVAILABLE,
|
||||
"Wayland: The platform does not support setting the window icon");
|
||||
}
|
||||
|
||||
void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos)
|
||||
void _glfwGetWindowPosWayland(_GLFWwindow* window, int* xpos, int* ypos)
|
||||
{
|
||||
// A Wayland client is not aware of its position, so just warn and leave it
|
||||
// as (0, 0)
|
||||
@ -911,7 +912,7 @@ void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos)
|
||||
"Wayland: The platform does not provide the window position");
|
||||
}
|
||||
|
||||
void _glfwPlatformSetWindowPos(_GLFWwindow* window, int xpos, int ypos)
|
||||
void _glfwSetWindowPosWayland(_GLFWwindow* window, int xpos, int ypos)
|
||||
{
|
||||
// A Wayland client can not set its position, so just warn
|
||||
|
||||
@ -919,7 +920,7 @@ void _glfwPlatformSetWindowPos(_GLFWwindow* window, int xpos, int ypos)
|
||||
"Wayland: The platform does not support setting the window position");
|
||||
}
|
||||
|
||||
void _glfwPlatformGetWindowSize(_GLFWwindow* window, int* width, int* height)
|
||||
void _glfwGetWindowSizeWayland(_GLFWwindow* window, int* width, int* height)
|
||||
{
|
||||
if (width)
|
||||
*width = window->wl.width;
|
||||
@ -927,16 +928,16 @@ void _glfwPlatformGetWindowSize(_GLFWwindow* window, int* width, int* height)
|
||||
*height = window->wl.height;
|
||||
}
|
||||
|
||||
void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
|
||||
void _glfwSetWindowSizeWayland(_GLFWwindow* window, int width, int height)
|
||||
{
|
||||
window->wl.width = width;
|
||||
window->wl.height = height;
|
||||
resizeWindow(window);
|
||||
}
|
||||
|
||||
void _glfwPlatformSetWindowSizeLimits(_GLFWwindow* window,
|
||||
int minwidth, int minheight,
|
||||
int maxwidth, int maxheight)
|
||||
void _glfwSetWindowSizeLimitsWayland(_GLFWwindow* window,
|
||||
int minwidth, int minheight,
|
||||
int maxwidth, int maxheight)
|
||||
{
|
||||
if (window->wl.xdg.toplevel)
|
||||
{
|
||||
@ -950,8 +951,7 @@ void _glfwPlatformSetWindowSizeLimits(_GLFWwindow* window,
|
||||
}
|
||||
}
|
||||
|
||||
void _glfwPlatformSetWindowAspectRatio(_GLFWwindow* window,
|
||||
int numer, int denom)
|
||||
void _glfwSetWindowAspectRatioWayland(_GLFWwindow* window, int numer, int denom)
|
||||
{
|
||||
// TODO: find out how to trigger a resize.
|
||||
// The actual limits are checked in the xdg_toplevel::configure handler.
|
||||
@ -959,19 +959,18 @@ void _glfwPlatformSetWindowAspectRatio(_GLFWwindow* window,
|
||||
"Wayland: Window aspect ratio not yet implemented");
|
||||
}
|
||||
|
||||
void _glfwPlatformGetFramebufferSize(_GLFWwindow* window,
|
||||
int* width, int* height)
|
||||
void _glfwGetFramebufferSizeWayland(_GLFWwindow* window, int* width, int* height)
|
||||
{
|
||||
_glfwPlatformGetWindowSize(window, width, height);
|
||||
_glfwGetWindowSizeWayland(window, width, height);
|
||||
if (width)
|
||||
*width *= window->wl.scale;
|
||||
if (height)
|
||||
*height *= window->wl.scale;
|
||||
}
|
||||
|
||||
void _glfwPlatformGetWindowFrameSize(_GLFWwindow* window,
|
||||
int* left, int* top,
|
||||
int* right, int* bottom)
|
||||
void _glfwGetWindowFrameSizeWayland(_GLFWwindow* window,
|
||||
int* left, int* top,
|
||||
int* right, int* bottom)
|
||||
{
|
||||
if (window->decorated && !window->monitor && !window->wl.decorations.serverSide)
|
||||
{
|
||||
@ -986,8 +985,8 @@ void _glfwPlatformGetWindowFrameSize(_GLFWwindow* window,
|
||||
}
|
||||
}
|
||||
|
||||
void _glfwPlatformGetWindowContentScale(_GLFWwindow* window,
|
||||
float* xscale, float* yscale)
|
||||
void _glfwGetWindowContentScaleWayland(_GLFWwindow* window,
|
||||
float* xscale, float* yscale)
|
||||
{
|
||||
if (xscale)
|
||||
*xscale = (float) window->wl.scale;
|
||||
@ -995,13 +994,13 @@ void _glfwPlatformGetWindowContentScale(_GLFWwindow* window,
|
||||
*yscale = (float) window->wl.scale;
|
||||
}
|
||||
|
||||
void _glfwPlatformIconifyWindow(_GLFWwindow* window)
|
||||
void _glfwIconifyWindowWayland(_GLFWwindow* window)
|
||||
{
|
||||
if (window->wl.xdg.toplevel)
|
||||
xdg_toplevel_set_minimized(window->wl.xdg.toplevel);
|
||||
}
|
||||
|
||||
void _glfwPlatformRestoreWindow(_GLFWwindow* window)
|
||||
void _glfwRestoreWindowWayland(_GLFWwindow* window)
|
||||
{
|
||||
if (window->wl.xdg.toplevel)
|
||||
{
|
||||
@ -1016,7 +1015,7 @@ void _glfwPlatformRestoreWindow(_GLFWwindow* window)
|
||||
window->wl.maximized = GLFW_FALSE;
|
||||
}
|
||||
|
||||
void _glfwPlatformMaximizeWindow(_GLFWwindow* window)
|
||||
void _glfwMaximizeWindowWayland(_GLFWwindow* window)
|
||||
{
|
||||
if (window->wl.xdg.toplevel)
|
||||
{
|
||||
@ -1025,45 +1024,48 @@ void _glfwPlatformMaximizeWindow(_GLFWwindow* window)
|
||||
window->wl.maximized = GLFW_TRUE;
|
||||
}
|
||||
|
||||
void _glfwPlatformShowWindow(_GLFWwindow* window)
|
||||
void _glfwShowWindowWayland(_GLFWwindow* window)
|
||||
{
|
||||
if (!window->wl.visible)
|
||||
{
|
||||
createXdgSurface(window);
|
||||
// NOTE: The XDG surface and role are created here so command-line applications
|
||||
// with off-screen windows do not appear in for example the Unity dock
|
||||
if (!window->wl.xdg.toplevel)
|
||||
createXdgSurface(window);
|
||||
|
||||
window->wl.visible = GLFW_TRUE;
|
||||
_glfwInputWindowDamage(window);
|
||||
}
|
||||
}
|
||||
|
||||
void _glfwPlatformHideWindow(_GLFWwindow* window)
|
||||
void _glfwHideWindowWayland(_GLFWwindow* window)
|
||||
{
|
||||
if (window->wl.xdg.toplevel)
|
||||
if (window->wl.visible)
|
||||
{
|
||||
xdg_toplevel_destroy(window->wl.xdg.toplevel);
|
||||
xdg_surface_destroy(window->wl.xdg.surface);
|
||||
window->wl.xdg.toplevel = NULL;
|
||||
window->wl.xdg.surface = NULL;
|
||||
window->wl.visible = GLFW_FALSE;
|
||||
wl_surface_attach(window->wl.surface, NULL, 0, 0);
|
||||
wl_surface_commit(window->wl.surface);
|
||||
}
|
||||
window->wl.visible = GLFW_FALSE;
|
||||
}
|
||||
|
||||
void _glfwPlatformRequestWindowAttention(_GLFWwindow* window)
|
||||
void _glfwRequestWindowAttentionWayland(_GLFWwindow* window)
|
||||
{
|
||||
// TODO
|
||||
_glfwInputError(GLFW_FEATURE_UNIMPLEMENTED,
|
||||
"Wayland: Window attention request not implemented yet");
|
||||
}
|
||||
|
||||
void _glfwPlatformFocusWindow(_GLFWwindow* window)
|
||||
void _glfwFocusWindowWayland(_GLFWwindow* window)
|
||||
{
|
||||
_glfwInputError(GLFW_FEATURE_UNAVAILABLE,
|
||||
"Wayland: The platform does not support setting the input focus");
|
||||
}
|
||||
|
||||
void _glfwPlatformSetWindowMonitor(_GLFWwindow* window,
|
||||
_GLFWmonitor* monitor,
|
||||
int xpos, int ypos,
|
||||
int width, int height,
|
||||
int refreshRate)
|
||||
void _glfwSetWindowMonitorWayland(_GLFWwindow* window,
|
||||
_GLFWmonitor* monitor,
|
||||
int xpos, int ypos,
|
||||
int width, int height,
|
||||
int refreshRate)
|
||||
{
|
||||
if (monitor)
|
||||
{
|
||||
@ -1080,46 +1082,46 @@ void _glfwPlatformSetWindowMonitor(_GLFWwindow* window,
|
||||
_glfwInputWindowMonitor(window, monitor);
|
||||
}
|
||||
|
||||
int _glfwPlatformWindowFocused(_GLFWwindow* window)
|
||||
int _glfwWindowFocusedWayland(_GLFWwindow* window)
|
||||
{
|
||||
return _glfw.wl.keyboardFocus == window;
|
||||
}
|
||||
|
||||
int _glfwPlatformWindowIconified(_GLFWwindow* window)
|
||||
int _glfwWindowIconifiedWayland(_GLFWwindow* window)
|
||||
{
|
||||
// xdg-shell doesn’t give any way to request whether a surface is
|
||||
// iconified.
|
||||
return GLFW_FALSE;
|
||||
}
|
||||
|
||||
int _glfwPlatformWindowVisible(_GLFWwindow* window)
|
||||
int _glfwWindowVisibleWayland(_GLFWwindow* window)
|
||||
{
|
||||
return window->wl.visible;
|
||||
}
|
||||
|
||||
int _glfwPlatformWindowMaximized(_GLFWwindow* window)
|
||||
int _glfwWindowMaximizedWayland(_GLFWwindow* window)
|
||||
{
|
||||
return window->wl.maximized;
|
||||
}
|
||||
|
||||
int _glfwPlatformWindowHovered(_GLFWwindow* window)
|
||||
int _glfwWindowHoveredWayland(_GLFWwindow* window)
|
||||
{
|
||||
return window->wl.hovered;
|
||||
}
|
||||
|
||||
int _glfwPlatformFramebufferTransparent(_GLFWwindow* window)
|
||||
int _glfwFramebufferTransparentWayland(_GLFWwindow* window)
|
||||
{
|
||||
return window->wl.transparent;
|
||||
}
|
||||
|
||||
void _glfwPlatformSetWindowResizable(_GLFWwindow* window, GLFWbool enabled)
|
||||
void _glfwSetWindowResizableWayland(_GLFWwindow* window, GLFWbool enabled)
|
||||
{
|
||||
// TODO
|
||||
_glfwInputError(GLFW_FEATURE_UNIMPLEMENTED,
|
||||
"Wayland: Window attribute setting not implemented yet");
|
||||
}
|
||||
|
||||
void _glfwPlatformSetWindowDecorated(_GLFWwindow* window, GLFWbool enabled)
|
||||
void _glfwSetWindowDecoratedWayland(_GLFWwindow* window, GLFWbool enabled)
|
||||
{
|
||||
if (!window->monitor)
|
||||
{
|
||||
@ -1130,14 +1132,14 @@ void _glfwPlatformSetWindowDecorated(_GLFWwindow* window, GLFWbool enabled)
|
||||
}
|
||||
}
|
||||
|
||||
void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled)
|
||||
void _glfwSetWindowFloatingWayland(_GLFWwindow* window, GLFWbool enabled)
|
||||
{
|
||||
// TODO
|
||||
_glfwInputError(GLFW_FEATURE_UNIMPLEMENTED,
|
||||
"Wayland: Window attribute setting not implemented yet");
|
||||
}
|
||||
|
||||
void _glfwPlatformSetWindowMousePassthrough(_GLFWwindow* window, GLFWbool enabled)
|
||||
void _glfwSetWindowMousePassthroughWayland(_GLFWwindow* window, GLFWbool enabled)
|
||||
{
|
||||
if (enabled)
|
||||
{
|
||||
@ -1150,48 +1152,50 @@ void _glfwPlatformSetWindowMousePassthrough(_GLFWwindow* window, GLFWbool enable
|
||||
wl_surface_commit(window->wl.surface);
|
||||
}
|
||||
|
||||
float _glfwPlatformGetWindowOpacity(_GLFWwindow* window)
|
||||
float _glfwGetWindowOpacityWayland(_GLFWwindow* window)
|
||||
{
|
||||
return 1.f;
|
||||
}
|
||||
|
||||
void _glfwPlatformSetWindowOpacity(_GLFWwindow* window, float opacity)
|
||||
void _glfwSetWindowOpacityWayland(_GLFWwindow* window, float opacity)
|
||||
{
|
||||
_glfwInputError(GLFW_FEATURE_UNAVAILABLE,
|
||||
"Wayland: The platform does not support setting the window opacity");
|
||||
}
|
||||
|
||||
void _glfwPlatformSetRawMouseMotion(_GLFWwindow *window, GLFWbool enabled)
|
||||
void _glfwSetRawMouseMotionWayland(_GLFWwindow *window, GLFWbool enabled)
|
||||
{
|
||||
// This is handled in relativePointerHandleRelativeMotion
|
||||
}
|
||||
|
||||
GLFWbool _glfwPlatformRawMouseMotionSupported(void)
|
||||
GLFWbool _glfwRawMouseMotionSupportedWayland(void)
|
||||
{
|
||||
return GLFW_TRUE;
|
||||
}
|
||||
|
||||
void _glfwPlatformPollEvents(void)
|
||||
void _glfwPollEventsWayland(void)
|
||||
{
|
||||
handleEvents(0);
|
||||
double timeout = 0.0;
|
||||
handleEvents(&timeout);
|
||||
}
|
||||
|
||||
void _glfwPlatformWaitEvents(void)
|
||||
void _glfwWaitEventsWayland(void)
|
||||
{
|
||||
handleEvents(-1);
|
||||
handleEvents(NULL);
|
||||
}
|
||||
|
||||
void _glfwPlatformWaitEventsTimeout(double timeout)
|
||||
void _glfwWaitEventsTimeoutWayland(double timeout)
|
||||
{
|
||||
handleEvents((int) (timeout * 1e3));
|
||||
handleEvents(&timeout);
|
||||
}
|
||||
|
||||
void _glfwPlatformPostEmptyEvent(void)
|
||||
void _glfwPostEmptyEventWayland(void)
|
||||
{
|
||||
wl_display_sync(_glfw.wl.display);
|
||||
flushDisplay();
|
||||
}
|
||||
|
||||
void _glfwPlatformGetCursorPos(_GLFWwindow* window, double* xpos, double* ypos)
|
||||
void _glfwGetCursorPosWayland(_GLFWwindow* window, double* xpos, double* ypos)
|
||||
{
|
||||
if (xpos)
|
||||
*xpos = window->wl.cursorPosX;
|
||||
@ -1201,7 +1205,7 @@ void _glfwPlatformGetCursorPos(_GLFWwindow* window, double* xpos, double* ypos)
|
||||
|
||||
static GLFWbool isPointerLocked(_GLFWwindow* window);
|
||||
|
||||
void _glfwPlatformSetCursorPos(_GLFWwindow* window, double x, double y)
|
||||
void _glfwSetCursorPosWayland(_GLFWwindow* window, double x, double y)
|
||||
{
|
||||
if (isPointerLocked(window))
|
||||
{
|
||||
@ -1212,27 +1216,74 @@ void _glfwPlatformSetCursorPos(_GLFWwindow* window, double x, double y)
|
||||
}
|
||||
}
|
||||
|
||||
void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode)
|
||||
void _glfwSetCursorModeWayland(_GLFWwindow* window, int mode)
|
||||
{
|
||||
_glfwPlatformSetCursor(window, window->wl.currentCursor);
|
||||
_glfwSetCursorWayland(window, window->wl.currentCursor);
|
||||
}
|
||||
|
||||
const char* _glfwPlatformGetScancodeName(int scancode)
|
||||
const char* _glfwGetScancodeNameWayland(int scancode)
|
||||
{
|
||||
// TODO
|
||||
_glfwInputError(GLFW_FEATURE_UNIMPLEMENTED,
|
||||
"Wayland: Key names not yet implemented");
|
||||
return NULL;
|
||||
if (scancode < 0 || scancode > 255 ||
|
||||
_glfw.wl.keycodes[scancode] == GLFW_KEY_UNKNOWN)
|
||||
{
|
||||
_glfwInputError(GLFW_INVALID_VALUE,
|
||||
"Wayland: Invalid scancode %i",
|
||||
scancode);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const int key = _glfw.wl.keycodes[scancode];
|
||||
const xkb_keycode_t keycode = scancode + 8;
|
||||
const xkb_layout_index_t layout =
|
||||
xkb_state_key_get_layout(_glfw.wl.xkb.state, keycode);
|
||||
if (layout == XKB_LAYOUT_INVALID)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"Wayland: Failed to retrieve layout for key name");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const xkb_keysym_t* keysyms = NULL;
|
||||
xkb_keymap_key_get_syms_by_level(_glfw.wl.xkb.keymap,
|
||||
keycode,
|
||||
layout,
|
||||
0,
|
||||
&keysyms);
|
||||
if (keysyms == NULL)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"Wayland: Failed to retrieve keysym for key name");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const uint32_t codepoint = _glfwKeySym2Unicode(keysyms[0]);
|
||||
if (codepoint == GLFW_INVALID_CODEPOINT)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"Wayland: Failed to retrieve codepoint for key name");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const size_t count = _glfwEncodeUTF8(_glfw.wl.keynames[key], codepoint);
|
||||
if (count == 0)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"Wayland: Failed to encode codepoint for key name");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
_glfw.wl.keynames[key][count] = '\0';
|
||||
return _glfw.wl.keynames[key];
|
||||
}
|
||||
|
||||
int _glfwPlatformGetKeyScancode(int key)
|
||||
int _glfwGetKeyScancodeWayland(int key)
|
||||
{
|
||||
return _glfw.wl.scancodes[key];
|
||||
}
|
||||
|
||||
int _glfwPlatformCreateCursor(_GLFWcursor* cursor,
|
||||
const GLFWimage* image,
|
||||
int xhot, int yhot)
|
||||
int _glfwCreateCursorWayland(_GLFWcursor* cursor,
|
||||
const GLFWimage* image,
|
||||
int xhot, int yhot)
|
||||
{
|
||||
cursor->wl.buffer = createShmBuffer(image);
|
||||
if (!cursor->wl.buffer)
|
||||
@ -1245,7 +1296,7 @@ int _glfwPlatformCreateCursor(_GLFWcursor* cursor,
|
||||
return GLFW_TRUE;
|
||||
}
|
||||
|
||||
int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape)
|
||||
int _glfwCreateStandardCursorWayland(_GLFWcursor* cursor, int shape)
|
||||
{
|
||||
const char* name = NULL;
|
||||
|
||||
@ -1346,7 +1397,7 @@ int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape)
|
||||
return GLFW_TRUE;
|
||||
}
|
||||
|
||||
void _glfwPlatformDestroyCursor(_GLFWcursor* cursor)
|
||||
void _glfwDestroyCursorWayland(_GLFWcursor* cursor)
|
||||
{
|
||||
// If it's a standard cursor we don't need to do anything here
|
||||
if (cursor->wl.cursor)
|
||||
@ -1464,7 +1515,7 @@ static GLFWbool isPointerLocked(_GLFWwindow* window)
|
||||
return window->wl.pointerLock.lockedPointer != NULL;
|
||||
}
|
||||
|
||||
void _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor)
|
||||
void _glfwSetCursorWayland(_GLFWwindow* window, _GLFWcursor* cursor)
|
||||
{
|
||||
struct wl_cursor* defaultCursor;
|
||||
struct wl_cursor* defaultCursorHiDPI = NULL;
|
||||
@ -1605,7 +1656,7 @@ static const struct wl_data_source_listener dataSourceListener = {
|
||||
dataSourceHandleCancelled,
|
||||
};
|
||||
|
||||
void _glfwPlatformSetClipboardString(const char* string)
|
||||
void _glfwSetClipboardStringWayland(const char* string)
|
||||
{
|
||||
if (_glfw.wl.dataSource)
|
||||
{
|
||||
@ -1652,7 +1703,7 @@ static GLFWbool growClipboardString(void)
|
||||
clipboard = _glfw_realloc(clipboard, _glfw.wl.clipboardSize * 2);
|
||||
if (!clipboard)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
_glfwInputError(GLFW_OUT_OF_MEMORY,
|
||||
"Wayland: Impossible to grow clipboard string");
|
||||
return GLFW_FALSE;
|
||||
}
|
||||
@ -1661,7 +1712,7 @@ static GLFWbool growClipboardString(void)
|
||||
return GLFW_TRUE;
|
||||
}
|
||||
|
||||
const char* _glfwPlatformGetClipboardString(void)
|
||||
const char* _glfwGetClipboardStringWayland(void)
|
||||
{
|
||||
int fds[2];
|
||||
int ret;
|
||||
@ -1687,9 +1738,9 @@ const char* _glfwPlatformGetClipboardString(void)
|
||||
close(fds[1]);
|
||||
|
||||
// XXX: this is a huge hack, this function shouldn’t be synchronous!
|
||||
handleEvents(-1);
|
||||
handleEvents(NULL);
|
||||
|
||||
while (1)
|
||||
for (;;)
|
||||
{
|
||||
// Grow the clipboard if we need to paste something bigger, there is no
|
||||
// shrink operation yet.
|
||||
@ -1728,7 +1779,7 @@ const char* _glfwPlatformGetClipboardString(void)
|
||||
return _glfw.wl.clipboardString;
|
||||
}
|
||||
|
||||
EGLenum _glfwPlatformGetEGLPlatform(EGLint** attribs)
|
||||
EGLenum _glfwGetEGLPlatformWayland(EGLint** attribs)
|
||||
{
|
||||
if (_glfw.egl.EXT_platform_base && _glfw.egl.EXT_platform_wayland)
|
||||
return EGL_PLATFORM_WAYLAND_EXT;
|
||||
@ -1736,17 +1787,17 @@ EGLenum _glfwPlatformGetEGLPlatform(EGLint** attribs)
|
||||
return 0;
|
||||
}
|
||||
|
||||
EGLNativeDisplayType _glfwPlatformGetEGLNativeDisplay(void)
|
||||
EGLNativeDisplayType _glfwGetEGLNativeDisplayWayland(void)
|
||||
{
|
||||
return _glfw.wl.display;
|
||||
}
|
||||
|
||||
EGLNativeWindowType _glfwPlatformGetEGLNativeWindow(_GLFWwindow* window)
|
||||
EGLNativeWindowType _glfwGetEGLNativeWindowWayland(_GLFWwindow* window)
|
||||
{
|
||||
return window->wl.native;
|
||||
}
|
||||
|
||||
void _glfwPlatformGetRequiredInstanceExtensions(char** extensions)
|
||||
void _glfwGetRequiredInstanceExtensionsWayland(char** extensions)
|
||||
{
|
||||
if (!_glfw.vk.KHR_surface || !_glfw.vk.KHR_wayland_surface)
|
||||
return;
|
||||
@ -1755,9 +1806,9 @@ void _glfwPlatformGetRequiredInstanceExtensions(char** extensions)
|
||||
extensions[1] = "VK_KHR_wayland_surface";
|
||||
}
|
||||
|
||||
int _glfwPlatformGetPhysicalDevicePresentationSupport(VkInstance instance,
|
||||
VkPhysicalDevice device,
|
||||
uint32_t queuefamily)
|
||||
int _glfwGetPhysicalDevicePresentationSupportWayland(VkInstance instance,
|
||||
VkPhysicalDevice device,
|
||||
uint32_t queuefamily)
|
||||
{
|
||||
PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR
|
||||
vkGetPhysicalDeviceWaylandPresentationSupportKHR =
|
||||
@ -1775,10 +1826,10 @@ int _glfwPlatformGetPhysicalDevicePresentationSupport(VkInstance instance,
|
||||
_glfw.wl.display);
|
||||
}
|
||||
|
||||
VkResult _glfwPlatformCreateWindowSurface(VkInstance instance,
|
||||
_GLFWwindow* window,
|
||||
const VkAllocationCallbacks* allocator,
|
||||
VkSurfaceKHR* surface)
|
||||
VkResult _glfwCreateWindowSurfaceWayland(VkInstance instance,
|
||||
_GLFWwindow* window,
|
||||
const VkAllocationCallbacks* allocator,
|
||||
VkSurfaceKHR* surface)
|
||||
{
|
||||
VkResult err;
|
||||
VkWaylandSurfaceCreateInfoKHR sci;
|
||||
@ -1830,6 +1881,14 @@ _GLFWusercontext* _glfwPlatformCreateUserContext(_GLFWwindow* window)
|
||||
GLFWAPI struct wl_display* glfwGetWaylandDisplay(void)
|
||||
{
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||
|
||||
if (_glfw.platform.platformID != GLFW_PLATFORM_WAYLAND)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_UNAVAILABLE,
|
||||
"Wayland: Platform not initialized");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return _glfw.wl.display;
|
||||
}
|
||||
|
||||
@ -1837,6 +1896,14 @@ GLFWAPI struct wl_surface* glfwGetWaylandWindow(GLFWwindow* handle)
|
||||
{
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||
|
||||
if (_glfw.platform.platformID != GLFW_PLATFORM_WAYLAND)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_UNAVAILABLE,
|
||||
"Wayland: Platform not initialized");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return window->wl.surface;
|
||||
}
|
||||
|
||||
|
775
src/x11_init.c
775
src/x11_init.c
File diff suppressed because it is too large
Load Diff
@ -232,7 +232,7 @@ void _glfwSetVideoModeX11(_GLFWmonitor* monitor, const GLFWvidmode* desired)
|
||||
RRMode native = None;
|
||||
|
||||
const GLFWvidmode* best = _glfwChooseVideoMode(monitor, desired);
|
||||
_glfwPlatformGetVideoMode(monitor, ¤t);
|
||||
_glfwGetVideoModeX11(monitor, ¤t);
|
||||
if (_glfwCompareVideoModes(¤t, best) == 0)
|
||||
return;
|
||||
|
||||
@ -310,11 +310,11 @@ void _glfwRestoreVideoModeX11(_GLFWmonitor* monitor)
|
||||
////// GLFW platform API //////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void _glfwPlatformFreeMonitor(_GLFWmonitor* monitor)
|
||||
void _glfwFreeMonitorX11(_GLFWmonitor* monitor)
|
||||
{
|
||||
}
|
||||
|
||||
void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos)
|
||||
void _glfwGetMonitorPosX11(_GLFWmonitor* monitor, int* xpos, int* ypos)
|
||||
{
|
||||
if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken)
|
||||
{
|
||||
@ -336,8 +336,8 @@ void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos)
|
||||
}
|
||||
}
|
||||
|
||||
void _glfwPlatformGetMonitorContentScale(_GLFWmonitor* monitor,
|
||||
float* xscale, float* yscale)
|
||||
void _glfwGetMonitorContentScaleX11(_GLFWmonitor* monitor,
|
||||
float* xscale, float* yscale)
|
||||
{
|
||||
if (xscale)
|
||||
*xscale = _glfw.x11.contentScaleX;
|
||||
@ -345,7 +345,9 @@ void _glfwPlatformGetMonitorContentScale(_GLFWmonitor* monitor,
|
||||
*yscale = _glfw.x11.contentScaleY;
|
||||
}
|
||||
|
||||
void _glfwPlatformGetMonitorWorkarea(_GLFWmonitor* monitor, int* xpos, int* ypos, int* width, int* height)
|
||||
void _glfwGetMonitorWorkareaX11(_GLFWmonitor* monitor,
|
||||
int* xpos, int* ypos,
|
||||
int* width, int* height)
|
||||
{
|
||||
int areaX = 0, areaY = 0, areaWidth = 0, areaHeight = 0;
|
||||
|
||||
@ -437,7 +439,7 @@ void _glfwPlatformGetMonitorWorkarea(_GLFWmonitor* monitor, int* xpos, int* ypos
|
||||
*height = areaHeight;
|
||||
}
|
||||
|
||||
GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* count)
|
||||
GLFWvidmode* _glfwGetVideoModesX11(_GLFWmonitor* monitor, int* count)
|
||||
{
|
||||
GLFWvidmode* result;
|
||||
|
||||
@ -483,13 +485,13 @@ GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* count)
|
||||
{
|
||||
*count = 1;
|
||||
result = _glfw_calloc(1, sizeof(GLFWvidmode));
|
||||
_glfwPlatformGetVideoMode(monitor, result);
|
||||
_glfwGetVideoModeX11(monitor, result);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode)
|
||||
void _glfwGetVideoModeX11(_GLFWmonitor* monitor, GLFWvidmode* mode)
|
||||
{
|
||||
if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken)
|
||||
{
|
||||
@ -519,7 +521,7 @@ void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode)
|
||||
}
|
||||
}
|
||||
|
||||
GLFWbool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
|
||||
GLFWbool _glfwGetGammaRampX11(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
|
||||
{
|
||||
if (_glfw.x11.randr.available && !_glfw.x11.randr.gammaBroken)
|
||||
{
|
||||
@ -557,7 +559,7 @@ GLFWbool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
|
||||
}
|
||||
}
|
||||
|
||||
void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp)
|
||||
void _glfwSetGammaRampX11(_GLFWmonitor* monitor, const GLFWgammaramp* ramp)
|
||||
{
|
||||
if (_glfw.x11.randr.available && !_glfw.x11.randr.gammaBroken)
|
||||
{
|
||||
|
@ -28,7 +28,6 @@
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
#include <stdint.h>
|
||||
#include <dlfcn.h>
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/keysym.h>
|
||||
@ -51,6 +50,53 @@
|
||||
// The Shape extension provides custom window shapes
|
||||
#include <X11/extensions/shape.h>
|
||||
|
||||
#define GLX_VENDOR 1
|
||||
#define GLX_RGBA_BIT 0x00000001
|
||||
#define GLX_WINDOW_BIT 0x00000001
|
||||
#define GLX_DRAWABLE_TYPE 0x8010
|
||||
#define GLX_RENDER_TYPE 0x8011
|
||||
#define GLX_RGBA_TYPE 0x8014
|
||||
#define GLX_DOUBLEBUFFER 5
|
||||
#define GLX_STEREO 6
|
||||
#define GLX_AUX_BUFFERS 7
|
||||
#define GLX_RED_SIZE 8
|
||||
#define GLX_GREEN_SIZE 9
|
||||
#define GLX_BLUE_SIZE 10
|
||||
#define GLX_ALPHA_SIZE 11
|
||||
#define GLX_DEPTH_SIZE 12
|
||||
#define GLX_STENCIL_SIZE 13
|
||||
#define GLX_ACCUM_RED_SIZE 14
|
||||
#define GLX_ACCUM_GREEN_SIZE 15
|
||||
#define GLX_ACCUM_BLUE_SIZE 16
|
||||
#define GLX_ACCUM_ALPHA_SIZE 17
|
||||
#define GLX_SAMPLES 0x186a1
|
||||
#define GLX_VISUAL_ID 0x800b
|
||||
|
||||
#define GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20b2
|
||||
#define GLX_CONTEXT_DEBUG_BIT_ARB 0x00000001
|
||||
#define GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002
|
||||
#define GLX_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001
|
||||
#define GLX_CONTEXT_PROFILE_MASK_ARB 0x9126
|
||||
#define GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x00000002
|
||||
#define GLX_CONTEXT_MAJOR_VERSION_ARB 0x2091
|
||||
#define GLX_CONTEXT_MINOR_VERSION_ARB 0x2092
|
||||
#define GLX_CONTEXT_FLAGS_ARB 0x2094
|
||||
#define GLX_CONTEXT_ES2_PROFILE_BIT_EXT 0x00000004
|
||||
#define GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB 0x00000004
|
||||
#define GLX_LOSE_CONTEXT_ON_RESET_ARB 0x8252
|
||||
#define GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB 0x8256
|
||||
#define GLX_NO_RESET_NOTIFICATION_ARB 0x8261
|
||||
#define GLX_CONTEXT_RELEASE_BEHAVIOR_ARB 0x2097
|
||||
#define GLX_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB 0
|
||||
#define GLX_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB 0x2098
|
||||
#define GLX_CONTEXT_OPENGL_NO_ERROR_ARB 0x31b3
|
||||
|
||||
typedef XID GLXWindow;
|
||||
typedef XID GLXDrawable;
|
||||
typedef struct __GLXFBConfig* GLXFBConfig;
|
||||
typedef struct __GLXcontext* GLXContext;
|
||||
typedef void (*__GLXextproc)(void);
|
||||
|
||||
typedef XClassHint* (* PFN_XAllocClassHint)(void);
|
||||
typedef XSizeHints* (* PFN_XAllocSizeHints)(void);
|
||||
typedef XWMHints* (* PFN_XAllocWMHints)(void);
|
||||
@ -197,7 +243,6 @@ typedef void (* PFN_Xutf8SetWMProperties)(Display*,Window,const char*,const char
|
||||
#define XGetWindowProperty _glfw.x11.xlib.GetWindowProperty
|
||||
#define XGrabPointer _glfw.x11.xlib.GrabPointer
|
||||
#define XIconifyWindow _glfw.x11.xlib.IconifyWindow
|
||||
#define XInitThreads _glfw.x11.xlib.InitThreads
|
||||
#define XInternAtom _glfw.x11.xlib.InternAtom
|
||||
#define XLookupString _glfw.x11.xlib.LookupString
|
||||
#define XMapRaised _glfw.x11.xlib.MapRaised
|
||||
@ -205,7 +250,6 @@ typedef void (* PFN_Xutf8SetWMProperties)(Display*,Window,const char*,const char
|
||||
#define XMoveResizeWindow _glfw.x11.xlib.MoveResizeWindow
|
||||
#define XMoveWindow _glfw.x11.xlib.MoveWindow
|
||||
#define XNextEvent _glfw.x11.xlib.NextEvent
|
||||
#define XOpenDisplay _glfw.x11.xlib.OpenDisplay
|
||||
#define XOpenIM _glfw.x11.xlib.OpenIM
|
||||
#define XPeekEvent _glfw.x11.xlib.PeekEvent
|
||||
#define XPending _glfw.x11.xlib.Pending
|
||||
@ -250,7 +294,6 @@ typedef void (* PFN_Xutf8SetWMProperties)(Display*,Window,const char*,const char
|
||||
#define XrmDestroyDatabase _glfw.x11.xrm.DestroyDatabase
|
||||
#define XrmGetResource _glfw.x11.xrm.GetResource
|
||||
#define XrmGetStringDatabase _glfw.x11.xrm.GetStringDatabase
|
||||
#define XrmInitialize _glfw.x11.xrm.Initialize
|
||||
#define XrmUniqueQuark _glfw.x11.xrm.UniqueQuark
|
||||
#define XUnregisterIMInstantiateCallback _glfw.x11.xlib.UnregisterIMInstantiateCallback
|
||||
#define Xutf8LookupString _glfw.x11.xlib.utf8LookupString
|
||||
@ -348,6 +391,41 @@ typedef void (* PFN_XShapeCombineMask)(Display*,Window,int,int,int,Pixmap,int);
|
||||
#define XShapeCombineRegion _glfw.x11.xshape.ShapeCombineRegion
|
||||
#define XShapeCombineMask _glfw.x11.xshape.ShapeCombineMask
|
||||
|
||||
typedef int (*PFNGLXGETFBCONFIGATTRIBPROC)(Display*,GLXFBConfig,int,int*);
|
||||
typedef const char* (*PFNGLXGETCLIENTSTRINGPROC)(Display*,int);
|
||||
typedef Bool (*PFNGLXQUERYEXTENSIONPROC)(Display*,int*,int*);
|
||||
typedef Bool (*PFNGLXQUERYVERSIONPROC)(Display*,int*,int*);
|
||||
typedef void (*PFNGLXDESTROYCONTEXTPROC)(Display*,GLXContext);
|
||||
typedef Bool (*PFNGLXMAKECURRENTPROC)(Display*,GLXDrawable,GLXContext);
|
||||
typedef void (*PFNGLXSWAPBUFFERSPROC)(Display*,GLXDrawable);
|
||||
typedef const char* (*PFNGLXQUERYEXTENSIONSSTRINGPROC)(Display*,int);
|
||||
typedef GLXFBConfig* (*PFNGLXGETFBCONFIGSPROC)(Display*,int,int*);
|
||||
typedef GLXContext (*PFNGLXCREATENEWCONTEXTPROC)(Display*,GLXFBConfig,int,GLXContext,Bool);
|
||||
typedef __GLXextproc (* PFNGLXGETPROCADDRESSPROC)(const GLubyte *procName);
|
||||
typedef void (*PFNGLXSWAPINTERVALEXTPROC)(Display*,GLXDrawable,int);
|
||||
typedef XVisualInfo* (*PFNGLXGETVISUALFROMFBCONFIGPROC)(Display*,GLXFBConfig);
|
||||
typedef GLXWindow (*PFNGLXCREATEWINDOWPROC)(Display*,GLXFBConfig,Window,const int*);
|
||||
typedef void (*PFNGLXDESTROYWINDOWPROC)(Display*,GLXWindow);
|
||||
|
||||
typedef int (*PFNGLXSWAPINTERVALMESAPROC)(int);
|
||||
typedef int (*PFNGLXSWAPINTERVALSGIPROC)(int);
|
||||
typedef GLXContext (*PFNGLXCREATECONTEXTATTRIBSARBPROC)(Display*,GLXFBConfig,GLXContext,Bool,const int*);
|
||||
|
||||
// libGL.so function pointer typedefs
|
||||
#define glXGetFBConfigs _glfw.glx.GetFBConfigs
|
||||
#define glXGetFBConfigAttrib _glfw.glx.GetFBConfigAttrib
|
||||
#define glXGetClientString _glfw.glx.GetClientString
|
||||
#define glXQueryExtension _glfw.glx.QueryExtension
|
||||
#define glXQueryVersion _glfw.glx.QueryVersion
|
||||
#define glXDestroyContext _glfw.glx.DestroyContext
|
||||
#define glXMakeCurrent _glfw.glx.MakeCurrent
|
||||
#define glXSwapBuffers _glfw.glx.SwapBuffers
|
||||
#define glXQueryExtensionsString _glfw.glx.QueryExtensionsString
|
||||
#define glXCreateNewContext _glfw.glx.CreateNewContext
|
||||
#define glXGetVisualFromFBConfig _glfw.glx.GetVisualFromFBConfig
|
||||
#define glXCreateWindow _glfw.glx.CreateWindow
|
||||
#define glXDestroyWindow _glfw.glx.DestroyWindow
|
||||
|
||||
typedef VkFlags VkXlibSurfaceCreateFlagsKHR;
|
||||
typedef VkFlags VkXcbSurfaceCreateFlagsKHR;
|
||||
|
||||
@ -374,25 +452,79 @@ typedef VkBool32 (APIENTRY *PFN_vkGetPhysicalDeviceXlibPresentationSupportKHR)(V
|
||||
typedef VkResult (APIENTRY *PFN_vkCreateXcbSurfaceKHR)(VkInstance,const VkXcbSurfaceCreateInfoKHR*,const VkAllocationCallbacks*,VkSurfaceKHR*);
|
||||
typedef VkBool32 (APIENTRY *PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR)(VkPhysicalDevice,uint32_t,xcb_connection_t*,xcb_visualid_t);
|
||||
|
||||
#include "posix_thread.h"
|
||||
#include "posix_time.h"
|
||||
#include "xkb_unicode.h"
|
||||
#include "glx_context.h"
|
||||
#if defined(__linux__)
|
||||
#include "linux_joystick.h"
|
||||
#else
|
||||
#include "null_joystick.h"
|
||||
#endif
|
||||
#include "posix_poll.h"
|
||||
|
||||
#define _glfw_dlopen(name) dlopen(name, RTLD_LAZY | RTLD_LOCAL)
|
||||
#define _glfw_dlclose(handle) dlclose(handle)
|
||||
#define _glfw_dlsym(handle, name) dlsym(handle, name)
|
||||
#define GLFW_X11_WINDOW_STATE _GLFWwindowX11 x11;
|
||||
#define GLFW_X11_LIBRARY_WINDOW_STATE _GLFWlibraryX11 x11;
|
||||
#define GLFW_X11_MONITOR_STATE _GLFWmonitorX11 x11;
|
||||
#define GLFW_X11_CURSOR_STATE _GLFWcursorX11 x11;
|
||||
|
||||
#define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowX11 x11
|
||||
#define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryX11 x11
|
||||
#define _GLFW_PLATFORM_MONITOR_STATE _GLFWmonitorX11 x11
|
||||
#define _GLFW_PLATFORM_CURSOR_STATE _GLFWcursorX11 x11
|
||||
#define GLFW_GLX_CONTEXT_STATE _GLFWcontextGLX glx;
|
||||
#define GLFW_GLX_LIBRARY_CONTEXT_STATE _GLFWlibraryGLX glx;
|
||||
#define GLFW_GLX_USER_CONTEXT_STATE _GLFWusercontextGLX glx;
|
||||
|
||||
// GLX-specific per-context data
|
||||
//
|
||||
typedef struct _GLFWcontextGLX
|
||||
{
|
||||
GLXContext handle;
|
||||
GLXWindow window;
|
||||
} _GLFWcontextGLX;
|
||||
|
||||
// GLX-specific global data
|
||||
//
|
||||
typedef struct _GLFWlibraryGLX
|
||||
{
|
||||
int major, minor;
|
||||
int eventBase;
|
||||
int errorBase;
|
||||
|
||||
// dlopen handle for libGL.so.1
|
||||
void* handle;
|
||||
|
||||
// GLX 1.3 functions
|
||||
PFNGLXGETFBCONFIGSPROC GetFBConfigs;
|
||||
PFNGLXGETFBCONFIGATTRIBPROC GetFBConfigAttrib;
|
||||
PFNGLXGETCLIENTSTRINGPROC GetClientString;
|
||||
PFNGLXQUERYEXTENSIONPROC QueryExtension;
|
||||
PFNGLXQUERYVERSIONPROC QueryVersion;
|
||||
PFNGLXDESTROYCONTEXTPROC DestroyContext;
|
||||
PFNGLXMAKECURRENTPROC MakeCurrent;
|
||||
PFNGLXSWAPBUFFERSPROC SwapBuffers;
|
||||
PFNGLXQUERYEXTENSIONSSTRINGPROC QueryExtensionsString;
|
||||
PFNGLXCREATENEWCONTEXTPROC CreateNewContext;
|
||||
PFNGLXGETVISUALFROMFBCONFIGPROC GetVisualFromFBConfig;
|
||||
PFNGLXCREATEWINDOWPROC CreateWindow;
|
||||
PFNGLXDESTROYWINDOWPROC DestroyWindow;
|
||||
|
||||
// GLX 1.4 and extension functions
|
||||
PFNGLXGETPROCADDRESSPROC GetProcAddress;
|
||||
PFNGLXGETPROCADDRESSPROC GetProcAddressARB;
|
||||
PFNGLXSWAPINTERVALSGIPROC SwapIntervalSGI;
|
||||
PFNGLXSWAPINTERVALEXTPROC SwapIntervalEXT;
|
||||
PFNGLXSWAPINTERVALMESAPROC SwapIntervalMESA;
|
||||
PFNGLXCREATECONTEXTATTRIBSARBPROC CreateContextAttribsARB;
|
||||
GLFWbool SGI_swap_control;
|
||||
GLFWbool EXT_swap_control;
|
||||
GLFWbool MESA_swap_control;
|
||||
GLFWbool ARB_multisample;
|
||||
GLFWbool ARB_framebuffer_sRGB;
|
||||
GLFWbool EXT_framebuffer_sRGB;
|
||||
GLFWbool ARB_create_context;
|
||||
GLFWbool ARB_create_context_profile;
|
||||
GLFWbool ARB_create_context_robustness;
|
||||
GLFWbool EXT_create_context_es2_profile;
|
||||
GLFWbool ARB_create_context_no_error;
|
||||
GLFWbool ARB_context_flush_control;
|
||||
} _GLFWlibraryGLX;
|
||||
|
||||
// GLX-specific per usercontext data
|
||||
//
|
||||
typedef struct _GLFWusercontextGLX
|
||||
{
|
||||
GLXContext handle;
|
||||
} _GLFWusercontextGLX;
|
||||
|
||||
// X11-specific per-window data
|
||||
//
|
||||
@ -422,7 +554,6 @@ typedef struct _GLFWwindowX11
|
||||
// The time of the last KeyPress event per keycode, for discarding
|
||||
// duplicate key events generated for some keys by ibus
|
||||
Time keyPressTimes[256];
|
||||
|
||||
} _GLFWwindowX11;
|
||||
|
||||
// X11-specific global data
|
||||
@ -459,6 +590,7 @@ typedef struct _GLFWlibraryX11
|
||||
double restoreCursorPosX, restoreCursorPosY;
|
||||
// The window whose disabled cursor mode is active
|
||||
_GLFWwindow* disabledCursorWindow;
|
||||
int emptyEventPipe[2];
|
||||
|
||||
// Window manager atoms
|
||||
Atom NET_SUPPORTED;
|
||||
@ -563,7 +695,6 @@ typedef struct _GLFWlibraryX11
|
||||
PFN_XGetWindowProperty GetWindowProperty;
|
||||
PFN_XGrabPointer GrabPointer;
|
||||
PFN_XIconifyWindow IconifyWindow;
|
||||
PFN_XInitThreads InitThreads;
|
||||
PFN_XInternAtom InternAtom;
|
||||
PFN_XLookupString LookupString;
|
||||
PFN_XMapRaised MapRaised;
|
||||
@ -571,7 +702,6 @@ typedef struct _GLFWlibraryX11
|
||||
PFN_XMoveResizeWindow MoveResizeWindow;
|
||||
PFN_XMoveWindow MoveWindow;
|
||||
PFN_XNextEvent NextEvent;
|
||||
PFN_XOpenDisplay OpenDisplay;
|
||||
PFN_XOpenIM OpenIM;
|
||||
PFN_XPeekEvent PeekEvent;
|
||||
PFN_XPending Pending;
|
||||
@ -613,7 +743,6 @@ typedef struct _GLFWlibraryX11
|
||||
PFN_XrmDestroyDatabase DestroyDatabase;
|
||||
PFN_XrmGetResource GetResource;
|
||||
PFN_XrmGetStringDatabase GetStringDatabase;
|
||||
PFN_XrmInitialize Initialize;
|
||||
PFN_XrmUniqueQuark UniqueQuark;
|
||||
} xrm;
|
||||
|
||||
@ -751,7 +880,6 @@ typedef struct _GLFWlibraryX11
|
||||
PFN_XShapeQueryVersion QueryVersion;
|
||||
PFN_XShapeCombineMask ShapeCombineMask;
|
||||
} xshape;
|
||||
|
||||
} _GLFWlibraryX11;
|
||||
|
||||
// X11-specific per-monitor data
|
||||
@ -765,7 +893,6 @@ typedef struct _GLFWmonitorX11
|
||||
// Index of corresponding Xinerama screen,
|
||||
// for EWMH full screen window placement
|
||||
int index;
|
||||
|
||||
} _GLFWmonitorX11;
|
||||
|
||||
// X11-specific per-cursor data
|
||||
@ -773,15 +900,89 @@ typedef struct _GLFWmonitorX11
|
||||
typedef struct _GLFWcursorX11
|
||||
{
|
||||
Cursor handle;
|
||||
|
||||
} _GLFWcursorX11;
|
||||
|
||||
|
||||
GLFWbool _glfwConnectX11(int platformID, _GLFWplatform* platform);
|
||||
int _glfwInitX11(void);
|
||||
void _glfwTerminateX11(void);
|
||||
|
||||
int _glfwCreateWindowX11(_GLFWwindow* window, const _GLFWwndconfig* wndconfig, const _GLFWctxconfig* ctxconfig, const _GLFWfbconfig* fbconfig);
|
||||
void _glfwDestroyWindowX11(_GLFWwindow* window);
|
||||
void _glfwSetWindowTitleX11(_GLFWwindow* window, const char* title);
|
||||
void _glfwSetWindowIconX11(_GLFWwindow* window, int count, const GLFWimage* images);
|
||||
void _glfwGetWindowPosX11(_GLFWwindow* window, int* xpos, int* ypos);
|
||||
void _glfwSetWindowPosX11(_GLFWwindow* window, int xpos, int ypos);
|
||||
void _glfwGetWindowSizeX11(_GLFWwindow* window, int* width, int* height);
|
||||
void _glfwSetWindowSizeX11(_GLFWwindow* window, int width, int height);
|
||||
void _glfwSetWindowSizeLimitsX11(_GLFWwindow* window, int minwidth, int minheight, int maxwidth, int maxheight);
|
||||
void _glfwSetWindowAspectRatioX11(_GLFWwindow* window, int numer, int denom);
|
||||
void _glfwGetFramebufferSizeX11(_GLFWwindow* window, int* width, int* height);
|
||||
void _glfwGetWindowFrameSizeX11(_GLFWwindow* window, int* left, int* top, int* right, int* bottom);
|
||||
void _glfwGetWindowContentScaleX11(_GLFWwindow* window, float* xscale, float* yscale);
|
||||
void _glfwIconifyWindowX11(_GLFWwindow* window);
|
||||
void _glfwRestoreWindowX11(_GLFWwindow* window);
|
||||
void _glfwMaximizeWindowX11(_GLFWwindow* window);
|
||||
void _glfwShowWindowX11(_GLFWwindow* window);
|
||||
void _glfwHideWindowX11(_GLFWwindow* window);
|
||||
void _glfwRequestWindowAttentionX11(_GLFWwindow* window);
|
||||
void _glfwFocusWindowX11(_GLFWwindow* window);
|
||||
void _glfwSetWindowMonitorX11(_GLFWwindow* window, _GLFWmonitor* monitor, int xpos, int ypos, int width, int height, int refreshRate);
|
||||
int _glfwWindowFocusedX11(_GLFWwindow* window);
|
||||
int _glfwWindowIconifiedX11(_GLFWwindow* window);
|
||||
int _glfwWindowVisibleX11(_GLFWwindow* window);
|
||||
int _glfwWindowMaximizedX11(_GLFWwindow* window);
|
||||
int _glfwWindowHoveredX11(_GLFWwindow* window);
|
||||
int _glfwFramebufferTransparentX11(_GLFWwindow* window);
|
||||
void _glfwSetWindowResizableX11(_GLFWwindow* window, GLFWbool enabled);
|
||||
void _glfwSetWindowDecoratedX11(_GLFWwindow* window, GLFWbool enabled);
|
||||
void _glfwSetWindowFloatingX11(_GLFWwindow* window, GLFWbool enabled);
|
||||
float _glfwGetWindowOpacityX11(_GLFWwindow* window);
|
||||
void _glfwSetWindowOpacityX11(_GLFWwindow* window, float opacity);
|
||||
void _glfwSetWindowMousePassthroughX11(_GLFWwindow* window, GLFWbool enabled);
|
||||
|
||||
void _glfwSetRawMouseMotionX11(_GLFWwindow *window, GLFWbool enabled);
|
||||
GLFWbool _glfwRawMouseMotionSupportedX11(void);
|
||||
|
||||
void _glfwPollEventsX11(void);
|
||||
void _glfwWaitEventsX11(void);
|
||||
void _glfwWaitEventsTimeoutX11(double timeout);
|
||||
void _glfwPostEmptyEventX11(void);
|
||||
|
||||
void _glfwGetCursorPosX11(_GLFWwindow* window, double* xpos, double* ypos);
|
||||
void _glfwSetCursorPosX11(_GLFWwindow* window, double xpos, double ypos);
|
||||
void _glfwSetCursorModeX11(_GLFWwindow* window, int mode);
|
||||
const char* _glfwGetScancodeNameX11(int scancode);
|
||||
int _glfwGetKeyScancodeX11(int key);
|
||||
int _glfwCreateCursorX11(_GLFWcursor* cursor, const GLFWimage* image, int xhot, int yhot);
|
||||
int _glfwCreateStandardCursorX11(_GLFWcursor* cursor, int shape);
|
||||
void _glfwDestroyCursorX11(_GLFWcursor* cursor);
|
||||
void _glfwSetCursorX11(_GLFWwindow* window, _GLFWcursor* cursor);
|
||||
void _glfwSetClipboardStringX11(const char* string);
|
||||
const char* _glfwGetClipboardStringX11(void);
|
||||
|
||||
EGLenum _glfwGetEGLPlatformX11(EGLint** attribs);
|
||||
EGLNativeDisplayType _glfwGetEGLNativeDisplayX11(void);
|
||||
EGLNativeWindowType _glfwGetEGLNativeWindowX11(_GLFWwindow* window);
|
||||
|
||||
void _glfwGetRequiredInstanceExtensionsX11(char** extensions);
|
||||
int _glfwGetPhysicalDevicePresentationSupportX11(VkInstance instance, VkPhysicalDevice device, uint32_t queuefamily);
|
||||
VkResult _glfwCreateWindowSurfaceX11(VkInstance instance, _GLFWwindow* window, const VkAllocationCallbacks* allocator, VkSurfaceKHR* surface);
|
||||
|
||||
void _glfwFreeMonitorX11(_GLFWmonitor* monitor);
|
||||
void _glfwGetMonitorPosX11(_GLFWmonitor* monitor, int* xpos, int* ypos);
|
||||
void _glfwGetMonitorContentScaleX11(_GLFWmonitor* monitor, float* xscale, float* yscale);
|
||||
void _glfwGetMonitorWorkareaX11(_GLFWmonitor* monitor, int* xpos, int* ypos, int* width, int* height);
|
||||
GLFWvidmode* _glfwGetVideoModesX11(_GLFWmonitor* monitor, int* count);
|
||||
void _glfwGetVideoModeX11(_GLFWmonitor* monitor, GLFWvidmode* mode);
|
||||
GLFWbool _glfwGetGammaRampX11(_GLFWmonitor* monitor, GLFWgammaramp* ramp);
|
||||
void _glfwSetGammaRampX11(_GLFWmonitor* monitor, const GLFWgammaramp* ramp);
|
||||
|
||||
void _glfwPollMonitorsX11(void);
|
||||
void _glfwSetVideoModeX11(_GLFWmonitor* monitor, const GLFWvidmode* desired);
|
||||
void _glfwRestoreVideoModeX11(_GLFWmonitor* monitor);
|
||||
|
||||
Cursor _glfwCreateCursorX11(const GLFWimage* image, int xhot, int yhot);
|
||||
Cursor _glfwCreateNativeCursorX11(const GLFWimage* image, int xhot, int yhot);
|
||||
|
||||
unsigned long _glfwGetWindowPropertyX11(Window window,
|
||||
Atom property,
|
||||
@ -796,3 +997,16 @@ void _glfwInputErrorX11(int error, const char* message);
|
||||
void _glfwPushSelectionToManagerX11(void);
|
||||
void _glfwCreateInputContextX11(_GLFWwindow* window);
|
||||
|
||||
GLFWbool _glfwInitGLX(void);
|
||||
void _glfwTerminateGLX(void);
|
||||
GLFWbool _glfwCreateContextGLX(_GLFWwindow* window,
|
||||
const _GLFWctxconfig* ctxconfig,
|
||||
const _GLFWfbconfig* fbconfig);
|
||||
void _glfwDestroyContextGLX(_GLFWwindow* window);
|
||||
GLFWbool _glfwChooseVisualGLX(const _GLFWwndconfig* wndconfig,
|
||||
const _GLFWctxconfig* ctxconfig,
|
||||
const _GLFWfbconfig* fbconfig,
|
||||
Visual** visual, int* depth);
|
||||
|
||||
_GLFWusercontext* _glfwCreateUserContextX11(_GLFWwindow* window);
|
||||
_GLFWusercontext* _glfwCreateUserContextWGL(_GLFWwindow* window);
|
||||
|
524
src/x11_window.c
524
src/x11_window.c
File diff suppressed because it is too large
Load Diff
@ -907,7 +907,7 @@ static const struct codepair {
|
||||
|
||||
// Convert XKB KeySym to Unicode
|
||||
//
|
||||
long _glfwKeySym2Unicode(unsigned int keysym)
|
||||
uint32_t _glfwKeySym2Unicode(unsigned int keysym)
|
||||
{
|
||||
int min = 0;
|
||||
int max = sizeof(keysymtab) / sizeof(struct codepair) - 1;
|
||||
@ -937,6 +937,6 @@ long _glfwKeySym2Unicode(unsigned int keysym)
|
||||
}
|
||||
|
||||
// No matching Unicode value found
|
||||
return -1;
|
||||
return GLFW_INVALID_CODEPOINT;
|
||||
}
|
||||
|
||||
|
@ -24,5 +24,7 @@
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
long _glfwKeySym2Unicode(unsigned int keysym);
|
||||
#define GLFW_INVALID_CODEPOINT 0xffffffffu
|
||||
|
||||
uint32_t _glfwKeySym2Unicode(unsigned int keysym);
|
||||
|
||||
|
@ -113,6 +113,12 @@ int main(int argc, char** argv)
|
||||
|
||||
{
|
||||
const GLFWgammaramp* ramp = glfwGetGammaRamp(monitor);
|
||||
if (!ramp)
|
||||
{
|
||||
glfwTerminate();
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
const size_t array_size = ramp->size * sizeof(short);
|
||||
orig_ramp.size = ramp->size;
|
||||
orig_ramp.red = malloc(array_size);
|
||||
|
@ -64,10 +64,24 @@
|
||||
#define ANGLE_TYPE_VULKAN "vk"
|
||||
#define ANGLE_TYPE_METAL "mtl"
|
||||
|
||||
#define PLATFORM_NAME_ANY "any"
|
||||
#define PLATFORM_NAME_WIN32 "win32"
|
||||
#define PLATFORM_NAME_COCOA "cooca"
|
||||
#define PLATFORM_NAME_WL "wayland"
|
||||
#define PLATFORM_NAME_X11 "x11"
|
||||
#define PLATFORM_NAME_NULL "null"
|
||||
|
||||
static void usage(void)
|
||||
{
|
||||
printf("Usage: glfwinfo [OPTION]...\n");
|
||||
printf("Options:\n");
|
||||
printf(" --platform=PLATFORM the platform to use ("
|
||||
PLATFORM_NAME_ANY " or "
|
||||
PLATFORM_NAME_WIN32 " or "
|
||||
PLATFORM_NAME_COCOA " or "
|
||||
PLATFORM_NAME_X11 " or "
|
||||
PLATFORM_NAME_WL " or "
|
||||
PLATFORM_NAME_NULL ")\n");
|
||||
printf(" -a, --client-api=API the client API to use ("
|
||||
API_NAME_OPENGL " or "
|
||||
API_NAME_OPENGL_ES ")\n");
|
||||
@ -126,6 +140,22 @@ static void error_callback(int error, const char* description)
|
||||
fprintf(stderr, "Error: %s\n", description);
|
||||
}
|
||||
|
||||
static const char* get_platform_name(int platform)
|
||||
{
|
||||
if (platform == GLFW_PLATFORM_WIN32)
|
||||
return "Win32";
|
||||
else if (platform == GLFW_PLATFORM_COCOA)
|
||||
return "Cocoa";
|
||||
else if (platform == GLFW_PLATFORM_WAYLAND)
|
||||
return "Wayland";
|
||||
else if (platform == GLFW_PLATFORM_X11)
|
||||
return "X11";
|
||||
else if (platform == GLFW_PLATFORM_NULL)
|
||||
return "Null";
|
||||
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
static const char* get_device_type_name(VkPhysicalDeviceType type)
|
||||
{
|
||||
if (type == VK_PHYSICAL_DEVICE_TYPE_OTHER)
|
||||
@ -325,12 +355,34 @@ static void print_version(void)
|
||||
printf("GLFW library version string: \"%s\"\n", glfwGetVersionString());
|
||||
}
|
||||
|
||||
static void print_platform(void)
|
||||
{
|
||||
const int platforms[] =
|
||||
{
|
||||
GLFW_PLATFORM_WIN32,
|
||||
GLFW_PLATFORM_COCOA,
|
||||
GLFW_PLATFORM_WAYLAND,
|
||||
GLFW_PLATFORM_X11,
|
||||
GLFW_PLATFORM_NULL
|
||||
};
|
||||
|
||||
printf("GLFW platform: %s\n", get_platform_name(glfwGetPlatform()));
|
||||
printf("GLFW supported platforms:\n");
|
||||
|
||||
for (size_t i = 0; i < sizeof(platforms) / sizeof(platforms[0]); i++)
|
||||
{
|
||||
if (glfwPlatformSupported(platforms[i]))
|
||||
printf(" %s\n", get_platform_name(platforms[i]));
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
int ch;
|
||||
bool list_extensions = false, list_layers = false;
|
||||
|
||||
// These duplicate the defaults for each hint
|
||||
int platform = GLFW_ANY_PLATFORM;
|
||||
int client_api = GLFW_OPENGL_API;
|
||||
int context_major = 1;
|
||||
int context_minor = 0;
|
||||
@ -360,7 +412,7 @@ int main(int argc, char** argv)
|
||||
bool cocoa_graphics_switching = false;
|
||||
bool disable_xcb_surface = false;
|
||||
|
||||
enum { CLIENT, CONTEXT, BEHAVIOR, DEBUG_CONTEXT, FORWARD, HELP,
|
||||
enum { PLATFORM, CLIENT, CONTEXT, BEHAVIOR, DEBUG_CONTEXT, FORWARD, HELP,
|
||||
EXTENSIONS, LAYERS,
|
||||
MAJOR, MINOR, PROFILE, ROBUSTNESS, VERSION,
|
||||
REDBITS, GREENBITS, BLUEBITS, ALPHABITS, DEPTHBITS, STENCILBITS,
|
||||
@ -369,6 +421,7 @@ int main(int argc, char** argv)
|
||||
ANGLE_TYPE, GRAPHICS_SWITCHING, XCB_SURFACE };
|
||||
const struct option options[] =
|
||||
{
|
||||
{ "platform", 1, NULL, PLATFORM },
|
||||
{ "behavior", 1, NULL, BEHAVIOR },
|
||||
{ "client-api", 1, NULL, CLIENT },
|
||||
{ "context-api", 1, NULL, CONTEXT },
|
||||
@ -408,6 +461,25 @@ int main(int argc, char** argv)
|
||||
{
|
||||
switch (ch)
|
||||
{
|
||||
case PLATFORM:
|
||||
if (strcasecmp(optarg, PLATFORM_NAME_ANY) == 0)
|
||||
platform = GLFW_ANY_PLATFORM;
|
||||
else if (strcasecmp(optarg, PLATFORM_NAME_WIN32) == 0)
|
||||
platform = GLFW_PLATFORM_WIN32;
|
||||
else if (strcasecmp(optarg, PLATFORM_NAME_COCOA) == 0)
|
||||
platform = GLFW_PLATFORM_COCOA;
|
||||
else if (strcasecmp(optarg, PLATFORM_NAME_WL) == 0)
|
||||
platform = GLFW_PLATFORM_WAYLAND;
|
||||
else if (strcasecmp(optarg, PLATFORM_NAME_X11) == 0)
|
||||
platform = GLFW_PLATFORM_X11;
|
||||
else if (strcasecmp(optarg, PLATFORM_NAME_NULL) == 0)
|
||||
platform = GLFW_PLATFORM_NULL;
|
||||
else
|
||||
{
|
||||
usage();
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
break;
|
||||
case 'a':
|
||||
case CLIENT:
|
||||
if (strcasecmp(optarg, API_NAME_OPENGL) == 0)
|
||||
@ -623,6 +695,8 @@ int main(int argc, char** argv)
|
||||
|
||||
glfwSetErrorCallback(error_callback);
|
||||
|
||||
glfwInitHint(GLFW_PLATFORM, platform);
|
||||
|
||||
glfwInitHint(GLFW_COCOA_MENUBAR, false);
|
||||
|
||||
glfwInitHint(GLFW_ANGLE_PLATFORM_TYPE, angle_type);
|
||||
@ -632,6 +706,7 @@ int main(int argc, char** argv)
|
||||
exit(EXIT_FAILURE);
|
||||
|
||||
print_version();
|
||||
print_platform();
|
||||
|
||||
glfwWindowHint(GLFW_VISIBLE, false);
|
||||
|
||||
@ -954,14 +1029,17 @@ int main(int argc, char** argv)
|
||||
uint32_t qfp_count;
|
||||
vkGetPhysicalDeviceQueueFamilyProperties(pd[i], &qfp_count, NULL);
|
||||
|
||||
printf("Vulkan device queue family presentation support:\n");
|
||||
for (uint32_t j = 0; j < qfp_count; j++)
|
||||
if (re)
|
||||
{
|
||||
printf(" %u: ", j);
|
||||
if (glfwGetPhysicalDevicePresentationSupport(instance, pd[i], j))
|
||||
printf("supported\n");
|
||||
else
|
||||
printf("no\n");
|
||||
printf("Vulkan device queue family presentation support:\n");
|
||||
for (uint32_t j = 0; j < qfp_count; j++)
|
||||
{
|
||||
printf(" %u: ", j);
|
||||
if (glfwGetPhysicalDevicePresentationSupport(instance, pd[i], j))
|
||||
printf("supported\n");
|
||||
else
|
||||
printf("no\n");
|
||||
}
|
||||
}
|
||||
|
||||
if (list_extensions)
|
||||
|
@ -38,7 +38,7 @@
|
||||
|
||||
#include "getopt.h"
|
||||
|
||||
static int windowed_xpos, windowed_ypos, windowed_width, windowed_height;
|
||||
static int windowed_xpos, windowed_ypos, windowed_width = 640, windowed_height = 480;
|
||||
|
||||
static void usage(void)
|
||||
{
|
||||
@ -181,8 +181,8 @@ static GLFWwindow* create_window(GLFWmonitor* monitor)
|
||||
}
|
||||
else
|
||||
{
|
||||
width = 640;
|
||||
height = 480;
|
||||
width = windowed_width;
|
||||
height = windowed_height;
|
||||
}
|
||||
|
||||
window = glfwCreateWindow(width, height, "Iconify", monitor, NULL);
|
||||
|
@ -56,11 +56,11 @@ int main(int argc, char** argv)
|
||||
int limit_aspect_ratio = false, aspect_numer = 1, aspect_denom = 1;
|
||||
int limit_min_size = false, min_width = 400, min_height = 400;
|
||||
int limit_max_size = false, max_width = 400, max_height = 400;
|
||||
char width_buffer[10] = "", height_buffer[10] = "";
|
||||
char xpos_buffer[10] = "", ypos_buffer[10] = "";
|
||||
char numer_buffer[10] = "", denom_buffer[10] = "";
|
||||
char min_width_buffer[10] = "", min_height_buffer[10] = "";
|
||||
char max_width_buffer[10] = "", max_height_buffer[10] = "";
|
||||
char width_buffer[12] = "", height_buffer[12] = "";
|
||||
char xpos_buffer[12] = "", ypos_buffer[12] = "";
|
||||
char numer_buffer[12] = "", denom_buffer[12] = "";
|
||||
char min_width_buffer[12] = "", min_height_buffer[12] = "";
|
||||
char max_width_buffer[12] = "", max_height_buffer[12] = "";
|
||||
int may_close = true;
|
||||
|
||||
if (!glfwInit())
|
||||
@ -121,7 +121,7 @@ int main(int argc, char** argv)
|
||||
nk_glfw3_new_frame();
|
||||
if (nk_begin(nk, "main", area, 0))
|
||||
{
|
||||
nk_layout_row_dynamic(nk, 30, 4);
|
||||
nk_layout_row_dynamic(nk, 30, 5);
|
||||
|
||||
if (nk_button_label(nk, "Toggle Fullscreen"))
|
||||
{
|
||||
@ -149,6 +149,16 @@ int main(int argc, char** argv)
|
||||
glfwIconifyWindow(window);
|
||||
if (nk_button_label(nk, "Restore"))
|
||||
glfwRestoreWindow(window);
|
||||
if (nk_button_label(nk, "Hide (briefly)"))
|
||||
{
|
||||
glfwHideWindow(window);
|
||||
|
||||
const double time = glfwGetTime() + 3.0;
|
||||
while (glfwGetTime() < time)
|
||||
glfwWaitEventsTimeout(1.0);
|
||||
|
||||
glfwShowWindow(window);
|
||||
}
|
||||
|
||||
nk_layout_row_dynamic(nk, 30, 1);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user