mirror of
https://github.com/glfw/glfw.git
synced 2024-11-15 02:34:36 +00:00
Merged from glfw/master
- Fixes for our titlebar stuff and GLFW's new platform API
This commit is contained in:
commit
d710a034f0
@ -1,10 +1,10 @@
|
|||||||
image:
|
image:
|
||||||
- Visual Studio 2015
|
- Visual Studio 2015
|
||||||
- Visual Studio 2019
|
|
||||||
branches:
|
branches:
|
||||||
only:
|
only:
|
||||||
- ci
|
- ci
|
||||||
- master
|
- master
|
||||||
|
- latest
|
||||||
- 3.3-stable
|
- 3.3-stable
|
||||||
skip_tags: true
|
skip_tags: true
|
||||||
environment:
|
environment:
|
||||||
@ -21,26 +21,13 @@ environment:
|
|||||||
- GENERATOR: Visual Studio 10 2010
|
- GENERATOR: Visual Studio 10 2010
|
||||||
BUILD_SHARED_LIBS: OFF
|
BUILD_SHARED_LIBS: OFF
|
||||||
CFLAGS: /WX
|
CFLAGS: /WX
|
||||||
- GENERATOR: Visual Studio 16 2019
|
|
||||||
BUILD_SHARED_LIBS: ON
|
|
||||||
CFLAGS: /WX
|
|
||||||
- GENERATOR: Visual Studio 16 2019
|
|
||||||
BUILD_SHARED_LIBS: OFF
|
|
||||||
CFLAGS: /WX
|
|
||||||
matrix:
|
matrix:
|
||||||
fast_finish: true
|
fast_finish: true
|
||||||
exclude:
|
|
||||||
- image: Visual Studio 2015
|
|
||||||
GENERATOR: Visual Studio 16 2019
|
|
||||||
- image: Visual Studio 2019
|
|
||||||
GENERATOR: Visual Studio 10 2010
|
|
||||||
- image: Visual Studio 2019
|
|
||||||
GENERATOR: MinGW Makefiles
|
|
||||||
for:
|
for:
|
||||||
-
|
-
|
||||||
matrix:
|
matrix:
|
||||||
except:
|
only:
|
||||||
- GENERATOR: Visual Studio 10 2010
|
- GENERATOR: MinGW Makefiles
|
||||||
build_script:
|
build_script:
|
||||||
- set PATH=%PATH:C:\Program Files\Git\usr\bin=C:\MinGW\bin%
|
- set PATH=%PATH:C:\Program Files\Git\usr\bin=C:\MinGW\bin%
|
||||||
- cmake -S . -B build -G "%GENERATOR%" -DBUILD_SHARED_LIBS=%BUILD_SHARED_LIBS%
|
- cmake -S . -B build -G "%GENERATOR%" -DBUILD_SHARED_LIBS=%BUILD_SHARED_LIBS%
|
||||||
|
93
.github/workflows/build.yml
vendored
Normal file
93
.github/workflows/build.yml
vendored
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
name: Build
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
push:
|
||||||
|
branches: [ ci, master, latest, 3.3-stable ]
|
||||||
|
permissions:
|
||||||
|
statuses: write
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-linux-x11-clang:
|
||||||
|
name: X11 (Linux, Clang)
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
env:
|
||||||
|
CC: clang
|
||||||
|
CFLAGS: -Werror
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
sudo apt update
|
||||||
|
sudo apt install libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev libxext-dev
|
||||||
|
|
||||||
|
- name: Configure static library
|
||||||
|
run: cmake -S . -B build-static
|
||||||
|
- name: Build static library
|
||||||
|
run: cmake --build build-static --parallel
|
||||||
|
|
||||||
|
- name: Configure shared library
|
||||||
|
run: cmake -S . -B build-shared -D BUILD_SHARED_LIBS=ON
|
||||||
|
- name: Build shared library
|
||||||
|
run: cmake --build build-shared --parallel
|
||||||
|
|
||||||
|
build-linux-full-clang:
|
||||||
|
name: X11+Wayland (Linux, Clang)
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
env:
|
||||||
|
CC: clang
|
||||||
|
CFLAGS: -Werror
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
sudo apt update
|
||||||
|
sudo apt install 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_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_BUILD_WAYLAND=ON -D BUILD_SHARED_LIBS=ON
|
||||||
|
- name: Build shared library
|
||||||
|
run: cmake --build build-shared --parallel
|
||||||
|
|
||||||
|
build-macos-cocoa-clang:
|
||||||
|
name: Cocoa (macOS, Clang)
|
||||||
|
runs-on: macos-latest
|
||||||
|
env:
|
||||||
|
CFLAGS: -Werror
|
||||||
|
MACOSX_DEPLOYMENT_TARGET: 10.8
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Configure static library
|
||||||
|
run: cmake -S . -B build-static
|
||||||
|
- name: Build static library
|
||||||
|
run: cmake --build build-static --parallel
|
||||||
|
|
||||||
|
- name: Configure shared library
|
||||||
|
run: cmake -S . -B build-shared -D BUILD_SHARED_LIBS=ON
|
||||||
|
- name: Build shared library
|
||||||
|
run: cmake --build build-shared --parallel
|
||||||
|
|
||||||
|
build-windows-win32-vs2019:
|
||||||
|
name: Win32 (Windows, VS2019)
|
||||||
|
runs-on: windows-latest
|
||||||
|
env:
|
||||||
|
CFLAGS: /WX
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Configure static library
|
||||||
|
run: cmake -S . -B build-static -G "Visual Studio 16 2019"
|
||||||
|
- name: Build static library
|
||||||
|
run: cmake --build build-static --parallel
|
||||||
|
|
||||||
|
- name: Configure shared library
|
||||||
|
run: cmake -S . -B build-shared -G "Visual Studio 16 2019" -D BUILD_SHARED_LIBS=ON
|
||||||
|
- name: Build shared library
|
||||||
|
run: cmake --build build-shared --parallel
|
||||||
|
|
7
.gitignore
vendored
7
.gitignore
vendored
@ -41,10 +41,6 @@ src/glfw_config.h
|
|||||||
src/glfw3.pc
|
src/glfw3.pc
|
||||||
src/glfw3Config.cmake
|
src/glfw3Config.cmake
|
||||||
src/glfw3ConfigVersion.cmake
|
src/glfw3ConfigVersion.cmake
|
||||||
src/wayland-pointer-constraints-unstable-v1-client-protocol.h
|
|
||||||
src/wayland-pointer-constraints-unstable-v1-protocol.c
|
|
||||||
src/wayland-relative-pointer-unstable-v1-client-protocol.h
|
|
||||||
src/wayland-relative-pointer-unstable-v1-protocol.c
|
|
||||||
|
|
||||||
# Compiled binaries
|
# Compiled binaries
|
||||||
src/libglfw.so
|
src/libglfw.so
|
||||||
@ -70,6 +66,7 @@ examples/splitview
|
|||||||
examples/sharing
|
examples/sharing
|
||||||
examples/triangle-opengl
|
examples/triangle-opengl
|
||||||
examples/wave
|
examples/wave
|
||||||
|
examples/windows
|
||||||
tests/*.app
|
tests/*.app
|
||||||
tests/*.exe
|
tests/*.exe
|
||||||
tests/clipboard
|
tests/clipboard
|
||||||
@ -80,6 +77,7 @@ tests/gamma
|
|||||||
tests/glfwinfo
|
tests/glfwinfo
|
||||||
tests/icon
|
tests/icon
|
||||||
tests/iconify
|
tests/iconify
|
||||||
|
tests/inputlag
|
||||||
tests/joysticks
|
tests/joysticks
|
||||||
tests/monitors
|
tests/monitors
|
||||||
tests/msaa
|
tests/msaa
|
||||||
@ -89,6 +87,7 @@ tests/threads
|
|||||||
tests/timeout
|
tests/timeout
|
||||||
tests/title
|
tests/title
|
||||||
tests/triangle-vulkan
|
tests/triangle-vulkan
|
||||||
|
tests/window
|
||||||
tests/windows
|
tests/windows
|
||||||
|
|
||||||
# Hazel-specific
|
# Hazel-specific
|
||||||
|
106
.travis.yml
106
.travis.yml
@ -1,106 +0,0 @@
|
|||||||
language: c
|
|
||||||
compiler: clang
|
|
||||||
branches:
|
|
||||||
only:
|
|
||||||
- ci
|
|
||||||
- master
|
|
||||||
- 3.3-stable
|
|
||||||
matrix:
|
|
||||||
include:
|
|
||||||
- os: linux
|
|
||||||
dist: xenial
|
|
||||||
sudo: false
|
|
||||||
name: "X11 shared library"
|
|
||||||
addons:
|
|
||||||
apt:
|
|
||||||
packages:
|
|
||||||
- libxrandr-dev
|
|
||||||
- libxinerama-dev
|
|
||||||
- libxcursor-dev
|
|
||||||
- libxi-dev
|
|
||||||
env:
|
|
||||||
- BUILD_SHARED_LIBS=ON
|
|
||||||
- CFLAGS=-Werror
|
|
||||||
- os: linux
|
|
||||||
dist: xenial
|
|
||||||
sudo: false
|
|
||||||
name: "X11 static library"
|
|
||||||
addons:
|
|
||||||
apt:
|
|
||||||
packages:
|
|
||||||
- libxrandr-dev
|
|
||||||
- libxinerama-dev
|
|
||||||
- libxcursor-dev
|
|
||||||
- libxi-dev
|
|
||||||
env:
|
|
||||||
- BUILD_SHARED_LIBS=OFF
|
|
||||||
- CFLAGS=-Werror
|
|
||||||
- os: linux
|
|
||||||
dist: xenial
|
|
||||||
sudo: required
|
|
||||||
name: "Wayland shared library"
|
|
||||||
addons:
|
|
||||||
apt:
|
|
||||||
sources:
|
|
||||||
- ppa:kubuntu-ppa/backports
|
|
||||||
packages:
|
|
||||||
- extra-cmake-modules
|
|
||||||
- libwayland-dev
|
|
||||||
- libxkbcommon-dev
|
|
||||||
- libegl1-mesa-dev
|
|
||||||
env:
|
|
||||||
- USE_WAYLAND=ON
|
|
||||||
- BUILD_SHARED_LIBS=ON
|
|
||||||
- CFLAGS=-Werror
|
|
||||||
- os: linux
|
|
||||||
dist: xenial
|
|
||||||
sudo: required
|
|
||||||
name: "Wayland static library"
|
|
||||||
addons:
|
|
||||||
apt:
|
|
||||||
sources:
|
|
||||||
- ppa:kubuntu-ppa/backports
|
|
||||||
packages:
|
|
||||||
- extra-cmake-modules
|
|
||||||
- libwayland-dev
|
|
||||||
- libxkbcommon-dev
|
|
||||||
- libegl1-mesa-dev
|
|
||||||
env:
|
|
||||||
- USE_WAYLAND=ON
|
|
||||||
- BUILD_SHARED_LIBS=OFF
|
|
||||||
- CFLAGS=-Werror
|
|
||||||
- os: osx
|
|
||||||
sudo: false
|
|
||||||
name: "Cocoa shared library"
|
|
||||||
env:
|
|
||||||
- BUILD_SHARED_LIBS=ON
|
|
||||||
- CFLAGS=-Werror
|
|
||||||
- MACOSX_DEPLOYMENT_TARGET=10.8
|
|
||||||
- os: osx
|
|
||||||
sudo: false
|
|
||||||
name: "Cocoa static library"
|
|
||||||
env:
|
|
||||||
- BUILD_SHARED_LIBS=OFF
|
|
||||||
- CFLAGS=-Werror
|
|
||||||
- MACOSX_DEPLOYMENT_TARGET=10.8
|
|
||||||
script:
|
|
||||||
- if grep -Inr '\s$' src include docs tests examples CMake *.md .gitattributes .gitignore; then
|
|
||||||
echo Trailing whitespace found, aborting;
|
|
||||||
exit 1;
|
|
||||||
fi
|
|
||||||
- mkdir build
|
|
||||||
- cd build
|
|
||||||
- if test -n "${USE_WAYLAND}"; then
|
|
||||||
git clone git://anongit.freedesktop.org/wayland/wayland-protocols;
|
|
||||||
pushd wayland-protocols;
|
|
||||||
git checkout 1.15 && ./autogen.sh --prefix=/usr && make && sudo make install;
|
|
||||||
popd;
|
|
||||||
fi
|
|
||||||
- cmake -DCMAKE_VERBOSE_MAKEFILE=ON -DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS} -DGLFW_USE_WAYLAND=${USE_WAYLAND} ..
|
|
||||||
- cmake --build .
|
|
||||||
notifications:
|
|
||||||
email:
|
|
||||||
recipients:
|
|
||||||
- ci@glfw.org
|
|
||||||
on_success: never
|
|
||||||
on_failure: always
|
|
@ -23,8 +23,23 @@ endif()
|
|||||||
|
|
||||||
file(STRINGS "${source_path}" lines)
|
file(STRINGS "${source_path}" lines)
|
||||||
foreach(line ${lines})
|
foreach(line ${lines})
|
||||||
if ("${line}" MATCHES "^[0-9a-fA-F].*$")
|
if (line MATCHES "^[0-9a-fA-F]")
|
||||||
set(GLFW_GAMEPAD_MAPPINGS "${GLFW_GAMEPAD_MAPPINGS}\"${line}\",\n")
|
if (line MATCHES "platform:Windows")
|
||||||
|
if (GLFW_WIN32_MAPPINGS)
|
||||||
|
string(APPEND GLFW_WIN32_MAPPINGS "\n")
|
||||||
|
endif()
|
||||||
|
string(APPEND GLFW_WIN32_MAPPINGS "\"${line}\",")
|
||||||
|
elseif (line MATCHES "platform:Mac OS X")
|
||||||
|
if (GLFW_COCOA_MAPPINGS)
|
||||||
|
string(APPEND GLFW_COCOA_MAPPINGS "\n")
|
||||||
|
endif()
|
||||||
|
string(APPEND GLFW_COCOA_MAPPINGS "\"${line}\",")
|
||||||
|
elseif (line MATCHES "platform:Linux")
|
||||||
|
if (GLFW_LINUX_MAPPINGS)
|
||||||
|
string(APPEND GLFW_LINUX_MAPPINGS "\n")
|
||||||
|
endif()
|
||||||
|
string(APPEND GLFW_LINUX_MAPPINGS "\"${line}\",")
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ Name: GLFW
|
|||||||
Description: A multi-platform library for OpenGL, window and input
|
Description: A multi-platform library for OpenGL, window and input
|
||||||
Version: @GLFW_VERSION@
|
Version: @GLFW_VERSION@
|
||||||
URL: https://www.glfw.org/
|
URL: https://www.glfw.org/
|
||||||
Requires.private: @GLFW_PKG_DEPS@
|
Requires.private: @GLFW_PKG_CONFIG_REQUIRES_PRIVATE@
|
||||||
Libs: -L${libdir} -l@GLFW_LIB_NAME@
|
Libs: -L${libdir} -l@GLFW_LIB_NAME@
|
||||||
Libs.private: @GLFW_PKG_LIBS@
|
Libs.private: @GLFW_PKG_CONFIG_LIBS_PRIVATE@
|
||||||
Cflags: -I${includedir}
|
Cflags: -I${includedir}
|
||||||
|
@ -13,5 +13,5 @@ if (EPOLLSHIM_INCLUDE_DIRS AND EPOLLSHIM_LIBRARIES)
|
|||||||
endif (EPOLLSHIM_INCLUDE_DIRS AND EPOLLSHIM_LIBRARIES)
|
endif (EPOLLSHIM_INCLUDE_DIRS AND EPOLLSHIM_LIBRARIES)
|
||||||
|
|
||||||
include(FindPackageHandleStandardArgs)
|
include(FindPackageHandleStandardArgs)
|
||||||
find_package_handle_standard_args(EPOLLSHIM DEFAULT_MSG EPOLLSHIM_LIBRARIES EPOLLSHIM_INCLUDE_DIRS)
|
find_package_handle_standard_args(EpollShim DEFAULT_MSG EPOLLSHIM_LIBRARIES EPOLLSHIM_INCLUDE_DIRS)
|
||||||
mark_as_advanced(EPOLLSHIM_INCLUDE_DIRS EPOLLSHIM_LIBRARIES)
|
mark_as_advanced(EPOLLSHIM_INCLUDE_DIRS EPOLLSHIM_LIBRARIES)
|
||||||
|
@ -1,26 +0,0 @@
|
|||||||
find_package(PkgConfig)
|
|
||||||
|
|
||||||
pkg_check_modules(WaylandProtocols QUIET wayland-protocols>=${WaylandProtocols_FIND_VERSION})
|
|
||||||
|
|
||||||
execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE} --variable=pkgdatadir wayland-protocols
|
|
||||||
OUTPUT_VARIABLE WaylandProtocols_PKGDATADIR
|
|
||||||
RESULT_VARIABLE _pkgconfig_failed)
|
|
||||||
if (_pkgconfig_failed)
|
|
||||||
message(FATAL_ERROR "Missing wayland-protocols pkgdatadir")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
string(REGEX REPLACE "[\r\n]" "" WaylandProtocols_PKGDATADIR "${WaylandProtocols_PKGDATADIR}")
|
|
||||||
|
|
||||||
find_package_handle_standard_args(WaylandProtocols
|
|
||||||
FOUND_VAR
|
|
||||||
WaylandProtocols_FOUND
|
|
||||||
REQUIRED_VARS
|
|
||||||
WaylandProtocols_PKGDATADIR
|
|
||||||
VERSION_VAR
|
|
||||||
WaylandProtocols_VERSION
|
|
||||||
HANDLE_COMPONENTS
|
|
||||||
)
|
|
||||||
|
|
||||||
set(WAYLAND_PROTOCOLS_FOUND ${WaylandProtocols_FOUND})
|
|
||||||
set(WAYLAND_PROTOCOLS_PKGDATADIR ${WaylandProtocols_PKGDATADIR})
|
|
||||||
set(WAYLAND_PROTOCOLS_VERSION ${WaylandProtocols_VERSION})
|
|
@ -1,34 +0,0 @@
|
|||||||
# - Try to find XKBCommon
|
|
||||||
# Once done, this will define
|
|
||||||
#
|
|
||||||
# XKBCOMMON_FOUND - System has XKBCommon
|
|
||||||
# XKBCOMMON_INCLUDE_DIRS - The XKBCommon include directories
|
|
||||||
# XKBCOMMON_LIBRARIES - The libraries needed to use XKBCommon
|
|
||||||
# XKBCOMMON_DEFINITIONS - Compiler switches required for using XKBCommon
|
|
||||||
|
|
||||||
find_package(PkgConfig)
|
|
||||||
pkg_check_modules(PC_XKBCOMMON QUIET xkbcommon)
|
|
||||||
set(XKBCOMMON_DEFINITIONS ${PC_XKBCOMMON_CFLAGS_OTHER})
|
|
||||||
|
|
||||||
find_path(XKBCOMMON_INCLUDE_DIR
|
|
||||||
NAMES xkbcommon/xkbcommon.h
|
|
||||||
HINTS ${PC_XKBCOMMON_INCLUDE_DIR} ${PC_XKBCOMMON_INCLUDE_DIRS}
|
|
||||||
)
|
|
||||||
|
|
||||||
find_library(XKBCOMMON_LIBRARY
|
|
||||||
NAMES xkbcommon
|
|
||||||
HINTS ${PC_XKBCOMMON_LIBRARY} ${PC_XKBCOMMON_LIBRARY_DIRS}
|
|
||||||
)
|
|
||||||
|
|
||||||
set(XKBCOMMON_LIBRARIES ${XKBCOMMON_LIBRARY})
|
|
||||||
set(XKBCOMMON_LIBRARY_DIRS ${XKBCOMMON_LIBRARY_DIRS})
|
|
||||||
set(XKBCOMMON_INCLUDE_DIRS ${XKBCOMMON_INCLUDE_DIR})
|
|
||||||
|
|
||||||
include(FindPackageHandleStandardArgs)
|
|
||||||
find_package_handle_standard_args(XKBCommon DEFAULT_MSG
|
|
||||||
XKBCOMMON_LIBRARY
|
|
||||||
XKBCOMMON_INCLUDE_DIR
|
|
||||||
)
|
|
||||||
|
|
||||||
mark_as_advanced(XKBCOMMON_LIBRARY XKBCOMMON_INCLUDE_DIR)
|
|
||||||
|
|
278
CMakeLists.txt
278
CMakeLists.txt
@ -1,4 +1,4 @@
|
|||||||
cmake_minimum_required(VERSION 3.1)
|
cmake_minimum_required(VERSION 3.4...3.20 FATAL_ERROR)
|
||||||
|
|
||||||
project(GLFW VERSION 3.4.0 LANGUAGES C)
|
project(GLFW VERSION 3.4.0 LANGUAGES C)
|
||||||
|
|
||||||
@ -8,13 +8,17 @@ if (POLICY CMP0054)
|
|||||||
cmake_policy(SET CMP0054 NEW)
|
cmake_policy(SET CMP0054 NEW)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if (POLICY CMP0069)
|
||||||
|
cmake_policy(SET CMP0069 NEW)
|
||||||
|
endif()
|
||||||
|
|
||||||
if (POLICY CMP0077)
|
if (POLICY CMP0077)
|
||||||
cmake_policy(SET CMP0077 NEW)
|
cmake_policy(SET CMP0077 NEW)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
||||||
|
|
||||||
if ("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
|
if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
|
||||||
set(GLFW_STANDALONE TRUE)
|
set(GLFW_STANDALONE TRUE)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@ -23,34 +27,36 @@ 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_TESTS "Build the GLFW test programs" ${GLFW_STANDALONE})
|
||||||
option(GLFW_BUILD_DOCS "Build the GLFW documentation" ON)
|
option(GLFW_BUILD_DOCS "Build the GLFW documentation" ON)
|
||||||
option(GLFW_INSTALL "Generate installation target" 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(GNUInstallDirs)
|
||||||
include(CMakeDependentOption)
|
include(CMakeDependentOption)
|
||||||
|
|
||||||
cmake_dependent_option(GLFW_USE_OSMESA "Use OSMesa for offscreen context creation" OFF
|
if (GLFW_USE_OSMESA)
|
||||||
"UNIX" OFF)
|
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
|
cmake_dependent_option(GLFW_USE_HYBRID_HPG "Force use of high-performance GPU on hybrid systems" OFF
|
||||||
"WIN32" 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
|
cmake_dependent_option(USE_MSVC_RUNTIME_LIBRARY_DLL "Use MSVC runtime library DLL" ON
|
||||||
"MSVC" OFF)
|
"MSVC" OFF)
|
||||||
|
|
||||||
if (BUILD_SHARED_LIBS AND UNIX)
|
set(GLFW_LIBRARY_TYPE "${GLFW_LIBRARY_TYPE}" CACHE STRING
|
||||||
# On Unix-like systems, shared libraries can use the soname system.
|
"Library type override for GLFW (SHARED, STATIC, OBJECT, or empty to follow BUILD_SHARED_LIBS)")
|
||||||
set(GLFW_LIB_NAME glfw)
|
|
||||||
else()
|
|
||||||
set(GLFW_LIB_NAME glfw3)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if (GLFW_VULKAN_STATIC)
|
if (GLFW_LIBRARY_TYPE)
|
||||||
if (BUILD_SHARED_LIBS)
|
if (GLFW_LIBRARY_TYPE STREQUAL "SHARED")
|
||||||
# If you absolutely must do this, remove this line and add the Vulkan
|
set(GLFW_BUILD_SHARED_LIBRARY TRUE)
|
||||||
# loader static library via the CMAKE_SHARED_LINKER_FLAGS
|
else()
|
||||||
message(FATAL_ERROR "You are trying to link the Vulkan loader static library into the GLFW shared library")
|
set(GLFW_BUILD_SHARED_LIBRARY FALSE)
|
||||||
endif()
|
endif()
|
||||||
set(_GLFW_VULKAN_STATIC 1)
|
else()
|
||||||
|
set(GLFW_BUILD_SHARED_LIBRARY ${BUILD_SHARED_LIBS})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
list(APPEND CMAKE_MODULE_PATH "${GLFW_SOURCE_DIR}/CMake/modules")
|
list(APPEND CMAKE_MODULE_PATH "${GLFW_SOURCE_DIR}/CMake/modules")
|
||||||
@ -63,238 +69,46 @@ if (GLFW_BUILD_DOCS)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
#--------------------------------------------------------------------
|
#--------------------------------------------------------------------
|
||||||
# Set compiler specific flags
|
# Report backend selection
|
||||||
#--------------------------------------------------------------------
|
#--------------------------------------------------------------------
|
||||||
if (MSVC)
|
if (GLFW_BUILD_WIN32)
|
||||||
if (MSVC90)
|
message(STATUS "Including Win32 support")
|
||||||
# Workaround for VS 2008 not shipping with the DirectX 9 SDK
|
|
||||||
include(CheckIncludeFile)
|
|
||||||
check_include_file(dinput.h DINPUT_H_FOUND)
|
|
||||||
if (NOT DINPUT_H_FOUND)
|
|
||||||
message(FATAL_ERROR "DirectX 9 headers not found; install DirectX 9 SDK")
|
|
||||||
endif()
|
endif()
|
||||||
# Workaround for VS 2008 not shipping with stdint.h
|
if (GLFW_BUILD_COCOA)
|
||||||
list(APPEND glfw_INCLUDE_DIRS "${GLFW_SOURCE_DIR}/deps/vs2008")
|
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()
|
endif()
|
||||||
|
|
||||||
if (NOT USE_MSVC_RUNTIME_LIBRARY_DLL)
|
#--------------------------------------------------------------------
|
||||||
|
# Apply Microsoft C runtime library option
|
||||||
|
# This is here because it also applies to tests and examples
|
||||||
|
#--------------------------------------------------------------------
|
||||||
|
if (MSVC AND NOT USE_MSVC_RUNTIME_LIBRARY_DLL)
|
||||||
|
if (CMAKE_VERSION VERSION_LESS 3.15)
|
||||||
foreach (flag CMAKE_C_FLAGS
|
foreach (flag CMAKE_C_FLAGS
|
||||||
CMAKE_C_FLAGS_DEBUG
|
CMAKE_C_FLAGS_DEBUG
|
||||||
CMAKE_C_FLAGS_RELEASE
|
CMAKE_C_FLAGS_RELEASE
|
||||||
CMAKE_C_FLAGS_MINSIZEREL
|
CMAKE_C_FLAGS_MINSIZEREL
|
||||||
CMAKE_C_FLAGS_RELWITHDEBINFO)
|
CMAKE_C_FLAGS_RELWITHDEBINFO)
|
||||||
|
|
||||||
if (${flag} MATCHES "/MD")
|
if (flag MATCHES "/MD")
|
||||||
string(REGEX REPLACE "/MD" "/MT" ${flag} "${${flag}}")
|
string(REGEX REPLACE "/MD" "/MT" ${flag} "${${flag}}")
|
||||||
endif()
|
endif()
|
||||||
if (${flag} MATCHES "/MDd")
|
if (flag MATCHES "/MDd")
|
||||||
string(REGEX REPLACE "/MDd" "/MTd" ${flag} "${${flag}}")
|
string(REGEX REPLACE "/MDd" "/MTd" ${flag} "${${flag}}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
endforeach()
|
endforeach()
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if (MINGW)
|
|
||||||
# Workaround for legacy MinGW not providing XInput and DirectInput
|
|
||||||
include(CheckIncludeFile)
|
|
||||||
|
|
||||||
check_include_file(dinput.h DINPUT_H_FOUND)
|
|
||||||
check_include_file(xinput.h XINPUT_H_FOUND)
|
|
||||||
if (NOT DINPUT_H_FOUND OR NOT XINPUT_H_FOUND)
|
|
||||||
list(APPEND glfw_INCLUDE_DIRS "${GLFW_SOURCE_DIR}/deps/mingw")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Enable link-time exploit mitigation features enabled by default on MSVC
|
|
||||||
include(CheckCCompilerFlag)
|
|
||||||
|
|
||||||
# Compatibility with data execution prevention (DEP)
|
|
||||||
set(CMAKE_REQUIRED_FLAGS "-Wl,--nxcompat")
|
|
||||||
check_c_compiler_flag("" _GLFW_HAS_DEP)
|
|
||||||
if (_GLFW_HAS_DEP)
|
|
||||||
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--nxcompat ${CMAKE_SHARED_LINKER_FLAGS}")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Compatibility with address space layout randomization (ASLR)
|
|
||||||
set(CMAKE_REQUIRED_FLAGS "-Wl,--dynamicbase")
|
|
||||||
check_c_compiler_flag("" _GLFW_HAS_ASLR)
|
|
||||||
if (_GLFW_HAS_ASLR)
|
|
||||||
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--dynamicbase ${CMAKE_SHARED_LINKER_FLAGS}")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Compatibility with 64-bit address space layout randomization (ASLR)
|
|
||||||
set(CMAKE_REQUIRED_FLAGS "-Wl,--high-entropy-va")
|
|
||||||
check_c_compiler_flag("" _GLFW_HAS_64ASLR)
|
|
||||||
if (_GLFW_HAS_64ASLR)
|
|
||||||
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--high-entropy-va ${CMAKE_SHARED_LINKER_FLAGS}")
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
#--------------------------------------------------------------------
|
|
||||||
# Detect and select backend APIs
|
|
||||||
#--------------------------------------------------------------------
|
|
||||||
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()
|
else()
|
||||||
message(FATAL_ERROR "No supported platform was detected")
|
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
|
||||||
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()
|
||||||
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()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
#--------------------------------------------------------------------
|
|
||||||
# Use Wayland for window creation
|
|
||||||
#--------------------------------------------------------------------
|
|
||||||
if (_GLFW_WAYLAND)
|
|
||||||
find_package(ECM REQUIRED NO_MODULE)
|
|
||||||
list(APPEND CMAKE_MODULE_PATH "${ECM_MODULE_PATH}")
|
|
||||||
|
|
||||||
find_package(Wayland REQUIRED Client Cursor Egl)
|
|
||||||
find_package(WaylandScanner REQUIRED)
|
|
||||||
find_package(WaylandProtocols 1.15 REQUIRED)
|
|
||||||
|
|
||||||
list(APPEND glfw_PKG_DEPS "wayland-client")
|
|
||||||
|
|
||||||
list(APPEND glfw_INCLUDE_DIRS "${Wayland_INCLUDE_DIRS}")
|
|
||||||
list(APPEND glfw_LIBRARIES "${Wayland_LIBRARIES}")
|
|
||||||
|
|
||||||
find_package(XKBCommon REQUIRED)
|
|
||||||
list(APPEND glfw_INCLUDE_DIRS "${XKBCOMMON_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 OSMesa for offscreen context creation
|
|
||||||
#--------------------------------------------------------------------
|
|
||||||
if (_GLFW_OSMESA)
|
|
||||||
find_package(OSMesa REQUIRED)
|
|
||||||
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})
|
|
||||||
set(GLFW_PKG_DEPS "${GLFW_PKG_DEPS} ${arg}")
|
|
||||||
endforeach()
|
|
||||||
foreach(arg ${glfw_PKG_LIBS})
|
|
||||||
set(GLFW_PKG_LIBS "${GLFW_PKG_LIBS} ${arg}")
|
|
||||||
endforeach()
|
|
||||||
|
|
||||||
#--------------------------------------------------------------------
|
#--------------------------------------------------------------------
|
||||||
# Create generated files
|
# Create generated files
|
||||||
#--------------------------------------------------------------------
|
#--------------------------------------------------------------------
|
||||||
@ -311,8 +125,6 @@ write_basic_package_version_file(src/glfw3ConfigVersion.cmake
|
|||||||
VERSION ${GLFW_VERSION}
|
VERSION ${GLFW_VERSION}
|
||||||
COMPATIBILITY SameMajorVersion)
|
COMPATIBILITY SameMajorVersion)
|
||||||
|
|
||||||
configure_file(CMake/glfw3.pc.in src/glfw3.pc @ONLY)
|
|
||||||
|
|
||||||
#--------------------------------------------------------------------
|
#--------------------------------------------------------------------
|
||||||
# Add subdirectories
|
# Add subdirectories
|
||||||
#--------------------------------------------------------------------
|
#--------------------------------------------------------------------
|
||||||
|
235
CONTRIBUTORS.md
Normal file
235
CONTRIBUTORS.md
Normal file
@ -0,0 +1,235 @@
|
|||||||
|
# Acknowledgements
|
||||||
|
|
||||||
|
GLFW exists because people around the world donated their time and lent their
|
||||||
|
skills. This list only includes contributions to the main repository and
|
||||||
|
excludes other invaluable contributions like language bindings and text and
|
||||||
|
video tutorials.
|
||||||
|
|
||||||
|
- Bobyshev Alexander
|
||||||
|
- Laurent Aphecetche
|
||||||
|
- Matt Arsenault
|
||||||
|
- ashishgamedev
|
||||||
|
- David Avedissian
|
||||||
|
- Keith Bauer
|
||||||
|
- John Bartholomew
|
||||||
|
- Coşku Baş
|
||||||
|
- Niklas Behrens
|
||||||
|
- Andrew Belt
|
||||||
|
- Nevyn Bengtsson
|
||||||
|
- Niklas Bergström
|
||||||
|
- Denis Bernard
|
||||||
|
- Doug Binks
|
||||||
|
- blanco
|
||||||
|
- Waris Boonyasiriwat
|
||||||
|
- Kyle Brenneman
|
||||||
|
- Rok Breulj
|
||||||
|
- Kai Burjack
|
||||||
|
- Martin Capitanio
|
||||||
|
- Nicolas Caramelli
|
||||||
|
- David Carlier
|
||||||
|
- Arturo Castro
|
||||||
|
- Chi-kwan Chan
|
||||||
|
- Joseph Chua
|
||||||
|
- Ian Clarkson
|
||||||
|
- Michał Cichoń
|
||||||
|
- Lambert Clara
|
||||||
|
- Anna Clarke
|
||||||
|
- 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
|
||||||
|
- 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
|
||||||
|
- InKryption
|
||||||
|
- 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
|
||||||
|
- 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
|
||||||
|
- Daniel Sieger
|
||||||
|
- 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
|
||||||
|
|
352
README.md
352
README.md
@ -1,6 +1,6 @@
|
|||||||
# GLFW
|
# GLFW
|
||||||
|
|
||||||
[![Build status](https://travis-ci.org/glfw/glfw.svg?branch=master)](https://travis-ci.org/glfw/glfw)
|
[![Build status](https://github.com/glfw/glfw/actions/workflows/build.yml/badge.svg)](https://github.com/glfw/glfw/actions)
|
||||||
[![Build status](https://ci.appveyor.com/api/projects/status/0kf0ct9831i5l6sp/branch/master?svg=true)](https://ci.appveyor.com/project/elmindreda/glfw)
|
[![Build status](https://ci.appveyor.com/api/projects/status/0kf0ct9831i5l6sp/branch/master?svg=true)](https://ci.appveyor.com/project/elmindreda/glfw)
|
||||||
[![Coverity Scan](https://scan.coverity.com/projects/4884/badge.svg)](https://scan.coverity.com/projects/glfw-glfw)
|
[![Coverity Scan](https://scan.coverity.com/projects/4884/badge.svg)](https://scan.coverity.com/projects/glfw-glfw)
|
||||||
|
|
||||||
@ -14,18 +14,18 @@ GLFW natively supports Windows, macOS and Linux and other Unix-like systems. On
|
|||||||
Linux both X11 and Wayland are supported.
|
Linux both X11 and Wayland are supported.
|
||||||
|
|
||||||
GLFW is licensed under the [zlib/libpng
|
GLFW is licensed under the [zlib/libpng
|
||||||
license](http://www.glfw.org/license.html).
|
license](https://www.glfw.org/license.html).
|
||||||
|
|
||||||
You can [download](http://www.glfw.org/download.html) the latest stable release
|
You can [download](https://www.glfw.org/download.html) the latest stable release
|
||||||
as source or Windows binaries, or fetch the `latest` branch from GitHub. Each
|
as source or Windows binaries, or fetch the `latest` branch from GitHub. Each
|
||||||
release starting with 3.0 also has a corresponding [annotated
|
release starting with 3.0 also has a corresponding [annotated
|
||||||
tag](https://github.com/glfw/glfw/releases) with source and binary archives.
|
tag](https://github.com/glfw/glfw/releases) with source and binary archives.
|
||||||
|
|
||||||
The [documentation](http://www.glfw.org/docs/latest/) is available online and is
|
The [documentation](https://www.glfw.org/docs/latest/) is available online and is
|
||||||
included in all source and binary archives. See the [release
|
included in all source and binary archives. See the [release
|
||||||
notes](https://www.glfw.org/docs/latest/news.html) for new features, caveats and
|
notes](https://www.glfw.org/docs/latest/news.html) for new features, caveats and
|
||||||
deprecations in the latest release. For more details see the [version
|
deprecations in the latest release. For more details see the [version
|
||||||
history](http://www.glfw.org/changelog.html).
|
history](https://www.glfw.org/changelog.html).
|
||||||
|
|
||||||
The `master` branch is the stable integration branch and _should_ always compile
|
The `master` branch is the stable integration branch and _should_ always compile
|
||||||
and run on all supported platforms, although details of newly added features may
|
and run on all supported platforms, although details of newly added features may
|
||||||
@ -34,11 +34,16 @@ fixes live in [other branches](https://github.com/glfw/glfw/branches/all) until
|
|||||||
they are stable enough to merge.
|
they are stable enough to merge.
|
||||||
|
|
||||||
If you are new to GLFW, you may find the
|
If you are new to GLFW, you may find the
|
||||||
[tutorial](http://www.glfw.org/docs/latest/quick.html) for GLFW 3 useful. If
|
[tutorial](https://www.glfw.org/docs/latest/quick.html) for GLFW 3 useful. If
|
||||||
you have used GLFW 2 in the past, there is a [transition
|
you have used GLFW 2 in the past, there is a [transition
|
||||||
guide](http://www.glfw.org/docs/latest/moving.html) for moving to the GLFW
|
guide](https://www.glfw.org/docs/latest/moving.html) for moving to the GLFW
|
||||||
3 API.
|
3 API.
|
||||||
|
|
||||||
|
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
|
## Compiling GLFW
|
||||||
|
|
||||||
@ -52,16 +57,16 @@ MinGW-w64, on macOS with Clang and on Linux and other Unix-like systems with GCC
|
|||||||
and Clang. It will likely compile in other environments as well, but this is
|
and Clang. It will likely compile in other environments as well, but this is
|
||||||
not regularly tested.
|
not regularly tested.
|
||||||
|
|
||||||
There are [pre-compiled Windows binaries](http://www.glfw.org/download.html)
|
There are [pre-compiled Windows binaries](https://www.glfw.org/download.html)
|
||||||
available for all supported compilers.
|
available for all supported compilers.
|
||||||
|
|
||||||
See the [compilation guide](http://www.glfw.org/docs/latest/compile.html) for
|
See the [compilation guide](https://www.glfw.org/docs/latest/compile.html) for
|
||||||
more information about how to compile GLFW yourself.
|
more information about how to compile GLFW yourself.
|
||||||
|
|
||||||
|
|
||||||
## Using GLFW
|
## Using GLFW
|
||||||
|
|
||||||
See the [documentation](http://www.glfw.org/docs/latest/) for tutorials, guides
|
See the [documentation](https://www.glfw.org/docs/latest/) for tutorials, guides
|
||||||
and the API reference.
|
and the API reference.
|
||||||
|
|
||||||
|
|
||||||
@ -79,7 +84,7 @@ Unix-like systems running the X Window System are supported even without
|
|||||||
a desktop environment or modern extensions, although some features require
|
a desktop environment or modern extensions, although some features require
|
||||||
a running window or clipboard manager. The OSMesa backend requires Mesa 6.3.
|
a running window or clipboard manager. The OSMesa backend requires Mesa 6.3.
|
||||||
|
|
||||||
See the [compatibility guide](http://www.glfw.org/docs/latest/compat.html)
|
See the [compatibility guide](https://www.glfw.org/docs/latest/compat.html)
|
||||||
in the documentation for more information.
|
in the documentation for more information.
|
||||||
|
|
||||||
|
|
||||||
@ -88,9 +93,6 @@ in the documentation for more information.
|
|||||||
GLFW itself needs only CMake 3.1 or later and the headers and libraries for your
|
GLFW itself needs only CMake 3.1 or later and the headers and libraries for your
|
||||||
OS and window system.
|
OS and window system.
|
||||||
|
|
||||||
The (experimental) Wayland backend also depends on the `extra-cmake-modules`
|
|
||||||
package, which is used to generate Wayland protocol headers.
|
|
||||||
|
|
||||||
The examples and test programs depend on a number of tiny libraries. These are
|
The examples and test programs depend on a number of tiny libraries. These are
|
||||||
located in the `deps/` directory.
|
located in the `deps/` directory.
|
||||||
|
|
||||||
@ -102,10 +104,10 @@ located in the `deps/` directory.
|
|||||||
functions
|
functions
|
||||||
- [linmath.h](https://github.com/datenwolf/linmath.h) for linear algebra in
|
- [linmath.h](https://github.com/datenwolf/linmath.h) for linear algebra in
|
||||||
examples
|
examples
|
||||||
- [Nuklear](https://github.com/vurtun/nuklear) for test and example UI
|
- [Nuklear](https://github.com/Immediate-Mode-UI/Nuklear) for test and example UI
|
||||||
- [stb\_image\_write](https://github.com/nothings/stb) for writing images to disk
|
- [stb\_image\_write](https://github.com/nothings/stb) for writing images to disk
|
||||||
|
|
||||||
The documentation is generated with [Doxygen](http://doxygen.org/) if CMake can
|
The documentation is generated with [Doxygen](https://doxygen.org/) if CMake can
|
||||||
find that tool.
|
find that tool.
|
||||||
|
|
||||||
|
|
||||||
@ -119,21 +121,62 @@ information on what to include when reporting a bug.
|
|||||||
|
|
||||||
## Changelog
|
## Changelog
|
||||||
|
|
||||||
|
- Added `GLFW_PLATFORM` init hint for runtime platform selection (#1958)
|
||||||
|
- Added `GLFW_ANY_PLATFORM`, `GLFW_PLATFORM_WIN32`, `GLFW_PLATFORM_COCOA`,
|
||||||
|
`GLFW_PLATFORM_WAYLAND`, `GLFW_PLATFORM_X11` and `GLFW_PLATFORM_NULL` symbols to
|
||||||
|
specify the desired platform (#1958)
|
||||||
|
- Added `glfwGetPlatform` function to query what platform was selected (#1655,#1958)
|
||||||
|
- Added `glfwPlatformSupported` function to query if a platform is supported
|
||||||
|
(#1655,#1958)
|
||||||
|
- Added `glfwInitAllocator` for setting a custom memory allocator (#544,#1628,#1947)
|
||||||
|
- Added `GLFWallocator` struct and `GLFWallocatefun`, `GLFWreallocatefun` and
|
||||||
|
`GLFWdeallocatefun` types (#544,#1628,#1947)
|
||||||
|
- Added `glfwInitVulkanLoader` for using a non-default Vulkan loader (#1374,#1890)
|
||||||
- Added `GLFW_RESIZE_NWSE_CURSOR`, `GLFW_RESIZE_NESW_CURSOR`,
|
- Added `GLFW_RESIZE_NWSE_CURSOR`, `GLFW_RESIZE_NESW_CURSOR`,
|
||||||
`GLFW_RESIZE_ALL_CURSOR` and `GLFW_NOT_ALLOWED_CURSOR` cursor shapes (#427)
|
`GLFW_RESIZE_ALL_CURSOR` and `GLFW_NOT_ALLOWED_CURSOR` cursor shapes (#427)
|
||||||
- Added `GLFW_RESIZE_EW_CURSOR` alias for `GLFW_HRESIZE_CURSOR` (#427)
|
- Added `GLFW_RESIZE_EW_CURSOR` alias for `GLFW_HRESIZE_CURSOR` (#427)
|
||||||
- Added `GLFW_RESIZE_NS_CURSOR` alias for `GLFW_VRESIZE_CURSOR` (#427)
|
- Added `GLFW_RESIZE_NS_CURSOR` alias for `GLFW_VRESIZE_CURSOR` (#427)
|
||||||
- Added `GLFW_POINTING_HAND_CURSOR` alias for `GLFW_HAND_CURSOR` (#427)
|
- Added `GLFW_POINTING_HAND_CURSOR` alias for `GLFW_HAND_CURSOR` (#427)
|
||||||
|
- Added `GLFW_MOUSE_PASSTHROUGH` window hint for letting mouse input pass
|
||||||
|
through the window (#1236,#1568)
|
||||||
|
- Added `GLFW_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
|
||||||
|
variables exposing pkg-config dependencies (#1307)
|
||||||
|
- Made joystick subsystem initialize at first use (#1284,#1646)
|
||||||
|
- Made `GLFW_DOUBLEBUFFER` a read-only window attribute
|
||||||
- Updated the minimum required CMake version to 3.1
|
- 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
|
- 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
|
- Bugfix: The CMake config-file package used an absolute path and was not
|
||||||
relocatable (#1470)
|
relocatable (#1470)
|
||||||
- Bugfix: Video modes with a duplicate screen area were discarded (#1555,#1556)
|
- Bugfix: Video modes with a duplicate screen area were discarded (#1555,#1556)
|
||||||
- Bugfix: Compiling with -Wextra-semi caused warnings (#1440)
|
- Bugfix: Compiling with -Wextra-semi caused warnings (#1440)
|
||||||
- Bugfix: Built-in mappings failed because some OEMs re-used VID/PID (#1583)
|
- Bugfix: Built-in mappings failed because some OEMs re-used VID/PID (#1583)
|
||||||
|
- Bugfix: Some extension loader headers did not prevent default OpenGL header
|
||||||
|
inclusion (#1695)
|
||||||
|
- 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
|
- [Win32] Added the `GLFW_WIN32_KEYBOARD_MENU` window hint for enabling access
|
||||||
to the window menu
|
to the window menu
|
||||||
- [Win32] Added a version info resource to the GLFW DLL
|
- [Win32] Added a version info resource to the GLFW DLL
|
||||||
|
- [Win32] Disabled framebuffer transparency on Windows 7 when DWM windows are
|
||||||
|
opaque (#1512)
|
||||||
- [Win32] Bugfix: `GLFW_INCLUDE_VULKAN` plus `VK_USE_PLATFORM_WIN32_KHR` caused
|
- [Win32] Bugfix: `GLFW_INCLUDE_VULKAN` plus `VK_USE_PLATFORM_WIN32_KHR` caused
|
||||||
symbol redefinition (#1524)
|
symbol redefinition (#1524)
|
||||||
- [Win32] Bugfix: The cursor position event was emitted before its cursor enter
|
- [Win32] Bugfix: The cursor position event was emitted before its cursor enter
|
||||||
@ -146,9 +189,28 @@ information on what to include when reporting a bug.
|
|||||||
invalid pointer
|
invalid pointer
|
||||||
- [Win32] Bugfix: Some synthetic key events were reported as `GLFW_KEY_UNKNOWN`
|
- [Win32] Bugfix: Some synthetic key events were reported as `GLFW_KEY_UNKNOWN`
|
||||||
(#1623)
|
(#1623)
|
||||||
|
- [Win32] Bugfix: Non-BMP Unicode codepoint input was reported as UTF-16
|
||||||
|
- [Win32] Bugfix: Monitor functions could return invalid values after
|
||||||
|
configuration change (#1761)
|
||||||
|
- [Win32] Bugfix: Initialization would segfault on Windows 8 (not 8.1) (#1775)
|
||||||
|
- [Win32] Bugfix: Duplicate size events were not filtered (#1610)
|
||||||
|
- [Win32] Bugfix: Full screen windows were incorrectly resized by DPI changes
|
||||||
|
(#1582)
|
||||||
|
- [Win32] Bugfix: `GLFW_SCALE_TO_MONITOR` had no effect on systems older than
|
||||||
|
Windows 10 version 1703 (#1511)
|
||||||
|
- [Win32] Bugfix: `USE_MSVC_RUNTIME_LIBRARY_DLL` had no effect on CMake 3.15 or
|
||||||
|
later (#1783,#1796)
|
||||||
|
- [Win32] Bugfix: Compilation with LLVM for Windows failed (#1807,#1824,#1874)
|
||||||
|
- [Win32] Bugfix: The foreground lock timeout was overridden, ignoring the user
|
||||||
|
- [Win32] Bugfix: Content scale queries could fail silently (#1615)
|
||||||
|
- [Win32] Bugfix: Content scales could have garbage values if monitor was recently
|
||||||
|
disconnected (#1615)
|
||||||
- [Cocoa] Added support for `VK_EXT_metal_surface` (#1619)
|
- [Cocoa] Added support for `VK_EXT_metal_surface` (#1619)
|
||||||
- [Cocoa] Added locating the Vulkan loader at runtime in an application bundle
|
- [Cocoa] Added locating the Vulkan loader at runtime in an application bundle
|
||||||
- [Cocoa] Moved main menu creation to GLFW initialization time (#1649)
|
- [Cocoa] Moved main menu creation to GLFW initialization time (#1649)
|
||||||
|
- [Cocoa] Changed `EGLNativeWindowType` from `NSView` to `CALayer` (#1169)
|
||||||
|
- [Cocoa] Changed F13 key to report Print Screen for cross-platform consistency
|
||||||
|
(#1786)
|
||||||
- [Cocoa] Removed dependency on the CoreVideo framework
|
- [Cocoa] Removed dependency on the CoreVideo framework
|
||||||
- [Cocoa] Bugfix: `glfwSetWindowSize` used a bottom-left anchor point (#1553)
|
- [Cocoa] Bugfix: `glfwSetWindowSize` used a bottom-left anchor point (#1553)
|
||||||
- [Cocoa] Bugfix: Window remained on screen after destruction until event poll
|
- [Cocoa] Bugfix: Window remained on screen after destruction until event poll
|
||||||
@ -157,6 +219,22 @@ information on what to include when reporting a bug.
|
|||||||
- [Cocoa] Bugfix: Undecorated windows could not be iconified on recent macOS
|
- [Cocoa] Bugfix: Undecorated windows could not be iconified on recent macOS
|
||||||
- [Cocoa] Bugfix: Touching event queue from secondary thread before main thread
|
- [Cocoa] Bugfix: Touching event queue from secondary thread before main thread
|
||||||
would abort (#1649)
|
would abort (#1649)
|
||||||
|
- [Cocoa] Bugfix: Non-BMP Unicode codepoint input was reported as UTF-16
|
||||||
|
(#1635)
|
||||||
|
- [Cocoa] Bugfix: Failing to retrieve the refresh rate of built-in displays
|
||||||
|
could leak memory
|
||||||
|
- [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: 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)
|
||||||
- [X11] Bugfix: The CMake files did not check for the XInput headers (#1480)
|
- [X11] Bugfix: The CMake files did not check for the XInput headers (#1480)
|
||||||
- [X11] Bugfix: Key names were not updated when the keyboard layout changed
|
- [X11] Bugfix: Key names were not updated when the keyboard layout changed
|
||||||
(#1462,#1528)
|
(#1462,#1528)
|
||||||
@ -179,25 +257,63 @@ information on what to include when reporting a bug.
|
|||||||
- [X11] Bugfix: XKB path used keysyms instead of physical locations for
|
- [X11] Bugfix: XKB path used keysyms instead of physical locations for
|
||||||
non-printable keys (#1598)
|
non-printable keys (#1598)
|
||||||
- [X11] Bugfix: Function keys were mapped to `GLFW_KEY_UNKNOWN` for some layout
|
- [X11] Bugfix: Function keys were mapped to `GLFW_KEY_UNKNOWN` for some layout
|
||||||
combinaitons (#1598)
|
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
|
||||||
|
- [Wayland] Added dynamic loading of all Wayland libraries
|
||||||
|
- [Wayland] Added support for key names via xkbcommon
|
||||||
- [Wayland] Removed support for `wl_shell` (#1443)
|
- [Wayland] Removed support for `wl_shell` (#1443)
|
||||||
- [Wayland] Bugfix: The `GLFW_HAND_CURSOR` shape used the wrong image (#1432)
|
- [Wayland] Bugfix: The `GLFW_HAND_CURSOR` shape used the wrong image (#1432)
|
||||||
- [Wayland] Bugfix: `CLOCK_MONOTONIC` was not correctly enabled
|
- [Wayland] Bugfix: `CLOCK_MONOTONIC` was not correctly enabled
|
||||||
|
- [Wayland] Bugfix: Repeated keys could be reported with `NULL` window (#1704)
|
||||||
|
- [Wayland] Bugfix: Retrieving partial framebuffer size would segfault
|
||||||
|
- [Wayland] Bugfix: Scrolling offsets were inverted compared to other platforms
|
||||||
|
(#1463)
|
||||||
|
- [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
|
||||||
|
- [POSIX] Removed use of deprecated function `gettimeofday`
|
||||||
- [POSIX] Bugfix: `CLOCK_MONOTONIC` was not correctly tested for or enabled
|
- [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] Removed enforcement of forward-compatible flag for core contexts
|
||||||
- [NSGL] Bugfix: `GLFW_COCOA_RETINA_FRAMEBUFFER` had no effect on newer
|
- [NSGL] Bugfix: `GLFW_COCOA_RETINA_FRAMEBUFFER` had no effect on newer
|
||||||
macOS versions (#1442)
|
macOS versions (#1442)
|
||||||
- [NSGL] Bugfix: Workaround for swap interval on 10.14 broke on 10.12 (#1483)
|
- [NSGL] Bugfix: Workaround for swap interval on 10.14 broke on 10.12 (#1483)
|
||||||
|
- [NSGL] Bugfix: Defining `GL_SILENCE_DEPRECATION` externally caused
|
||||||
|
a duplicate definition warning (#1840)
|
||||||
|
- [EGL] Added platform selection via the `EGL_EXT_platform_base` extension
|
||||||
|
(#442)
|
||||||
|
- [EGL] Added ANGLE backend selection via `EGL_ANGLE_platform_angle` extension
|
||||||
|
(#1380)
|
||||||
|
- [EGL] Bugfix: The `GLFW_DOUBLEBUFFER` context attribute was ignored (#1843)
|
||||||
|
|
||||||
|
|
||||||
## Contact
|
## Contact
|
||||||
|
|
||||||
On [glfw.org](http://www.glfw.org/) you can find the latest version of GLFW, as
|
On [glfw.org](https://www.glfw.org/) you can find the latest version of GLFW, as
|
||||||
well as news, documentation and other information about the project.
|
well as news, documentation and other information about the project.
|
||||||
|
|
||||||
If you have questions related to the use of GLFW, we have a
|
If you have questions related to the use of GLFW, we have a
|
||||||
[forum](https://discourse.glfw.org/), and the `#glfw` IRC channel on
|
[forum](https://discourse.glfw.org/), and the `#glfw` IRC channel on
|
||||||
[Freenode](http://freenode.net/).
|
[Libera.Chat](https://libera.chat/).
|
||||||
|
|
||||||
If you have a bug to report, a patch to submit or a feature you'd like to
|
If you have a bug to report, a patch to submit or a feature you'd like to
|
||||||
request, please file it in the
|
request, please file it in the
|
||||||
@ -206,201 +322,3 @@ request, please file it in the
|
|||||||
Finally, if you're interested in helping out with the development of GLFW or
|
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.
|
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
|
|
||||||
- Matt Arsenault
|
|
||||||
- David Avedissian
|
|
||||||
- Keith Bauer
|
|
||||||
- John Bartholomew
|
|
||||||
- Coşku Baş
|
|
||||||
- Niklas Behrens
|
|
||||||
- Andrew Belt
|
|
||||||
- Niklas Bergström
|
|
||||||
- Denis Bernard
|
|
||||||
- Doug Binks
|
|
||||||
- blanco
|
|
||||||
- Kyle Brenneman
|
|
||||||
- Rok Breulj
|
|
||||||
- Kai Burjack
|
|
||||||
- Martin Capitanio
|
|
||||||
- David Carlier
|
|
||||||
- Arturo Castro
|
|
||||||
- Chi-kwan Chan
|
|
||||||
- Ian Clarkson
|
|
||||||
- Michał Cichoń
|
|
||||||
- Lambert Clara
|
|
||||||
- Anna Clarke
|
|
||||||
- Yaron Cohen-Tal
|
|
||||||
- Omar Cornut
|
|
||||||
- Andrew Corrigan
|
|
||||||
- Bailey Cosier
|
|
||||||
- Noel Cower
|
|
||||||
- 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
|
|
||||||
- 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
|
|
||||||
- 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
|
|
||||||
- Josh Kilmer
|
|
||||||
- Byunghoon Kim
|
|
||||||
- Cameron King
|
|
||||||
- Peter Knut
|
|
||||||
- Christoph Kubisch
|
|
||||||
- Yuri Kunde Schlesner
|
|
||||||
- Rokas Kupstys
|
|
||||||
- Konstantin Käfer
|
|
||||||
- Eric Larson
|
|
||||||
- Francis Lecavalier
|
|
||||||
- Robin Leffmann
|
|
||||||
- Glenn Lewis
|
|
||||||
- Shane Liesegang
|
|
||||||
- Anders Lindqvist
|
|
||||||
- Leon Linhart
|
|
||||||
- Eyal Lotem
|
|
||||||
- Aaron Loucks
|
|
||||||
- Luflosi
|
|
||||||
- lukect
|
|
||||||
- Tristam MacDonald
|
|
||||||
- Hans Mackowiak
|
|
||||||
- Дмитри Малышев
|
|
||||||
- Zbigniew Mandziejewicz
|
|
||||||
- Adam Marcus
|
|
||||||
- Célestin Marot
|
|
||||||
- Kyle McDonald
|
|
||||||
- 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
|
|
||||||
- Kristian Nielsen
|
|
||||||
- Kamil Nowakowski
|
|
||||||
- Denis Ovod
|
|
||||||
- Ozzy
|
|
||||||
- Andri Pálsson
|
|
||||||
- Peoro
|
|
||||||
- Braden Pellett
|
|
||||||
- Christopher Pelloux
|
|
||||||
- Arturo J. Pérez
|
|
||||||
- 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
|
|
||||||
- Ed Ropple
|
|
||||||
- Aleksey Rybalkin
|
|
||||||
- Riku Salminen
|
|
||||||
- Brandon Schaefer
|
|
||||||
- Sebastian Schuberth
|
|
||||||
- Christian Sdunek
|
|
||||||
- Matt Sealey
|
|
||||||
- Steve Sexton
|
|
||||||
- Arkady Shapkin
|
|
||||||
- Ali Sherief
|
|
||||||
- Yoshiki Shibukawa
|
|
||||||
- Dmitri Shuralyov
|
|
||||||
- Daniel Skorupski
|
|
||||||
- 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
|
|
||||||
- Ryogo Yoshimura
|
|
||||||
- Lukas Zanner
|
|
||||||
- Andrey Zholos
|
|
||||||
- Santi Zupancic
|
|
||||||
- Jonas Ådahl
|
|
||||||
- Lasse Öörni
|
|
||||||
- All the unmentioned and anonymous contributors in the GLFW community, for bug
|
|
||||||
reports, patches, feedback, testing and encouragement
|
|
||||||
|
|
||||||
|
2198
deps/glad/gl.h
vendored
2198
deps/glad/gl.h
vendored
File diff suppressed because it is too large
Load Diff
1805
deps/glad/gles2.h
vendored
Normal file
1805
deps/glad/gles2.h
vendored
Normal file
File diff suppressed because it is too large
Load Diff
282
deps/glad/khrplatform.h
vendored
282
deps/glad/khrplatform.h
vendored
@ -1,282 +0,0 @@
|
|||||||
#ifndef __khrplatform_h_
|
|
||||||
#define __khrplatform_h_
|
|
||||||
|
|
||||||
/*
|
|
||||||
** Copyright (c) 2008-2018 The Khronos Group Inc.
|
|
||||||
**
|
|
||||||
** Permission is hereby granted, free of charge, to any person obtaining a
|
|
||||||
** copy of this software and/or associated documentation files (the
|
|
||||||
** "Materials"), to deal in the Materials without restriction, including
|
|
||||||
** without limitation the rights to use, copy, modify, merge, publish,
|
|
||||||
** distribute, sublicense, and/or sell copies of the Materials, and to
|
|
||||||
** permit persons to whom the Materials are furnished to do so, subject to
|
|
||||||
** the following conditions:
|
|
||||||
**
|
|
||||||
** The above copyright notice and this permission notice shall be included
|
|
||||||
** in all copies or substantial portions of the Materials.
|
|
||||||
**
|
|
||||||
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
||||||
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
||||||
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
||||||
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
||||||
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Khronos platform-specific types and definitions.
|
|
||||||
*
|
|
||||||
* The master copy of khrplatform.h is maintained in the Khronos EGL
|
|
||||||
* Registry repository at https://github.com/KhronosGroup/EGL-Registry
|
|
||||||
* The last semantic modification to khrplatform.h was at commit ID:
|
|
||||||
* 67a3e0864c2d75ea5287b9f3d2eb74a745936692
|
|
||||||
*
|
|
||||||
* Adopters may modify this file to suit their platform. Adopters are
|
|
||||||
* encouraged to submit platform specific modifications to the Khronos
|
|
||||||
* group so that they can be included in future versions of this file.
|
|
||||||
* Please submit changes by filing pull requests or issues on
|
|
||||||
* the EGL Registry repository linked above.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* See the Implementer's Guidelines for information about where this file
|
|
||||||
* should be located on your system and for more details of its use:
|
|
||||||
* http://www.khronos.org/registry/implementers_guide.pdf
|
|
||||||
*
|
|
||||||
* This file should be included as
|
|
||||||
* #include <KHR/khrplatform.h>
|
|
||||||
* by Khronos client API header files that use its types and defines.
|
|
||||||
*
|
|
||||||
* The types in khrplatform.h should only be used to define API-specific types.
|
|
||||||
*
|
|
||||||
* Types defined in khrplatform.h:
|
|
||||||
* khronos_int8_t signed 8 bit
|
|
||||||
* khronos_uint8_t unsigned 8 bit
|
|
||||||
* khronos_int16_t signed 16 bit
|
|
||||||
* khronos_uint16_t unsigned 16 bit
|
|
||||||
* khronos_int32_t signed 32 bit
|
|
||||||
* khronos_uint32_t unsigned 32 bit
|
|
||||||
* khronos_int64_t signed 64 bit
|
|
||||||
* khronos_uint64_t unsigned 64 bit
|
|
||||||
* khronos_intptr_t signed same number of bits as a pointer
|
|
||||||
* khronos_uintptr_t unsigned same number of bits as a pointer
|
|
||||||
* khronos_ssize_t signed size
|
|
||||||
* khronos_usize_t unsigned size
|
|
||||||
* khronos_float_t signed 32 bit floating point
|
|
||||||
* khronos_time_ns_t unsigned 64 bit time in nanoseconds
|
|
||||||
* khronos_utime_nanoseconds_t unsigned time interval or absolute time in
|
|
||||||
* nanoseconds
|
|
||||||
* khronos_stime_nanoseconds_t signed time interval in nanoseconds
|
|
||||||
* khronos_boolean_enum_t enumerated boolean type. This should
|
|
||||||
* only be used as a base type when a client API's boolean type is
|
|
||||||
* an enum. Client APIs which use an integer or other type for
|
|
||||||
* booleans cannot use this as the base type for their boolean.
|
|
||||||
*
|
|
||||||
* Tokens defined in khrplatform.h:
|
|
||||||
*
|
|
||||||
* KHRONOS_FALSE, KHRONOS_TRUE Enumerated boolean false/true values.
|
|
||||||
*
|
|
||||||
* KHRONOS_SUPPORT_INT64 is 1 if 64 bit integers are supported; otherwise 0.
|
|
||||||
* KHRONOS_SUPPORT_FLOAT is 1 if floats are supported; otherwise 0.
|
|
||||||
*
|
|
||||||
* Calling convention macros defined in this file:
|
|
||||||
* KHRONOS_APICALL
|
|
||||||
* KHRONOS_APIENTRY
|
|
||||||
* KHRONOS_APIATTRIBUTES
|
|
||||||
*
|
|
||||||
* These may be used in function prototypes as:
|
|
||||||
*
|
|
||||||
* KHRONOS_APICALL void KHRONOS_APIENTRY funcname(
|
|
||||||
* int arg1,
|
|
||||||
* int arg2) KHRONOS_APIATTRIBUTES;
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*-------------------------------------------------------------------------
|
|
||||||
* Definition of KHRONOS_APICALL
|
|
||||||
*-------------------------------------------------------------------------
|
|
||||||
* This precedes the return type of the function in the function prototype.
|
|
||||||
*/
|
|
||||||
#if defined(_WIN32) && !defined(__SCITECH_SNAP__)
|
|
||||||
# define KHRONOS_APICALL __declspec(dllimport)
|
|
||||||
#elif defined (__SYMBIAN32__)
|
|
||||||
# define KHRONOS_APICALL IMPORT_C
|
|
||||||
#elif defined(__ANDROID__)
|
|
||||||
# define KHRONOS_APICALL __attribute__((visibility("default")))
|
|
||||||
#else
|
|
||||||
# define KHRONOS_APICALL
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*-------------------------------------------------------------------------
|
|
||||||
* Definition of KHRONOS_APIENTRY
|
|
||||||
*-------------------------------------------------------------------------
|
|
||||||
* This follows the return type of the function and precedes the function
|
|
||||||
* name in the function prototype.
|
|
||||||
*/
|
|
||||||
#if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(__SCITECH_SNAP__)
|
|
||||||
/* Win32 but not WinCE */
|
|
||||||
# define KHRONOS_APIENTRY __stdcall
|
|
||||||
#else
|
|
||||||
# define KHRONOS_APIENTRY
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*-------------------------------------------------------------------------
|
|
||||||
* Definition of KHRONOS_APIATTRIBUTES
|
|
||||||
*-------------------------------------------------------------------------
|
|
||||||
* This follows the closing parenthesis of the function prototype arguments.
|
|
||||||
*/
|
|
||||||
#if defined (__ARMCC_2__)
|
|
||||||
#define KHRONOS_APIATTRIBUTES __softfp
|
|
||||||
#else
|
|
||||||
#define KHRONOS_APIATTRIBUTES
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*-------------------------------------------------------------------------
|
|
||||||
* basic type definitions
|
|
||||||
*-----------------------------------------------------------------------*/
|
|
||||||
#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__GNUC__) || defined(__SCO__) || defined(__USLC__)
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Using <stdint.h>
|
|
||||||
*/
|
|
||||||
#include <stdint.h>
|
|
||||||
typedef int32_t khronos_int32_t;
|
|
||||||
typedef uint32_t khronos_uint32_t;
|
|
||||||
typedef int64_t khronos_int64_t;
|
|
||||||
typedef uint64_t khronos_uint64_t;
|
|
||||||
#define KHRONOS_SUPPORT_INT64 1
|
|
||||||
#define KHRONOS_SUPPORT_FLOAT 1
|
|
||||||
|
|
||||||
#elif defined(__VMS ) || defined(__sgi)
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Using <inttypes.h>
|
|
||||||
*/
|
|
||||||
#include <inttypes.h>
|
|
||||||
typedef int32_t khronos_int32_t;
|
|
||||||
typedef uint32_t khronos_uint32_t;
|
|
||||||
typedef int64_t khronos_int64_t;
|
|
||||||
typedef uint64_t khronos_uint64_t;
|
|
||||||
#define KHRONOS_SUPPORT_INT64 1
|
|
||||||
#define KHRONOS_SUPPORT_FLOAT 1
|
|
||||||
|
|
||||||
#elif defined(_WIN32) && !defined(__SCITECH_SNAP__)
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Win32
|
|
||||||
*/
|
|
||||||
typedef __int32 khronos_int32_t;
|
|
||||||
typedef unsigned __int32 khronos_uint32_t;
|
|
||||||
typedef __int64 khronos_int64_t;
|
|
||||||
typedef unsigned __int64 khronos_uint64_t;
|
|
||||||
#define KHRONOS_SUPPORT_INT64 1
|
|
||||||
#define KHRONOS_SUPPORT_FLOAT 1
|
|
||||||
|
|
||||||
#elif defined(__sun__) || defined(__digital__)
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Sun or Digital
|
|
||||||
*/
|
|
||||||
typedef int khronos_int32_t;
|
|
||||||
typedef unsigned int khronos_uint32_t;
|
|
||||||
#if defined(__arch64__) || defined(_LP64)
|
|
||||||
typedef long int khronos_int64_t;
|
|
||||||
typedef unsigned long int khronos_uint64_t;
|
|
||||||
#else
|
|
||||||
typedef long long int khronos_int64_t;
|
|
||||||
typedef unsigned long long int khronos_uint64_t;
|
|
||||||
#endif /* __arch64__ */
|
|
||||||
#define KHRONOS_SUPPORT_INT64 1
|
|
||||||
#define KHRONOS_SUPPORT_FLOAT 1
|
|
||||||
|
|
||||||
#elif 0
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Hypothetical platform with no float or int64 support
|
|
||||||
*/
|
|
||||||
typedef int khronos_int32_t;
|
|
||||||
typedef unsigned int khronos_uint32_t;
|
|
||||||
#define KHRONOS_SUPPORT_INT64 0
|
|
||||||
#define KHRONOS_SUPPORT_FLOAT 0
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Generic fallback
|
|
||||||
*/
|
|
||||||
#include <stdint.h>
|
|
||||||
typedef int32_t khronos_int32_t;
|
|
||||||
typedef uint32_t khronos_uint32_t;
|
|
||||||
typedef int64_t khronos_int64_t;
|
|
||||||
typedef uint64_t khronos_uint64_t;
|
|
||||||
#define KHRONOS_SUPPORT_INT64 1
|
|
||||||
#define KHRONOS_SUPPORT_FLOAT 1
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Types that are (so far) the same on all platforms
|
|
||||||
*/
|
|
||||||
typedef signed char khronos_int8_t;
|
|
||||||
typedef unsigned char khronos_uint8_t;
|
|
||||||
typedef signed short int khronos_int16_t;
|
|
||||||
typedef unsigned short int khronos_uint16_t;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Types that differ between LLP64 and LP64 architectures - in LLP64,
|
|
||||||
* pointers are 64 bits, but 'long' is still 32 bits. Win64 appears
|
|
||||||
* to be the only LLP64 architecture in current use.
|
|
||||||
*/
|
|
||||||
#ifdef _WIN64
|
|
||||||
typedef signed long long int khronos_intptr_t;
|
|
||||||
typedef unsigned long long int khronos_uintptr_t;
|
|
||||||
typedef signed long long int khronos_ssize_t;
|
|
||||||
typedef unsigned long long int khronos_usize_t;
|
|
||||||
#else
|
|
||||||
typedef signed long int khronos_intptr_t;
|
|
||||||
typedef unsigned long int khronos_uintptr_t;
|
|
||||||
typedef signed long int khronos_ssize_t;
|
|
||||||
typedef unsigned long int khronos_usize_t;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if KHRONOS_SUPPORT_FLOAT
|
|
||||||
/*
|
|
||||||
* Float type
|
|
||||||
*/
|
|
||||||
typedef float khronos_float_t;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if KHRONOS_SUPPORT_INT64
|
|
||||||
/* Time types
|
|
||||||
*
|
|
||||||
* These types can be used to represent a time interval in nanoseconds or
|
|
||||||
* an absolute Unadjusted System Time. Unadjusted System Time is the number
|
|
||||||
* of nanoseconds since some arbitrary system event (e.g. since the last
|
|
||||||
* time the system booted). The Unadjusted System Time is an unsigned
|
|
||||||
* 64 bit value that wraps back to 0 every 584 years. Time intervals
|
|
||||||
* may be either signed or unsigned.
|
|
||||||
*/
|
|
||||||
typedef khronos_uint64_t khronos_utime_nanoseconds_t;
|
|
||||||
typedef khronos_int64_t khronos_stime_nanoseconds_t;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Dummy value used to pad enum types to 32 bits.
|
|
||||||
*/
|
|
||||||
#ifndef KHRONOS_MAX_ENUM
|
|
||||||
#define KHRONOS_MAX_ENUM 0x7FFFFFFF
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Enumerated boolean type
|
|
||||||
*
|
|
||||||
* Values other than zero should be considered to be true. Therefore
|
|
||||||
* comparisons should not be made against KHRONOS_TRUE.
|
|
||||||
*/
|
|
||||||
typedef enum {
|
|
||||||
KHRONOS_FALSE = 0,
|
|
||||||
KHRONOS_TRUE = 1,
|
|
||||||
KHRONOS_BOOLEAN_ENUM_FORCE_SIZE = KHRONOS_MAX_ENUM
|
|
||||||
} khronos_boolean_enum_t;
|
|
||||||
|
|
||||||
#endif /* __khrplatform_h_ */
|
|
92
deps/glad/vk_platform.h
vendored
92
deps/glad/vk_platform.h
vendored
@ -1,92 +0,0 @@
|
|||||||
/* */
|
|
||||||
/* File: vk_platform.h */
|
|
||||||
/* */
|
|
||||||
/*
|
|
||||||
** Copyright (c) 2014-2017 The Khronos Group Inc.
|
|
||||||
**
|
|
||||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
** you may not use this file except in compliance with the License.
|
|
||||||
** You may obtain a copy of the License at
|
|
||||||
**
|
|
||||||
** http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
**
|
|
||||||
** Unless required by applicable law or agreed to in writing, software
|
|
||||||
** distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
** See the License for the specific language governing permissions and
|
|
||||||
** limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef VK_PLATFORM_H_
|
|
||||||
#define VK_PLATFORM_H_
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
#endif /* __cplusplus */
|
|
||||||
|
|
||||||
/*
|
|
||||||
***************************************************************************************************
|
|
||||||
* Platform-specific directives and type declarations
|
|
||||||
***************************************************************************************************
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Platform-specific calling convention macros.
|
|
||||||
*
|
|
||||||
* Platforms should define these so that Vulkan clients call Vulkan commands
|
|
||||||
* with the same calling conventions that the Vulkan implementation expects.
|
|
||||||
*
|
|
||||||
* VKAPI_ATTR - Placed before the return type in function declarations.
|
|
||||||
* Useful for C++11 and GCC/Clang-style function attribute syntax.
|
|
||||||
* VKAPI_CALL - Placed after the return type in function declarations.
|
|
||||||
* Useful for MSVC-style calling convention syntax.
|
|
||||||
* VKAPI_PTR - Placed between the '(' and '*' in function pointer types.
|
|
||||||
*
|
|
||||||
* Function declaration: VKAPI_ATTR void VKAPI_CALL vkCommand(void);
|
|
||||||
* Function pointer type: typedef void (VKAPI_PTR *PFN_vkCommand)(void);
|
|
||||||
*/
|
|
||||||
#if defined(_WIN32)
|
|
||||||
/* On Windows, Vulkan commands use the stdcall convention */
|
|
||||||
#define VKAPI_ATTR
|
|
||||||
#define VKAPI_CALL __stdcall
|
|
||||||
#define VKAPI_PTR VKAPI_CALL
|
|
||||||
#elif defined(__ANDROID__) && defined(__ARM_ARCH) && __ARM_ARCH < 7
|
|
||||||
#error "Vulkan isn't supported for the 'armeabi' NDK ABI"
|
|
||||||
#elif defined(__ANDROID__) && defined(__ARM_ARCH) && __ARM_ARCH >= 7 && defined(__ARM_32BIT_STATE)
|
|
||||||
/* On Android 32-bit ARM targets, Vulkan functions use the "hardfloat" */
|
|
||||||
/* calling convention, i.e. float parameters are passed in registers. This */
|
|
||||||
/* is true even if the rest of the application passes floats on the stack, */
|
|
||||||
/* as it does by default when compiling for the armeabi-v7a NDK ABI. */
|
|
||||||
#define VKAPI_ATTR __attribute__((pcs("aapcs-vfp")))
|
|
||||||
#define VKAPI_CALL
|
|
||||||
#define VKAPI_PTR VKAPI_ATTR
|
|
||||||
#else
|
|
||||||
/* On other platforms, use the default calling convention */
|
|
||||||
#define VKAPI_ATTR
|
|
||||||
#define VKAPI_CALL
|
|
||||||
#define VKAPI_PTR
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stddef.h>
|
|
||||||
|
|
||||||
#if !defined(VK_NO_STDINT_H)
|
|
||||||
#if defined(_MSC_VER) && (_MSC_VER < 1600)
|
|
||||||
typedef signed __int8 int8_t;
|
|
||||||
typedef unsigned __int8 uint8_t;
|
|
||||||
typedef signed __int16 int16_t;
|
|
||||||
typedef unsigned __int16 uint16_t;
|
|
||||||
typedef signed __int32 int32_t;
|
|
||||||
typedef unsigned __int32 uint32_t;
|
|
||||||
typedef signed __int64 int64_t;
|
|
||||||
typedef unsigned __int64 uint64_t;
|
|
||||||
#else
|
|
||||||
#include <stdint.h>
|
|
||||||
#endif
|
|
||||||
#endif /* !defined(VK_NO_STDINT_H) */
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
} /* extern "C" */
|
|
||||||
#endif /* __cplusplus */
|
|
||||||
|
|
||||||
#endif
|
|
1176
deps/glad/vulkan.h
vendored
1176
deps/glad/vulkan.h
vendored
File diff suppressed because it is too large
Load Diff
1791
deps/glad_gl.c
vendored
1791
deps/glad_gl.c
vendored
File diff suppressed because it is too large
Load Diff
593
deps/glad_vulkan.c
vendored
593
deps/glad_vulkan.c
vendored
@ -1,593 +0,0 @@
|
|||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <glad/vulkan.h>
|
|
||||||
|
|
||||||
#ifndef GLAD_IMPL_UTIL_C_
|
|
||||||
#define GLAD_IMPL_UTIL_C_
|
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
#define GLAD_IMPL_UTIL_SSCANF sscanf_s
|
|
||||||
#else
|
|
||||||
#define GLAD_IMPL_UTIL_SSCANF sscanf
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* GLAD_IMPL_UTIL_C_ */
|
|
||||||
|
|
||||||
|
|
||||||
int GLAD_VK_VERSION_1_0 = 0;
|
|
||||||
int GLAD_VK_VERSION_1_1 = 0;
|
|
||||||
int GLAD_VK_EXT_debug_report = 0;
|
|
||||||
int GLAD_VK_KHR_surface = 0;
|
|
||||||
int GLAD_VK_KHR_swapchain = 0;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
PFN_vkAcquireNextImage2KHR glad_vkAcquireNextImage2KHR = NULL;
|
|
||||||
PFN_vkAcquireNextImageKHR glad_vkAcquireNextImageKHR = NULL;
|
|
||||||
PFN_vkAllocateCommandBuffers glad_vkAllocateCommandBuffers = NULL;
|
|
||||||
PFN_vkAllocateDescriptorSets glad_vkAllocateDescriptorSets = NULL;
|
|
||||||
PFN_vkAllocateMemory glad_vkAllocateMemory = NULL;
|
|
||||||
PFN_vkBeginCommandBuffer glad_vkBeginCommandBuffer = NULL;
|
|
||||||
PFN_vkBindBufferMemory glad_vkBindBufferMemory = NULL;
|
|
||||||
PFN_vkBindBufferMemory2 glad_vkBindBufferMemory2 = NULL;
|
|
||||||
PFN_vkBindImageMemory glad_vkBindImageMemory = NULL;
|
|
||||||
PFN_vkBindImageMemory2 glad_vkBindImageMemory2 = NULL;
|
|
||||||
PFN_vkCmdBeginQuery glad_vkCmdBeginQuery = NULL;
|
|
||||||
PFN_vkCmdBeginRenderPass glad_vkCmdBeginRenderPass = NULL;
|
|
||||||
PFN_vkCmdBindDescriptorSets glad_vkCmdBindDescriptorSets = NULL;
|
|
||||||
PFN_vkCmdBindIndexBuffer glad_vkCmdBindIndexBuffer = NULL;
|
|
||||||
PFN_vkCmdBindPipeline glad_vkCmdBindPipeline = NULL;
|
|
||||||
PFN_vkCmdBindVertexBuffers glad_vkCmdBindVertexBuffers = NULL;
|
|
||||||
PFN_vkCmdBlitImage glad_vkCmdBlitImage = NULL;
|
|
||||||
PFN_vkCmdClearAttachments glad_vkCmdClearAttachments = NULL;
|
|
||||||
PFN_vkCmdClearColorImage glad_vkCmdClearColorImage = NULL;
|
|
||||||
PFN_vkCmdClearDepthStencilImage glad_vkCmdClearDepthStencilImage = NULL;
|
|
||||||
PFN_vkCmdCopyBuffer glad_vkCmdCopyBuffer = NULL;
|
|
||||||
PFN_vkCmdCopyBufferToImage glad_vkCmdCopyBufferToImage = NULL;
|
|
||||||
PFN_vkCmdCopyImage glad_vkCmdCopyImage = NULL;
|
|
||||||
PFN_vkCmdCopyImageToBuffer glad_vkCmdCopyImageToBuffer = NULL;
|
|
||||||
PFN_vkCmdCopyQueryPoolResults glad_vkCmdCopyQueryPoolResults = NULL;
|
|
||||||
PFN_vkCmdDispatch glad_vkCmdDispatch = NULL;
|
|
||||||
PFN_vkCmdDispatchBase glad_vkCmdDispatchBase = NULL;
|
|
||||||
PFN_vkCmdDispatchIndirect glad_vkCmdDispatchIndirect = NULL;
|
|
||||||
PFN_vkCmdDraw glad_vkCmdDraw = NULL;
|
|
||||||
PFN_vkCmdDrawIndexed glad_vkCmdDrawIndexed = NULL;
|
|
||||||
PFN_vkCmdDrawIndexedIndirect glad_vkCmdDrawIndexedIndirect = NULL;
|
|
||||||
PFN_vkCmdDrawIndirect glad_vkCmdDrawIndirect = NULL;
|
|
||||||
PFN_vkCmdEndQuery glad_vkCmdEndQuery = NULL;
|
|
||||||
PFN_vkCmdEndRenderPass glad_vkCmdEndRenderPass = NULL;
|
|
||||||
PFN_vkCmdExecuteCommands glad_vkCmdExecuteCommands = NULL;
|
|
||||||
PFN_vkCmdFillBuffer glad_vkCmdFillBuffer = NULL;
|
|
||||||
PFN_vkCmdNextSubpass glad_vkCmdNextSubpass = NULL;
|
|
||||||
PFN_vkCmdPipelineBarrier glad_vkCmdPipelineBarrier = NULL;
|
|
||||||
PFN_vkCmdPushConstants glad_vkCmdPushConstants = NULL;
|
|
||||||
PFN_vkCmdResetEvent glad_vkCmdResetEvent = NULL;
|
|
||||||
PFN_vkCmdResetQueryPool glad_vkCmdResetQueryPool = NULL;
|
|
||||||
PFN_vkCmdResolveImage glad_vkCmdResolveImage = NULL;
|
|
||||||
PFN_vkCmdSetBlendConstants glad_vkCmdSetBlendConstants = NULL;
|
|
||||||
PFN_vkCmdSetDepthBias glad_vkCmdSetDepthBias = NULL;
|
|
||||||
PFN_vkCmdSetDepthBounds glad_vkCmdSetDepthBounds = NULL;
|
|
||||||
PFN_vkCmdSetDeviceMask glad_vkCmdSetDeviceMask = NULL;
|
|
||||||
PFN_vkCmdSetEvent glad_vkCmdSetEvent = NULL;
|
|
||||||
PFN_vkCmdSetLineWidth glad_vkCmdSetLineWidth = NULL;
|
|
||||||
PFN_vkCmdSetScissor glad_vkCmdSetScissor = NULL;
|
|
||||||
PFN_vkCmdSetStencilCompareMask glad_vkCmdSetStencilCompareMask = NULL;
|
|
||||||
PFN_vkCmdSetStencilReference glad_vkCmdSetStencilReference = NULL;
|
|
||||||
PFN_vkCmdSetStencilWriteMask glad_vkCmdSetStencilWriteMask = NULL;
|
|
||||||
PFN_vkCmdSetViewport glad_vkCmdSetViewport = NULL;
|
|
||||||
PFN_vkCmdUpdateBuffer glad_vkCmdUpdateBuffer = NULL;
|
|
||||||
PFN_vkCmdWaitEvents glad_vkCmdWaitEvents = NULL;
|
|
||||||
PFN_vkCmdWriteTimestamp glad_vkCmdWriteTimestamp = NULL;
|
|
||||||
PFN_vkCreateBuffer glad_vkCreateBuffer = NULL;
|
|
||||||
PFN_vkCreateBufferView glad_vkCreateBufferView = NULL;
|
|
||||||
PFN_vkCreateCommandPool glad_vkCreateCommandPool = NULL;
|
|
||||||
PFN_vkCreateComputePipelines glad_vkCreateComputePipelines = NULL;
|
|
||||||
PFN_vkCreateDebugReportCallbackEXT glad_vkCreateDebugReportCallbackEXT = NULL;
|
|
||||||
PFN_vkCreateDescriptorPool glad_vkCreateDescriptorPool = NULL;
|
|
||||||
PFN_vkCreateDescriptorSetLayout glad_vkCreateDescriptorSetLayout = NULL;
|
|
||||||
PFN_vkCreateDescriptorUpdateTemplate glad_vkCreateDescriptorUpdateTemplate = NULL;
|
|
||||||
PFN_vkCreateDevice glad_vkCreateDevice = NULL;
|
|
||||||
PFN_vkCreateEvent glad_vkCreateEvent = NULL;
|
|
||||||
PFN_vkCreateFence glad_vkCreateFence = NULL;
|
|
||||||
PFN_vkCreateFramebuffer glad_vkCreateFramebuffer = NULL;
|
|
||||||
PFN_vkCreateGraphicsPipelines glad_vkCreateGraphicsPipelines = NULL;
|
|
||||||
PFN_vkCreateImage glad_vkCreateImage = NULL;
|
|
||||||
PFN_vkCreateImageView glad_vkCreateImageView = NULL;
|
|
||||||
PFN_vkCreateInstance glad_vkCreateInstance = NULL;
|
|
||||||
PFN_vkCreatePipelineCache glad_vkCreatePipelineCache = NULL;
|
|
||||||
PFN_vkCreatePipelineLayout glad_vkCreatePipelineLayout = NULL;
|
|
||||||
PFN_vkCreateQueryPool glad_vkCreateQueryPool = NULL;
|
|
||||||
PFN_vkCreateRenderPass glad_vkCreateRenderPass = NULL;
|
|
||||||
PFN_vkCreateSampler glad_vkCreateSampler = NULL;
|
|
||||||
PFN_vkCreateSamplerYcbcrConversion glad_vkCreateSamplerYcbcrConversion = NULL;
|
|
||||||
PFN_vkCreateSemaphore glad_vkCreateSemaphore = NULL;
|
|
||||||
PFN_vkCreateShaderModule glad_vkCreateShaderModule = NULL;
|
|
||||||
PFN_vkCreateSwapchainKHR glad_vkCreateSwapchainKHR = NULL;
|
|
||||||
PFN_vkDebugReportMessageEXT glad_vkDebugReportMessageEXT = NULL;
|
|
||||||
PFN_vkDestroyBuffer glad_vkDestroyBuffer = NULL;
|
|
||||||
PFN_vkDestroyBufferView glad_vkDestroyBufferView = NULL;
|
|
||||||
PFN_vkDestroyCommandPool glad_vkDestroyCommandPool = NULL;
|
|
||||||
PFN_vkDestroyDebugReportCallbackEXT glad_vkDestroyDebugReportCallbackEXT = NULL;
|
|
||||||
PFN_vkDestroyDescriptorPool glad_vkDestroyDescriptorPool = NULL;
|
|
||||||
PFN_vkDestroyDescriptorSetLayout glad_vkDestroyDescriptorSetLayout = NULL;
|
|
||||||
PFN_vkDestroyDescriptorUpdateTemplate glad_vkDestroyDescriptorUpdateTemplate = NULL;
|
|
||||||
PFN_vkDestroyDevice glad_vkDestroyDevice = NULL;
|
|
||||||
PFN_vkDestroyEvent glad_vkDestroyEvent = NULL;
|
|
||||||
PFN_vkDestroyFence glad_vkDestroyFence = NULL;
|
|
||||||
PFN_vkDestroyFramebuffer glad_vkDestroyFramebuffer = NULL;
|
|
||||||
PFN_vkDestroyImage glad_vkDestroyImage = NULL;
|
|
||||||
PFN_vkDestroyImageView glad_vkDestroyImageView = NULL;
|
|
||||||
PFN_vkDestroyInstance glad_vkDestroyInstance = NULL;
|
|
||||||
PFN_vkDestroyPipeline glad_vkDestroyPipeline = NULL;
|
|
||||||
PFN_vkDestroyPipelineCache glad_vkDestroyPipelineCache = NULL;
|
|
||||||
PFN_vkDestroyPipelineLayout glad_vkDestroyPipelineLayout = NULL;
|
|
||||||
PFN_vkDestroyQueryPool glad_vkDestroyQueryPool = NULL;
|
|
||||||
PFN_vkDestroyRenderPass glad_vkDestroyRenderPass = NULL;
|
|
||||||
PFN_vkDestroySampler glad_vkDestroySampler = NULL;
|
|
||||||
PFN_vkDestroySamplerYcbcrConversion glad_vkDestroySamplerYcbcrConversion = NULL;
|
|
||||||
PFN_vkDestroySemaphore glad_vkDestroySemaphore = NULL;
|
|
||||||
PFN_vkDestroyShaderModule glad_vkDestroyShaderModule = NULL;
|
|
||||||
PFN_vkDestroySurfaceKHR glad_vkDestroySurfaceKHR = NULL;
|
|
||||||
PFN_vkDestroySwapchainKHR glad_vkDestroySwapchainKHR = NULL;
|
|
||||||
PFN_vkDeviceWaitIdle glad_vkDeviceWaitIdle = NULL;
|
|
||||||
PFN_vkEndCommandBuffer glad_vkEndCommandBuffer = NULL;
|
|
||||||
PFN_vkEnumerateDeviceExtensionProperties glad_vkEnumerateDeviceExtensionProperties = NULL;
|
|
||||||
PFN_vkEnumerateDeviceLayerProperties glad_vkEnumerateDeviceLayerProperties = NULL;
|
|
||||||
PFN_vkEnumerateInstanceExtensionProperties glad_vkEnumerateInstanceExtensionProperties = NULL;
|
|
||||||
PFN_vkEnumerateInstanceLayerProperties glad_vkEnumerateInstanceLayerProperties = NULL;
|
|
||||||
PFN_vkEnumerateInstanceVersion glad_vkEnumerateInstanceVersion = NULL;
|
|
||||||
PFN_vkEnumeratePhysicalDeviceGroups glad_vkEnumeratePhysicalDeviceGroups = NULL;
|
|
||||||
PFN_vkEnumeratePhysicalDevices glad_vkEnumeratePhysicalDevices = NULL;
|
|
||||||
PFN_vkFlushMappedMemoryRanges glad_vkFlushMappedMemoryRanges = NULL;
|
|
||||||
PFN_vkFreeCommandBuffers glad_vkFreeCommandBuffers = NULL;
|
|
||||||
PFN_vkFreeDescriptorSets glad_vkFreeDescriptorSets = NULL;
|
|
||||||
PFN_vkFreeMemory glad_vkFreeMemory = NULL;
|
|
||||||
PFN_vkGetBufferMemoryRequirements glad_vkGetBufferMemoryRequirements = NULL;
|
|
||||||
PFN_vkGetBufferMemoryRequirements2 glad_vkGetBufferMemoryRequirements2 = NULL;
|
|
||||||
PFN_vkGetDescriptorSetLayoutSupport glad_vkGetDescriptorSetLayoutSupport = NULL;
|
|
||||||
PFN_vkGetDeviceGroupPeerMemoryFeatures glad_vkGetDeviceGroupPeerMemoryFeatures = NULL;
|
|
||||||
PFN_vkGetDeviceGroupPresentCapabilitiesKHR glad_vkGetDeviceGroupPresentCapabilitiesKHR = NULL;
|
|
||||||
PFN_vkGetDeviceGroupSurfacePresentModesKHR glad_vkGetDeviceGroupSurfacePresentModesKHR = NULL;
|
|
||||||
PFN_vkGetDeviceMemoryCommitment glad_vkGetDeviceMemoryCommitment = NULL;
|
|
||||||
PFN_vkGetDeviceProcAddr glad_vkGetDeviceProcAddr = NULL;
|
|
||||||
PFN_vkGetDeviceQueue glad_vkGetDeviceQueue = NULL;
|
|
||||||
PFN_vkGetDeviceQueue2 glad_vkGetDeviceQueue2 = NULL;
|
|
||||||
PFN_vkGetEventStatus glad_vkGetEventStatus = NULL;
|
|
||||||
PFN_vkGetFenceStatus glad_vkGetFenceStatus = NULL;
|
|
||||||
PFN_vkGetImageMemoryRequirements glad_vkGetImageMemoryRequirements = NULL;
|
|
||||||
PFN_vkGetImageMemoryRequirements2 glad_vkGetImageMemoryRequirements2 = NULL;
|
|
||||||
PFN_vkGetImageSparseMemoryRequirements glad_vkGetImageSparseMemoryRequirements = NULL;
|
|
||||||
PFN_vkGetImageSparseMemoryRequirements2 glad_vkGetImageSparseMemoryRequirements2 = NULL;
|
|
||||||
PFN_vkGetImageSubresourceLayout glad_vkGetImageSubresourceLayout = NULL;
|
|
||||||
PFN_vkGetInstanceProcAddr glad_vkGetInstanceProcAddr = NULL;
|
|
||||||
PFN_vkGetPhysicalDeviceExternalBufferProperties glad_vkGetPhysicalDeviceExternalBufferProperties = NULL;
|
|
||||||
PFN_vkGetPhysicalDeviceExternalFenceProperties glad_vkGetPhysicalDeviceExternalFenceProperties = NULL;
|
|
||||||
PFN_vkGetPhysicalDeviceExternalSemaphoreProperties glad_vkGetPhysicalDeviceExternalSemaphoreProperties = NULL;
|
|
||||||
PFN_vkGetPhysicalDeviceFeatures glad_vkGetPhysicalDeviceFeatures = NULL;
|
|
||||||
PFN_vkGetPhysicalDeviceFeatures2 glad_vkGetPhysicalDeviceFeatures2 = NULL;
|
|
||||||
PFN_vkGetPhysicalDeviceFormatProperties glad_vkGetPhysicalDeviceFormatProperties = NULL;
|
|
||||||
PFN_vkGetPhysicalDeviceFormatProperties2 glad_vkGetPhysicalDeviceFormatProperties2 = NULL;
|
|
||||||
PFN_vkGetPhysicalDeviceImageFormatProperties glad_vkGetPhysicalDeviceImageFormatProperties = NULL;
|
|
||||||
PFN_vkGetPhysicalDeviceImageFormatProperties2 glad_vkGetPhysicalDeviceImageFormatProperties2 = NULL;
|
|
||||||
PFN_vkGetPhysicalDeviceMemoryProperties glad_vkGetPhysicalDeviceMemoryProperties = NULL;
|
|
||||||
PFN_vkGetPhysicalDeviceMemoryProperties2 glad_vkGetPhysicalDeviceMemoryProperties2 = NULL;
|
|
||||||
PFN_vkGetPhysicalDevicePresentRectanglesKHR glad_vkGetPhysicalDevicePresentRectanglesKHR = NULL;
|
|
||||||
PFN_vkGetPhysicalDeviceProperties glad_vkGetPhysicalDeviceProperties = NULL;
|
|
||||||
PFN_vkGetPhysicalDeviceProperties2 glad_vkGetPhysicalDeviceProperties2 = NULL;
|
|
||||||
PFN_vkGetPhysicalDeviceQueueFamilyProperties glad_vkGetPhysicalDeviceQueueFamilyProperties = NULL;
|
|
||||||
PFN_vkGetPhysicalDeviceQueueFamilyProperties2 glad_vkGetPhysicalDeviceQueueFamilyProperties2 = NULL;
|
|
||||||
PFN_vkGetPhysicalDeviceSparseImageFormatProperties glad_vkGetPhysicalDeviceSparseImageFormatProperties = NULL;
|
|
||||||
PFN_vkGetPhysicalDeviceSparseImageFormatProperties2 glad_vkGetPhysicalDeviceSparseImageFormatProperties2 = NULL;
|
|
||||||
PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR glad_vkGetPhysicalDeviceSurfaceCapabilitiesKHR = NULL;
|
|
||||||
PFN_vkGetPhysicalDeviceSurfaceFormatsKHR glad_vkGetPhysicalDeviceSurfaceFormatsKHR = NULL;
|
|
||||||
PFN_vkGetPhysicalDeviceSurfacePresentModesKHR glad_vkGetPhysicalDeviceSurfacePresentModesKHR = NULL;
|
|
||||||
PFN_vkGetPhysicalDeviceSurfaceSupportKHR glad_vkGetPhysicalDeviceSurfaceSupportKHR = NULL;
|
|
||||||
PFN_vkGetPipelineCacheData glad_vkGetPipelineCacheData = NULL;
|
|
||||||
PFN_vkGetQueryPoolResults glad_vkGetQueryPoolResults = NULL;
|
|
||||||
PFN_vkGetRenderAreaGranularity glad_vkGetRenderAreaGranularity = NULL;
|
|
||||||
PFN_vkGetSwapchainImagesKHR glad_vkGetSwapchainImagesKHR = NULL;
|
|
||||||
PFN_vkInvalidateMappedMemoryRanges glad_vkInvalidateMappedMemoryRanges = NULL;
|
|
||||||
PFN_vkMapMemory glad_vkMapMemory = NULL;
|
|
||||||
PFN_vkMergePipelineCaches glad_vkMergePipelineCaches = NULL;
|
|
||||||
PFN_vkQueueBindSparse glad_vkQueueBindSparse = NULL;
|
|
||||||
PFN_vkQueuePresentKHR glad_vkQueuePresentKHR = NULL;
|
|
||||||
PFN_vkQueueSubmit glad_vkQueueSubmit = NULL;
|
|
||||||
PFN_vkQueueWaitIdle glad_vkQueueWaitIdle = NULL;
|
|
||||||
PFN_vkResetCommandBuffer glad_vkResetCommandBuffer = NULL;
|
|
||||||
PFN_vkResetCommandPool glad_vkResetCommandPool = NULL;
|
|
||||||
PFN_vkResetDescriptorPool glad_vkResetDescriptorPool = NULL;
|
|
||||||
PFN_vkResetEvent glad_vkResetEvent = NULL;
|
|
||||||
PFN_vkResetFences glad_vkResetFences = NULL;
|
|
||||||
PFN_vkSetEvent glad_vkSetEvent = NULL;
|
|
||||||
PFN_vkTrimCommandPool glad_vkTrimCommandPool = NULL;
|
|
||||||
PFN_vkUnmapMemory glad_vkUnmapMemory = NULL;
|
|
||||||
PFN_vkUpdateDescriptorSetWithTemplate glad_vkUpdateDescriptorSetWithTemplate = NULL;
|
|
||||||
PFN_vkUpdateDescriptorSets glad_vkUpdateDescriptorSets = NULL;
|
|
||||||
PFN_vkWaitForFences glad_vkWaitForFences = NULL;
|
|
||||||
|
|
||||||
|
|
||||||
static void glad_vk_load_VK_VERSION_1_0( GLADuserptrloadfunc load, void* userptr) {
|
|
||||||
if(!GLAD_VK_VERSION_1_0) return;
|
|
||||||
vkAllocateCommandBuffers = (PFN_vkAllocateCommandBuffers) load("vkAllocateCommandBuffers", userptr);
|
|
||||||
vkAllocateDescriptorSets = (PFN_vkAllocateDescriptorSets) load("vkAllocateDescriptorSets", userptr);
|
|
||||||
vkAllocateMemory = (PFN_vkAllocateMemory) load("vkAllocateMemory", userptr);
|
|
||||||
vkBeginCommandBuffer = (PFN_vkBeginCommandBuffer) load("vkBeginCommandBuffer", userptr);
|
|
||||||
vkBindBufferMemory = (PFN_vkBindBufferMemory) load("vkBindBufferMemory", userptr);
|
|
||||||
vkBindImageMemory = (PFN_vkBindImageMemory) load("vkBindImageMemory", userptr);
|
|
||||||
vkCmdBeginQuery = (PFN_vkCmdBeginQuery) load("vkCmdBeginQuery", userptr);
|
|
||||||
vkCmdBeginRenderPass = (PFN_vkCmdBeginRenderPass) load("vkCmdBeginRenderPass", userptr);
|
|
||||||
vkCmdBindDescriptorSets = (PFN_vkCmdBindDescriptorSets) load("vkCmdBindDescriptorSets", userptr);
|
|
||||||
vkCmdBindIndexBuffer = (PFN_vkCmdBindIndexBuffer) load("vkCmdBindIndexBuffer", userptr);
|
|
||||||
vkCmdBindPipeline = (PFN_vkCmdBindPipeline) load("vkCmdBindPipeline", userptr);
|
|
||||||
vkCmdBindVertexBuffers = (PFN_vkCmdBindVertexBuffers) load("vkCmdBindVertexBuffers", userptr);
|
|
||||||
vkCmdBlitImage = (PFN_vkCmdBlitImage) load("vkCmdBlitImage", userptr);
|
|
||||||
vkCmdClearAttachments = (PFN_vkCmdClearAttachments) load("vkCmdClearAttachments", userptr);
|
|
||||||
vkCmdClearColorImage = (PFN_vkCmdClearColorImage) load("vkCmdClearColorImage", userptr);
|
|
||||||
vkCmdClearDepthStencilImage = (PFN_vkCmdClearDepthStencilImage) load("vkCmdClearDepthStencilImage", userptr);
|
|
||||||
vkCmdCopyBuffer = (PFN_vkCmdCopyBuffer) load("vkCmdCopyBuffer", userptr);
|
|
||||||
vkCmdCopyBufferToImage = (PFN_vkCmdCopyBufferToImage) load("vkCmdCopyBufferToImage", userptr);
|
|
||||||
vkCmdCopyImage = (PFN_vkCmdCopyImage) load("vkCmdCopyImage", userptr);
|
|
||||||
vkCmdCopyImageToBuffer = (PFN_vkCmdCopyImageToBuffer) load("vkCmdCopyImageToBuffer", userptr);
|
|
||||||
vkCmdCopyQueryPoolResults = (PFN_vkCmdCopyQueryPoolResults) load("vkCmdCopyQueryPoolResults", userptr);
|
|
||||||
vkCmdDispatch = (PFN_vkCmdDispatch) load("vkCmdDispatch", userptr);
|
|
||||||
vkCmdDispatchIndirect = (PFN_vkCmdDispatchIndirect) load("vkCmdDispatchIndirect", userptr);
|
|
||||||
vkCmdDraw = (PFN_vkCmdDraw) load("vkCmdDraw", userptr);
|
|
||||||
vkCmdDrawIndexed = (PFN_vkCmdDrawIndexed) load("vkCmdDrawIndexed", userptr);
|
|
||||||
vkCmdDrawIndexedIndirect = (PFN_vkCmdDrawIndexedIndirect) load("vkCmdDrawIndexedIndirect", userptr);
|
|
||||||
vkCmdDrawIndirect = (PFN_vkCmdDrawIndirect) load("vkCmdDrawIndirect", userptr);
|
|
||||||
vkCmdEndQuery = (PFN_vkCmdEndQuery) load("vkCmdEndQuery", userptr);
|
|
||||||
vkCmdEndRenderPass = (PFN_vkCmdEndRenderPass) load("vkCmdEndRenderPass", userptr);
|
|
||||||
vkCmdExecuteCommands = (PFN_vkCmdExecuteCommands) load("vkCmdExecuteCommands", userptr);
|
|
||||||
vkCmdFillBuffer = (PFN_vkCmdFillBuffer) load("vkCmdFillBuffer", userptr);
|
|
||||||
vkCmdNextSubpass = (PFN_vkCmdNextSubpass) load("vkCmdNextSubpass", userptr);
|
|
||||||
vkCmdPipelineBarrier = (PFN_vkCmdPipelineBarrier) load("vkCmdPipelineBarrier", userptr);
|
|
||||||
vkCmdPushConstants = (PFN_vkCmdPushConstants) load("vkCmdPushConstants", userptr);
|
|
||||||
vkCmdResetEvent = (PFN_vkCmdResetEvent) load("vkCmdResetEvent", userptr);
|
|
||||||
vkCmdResetQueryPool = (PFN_vkCmdResetQueryPool) load("vkCmdResetQueryPool", userptr);
|
|
||||||
vkCmdResolveImage = (PFN_vkCmdResolveImage) load("vkCmdResolveImage", userptr);
|
|
||||||
vkCmdSetBlendConstants = (PFN_vkCmdSetBlendConstants) load("vkCmdSetBlendConstants", userptr);
|
|
||||||
vkCmdSetDepthBias = (PFN_vkCmdSetDepthBias) load("vkCmdSetDepthBias", userptr);
|
|
||||||
vkCmdSetDepthBounds = (PFN_vkCmdSetDepthBounds) load("vkCmdSetDepthBounds", userptr);
|
|
||||||
vkCmdSetEvent = (PFN_vkCmdSetEvent) load("vkCmdSetEvent", userptr);
|
|
||||||
vkCmdSetLineWidth = (PFN_vkCmdSetLineWidth) load("vkCmdSetLineWidth", userptr);
|
|
||||||
vkCmdSetScissor = (PFN_vkCmdSetScissor) load("vkCmdSetScissor", userptr);
|
|
||||||
vkCmdSetStencilCompareMask = (PFN_vkCmdSetStencilCompareMask) load("vkCmdSetStencilCompareMask", userptr);
|
|
||||||
vkCmdSetStencilReference = (PFN_vkCmdSetStencilReference) load("vkCmdSetStencilReference", userptr);
|
|
||||||
vkCmdSetStencilWriteMask = (PFN_vkCmdSetStencilWriteMask) load("vkCmdSetStencilWriteMask", userptr);
|
|
||||||
vkCmdSetViewport = (PFN_vkCmdSetViewport) load("vkCmdSetViewport", userptr);
|
|
||||||
vkCmdUpdateBuffer = (PFN_vkCmdUpdateBuffer) load("vkCmdUpdateBuffer", userptr);
|
|
||||||
vkCmdWaitEvents = (PFN_vkCmdWaitEvents) load("vkCmdWaitEvents", userptr);
|
|
||||||
vkCmdWriteTimestamp = (PFN_vkCmdWriteTimestamp) load("vkCmdWriteTimestamp", userptr);
|
|
||||||
vkCreateBuffer = (PFN_vkCreateBuffer) load("vkCreateBuffer", userptr);
|
|
||||||
vkCreateBufferView = (PFN_vkCreateBufferView) load("vkCreateBufferView", userptr);
|
|
||||||
vkCreateCommandPool = (PFN_vkCreateCommandPool) load("vkCreateCommandPool", userptr);
|
|
||||||
vkCreateComputePipelines = (PFN_vkCreateComputePipelines) load("vkCreateComputePipelines", userptr);
|
|
||||||
vkCreateDescriptorPool = (PFN_vkCreateDescriptorPool) load("vkCreateDescriptorPool", userptr);
|
|
||||||
vkCreateDescriptorSetLayout = (PFN_vkCreateDescriptorSetLayout) load("vkCreateDescriptorSetLayout", userptr);
|
|
||||||
vkCreateDevice = (PFN_vkCreateDevice) load("vkCreateDevice", userptr);
|
|
||||||
vkCreateEvent = (PFN_vkCreateEvent) load("vkCreateEvent", userptr);
|
|
||||||
vkCreateFence = (PFN_vkCreateFence) load("vkCreateFence", userptr);
|
|
||||||
vkCreateFramebuffer = (PFN_vkCreateFramebuffer) load("vkCreateFramebuffer", userptr);
|
|
||||||
vkCreateGraphicsPipelines = (PFN_vkCreateGraphicsPipelines) load("vkCreateGraphicsPipelines", userptr);
|
|
||||||
vkCreateImage = (PFN_vkCreateImage) load("vkCreateImage", userptr);
|
|
||||||
vkCreateImageView = (PFN_vkCreateImageView) load("vkCreateImageView", userptr);
|
|
||||||
vkCreateInstance = (PFN_vkCreateInstance) load("vkCreateInstance", userptr);
|
|
||||||
vkCreatePipelineCache = (PFN_vkCreatePipelineCache) load("vkCreatePipelineCache", userptr);
|
|
||||||
vkCreatePipelineLayout = (PFN_vkCreatePipelineLayout) load("vkCreatePipelineLayout", userptr);
|
|
||||||
vkCreateQueryPool = (PFN_vkCreateQueryPool) load("vkCreateQueryPool", userptr);
|
|
||||||
vkCreateRenderPass = (PFN_vkCreateRenderPass) load("vkCreateRenderPass", userptr);
|
|
||||||
vkCreateSampler = (PFN_vkCreateSampler) load("vkCreateSampler", userptr);
|
|
||||||
vkCreateSemaphore = (PFN_vkCreateSemaphore) load("vkCreateSemaphore", userptr);
|
|
||||||
vkCreateShaderModule = (PFN_vkCreateShaderModule) load("vkCreateShaderModule", userptr);
|
|
||||||
vkDestroyBuffer = (PFN_vkDestroyBuffer) load("vkDestroyBuffer", userptr);
|
|
||||||
vkDestroyBufferView = (PFN_vkDestroyBufferView) load("vkDestroyBufferView", userptr);
|
|
||||||
vkDestroyCommandPool = (PFN_vkDestroyCommandPool) load("vkDestroyCommandPool", userptr);
|
|
||||||
vkDestroyDescriptorPool = (PFN_vkDestroyDescriptorPool) load("vkDestroyDescriptorPool", userptr);
|
|
||||||
vkDestroyDescriptorSetLayout = (PFN_vkDestroyDescriptorSetLayout) load("vkDestroyDescriptorSetLayout", userptr);
|
|
||||||
vkDestroyDevice = (PFN_vkDestroyDevice) load("vkDestroyDevice", userptr);
|
|
||||||
vkDestroyEvent = (PFN_vkDestroyEvent) load("vkDestroyEvent", userptr);
|
|
||||||
vkDestroyFence = (PFN_vkDestroyFence) load("vkDestroyFence", userptr);
|
|
||||||
vkDestroyFramebuffer = (PFN_vkDestroyFramebuffer) load("vkDestroyFramebuffer", userptr);
|
|
||||||
vkDestroyImage = (PFN_vkDestroyImage) load("vkDestroyImage", userptr);
|
|
||||||
vkDestroyImageView = (PFN_vkDestroyImageView) load("vkDestroyImageView", userptr);
|
|
||||||
vkDestroyInstance = (PFN_vkDestroyInstance) load("vkDestroyInstance", userptr);
|
|
||||||
vkDestroyPipeline = (PFN_vkDestroyPipeline) load("vkDestroyPipeline", userptr);
|
|
||||||
vkDestroyPipelineCache = (PFN_vkDestroyPipelineCache) load("vkDestroyPipelineCache", userptr);
|
|
||||||
vkDestroyPipelineLayout = (PFN_vkDestroyPipelineLayout) load("vkDestroyPipelineLayout", userptr);
|
|
||||||
vkDestroyQueryPool = (PFN_vkDestroyQueryPool) load("vkDestroyQueryPool", userptr);
|
|
||||||
vkDestroyRenderPass = (PFN_vkDestroyRenderPass) load("vkDestroyRenderPass", userptr);
|
|
||||||
vkDestroySampler = (PFN_vkDestroySampler) load("vkDestroySampler", userptr);
|
|
||||||
vkDestroySemaphore = (PFN_vkDestroySemaphore) load("vkDestroySemaphore", userptr);
|
|
||||||
vkDestroyShaderModule = (PFN_vkDestroyShaderModule) load("vkDestroyShaderModule", userptr);
|
|
||||||
vkDeviceWaitIdle = (PFN_vkDeviceWaitIdle) load("vkDeviceWaitIdle", userptr);
|
|
||||||
vkEndCommandBuffer = (PFN_vkEndCommandBuffer) load("vkEndCommandBuffer", userptr);
|
|
||||||
vkEnumerateDeviceExtensionProperties = (PFN_vkEnumerateDeviceExtensionProperties) load("vkEnumerateDeviceExtensionProperties", userptr);
|
|
||||||
vkEnumerateDeviceLayerProperties = (PFN_vkEnumerateDeviceLayerProperties) load("vkEnumerateDeviceLayerProperties", userptr);
|
|
||||||
vkEnumerateInstanceExtensionProperties = (PFN_vkEnumerateInstanceExtensionProperties) load("vkEnumerateInstanceExtensionProperties", userptr);
|
|
||||||
vkEnumerateInstanceLayerProperties = (PFN_vkEnumerateInstanceLayerProperties) load("vkEnumerateInstanceLayerProperties", userptr);
|
|
||||||
vkEnumeratePhysicalDevices = (PFN_vkEnumeratePhysicalDevices) load("vkEnumeratePhysicalDevices", userptr);
|
|
||||||
vkFlushMappedMemoryRanges = (PFN_vkFlushMappedMemoryRanges) load("vkFlushMappedMemoryRanges", userptr);
|
|
||||||
vkFreeCommandBuffers = (PFN_vkFreeCommandBuffers) load("vkFreeCommandBuffers", userptr);
|
|
||||||
vkFreeDescriptorSets = (PFN_vkFreeDescriptorSets) load("vkFreeDescriptorSets", userptr);
|
|
||||||
vkFreeMemory = (PFN_vkFreeMemory) load("vkFreeMemory", userptr);
|
|
||||||
vkGetBufferMemoryRequirements = (PFN_vkGetBufferMemoryRequirements) load("vkGetBufferMemoryRequirements", userptr);
|
|
||||||
vkGetDeviceMemoryCommitment = (PFN_vkGetDeviceMemoryCommitment) load("vkGetDeviceMemoryCommitment", userptr);
|
|
||||||
vkGetDeviceProcAddr = (PFN_vkGetDeviceProcAddr) load("vkGetDeviceProcAddr", userptr);
|
|
||||||
vkGetDeviceQueue = (PFN_vkGetDeviceQueue) load("vkGetDeviceQueue", userptr);
|
|
||||||
vkGetEventStatus = (PFN_vkGetEventStatus) load("vkGetEventStatus", userptr);
|
|
||||||
vkGetFenceStatus = (PFN_vkGetFenceStatus) load("vkGetFenceStatus", userptr);
|
|
||||||
vkGetImageMemoryRequirements = (PFN_vkGetImageMemoryRequirements) load("vkGetImageMemoryRequirements", userptr);
|
|
||||||
vkGetImageSparseMemoryRequirements = (PFN_vkGetImageSparseMemoryRequirements) load("vkGetImageSparseMemoryRequirements", userptr);
|
|
||||||
vkGetImageSubresourceLayout = (PFN_vkGetImageSubresourceLayout) load("vkGetImageSubresourceLayout", userptr);
|
|
||||||
vkGetInstanceProcAddr = (PFN_vkGetInstanceProcAddr) load("vkGetInstanceProcAddr", userptr);
|
|
||||||
vkGetPhysicalDeviceFeatures = (PFN_vkGetPhysicalDeviceFeatures) load("vkGetPhysicalDeviceFeatures", userptr);
|
|
||||||
vkGetPhysicalDeviceFormatProperties = (PFN_vkGetPhysicalDeviceFormatProperties) load("vkGetPhysicalDeviceFormatProperties", userptr);
|
|
||||||
vkGetPhysicalDeviceImageFormatProperties = (PFN_vkGetPhysicalDeviceImageFormatProperties) load("vkGetPhysicalDeviceImageFormatProperties", userptr);
|
|
||||||
vkGetPhysicalDeviceMemoryProperties = (PFN_vkGetPhysicalDeviceMemoryProperties) load("vkGetPhysicalDeviceMemoryProperties", userptr);
|
|
||||||
vkGetPhysicalDeviceProperties = (PFN_vkGetPhysicalDeviceProperties) load("vkGetPhysicalDeviceProperties", userptr);
|
|
||||||
vkGetPhysicalDeviceQueueFamilyProperties = (PFN_vkGetPhysicalDeviceQueueFamilyProperties) load("vkGetPhysicalDeviceQueueFamilyProperties", userptr);
|
|
||||||
vkGetPhysicalDeviceSparseImageFormatProperties = (PFN_vkGetPhysicalDeviceSparseImageFormatProperties) load("vkGetPhysicalDeviceSparseImageFormatProperties", userptr);
|
|
||||||
vkGetPipelineCacheData = (PFN_vkGetPipelineCacheData) load("vkGetPipelineCacheData", userptr);
|
|
||||||
vkGetQueryPoolResults = (PFN_vkGetQueryPoolResults) load("vkGetQueryPoolResults", userptr);
|
|
||||||
vkGetRenderAreaGranularity = (PFN_vkGetRenderAreaGranularity) load("vkGetRenderAreaGranularity", userptr);
|
|
||||||
vkInvalidateMappedMemoryRanges = (PFN_vkInvalidateMappedMemoryRanges) load("vkInvalidateMappedMemoryRanges", userptr);
|
|
||||||
vkMapMemory = (PFN_vkMapMemory) load("vkMapMemory", userptr);
|
|
||||||
vkMergePipelineCaches = (PFN_vkMergePipelineCaches) load("vkMergePipelineCaches", userptr);
|
|
||||||
vkQueueBindSparse = (PFN_vkQueueBindSparse) load("vkQueueBindSparse", userptr);
|
|
||||||
vkQueueSubmit = (PFN_vkQueueSubmit) load("vkQueueSubmit", userptr);
|
|
||||||
vkQueueWaitIdle = (PFN_vkQueueWaitIdle) load("vkQueueWaitIdle", userptr);
|
|
||||||
vkResetCommandBuffer = (PFN_vkResetCommandBuffer) load("vkResetCommandBuffer", userptr);
|
|
||||||
vkResetCommandPool = (PFN_vkResetCommandPool) load("vkResetCommandPool", userptr);
|
|
||||||
vkResetDescriptorPool = (PFN_vkResetDescriptorPool) load("vkResetDescriptorPool", userptr);
|
|
||||||
vkResetEvent = (PFN_vkResetEvent) load("vkResetEvent", userptr);
|
|
||||||
vkResetFences = (PFN_vkResetFences) load("vkResetFences", userptr);
|
|
||||||
vkSetEvent = (PFN_vkSetEvent) load("vkSetEvent", userptr);
|
|
||||||
vkUnmapMemory = (PFN_vkUnmapMemory) load("vkUnmapMemory", userptr);
|
|
||||||
vkUpdateDescriptorSets = (PFN_vkUpdateDescriptorSets) load("vkUpdateDescriptorSets", userptr);
|
|
||||||
vkWaitForFences = (PFN_vkWaitForFences) load("vkWaitForFences", userptr);
|
|
||||||
}
|
|
||||||
static void glad_vk_load_VK_VERSION_1_1( GLADuserptrloadfunc load, void* userptr) {
|
|
||||||
if(!GLAD_VK_VERSION_1_1) return;
|
|
||||||
vkBindBufferMemory2 = (PFN_vkBindBufferMemory2) load("vkBindBufferMemory2", userptr);
|
|
||||||
vkBindImageMemory2 = (PFN_vkBindImageMemory2) load("vkBindImageMemory2", userptr);
|
|
||||||
vkCmdDispatchBase = (PFN_vkCmdDispatchBase) load("vkCmdDispatchBase", userptr);
|
|
||||||
vkCmdSetDeviceMask = (PFN_vkCmdSetDeviceMask) load("vkCmdSetDeviceMask", userptr);
|
|
||||||
vkCreateDescriptorUpdateTemplate = (PFN_vkCreateDescriptorUpdateTemplate) load("vkCreateDescriptorUpdateTemplate", userptr);
|
|
||||||
vkCreateSamplerYcbcrConversion = (PFN_vkCreateSamplerYcbcrConversion) load("vkCreateSamplerYcbcrConversion", userptr);
|
|
||||||
vkDestroyDescriptorUpdateTemplate = (PFN_vkDestroyDescriptorUpdateTemplate) load("vkDestroyDescriptorUpdateTemplate", userptr);
|
|
||||||
vkDestroySamplerYcbcrConversion = (PFN_vkDestroySamplerYcbcrConversion) load("vkDestroySamplerYcbcrConversion", userptr);
|
|
||||||
vkEnumerateInstanceVersion = (PFN_vkEnumerateInstanceVersion) load("vkEnumerateInstanceVersion", userptr);
|
|
||||||
vkEnumeratePhysicalDeviceGroups = (PFN_vkEnumeratePhysicalDeviceGroups) load("vkEnumeratePhysicalDeviceGroups", userptr);
|
|
||||||
vkGetBufferMemoryRequirements2 = (PFN_vkGetBufferMemoryRequirements2) load("vkGetBufferMemoryRequirements2", userptr);
|
|
||||||
vkGetDescriptorSetLayoutSupport = (PFN_vkGetDescriptorSetLayoutSupport) load("vkGetDescriptorSetLayoutSupport", userptr);
|
|
||||||
vkGetDeviceGroupPeerMemoryFeatures = (PFN_vkGetDeviceGroupPeerMemoryFeatures) load("vkGetDeviceGroupPeerMemoryFeatures", userptr);
|
|
||||||
vkGetDeviceQueue2 = (PFN_vkGetDeviceQueue2) load("vkGetDeviceQueue2", userptr);
|
|
||||||
vkGetImageMemoryRequirements2 = (PFN_vkGetImageMemoryRequirements2) load("vkGetImageMemoryRequirements2", userptr);
|
|
||||||
vkGetImageSparseMemoryRequirements2 = (PFN_vkGetImageSparseMemoryRequirements2) load("vkGetImageSparseMemoryRequirements2", userptr);
|
|
||||||
vkGetPhysicalDeviceExternalBufferProperties = (PFN_vkGetPhysicalDeviceExternalBufferProperties) load("vkGetPhysicalDeviceExternalBufferProperties", userptr);
|
|
||||||
vkGetPhysicalDeviceExternalFenceProperties = (PFN_vkGetPhysicalDeviceExternalFenceProperties) load("vkGetPhysicalDeviceExternalFenceProperties", userptr);
|
|
||||||
vkGetPhysicalDeviceExternalSemaphoreProperties = (PFN_vkGetPhysicalDeviceExternalSemaphoreProperties) load("vkGetPhysicalDeviceExternalSemaphoreProperties", userptr);
|
|
||||||
vkGetPhysicalDeviceFeatures2 = (PFN_vkGetPhysicalDeviceFeatures2) load("vkGetPhysicalDeviceFeatures2", userptr);
|
|
||||||
vkGetPhysicalDeviceFormatProperties2 = (PFN_vkGetPhysicalDeviceFormatProperties2) load("vkGetPhysicalDeviceFormatProperties2", userptr);
|
|
||||||
vkGetPhysicalDeviceImageFormatProperties2 = (PFN_vkGetPhysicalDeviceImageFormatProperties2) load("vkGetPhysicalDeviceImageFormatProperties2", userptr);
|
|
||||||
vkGetPhysicalDeviceMemoryProperties2 = (PFN_vkGetPhysicalDeviceMemoryProperties2) load("vkGetPhysicalDeviceMemoryProperties2", userptr);
|
|
||||||
vkGetPhysicalDeviceProperties2 = (PFN_vkGetPhysicalDeviceProperties2) load("vkGetPhysicalDeviceProperties2", userptr);
|
|
||||||
vkGetPhysicalDeviceQueueFamilyProperties2 = (PFN_vkGetPhysicalDeviceQueueFamilyProperties2) load("vkGetPhysicalDeviceQueueFamilyProperties2", userptr);
|
|
||||||
vkGetPhysicalDeviceSparseImageFormatProperties2 = (PFN_vkGetPhysicalDeviceSparseImageFormatProperties2) load("vkGetPhysicalDeviceSparseImageFormatProperties2", userptr);
|
|
||||||
vkTrimCommandPool = (PFN_vkTrimCommandPool) load("vkTrimCommandPool", userptr);
|
|
||||||
vkUpdateDescriptorSetWithTemplate = (PFN_vkUpdateDescriptorSetWithTemplate) load("vkUpdateDescriptorSetWithTemplate", userptr);
|
|
||||||
}
|
|
||||||
static void glad_vk_load_VK_EXT_debug_report( GLADuserptrloadfunc load, void* userptr) {
|
|
||||||
if(!GLAD_VK_EXT_debug_report) return;
|
|
||||||
vkCreateDebugReportCallbackEXT = (PFN_vkCreateDebugReportCallbackEXT) load("vkCreateDebugReportCallbackEXT", userptr);
|
|
||||||
vkDebugReportMessageEXT = (PFN_vkDebugReportMessageEXT) load("vkDebugReportMessageEXT", userptr);
|
|
||||||
vkDestroyDebugReportCallbackEXT = (PFN_vkDestroyDebugReportCallbackEXT) load("vkDestroyDebugReportCallbackEXT", userptr);
|
|
||||||
}
|
|
||||||
static void glad_vk_load_VK_KHR_surface( GLADuserptrloadfunc load, void* userptr) {
|
|
||||||
if(!GLAD_VK_KHR_surface) return;
|
|
||||||
vkDestroySurfaceKHR = (PFN_vkDestroySurfaceKHR) load("vkDestroySurfaceKHR", userptr);
|
|
||||||
vkGetPhysicalDeviceSurfaceCapabilitiesKHR = (PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR) load("vkGetPhysicalDeviceSurfaceCapabilitiesKHR", userptr);
|
|
||||||
vkGetPhysicalDeviceSurfaceFormatsKHR = (PFN_vkGetPhysicalDeviceSurfaceFormatsKHR) load("vkGetPhysicalDeviceSurfaceFormatsKHR", userptr);
|
|
||||||
vkGetPhysicalDeviceSurfacePresentModesKHR = (PFN_vkGetPhysicalDeviceSurfacePresentModesKHR) load("vkGetPhysicalDeviceSurfacePresentModesKHR", userptr);
|
|
||||||
vkGetPhysicalDeviceSurfaceSupportKHR = (PFN_vkGetPhysicalDeviceSurfaceSupportKHR) load("vkGetPhysicalDeviceSurfaceSupportKHR", userptr);
|
|
||||||
}
|
|
||||||
static void glad_vk_load_VK_KHR_swapchain( GLADuserptrloadfunc load, void* userptr) {
|
|
||||||
if(!GLAD_VK_KHR_swapchain) return;
|
|
||||||
vkAcquireNextImage2KHR = (PFN_vkAcquireNextImage2KHR) load("vkAcquireNextImage2KHR", userptr);
|
|
||||||
vkAcquireNextImageKHR = (PFN_vkAcquireNextImageKHR) load("vkAcquireNextImageKHR", userptr);
|
|
||||||
vkCreateSwapchainKHR = (PFN_vkCreateSwapchainKHR) load("vkCreateSwapchainKHR", userptr);
|
|
||||||
vkDestroySwapchainKHR = (PFN_vkDestroySwapchainKHR) load("vkDestroySwapchainKHR", userptr);
|
|
||||||
vkGetDeviceGroupPresentCapabilitiesKHR = (PFN_vkGetDeviceGroupPresentCapabilitiesKHR) load("vkGetDeviceGroupPresentCapabilitiesKHR", userptr);
|
|
||||||
vkGetDeviceGroupSurfacePresentModesKHR = (PFN_vkGetDeviceGroupSurfacePresentModesKHR) load("vkGetDeviceGroupSurfacePresentModesKHR", userptr);
|
|
||||||
vkGetPhysicalDevicePresentRectanglesKHR = (PFN_vkGetPhysicalDevicePresentRectanglesKHR) load("vkGetPhysicalDevicePresentRectanglesKHR", userptr);
|
|
||||||
vkGetSwapchainImagesKHR = (PFN_vkGetSwapchainImagesKHR) load("vkGetSwapchainImagesKHR", userptr);
|
|
||||||
vkQueuePresentKHR = (PFN_vkQueuePresentKHR) load("vkQueuePresentKHR", userptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static int glad_vk_get_extensions( VkPhysicalDevice physical_device, uint32_t *out_extension_count, char ***out_extensions) {
|
|
||||||
uint32_t i;
|
|
||||||
uint32_t instance_extension_count = 0;
|
|
||||||
uint32_t device_extension_count = 0;
|
|
||||||
uint32_t max_extension_count;
|
|
||||||
uint32_t total_extension_count;
|
|
||||||
char **extensions;
|
|
||||||
VkExtensionProperties *ext_properties;
|
|
||||||
VkResult result;
|
|
||||||
|
|
||||||
if (vkEnumerateInstanceExtensionProperties == NULL || (physical_device != NULL && vkEnumerateDeviceExtensionProperties == NULL)) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
result = vkEnumerateInstanceExtensionProperties(NULL, &instance_extension_count, NULL);
|
|
||||||
if (result != VK_SUCCESS) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (physical_device != NULL) {
|
|
||||||
result = vkEnumerateDeviceExtensionProperties(physical_device, NULL, &device_extension_count, NULL);
|
|
||||||
if (result != VK_SUCCESS) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
total_extension_count = instance_extension_count + device_extension_count;
|
|
||||||
max_extension_count = instance_extension_count > device_extension_count
|
|
||||||
? instance_extension_count : device_extension_count;
|
|
||||||
|
|
||||||
ext_properties = (VkExtensionProperties*) malloc(max_extension_count * sizeof(VkExtensionProperties));
|
|
||||||
if (ext_properties == NULL) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
result = vkEnumerateInstanceExtensionProperties(NULL, &instance_extension_count, ext_properties);
|
|
||||||
if (result != VK_SUCCESS) {
|
|
||||||
free((void*) ext_properties);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
extensions = (char**) calloc(total_extension_count, sizeof(char*));
|
|
||||||
if (extensions == NULL) {
|
|
||||||
free((void*) ext_properties);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < instance_extension_count; ++i) {
|
|
||||||
VkExtensionProperties ext = ext_properties[i];
|
|
||||||
|
|
||||||
size_t extension_name_length = strlen(ext.extensionName) + 1;
|
|
||||||
extensions[i] = (char*) malloc(extension_name_length * sizeof(char));
|
|
||||||
memcpy(extensions[i], ext.extensionName, extension_name_length * sizeof(char));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (physical_device != NULL) {
|
|
||||||
result = vkEnumerateDeviceExtensionProperties(physical_device, NULL, &device_extension_count, ext_properties);
|
|
||||||
if (result != VK_SUCCESS) {
|
|
||||||
for (i = 0; i < instance_extension_count; ++i) {
|
|
||||||
free((void*) extensions[i]);
|
|
||||||
}
|
|
||||||
free(extensions);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < device_extension_count; ++i) {
|
|
||||||
VkExtensionProperties ext = ext_properties[i];
|
|
||||||
|
|
||||||
size_t extension_name_length = strlen(ext.extensionName) + 1;
|
|
||||||
extensions[instance_extension_count + i] = (char*) malloc(extension_name_length * sizeof(char));
|
|
||||||
memcpy(extensions[instance_extension_count + i], ext.extensionName, extension_name_length * sizeof(char));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
free((void*) ext_properties);
|
|
||||||
|
|
||||||
*out_extension_count = total_extension_count;
|
|
||||||
*out_extensions = extensions;
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void glad_vk_free_extensions(uint32_t extension_count, char **extensions) {
|
|
||||||
uint32_t i;
|
|
||||||
|
|
||||||
for(i = 0; i < extension_count ; ++i) {
|
|
||||||
free((void*) (extensions[i]));
|
|
||||||
}
|
|
||||||
|
|
||||||
free((void*) extensions);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int glad_vk_has_extension(const char *name, uint32_t extension_count, char **extensions) {
|
|
||||||
uint32_t i;
|
|
||||||
|
|
||||||
for (i = 0; i < extension_count; ++i) {
|
|
||||||
if(strcmp(name, extensions[i]) == 0) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static GLADapiproc glad_vk_get_proc_from_userptr(const char* name, void *userptr) {
|
|
||||||
return (GLAD_GNUC_EXTENSION (GLADapiproc (*)(const char *name)) userptr)(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int glad_vk_find_extensions_vulkan( VkPhysicalDevice physical_device) {
|
|
||||||
uint32_t extension_count = 0;
|
|
||||||
char **extensions = NULL;
|
|
||||||
if (!glad_vk_get_extensions(physical_device, &extension_count, &extensions)) return 0;
|
|
||||||
|
|
||||||
GLAD_VK_EXT_debug_report = glad_vk_has_extension("VK_EXT_debug_report", extension_count, extensions);
|
|
||||||
GLAD_VK_KHR_surface = glad_vk_has_extension("VK_KHR_surface", extension_count, extensions);
|
|
||||||
GLAD_VK_KHR_swapchain = glad_vk_has_extension("VK_KHR_swapchain", extension_count, extensions);
|
|
||||||
|
|
||||||
glad_vk_free_extensions(extension_count, extensions);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int glad_vk_find_core_vulkan( VkPhysicalDevice physical_device) {
|
|
||||||
int major = 1;
|
|
||||||
int minor = 0;
|
|
||||||
|
|
||||||
#ifdef VK_VERSION_1_1
|
|
||||||
if (vkEnumerateInstanceVersion != NULL) {
|
|
||||||
uint32_t version;
|
|
||||||
VkResult result;
|
|
||||||
|
|
||||||
result = vkEnumerateInstanceVersion(&version);
|
|
||||||
if (result == VK_SUCCESS) {
|
|
||||||
major = (int) VK_VERSION_MAJOR(version);
|
|
||||||
minor = (int) VK_VERSION_MINOR(version);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (physical_device != NULL && vkGetPhysicalDeviceProperties != NULL) {
|
|
||||||
VkPhysicalDeviceProperties properties;
|
|
||||||
vkGetPhysicalDeviceProperties(physical_device, &properties);
|
|
||||||
|
|
||||||
major = (int) VK_VERSION_MAJOR(properties.apiVersion);
|
|
||||||
minor = (int) VK_VERSION_MINOR(properties.apiVersion);
|
|
||||||
}
|
|
||||||
|
|
||||||
GLAD_VK_VERSION_1_0 = (major == 1 && minor >= 0) || major > 1;
|
|
||||||
GLAD_VK_VERSION_1_1 = (major == 1 && minor >= 1) || major > 1;
|
|
||||||
|
|
||||||
return GLAD_MAKE_VERSION(major, minor);
|
|
||||||
}
|
|
||||||
|
|
||||||
int gladLoadVulkanUserPtr( VkPhysicalDevice physical_device, GLADuserptrloadfunc load, void *userptr) {
|
|
||||||
int version;
|
|
||||||
|
|
||||||
#ifdef VK_VERSION_1_1
|
|
||||||
vkEnumerateInstanceVersion = (PFN_vkEnumerateInstanceVersion) load("vkEnumerateInstanceVersion", userptr);
|
|
||||||
#endif
|
|
||||||
version = glad_vk_find_core_vulkan( physical_device);
|
|
||||||
if (!version) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
glad_vk_load_VK_VERSION_1_0(load, userptr);
|
|
||||||
glad_vk_load_VK_VERSION_1_1(load, userptr);
|
|
||||||
|
|
||||||
if (!glad_vk_find_extensions_vulkan( physical_device)) return 0;
|
|
||||||
glad_vk_load_VK_EXT_debug_report(load, userptr);
|
|
||||||
glad_vk_load_VK_KHR_surface(load, userptr);
|
|
||||||
glad_vk_load_VK_KHR_swapchain(load, userptr);
|
|
||||||
|
|
||||||
|
|
||||||
return version;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int gladLoadVulkan( VkPhysicalDevice physical_device, GLADloadfunc load) {
|
|
||||||
return gladLoadVulkanUserPtr( physical_device, glad_vk_get_proc_from_userptr, GLAD_GNUC_EXTENSION (void*) load);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
149
deps/linmath.h
vendored
149
deps/linmath.h
vendored
@ -1,14 +1,13 @@
|
|||||||
#ifndef LINMATH_H
|
#ifndef LINMATH_H
|
||||||
#define LINMATH_H
|
#define LINMATH_H
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
/* 2020-03-02 Camilla Löwy <elmindreda@elmindreda.org>
|
/* 2021-03-21 Camilla Löwy <elmindreda@elmindreda.org>
|
||||||
* - Added inclusion of string.h for memcpy
|
|
||||||
* - Replaced tan and acos with tanf and acosf
|
|
||||||
* - Replaced double constants with float equivalents
|
* - Replaced double constants with float equivalents
|
||||||
*/
|
*/
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#ifdef LINMATH_NO_INLINE
|
#ifdef LINMATH_NO_INLINE
|
||||||
#define LINMATH_H_FUNC static
|
#define LINMATH_H_FUNC static
|
||||||
@ -38,7 +37,7 @@ LINMATH_H_FUNC void vec##n##_scale(vec##n r, vec##n const v, float const s) \
|
|||||||
} \
|
} \
|
||||||
LINMATH_H_FUNC float vec##n##_mul_inner(vec##n const a, vec##n const b) \
|
LINMATH_H_FUNC float vec##n##_mul_inner(vec##n const a, vec##n const b) \
|
||||||
{ \
|
{ \
|
||||||
float p = 0.; \
|
float p = 0.f; \
|
||||||
int i; \
|
int i; \
|
||||||
for(i=0; i<n; ++i) \
|
for(i=0; i<n; ++i) \
|
||||||
p += b[i]*a[i]; \
|
p += b[i]*a[i]; \
|
||||||
@ -64,6 +63,12 @@ LINMATH_H_FUNC void vec##n##_max(vec##n r, vec##n const a, vec##n const b) \
|
|||||||
int i; \
|
int i; \
|
||||||
for(i=0; i<n; ++i) \
|
for(i=0; i<n; ++i) \
|
||||||
r[i] = a[i]>b[i] ? a[i] : b[i]; \
|
r[i] = a[i]>b[i] ? a[i] : b[i]; \
|
||||||
|
} \
|
||||||
|
LINMATH_H_FUNC void vec##n##_dup(vec##n r, vec##n const src) \
|
||||||
|
{ \
|
||||||
|
int i; \
|
||||||
|
for(i=0; i<n; ++i) \
|
||||||
|
r[i] = src[i]; \
|
||||||
}
|
}
|
||||||
|
|
||||||
LINMATH_H_DEFINE_VEC(2)
|
LINMATH_H_DEFINE_VEC(2)
|
||||||
@ -85,7 +90,7 @@ LINMATH_H_FUNC void vec3_reflect(vec3 r, vec3 const v, vec3 const n)
|
|||||||
r[i] = v[i] - p*n[i];
|
r[i] = v[i] - p*n[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
LINMATH_H_FUNC void vec4_mul_cross(vec4 r, vec4 a, vec4 b)
|
LINMATH_H_FUNC void vec4_mul_cross(vec4 r, vec4 const a, vec4 const b)
|
||||||
{
|
{
|
||||||
r[0] = a[1]*b[2] - a[2]*b[1];
|
r[0] = a[1]*b[2] - a[2]*b[1];
|
||||||
r[1] = a[2]*b[0] - a[0]*b[2];
|
r[1] = a[2]*b[0] - a[0]*b[2];
|
||||||
@ -93,7 +98,7 @@ LINMATH_H_FUNC void vec4_mul_cross(vec4 r, vec4 a, vec4 b)
|
|||||||
r[3] = 1.f;
|
r[3] = 1.f;
|
||||||
}
|
}
|
||||||
|
|
||||||
LINMATH_H_FUNC void vec4_reflect(vec4 r, vec4 v, vec4 n)
|
LINMATH_H_FUNC void vec4_reflect(vec4 r, vec4 const v, vec4 const n)
|
||||||
{
|
{
|
||||||
float p = 2.f*vec4_mul_inner(v, n);
|
float p = 2.f*vec4_mul_inner(v, n);
|
||||||
int i;
|
int i;
|
||||||
@ -109,61 +114,59 @@ LINMATH_H_FUNC void mat4x4_identity(mat4x4 M)
|
|||||||
for(j=0; j<4; ++j)
|
for(j=0; j<4; ++j)
|
||||||
M[i][j] = i==j ? 1.f : 0.f;
|
M[i][j] = i==j ? 1.f : 0.f;
|
||||||
}
|
}
|
||||||
LINMATH_H_FUNC void mat4x4_dup(mat4x4 M, mat4x4 N)
|
LINMATH_H_FUNC void mat4x4_dup(mat4x4 M, mat4x4 const N)
|
||||||
{
|
{
|
||||||
int i, j;
|
int i;
|
||||||
for(i=0; i<4; ++i)
|
for(i=0; i<4; ++i)
|
||||||
for(j=0; j<4; ++j)
|
vec4_dup(M[i], N[i]);
|
||||||
M[i][j] = N[i][j];
|
|
||||||
}
|
}
|
||||||
LINMATH_H_FUNC void mat4x4_row(vec4 r, mat4x4 M, int i)
|
LINMATH_H_FUNC void mat4x4_row(vec4 r, mat4x4 const M, int i)
|
||||||
{
|
{
|
||||||
int k;
|
int k;
|
||||||
for(k=0; k<4; ++k)
|
for(k=0; k<4; ++k)
|
||||||
r[k] = M[k][i];
|
r[k] = M[k][i];
|
||||||
}
|
}
|
||||||
LINMATH_H_FUNC void mat4x4_col(vec4 r, mat4x4 M, int i)
|
LINMATH_H_FUNC void mat4x4_col(vec4 r, mat4x4 const M, int i)
|
||||||
{
|
{
|
||||||
int k;
|
int k;
|
||||||
for(k=0; k<4; ++k)
|
for(k=0; k<4; ++k)
|
||||||
r[k] = M[i][k];
|
r[k] = M[i][k];
|
||||||
}
|
}
|
||||||
LINMATH_H_FUNC void mat4x4_transpose(mat4x4 M, mat4x4 N)
|
LINMATH_H_FUNC void mat4x4_transpose(mat4x4 M, mat4x4 const N)
|
||||||
{
|
{
|
||||||
|
// Note: if M and N are the same, the user has to
|
||||||
|
// explicitly make a copy of M and set it to N.
|
||||||
int i, j;
|
int i, j;
|
||||||
for(j=0; j<4; ++j)
|
for(j=0; j<4; ++j)
|
||||||
for(i=0; i<4; ++i)
|
for(i=0; i<4; ++i)
|
||||||
M[i][j] = N[j][i];
|
M[i][j] = N[j][i];
|
||||||
}
|
}
|
||||||
LINMATH_H_FUNC void mat4x4_add(mat4x4 M, mat4x4 a, mat4x4 b)
|
LINMATH_H_FUNC void mat4x4_add(mat4x4 M, mat4x4 const a, mat4x4 const b)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for(i=0; i<4; ++i)
|
for(i=0; i<4; ++i)
|
||||||
vec4_add(M[i], a[i], b[i]);
|
vec4_add(M[i], a[i], b[i]);
|
||||||
}
|
}
|
||||||
LINMATH_H_FUNC void mat4x4_sub(mat4x4 M, mat4x4 a, mat4x4 b)
|
LINMATH_H_FUNC void mat4x4_sub(mat4x4 M, mat4x4 const a, mat4x4 const b)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for(i=0; i<4; ++i)
|
for(i=0; i<4; ++i)
|
||||||
vec4_sub(M[i], a[i], b[i]);
|
vec4_sub(M[i], a[i], b[i]);
|
||||||
}
|
}
|
||||||
LINMATH_H_FUNC void mat4x4_scale(mat4x4 M, mat4x4 a, float k)
|
LINMATH_H_FUNC void mat4x4_scale(mat4x4 M, mat4x4 const a, float k)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for(i=0; i<4; ++i)
|
for(i=0; i<4; ++i)
|
||||||
vec4_scale(M[i], a[i], k);
|
vec4_scale(M[i], a[i], k);
|
||||||
}
|
}
|
||||||
LINMATH_H_FUNC void mat4x4_scale_aniso(mat4x4 M, mat4x4 a, float x, float y, float z)
|
LINMATH_H_FUNC void mat4x4_scale_aniso(mat4x4 M, mat4x4 const a, float x, float y, float z)
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
vec4_scale(M[0], a[0], x);
|
vec4_scale(M[0], a[0], x);
|
||||||
vec4_scale(M[1], a[1], y);
|
vec4_scale(M[1], a[1], y);
|
||||||
vec4_scale(M[2], a[2], z);
|
vec4_scale(M[2], a[2], z);
|
||||||
for(i = 0; i < 4; ++i) {
|
vec4_dup(M[3], a[3]);
|
||||||
M[3][i] = a[3][i];
|
|
||||||
}
|
}
|
||||||
}
|
LINMATH_H_FUNC void mat4x4_mul(mat4x4 M, mat4x4 const a, mat4x4 const b)
|
||||||
LINMATH_H_FUNC void mat4x4_mul(mat4x4 M, mat4x4 a, mat4x4 b)
|
|
||||||
{
|
{
|
||||||
mat4x4 temp;
|
mat4x4 temp;
|
||||||
int k, r, c;
|
int k, r, c;
|
||||||
@ -174,7 +177,7 @@ LINMATH_H_FUNC void mat4x4_mul(mat4x4 M, mat4x4 a, mat4x4 b)
|
|||||||
}
|
}
|
||||||
mat4x4_dup(M, temp);
|
mat4x4_dup(M, temp);
|
||||||
}
|
}
|
||||||
LINMATH_H_FUNC void mat4x4_mul_vec4(vec4 r, mat4x4 M, vec4 v)
|
LINMATH_H_FUNC void mat4x4_mul_vec4(vec4 r, mat4x4 const M, vec4 const v)
|
||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
for(j=0; j<4; ++j) {
|
for(j=0; j<4; ++j) {
|
||||||
@ -200,13 +203,13 @@ LINMATH_H_FUNC void mat4x4_translate_in_place(mat4x4 M, float x, float y, float
|
|||||||
M[3][i] += vec4_mul_inner(r, t);
|
M[3][i] += vec4_mul_inner(r, t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LINMATH_H_FUNC void mat4x4_from_vec3_mul_outer(mat4x4 M, vec3 a, vec3 b)
|
LINMATH_H_FUNC void mat4x4_from_vec3_mul_outer(mat4x4 M, vec3 const a, vec3 const b)
|
||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
for(i=0; i<4; ++i) for(j=0; j<4; ++j)
|
for(i=0; i<4; ++i) for(j=0; j<4; ++j)
|
||||||
M[i][j] = i<3 && j<3 ? a[i] * b[j] : 0.f;
|
M[i][j] = i<3 && j<3 ? a[i] * b[j] : 0.f;
|
||||||
}
|
}
|
||||||
LINMATH_H_FUNC void mat4x4_rotate(mat4x4 R, mat4x4 M, float x, float y, float z, float angle)
|
LINMATH_H_FUNC void mat4x4_rotate(mat4x4 R, mat4x4 const M, float x, float y, float z, float angle)
|
||||||
{
|
{
|
||||||
float s = sinf(angle);
|
float s = sinf(angle);
|
||||||
float c = cosf(angle);
|
float c = cosf(angle);
|
||||||
@ -234,13 +237,13 @@ LINMATH_H_FUNC void mat4x4_rotate(mat4x4 R, mat4x4 M, float x, float y, float z,
|
|||||||
mat4x4_add(T, T, C);
|
mat4x4_add(T, T, C);
|
||||||
mat4x4_add(T, T, S);
|
mat4x4_add(T, T, S);
|
||||||
|
|
||||||
T[3][3] = 1.;
|
T[3][3] = 1.f;
|
||||||
mat4x4_mul(R, M, T);
|
mat4x4_mul(R, M, T);
|
||||||
} else {
|
} else {
|
||||||
mat4x4_dup(R, M);
|
mat4x4_dup(R, M);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LINMATH_H_FUNC void mat4x4_rotate_X(mat4x4 Q, mat4x4 M, float angle)
|
LINMATH_H_FUNC void mat4x4_rotate_X(mat4x4 Q, mat4x4 const M, float angle)
|
||||||
{
|
{
|
||||||
float s = sinf(angle);
|
float s = sinf(angle);
|
||||||
float c = cosf(angle);
|
float c = cosf(angle);
|
||||||
@ -252,19 +255,19 @@ LINMATH_H_FUNC void mat4x4_rotate_X(mat4x4 Q, mat4x4 M, float angle)
|
|||||||
};
|
};
|
||||||
mat4x4_mul(Q, M, R);
|
mat4x4_mul(Q, M, R);
|
||||||
}
|
}
|
||||||
LINMATH_H_FUNC void mat4x4_rotate_Y(mat4x4 Q, mat4x4 M, float angle)
|
LINMATH_H_FUNC void mat4x4_rotate_Y(mat4x4 Q, mat4x4 const M, float angle)
|
||||||
{
|
{
|
||||||
float s = sinf(angle);
|
float s = sinf(angle);
|
||||||
float c = cosf(angle);
|
float c = cosf(angle);
|
||||||
mat4x4 R = {
|
mat4x4 R = {
|
||||||
{ c, 0.f, s, 0.f},
|
{ c, 0.f, -s, 0.f},
|
||||||
{ 0.f, 1.f, 0.f, 0.f},
|
{ 0.f, 1.f, 0.f, 0.f},
|
||||||
{ -s, 0.f, c, 0.f},
|
{ s, 0.f, c, 0.f},
|
||||||
{ 0.f, 0.f, 0.f, 1.f}
|
{ 0.f, 0.f, 0.f, 1.f}
|
||||||
};
|
};
|
||||||
mat4x4_mul(Q, M, R);
|
mat4x4_mul(Q, M, R);
|
||||||
}
|
}
|
||||||
LINMATH_H_FUNC void mat4x4_rotate_Z(mat4x4 Q, mat4x4 M, float angle)
|
LINMATH_H_FUNC void mat4x4_rotate_Z(mat4x4 Q, mat4x4 const M, float angle)
|
||||||
{
|
{
|
||||||
float s = sinf(angle);
|
float s = sinf(angle);
|
||||||
float c = cosf(angle);
|
float c = cosf(angle);
|
||||||
@ -276,7 +279,7 @@ LINMATH_H_FUNC void mat4x4_rotate_Z(mat4x4 Q, mat4x4 M, float angle)
|
|||||||
};
|
};
|
||||||
mat4x4_mul(Q, M, R);
|
mat4x4_mul(Q, M, R);
|
||||||
}
|
}
|
||||||
LINMATH_H_FUNC void mat4x4_invert(mat4x4 T, mat4x4 M)
|
LINMATH_H_FUNC void mat4x4_invert(mat4x4 T, mat4x4 const M)
|
||||||
{
|
{
|
||||||
float s[6];
|
float s[6];
|
||||||
float c[6];
|
float c[6];
|
||||||
@ -317,10 +320,10 @@ LINMATH_H_FUNC void mat4x4_invert(mat4x4 T, mat4x4 M)
|
|||||||
T[3][2] = (-M[3][0] * s[3] + M[3][1] * s[1] - M[3][2] * s[0]) * idet;
|
T[3][2] = (-M[3][0] * s[3] + M[3][1] * s[1] - M[3][2] * s[0]) * idet;
|
||||||
T[3][3] = ( M[2][0] * s[3] - M[2][1] * s[1] + M[2][2] * s[0]) * idet;
|
T[3][3] = ( M[2][0] * s[3] - M[2][1] * s[1] + M[2][2] * s[0]) * idet;
|
||||||
}
|
}
|
||||||
LINMATH_H_FUNC void mat4x4_orthonormalize(mat4x4 R, mat4x4 M)
|
LINMATH_H_FUNC void mat4x4_orthonormalize(mat4x4 R, mat4x4 const M)
|
||||||
{
|
{
|
||||||
mat4x4_dup(R, M);
|
mat4x4_dup(R, M);
|
||||||
float s = 1.;
|
float s = 1.f;
|
||||||
vec3 h;
|
vec3 h;
|
||||||
|
|
||||||
vec3_norm(R[2], R[2]);
|
vec3_norm(R[2], R[2]);
|
||||||
@ -398,7 +401,7 @@ LINMATH_H_FUNC void mat4x4_perspective(mat4x4 m, float y_fov, float aspect, floa
|
|||||||
m[3][2] = -((2.f * f * n) / (f - n));
|
m[3][2] = -((2.f * f * n) / (f - n));
|
||||||
m[3][3] = 0.f;
|
m[3][3] = 0.f;
|
||||||
}
|
}
|
||||||
LINMATH_H_FUNC void mat4x4_look_at(mat4x4 m, vec3 eye, vec3 center, vec3 up)
|
LINMATH_H_FUNC void mat4x4_look_at(mat4x4 m, vec3 const eye, vec3 const center, vec3 const up)
|
||||||
{
|
{
|
||||||
/* Adapted from Android's OpenGL Matrix.java. */
|
/* Adapted from Android's OpenGL Matrix.java. */
|
||||||
/* See the OpenGL GLUT documentation for gluLookAt for a description */
|
/* See the OpenGL GLUT documentation for gluLookAt for a description */
|
||||||
@ -441,24 +444,18 @@ LINMATH_H_FUNC void mat4x4_look_at(mat4x4 m, vec3 eye, vec3 center, vec3 up)
|
|||||||
}
|
}
|
||||||
|
|
||||||
typedef float quat[4];
|
typedef float quat[4];
|
||||||
|
#define quat_add vec4_add
|
||||||
|
#define quat_sub vec4_sub
|
||||||
|
#define quat_norm vec4_norm
|
||||||
|
#define quat_scale vec4_scale
|
||||||
|
#define quat_mul_inner vec4_mul_inner
|
||||||
|
|
||||||
LINMATH_H_FUNC void quat_identity(quat q)
|
LINMATH_H_FUNC void quat_identity(quat q)
|
||||||
{
|
{
|
||||||
q[0] = q[1] = q[2] = 0.f;
|
q[0] = q[1] = q[2] = 0.f;
|
||||||
q[3] = 1.f;
|
q[3] = 1.f;
|
||||||
}
|
}
|
||||||
LINMATH_H_FUNC void quat_add(quat r, quat a, quat b)
|
LINMATH_H_FUNC void quat_mul(quat r, quat const p, quat const q)
|
||||||
{
|
|
||||||
int i;
|
|
||||||
for(i=0; i<4; ++i)
|
|
||||||
r[i] = a[i] + b[i];
|
|
||||||
}
|
|
||||||
LINMATH_H_FUNC void quat_sub(quat r, quat a, quat b)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
for(i=0; i<4; ++i)
|
|
||||||
r[i] = a[i] - b[i];
|
|
||||||
}
|
|
||||||
LINMATH_H_FUNC void quat_mul(quat r, quat p, quat q)
|
|
||||||
{
|
{
|
||||||
vec3 w;
|
vec3 w;
|
||||||
vec3_mul_cross(r, p, q);
|
vec3_mul_cross(r, p, q);
|
||||||
@ -468,37 +465,22 @@ LINMATH_H_FUNC void quat_mul(quat r, quat p, quat q)
|
|||||||
vec3_add(r, r, w);
|
vec3_add(r, r, w);
|
||||||
r[3] = p[3]*q[3] - vec3_mul_inner(p, q);
|
r[3] = p[3]*q[3] - vec3_mul_inner(p, q);
|
||||||
}
|
}
|
||||||
LINMATH_H_FUNC void quat_scale(quat r, quat v, float s)
|
LINMATH_H_FUNC void quat_conj(quat r, quat const q)
|
||||||
{
|
|
||||||
int i;
|
|
||||||
for(i=0; i<4; ++i)
|
|
||||||
r[i] = v[i] * s;
|
|
||||||
}
|
|
||||||
LINMATH_H_FUNC float quat_inner_product(quat a, quat b)
|
|
||||||
{
|
|
||||||
float p = 0.f;
|
|
||||||
int i;
|
|
||||||
for(i=0; i<4; ++i)
|
|
||||||
p += b[i]*a[i];
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
LINMATH_H_FUNC void quat_conj(quat r, quat q)
|
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for(i=0; i<3; ++i)
|
for(i=0; i<3; ++i)
|
||||||
r[i] = -q[i];
|
r[i] = -q[i];
|
||||||
r[3] = q[3];
|
r[3] = q[3];
|
||||||
}
|
}
|
||||||
LINMATH_H_FUNC void quat_rotate(quat r, float angle, vec3 axis) {
|
LINMATH_H_FUNC void quat_rotate(quat r, float angle, vec3 const axis) {
|
||||||
vec3 v;
|
vec3 axis_norm;
|
||||||
vec3_scale(v, axis, sinf(angle / 2));
|
vec3_norm(axis_norm, axis);
|
||||||
int i;
|
float s = sinf(angle / 2);
|
||||||
for(i=0; i<3; ++i)
|
float c = cosf(angle / 2);
|
||||||
r[i] = v[i];
|
vec3_scale(r, axis_norm, s);
|
||||||
r[3] = cosf(angle / 2);
|
r[3] = c;
|
||||||
}
|
}
|
||||||
#define quat_norm vec4_norm
|
LINMATH_H_FUNC void quat_mul_vec3(vec3 r, quat const q, vec3 const v)
|
||||||
LINMATH_H_FUNC void quat_mul_vec3(vec3 r, quat q, vec3 v)
|
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Method by Fabian 'ryg' Giessen (of Farbrausch)
|
* Method by Fabian 'ryg' Giessen (of Farbrausch)
|
||||||
@ -518,7 +500,7 @@ v' = v + q.w * t + cross(q.xyz, t)
|
|||||||
vec3_add(r, v, t);
|
vec3_add(r, v, t);
|
||||||
vec3_add(r, r, u);
|
vec3_add(r, r, u);
|
||||||
}
|
}
|
||||||
LINMATH_H_FUNC void mat4x4_from_quat(mat4x4 M, quat q)
|
LINMATH_H_FUNC void mat4x4_from_quat(mat4x4 M, quat const q)
|
||||||
{
|
{
|
||||||
float a = q[3];
|
float a = q[3];
|
||||||
float b = q[0];
|
float b = q[0];
|
||||||
@ -548,18 +530,21 @@ LINMATH_H_FUNC void mat4x4_from_quat(mat4x4 M, quat q)
|
|||||||
M[3][3] = 1.f;
|
M[3][3] = 1.f;
|
||||||
}
|
}
|
||||||
|
|
||||||
LINMATH_H_FUNC void mat4x4o_mul_quat(mat4x4 R, mat4x4 M, quat q)
|
LINMATH_H_FUNC void mat4x4o_mul_quat(mat4x4 R, mat4x4 const M, quat const q)
|
||||||
{
|
{
|
||||||
/* XXX: The way this is written only works for othogonal matrices. */
|
/* XXX: The way this is written only works for orthogonal matrices. */
|
||||||
/* TODO: Take care of non-orthogonal case. */
|
/* TODO: Take care of non-orthogonal case. */
|
||||||
quat_mul_vec3(R[0], q, M[0]);
|
quat_mul_vec3(R[0], q, M[0]);
|
||||||
quat_mul_vec3(R[1], q, M[1]);
|
quat_mul_vec3(R[1], q, M[1]);
|
||||||
quat_mul_vec3(R[2], q, M[2]);
|
quat_mul_vec3(R[2], q, M[2]);
|
||||||
|
|
||||||
R[3][0] = R[3][1] = R[3][2] = 0.f;
|
R[3][0] = R[3][1] = R[3][2] = 0.f;
|
||||||
R[3][3] = 1.f;
|
R[0][3] = M[0][3];
|
||||||
|
R[1][3] = M[1][3];
|
||||||
|
R[2][3] = M[2][3];
|
||||||
|
R[3][3] = M[3][3]; // typically 1.0, but here we make it general
|
||||||
}
|
}
|
||||||
LINMATH_H_FUNC void quat_from_mat4x4(quat q, mat4x4 M)
|
LINMATH_H_FUNC void quat_from_mat4x4(quat q, mat4x4 const M)
|
||||||
{
|
{
|
||||||
float r=0.f;
|
float r=0.f;
|
||||||
int i;
|
int i;
|
||||||
@ -589,13 +574,13 @@ LINMATH_H_FUNC void quat_from_mat4x4(quat q, mat4x4 M)
|
|||||||
q[3] = (M[p[2]][p[1]] - M[p[1]][p[2]])/(2.f*r);
|
q[3] = (M[p[2]][p[1]] - M[p[1]][p[2]])/(2.f*r);
|
||||||
}
|
}
|
||||||
|
|
||||||
LINMATH_H_FUNC void mat4x4_arcball(mat4x4 R, mat4x4 M, vec2 _a, vec2 _b, float s)
|
LINMATH_H_FUNC void mat4x4_arcball(mat4x4 R, mat4x4 const M, vec2 const _a, vec2 const _b, float s)
|
||||||
{
|
{
|
||||||
vec2 a; memcpy(a, _a, sizeof(a));
|
vec2 a; memcpy(a, _a, sizeof(a));
|
||||||
vec2 b; memcpy(b, _b, sizeof(b));
|
vec2 b; memcpy(b, _b, sizeof(b));
|
||||||
|
|
||||||
float z_a = 0.;
|
float z_a = 0.f;
|
||||||
float z_b = 0.;
|
float z_b = 0.f;
|
||||||
|
|
||||||
if(vec2_len(a) < 1.f) {
|
if(vec2_len(a) < 1.f) {
|
||||||
z_a = sqrtf(1.f - vec2_mul_inner(a, a));
|
z_a = sqrtf(1.f - vec2_mul_inner(a, a));
|
||||||
@ -615,7 +600,7 @@ LINMATH_H_FUNC void mat4x4_arcball(mat4x4 R, mat4x4 M, vec2 _a, vec2 _b, float s
|
|||||||
vec3 c_;
|
vec3 c_;
|
||||||
vec3_mul_cross(c_, a_, b_);
|
vec3_mul_cross(c_, a_, b_);
|
||||||
|
|
||||||
float const angle = acosf(vec3_mul_inner(a_, b_)) * s;
|
float const angle = acos(vec3_mul_inner(a_, b_)) * s;
|
||||||
mat4x4_rotate(R, M, c_[0], c_[1], c_[2], angle);
|
mat4x4_rotate(R, M, c_[0], c_[1], c_[2], angle);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
563
deps/nuklear.h
vendored
563
deps/nuklear.h
vendored
@ -105,6 +105,8 @@
|
|||||||
/// NK_INCLUDE_COMMAND_USERDATA | Defining this adds a userdata pointer into each command. Can be useful for example if you want to provide custom shaders depending on the used widget. Can be combined with the style structures.
|
/// NK_INCLUDE_COMMAND_USERDATA | Defining this adds a userdata pointer into each command. Can be useful for example if you want to provide custom shaders depending on the used widget. Can be combined with the style structures.
|
||||||
/// NK_BUTTON_TRIGGER_ON_RELEASE | Different platforms require button clicks occurring either on buttons being pressed (up to down) or released (down to up). By default this library will react on buttons being pressed, but if you define this it will only trigger if a button is released.
|
/// NK_BUTTON_TRIGGER_ON_RELEASE | Different platforms require button clicks occurring either on buttons being pressed (up to down) or released (down to up). By default this library will react on buttons being pressed, but if you define this it will only trigger if a button is released.
|
||||||
/// NK_ZERO_COMMAND_MEMORY | Defining this will zero out memory for each drawing command added to a drawing queue (inside nk_command_buffer_push). Zeroing command memory is very useful for fast checking (using memcmp) if command buffers are equal and avoid drawing frames when nothing on screen has changed since previous frame.
|
/// NK_ZERO_COMMAND_MEMORY | Defining this will zero out memory for each drawing command added to a drawing queue (inside nk_command_buffer_push). Zeroing command memory is very useful for fast checking (using memcmp) if command buffers are equal and avoid drawing frames when nothing on screen has changed since previous frame.
|
||||||
|
/// NK_UINT_DRAW_INDEX | Defining this will set the size of vertex index elements when using NK_VERTEX_BUFFER_OUTPUT to 32bit instead of the default of 16bit
|
||||||
|
/// NK_KEYSTATE_BASED_INPUT | Define this if your backend uses key state for each frame rather than key press/release events
|
||||||
///
|
///
|
||||||
/// !!! WARNING
|
/// !!! WARNING
|
||||||
/// The following flags will pull in the standard C library:
|
/// The following flags will pull in the standard C library:
|
||||||
@ -122,6 +124,7 @@
|
|||||||
/// - NK_INCLUDE_DEFAULT_FONT
|
/// - NK_INCLUDE_DEFAULT_FONT
|
||||||
/// - NK_INCLUDE_STANDARD_VARARGS
|
/// - NK_INCLUDE_STANDARD_VARARGS
|
||||||
/// - NK_INCLUDE_COMMAND_USERDATA
|
/// - NK_INCLUDE_COMMAND_USERDATA
|
||||||
|
/// - NK_UINT_DRAW_INDEX
|
||||||
///
|
///
|
||||||
/// ### Constants
|
/// ### Constants
|
||||||
/// Define | Description
|
/// Define | Description
|
||||||
@ -301,6 +304,7 @@ extern "C" {
|
|||||||
#define NK_CLAMP(i,v,x) (NK_MAX(NK_MIN(v,x), i))
|
#define NK_CLAMP(i,v,x) (NK_MAX(NK_MIN(v,x), i))
|
||||||
|
|
||||||
#ifdef NK_INCLUDE_STANDARD_VARARGS
|
#ifdef NK_INCLUDE_STANDARD_VARARGS
|
||||||
|
#include <stdarg.h> /* valist, va_start, va_end, ... */
|
||||||
#if defined(_MSC_VER) && (_MSC_VER >= 1600) /* VS 2010 and above */
|
#if defined(_MSC_VER) && (_MSC_VER >= 1600) /* VS 2010 and above */
|
||||||
#include <sal.h>
|
#include <sal.h>
|
||||||
#define NK_PRINTF_FORMAT_STRING _Printf_format_string_
|
#define NK_PRINTF_FORMAT_STRING _Printf_format_string_
|
||||||
@ -314,7 +318,6 @@ extern "C" {
|
|||||||
#define NK_PRINTF_VARARG_FUNC(fmtargnumber)
|
#define NK_PRINTF_VARARG_FUNC(fmtargnumber)
|
||||||
#define NK_PRINTF_VALIST_FUNC(fmtargnumber)
|
#define NK_PRINTF_VALIST_FUNC(fmtargnumber)
|
||||||
#endif
|
#endif
|
||||||
#include <stdarg.h> /* valist, va_start, va_end, ... */
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -336,7 +339,7 @@ extern "C" {
|
|||||||
#define NK_POINTER_TYPE uintptr_t
|
#define NK_POINTER_TYPE uintptr_t
|
||||||
#else
|
#else
|
||||||
#ifndef NK_INT8
|
#ifndef NK_INT8
|
||||||
#define NK_INT8 char
|
#define NK_INT8 signed char
|
||||||
#endif
|
#endif
|
||||||
#ifndef NK_UINT8
|
#ifndef NK_UINT8
|
||||||
#define NK_UINT8 unsigned char
|
#define NK_UINT8 unsigned char
|
||||||
@ -1084,6 +1087,12 @@ NK_API void nk_input_end(struct nk_context*);
|
|||||||
///
|
///
|
||||||
/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
|
/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
|
||||||
/// // fill configuration
|
/// // fill configuration
|
||||||
|
/// struct your_vertex
|
||||||
|
/// {
|
||||||
|
/// float pos[2]; // important to keep it to 2 floats
|
||||||
|
/// float uv[2];
|
||||||
|
/// unsigned char col[4];
|
||||||
|
/// };
|
||||||
/// struct nk_convert_config cfg = {};
|
/// struct nk_convert_config cfg = {};
|
||||||
/// static const struct nk_draw_vertex_layout_element vertex_layout[] = {
|
/// static const struct nk_draw_vertex_layout_element vertex_layout[] = {
|
||||||
/// {NK_VERTEX_POSITION, NK_FORMAT_FLOAT, NK_OFFSETOF(struct your_vertex, pos)},
|
/// {NK_VERTEX_POSITION, NK_FORMAT_FLOAT, NK_OFFSETOF(struct your_vertex, pos)},
|
||||||
@ -1209,7 +1218,7 @@ NK_API const struct nk_command* nk__next(struct nk_context*, const struct nk_com
|
|||||||
///
|
///
|
||||||
/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
|
/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
|
||||||
/// nk_flags nk_convert(struct nk_context *ctx, struct nk_buffer *cmds,
|
/// nk_flags nk_convert(struct nk_context *ctx, struct nk_buffer *cmds,
|
||||||
// struct nk_buffer *vertices, struct nk_buffer *elements, const struct nk_convert_config*);
|
/// struct nk_buffer *vertices, struct nk_buffer *elements, const struct nk_convert_config*);
|
||||||
/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
///
|
///
|
||||||
/// Parameter | Description
|
/// Parameter | Description
|
||||||
@ -1394,6 +1403,7 @@ NK_API const struct nk_draw_command* nk__draw_next(const struct nk_draw_command*
|
|||||||
/// nk_window_get_content_region_max | Returns the upper rectangle position of the currently visible and non-clipped space inside the currently processed window
|
/// nk_window_get_content_region_max | Returns the upper rectangle position of the currently visible and non-clipped space inside the currently processed window
|
||||||
/// nk_window_get_content_region_size | Returns the size of the currently visible and non-clipped space inside the currently processed window
|
/// nk_window_get_content_region_size | Returns the size of the currently visible and non-clipped space inside the currently processed window
|
||||||
/// nk_window_get_canvas | Returns the draw command buffer. Can be used to draw custom widgets
|
/// nk_window_get_canvas | Returns the draw command buffer. Can be used to draw custom widgets
|
||||||
|
/// nk_window_get_scroll | Gets the scroll offset of the current window
|
||||||
/// nk_window_has_focus | Returns if the currently processed window is currently active
|
/// nk_window_has_focus | Returns if the currently processed window is currently active
|
||||||
/// nk_window_is_collapsed | Returns if the window with given name is currently minimized/collapsed
|
/// nk_window_is_collapsed | Returns if the window with given name is currently minimized/collapsed
|
||||||
/// nk_window_is_closed | Returns if the currently processed window was closed
|
/// nk_window_is_closed | Returns if the currently processed window was closed
|
||||||
@ -1407,6 +1417,7 @@ NK_API const struct nk_draw_command* nk__draw_next(const struct nk_draw_command*
|
|||||||
/// nk_window_set_position | Updates position of the currently process window
|
/// nk_window_set_position | Updates position of the currently process window
|
||||||
/// nk_window_set_size | Updates the size of the currently processed window
|
/// nk_window_set_size | Updates the size of the currently processed window
|
||||||
/// nk_window_set_focus | Set the currently processed window as active window
|
/// nk_window_set_focus | Set the currently processed window as active window
|
||||||
|
/// nk_window_set_scroll | Sets the scroll offset of the current window
|
||||||
//
|
//
|
||||||
/// nk_window_close | Closes the window with given window name which deletes the window at the end of the frame
|
/// nk_window_close | Closes the window with given window name which deletes the window at the end of the frame
|
||||||
/// nk_window_collapse | Collapses the window with given window name
|
/// nk_window_collapse | Collapses the window with given window name
|
||||||
@ -1427,7 +1438,7 @@ NK_API const struct nk_draw_command* nk__draw_next(const struct nk_draw_command*
|
|||||||
/// NK_WINDOW_TITLE | Forces a header at the top at the window showing the title
|
/// NK_WINDOW_TITLE | Forces a header at the top at the window showing the title
|
||||||
/// NK_WINDOW_SCROLL_AUTO_HIDE | Automatically hides the window scrollbar if no user interaction: also requires delta time in `nk_context` to be set each frame
|
/// NK_WINDOW_SCROLL_AUTO_HIDE | Automatically hides the window scrollbar if no user interaction: also requires delta time in `nk_context` to be set each frame
|
||||||
/// NK_WINDOW_BACKGROUND | Always keep window in the background
|
/// NK_WINDOW_BACKGROUND | Always keep window in the background
|
||||||
/// NK_WINDOW_SCALE_LEFT | Puts window scaler in the left-ottom corner instead right-bottom
|
/// NK_WINDOW_SCALE_LEFT | Puts window scaler in the left-bottom corner instead right-bottom
|
||||||
/// NK_WINDOW_NO_INPUT | Prevents window of scaling, moving or getting focus
|
/// NK_WINDOW_NO_INPUT | Prevents window of scaling, moving or getting focus
|
||||||
///
|
///
|
||||||
/// #### nk_collapse_states
|
/// #### nk_collapse_states
|
||||||
@ -1506,7 +1517,7 @@ NK_API void nk_end(struct nk_context *ctx);
|
|||||||
/// Finds and returns a window from passed name
|
/// Finds and returns a window from passed name
|
||||||
///
|
///
|
||||||
/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
|
/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
|
||||||
/// void nk_end(struct nk_context *ctx);
|
/// struct nk_window *nk_window_find(struct nk_context *ctx, const char *name);
|
||||||
/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
///
|
///
|
||||||
/// Parameter | Description
|
/// Parameter | Description
|
||||||
@ -1710,6 +1721,22 @@ NK_API struct nk_vec2 nk_window_get_content_region_size(struct nk_context*);
|
|||||||
/// drawing canvas. Can be used to do custom drawing.
|
/// drawing canvas. Can be used to do custom drawing.
|
||||||
*/
|
*/
|
||||||
NK_API struct nk_command_buffer* nk_window_get_canvas(struct nk_context*);
|
NK_API struct nk_command_buffer* nk_window_get_canvas(struct nk_context*);
|
||||||
|
/*/// #### nk_window_get_scroll
|
||||||
|
/// Gets the scroll offset for the current window
|
||||||
|
/// !!! WARNING
|
||||||
|
/// Only call this function between calls `nk_begin_xxx` and `nk_end`
|
||||||
|
///
|
||||||
|
/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
|
||||||
|
/// void nk_window_get_scroll(struct nk_context *ctx, nk_uint *offset_x, nk_uint *offset_y);
|
||||||
|
/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
///
|
||||||
|
/// Parameter | Description
|
||||||
|
/// -------------|-----------------------------------------------------------
|
||||||
|
/// __ctx__ | Must point to an previously initialized `nk_context` struct
|
||||||
|
/// __offset_x__ | A pointer to the x offset output (or NULL to ignore)
|
||||||
|
/// __offset_y__ | A pointer to the y offset output (or NULL to ignore)
|
||||||
|
*/
|
||||||
|
NK_API void nk_window_get_scroll(struct nk_context*, nk_uint *offset_x, nk_uint *offset_y);
|
||||||
/*/// #### nk_window_has_focus
|
/*/// #### nk_window_has_focus
|
||||||
/// Returns if the currently processed window is currently active
|
/// Returns if the currently processed window is currently active
|
||||||
/// !!! WARNING
|
/// !!! WARNING
|
||||||
@ -1876,6 +1903,22 @@ NK_API void nk_window_set_size(struct nk_context*, const char *name, struct nk_v
|
|||||||
/// __name__ | Identifier of the window to set focus on
|
/// __name__ | Identifier of the window to set focus on
|
||||||
*/
|
*/
|
||||||
NK_API void nk_window_set_focus(struct nk_context*, const char *name);
|
NK_API void nk_window_set_focus(struct nk_context*, const char *name);
|
||||||
|
/*/// #### nk_window_set_scroll
|
||||||
|
/// Sets the scroll offset for the current window
|
||||||
|
/// !!! WARNING
|
||||||
|
/// Only call this function between calls `nk_begin_xxx` and `nk_end`
|
||||||
|
///
|
||||||
|
/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
|
||||||
|
/// void nk_window_set_scroll(struct nk_context *ctx, nk_uint offset_x, nk_uint offset_y);
|
||||||
|
/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
///
|
||||||
|
/// Parameter | Description
|
||||||
|
/// -------------|-----------------------------------------------------------
|
||||||
|
/// __ctx__ | Must point to an previously initialized `nk_context` struct
|
||||||
|
/// __offset_x__ | The x offset to scroll to
|
||||||
|
/// __offset_y__ | The y offset to scroll to
|
||||||
|
*/
|
||||||
|
NK_API void nk_window_set_scroll(struct nk_context*, nk_uint offset_x, nk_uint offset_y);
|
||||||
/*/// #### nk_window_close
|
/*/// #### nk_window_close
|
||||||
/// Closes a window and marks it for being freed at the end of the frame
|
/// Closes a window and marks it for being freed at the end of the frame
|
||||||
/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
|
/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
|
||||||
@ -2588,7 +2631,7 @@ NK_API struct nk_rect nk_layout_space_rect_to_local(struct nk_context*, struct n
|
|||||||
/// case ...:
|
/// case ...:
|
||||||
/// // [...]
|
/// // [...]
|
||||||
/// }
|
/// }
|
||||||
// nk_clear(&ctx);
|
/// nk_clear(&ctx);
|
||||||
/// }
|
/// }
|
||||||
/// nk_free(&ctx);
|
/// nk_free(&ctx);
|
||||||
/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
@ -2601,6 +2644,8 @@ NK_API struct nk_rect nk_layout_space_rect_to_local(struct nk_context*, struct n
|
|||||||
/// nk_group_scrolled_offset_begin | Start a new group with manual separated handling of scrollbar x- and y-offset
|
/// nk_group_scrolled_offset_begin | Start a new group with manual separated handling of scrollbar x- and y-offset
|
||||||
/// nk_group_scrolled_begin | Start a new group with manual scrollbar handling
|
/// nk_group_scrolled_begin | Start a new group with manual scrollbar handling
|
||||||
/// nk_group_scrolled_end | Ends a group with manual scrollbar handling. Should only be called if nk_group_begin returned non-zero
|
/// nk_group_scrolled_end | Ends a group with manual scrollbar handling. Should only be called if nk_group_begin returned non-zero
|
||||||
|
/// nk_group_get_scroll | Gets the scroll offset for the given group
|
||||||
|
/// nk_group_set_scroll | Sets the scroll offset for the given group
|
||||||
*/
|
*/
|
||||||
/*/// #### nk_group_begin
|
/*/// #### nk_group_begin
|
||||||
/// Starts a new widget group. Requires a previous layouting function to specify a pos/size.
|
/// Starts a new widget group. Requires a previous layouting function to specify a pos/size.
|
||||||
@ -2690,6 +2735,34 @@ NK_API int nk_group_scrolled_begin(struct nk_context*, struct nk_scroll *off, co
|
|||||||
/// __ctx__ | Must point to an previously initialized `nk_context` struct
|
/// __ctx__ | Must point to an previously initialized `nk_context` struct
|
||||||
*/
|
*/
|
||||||
NK_API void nk_group_scrolled_end(struct nk_context*);
|
NK_API void nk_group_scrolled_end(struct nk_context*);
|
||||||
|
/*/// #### nk_group_get_scroll
|
||||||
|
/// Gets the scroll position of the given group.
|
||||||
|
/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
|
||||||
|
/// void nk_group_get_scroll(struct nk_context*, const char *id, nk_uint *x_offset, nk_uint *y_offset);
|
||||||
|
/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
///
|
||||||
|
/// Parameter | Description
|
||||||
|
/// -------------|-----------------------------------------------------------
|
||||||
|
/// __ctx__ | Must point to an previously initialized `nk_context` struct
|
||||||
|
/// __id__ | The id of the group to get the scroll position of
|
||||||
|
/// __x_offset__ | A pointer to the x offset output (or NULL to ignore)
|
||||||
|
/// __y_offset__ | A pointer to the y offset output (or NULL to ignore)
|
||||||
|
*/
|
||||||
|
NK_API void nk_group_get_scroll(struct nk_context*, const char *id, nk_uint *x_offset, nk_uint *y_offset);
|
||||||
|
/*/// #### nk_group_set_scroll
|
||||||
|
/// Sets the scroll position of the given group.
|
||||||
|
/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
|
||||||
|
/// void nk_group_set_scroll(struct nk_context*, const char *id, nk_uint x_offset, nk_uint y_offset);
|
||||||
|
/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
///
|
||||||
|
/// Parameter | Description
|
||||||
|
/// -------------|-----------------------------------------------------------
|
||||||
|
/// __ctx__ | Must point to an previously initialized `nk_context` struct
|
||||||
|
/// __id__ | The id of the group to scroll
|
||||||
|
/// __x_offset__ | The x offset to scroll to
|
||||||
|
/// __y_offset__ | The y offset to scroll to
|
||||||
|
*/
|
||||||
|
NK_API void nk_group_set_scroll(struct nk_context*, const char *id, nk_uint x_offset, nk_uint y_offset);
|
||||||
/* =============================================================================
|
/* =============================================================================
|
||||||
*
|
*
|
||||||
* TREE
|
* TREE
|
||||||
@ -3187,7 +3260,7 @@ NK_API int nk_color_pick(struct nk_context*, struct nk_colorf*, enum nk_color_fo
|
|||||||
/// case ...:
|
/// case ...:
|
||||||
/// // [...]
|
/// // [...]
|
||||||
/// }
|
/// }
|
||||||
// nk_clear(&ctx);
|
/// nk_clear(&ctx);
|
||||||
/// }
|
/// }
|
||||||
/// nk_free(&ctx);
|
/// nk_free(&ctx);
|
||||||
/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
@ -3395,6 +3468,8 @@ NK_API void nk_plot_function(struct nk_context*, enum nk_chart_type, void *userd
|
|||||||
NK_API int nk_popup_begin(struct nk_context*, enum nk_popup_type, const char*, nk_flags, struct nk_rect bounds);
|
NK_API int nk_popup_begin(struct nk_context*, enum nk_popup_type, const char*, nk_flags, struct nk_rect bounds);
|
||||||
NK_API void nk_popup_close(struct nk_context*);
|
NK_API void nk_popup_close(struct nk_context*);
|
||||||
NK_API void nk_popup_end(struct nk_context*);
|
NK_API void nk_popup_end(struct nk_context*);
|
||||||
|
NK_API void nk_popup_get_scroll(struct nk_context*, nk_uint *offset_x, nk_uint *offset_y);
|
||||||
|
NK_API void nk_popup_set_scroll(struct nk_context*, nk_uint offset_x, nk_uint offset_y);
|
||||||
/* =============================================================================
|
/* =============================================================================
|
||||||
*
|
*
|
||||||
* COMBOBOX
|
* COMBOBOX
|
||||||
@ -4588,7 +4663,11 @@ NK_API int nk_input_is_key_down(const struct nk_input*, enum nk_keys);
|
|||||||
In fact it is probably more powerful than needed but allows even more crazy
|
In fact it is probably more powerful than needed but allows even more crazy
|
||||||
things than this library provides by default.
|
things than this library provides by default.
|
||||||
*/
|
*/
|
||||||
|
#ifdef NK_UINT_DRAW_INDEX
|
||||||
|
typedef nk_uint nk_draw_index;
|
||||||
|
#else
|
||||||
typedef nk_ushort nk_draw_index;
|
typedef nk_ushort nk_draw_index;
|
||||||
|
#endif
|
||||||
enum nk_draw_list_stroke {
|
enum nk_draw_list_stroke {
|
||||||
NK_STROKE_OPEN = nk_false,
|
NK_STROKE_OPEN = nk_false,
|
||||||
/* build up path has no connection back to the beginning */
|
/* build up path has no connection back to the beginning */
|
||||||
@ -5603,7 +5682,6 @@ template<typename T> struct nk_alignof{struct Big {T x; char c;}; enum {
|
|||||||
|
|
||||||
#endif /* NK_NUKLEAR_H_ */
|
#endif /* NK_NUKLEAR_H_ */
|
||||||
|
|
||||||
|
|
||||||
#ifdef NK_IMPLEMENTATION
|
#ifdef NK_IMPLEMENTATION
|
||||||
|
|
||||||
#ifndef NK_INTERNAL_H
|
#ifndef NK_INTERNAL_H
|
||||||
@ -6007,15 +6085,18 @@ nk_sin(float x)
|
|||||||
NK_LIB float
|
NK_LIB float
|
||||||
nk_cos(float x)
|
nk_cos(float x)
|
||||||
{
|
{
|
||||||
NK_STORAGE const float a0 = +1.00238601909309722f;
|
/* New implementation. Also generated using lolremez. */
|
||||||
NK_STORAGE const float a1 = -3.81919947353040024e-2f;
|
/* Old version significantly deviated from expected results. */
|
||||||
NK_STORAGE const float a2 = -3.94382342128062756e-1f;
|
NK_STORAGE const float a0 = 9.9995999154986614e-1f;
|
||||||
NK_STORAGE const float a3 = -1.18134036025221444e-1f;
|
NK_STORAGE const float a1 = 1.2548995793001028e-3f;
|
||||||
NK_STORAGE const float a4 = +1.07123798512170878e-1f;
|
NK_STORAGE const float a2 = -5.0648546280678015e-1f;
|
||||||
NK_STORAGE const float a5 = -1.86637164165180873e-2f;
|
NK_STORAGE const float a3 = 1.2942246466519995e-2f;
|
||||||
NK_STORAGE const float a6 = +9.90140908664079833e-4f;
|
NK_STORAGE const float a4 = 2.8668384702547972e-2f;
|
||||||
NK_STORAGE const float a7 = -5.23022132118824778e-14f;
|
NK_STORAGE const float a5 = 7.3726485210586547e-3f;
|
||||||
return a0 + x*(a1 + x*(a2 + x*(a3 + x*(a4 + x*(a5 + x*(a6 + x*a7))))));
|
NK_STORAGE const float a6 = -3.8510875386947414e-3f;
|
||||||
|
NK_STORAGE const float a7 = 4.7196604604366623e-4f;
|
||||||
|
NK_STORAGE const float a8 = -1.8776444013090451e-5f;
|
||||||
|
return a0 + x*(a1 + x*(a2 + x*(a3 + x*(a4 + x*(a5 + x*(a6 + x*(a7 + x*a8)))))));
|
||||||
}
|
}
|
||||||
NK_LIB nk_uint
|
NK_LIB nk_uint
|
||||||
nk_round_up_pow2(nk_uint v)
|
nk_round_up_pow2(nk_uint v)
|
||||||
@ -7151,23 +7232,29 @@ nk_murmur_hash(const void * key, int len, nk_hash seed)
|
|||||||
{
|
{
|
||||||
/* 32-Bit MurmurHash3: https://code.google.com/p/smhasher/wiki/MurmurHash3*/
|
/* 32-Bit MurmurHash3: https://code.google.com/p/smhasher/wiki/MurmurHash3*/
|
||||||
#define NK_ROTL(x,r) ((x) << (r) | ((x) >> (32 - r)))
|
#define NK_ROTL(x,r) ((x) << (r) | ((x) >> (32 - r)))
|
||||||
union {const nk_uint *i; const nk_byte *b;} conv = {0};
|
|
||||||
const nk_byte *data = (const nk_byte*)key;
|
|
||||||
const int nblocks = len/4;
|
|
||||||
nk_uint h1 = seed;
|
nk_uint h1 = seed;
|
||||||
|
nk_uint k1;
|
||||||
|
const nk_byte *data = (const nk_byte*)key;
|
||||||
|
const nk_byte *keyptr = data;
|
||||||
|
nk_byte *k1ptr;
|
||||||
|
const int bsize = sizeof(k1);
|
||||||
|
const int nblocks = len/4;
|
||||||
|
|
||||||
const nk_uint c1 = 0xcc9e2d51;
|
const nk_uint c1 = 0xcc9e2d51;
|
||||||
const nk_uint c2 = 0x1b873593;
|
const nk_uint c2 = 0x1b873593;
|
||||||
const nk_byte *tail;
|
const nk_byte *tail;
|
||||||
const nk_uint *blocks;
|
|
||||||
nk_uint k1;
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* body */
|
/* body */
|
||||||
if (!key) return 0;
|
if (!key) return 0;
|
||||||
conv.b = (data + nblocks*4);
|
for (i = 0; i < nblocks; ++i, keyptr += bsize) {
|
||||||
blocks = (const nk_uint*)conv.i;
|
k1ptr = (nk_byte*)&k1;
|
||||||
for (i = -nblocks; i; ++i) {
|
k1ptr[0] = keyptr[0];
|
||||||
k1 = blocks[i];
|
k1ptr[1] = keyptr[1];
|
||||||
|
k1ptr[2] = keyptr[2];
|
||||||
|
k1ptr[3] = keyptr[3];
|
||||||
|
|
||||||
k1 *= c1;
|
k1 *= c1;
|
||||||
k1 = NK_ROTL(k1,15);
|
k1 = NK_ROTL(k1,15);
|
||||||
k1 *= c2;
|
k1 *= c2;
|
||||||
@ -9356,7 +9443,7 @@ nk_draw_list_alloc_vertices(struct nk_draw_list *list, nk_size count)
|
|||||||
* backend (OpenGL, DirectX, ...). For example in OpenGL for `glDrawElements`
|
* backend (OpenGL, DirectX, ...). For example in OpenGL for `glDrawElements`
|
||||||
* instead of specifing `GL_UNSIGNED_SHORT` you have to define `GL_UNSIGNED_INT`.
|
* instead of specifing `GL_UNSIGNED_SHORT` you have to define `GL_UNSIGNED_INT`.
|
||||||
* Sorry for the inconvenience. */
|
* Sorry for the inconvenience. */
|
||||||
NK_ASSERT((sizeof(nk_draw_index) == 2 && list->vertex_count < NK_USHORT_MAX &&
|
if(sizeof(nk_draw_index)==2) NK_ASSERT((list->vertex_count < NK_USHORT_MAX &&
|
||||||
"To many verticies for 16-bit vertex indicies. Please read comment above on how to solve this problem"));
|
"To many verticies for 16-bit vertex indicies. Please read comment above on how to solve this problem"));
|
||||||
return vtx;
|
return vtx;
|
||||||
}
|
}
|
||||||
@ -12809,6 +12896,9 @@ nk_font_bake(struct nk_font_baker *baker, void *image_memory, int width, int hei
|
|||||||
dst_font->ascent = ((float)unscaled_ascent * font_scale);
|
dst_font->ascent = ((float)unscaled_ascent * font_scale);
|
||||||
dst_font->descent = ((float)unscaled_descent * font_scale);
|
dst_font->descent = ((float)unscaled_descent * font_scale);
|
||||||
dst_font->glyph_offset = glyph_n;
|
dst_font->glyph_offset = glyph_n;
|
||||||
|
// Need to zero this, or it will carry over from a previous
|
||||||
|
// bake, and cause a segfault when accessing glyphs[].
|
||||||
|
dst_font->glyph_count = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* fill own baked font glyph array */
|
/* fill own baked font glyph array */
|
||||||
@ -13903,8 +13993,12 @@ nk_input_key(struct nk_context *ctx, enum nk_keys key, int down)
|
|||||||
NK_ASSERT(ctx);
|
NK_ASSERT(ctx);
|
||||||
if (!ctx) return;
|
if (!ctx) return;
|
||||||
in = &ctx->input;
|
in = &ctx->input;
|
||||||
|
#ifdef NK_KEYSTATE_BASED_INPUT
|
||||||
if (in->keyboard.keys[key].down != down)
|
if (in->keyboard.keys[key].down != down)
|
||||||
in->keyboard.keys[key].clicked++;
|
in->keyboard.keys[key].clicked++;
|
||||||
|
#else
|
||||||
|
in->keyboard.keys[key].clicked++;
|
||||||
|
#endif
|
||||||
in->keyboard.keys[key].down = down;
|
in->keyboard.keys[key].down = down;
|
||||||
}
|
}
|
||||||
NK_API void
|
NK_API void
|
||||||
@ -15788,7 +15882,7 @@ nk_panel_end(struct nk_context *ctx)
|
|||||||
nk_fill_rect(out, empty_space, 0, style->window.background);
|
nk_fill_rect(out, empty_space, 0, style->window.background);
|
||||||
|
|
||||||
/* fill right empty space */
|
/* fill right empty space */
|
||||||
empty_space.x = layout->bounds.x + layout->bounds.w - layout->border;
|
empty_space.x = layout->bounds.x + layout->bounds.w;
|
||||||
empty_space.y = layout->bounds.y;
|
empty_space.y = layout->bounds.y;
|
||||||
empty_space.w = panel_padding.x + layout->border;
|
empty_space.w = panel_padding.x + layout->border;
|
||||||
empty_space.h = layout->bounds.h;
|
empty_space.h = layout->bounds.h;
|
||||||
@ -15797,11 +15891,11 @@ nk_panel_end(struct nk_context *ctx)
|
|||||||
nk_fill_rect(out, empty_space, 0, style->window.background);
|
nk_fill_rect(out, empty_space, 0, style->window.background);
|
||||||
|
|
||||||
/* fill bottom empty space */
|
/* fill bottom empty space */
|
||||||
if (*layout->offset_x != 0 && !(layout->flags & NK_WINDOW_NO_SCROLLBAR)) {
|
if (layout->footer_height > 0) {
|
||||||
empty_space.x = window->bounds.x;
|
empty_space.x = window->bounds.x;
|
||||||
empty_space.y = layout->bounds.y + layout->bounds.h;
|
empty_space.y = layout->bounds.y + layout->bounds.h;
|
||||||
empty_space.w = window->bounds.w;
|
empty_space.w = window->bounds.w;
|
||||||
empty_space.h = scrollbar_size.y;
|
empty_space.h = layout->footer_height;
|
||||||
nk_fill_rect(out, empty_space, 0, style->window.background);
|
nk_fill_rect(out, empty_space, 0, style->window.background);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -16175,8 +16269,8 @@ nk_begin_titled(struct nk_context *ctx, const char *name, const char *title,
|
|||||||
{
|
{
|
||||||
struct nk_window *win;
|
struct nk_window *win;
|
||||||
struct nk_style *style;
|
struct nk_style *style;
|
||||||
nk_hash title_hash;
|
nk_hash name_hash;
|
||||||
int title_len;
|
int name_len;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
NK_ASSERT(ctx);
|
NK_ASSERT(ctx);
|
||||||
@ -16189,12 +16283,12 @@ nk_begin_titled(struct nk_context *ctx, const char *name, const char *title,
|
|||||||
|
|
||||||
/* find or create window */
|
/* find or create window */
|
||||||
style = &ctx->style;
|
style = &ctx->style;
|
||||||
title_len = (int)nk_strlen(name);
|
name_len = (int)nk_strlen(name);
|
||||||
title_hash = nk_murmur_hash(name, (int)title_len, NK_WINDOW_TITLE);
|
name_hash = nk_murmur_hash(name, (int)name_len, NK_WINDOW_TITLE);
|
||||||
win = nk_find_window(ctx, title_hash, name);
|
win = nk_find_window(ctx, name_hash, name);
|
||||||
if (!win) {
|
if (!win) {
|
||||||
/* create new window */
|
/* create new window */
|
||||||
nk_size name_length = (nk_size)nk_strlen(name);
|
nk_size name_length = (nk_size)name_len;
|
||||||
win = (struct nk_window*)nk_create_window(ctx);
|
win = (struct nk_window*)nk_create_window(ctx);
|
||||||
NK_ASSERT(win);
|
NK_ASSERT(win);
|
||||||
if (!win) return 0;
|
if (!win) return 0;
|
||||||
@ -16206,7 +16300,7 @@ nk_begin_titled(struct nk_context *ctx, const char *name, const char *title,
|
|||||||
|
|
||||||
win->flags = flags;
|
win->flags = flags;
|
||||||
win->bounds = bounds;
|
win->bounds = bounds;
|
||||||
win->name = title_hash;
|
win->name = name_hash;
|
||||||
name_length = NK_MIN(name_length, NK_WINDOW_MAX_NAME-1);
|
name_length = NK_MIN(name_length, NK_WINDOW_MAX_NAME-1);
|
||||||
NK_MEMCPY(win->name_string, name, name_length);
|
NK_MEMCPY(win->name_string, name, name_length);
|
||||||
win->name_string[name_length] = 0;
|
win->name_string[name_length] = 0;
|
||||||
@ -16434,6 +16528,20 @@ nk_window_get_panel(struct nk_context *ctx)
|
|||||||
if (!ctx || !ctx->current) return 0;
|
if (!ctx || !ctx->current) return 0;
|
||||||
return ctx->current->layout;
|
return ctx->current->layout;
|
||||||
}
|
}
|
||||||
|
NK_API void
|
||||||
|
nk_window_get_scroll(struct nk_context *ctx, nk_uint *offset_x, nk_uint *offset_y)
|
||||||
|
{
|
||||||
|
struct nk_window *win;
|
||||||
|
NK_ASSERT(ctx);
|
||||||
|
NK_ASSERT(ctx->current);
|
||||||
|
if (!ctx || !ctx->current)
|
||||||
|
return ;
|
||||||
|
win = ctx->current;
|
||||||
|
if (offset_x)
|
||||||
|
*offset_x = win->scrollbar.x;
|
||||||
|
if (offset_y)
|
||||||
|
*offset_y = win->scrollbar.y;
|
||||||
|
}
|
||||||
NK_API int
|
NK_API int
|
||||||
nk_window_has_focus(const struct nk_context *ctx)
|
nk_window_has_focus(const struct nk_context *ctx)
|
||||||
{
|
{
|
||||||
@ -16600,6 +16708,18 @@ nk_window_set_size(struct nk_context *ctx,
|
|||||||
win->bounds.h = size.y;
|
win->bounds.h = size.y;
|
||||||
}
|
}
|
||||||
NK_API void
|
NK_API void
|
||||||
|
nk_window_set_scroll(struct nk_context *ctx, nk_uint offset_x, nk_uint offset_y)
|
||||||
|
{
|
||||||
|
struct nk_window *win;
|
||||||
|
NK_ASSERT(ctx);
|
||||||
|
NK_ASSERT(ctx->current);
|
||||||
|
if (!ctx || !ctx->current)
|
||||||
|
return;
|
||||||
|
win = ctx->current;
|
||||||
|
win->scrollbar.x = offset_x;
|
||||||
|
win->scrollbar.y = offset_y;
|
||||||
|
}
|
||||||
|
NK_API void
|
||||||
nk_window_collapse(struct nk_context *ctx, const char *name,
|
nk_window_collapse(struct nk_context *ctx, const char *name,
|
||||||
enum nk_collapse_states c)
|
enum nk_collapse_states c)
|
||||||
{
|
{
|
||||||
@ -16673,7 +16793,6 @@ nk_window_set_focus(struct nk_context *ctx, const char *name)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* ===============================================================
|
/* ===============================================================
|
||||||
*
|
*
|
||||||
* POPUP
|
* POPUP
|
||||||
@ -16807,7 +16926,11 @@ nk_nonblock_begin(struct nk_context *ctx,
|
|||||||
} else {
|
} else {
|
||||||
/* close the popup if user pressed outside or in the header */
|
/* close the popup if user pressed outside or in the header */
|
||||||
int pressed, in_body, in_header;
|
int pressed, in_body, in_header;
|
||||||
|
#ifdef NK_BUTTON_TRIGGER_ON_RELEASE
|
||||||
|
pressed = nk_input_is_mouse_released(&ctx->input, NK_BUTTON_LEFT);
|
||||||
|
#else
|
||||||
pressed = nk_input_is_mouse_pressed(&ctx->input, NK_BUTTON_LEFT);
|
pressed = nk_input_is_mouse_pressed(&ctx->input, NK_BUTTON_LEFT);
|
||||||
|
#endif
|
||||||
in_body = nk_input_is_mouse_hovering_rect(&ctx->input, body);
|
in_body = nk_input_is_mouse_hovering_rect(&ctx->input, body);
|
||||||
in_header = nk_input_is_mouse_hovering_rect(&ctx->input, header);
|
in_header = nk_input_is_mouse_hovering_rect(&ctx->input, header);
|
||||||
if (pressed && (!in_body || in_header))
|
if (pressed && (!in_body || in_header))
|
||||||
@ -16898,7 +17021,38 @@ nk_popup_end(struct nk_context *ctx)
|
|||||||
ctx->current = win;
|
ctx->current = win;
|
||||||
nk_push_scissor(&win->buffer, win->layout->clip);
|
nk_push_scissor(&win->buffer, win->layout->clip);
|
||||||
}
|
}
|
||||||
|
NK_API void
|
||||||
|
nk_popup_get_scroll(struct nk_context *ctx, nk_uint *offset_x, nk_uint *offset_y)
|
||||||
|
{
|
||||||
|
struct nk_window *popup;
|
||||||
|
|
||||||
|
NK_ASSERT(ctx);
|
||||||
|
NK_ASSERT(ctx->current);
|
||||||
|
NK_ASSERT(ctx->current->layout);
|
||||||
|
if (!ctx || !ctx->current || !ctx->current->layout)
|
||||||
|
return;
|
||||||
|
|
||||||
|
popup = ctx->current;
|
||||||
|
if (offset_x)
|
||||||
|
*offset_x = popup->scrollbar.x;
|
||||||
|
if (offset_y)
|
||||||
|
*offset_y = popup->scrollbar.y;
|
||||||
|
}
|
||||||
|
NK_API void
|
||||||
|
nk_popup_set_scroll(struct nk_context *ctx, nk_uint offset_x, nk_uint offset_y)
|
||||||
|
{
|
||||||
|
struct nk_window *popup;
|
||||||
|
|
||||||
|
NK_ASSERT(ctx);
|
||||||
|
NK_ASSERT(ctx->current);
|
||||||
|
NK_ASSERT(ctx->current->layout);
|
||||||
|
if (!ctx || !ctx->current || !ctx->current->layout)
|
||||||
|
return;
|
||||||
|
|
||||||
|
popup = ctx->current;
|
||||||
|
popup->scrollbar.x = offset_x;
|
||||||
|
popup->scrollbar.y = offset_y;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -18025,22 +18179,25 @@ nk_layout_widget_space(struct nk_rect *bounds, const struct nk_context *ctx,
|
|||||||
panel_space = nk_layout_row_calculate_usable_space(&ctx->style, layout->type,
|
panel_space = nk_layout_row_calculate_usable_space(&ctx->style, layout->type,
|
||||||
layout->bounds.w, layout->row.columns);
|
layout->bounds.w, layout->row.columns);
|
||||||
|
|
||||||
|
#define NK_FRAC(x) (x - (int)x) /* will be used to remove fookin gaps */
|
||||||
/* calculate the width of one item inside the current layout space */
|
/* calculate the width of one item inside the current layout space */
|
||||||
switch (layout->row.type) {
|
switch (layout->row.type) {
|
||||||
case NK_LAYOUT_DYNAMIC_FIXED: {
|
case NK_LAYOUT_DYNAMIC_FIXED: {
|
||||||
/* scaling fixed size widgets item width */
|
/* scaling fixed size widgets item width */
|
||||||
item_width = NK_MAX(1.0f,panel_space) / (float)layout->row.columns;
|
float w = NK_MAX(1.0f,panel_space) / (float)layout->row.columns;
|
||||||
item_offset = (float)layout->row.index * item_width;
|
item_offset = (float)layout->row.index * w;
|
||||||
|
item_width = w + NK_FRAC(item_offset);
|
||||||
item_spacing = (float)layout->row.index * spacing.x;
|
item_spacing = (float)layout->row.index * spacing.x;
|
||||||
} break;
|
} break;
|
||||||
case NK_LAYOUT_DYNAMIC_ROW: {
|
case NK_LAYOUT_DYNAMIC_ROW: {
|
||||||
/* scaling single ratio widget width */
|
/* scaling single ratio widget width */
|
||||||
item_width = layout->row.item_width * panel_space;
|
float w = layout->row.item_width * panel_space;
|
||||||
item_offset = layout->row.item_offset;
|
item_offset = layout->row.item_offset;
|
||||||
|
item_width = w + NK_FRAC(item_offset);
|
||||||
item_spacing = 0;
|
item_spacing = 0;
|
||||||
|
|
||||||
if (modify) {
|
if (modify) {
|
||||||
layout->row.item_offset += item_width + spacing.x;
|
layout->row.item_offset += w + spacing.x;
|
||||||
layout->row.filled += layout->row.item_width;
|
layout->row.filled += layout->row.item_width;
|
||||||
layout->row.index = 0;
|
layout->row.index = 0;
|
||||||
}
|
}
|
||||||
@ -18051,23 +18208,24 @@ nk_layout_widget_space(struct nk_rect *bounds, const struct nk_context *ctx,
|
|||||||
bounds->x -= (float)*layout->offset_x;
|
bounds->x -= (float)*layout->offset_x;
|
||||||
bounds->y = layout->at_y + (layout->row.height * layout->row.item.y);
|
bounds->y = layout->at_y + (layout->row.height * layout->row.item.y);
|
||||||
bounds->y -= (float)*layout->offset_y;
|
bounds->y -= (float)*layout->offset_y;
|
||||||
bounds->w = layout->bounds.w * layout->row.item.w;
|
bounds->w = layout->bounds.w * layout->row.item.w + NK_FRAC(bounds->x);
|
||||||
bounds->h = layout->row.height * layout->row.item.h;
|
bounds->h = layout->row.height * layout->row.item.h + NK_FRAC(bounds->y);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
case NK_LAYOUT_DYNAMIC: {
|
case NK_LAYOUT_DYNAMIC: {
|
||||||
/* scaling arrays of panel width ratios for every widget */
|
/* scaling arrays of panel width ratios for every widget */
|
||||||
float ratio;
|
float ratio, w;
|
||||||
NK_ASSERT(layout->row.ratio);
|
NK_ASSERT(layout->row.ratio);
|
||||||
ratio = (layout->row.ratio[layout->row.index] < 0) ?
|
ratio = (layout->row.ratio[layout->row.index] < 0) ?
|
||||||
layout->row.item_width : layout->row.ratio[layout->row.index];
|
layout->row.item_width : layout->row.ratio[layout->row.index];
|
||||||
|
|
||||||
|
w = (ratio * panel_space);
|
||||||
item_spacing = (float)layout->row.index * spacing.x;
|
item_spacing = (float)layout->row.index * spacing.x;
|
||||||
item_width = (ratio * panel_space);
|
|
||||||
item_offset = layout->row.item_offset;
|
item_offset = layout->row.item_offset;
|
||||||
|
item_width = w + NK_FRAC(item_offset);
|
||||||
|
|
||||||
if (modify) {
|
if (modify) {
|
||||||
layout->row.item_offset += item_width;
|
layout->row.item_offset += w;
|
||||||
layout->row.filled += ratio;
|
layout->row.filled += ratio;
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
@ -18105,13 +18263,16 @@ nk_layout_widget_space(struct nk_rect *bounds, const struct nk_context *ctx,
|
|||||||
} break;
|
} break;
|
||||||
case NK_LAYOUT_TEMPLATE: {
|
case NK_LAYOUT_TEMPLATE: {
|
||||||
/* stretchy row layout with combined dynamic/static widget width*/
|
/* stretchy row layout with combined dynamic/static widget width*/
|
||||||
|
float w;
|
||||||
NK_ASSERT(layout->row.index < layout->row.columns);
|
NK_ASSERT(layout->row.index < layout->row.columns);
|
||||||
NK_ASSERT(layout->row.index < NK_MAX_LAYOUT_ROW_TEMPLATE_COLUMNS);
|
NK_ASSERT(layout->row.index < NK_MAX_LAYOUT_ROW_TEMPLATE_COLUMNS);
|
||||||
item_width = layout->row.templates[layout->row.index];
|
w = layout->row.templates[layout->row.index];
|
||||||
item_offset = layout->row.item_offset;
|
item_offset = layout->row.item_offset;
|
||||||
|
item_width = w + NK_FRAC(item_offset);
|
||||||
item_spacing = (float)layout->row.index * spacing.x;
|
item_spacing = (float)layout->row.index * spacing.x;
|
||||||
if (modify) layout->row.item_offset += item_width;
|
if (modify) layout->row.item_offset += w;
|
||||||
} break;
|
} break;
|
||||||
|
#undef NK_FRAC
|
||||||
default: NK_ASSERT(0); break;
|
default: NK_ASSERT(0); break;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -18687,7 +18848,74 @@ nk_group_end(struct nk_context *ctx)
|
|||||||
{
|
{
|
||||||
nk_group_scrolled_end(ctx);
|
nk_group_scrolled_end(ctx);
|
||||||
}
|
}
|
||||||
|
NK_API void
|
||||||
|
nk_group_get_scroll(struct nk_context *ctx, const char *id, nk_uint *x_offset, nk_uint *y_offset)
|
||||||
|
{
|
||||||
|
int id_len;
|
||||||
|
nk_hash id_hash;
|
||||||
|
struct nk_window *win;
|
||||||
|
nk_uint *x_offset_ptr;
|
||||||
|
nk_uint *y_offset_ptr;
|
||||||
|
|
||||||
|
NK_ASSERT(ctx);
|
||||||
|
NK_ASSERT(id);
|
||||||
|
NK_ASSERT(ctx->current);
|
||||||
|
NK_ASSERT(ctx->current->layout);
|
||||||
|
if (!ctx || !ctx->current || !ctx->current->layout || !id)
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* find persistent group scrollbar value */
|
||||||
|
win = ctx->current;
|
||||||
|
id_len = (int)nk_strlen(id);
|
||||||
|
id_hash = nk_murmur_hash(id, (int)id_len, NK_PANEL_GROUP);
|
||||||
|
x_offset_ptr = nk_find_value(win, id_hash);
|
||||||
|
if (!x_offset_ptr) {
|
||||||
|
x_offset_ptr = nk_add_value(ctx, win, id_hash, 0);
|
||||||
|
y_offset_ptr = nk_add_value(ctx, win, id_hash+1, 0);
|
||||||
|
|
||||||
|
NK_ASSERT(x_offset_ptr);
|
||||||
|
NK_ASSERT(y_offset_ptr);
|
||||||
|
if (!x_offset_ptr || !y_offset_ptr) return;
|
||||||
|
*x_offset_ptr = *y_offset_ptr = 0;
|
||||||
|
} else y_offset_ptr = nk_find_value(win, id_hash+1);
|
||||||
|
if (x_offset)
|
||||||
|
*x_offset = *x_offset_ptr;
|
||||||
|
if (y_offset)
|
||||||
|
*y_offset = *y_offset_ptr;
|
||||||
|
}
|
||||||
|
NK_API void
|
||||||
|
nk_group_set_scroll(struct nk_context *ctx, const char *id, nk_uint x_offset, nk_uint y_offset)
|
||||||
|
{
|
||||||
|
int id_len;
|
||||||
|
nk_hash id_hash;
|
||||||
|
struct nk_window *win;
|
||||||
|
nk_uint *x_offset_ptr;
|
||||||
|
nk_uint *y_offset_ptr;
|
||||||
|
|
||||||
|
NK_ASSERT(ctx);
|
||||||
|
NK_ASSERT(id);
|
||||||
|
NK_ASSERT(ctx->current);
|
||||||
|
NK_ASSERT(ctx->current->layout);
|
||||||
|
if (!ctx || !ctx->current || !ctx->current->layout || !id)
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* find persistent group scrollbar value */
|
||||||
|
win = ctx->current;
|
||||||
|
id_len = (int)nk_strlen(id);
|
||||||
|
id_hash = nk_murmur_hash(id, (int)id_len, NK_PANEL_GROUP);
|
||||||
|
x_offset_ptr = nk_find_value(win, id_hash);
|
||||||
|
if (!x_offset_ptr) {
|
||||||
|
x_offset_ptr = nk_add_value(ctx, win, id_hash, 0);
|
||||||
|
y_offset_ptr = nk_add_value(ctx, win, id_hash+1, 0);
|
||||||
|
|
||||||
|
NK_ASSERT(x_offset_ptr);
|
||||||
|
NK_ASSERT(y_offset_ptr);
|
||||||
|
if (!x_offset_ptr || !y_offset_ptr) return;
|
||||||
|
*x_offset_ptr = *y_offset_ptr = 0;
|
||||||
|
} else y_offset_ptr = nk_find_value(win, id_hash+1);
|
||||||
|
*x_offset_ptr = x_offset;
|
||||||
|
*y_offset_ptr = y_offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -21179,6 +21407,7 @@ nk_scrollbar_behavior(nk_flags *state, struct nk_input *in,
|
|||||||
{
|
{
|
||||||
nk_flags ws = 0;
|
nk_flags ws = 0;
|
||||||
int left_mouse_down;
|
int left_mouse_down;
|
||||||
|
int left_mouse_clicked;
|
||||||
int left_mouse_click_in_cursor;
|
int left_mouse_click_in_cursor;
|
||||||
float scroll_delta;
|
float scroll_delta;
|
||||||
|
|
||||||
@ -21186,13 +21415,14 @@ nk_scrollbar_behavior(nk_flags *state, struct nk_input *in,
|
|||||||
if (!in) return scroll_offset;
|
if (!in) return scroll_offset;
|
||||||
|
|
||||||
left_mouse_down = in->mouse.buttons[NK_BUTTON_LEFT].down;
|
left_mouse_down = in->mouse.buttons[NK_BUTTON_LEFT].down;
|
||||||
|
left_mouse_clicked = in->mouse.buttons[NK_BUTTON_LEFT].clicked;
|
||||||
left_mouse_click_in_cursor = nk_input_has_mouse_click_down_in_rect(in,
|
left_mouse_click_in_cursor = nk_input_has_mouse_click_down_in_rect(in,
|
||||||
NK_BUTTON_LEFT, *cursor, nk_true);
|
NK_BUTTON_LEFT, *cursor, nk_true);
|
||||||
if (nk_input_is_mouse_hovering_rect(in, *scroll))
|
if (nk_input_is_mouse_hovering_rect(in, *scroll))
|
||||||
*state = NK_WIDGET_STATE_HOVERED;
|
*state = NK_WIDGET_STATE_HOVERED;
|
||||||
|
|
||||||
scroll_delta = (o == NK_VERTICAL) ? in->mouse.scroll_delta.y: in->mouse.scroll_delta.x;
|
scroll_delta = (o == NK_VERTICAL) ? in->mouse.scroll_delta.y: in->mouse.scroll_delta.x;
|
||||||
if (left_mouse_down && left_mouse_click_in_cursor) {
|
if (left_mouse_down && left_mouse_click_in_cursor && !left_mouse_clicked) {
|
||||||
/* update cursor by mouse dragging */
|
/* update cursor by mouse dragging */
|
||||||
float pixel, delta;
|
float pixel, delta;
|
||||||
*state = NK_WIDGET_STATE_ACTIVE;
|
*state = NK_WIDGET_STATE_ACTIVE;
|
||||||
@ -25243,95 +25473,105 @@ nk_tooltipfv(struct nk_context *ctx, const char *fmt, va_list args)
|
|||||||
/// - [yy]: Minor version with non-breaking API and library changes
|
/// - [yy]: Minor version with non-breaking API and library changes
|
||||||
/// - [zz]: Bug fix version with no direct changes to API
|
/// - [zz]: Bug fix version with no direct changes to API
|
||||||
///
|
///
|
||||||
/// - 2018/04/01 (4.00.1) - Fixed calling `nk_convert` multiple time per single frame
|
/// - 2019/09/20 (4.01.3) - Fixed a bug wherein combobox cannot be closed by clicking the header
|
||||||
|
/// when NK_BUTTON_TRIGGER_ON_RELEASE is defined.
|
||||||
|
/// - 2019/09/10 (4.01.2) - Fixed the nk_cos function, which deviated significantly.
|
||||||
|
/// - 2019/09/08 (4.01.1) - Fixed a bug wherein re-baking of fonts caused a segmentation
|
||||||
|
/// fault due to dst_font->glyph_count not being zeroed on subsequent
|
||||||
|
/// bakes of the same set of fonts.
|
||||||
|
/// - 2019/06/23 (4.01.0) - Added nk_***_get_scroll and nk_***_set_scroll for groups, windows, and popups.
|
||||||
|
/// - 2019/06/12 (4.00.3) - Fix panel background drawing bug.
|
||||||
|
/// - 2018/10/31 (4.00.2) - Added NK_KEYSTATE_BASED_INPUT to "fix" state based backends
|
||||||
|
/// like GLFW without breaking key repeat behavior on event based.
|
||||||
|
/// - 2018/04/01 (4.00.1) - Fixed calling `nk_convert` multiple time per single frame.
|
||||||
/// - 2018/04/01 (4.00.0) - BREAKING CHANGE: nk_draw_list_clear no longer tries to
|
/// - 2018/04/01 (4.00.0) - BREAKING CHANGE: nk_draw_list_clear no longer tries to
|
||||||
/// clear provided buffers. So make sure to either free
|
/// clear provided buffers. So make sure to either free
|
||||||
/// or clear each passed buffer after calling nk_convert.
|
/// or clear each passed buffer after calling nk_convert.
|
||||||
/// - 2018/02/23 (3.00.6) - Fixed slider dragging behavior
|
/// - 2018/02/23 (3.00.6) - Fixed slider dragging behavior.
|
||||||
/// - 2018/01/31 (3.00.5) - Fixed overcalculation of cursor data in font baking process
|
/// - 2018/01/31 (3.00.5) - Fixed overcalculation of cursor data in font baking process.
|
||||||
/// - 2018/01/31 (3.00.4) - Removed name collision with stb_truetype
|
/// - 2018/01/31 (3.00.4) - Removed name collision with stb_truetype.
|
||||||
/// - 2018/01/28 (3.00.3) - Fixed panel window border drawing bug
|
/// - 2018/01/28 (3.00.3) - Fixed panel window border drawing bug.
|
||||||
/// - 2018/01/12 (3.00.2) - Added `nk_group_begin_titled` for separed group identifier and title
|
/// - 2018/01/12 (3.00.2) - Added `nk_group_begin_titled` for separed group identifier and title.
|
||||||
/// - 2018/01/07 (3.00.1) - Started to change documentation style
|
/// - 2018/01/07 (3.00.1) - Started to change documentation style.
|
||||||
/// - 2018/01/05 (3.00.0) - BREAKING CHANGE: The previous color picker API was broken
|
/// - 2018/01/05 (3.00.0) - BREAKING CHANGE: The previous color picker API was broken
|
||||||
/// because of conversions between float and byte color representation.
|
/// because of conversions between float and byte color representation.
|
||||||
/// Color pickers now use floating point values to represent
|
/// Color pickers now use floating point values to represent
|
||||||
/// HSV values. To get back the old behavior I added some additional
|
/// HSV values. To get back the old behavior I added some additional
|
||||||
/// color conversion functions to cast between nk_color and
|
/// color conversion functions to cast between nk_color and
|
||||||
/// nk_colorf.
|
/// nk_colorf.
|
||||||
/// - 2017/12/23 (2.00.7) - Fixed small warning
|
/// - 2017/12/23 (2.00.7) - Fixed small warning.
|
||||||
/// - 2017/12/23 (2.00.7) - Fixed nk_edit_buffer behavior if activated to allow input
|
/// - 2017/12/23 (2.00.7) - Fixed `nk_edit_buffer` behavior if activated to allow input.
|
||||||
/// - 2017/12/23 (2.00.7) - Fixed modifyable progressbar dragging visuals and input behavior
|
/// - 2017/12/23 (2.00.7) - Fixed modifyable progressbar dragging visuals and input behavior.
|
||||||
/// - 2017/12/04 (2.00.6) - Added formated string tooltip widget
|
/// - 2017/12/04 (2.00.6) - Added formated string tooltip widget.
|
||||||
/// - 2017/11/18 (2.00.5) - Fixed window becoming hidden with flag NK_WINDOW_NO_INPUT
|
/// - 2017/11/18 (2.00.5) - Fixed window becoming hidden with flag `NK_WINDOW_NO_INPUT`.
|
||||||
/// - 2017/11/15 (2.00.4) - Fixed font merging
|
/// - 2017/11/15 (2.00.4) - Fixed font merging.
|
||||||
/// - 2017/11/07 (2.00.3) - Fixed window size and position modifier functions
|
/// - 2017/11/07 (2.00.3) - Fixed window size and position modifier functions.
|
||||||
/// - 2017/09/14 (2.00.2) - Fixed nk_edit_buffer and nk_edit_focus behavior
|
/// - 2017/09/14 (2.00.2) - Fixed `nk_edit_buffer` and `nk_edit_focus` behavior.
|
||||||
/// - 2017/09/14 (2.00.1) - Fixed window closing behavior
|
/// - 2017/09/14 (2.00.1) - Fixed window closing behavior.
|
||||||
/// - 2017/09/14 (2.00.0) - BREAKING CHANGE: Modifing window position and size funtions now
|
/// - 2017/09/14 (2.00.0) - BREAKING CHANGE: Modifing window position and size funtions now
|
||||||
/// require the name of the window and must happen outside the window
|
/// require the name of the window and must happen outside the window
|
||||||
/// building process (between function call nk_begin and nk_end).
|
/// building process (between function call nk_begin and nk_end).
|
||||||
/// - 2017/09/11 (1.40.9) - Fixed window background flag if background window is declared last
|
/// - 2017/09/11 (1.40.9) - Fixed window background flag if background window is declared last.
|
||||||
/// - 2017/08/27 (1.40.8) - Fixed `nk_item_is_any_active` for hidden windows
|
/// - 2017/08/27 (1.40.8) - Fixed `nk_item_is_any_active` for hidden windows.
|
||||||
/// - 2017/08/27 (1.40.7) - Fixed window background flag
|
/// - 2017/08/27 (1.40.7) - Fixed window background flag.
|
||||||
/// - 2017/07/07 (1.40.6) - Fixed missing clipping rect check for hovering/clicked
|
/// - 2017/07/07 (1.40.6) - Fixed missing clipping rect check for hovering/clicked
|
||||||
/// query for widgets
|
/// query for widgets.
|
||||||
/// - 2017/07/07 (1.40.5) - Fixed drawing bug for vertex output for lines and stroked
|
/// - 2017/07/07 (1.40.5) - Fixed drawing bug for vertex output for lines and stroked
|
||||||
/// and filled rectangles
|
/// and filled rectangles.
|
||||||
/// - 2017/07/07 (1.40.4) - Fixed bug in nk_convert trying to add windows that are in
|
/// - 2017/07/07 (1.40.4) - Fixed bug in nk_convert trying to add windows that are in
|
||||||
/// process of being destroyed.
|
/// process of being destroyed.
|
||||||
/// - 2017/07/07 (1.40.3) - Fixed table internal bug caused by storing table size in
|
/// - 2017/07/07 (1.40.3) - Fixed table internal bug caused by storing table size in
|
||||||
/// window instead of directly in table.
|
/// window instead of directly in table.
|
||||||
/// - 2017/06/30 (1.40.2) - Removed unneeded semicolon in C++ NK_ALIGNOF macro
|
/// - 2017/06/30 (1.40.2) - Removed unneeded semicolon in C++ NK_ALIGNOF macro.
|
||||||
/// - 2017/06/30 (1.40.1) - Fixed drawing lines smaller or equal zero
|
/// - 2017/06/30 (1.40.1) - Fixed drawing lines smaller or equal zero.
|
||||||
/// - 2017/06/08 (1.40.0) - Removed the breaking part of last commit. Auto layout now only
|
/// - 2017/06/08 (1.40.0) - Removed the breaking part of last commit. Auto layout now only
|
||||||
/// comes in effect if you pass in zero was row height argument
|
/// comes in effect if you pass in zero was row height argument.
|
||||||
/// - 2017/06/08 (1.40.0) - BREAKING CHANGE: while not directly API breaking it will change
|
/// - 2017/06/08 (1.40.0) - BREAKING CHANGE: while not directly API breaking it will change
|
||||||
/// how layouting works. From now there will be an internal minimum
|
/// how layouting works. From now there will be an internal minimum
|
||||||
/// row height derived from font height. If you need a row smaller than
|
/// row height derived from font height. If you need a row smaller than
|
||||||
/// that you can directly set it by `nk_layout_set_min_row_height` and
|
/// that you can directly set it by `nk_layout_set_min_row_height` and
|
||||||
/// reset the value back by calling `nk_layout_reset_min_row_height.
|
/// reset the value back by calling `nk_layout_reset_min_row_height.
|
||||||
/// - 2017/06/08 (1.39.1) - Fixed property text edit handling bug caused by past `nk_widget` fix
|
/// - 2017/06/08 (1.39.1) - Fixed property text edit handling bug caused by past `nk_widget` fix.
|
||||||
/// - 2017/06/08 (1.39.0) - Added function to retrieve window space without calling a nk_layout_xxx function
|
/// - 2017/06/08 (1.39.0) - Added function to retrieve window space without calling a `nk_layout_xxx` function.
|
||||||
/// - 2017/06/06 (1.38.5) - Fixed `nk_convert` return flag for command buffer
|
/// - 2017/06/06 (1.38.5) - Fixed `nk_convert` return flag for command buffer.
|
||||||
/// - 2017/05/23 (1.38.4) - Fixed activation behavior for widgets partially clipped
|
/// - 2017/05/23 (1.38.4) - Fixed activation behavior for widgets partially clipped.
|
||||||
/// - 2017/05/10 (1.38.3) - Fixed wrong min window size mouse scaling over boundries
|
/// - 2017/05/10 (1.38.3) - Fixed wrong min window size mouse scaling over boundries.
|
||||||
/// - 2017/05/09 (1.38.2) - Fixed vertical scrollbar drawing with not enough space
|
/// - 2017/05/09 (1.38.2) - Fixed vertical scrollbar drawing with not enough space.
|
||||||
/// - 2017/05/09 (1.38.1) - Fixed scaler dragging behavior if window size hits minimum size
|
/// - 2017/05/09 (1.38.1) - Fixed scaler dragging behavior if window size hits minimum size.
|
||||||
/// - 2017/05/06 (1.38.0) - Added platform double-click support
|
/// - 2017/05/06 (1.38.0) - Added platform double-click support.
|
||||||
/// - 2017/04/20 (1.37.1) - Fixed key repeat found inside glfw demo backends
|
/// - 2017/04/20 (1.37.1) - Fixed key repeat found inside glfw demo backends.
|
||||||
/// - 2017/04/20 (1.37.0) - Extended properties with selection and clipbard support
|
/// - 2017/04/20 (1.37.0) - Extended properties with selection and clipboard support.
|
||||||
/// - 2017/04/20 (1.36.2) - Fixed #405 overlapping rows with zero padding and spacing
|
/// - 2017/04/20 (1.36.2) - Fixed #405 overlapping rows with zero padding and spacing.
|
||||||
/// - 2017/04/09 (1.36.1) - Fixed #403 with another widget float error
|
/// - 2017/04/09 (1.36.1) - Fixed #403 with another widget float error.
|
||||||
/// - 2017/04/09 (1.36.0) - Added window `NK_WINDOW_NO_INPUT` and `NK_WINDOW_NOT_INTERACTIVE` flags
|
/// - 2017/04/09 (1.36.0) - Added window `NK_WINDOW_NO_INPUT` and `NK_WINDOW_NOT_INTERACTIVE` flags.
|
||||||
/// - 2017/04/09 (1.35.3) - Fixed buffer heap corruption
|
/// - 2017/04/09 (1.35.3) - Fixed buffer heap corruption.
|
||||||
/// - 2017/03/25 (1.35.2) - Fixed popup overlapping for `NK_WINDOW_BACKGROUND` windows
|
/// - 2017/03/25 (1.35.2) - Fixed popup overlapping for `NK_WINDOW_BACKGROUND` windows.
|
||||||
/// - 2017/03/25 (1.35.1) - Fixed windows closing behavior
|
/// - 2017/03/25 (1.35.1) - Fixed windows closing behavior.
|
||||||
/// - 2017/03/18 (1.35.0) - Added horizontal scroll requested in #377
|
/// - 2017/03/18 (1.35.0) - Added horizontal scroll requested in #377.
|
||||||
/// - 2017/03/18 (1.34.3) - Fixed long window header titles
|
/// - 2017/03/18 (1.34.3) - Fixed long window header titles.
|
||||||
/// - 2017/03/04 (1.34.2) - Fixed text edit filtering
|
/// - 2017/03/04 (1.34.2) - Fixed text edit filtering.
|
||||||
/// - 2017/03/04 (1.34.1) - Fixed group closable flag
|
/// - 2017/03/04 (1.34.1) - Fixed group closable flag.
|
||||||
/// - 2017/02/25 (1.34.0) - Added custom draw command for better language binding support
|
/// - 2017/02/25 (1.34.0) - Added custom draw command for better language binding support.
|
||||||
/// - 2017/01/24 (1.33.0) - Added programatic way of remove edit focus
|
/// - 2017/01/24 (1.33.0) - Added programatic way of remove edit focus.
|
||||||
/// - 2017/01/24 (1.32.3) - Fixed wrong define for basic type definitions for windows
|
/// - 2017/01/24 (1.32.3) - Fixed wrong define for basic type definitions for windows.
|
||||||
/// - 2017/01/21 (1.32.2) - Fixed input capture from hidden or closed windows
|
/// - 2017/01/21 (1.32.2) - Fixed input capture from hidden or closed windows.
|
||||||
/// - 2017/01/21 (1.32.1) - Fixed slider behavior and drawing
|
/// - 2017/01/21 (1.32.1) - Fixed slider behavior and drawing.
|
||||||
/// - 2017/01/13 (1.32.0) - Added flag to put scaler into the bottom left corner
|
/// - 2017/01/13 (1.32.0) - Added flag to put scaler into the bottom left corner.
|
||||||
/// - 2017/01/13 (1.31.0) - Added additional row layouting method to combine both
|
/// - 2017/01/13 (1.31.0) - Added additional row layouting method to combine both
|
||||||
/// dynamic and static widgets.
|
/// dynamic and static widgets.
|
||||||
/// - 2016/12/31 (1.30.0) - Extended scrollbar offset from 16-bit to 32-bit
|
/// - 2016/12/31 (1.30.0) - Extended scrollbar offset from 16-bit to 32-bit.
|
||||||
/// - 2016/12/31 (1.29.2)- Fixed closing window bug of minimized windows
|
/// - 2016/12/31 (1.29.2) - Fixed closing window bug of minimized windows.
|
||||||
/// - 2016/12/03 (1.29.1)- Fixed wrapped text with no seperator and C89 error
|
/// - 2016/12/03 (1.29.1) - Fixed wrapped text with no seperator and C89 error.
|
||||||
/// - 2016/12/03 (1.29.0) - Changed text wrapping to process words not characters
|
/// - 2016/12/03 (1.29.0) - Changed text wrapping to process words not characters.
|
||||||
/// - 2016/11/22 (1.28.6)- Fixed window minimized closing bug
|
/// - 2016/11/22 (1.28.6) - Fixed window minimized closing bug.
|
||||||
/// - 2016/11/19 (1.28.5)- Fixed abstract combo box closing behavior
|
/// - 2016/11/19 (1.28.5) - Fixed abstract combo box closing behavior.
|
||||||
/// - 2016/11/19 (1.28.4)- Fixed tooltip flickering
|
/// - 2016/11/19 (1.28.4) - Fixed tooltip flickering.
|
||||||
/// - 2016/11/19 (1.28.3)- Fixed memory leak caused by popup repeated closing
|
/// - 2016/11/19 (1.28.3) - Fixed memory leak caused by popup repeated closing.
|
||||||
/// - 2016/11/18 (1.28.2)- Fixed memory leak caused by popup panel allocation
|
/// - 2016/11/18 (1.28.2) - Fixed memory leak caused by popup panel allocation.
|
||||||
/// - 2016/11/10 (1.28.1)- Fixed some warnings and C++ error
|
/// - 2016/11/10 (1.28.1) - Fixed some warnings and C++ error.
|
||||||
/// - 2016/11/10 (1.28.0) - Added additional `nk_button` versions which allows to directly
|
/// - 2016/11/10 (1.28.0) - Added additional `nk_button` versions which allows to directly
|
||||||
/// pass in a style struct to change buttons visual.
|
/// pass in a style struct to change buttons visual.
|
||||||
/// - 2016/11/10 (1.27.0)- Added additional 'nk_tree' versions to support external state
|
/// - 2016/11/10 (1.27.0) - Added additional `nk_tree` versions to support external state
|
||||||
/// storage. Just like last the `nk_group` commit the main
|
/// storage. Just like last the `nk_group` commit the main
|
||||||
/// advantage is that you optionally can minimize nuklears runtime
|
/// advantage is that you optionally can minimize nuklears runtime
|
||||||
/// memory consumption or handle hash collisions.
|
/// memory consumption or handle hash collisions.
|
||||||
@ -25342,25 +25582,25 @@ nk_tooltipfv(struct nk_context *ctx, const char *fmt, va_list args)
|
|||||||
/// want the name. In addition I added `nk_list_view` which allows
|
/// want the name. In addition I added `nk_list_view` which allows
|
||||||
/// to draw big lists inside a group without actually having to
|
/// to draw big lists inside a group without actually having to
|
||||||
/// commit the whole list to nuklear (issue #269).
|
/// commit the whole list to nuklear (issue #269).
|
||||||
/// - 2016/10/30 (1.25.1)- Fixed clipping rectangle bug inside `nk_draw_list`
|
/// - 2016/10/30 (1.25.1) - Fixed clipping rectangle bug inside `nk_draw_list`.
|
||||||
/// - 2016/10/29 (1.25.0) - Pulled `nk_panel` memory management into nuklear and out of
|
/// - 2016/10/29 (1.25.0) - Pulled `nk_panel` memory management into nuklear and out of
|
||||||
/// the hands of the user. From now on users don't have to care
|
/// the hands of the user. From now on users don't have to care
|
||||||
/// about panels unless they care about some information. If you
|
/// about panels unless they care about some information. If you
|
||||||
/// still need the panel just call `nk_window_get_panel`.
|
/// still need the panel just call `nk_window_get_panel`.
|
||||||
/// - 2016/10/21 (1.24.0) - Changed widget border drawing to stroked rectangle from filled
|
/// - 2016/10/21 (1.24.0) - Changed widget border drawing to stroked rectangle from filled
|
||||||
/// rectangle for less overdraw and widget background transparency.
|
/// rectangle for less overdraw and widget background transparency.
|
||||||
/// - 2016/10/18 (1.23.0)- Added `nk_edit_focus` for manually edit widget focus control
|
/// - 2016/10/18 (1.23.0) - Added `nk_edit_focus` for manually edit widget focus control.
|
||||||
/// - 2016/09/29 (1.22.7)- Fixed deduction of basic type in non `<stdint.h>` compilation
|
/// - 2016/09/29 (1.22.7) - Fixed deduction of basic type in non `<stdint.h>` compilation.
|
||||||
/// - 2016/09/29 (1.22.6)- Fixed edit widget UTF-8 text cursor drawing bug
|
/// - 2016/09/29 (1.22.6) - Fixed edit widget UTF-8 text cursor drawing bug.
|
||||||
/// - 2016/09/28 (1.22.5)- Fixed edit widget UTF-8 text appending/inserting/removing
|
/// - 2016/09/28 (1.22.5) - Fixed edit widget UTF-8 text appending/inserting/removing.
|
||||||
/// - 2016/09/28 (1.22.4) - Fixed drawing bug inside edit widgets which offset all text
|
/// - 2016/09/28 (1.22.4) - Fixed drawing bug inside edit widgets which offset all text
|
||||||
/// text in every edit widget if one of them is scrolled.
|
/// text in every edit widget if one of them is scrolled.
|
||||||
/// - 2016/09/28 (1.22.3) - Fixed small bug in edit widgets if not active. The wrong
|
/// - 2016/09/28 (1.22.3) - Fixed small bug in edit widgets if not active. The wrong
|
||||||
/// text length is passed. It should have been in bytes but
|
/// text length is passed. It should have been in bytes but
|
||||||
/// was passed as glyphes.
|
/// was passed as glyphes.
|
||||||
/// - 2016/09/20 (1.22.2)- Fixed color button size calculation
|
/// - 2016/09/20 (1.22.2) - Fixed color button size calculation.
|
||||||
/// - 2016/09/20 (1.22.1)- Fixed some `nk_vsnprintf` behavior bugs and removed
|
/// - 2016/09/20 (1.22.1) - Fixed some `nk_vsnprintf` behavior bugs and removed `<stdio.h>`
|
||||||
/// `<stdio.h>` again from `NK_INCLUDE_STANDARD_VARARGS`.
|
/// again from `NK_INCLUDE_STANDARD_VARARGS`.
|
||||||
/// - 2016/09/18 (1.22.0) - C89 does not support vsnprintf only C99 and newer as well
|
/// - 2016/09/18 (1.22.0) - C89 does not support vsnprintf only C99 and newer as well
|
||||||
/// as C++11 and newer. In addition to use vsnprintf you have
|
/// as C++11 and newer. In addition to use vsnprintf you have
|
||||||
/// to include <stdio.h>. So just defining `NK_INCLUDE_STD_VAR_ARGS`
|
/// to include <stdio.h>. So just defining `NK_INCLUDE_STD_VAR_ARGS`
|
||||||
@ -25368,14 +25608,14 @@ nk_tooltipfv(struct nk_context *ctx, const char *fmt, va_list args)
|
|||||||
/// both varargs as well as stdio is selected I try to use
|
/// both varargs as well as stdio is selected I try to use
|
||||||
/// vsnprintf if not possible I will revert to vsprintf. If
|
/// vsnprintf if not possible I will revert to vsprintf. If
|
||||||
/// varargs but not stdio was defined I will use my own function.
|
/// varargs but not stdio was defined I will use my own function.
|
||||||
/// - 2016/09/15 (1.21.2)- Fixed panel `close` behavior for deeper panel levels
|
/// - 2016/09/15 (1.21.2) - Fixed panel `close` behavior for deeper panel levels.
|
||||||
/// - 2016/09/15 (1.21.1)- Fixed C++ errors and wrong argument to `nk_panel_get_xxxx`
|
/// - 2016/09/15 (1.21.1) - Fixed C++ errors and wrong argument to `nk_panel_get_xxxx`.
|
||||||
/// - 2016/09/13 (1.21.0) - !BREAKING! Fixed nonblocking popup behavior in menu, combo,
|
/// - 2016/09/13 (1.21.0) - !BREAKING! Fixed nonblocking popup behavior in menu, combo,
|
||||||
/// and contextual which prevented closing in y-direction if
|
/// and contextual which prevented closing in y-direction if
|
||||||
/// popup did not reach max height.
|
/// popup did not reach max height.
|
||||||
/// In addition the height parameter was changed into vec2
|
/// In addition the height parameter was changed into vec2
|
||||||
/// for width and height to have more control over the popup size.
|
/// for width and height to have more control over the popup size.
|
||||||
/// - 2016/09/13 (1.20.3) - Cleaned up and extended type selection
|
/// - 2016/09/13 (1.20.3) - Cleaned up and extended type selection.
|
||||||
/// - 2016/09/13 (1.20.2) - Fixed slider behavior hopefully for the last time. This time
|
/// - 2016/09/13 (1.20.2) - Fixed slider behavior hopefully for the last time. This time
|
||||||
/// all calculation are correct so no more hackery.
|
/// all calculation are correct so no more hackery.
|
||||||
/// - 2016/09/13 (1.20.1) - Internal change to divide window/panel flags into panel flags and types.
|
/// - 2016/09/13 (1.20.1) - Internal change to divide window/panel flags into panel flags and types.
|
||||||
@ -25398,17 +25638,17 @@ nk_tooltipfv(struct nk_context *ctx, const char *fmt, va_list args)
|
|||||||
/// `NK_SYMBOL_CIRCLE_OUTLINE`.
|
/// `NK_SYMBOL_CIRCLE_OUTLINE`.
|
||||||
/// - 2016/09/08 (1.16.0) - Added additional checks to select correct types if `NK_INCLUDE_FIXED_TYPES`
|
/// - 2016/09/08 (1.16.0) - Added additional checks to select correct types if `NK_INCLUDE_FIXED_TYPES`
|
||||||
/// is not defined by supporting the biggest compiler GCC, clang and MSVC.
|
/// is not defined by supporting the biggest compiler GCC, clang and MSVC.
|
||||||
/// - 2016/09/07 (1.15.3)- Fixed `NK_INCLUDE_COMMAND_USERDATA` define to not cause an error
|
/// - 2016/09/07 (1.15.3) - Fixed `NK_INCLUDE_COMMAND_USERDATA` define to not cause an error.
|
||||||
/// - 2016/09/04 (1.15.2)- Fixed wrong combobox height calculation
|
/// - 2016/09/04 (1.15.2) - Fixed wrong combobox height calculation.
|
||||||
/// - 2016/09/03 (1.15.1)- Fixed gaps inside combo boxes in OpenGL
|
/// - 2016/09/03 (1.15.1) - Fixed gaps inside combo boxes in OpenGL.
|
||||||
/// - 2016/09/02 (1.15.0) - Changed nuklear to not have any default vertex layout and
|
/// - 2016/09/02 (1.15.0) - Changed nuklear to not have any default vertex layout and
|
||||||
/// instead made it user provided. The range of types to convert
|
/// instead made it user provided. The range of types to convert
|
||||||
/// to is quite limited at the moment, but I would be more than
|
/// to is quite limited at the moment, but I would be more than
|
||||||
/// happy to accept PRs to add additional.
|
/// happy to accept PRs to add additional.
|
||||||
/// - 2016/08/30 (1.14.2) - Removed unused variables
|
/// - 2016/08/30 (1.14.2) - Removed unused variables.
|
||||||
/// - 2016/08/30 (1.14.1) - Fixed C++ build errors
|
/// - 2016/08/30 (1.14.1) - Fixed C++ build errors.
|
||||||
/// - 2016/08/30 (1.14.0) - Removed mouse dragging from SDL demo since it does not work correctly
|
/// - 2016/08/30 (1.14.0) - Removed mouse dragging from SDL demo since it does not work correctly.
|
||||||
/// - 2016/08/30 (1.13.4) - Tweaked some default styling variables
|
/// - 2016/08/30 (1.13.4) - Tweaked some default styling variables.
|
||||||
/// - 2016/08/30 (1.13.3) - Hopefully fixed drawing bug in slider, in general I would
|
/// - 2016/08/30 (1.13.3) - Hopefully fixed drawing bug in slider, in general I would
|
||||||
/// refrain from using slider with a big number of steps.
|
/// refrain from using slider with a big number of steps.
|
||||||
/// - 2016/08/30 (1.13.2) - Fixed close and minimize button which would fire even if the
|
/// - 2016/08/30 (1.13.2) - Fixed close and minimize button which would fire even if the
|
||||||
@ -25418,28 +25658,28 @@ nk_tooltipfv(struct nk_context *ctx, const char *fmt, va_list args)
|
|||||||
/// - 2016/08/30 (1.13.0) - Removed `NK_WINDOW_DYNAMIC` flag from public API since
|
/// - 2016/08/30 (1.13.0) - Removed `NK_WINDOW_DYNAMIC` flag from public API since
|
||||||
/// it is bugged and causes issues in window selection.
|
/// it is bugged and causes issues in window selection.
|
||||||
/// - 2016/08/30 (1.12.0) - Removed scaler size. The size of the scaler is now
|
/// - 2016/08/30 (1.12.0) - Removed scaler size. The size of the scaler is now
|
||||||
/// determined by the scrollbar size
|
/// determined by the scrollbar size.
|
||||||
/// - 2016/08/30 (1.11.2) - Fixed some drawing bugs caused by changes from 1.11
|
/// - 2016/08/30 (1.11.2) - Fixed some drawing bugs caused by changes from 1.11.0.
|
||||||
/// - 2016/08/30 (1.11.1) - Fixed overlapping minimized window selection
|
/// - 2016/08/30 (1.11.1) - Fixed overlapping minimized window selection.
|
||||||
/// - 2016/08/30 (1.11.0) - Removed some internal complexity and overly complex code
|
/// - 2016/08/30 (1.11.0) - Removed some internal complexity and overly complex code
|
||||||
/// handling panel padding and panel border.
|
/// handling panel padding and panel border.
|
||||||
/// - 2016/08/29 (1.10.0) - Added additional height parameter to `nk_combobox_xxx`
|
/// - 2016/08/29 (1.10.0) - Added additional height parameter to `nk_combobox_xxx`.
|
||||||
/// - 2016/08/29 (1.10.0) - Fixed drawing bug in dynamic popups
|
/// - 2016/08/29 (1.10.0) - Fixed drawing bug in dynamic popups.
|
||||||
/// - 2016/08/29 (1.10.0) - Added experimental mouse scrolling to popups, menus and comboboxes
|
/// - 2016/08/29 (1.10.0) - Added experimental mouse scrolling to popups, menus and comboboxes.
|
||||||
/// - 2016/08/26 (1.10.0) - Added window name string prepresentation to account for
|
/// - 2016/08/26 (1.10.0) - Added window name string prepresentation to account for
|
||||||
/// hash collisions. Currently limited to NK_WINDOW_MAX_NAME
|
/// hash collisions. Currently limited to `NK_WINDOW_MAX_NAME`
|
||||||
/// which in term can be redefined if not big enough.
|
/// which in term can be redefined if not big enough.
|
||||||
/// - 2016/08/26 (1.10.0) - Added stacks for temporary style/UI changes in code
|
/// - 2016/08/26 (1.10.0) - Added stacks for temporary style/UI changes in code.
|
||||||
/// - 2016/08/25 (1.10.0) - Changed `nk_input_is_key_pressed` and 'nk_input_is_key_released'
|
/// - 2016/08/25 (1.10.0) - Changed `nk_input_is_key_pressed` and 'nk_input_is_key_released'
|
||||||
/// to account for key press and release happening in one frame.
|
/// to account for key press and release happening in one frame.
|
||||||
/// - 2016/08/25 (1.10.0) - Added additional nk_edit flag to directly jump to the end on activate
|
/// - 2016/08/25 (1.10.0) - Added additional nk_edit flag to directly jump to the end on activate.
|
||||||
/// - 2016/08/17 (1.09.6)- Removed invalid check for value zero in nk_propertyx
|
/// - 2016/08/17 (1.09.6) - Removed invalid check for value zero in `nk_propertyx`.
|
||||||
/// - 2016/08/16 (1.09.5) - Fixed ROM mode for deeper levels of popup windows parents.
|
/// - 2016/08/16 (1.09.5) - Fixed ROM mode for deeper levels of popup windows parents.
|
||||||
/// - 2016/08/15 (1.09.4) - Editbox are now still active if enter was pressed with flag
|
/// - 2016/08/15 (1.09.4) - Editbox are now still active if enter was pressed with flag
|
||||||
/// `NK_EDIT_SIG_ENTER`. Main reasoning is to be able to keep
|
/// `NK_EDIT_SIG_ENTER`. Main reasoning is to be able to keep
|
||||||
/// typing after commiting.
|
/// typing after commiting.
|
||||||
/// - 2016/08/15 (1.09.4)- Removed redundant code
|
/// - 2016/08/15 (1.09.4) - Removed redundant code.
|
||||||
/// - 2016/08/15 (1.09.4)- Fixed negative numbers in `nk_strtoi` and remove unused variable
|
/// - 2016/08/15 (1.09.4) - Fixed negative numbers in `nk_strtoi` and remove unused variable.
|
||||||
/// - 2016/08/15 (1.09.3) - Fixed `NK_WINDOW_BACKGROUND` flag behavior to select a background
|
/// - 2016/08/15 (1.09.3) - Fixed `NK_WINDOW_BACKGROUND` flag behavior to select a background
|
||||||
/// window only as selected by hovering and not by clicking.
|
/// window only as selected by hovering and not by clicking.
|
||||||
/// - 2016/08/14 (1.09.2) - Fixed a bug in font atlas which caused wrong loading
|
/// - 2016/08/14 (1.09.2) - Fixed a bug in font atlas which caused wrong loading
|
||||||
@ -25447,7 +25687,7 @@ nk_tooltipfv(struct nk_context *ctx, const char *fmt, va_list args)
|
|||||||
/// - 2016/08/12 (1.09.1) - Added additional function to check if window is currently
|
/// - 2016/08/12 (1.09.1) - Added additional function to check if window is currently
|
||||||
/// hidden and therefore not visible.
|
/// hidden and therefore not visible.
|
||||||
/// - 2016/08/12 (1.09.1) - nk_window_is_closed now queries the correct flag `NK_WINDOW_CLOSED`
|
/// - 2016/08/12 (1.09.1) - nk_window_is_closed now queries the correct flag `NK_WINDOW_CLOSED`
|
||||||
/// instead of the old flag `NK_WINDOW_HIDDEN`
|
/// instead of the old flag `NK_WINDOW_HIDDEN`.
|
||||||
/// - 2016/08/09 (1.09.0) - Added additional double version to nk_property and changed
|
/// - 2016/08/09 (1.09.0) - Added additional double version to nk_property and changed
|
||||||
/// the underlying implementation to not cast to float and instead
|
/// the underlying implementation to not cast to float and instead
|
||||||
/// work directly on the given values.
|
/// work directly on the given values.
|
||||||
@ -25457,7 +25697,7 @@ nk_tooltipfv(struct nk_context *ctx, const char *fmt, va_list args)
|
|||||||
/// - 2016/08/09 (1.08.0) - Added additional define to overwrite library internal
|
/// - 2016/08/09 (1.08.0) - Added additional define to overwrite library internal
|
||||||
/// string to floating point number conversion for additional
|
/// string to floating point number conversion for additional
|
||||||
/// precision.
|
/// precision.
|
||||||
/// - 2016/08/08 (1.07.2)- Fixed compiling error without define NK_INCLUDE_FIXED_TYPE
|
/// - 2016/08/08 (1.07.2) - Fixed compiling error without define `NK_INCLUDE_FIXED_TYPE`.
|
||||||
/// - 2016/08/08 (1.07.1) - Fixed possible floating point error inside `nk_widget` leading
|
/// - 2016/08/08 (1.07.1) - Fixed possible floating point error inside `nk_widget` leading
|
||||||
/// to wrong wiget width calculation which results in widgets falsly
|
/// to wrong wiget width calculation which results in widgets falsly
|
||||||
/// becomming tagged as not inside window and cannot be accessed.
|
/// becomming tagged as not inside window and cannot be accessed.
|
||||||
@ -25469,31 +25709,31 @@ nk_tooltipfv(struct nk_context *ctx, const char *fmt, va_list args)
|
|||||||
/// remain.
|
/// remain.
|
||||||
/// - 2016/08/08 (1.06.0) - Added `nk_edit_string_zero_terminated` as a second option to
|
/// - 2016/08/08 (1.06.0) - Added `nk_edit_string_zero_terminated` as a second option to
|
||||||
/// `nk_edit_string` which takes, edits and outputs a '\0' terminated string.
|
/// `nk_edit_string` which takes, edits and outputs a '\0' terminated string.
|
||||||
/// - 2016/08/08 (1.05.4)- Fixed scrollbar auto hiding behavior
|
/// - 2016/08/08 (1.05.4) - Fixed scrollbar auto hiding behavior.
|
||||||
/// - 2016/08/08 (1.05.3)- Fixed wrong panel padding selection in `nk_layout_widget_space`
|
/// - 2016/08/08 (1.05.3) - Fixed wrong panel padding selection in `nk_layout_widget_space`.
|
||||||
/// - 2016/08/07 (1.05.2) - Fixed old bug in dynamic immediate mode layout API, calculating
|
/// - 2016/08/07 (1.05.2) - Fixed old bug in dynamic immediate mode layout API, calculating
|
||||||
/// wrong item spacing and panel width.
|
/// wrong item spacing and panel width.
|
||||||
///- 2016/08/07 (1.05.1)- Hopefully finally fixed combobox popup drawing bug
|
/// - 2016/08/07 (1.05.1) - Hopefully finally fixed combobox popup drawing bug.
|
||||||
///- 2016/08/07 (1.05.0) - Split varargs away from NK_INCLUDE_STANDARD_IO into own
|
/// - 2016/08/07 (1.05.0) - Split varargs away from `NK_INCLUDE_STANDARD_IO` into own
|
||||||
/// define NK_INCLUDE_STANDARD_VARARGS to allow more fine
|
/// define `NK_INCLUDE_STANDARD_VARARGS` to allow more fine
|
||||||
/// grained controlled over library includes.
|
/// grained controlled over library includes.
|
||||||
/// - 2016/08/06 (1.04.5)- Changed memset calls to NK_MEMSET
|
/// - 2016/08/06 (1.04.5) - Changed memset calls to `NK_MEMSET`.
|
||||||
/// - 2016/08/04 (1.04.4)- Fixed fast window scaling behavior
|
/// - 2016/08/04 (1.04.4) - Fixed fast window scaling behavior.
|
||||||
/// - 2016/08/04 (1.04.3) - Fixed window scaling, movement bug which appears if you
|
/// - 2016/08/04 (1.04.3) - Fixed window scaling, movement bug which appears if you
|
||||||
/// move/scale a window and another window is behind it.
|
/// move/scale a window and another window is behind it.
|
||||||
/// If you are fast enough then the window behind gets activated
|
/// If you are fast enough then the window behind gets activated
|
||||||
/// and the operation is blocked. I now require activating
|
/// and the operation is blocked. I now require activating
|
||||||
/// by hovering only if mouse is not pressed.
|
/// by hovering only if mouse is not pressed.
|
||||||
/// - 2016/08/04 (1.04.2)- Fixed changing fonts
|
/// - 2016/08/04 (1.04.2) - Fixed changing fonts.
|
||||||
/// - 2016/08/03 (1.04.1)- Fixed `NK_WINDOW_BACKGROUND` behavior
|
/// - 2016/08/03 (1.04.1) - Fixed `NK_WINDOW_BACKGROUND` behavior.
|
||||||
/// - 2016/08/03 (1.04.0) - Added color parameter to `nk_draw_image`
|
/// - 2016/08/03 (1.04.0) - Added color parameter to `nk_draw_image`.
|
||||||
/// - 2016/08/03 (1.04.0) - Added additional window padding style attributes for
|
/// - 2016/08/03 (1.04.0) - Added additional window padding style attributes for
|
||||||
/// sub windows (combo, menu, ...)
|
/// sub windows (combo, menu, ...).
|
||||||
/// - 2016/08/03 (1.04.0) - Added functions to show/hide software cursor
|
/// - 2016/08/03 (1.04.0) - Added functions to show/hide software cursor.
|
||||||
/// - 2016/08/03 (1.04.0) - Added `NK_WINDOW_BACKGROUND` flag to force a window
|
/// - 2016/08/03 (1.04.0) - Added `NK_WINDOW_BACKGROUND` flag to force a window
|
||||||
/// to be always in the background of the screen
|
/// to be always in the background of the screen.
|
||||||
/// - 2016/08/03 (1.03.2)- Removed invalid assert macro for NK_RGB color picker
|
/// - 2016/08/03 (1.03.2) - Removed invalid assert macro for NK_RGB color picker.
|
||||||
/// - 2016/08/01 (1.03.1)- Added helper macros into header include guard
|
/// - 2016/08/01 (1.03.1) - Added helper macros into header include guard.
|
||||||
/// - 2016/07/29 (1.03.0) - Moved the window/table pool into the header part to
|
/// - 2016/07/29 (1.03.0) - Moved the window/table pool into the header part to
|
||||||
/// simplify memory management by removing the need to
|
/// simplify memory management by removing the need to
|
||||||
/// allocate the pool.
|
/// allocate the pool.
|
||||||
@ -25501,16 +25741,15 @@ nk_tooltipfv(struct nk_context *ctx, const char *fmt, va_list args)
|
|||||||
/// will hide the window scrollbar after NK_SCROLLBAR_HIDING_TIMEOUT
|
/// will hide the window scrollbar after NK_SCROLLBAR_HIDING_TIMEOUT
|
||||||
/// seconds without window interaction. To make it work
|
/// seconds without window interaction. To make it work
|
||||||
/// you have to also set a delta time inside the `nk_context`.
|
/// you have to also set a delta time inside the `nk_context`.
|
||||||
/// - 2016/07/25 (1.01.1) - Fixed small panel and panel border drawing bugs
|
/// - 2016/07/25 (1.01.1) - Fixed small panel and panel border drawing bugs.
|
||||||
/// - 2016/07/15 (1.01.0) - Added software cursor to `nk_style` and `nk_context`
|
/// - 2016/07/15 (1.01.0) - Added software cursor to `nk_style` and `nk_context`.
|
||||||
/// - 2016/07/15 (1.01.0) - Added const correctness to `nk_buffer_push' data argument
|
/// - 2016/07/15 (1.01.0) - Added const correctness to `nk_buffer_push' data argument.
|
||||||
/// - 2016/07/15 (1.01.0) - Removed internal font baking API and simplified
|
/// - 2016/07/15 (1.01.0) - Removed internal font baking API and simplified
|
||||||
/// font atlas memory management by converting pointer
|
/// font atlas memory management by converting pointer
|
||||||
/// arrays for fonts and font configurations to lists.
|
/// arrays for fonts and font configurations to lists.
|
||||||
/// - 2016/07/15 (1.00.0) - Changed button API to use context dependend button
|
/// - 2016/07/15 (1.00.0) - Changed button API to use context dependend button
|
||||||
/// behavior instead of passing it for every function call.
|
/// behavior instead of passing it for every function call.
|
||||||
/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
/// ## Gallery
|
/// ## Gallery
|
||||||
/// ![Figure [blue]: Feature overview with blue color styling](https://cloud.githubusercontent.com/assets/8057201/13538240/acd96876-e249-11e5-9547-5ac0b19667a0.png)
|
/// ![Figure [blue]: Feature overview with blue color styling](https://cloud.githubusercontent.com/assets/8057201/13538240/acd96876-e249-11e5-9547-5ac0b19667a0.png)
|
||||||
/// ![Figure [red]: Feature overview with red color styling](https://cloud.githubusercontent.com/assets/8057201/13538243/b04acd4c-e249-11e5-8fd2-ad7744a5b446.png)
|
/// ![Figure [red]: Feature overview with red color styling](https://cloud.githubusercontent.com/assets/8057201/13538243/b04acd4c-e249-11e5-8fd2-ad7744a5b446.png)
|
||||||
|
8
deps/nuklear_glfw_gl2.h
vendored
8
deps/nuklear_glfw_gl2.h
vendored
@ -230,7 +230,7 @@ nk_glfw3_mouse_button_callback(GLFWwindow* window, int button, int action, int m
|
|||||||
}
|
}
|
||||||
|
|
||||||
NK_INTERN void
|
NK_INTERN void
|
||||||
nk_glfw3_clipbard_paste(nk_handle usr, struct nk_text_edit *edit)
|
nk_glfw3_clipboard_paste(nk_handle usr, struct nk_text_edit *edit)
|
||||||
{
|
{
|
||||||
const char *text = glfwGetClipboardString(glfw.win);
|
const char *text = glfwGetClipboardString(glfw.win);
|
||||||
if (text) nk_textedit_paste(edit, text, nk_strlen(text));
|
if (text) nk_textedit_paste(edit, text, nk_strlen(text));
|
||||||
@ -238,7 +238,7 @@ nk_glfw3_clipbard_paste(nk_handle usr, struct nk_text_edit *edit)
|
|||||||
}
|
}
|
||||||
|
|
||||||
NK_INTERN void
|
NK_INTERN void
|
||||||
nk_glfw3_clipbard_copy(nk_handle usr, const char *text, int len)
|
nk_glfw3_clipboard_copy(nk_handle usr, const char *text, int len)
|
||||||
{
|
{
|
||||||
char *str = 0;
|
char *str = 0;
|
||||||
(void)usr;
|
(void)usr;
|
||||||
@ -261,8 +261,8 @@ nk_glfw3_init(GLFWwindow *win, enum nk_glfw_init_state init_state)
|
|||||||
glfwSetMouseButtonCallback(win, nk_glfw3_mouse_button_callback);
|
glfwSetMouseButtonCallback(win, nk_glfw3_mouse_button_callback);
|
||||||
}
|
}
|
||||||
nk_init_default(&glfw.ctx, 0);
|
nk_init_default(&glfw.ctx, 0);
|
||||||
glfw.ctx.clip.copy = nk_glfw3_clipbard_copy;
|
glfw.ctx.clip.copy = nk_glfw3_clipboard_copy;
|
||||||
glfw.ctx.clip.paste = nk_glfw3_clipbard_paste;
|
glfw.ctx.clip.paste = nk_glfw3_clipboard_paste;
|
||||||
glfw.ctx.clip.userdata = nk_handle_ptr(0);
|
glfw.ctx.clip.userdata = nk_handle_ptr(0);
|
||||||
nk_buffer_init_default(&glfw.ogl.cmds);
|
nk_buffer_init_default(&glfw.ogl.cmds);
|
||||||
|
|
||||||
|
@ -1,34 +1,46 @@
|
|||||||
|
|
||||||
# NOTE: The order of this list determines the order of items in the Guides
|
# NOTE: The order of this list determines the order of items in the Guides
|
||||||
# (i.e. Pages) list in the generated documentation
|
# (i.e. Pages) list in the generated documentation
|
||||||
set(GLFW_DOXYGEN_SOURCES
|
set(source_files
|
||||||
"include/GLFW/glfw3.h"
|
main.dox
|
||||||
"include/GLFW/glfw3native.h"
|
news.dox
|
||||||
"docs/main.dox"
|
quick.dox
|
||||||
"docs/news.dox"
|
moving.dox
|
||||||
"docs/quick.dox"
|
compile.dox
|
||||||
"docs/moving.dox"
|
build.dox
|
||||||
"docs/compile.dox"
|
intro.dox
|
||||||
"docs/build.dox"
|
context.dox
|
||||||
"docs/intro.dox"
|
monitor.dox
|
||||||
"docs/context.dox"
|
window.dox
|
||||||
"docs/monitor.dox"
|
input.dox
|
||||||
"docs/window.dox"
|
vulkan.dox
|
||||||
"docs/input.dox"
|
compat.dox
|
||||||
"docs/vulkan.dox"
|
internal.dox)
|
||||||
"docs/compat.dox"
|
|
||||||
"docs/internal.dox")
|
set(extra_files DoxygenLayout.xml header.html footer.html extra.css spaces.svg)
|
||||||
|
|
||||||
|
set(header_paths
|
||||||
|
"${GLFW_SOURCE_DIR}/include/GLFW/glfw3.h"
|
||||||
|
"${GLFW_SOURCE_DIR}/include/GLFW/glfw3native.h")
|
||||||
|
|
||||||
# Format the source list into a Doxyfile INPUT value that Doxygen can parse
|
# Format the source list into a Doxyfile INPUT value that Doxygen can parse
|
||||||
foreach(path IN LISTS GLFW_DOXYGEN_SOURCES)
|
foreach(path IN LISTS header_paths)
|
||||||
set(GLFW_DOXYGEN_INPUT "${GLFW_DOXYGEN_INPUT} \\\n\"${GLFW_SOURCE_DIR}/${path}\"")
|
string(APPEND GLFW_DOXYGEN_INPUT " \\\n\"${path}\"")
|
||||||
|
endforeach()
|
||||||
|
foreach(file IN LISTS source_files)
|
||||||
|
string(APPEND GLFW_DOXYGEN_INPUT " \\\n\"${CMAKE_CURRENT_SOURCE_DIR}/${file}\"")
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
configure_file(Doxyfile.in Doxyfile @ONLY)
|
configure_file(Doxyfile.in Doxyfile @ONLY)
|
||||||
|
|
||||||
add_custom_target(docs ALL "${DOXYGEN_EXECUTABLE}"
|
add_custom_command(OUTPUT "html/index.html"
|
||||||
WORKING_DIRECTORY "${GLFW_BINARY_DIR}/docs"
|
COMMAND "${DOXYGEN_EXECUTABLE}"
|
||||||
COMMENT "Generating HTML documentation" VERBATIM)
|
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
|
||||||
|
MAIN_DEPENDENCY Doxyfile
|
||||||
|
DEPENDS ${header_paths} ${source_files} ${extra_files}
|
||||||
|
COMMENT "Generating HTML documentation"
|
||||||
|
VERBATIM)
|
||||||
|
|
||||||
|
add_custom_target(docs ALL SOURCES "html/index.html")
|
||||||
set_target_properties(docs PROPERTIES FOLDER "GLFW3")
|
set_target_properties(docs PROPERTIES FOLDER "GLFW3")
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
src/wl_* @linkmauve
|
src/wl_* @linkmauve
|
||||||
|
|
||||||
docs/*.css @glfw/webdev
|
docs/*.css @glfw/webdev
|
||||||
docs/*.less @glfw/webdev
|
docs/*.scss @glfw/webdev
|
||||||
docs/*.html @glfw/webdev
|
docs/*.html @glfw/webdev
|
||||||
docs/*.xml @glfw/webdev
|
docs/*.xml @glfw/webdev
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ section](https://discourse.glfw.org/c/support) of the forum, under the [Stack
|
|||||||
Overflow tag](https://stackoverflow.com/questions/tagged/glfw) or [Game
|
Overflow tag](https://stackoverflow.com/questions/tagged/glfw) or [Game
|
||||||
Development tag](https://gamedev.stackexchange.com/questions/tagged/glfw) on
|
Development tag](https://gamedev.stackexchange.com/questions/tagged/glfw) on
|
||||||
Stack Exchange or in the IRC channel `#glfw` on
|
Stack Exchange or in the IRC channel `#glfw` on
|
||||||
[Freenode](http://freenode.net/).
|
[Libera.Chat](https://libera.chat/).
|
||||||
|
|
||||||
Questions about the design or implementation of GLFW or about future plans
|
Questions about the design or implementation of GLFW or about future plans
|
||||||
should be asked in the [dev section](https://discourse.glfw.org/c/dev) of the
|
should be asked in the [dev section](https://discourse.glfw.org/c/dev) of the
|
||||||
|
2491
docs/Doxyfile.in
2491
docs/Doxyfile.in
File diff suppressed because it is too large
Load Diff
@ -1,11 +1,11 @@
|
|||||||
# Support resources
|
# Support resources
|
||||||
|
|
||||||
See the [latest documentation](http://www.glfw.org/docs/latest/) for tutorials,
|
See the [latest documentation](https://www.glfw.org/docs/latest/) for tutorials,
|
||||||
guides and the API reference.
|
guides and the API reference.
|
||||||
|
|
||||||
If you have questions about using GLFW, we have a
|
If you have questions about using GLFW, we have a
|
||||||
[forum](https://discourse.glfw.org/), and the `#glfw` IRC channel on
|
[forum](https://discourse.glfw.org/), and the `#glfw` IRC channel on
|
||||||
[Freenode](http://freenode.net/).
|
[Libera.Chat](https://libera.chat/).
|
||||||
|
|
||||||
Bugs are reported to our [issue tracker](https://github.com/glfw/glfw/issues).
|
Bugs are reported to our [issue tracker](https://github.com/glfw/glfw/issues).
|
||||||
Please check the [contribution
|
Please check the [contribution
|
||||||
|
@ -25,39 +25,41 @@ GLFW.
|
|||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
@endcode
|
@endcode
|
||||||
|
|
||||||
This header declares the GLFW API and by default also includes the OpenGL header
|
This header defines all the constants and declares all the types and function
|
||||||
from your development environment. See below for how to control this.
|
prototypes of the GLFW API. By default it also includes the OpenGL header from
|
||||||
|
your development environment. See [option macros](@ref build_macros) below for
|
||||||
|
how to select OpenGL ES headers and more.
|
||||||
|
|
||||||
The GLFW header also defines any platform-specific macros needed by your OpenGL
|
The GLFW header also defines any platform-specific macros needed by your OpenGL
|
||||||
header, so it can be included without needing any window system headers.
|
header, so that it can be included without needing any window system headers.
|
||||||
|
|
||||||
For example, under Windows you are normally required to include `windows.h`
|
It does this only when needed, so if window system headers are included, the
|
||||||
before the OpenGL header, which would bring in the whole Win32 API. The GLFW
|
GLFW header does not try to redefine those symbols. The reverse is not true,
|
||||||
header duplicates the small number of macros needed.
|
i.e. `windows.h` cannot cope if any Win32 symbols have already been defined.
|
||||||
|
|
||||||
It does this only when needed, so if `windows.h` _is_ included, the GLFW header
|
|
||||||
does not try to redefine those symbols. The reverse is not true, i.e.
|
|
||||||
`windows.h` cannot cope if any of its symbols have already been defined.
|
|
||||||
|
|
||||||
In other words:
|
In other words:
|
||||||
|
|
||||||
- Do _not_ include the OpenGL headers yourself, as GLFW does this for you
|
- Use the GLFW header to include OpenGL or OpenGL ES headers portably
|
||||||
- Do _not_ include `windows.h` or other platform-specific headers unless you
|
- Do not include window system headers unless you will use those APIs directly
|
||||||
plan on using those APIs directly
|
- If you do need such headers, include them before the GLFW header
|
||||||
- If you _do_ need to include such headers, do it _before_ including
|
|
||||||
the GLFW header and it will handle this
|
|
||||||
|
|
||||||
If you are using an OpenGL extension loading library such as
|
If you are using an OpenGL extension loading library such as
|
||||||
[glad](https://github.com/Dav1dde/glad), the extension loader header should
|
[glad](https://github.com/Dav1dde/glad), the extension loader header should
|
||||||
be included _before_ the GLFW one.
|
be included before the GLFW one. GLFW attempts to detect any OpenGL or OpenGL
|
||||||
|
ES header or extension loader header included before it and will then disable
|
||||||
|
the inclusion of the default OpenGL header. Most extension loaders also define
|
||||||
|
macros that disable similar headers below it.
|
||||||
|
|
||||||
@code
|
@code
|
||||||
#include <glad/gl.h>
|
#include <glad/gl.h>
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
@endcode
|
@endcode
|
||||||
|
|
||||||
Alternatively the @ref GLFW_INCLUDE_NONE macro (described below) can be used to
|
Both of these mechanisms depend on the extension loader header defining a known
|
||||||
prevent the GLFW header from including the OpenGL header.
|
macro. If yours doesn't or you don't know which one your users will pick, the
|
||||||
|
@ref GLFW_INCLUDE_NONE macro will explicitly to prevent the GLFW header from
|
||||||
|
including the OpenGL header. This will also allow you to include the two
|
||||||
|
headers in any order.
|
||||||
|
|
||||||
@code
|
@code
|
||||||
#define GLFW_INCLUDE_NONE
|
#define GLFW_INCLUDE_NONE
|
||||||
@ -105,7 +107,7 @@ __GLFW_INCLUDE_ES31__ makes the GLFW header include the OpenGL ES 3.1
|
|||||||
`GLES3/gl31.h` header instead of the regular OpenGL header.
|
`GLES3/gl31.h` header instead of the regular OpenGL header.
|
||||||
|
|
||||||
@anchor GLFW_INCLUDE_ES32
|
@anchor GLFW_INCLUDE_ES32
|
||||||
__GLFW_INCLUDE_ES31__ makes the GLFW header include the OpenGL ES 3.2
|
__GLFW_INCLUDE_ES32__ makes the GLFW header include the OpenGL ES 3.2
|
||||||
`GLES3/gl32.h` header instead of the regular OpenGL header.
|
`GLES3/gl32.h` header instead of the regular OpenGL header.
|
||||||
|
|
||||||
@anchor GLFW_INCLUDE_NONE
|
@anchor GLFW_INCLUDE_NONE
|
||||||
@ -113,7 +115,8 @@ __GLFW_INCLUDE_NONE__ makes the GLFW header not include any OpenGL or OpenGL ES
|
|||||||
API header. This is useful in combination with an extension loading library.
|
API header. This is useful in combination with an extension loading library.
|
||||||
|
|
||||||
If none of the above inclusion macros are defined, the standard OpenGL `GL/gl.h`
|
If none of the above inclusion macros are defined, the standard OpenGL `GL/gl.h`
|
||||||
header (`OpenGL/gl.h` on macOS) is included.
|
header (`OpenGL/gl.h` on macOS) is included, unless GLFW detects the inclusion
|
||||||
|
guards of any OpenGL, OpenGL ES or extension loader header it knows about.
|
||||||
|
|
||||||
The following macros control the inclusion of additional API headers. Any
|
The following macros control the inclusion of additional API headers. Any
|
||||||
number of these may be defined simultaneously, and/or together with one of the
|
number of these may be defined simultaneously, and/or together with one of the
|
||||||
@ -215,6 +218,9 @@ library and include directory paths. Link against this like any other library.
|
|||||||
target_link_libraries(myapp OpenGL::GL)
|
target_link_libraries(myapp OpenGL::GL)
|
||||||
@endcode
|
@endcode
|
||||||
|
|
||||||
|
For a minimal example of a program and GLFW sources built with CMake, see the
|
||||||
|
[GLFW CMake Starter](https://github.com/juliettef/GLFW-CMake-starter) on GitHub.
|
||||||
|
|
||||||
|
|
||||||
@subsection build_link_cmake_package With CMake and installed GLFW binaries
|
@subsection build_link_cmake_package With CMake and installed GLFW binaries
|
||||||
|
|
||||||
|
@ -104,9 +104,8 @@ integration by libwayland-egl, and keyboard handling by
|
|||||||
from wayland-protocols to provide additional features if the compositor
|
from wayland-protocols to provide additional features if the compositor
|
||||||
supports them.
|
supports them.
|
||||||
|
|
||||||
GLFW uses xkbcommon 0.5.0 to provide compose key support. When it has been
|
GLFW uses xkbcommon 0.5.0 to provide key and text input support. Earlier
|
||||||
built against an older xkbcommon, the compose key will be disabled even if it
|
versions are not supported.
|
||||||
has been configured in the compositor.
|
|
||||||
|
|
||||||
GLFW uses the [xdg-shell
|
GLFW uses the [xdg-shell
|
||||||
protocol](https://cgit.freedesktop.org/wayland/wayland-protocols/tree/stable/xdg-shell/xdg-shell.xml)
|
protocol](https://cgit.freedesktop.org/wayland/wayland-protocols/tree/stable/xdg-shell/xdg-shell.xml)
|
||||||
@ -163,10 +162,9 @@ multisampling anti-aliasing. Where this extension is unavailable, the
|
|||||||
GLFW uses the `GLX_ARB_create_context` extension when available, even when
|
GLFW uses the `GLX_ARB_create_context` extension when available, even when
|
||||||
creating OpenGL contexts of version 2.1 and below. Where this extension is
|
creating OpenGL contexts of version 2.1 and below. Where this extension is
|
||||||
unavailable, the `GLFW_CONTEXT_VERSION_MAJOR` and `GLFW_CONTEXT_VERSION_MINOR`
|
unavailable, the `GLFW_CONTEXT_VERSION_MAJOR` and `GLFW_CONTEXT_VERSION_MINOR`
|
||||||
hints will only be partially supported, the `GLFW_OPENGL_DEBUG_CONTEXT` hint
|
hints will only be partially supported, the `GLFW_CONTEXT_DEBUG` hint will have
|
||||||
will have no effect, and setting the `GLFW_OPENGL_PROFILE` or
|
no effect, and setting the `GLFW_OPENGL_PROFILE` or `GLFW_OPENGL_FORWARD_COMPAT`
|
||||||
`GLFW_OPENGL_FORWARD_COMPAT` hints to `GLFW_TRUE` will cause @ref
|
hints to `GLFW_TRUE` will cause @ref glfwCreateWindow to fail.
|
||||||
glfwCreateWindow to fail.
|
|
||||||
|
|
||||||
GLFW uses the `GLX_ARB_create_context_profile` extension to provide support for
|
GLFW uses the `GLX_ARB_create_context_profile` extension to provide support for
|
||||||
context profiles. Where this extension is unavailable, setting the
|
context profiles. Where this extension is unavailable, setting the
|
||||||
@ -206,10 +204,9 @@ unavailable, the `GLFW_SAMPLES` hint will have no effect.
|
|||||||
GLFW uses the `WGL_ARB_create_context` extension when available, even when
|
GLFW uses the `WGL_ARB_create_context` extension when available, even when
|
||||||
creating OpenGL contexts of version 2.1 and below. Where this extension is
|
creating OpenGL contexts of version 2.1 and below. Where this extension is
|
||||||
unavailable, the `GLFW_CONTEXT_VERSION_MAJOR` and `GLFW_CONTEXT_VERSION_MINOR`
|
unavailable, the `GLFW_CONTEXT_VERSION_MAJOR` and `GLFW_CONTEXT_VERSION_MINOR`
|
||||||
hints will only be partially supported, the `GLFW_OPENGL_DEBUG_CONTEXT` hint
|
hints will only be partially supported, the `GLFW_CONTEXT_DEBUG` hint will have
|
||||||
will have no effect, and setting the `GLFW_OPENGL_PROFILE` or
|
no effect, and setting the `GLFW_OPENGL_PROFILE` or `GLFW_OPENGL_FORWARD_COMPAT`
|
||||||
`GLFW_OPENGL_FORWARD_COMPAT` hints to `GLFW_TRUE` will cause @ref
|
hints to `GLFW_TRUE` will cause @ref glfwCreateWindow to fail.
|
||||||
glfwCreateWindow to fail.
|
|
||||||
|
|
||||||
GLFW uses the `WGL_ARB_create_context_profile` extension to provide support for
|
GLFW uses the `WGL_ARB_create_context_profile` extension to provide support for
|
||||||
context profiles. Where this extension is unavailable, setting the
|
context profiles. Where this extension is unavailable, setting the
|
||||||
@ -239,13 +236,13 @@ Because of this, on OS X 10.7 and later, the `GLFW_CONTEXT_VERSION_MAJOR` and
|
|||||||
`GLFW_CONTEXT_VERSION_MINOR` hints will cause @ref glfwCreateWindow to fail if
|
`GLFW_CONTEXT_VERSION_MINOR` hints will cause @ref glfwCreateWindow to fail if
|
||||||
given version 3.0 or 3.1. The `GLFW_OPENGL_PROFILE` hint must be set to
|
given version 3.0 or 3.1. The `GLFW_OPENGL_PROFILE` hint must be set to
|
||||||
`GLFW_OPENGL_CORE_PROFILE` when creating OpenGL 3.2 and later contexts. The
|
`GLFW_OPENGL_CORE_PROFILE` when creating OpenGL 3.2 and later contexts. The
|
||||||
`GLFW_OPENGL_DEBUG_CONTEXT` and `GLFW_CONTEXT_NO_ERROR` hints are ignored.
|
`GLFW_CONTEXT_DEBUG` and `GLFW_CONTEXT_NO_ERROR` hints are ignored.
|
||||||
|
|
||||||
Also, on Mac OS X 10.6 and below, the `GLFW_CONTEXT_VERSION_MAJOR` and
|
Also, on Mac OS X 10.6 and below, the `GLFW_CONTEXT_VERSION_MAJOR` and
|
||||||
`GLFW_CONTEXT_VERSION_MINOR` hints will fail if given a version above 2.1,
|
`GLFW_CONTEXT_VERSION_MINOR` hints will fail if given a version above 2.1,
|
||||||
setting the `GLFW_OPENGL_PROFILE` or `GLFW_OPENGL_FORWARD_COMPAT` hints to
|
setting the `GLFW_OPENGL_PROFILE` or `GLFW_OPENGL_FORWARD_COMPAT` hints to
|
||||||
a non-default value will cause @ref glfwCreateWindow to fail and the
|
a non-default value will cause @ref glfwCreateWindow to fail and the
|
||||||
`GLFW_OPENGL_DEBUG_CONTEXT` hint is ignored.
|
`GLFW_CONTEXT_DEBUG` hint is ignored.
|
||||||
|
|
||||||
|
|
||||||
@section compat_vulkan Vulkan loader and API
|
@section compat_vulkan Vulkan loader and API
|
||||||
|
408
docs/compile.dox
408
docs/compile.dox
@ -10,165 +10,177 @@ build applications that use GLFW, see @ref build_guide.
|
|||||||
|
|
||||||
@section compile_cmake Using CMake
|
@section compile_cmake Using CMake
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
GLFW uses [CMake](https://cmake.org/) to generate project files or makefiles
|
GLFW uses [CMake](https://cmake.org/) to generate project files or makefiles
|
||||||
for a particular development environment. If you are on a Unix-like system such
|
for your chosen development environment. To compile GLFW, first generate these
|
||||||
as Linux or FreeBSD or have a package system like Fink, MacPorts, Cygwin or
|
files with CMake and then use them to compile the GLFW library.
|
||||||
Homebrew, you can install its CMake package. If not, you can download
|
|
||||||
installers for Windows and macOS from the
|
|
||||||
[CMake website](https://cmake.org/).
|
|
||||||
|
|
||||||
@note CMake only generates project files or makefiles. It does not compile the
|
If you are on Windows and macOS you can
|
||||||
actual GLFW library. To compile GLFW, first generate these files for your
|
[download CMake](https://cmake.org/download/) from their site.
|
||||||
chosen development environment and then use them to compile the actual GLFW
|
|
||||||
library.
|
If you are on a Unix-like system such as Linux, FreeBSD or Cygwin or have
|
||||||
|
a package system like Fink, MacPorts or Homebrew, you can install its CMake
|
||||||
|
package.
|
||||||
|
|
||||||
|
CMake is a complex tool and this guide will only show a few of the possible ways
|
||||||
|
to set up and compile GLFW. The CMake project has their own much more detailed
|
||||||
|
[CMake user guide](https://cmake.org/cmake/help/latest/guide/user-interaction/)
|
||||||
|
that includes everything in this guide not specific to GLFW. It may be a useful
|
||||||
|
companion to this one.
|
||||||
|
|
||||||
|
|
||||||
@subsection compile_deps Dependencies
|
@subsection compile_deps Installing dependencies
|
||||||
|
|
||||||
Once you have installed CMake, make sure that all other dependencies are
|
The C/C++ development environments in Visual Studio, Xcode and MinGW come with
|
||||||
available. On some platforms, GLFW needs a few additional packages to be
|
all necessary dependencies for compiling GLFW, but on Unix-like systems like
|
||||||
installed. See the section for your chosen platform and development environment
|
Linux and FreeBSD you will need a few extra packages.
|
||||||
below.
|
|
||||||
|
|
||||||
|
|
||||||
@subsubsection compile_deps_msvc Dependencies for Visual C++ on Windows
|
@subsubsection compile_deps_x11 Dependencies for X11
|
||||||
|
|
||||||
The Windows SDK bundled with Visual C++ already contains all the necessary
|
To compile GLFW for X11, you need to have the X11 development packages
|
||||||
headers, link libraries and tools except for CMake. Move on to @ref
|
installed. They are not needed to build or run programs that use GLFW.
|
||||||
compile_generate.
|
|
||||||
|
|
||||||
|
On Debian and derivates like Ubuntu and Linux Mint the `xorg-dev` meta-package
|
||||||
@subsubsection compile_deps_mingw Dependencies for MinGW or MinGW-w64 on Windows
|
pulls in the development packages for all of X11.
|
||||||
|
|
||||||
Both the MinGW and the MinGW-w64 packages already contain all the necessary
|
|
||||||
headers, link libraries and tools except for CMake. Move on to @ref
|
|
||||||
compile_generate.
|
|
||||||
|
|
||||||
|
|
||||||
@subsubsection compile_deps_mingw_cross Dependencies for MinGW or MinGW-w64 cross-compilation
|
|
||||||
|
|
||||||
Both Cygwin and many Linux distributions have MinGW or MinGW-w64 packages. For
|
|
||||||
example, Cygwin has the `mingw64-i686-gcc` and `mingw64-x86_64-gcc` packages
|
|
||||||
for 32- and 64-bit version of MinGW-w64, while Debian GNU/Linux and derivatives
|
|
||||||
like Ubuntu have the `mingw-w64` package for both.
|
|
||||||
|
|
||||||
GLFW has CMake toolchain files in the `CMake/` directory that set up
|
|
||||||
cross-compilation of Windows binaries. To use these files you add an option
|
|
||||||
when running `cmake` to generate the project files or makefiles:
|
|
||||||
|
|
||||||
@code{.sh}
|
@code{.sh}
|
||||||
cmake -DCMAKE_TOOLCHAIN_FILE=<toolchain-file> .
|
sudo apt install xorg-dev
|
||||||
@endcode
|
@endcode
|
||||||
|
|
||||||
The exact toolchain file to use depends on the prefix used by the MinGW or
|
On Fedora and derivatives like Red Hat the X11 extension packages
|
||||||
MinGW-w64 binaries on your system. You can usually see this in the /usr
|
`libXcursor-devel`, `libXi-devel`, `libXinerama-devel` and `libXrandr-devel`
|
||||||
directory. For example, both the Debian/Ubuntu and Cygwin MinGW-w64 packages
|
required by GLFW pull in all its other dependencies.
|
||||||
have `/usr/x86_64-w64-mingw32` for the 64-bit compilers, so the correct
|
|
||||||
invocation would be:
|
|
||||||
|
|
||||||
@code{.sh}
|
@code{.sh}
|
||||||
cmake -DCMAKE_TOOLCHAIN_FILE=CMake/x86_64-w64-mingw32.cmake .
|
sudo dnf install libXcursor-devel libXi-devel libXinerama-devel libXrandr-devel
|
||||||
@endcode
|
@endcode
|
||||||
|
|
||||||
For more details see the article
|
On FreeBSD the X11 headers are installed along the end-user X11 packages, so if
|
||||||
[CMake Cross Compiling](https://gitlab.kitware.com/cmake/community/wikis/doc/cmake/CrossCompiling) on
|
you have an X server running you should have the headers as well. If not,
|
||||||
the CMake wiki.
|
install the `xorgproto` package.
|
||||||
|
|
||||||
Once you have this set up, move on to @ref compile_generate.
|
@code{.sh}
|
||||||
|
pkg install xorgproto
|
||||||
|
@endcode
|
||||||
|
|
||||||
|
On Cygwin the `xorgproto` package in the Devel section of the GUI installer will
|
||||||
|
install the headers and other development related files for all of X11.
|
||||||
|
|
||||||
|
Once you have the required dependencies, move on to @ref compile_generate.
|
||||||
|
|
||||||
|
|
||||||
@subsubsection compile_deps_xcode Dependencies for Xcode on macOS
|
@subsubsection compile_deps_wayland Dependencies for Wayland and X11
|
||||||
|
|
||||||
Xcode comes with all necessary tools except for CMake. The required headers
|
To compile GLFW for both Wayland and X11, you need to have the X11, Wayland and xkbcommon
|
||||||
and libraries are included in the core macOS frameworks. Xcode can be
|
development packages installed. They are not needed to build or run programs that use
|
||||||
downloaded from the Mac App Store or from the ADC Member Center.
|
GLFW. You will also need to set the @ref GLFW_BUILD_WAYLAND CMake option in the next
|
||||||
|
step when generating build files.
|
||||||
|
|
||||||
Once you have Xcode installed, move on to @ref compile_generate.
|
On Debian and derivates like Ubuntu and Linux Mint you will need the `libwayland-dev`,
|
||||||
|
`libxkbcommon-dev` and `wayland-protocols` packages and the `xorg-dev` meta-package.
|
||||||
|
These will pull in all other dependencies.
|
||||||
|
|
||||||
|
@code{.sh}
|
||||||
|
sudo apt install libwayland-dev libxkbcommon-dev wayland-protocols xorg-dev
|
||||||
|
@endcode
|
||||||
|
|
||||||
@subsubsection compile_deps_x11 Dependencies for Linux and X11
|
On Fedora and derivatives like Red Hat you will need the `wayland-devel`,
|
||||||
|
`libxkbcommon-devel`, `wayland-protocols-devel`, `libXcursor-devel`, `libXi-devel`,
|
||||||
|
`libXinerama-devel` and `libXrandr-devel` packages. These will pull in all other
|
||||||
|
dependencies.
|
||||||
|
|
||||||
To compile GLFW for X11, you need to have the X11 packages installed, as well as
|
@code{.sh}
|
||||||
the basic development tools like GCC and make. For example, on Ubuntu and other
|
sudo dnf install wayland-devel libxkbcommon-devel wayland-protocols-devel libXcursor-devel libXi-devel libXinerama-devel libXrandr-devel
|
||||||
distributions based on Debian GNU/Linux, you need to install the `xorg-dev`
|
@endcode
|
||||||
package, which pulls in all X.org header packages.
|
|
||||||
|
|
||||||
Once you have installed the necessary packages, move on to @ref
|
On FreeBSD you will need the `wayland`, `libxkbcommon` and `wayland-protocols` packages.
|
||||||
compile_generate.
|
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 xorgproto
|
||||||
|
@endcode
|
||||||
|
|
||||||
@subsubsection compile_deps_wayland Dependencies for Linux and Wayland
|
Once you have the required dependencies, move on to @ref compile_generate.
|
||||||
|
|
||||||
To compile GLFW for Wayland, you need to have the Wayland packages installed,
|
|
||||||
as well as the basic development tools like GCC and make. For example, on
|
|
||||||
Ubuntu and other distributions based on Debian GNU/Linux, you need to install
|
|
||||||
the `libwayland-dev` package, which contains all Wayland headers and pulls in
|
|
||||||
wayland-scanner, as well as the `wayland-protocols` and `extra-cmake-modules`
|
|
||||||
packages.
|
|
||||||
|
|
||||||
Once you have installed the necessary packages, move on to @ref
|
|
||||||
compile_generate.
|
|
||||||
|
|
||||||
|
|
||||||
@subsection compile_deps_osmesa Dependencies for Linux and OSMesa
|
|
||||||
|
|
||||||
To compile GLFW for OSMesa, you need to install the OSMesa library and header
|
|
||||||
packages. For example, on Ubuntu and other distributions based on Debian
|
|
||||||
GNU/Linux, you need to install the `libosmesa6-dev` package. The OSMesa library
|
|
||||||
is required at runtime for context creation and is loaded on demand.
|
|
||||||
|
|
||||||
Once you have installed the necessary packages, move on to @ref
|
|
||||||
compile_generate.
|
|
||||||
|
|
||||||
|
|
||||||
@subsection compile_generate Generating build files with CMake
|
@subsection compile_generate Generating build files with CMake
|
||||||
|
|
||||||
Once you have all necessary dependencies it is time to generate the project
|
Once you have all necessary dependencies it is time to generate the project
|
||||||
files or makefiles for your development environment. CMake needs to know two
|
files or makefiles for your development environment. CMake needs two paths for
|
||||||
paths for this: the path to the _root_ directory of the GLFW source tree (i.e.
|
this:
|
||||||
_not_ the `src` subdirectory) and the target path for the generated files and
|
|
||||||
compiled binaries. If these are the same, it is called an in-tree build,
|
|
||||||
otherwise it is called an out-of-tree build.
|
|
||||||
|
|
||||||
One of several advantages of out-of-tree builds is that you can generate files
|
- the path to the root directory of the GLFW source tree (not its `src`
|
||||||
and compile for different development environments using a single source tree.
|
subdirectory)
|
||||||
|
- the path to the directory where the generated build files and compiled
|
||||||
|
binaries will be placed
|
||||||
|
|
||||||
@note This section is about generating the project files or makefiles necessary
|
If these are the same, it is called an in-tree build, otherwise it is called an
|
||||||
to compile the GLFW library, not about compiling the actual library.
|
out-of-tree build.
|
||||||
|
|
||||||
|
Out-of-tree builds are recommended as they avoid cluttering up the source tree.
|
||||||
|
They also allow you to have several build directories for different
|
||||||
|
configurations all using the same source tree.
|
||||||
|
|
||||||
|
A common pattern when building a single configuration is to have a build
|
||||||
|
directory named `build` in the root of the source tree.
|
||||||
|
|
||||||
|
|
||||||
@subsubsection compile_generate_cli Generating files with the CMake command-line tool
|
@subsubsection compile_generate_gui Generating with the CMake GUI
|
||||||
|
|
||||||
To make an in-tree build, enter the _root_ directory of the GLFW source tree
|
Start the CMake GUI and set the paths to the source and build directories
|
||||||
(i.e. _not_ the `src` subdirectory) and run CMake. The current directory is
|
described above. Then press _Configure_ and _Generate_.
|
||||||
used as target path, while the path provided as an argument is used to find the
|
|
||||||
source tree.
|
|
||||||
|
|
||||||
@code{.sh}
|
If you wish change any CMake variables in the list, press _Configure_ and then
|
||||||
cd <glfw-root-dir>
|
_Generate_ to have the new values take effect. The variable list will be
|
||||||
cmake .
|
populated after the first configure step.
|
||||||
@endcode
|
|
||||||
|
|
||||||
To make an out-of-tree build, make a directory outside of the source tree, enter
|
By default GLFW will use X11 on Linux and other Unix-like systems other than macOS. To
|
||||||
it and run CMake with the (relative or absolute) path to the root of the source
|
include support for Wayland as well, set the @ref GLFW_BUILD_WAYLAND option in the GLFW
|
||||||
tree as an argument.
|
section of the variable list, then apply the new value as described above.
|
||||||
|
|
||||||
@code{.sh}
|
|
||||||
mkdir glfw-build
|
|
||||||
cd glfw-build
|
|
||||||
cmake <glfw-root-dir>
|
|
||||||
@endcode
|
|
||||||
|
|
||||||
Once you have generated the project files or makefiles for your chosen
|
Once you have generated the project files or makefiles for your chosen
|
||||||
development environment, move on to @ref compile_compile.
|
development environment, move on to @ref compile_compile.
|
||||||
|
|
||||||
|
|
||||||
@subsubsection compile_generate_gui Generating files with the CMake GUI
|
@subsubsection compile_generate_cli Generating with command-line CMake
|
||||||
|
|
||||||
If you are using the GUI version, choose the root of the GLFW source tree as
|
To make a build directory, pass the source and build directories to the `cmake`
|
||||||
source location and the same directory or another, empty directory as the
|
command. These can be relative or absolute paths. The build directory is
|
||||||
destination for binaries. Choose _Configure_, change any options you wish to,
|
created if it doesn't already exist.
|
||||||
_Configure_ again to let the changes take effect and then _Generate_.
|
|
||||||
|
@code{.sh}
|
||||||
|
cmake -S path/to/glfw -B path/to/build
|
||||||
|
@endcode
|
||||||
|
|
||||||
|
It is common to name the build directory `build` and place it in the root of the
|
||||||
|
source tree when only planning to build a single configuration.
|
||||||
|
|
||||||
|
@code{.sh}
|
||||||
|
cd path/to/glfw
|
||||||
|
cmake -S . -B build
|
||||||
|
@endcode
|
||||||
|
|
||||||
|
Without other flags these will generate Visual Studio project files on Windows
|
||||||
|
and makefiles on other platforms. You can choose other targets using the `-G`
|
||||||
|
flag.
|
||||||
|
|
||||||
|
@code{.sh}
|
||||||
|
cmake -S path/to/glfw -B path/to/build -G Xcode
|
||||||
|
@endcode
|
||||||
|
|
||||||
|
By default GLFW will use X11 on Linux and other Unix-like systems other
|
||||||
|
than macOS. To 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_BUILD_WAYLAND=1
|
||||||
|
@endcode
|
||||||
|
|
||||||
Once you have generated the project files or makefiles for your chosen
|
Once you have generated the project files or makefiles for your chosen
|
||||||
development environment, move on to @ref compile_compile.
|
development environment, move on to @ref compile_compile.
|
||||||
@ -178,13 +190,39 @@ development environment, move on to @ref compile_compile.
|
|||||||
|
|
||||||
You should now have all required dependencies and the project files or makefiles
|
You should now have all required dependencies and the project files or makefiles
|
||||||
necessary to compile GLFW. Go ahead and compile the actual GLFW library with
|
necessary to compile GLFW. Go ahead and compile the actual GLFW library with
|
||||||
these files, as you would with any other project.
|
these files as you would with any other project.
|
||||||
|
|
||||||
Once the GLFW library is compiled, you are ready to build your applications,
|
With Visual Studio open `GLFW.sln` and use the Build menu. With Xcode open
|
||||||
|
`GLFW.xcodeproj` and use the Project menu.
|
||||||
|
|
||||||
|
With Linux, macOS and other forms of Unix, run `make`.
|
||||||
|
|
||||||
|
@code{.sh}
|
||||||
|
cd path/to/build
|
||||||
|
make
|
||||||
|
@endcode
|
||||||
|
|
||||||
|
With MinGW, it is `mingw32-make`.
|
||||||
|
|
||||||
|
@code{.sh}
|
||||||
|
cd path/to/build
|
||||||
|
mingw32-make
|
||||||
|
@endcode
|
||||||
|
|
||||||
|
Any CMake build directory can also be built with the `cmake` command and the
|
||||||
|
`--build` flag.
|
||||||
|
|
||||||
|
@code{.sh}
|
||||||
|
cmake --build path/to/build
|
||||||
|
@endcode
|
||||||
|
|
||||||
|
This will run the platform specific build tool the directory was generated for.
|
||||||
|
|
||||||
|
Once the GLFW library is compiled you are ready to build your application,
|
||||||
linking it to the GLFW library. See @ref build_guide for more information.
|
linking it to the GLFW library. See @ref build_guide for more information.
|
||||||
|
|
||||||
|
|
||||||
@subsection compile_options CMake options
|
@section compile_options CMake options
|
||||||
|
|
||||||
The CMake files for GLFW provide a number of options, although not all are
|
The CMake files for GLFW provide a number of options, although not all are
|
||||||
available on all supported platforms. Some of these are de facto standards
|
available on all supported platforms. Some of these are de facto standards
|
||||||
@ -200,91 +238,153 @@ Finally, if you don't want to use any GUI, you can set options from the `cmake`
|
|||||||
command-line with the `-D` flag.
|
command-line with the `-D` flag.
|
||||||
|
|
||||||
@code{.sh}
|
@code{.sh}
|
||||||
cmake -DBUILD_SHARED_LIBS=ON .
|
cmake -S path/to/glfw -B path/to/build -D BUILD_SHARED_LIBS=ON
|
||||||
@endcode
|
@endcode
|
||||||
|
|
||||||
|
|
||||||
@subsubsection compile_options_shared Shared CMake options
|
@subsection compile_options_shared Shared CMake options
|
||||||
|
|
||||||
@anchor BUILD_SHARED_LIBS
|
@anchor BUILD_SHARED_LIBS
|
||||||
__BUILD_SHARED_LIBS__ determines whether GLFW is built as a static
|
__BUILD_SHARED_LIBS__ determines whether GLFW is built as a static library or as
|
||||||
library or as a DLL / shared library / dynamic library.
|
a DLL / shared library / dynamic library. This is disabled by default,
|
||||||
|
producing a static GLFW library. This variable has no `GLFW_` prefix because it
|
||||||
|
is defined by CMake. If you want to change the library only for GLFW when it is
|
||||||
|
part of a larger project, see @ref GLFW_LIBRARY_TYPE.
|
||||||
|
|
||||||
|
@anchor GLFW_LIBRARY_TYPE
|
||||||
|
__GLFW_LIBRARY_TYPE__ allows you to override @ref BUILD_SHARED_LIBS only for
|
||||||
|
GLFW, without affecting other libraries in a larger project. When set, the
|
||||||
|
value of this option must be a valid CMake library type. Set it to `STATIC` to
|
||||||
|
build GLFW as a static library, `SHARED` to build it as a shared library
|
||||||
|
/ dynamic library / DLL, or `OBJECT` to make GLFW a CMake object library.
|
||||||
|
|
||||||
@anchor GLFW_BUILD_EXAMPLES
|
@anchor GLFW_BUILD_EXAMPLES
|
||||||
__GLFW_BUILD_EXAMPLES__ determines whether the GLFW examples are built
|
__GLFW_BUILD_EXAMPLES__ determines whether the GLFW examples are built
|
||||||
along with the library. This is enabled by default unless GLFW is being built
|
along with the library. This is enabled by default unless GLFW is being built
|
||||||
as a sub-project.
|
as a sub-project of a larger CMake project.
|
||||||
|
|
||||||
@anchor GLFW_BUILD_TESTS
|
@anchor GLFW_BUILD_TESTS
|
||||||
__GLFW_BUILD_TESTS__ determines whether the GLFW test programs are
|
__GLFW_BUILD_TESTS__ determines whether the GLFW test programs are
|
||||||
built along with the library. This is enabled by default unless GLFW is being
|
built along with the library. This is enabled by default unless GLFW is being
|
||||||
built as a sub-project.
|
built as a sub-project of a larger CMake project.
|
||||||
|
|
||||||
@anchor GLFW_BUILD_DOCS
|
@anchor GLFW_BUILD_DOCS
|
||||||
__GLFW_BUILD_DOCS__ determines whether the GLFW documentation is built along
|
__GLFW_BUILD_DOCS__ determines whether the GLFW documentation is built along
|
||||||
with the library.
|
with the library. This is enabled by default if
|
||||||
|
[Doxygen](https://www.doxygen.nl/) is found by CMake during configuration.
|
||||||
@anchor GLFW_VULKAN_STATIC
|
|
||||||
__GLFW_VULKAN_STATIC__ determines whether to use the Vulkan loader linked
|
|
||||||
directly with the application.
|
|
||||||
|
|
||||||
|
|
||||||
@subsubsection compile_options_win32 Windows specific CMake options
|
@subsection compile_options_win32 Win32 specific CMake options
|
||||||
|
|
||||||
|
@anchor GLFW_BUILD_WIN32
|
||||||
|
__GLFW_BUILD_WIN32__ determines whether to include support for Win32 when compiling the
|
||||||
|
library. This option is only available when compiling for Windows. This is enabled by
|
||||||
|
default.
|
||||||
|
|
||||||
@anchor USE_MSVC_RUNTIME_LIBRARY_DLL
|
@anchor USE_MSVC_RUNTIME_LIBRARY_DLL
|
||||||
__USE_MSVC_RUNTIME_LIBRARY_DLL__ determines whether to use the DLL version or the
|
__USE_MSVC_RUNTIME_LIBRARY_DLL__ determines whether to use the DLL version or the
|
||||||
static library version of the Visual C++ runtime library. If set to `ON`, the
|
static library version of the Visual C++ runtime library. When enabled, the
|
||||||
DLL version of the Visual C++ library is used.
|
DLL version of the Visual C++ library is used. This is enabled by default.
|
||||||
|
|
||||||
|
On CMake 3.15 and later you can set the standard CMake
|
||||||
|
[CMAKE_MSVC_RUNTIME_LIBRARY](https://cmake.org/cmake/help/latest/variable/CMAKE_MSVC_RUNTIME_LIBRARY.html)
|
||||||
|
variable instead of this GLFW-specific option.
|
||||||
|
|
||||||
@anchor GLFW_USE_HYBRID_HPG
|
@anchor GLFW_USE_HYBRID_HPG
|
||||||
__GLFW_USE_HYBRID_HPG__ determines whether to export the `NvOptimusEnablement` and
|
__GLFW_USE_HYBRID_HPG__ determines whether to export the `NvOptimusEnablement` and
|
||||||
`AmdPowerXpressRequestHighPerformance` symbols, which force the use of the
|
`AmdPowerXpressRequestHighPerformance` symbols, which force the use of the
|
||||||
high-performance GPU on Nvidia Optimus and AMD PowerXpress systems. These symbols
|
high-performance GPU on Nvidia Optimus and AMD PowerXpress systems. These symbols
|
||||||
need to be exported by the EXE to be detected by the driver, so the override
|
need to be exported by the EXE to be detected by the driver, so the override
|
||||||
will not work if GLFW is built as a DLL.
|
will not work if GLFW is built as a DLL. This is disabled by default, letting
|
||||||
|
the operating system and driver decide.
|
||||||
|
|
||||||
|
|
||||||
|
@subsection compile_options_macos macOS specific CMake options
|
||||||
|
|
||||||
|
@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
|
||||||
|
|
||||||
|
Both Cygwin and many Linux distributions have MinGW or MinGW-w64 packages. For
|
||||||
|
example, Cygwin has the `mingw64-i686-gcc` and `mingw64-x86_64-gcc` packages
|
||||||
|
for 32- and 64-bit version of MinGW-w64, while Debian GNU/Linux and derivatives
|
||||||
|
like Ubuntu have the `mingw-w64` package for both.
|
||||||
|
|
||||||
|
GLFW has CMake toolchain files in the `CMake` subdirectory that set up
|
||||||
|
cross-compilation of Windows binaries. To use these files you set the
|
||||||
|
`CMAKE_TOOLCHAIN_FILE` CMake variable with the `-D` flag add an option when
|
||||||
|
configuring and generating the build files.
|
||||||
|
|
||||||
|
@code{.sh}
|
||||||
|
cmake -S path/to/glfw -B path/to/build -D CMAKE_TOOLCHAIN_FILE=path/to/file
|
||||||
|
@endcode
|
||||||
|
|
||||||
|
The exact toolchain file to use depends on the prefix used by the MinGW or
|
||||||
|
MinGW-w64 binaries on your system. You can usually see this in the /usr
|
||||||
|
directory. For example, both the Ubuntu and Cygwin MinGW-w64 packages have
|
||||||
|
`/usr/x86_64-w64-mingw32` for the 64-bit compilers, so the correct invocation
|
||||||
|
would be:
|
||||||
|
|
||||||
|
@code{.sh}
|
||||||
|
cmake -S path/to/glfw -B path/to/build -D CMAKE_TOOLCHAIN_FILE=CMake/x86_64-w64-mingw32.cmake
|
||||||
|
@endcode
|
||||||
|
|
||||||
|
The path to the toolchain file is relative to the path to the GLFW source tree
|
||||||
|
passed to the `-S` flag, not to the current directory.
|
||||||
|
|
||||||
|
For more details see the
|
||||||
|
[CMake toolchain guide](https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html).
|
||||||
|
|
||||||
|
|
||||||
@section compile_manual Compiling GLFW manually
|
@section compile_manual Compiling GLFW manually
|
||||||
|
|
||||||
If you wish to compile GLFW without its CMake build environment then you will
|
If you wish to compile GLFW without its CMake build environment then you will have to do
|
||||||
have to do at least some of the platform detection yourself. GLFW needs
|
at least some of the platform detection yourself. There are preprocessor macros for
|
||||||
a configuration macro to be defined in order to know what window system it's
|
enabling support for the platforms (window systems) available. There are also optional,
|
||||||
being compiled for and also has optional, platform-specific ones for various
|
platform-specific macros for various features.
|
||||||
features.
|
|
||||||
|
|
||||||
When building with CMake, the `glfw_config.h` configuration header is generated
|
When building, GLFW will expect the necessary configuration macros to be defined
|
||||||
based on the current platform and CMake options. The GLFW CMake environment
|
on the command-line. The GLFW CMake files set these as private compile
|
||||||
defines @b GLFW_USE_CONFIG_H, which causes this header to be included by
|
definitions on the GLFW target but if you compile the GLFW sources manually you
|
||||||
`internal.h`. Without this macro, GLFW will expect the necessary configuration
|
will need to define them yourself.
|
||||||
macros to be defined on the command-line.
|
|
||||||
|
|
||||||
The window creation API is used to create windows, handle input, monitors, gamma
|
The window system is used to create windows, handle input, monitors, gamma ramps and
|
||||||
ramps and clipboard. The options are:
|
clipboard. The options are:
|
||||||
|
|
||||||
- @b _GLFW_COCOA to use the Cocoa frameworks
|
- @b _GLFW_COCOA to use the Cocoa frameworks
|
||||||
- @b _GLFW_WIN32 to use the Win32 API
|
- @b _GLFW_WIN32 to use the Win32 API
|
||||||
- @b _GLFW_X11 to use the X Window System
|
- @b _GLFW_X11 to use the X Window System
|
||||||
- @b _GLFW_WAYLAND to use the Wayland API (experimental and incomplete)
|
- @b _GLFW_WAYLAND to use the Wayland API (incomplete)
|
||||||
- @b _GLFW_OSMESA to use the OSMesa API (headless and non-interactive)
|
|
||||||
|
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
|
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.
|
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
|
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
|
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
|
of @b _GLFW_VULKAN_LIBRARY, @b _GLFW_EGL_LIBRARY, @b _GLFW_GLX_LIBRARY, @b
|
||||||
_GLFW_OSMESA_LIBRARY, @b _GLFW_OPENGL_LIBRARY, @b _GLFW_GLESV1_LIBRARY and @b
|
_GLFW_OSMESA_LIBRARY, @b _GLFW_OPENGL_LIBRARY, @b _GLFW_GLESV1_LIBRARY and @b
|
||||||
_GLFW_GLESV2_LIBRARY. Otherwise, GLFW will use the built-in default names.
|
_GLFW_GLESV2_LIBRARY. Otherwise, GLFW will use the built-in default names.
|
||||||
|
|
||||||
For the EGL context creation API, the following options are available:
|
|
||||||
|
|
||||||
- @b _GLFW_USE_EGLPLATFORM_H to use an existing `EGL/eglplatform.h` header file
|
|
||||||
for native handle types (fallback)
|
|
||||||
|
|
||||||
@note None of the @ref build_macros may be defined during the compilation of
|
@note None of the @ref build_macros may be defined during the compilation of
|
||||||
GLFW. If you define any of these in your build files, make sure they are not
|
GLFW. If you define any of these in your build files, make sure they are not
|
||||||
applied to the GLFW sources.
|
applied to the GLFW sources.
|
||||||
|
@ -138,9 +138,9 @@ as extensions until they become obsolete.
|
|||||||
|
|
||||||
An extension is defined by:
|
An extension is defined by:
|
||||||
|
|
||||||
- An extension name (e.g. `GL_ARB_debug_output`)
|
- An extension name (e.g. `GL_ARB_gl_spirv`)
|
||||||
- New OpenGL tokens (e.g. `GL_DEBUG_SEVERITY_HIGH_ARB`)
|
- New OpenGL tokens (e.g. `GL_SPIR_V_BINARY_ARB`)
|
||||||
- New OpenGL functions (e.g. `glGetDebugMessageLogARB`)
|
- New OpenGL functions (e.g. `glSpecializeShaderARB`)
|
||||||
|
|
||||||
Note the `ARB` affix, which stands for Architecture Review Board and is used
|
Note the `ARB` affix, which stands for Architecture Review Board and is used
|
||||||
for official extensions. The extension above was created by the ARB, but there
|
for official extensions. The extension above was created by the ARB, but there
|
||||||
@ -225,9 +225,9 @@ To check whether a specific extension is supported, use the `GLAD_GL_xxx`
|
|||||||
booleans.
|
booleans.
|
||||||
|
|
||||||
@code
|
@code
|
||||||
if (GLAD_GL_ARB_debug_output)
|
if (GLAD_GL_ARB_gl_spirv)
|
||||||
{
|
{
|
||||||
// Use GL_ARB_debug_output
|
// Use GL_ARB_gl_spirv
|
||||||
}
|
}
|
||||||
@endcode
|
@endcode
|
||||||
|
|
||||||
@ -259,8 +259,8 @@ included in your development environment may be several years out of date and
|
|||||||
may not include the extensions you wish to use.
|
may not include the extensions you wish to use.
|
||||||
|
|
||||||
The header defines function pointer types for all functions of all extensions it
|
The header defines function pointer types for all functions of all extensions it
|
||||||
supports. These have names like `PFNGLGETDEBUGMESSAGELOGARBPROC` (for
|
supports. These have names like `PFNGLSPECIALIZESHADERARBPROC` (for
|
||||||
`glGetDebugMessageLogARB`), i.e. the name is made uppercase and `PFN` (pointer
|
`glSpecializeShaderARB`), i.e. the name is made uppercase and `PFN` (pointer
|
||||||
to function) and `PROC` (procedure) are added to the ends.
|
to function) and `PROC` (procedure) are added to the ends.
|
||||||
|
|
||||||
To include the extension header, define @ref GLFW_INCLUDE_GLEXT before including
|
To include the extension header, define @ref GLFW_INCLUDE_GLEXT before including
|
||||||
@ -280,7 +280,7 @@ is necessary to check at run-time whether the context supports the extension.
|
|||||||
This is done with @ref glfwExtensionSupported.
|
This is done with @ref glfwExtensionSupported.
|
||||||
|
|
||||||
@code
|
@code
|
||||||
if (glfwExtensionSupported("GL_ARB_debug_output"))
|
if (glfwExtensionSupported("GL_ARB_gl_spirv"))
|
||||||
{
|
{
|
||||||
// The extension is supported by the current context
|
// The extension is supported by the current context
|
||||||
}
|
}
|
||||||
@ -299,7 +299,7 @@ your operating system, making it necessary to fetch them at run time. You can
|
|||||||
retrieve pointers to these functions with @ref glfwGetProcAddress.
|
retrieve pointers to these functions with @ref glfwGetProcAddress.
|
||||||
|
|
||||||
@code
|
@code
|
||||||
PFNGLGETDEBUGMESSAGELOGARBPROC pfnGetDebugMessageLog = glfwGetProcAddress("glGetDebugMessageLogARB");
|
PFNGLSPECIALIZESHADERARBPROC pfnSpecializeShaderARB = glfwGetProcAddress("glSpecializeShaderARB");
|
||||||
@endcode
|
@endcode
|
||||||
|
|
||||||
In general, you should avoid giving the function pointer variables the (exact)
|
In general, you should avoid giving the function pointer variables the (exact)
|
||||||
@ -313,28 +313,28 @@ when used together.
|
|||||||
#define GLFW_INCLUDE_GLEXT
|
#define GLFW_INCLUDE_GLEXT
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
|
|
||||||
#define glGetDebugMessageLogARB pfnGetDebugMessageLog
|
#define glSpecializeShaderARB pfnSpecializeShaderARB
|
||||||
PFNGLGETDEBUGMESSAGELOGARBPROC pfnGetDebugMessageLog;
|
PFNGLSPECIALIZESHADERARBPROC pfnSpecializeShaderARB;
|
||||||
|
|
||||||
// Flag indicating whether the extension is supported
|
// Flag indicating whether the extension is supported
|
||||||
int has_ARB_debug_output = 0;
|
int has_ARB_gl_spirv = 0;
|
||||||
|
|
||||||
void load_extensions(void)
|
void load_extensions(void)
|
||||||
{
|
{
|
||||||
if (glfwExtensionSupported("GL_ARB_debug_output"))
|
if (glfwExtensionSupported("GL_ARB_gl_spirv"))
|
||||||
{
|
{
|
||||||
pfnGetDebugMessageLog = (PFNGLGETDEBUGMESSAGELOGARBPROC)
|
pfnSpecializeShaderARB = (PFNGLSPECIALIZESHADERARBPROC)
|
||||||
glfwGetProcAddress("glGetDebugMessageLogARB");
|
glfwGetProcAddress("glSpecializeShaderARB");
|
||||||
has_ARB_debug_output = 1;
|
has_ARB_gl_spirv = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void some_function(void)
|
void some_function(void)
|
||||||
{
|
{
|
||||||
if (has_ARB_debug_output)
|
if (has_ARB_gl_spirv)
|
||||||
{
|
{
|
||||||
// Now the extension function can be called as usual
|
// Now the extension function can be called as usual
|
||||||
glGetDebugMessageLogARB(...);
|
glSpecializeShaderARB(...);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@endcode
|
@endcode
|
||||||
|
File diff suppressed because one or more lines are too long
7
docs/extra.css.map
Normal file
7
docs/extra.css.map
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"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"
|
||||||
|
}
|
@ -1,79 +1,79 @@
|
|||||||
// NOTE: Please use this file to perform modifications on default style sheets.
|
// NOTE: Please use this file to perform modifications on default style sheets.
|
||||||
//
|
//
|
||||||
// You need to install a few Ruby gems to generate extra.css from this file:
|
// You need to install the official Sass CLI tool:
|
||||||
// gem install less therubyracer
|
// npm install -g sass
|
||||||
//
|
//
|
||||||
// Run this command to regenerate extra.css after you're finished with changes:
|
// Run this command to regenerate extra.css after you're finished with changes:
|
||||||
// lessc --compress extra.less > extra.css
|
// sass --style=compressed extra.scss extra.css
|
||||||
//
|
//
|
||||||
// Alternatively you can use online services to regenerate extra.css.
|
// Alternatively you can use online services to regenerate extra.css.
|
||||||
|
|
||||||
|
|
||||||
// Default text color for page contents
|
// Default text color for page contents
|
||||||
@default-text-color: hsl(0,0%,30%);
|
$default-text-color: hsl(0,0%,30%);
|
||||||
|
|
||||||
// Page header, footer, table rows, inline codes and definition lists
|
// Page header, footer, table rows, inline codes and definition lists
|
||||||
@header-footer-background-color: hsl(0,0%,95%);
|
$header-footer-background-color: hsl(0,0%,95%);
|
||||||
|
|
||||||
// Page header, footer links and navigation bar background
|
// Page header, footer links and navigation bar background
|
||||||
@header-footer-link-color: hsl(0,0%,40%);
|
$header-footer-link-color: hsl(0,0%,40%);
|
||||||
|
|
||||||
// Doxygen navigation bar links
|
// Doxygen navigation bar links
|
||||||
@navbar-link-color: @header-footer-background-color;
|
$navbar-link-color: $header-footer-background-color;
|
||||||
|
|
||||||
// Page content background color
|
// Page content background color
|
||||||
@content-background-color: hsl(0,0%,100%);
|
$content-background-color: hsl(0,0%,100%);
|
||||||
|
|
||||||
// Bold, italic, h1, h2, ... and table of contents
|
// Bold, italic, h1, h2, ... and table of contents
|
||||||
@heading-color: hsl(0,0%,10%);
|
$heading-color: hsl(0,0%,10%);
|
||||||
|
|
||||||
// Function, enum and macro definition separator
|
// Function, enum and macro definition separator
|
||||||
@def-separator-color: @header-footer-background-color;
|
$def-separator-color: $header-footer-background-color;
|
||||||
|
|
||||||
// Base color hue
|
// Base color hue
|
||||||
@base-hue: 24;
|
$base-hue: 24;
|
||||||
|
|
||||||
// Default color used for links
|
// Default color used for links
|
||||||
@default-link-color: hsl(@base-hue,100%,50%);
|
$default-link-color: hsl($base-hue,100%,50%);
|
||||||
|
|
||||||
// Doxygen navigation bar active tab
|
// Doxygen navigation bar active tab
|
||||||
@tab-text-color: hsl(0,0%,100%);
|
$tab-text-color: hsl(0,0%,100%);
|
||||||
@tab-background-color1: @default-link-color;
|
$tab-background-color1: $default-link-color;
|
||||||
@tab-background-color2: lighten(spin(@tab-background-color1, 10), 10%);
|
$tab-background-color2: lighten(adjust-hue($tab-background-color1, 10), 10%);
|
||||||
|
|
||||||
// Table borders
|
// Table borders
|
||||||
@default-border-color: @default-link-color;
|
$default-border-color: $default-link-color;
|
||||||
|
|
||||||
// Table header
|
// Table header
|
||||||
@table-text-color: @tab-text-color;
|
$table-text-color: $tab-text-color;
|
||||||
@table-background-color1: @tab-background-color1;
|
$table-background-color1: $tab-background-color1;
|
||||||
@table-background-color2: @tab-background-color2;
|
$table-background-color2: $tab-background-color2;
|
||||||
|
|
||||||
// Table of contents, data structure index and prototypes
|
// Table of contents, data structure index and prototypes
|
||||||
@toc-background-color1: hsl(0,0%,90%);
|
$toc-background-color1: hsl(0,0%,90%);
|
||||||
@toc-background-color2: lighten(@toc-background-color1, 5%);
|
$toc-background-color2: lighten($toc-background-color1, 5%);
|
||||||
|
|
||||||
// Function prototype parameters color
|
// Function prototype parameters color
|
||||||
@prototype-param-color: darken(@default-link-color, 25%);
|
$prototype-param-color: darken($default-link-color, 25%);
|
||||||
|
|
||||||
// Message box color: note, pre, post and invariant
|
// Message box color: note, pre, post and invariant
|
||||||
@box-note-color: hsl(103,80%,85%);
|
$box-note-color: hsl(103,80%,85%);
|
||||||
|
|
||||||
// Message box color: warning and attention
|
// Message box color: warning and attention
|
||||||
@box-warning-color: hsl(34,80%,85%);
|
$box-warning-color: hsl(34,80%,85%);
|
||||||
|
|
||||||
// Message box color: deprecated and bug
|
// Message box color: deprecated and bug
|
||||||
@box-bug-color: hsl(333,80%,85%);
|
$box-bug-color: hsl(333,80%,85%);
|
||||||
|
|
||||||
// Message box color: todo and test
|
// Message box color: todo and test
|
||||||
@box-todo-color: hsl(200,80%,85%);
|
$box-todo-color: hsl(200,80%,85%);
|
||||||
|
|
||||||
// Message box helper function
|
// Message box helper function
|
||||||
.message-box(@base-color) {
|
@mixin message-box($base-color){
|
||||||
background:linear-gradient(to bottom,lighten(@base-color, 5%) 0%,@base-color 100%);
|
background:linear-gradient(to bottom,lighten($base-color, 5%) 0%,$base-color 100%);
|
||||||
box-shadow:inset 0 0 32px darken(@base-color, 5%);
|
box-shadow:inset 0 0 32px darken($base-color, 5%);
|
||||||
color:darken(@base-color, 67%);
|
color:darken($base-color, 67%);
|
||||||
border:2px solid desaturate(darken(@base-color, 10%), 20%);
|
border:2px solid desaturate(darken($base-color, 10%), 20%);
|
||||||
}
|
}
|
||||||
|
|
||||||
.sm-dox,.sm-dox a,.sm-dox a:focus,.sm-dox a:active,.sm-dox a:hover,.sm-dox a.highlighted,.sm-dox ul a:hover {
|
.sm-dox,.sm-dox a,.sm-dox a:focus,.sm-dox a:active,.sm-dox a:hover,.sm-dox a.highlighted,.sm-dox ul a:hover {
|
||||||
@ -82,24 +82,24 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.sm-dox a span.sub-arrow {
|
.sm-dox a span.sub-arrow {
|
||||||
border-color:@navbar-link-color transparent transparent transparent;
|
border-color:$navbar-link-color transparent transparent transparent;
|
||||||
}
|
}
|
||||||
|
|
||||||
.sm-dox a span.sub-arrow:active,.sm-dox a span.sub-arrow:focus,.sm-dox a span.sub-arrow:hover,.sm-dox a:hover span.sub-arrow {
|
.sm-dox a span.sub-arrow:active,.sm-dox a span.sub-arrow:focus,.sm-dox a span.sub-arrow:hover,.sm-dox a:hover span.sub-arrow {
|
||||||
border-color:@default-link-color transparent transparent transparent;
|
border-color:$default-link-color transparent transparent transparent;
|
||||||
}
|
}
|
||||||
|
|
||||||
.sm-dox ul a span.sub-arrow:active,.sm-dox ul a span.sub-arrow:focus,.sm-dox ul a span.sub-arrow:hover,.sm-dox ul a:hover span.sub-arrow {
|
.sm-dox ul a span.sub-arrow:active,.sm-dox ul a span.sub-arrow:focus,.sm-dox ul a span.sub-arrow:hover,.sm-dox ul a:hover span.sub-arrow {
|
||||||
border-color:transparent transparent transparent @default-link-color;
|
border-color:transparent transparent transparent $default-link-color;
|
||||||
}
|
}
|
||||||
|
|
||||||
.sm-dox ul a:hover {
|
.sm-dox ul a:hover {
|
||||||
background:@header-footer-link-color;
|
background:$header-footer-link-color;
|
||||||
text-shadow:none;
|
text-shadow:none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.sm-dox ul.sm-nowrap a {
|
.sm-dox ul.sm-nowrap a {
|
||||||
color:@default-text-color;
|
color:$default-text-color;
|
||||||
text-shadow:none;
|
text-shadow:none;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,27 +128,32 @@ div.headertitle,.note code,.pre code,.post code,.invariant code,.warning code,.a
|
|||||||
}
|
}
|
||||||
|
|
||||||
html,#titlearea,.footer,tr.even,.directory tr.even,.doxtable tr:nth-child(even),tr.markdownTableBody:nth-child(even),.mdescLeft,.mdescRight,.memItemLeft,.memItemRight,code,.markdownTableRowEven {
|
html,#titlearea,.footer,tr.even,.directory tr.even,.doxtable tr:nth-child(even),tr.markdownTableBody:nth-child(even),.mdescLeft,.mdescRight,.memItemLeft,.memItemRight,code,.markdownTableRowEven {
|
||||||
background:@header-footer-background-color;
|
background:$header-footer-background-color;
|
||||||
}
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
color:@default-text-color;
|
color:$default-text-color;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.title {
|
||||||
|
font-size: 170%;
|
||||||
|
margin: 1em 0 0.5em 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
h1,h2,h2.groupheader,h3,div.toc h3,h4,h5,h6,strong,em {
|
h1,h2,h2.groupheader,h3,div.toc h3,h4,h5,h6,strong,em {
|
||||||
color:@heading-color;
|
color:$heading-color;
|
||||||
border-bottom:none;
|
border-bottom:none;
|
||||||
}
|
}
|
||||||
|
|
||||||
h1 {
|
h1 {
|
||||||
padding-top:0.5em;
|
padding-top:0.5em;
|
||||||
font-size:180%;
|
font-size:150%;
|
||||||
}
|
}
|
||||||
|
|
||||||
h2 {
|
h2 {
|
||||||
padding-top:0.5em;
|
padding-top:0.5em;
|
||||||
margin-bottom:0;
|
margin-bottom:0;
|
||||||
font-size:140%;
|
font-size:130%;
|
||||||
}
|
}
|
||||||
|
|
||||||
h3 {
|
h3 {
|
||||||
@ -159,24 +164,30 @@ h3 {
|
|||||||
|
|
||||||
.glfwheader {
|
.glfwheader {
|
||||||
font-size:16px;
|
font-size:16px;
|
||||||
height:64px;
|
min-height:64px;
|
||||||
max-width:920px;
|
max-width:920px;
|
||||||
min-width:800px;
|
|
||||||
padding:0 32px;
|
padding:0 32px;
|
||||||
margin:0 auto;
|
margin:0 auto;
|
||||||
|
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
justify-content: flex-start;
|
||||||
|
align-items: center;
|
||||||
|
align-content: stretch;
|
||||||
}
|
}
|
||||||
|
|
||||||
#glfwhome {
|
#glfwhome {
|
||||||
line-height:64px;
|
line-height:64px;
|
||||||
padding-right:48px;
|
padding-right:48px;
|
||||||
color:@header-footer-link-color;
|
color:$header-footer-link-color;
|
||||||
font-size:2.5em;
|
font-size:2.5em;
|
||||||
background:url("https://www.glfw.org/css/arrow.png") no-repeat right;
|
background:url("https://www.glfw.org/css/arrow.png") no-repeat right;
|
||||||
}
|
}
|
||||||
|
|
||||||
.glfwnavbar {
|
.glfwnavbar {
|
||||||
list-style-type:none;
|
list-style-type:none;
|
||||||
margin:0 auto;
|
margin:0 0 0 auto;
|
||||||
float:right;
|
float:right;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -188,7 +199,11 @@ h3 {
|
|||||||
line-height:64px;
|
line-height:64px;
|
||||||
margin-left:2em;
|
margin-left:2em;
|
||||||
display:block;
|
display:block;
|
||||||
color:@header-footer-link-color;
|
color:$header-footer-link-color;
|
||||||
|
}
|
||||||
|
|
||||||
|
.glfwnavbar {
|
||||||
|
padding-left: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#glfwhome,.glfwnavbar a,.glfwnavbar a:visited {
|
#glfwhome,.glfwnavbar a,.glfwnavbar a:visited {
|
||||||
@ -196,7 +211,7 @@ h3 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#titlearea,.footer {
|
#titlearea,.footer {
|
||||||
color:@header-footer-link-color;
|
color:$header-footer-link-color;
|
||||||
}
|
}
|
||||||
|
|
||||||
address.footer {
|
address.footer {
|
||||||
@ -206,19 +221,17 @@ address.footer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#top {
|
#top {
|
||||||
background:@header-footer-link-color;
|
background:$header-footer-link-color;
|
||||||
}
|
}
|
||||||
|
|
||||||
#main-nav {
|
#main-nav {
|
||||||
max-width:960px;
|
max-width:960px;
|
||||||
min-width:800px;
|
|
||||||
margin:0 auto;
|
margin:0 auto;
|
||||||
font-size:13px;
|
font-size:13px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#main-menu {
|
#main-menu {
|
||||||
max-width:920px;
|
max-width:920px;
|
||||||
min-width:800px;
|
|
||||||
margin:0 auto;
|
margin:0 auto;
|
||||||
font-size:13px;
|
font-size:13px;
|
||||||
}
|
}
|
||||||
@ -233,21 +246,29 @@ address.footer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#main-menu {
|
#main-menu {
|
||||||
height:36px;
|
min-height:36px;
|
||||||
display:block;
|
display: flex;
|
||||||
position:relative;
|
flex-direction: row;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
justify-content: flex-start;
|
||||||
|
align-items: center;
|
||||||
|
align-content: stretch;
|
||||||
}
|
}
|
||||||
|
|
||||||
#main-menu a,#main-menu a:visited,#main-menu a:hover,#main-menu li {
|
#main-menu a,#main-menu a:visited,#main-menu a:hover,#main-menu li {
|
||||||
color:@navbar-link-color;
|
color:$navbar-link-color;
|
||||||
}
|
}
|
||||||
|
|
||||||
#main-menu li ul.sm-nowrap li a {
|
#main-menu li ul.sm-nowrap li a {
|
||||||
color:@default-text-color;
|
color:$default-text-color;
|
||||||
}
|
}
|
||||||
|
|
||||||
#main-menu li ul.sm-nowrap li a:hover {
|
#main-menu li ul.sm-nowrap li a:hover {
|
||||||
color:@default-link-color;
|
color:$default-link-color;
|
||||||
|
}
|
||||||
|
|
||||||
|
#main-menu > li:last-child {
|
||||||
|
margin: 0 0 0 auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.contents {
|
.contents {
|
||||||
@ -258,27 +279,35 @@ div.contents,div.header {
|
|||||||
max-width:920px;
|
max-width:920px;
|
||||||
margin:0 auto;
|
margin:0 auto;
|
||||||
padding:0 32px;
|
padding:0 32px;
|
||||||
background:@content-background-color none;
|
background:$content-background-color none;
|
||||||
}
|
}
|
||||||
|
|
||||||
table.doxtable th,table.markdownTable th,dl.reflist dt {
|
table.doxtable th,table.markdownTable th,dl.reflist dt {
|
||||||
background:linear-gradient(to bottom,@table-background-color2 0%,@table-background-color1 100%);
|
background:linear-gradient(to bottom,$table-background-color2 0%,$table-background-color1 100%);
|
||||||
box-shadow:inset 0 0 32px @table-background-color1;
|
box-shadow:inset 0 0 32px $table-background-color1;
|
||||||
text-shadow:0 -1px 1px darken(@table-background-color1, 15%);
|
text-shadow:0 -1px 1px darken($table-background-color1, 15%);
|
||||||
text-align:left;
|
text-align:left;
|
||||||
color:@table-text-color;
|
color:$table-text-color;
|
||||||
}
|
}
|
||||||
|
|
||||||
dl.reflist dt a.el {
|
dl.reflist dt a.el {
|
||||||
color:@default-link-color;
|
color:$default-link-color;
|
||||||
padding:.2em;
|
padding:.2em;
|
||||||
border-radius:4px;
|
border-radius:4px;
|
||||||
background-color:lighten(@default-link-color, 40%);
|
background-color:lighten($default-link-color, 40%);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
div.toc {
|
||||||
|
float:right;
|
||||||
|
width:35%;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media screen and (max-width:600px) {
|
||||||
div.toc {
|
div.toc {
|
||||||
float:none;
|
float:none;
|
||||||
width:auto;
|
width:inherit;
|
||||||
|
margin:0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
div.toc h3 {
|
div.toc h3 {
|
||||||
@ -295,28 +324,34 @@ div.toc li {
|
|||||||
list-style-type:disc;
|
list-style-type:disc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
div.toc {
|
||||||
|
li.level2, li.level3 {
|
||||||
|
margin-left:0.5em;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
div.toc,.memproto,div.qindex,div.ah {
|
div.toc,.memproto,div.qindex,div.ah {
|
||||||
background:linear-gradient(to bottom,@toc-background-color2 0%,@toc-background-color1 100%);
|
background:linear-gradient(to bottom,$toc-background-color2 0%,$toc-background-color1 100%);
|
||||||
box-shadow:inset 0 0 32px @toc-background-color1;
|
box-shadow:inset 0 0 32px $toc-background-color1;
|
||||||
text-shadow:0 1px 1px lighten(@toc-background-color2, 10%);
|
text-shadow:0 1px 1px lighten($toc-background-color2, 10%);
|
||||||
color:@heading-color;
|
color:$heading-color;
|
||||||
border:2px solid @toc-background-color1;
|
border:2px solid $toc-background-color1;
|
||||||
border-radius:4px;
|
border-radius:4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.paramname {
|
.paramname {
|
||||||
color:@prototype-param-color;
|
color:$prototype-param-color;
|
||||||
}
|
}
|
||||||
|
|
||||||
dl.reflist dt {
|
dl.reflist dt {
|
||||||
border:2px solid @default-border-color;
|
border:2px solid $default-border-color;
|
||||||
border-top-left-radius:4px;
|
border-top-left-radius:4px;
|
||||||
border-top-right-radius:4px;
|
border-top-right-radius:4px;
|
||||||
border-bottom:none;
|
border-bottom:none;
|
||||||
}
|
}
|
||||||
|
|
||||||
dl.reflist dd {
|
dl.reflist dd {
|
||||||
border:2px solid @default-border-color;
|
border:2px solid $default-border-color;
|
||||||
border-bottom-right-radius:4px;
|
border-bottom-right-radius:4px;
|
||||||
border-bottom-left-radius:4px;
|
border-bottom-left-radius:4px;
|
||||||
border-top:none;
|
border-top:none;
|
||||||
@ -325,41 +360,41 @@ dl.reflist dd {
|
|||||||
table.doxtable,table.markdownTable {
|
table.doxtable,table.markdownTable {
|
||||||
border-collapse:inherit;
|
border-collapse:inherit;
|
||||||
border-spacing:0;
|
border-spacing:0;
|
||||||
border:2px solid @default-border-color;
|
border:2px solid $default-border-color;
|
||||||
border-radius:4px;
|
border-radius:4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
a,a:hover,a:visited,a:visited:hover,.contents a:visited,.el,a.el:visited,#glfwhome:hover,#main-menu a:hover,span.lineno a:hover {
|
a,a:hover,a:visited,a:visited:hover,.contents a:visited,.el,a.el:visited,#glfwhome:hover,#main-menu a:hover,span.lineno a:hover {
|
||||||
color:@default-link-color;
|
color:$default-link-color;
|
||||||
text-decoration:none;
|
text-decoration:none;
|
||||||
}
|
}
|
||||||
|
|
||||||
div.directory {
|
div.directory {
|
||||||
border-collapse:inherit;
|
border-collapse:inherit;
|
||||||
border-spacing:0;
|
border-spacing:0;
|
||||||
border:2px solid @default-border-color;
|
border:2px solid $default-border-color;
|
||||||
border-radius:4px;
|
border-radius:4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
hr,.memSeparator {
|
hr,.memSeparator {
|
||||||
height:2px;
|
height:2px;
|
||||||
background:linear-gradient(to right,@def-separator-color 0%,darken(@def-separator-color, 10%) 50%,@def-separator-color 100%);
|
background:linear-gradient(to right,$def-separator-color 0%,darken($def-separator-color, 10%) 50%,$def-separator-color 100%);
|
||||||
}
|
}
|
||||||
|
|
||||||
dl.note,dl.pre,dl.post,dl.invariant {
|
dl.note,dl.pre,dl.post,dl.invariant {
|
||||||
.message-box(@box-note-color);
|
@include message-box($box-note-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
dl.warning,dl.attention {
|
dl.warning,dl.attention {
|
||||||
.message-box(@box-warning-color);
|
@include message-box($box-warning-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
dl.deprecated,dl.bug {
|
dl.deprecated,dl.bug {
|
||||||
.message-box(@box-bug-color);
|
@include message-box($box-bug-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
dl.todo,dl.test {
|
dl.todo,dl.test {
|
||||||
.message-box(@box-todo-color);
|
@include message-box($box-todo-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
dl.note,dl.pre,dl.post,dl.invariant,dl.warning,dl.attention,dl.deprecated,dl.bug,dl.todo,dl.test {
|
dl.note,dl.pre,dl.post,dl.invariant,dl.warning,dl.attention,dl.deprecated,dl.bug,dl.todo,dl.test {
|
||||||
@ -388,7 +423,7 @@ div.fragment,pre.fragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.lineno a,.lineno a:visited,.line,pre.fragment {
|
.lineno a,.lineno a:visited,.line,pre.fragment {
|
||||||
color:@default-text-color;
|
color:$default-text-color;
|
||||||
}
|
}
|
||||||
|
|
||||||
span.preprocessor,span.comment {
|
span.preprocessor,span.comment {
|
||||||
@ -400,7 +435,7 @@ a.code,a.code:visited {
|
|||||||
}
|
}
|
||||||
|
|
||||||
span.keyword,span.keywordtype,span.keywordflow {
|
span.keyword,span.keywordtype,span.keywordflow {
|
||||||
color:darken(@default-text-color, 5%);
|
color:darken($default-text-color, 5%);
|
||||||
font-weight:bold;
|
font-weight:bold;
|
||||||
}
|
}
|
||||||
|
|
@ -1,7 +1,8 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
<!DOCTYPE html>
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
|
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
|
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
|
||||||
<meta name="generator" content="Doxygen $doxygenversion"/>
|
<meta name="generator" content="Doxygen $doxygenversion"/>
|
||||||
<!--BEGIN PROJECT_NAME--><title>$projectname: $title</title><!--END PROJECT_NAME-->
|
<!--BEGIN PROJECT_NAME--><title>$projectname: $title</title><!--END PROJECT_NAME-->
|
||||||
|
@ -550,10 +550,10 @@ int present = glfwJoystickPresent(GLFW_JOYSTICK_1);
|
|||||||
Each joystick has zero or more axes, zero or more buttons, zero or more hats,
|
Each joystick has zero or more axes, zero or more buttons, zero or more hats,
|
||||||
a human-readable name, a user pointer and an SDL compatible GUID.
|
a human-readable name, a user pointer and an SDL compatible GUID.
|
||||||
|
|
||||||
When GLFW is initialized, detected joysticks are added to the beginning of
|
Detected joysticks are added to the beginning of the array. Once a joystick is
|
||||||
the array. Once a joystick is detected, it keeps its assigned ID until it is
|
detected, it keeps its assigned ID until it is disconnected or the library is
|
||||||
disconnected or the library is terminated, so as joysticks are connected and
|
terminated, so as joysticks are connected and disconnected, there may appear
|
||||||
disconnected, there may appear gaps in the IDs.
|
gaps in the IDs.
|
||||||
|
|
||||||
Joystick axis, button and hat state is updated when polled and does not require
|
Joystick axis, button and hat state is updated when polled and does not require
|
||||||
a window to be created or events to be processed. However, if you want joystick
|
a window to be created or events to be processed. However, if you want joystick
|
||||||
@ -648,7 +648,7 @@ const char* name = glfwGetJoystickName(GLFW_JOYSTICK_4);
|
|||||||
@endcode
|
@endcode
|
||||||
|
|
||||||
Joystick names are not guaranteed to be unique. Two joysticks of the same model
|
Joystick names are not guaranteed to be unique. Two joysticks of the same model
|
||||||
and make may have the same name. Only the [joystick token](@ref joysticks) is
|
and make may have the same name. Only the [joystick ID](@ref joysticks) is
|
||||||
guaranteed to be unique, and only until that joystick is disconnected.
|
guaranteed to be unique, and only until that joystick is disconnected.
|
||||||
|
|
||||||
|
|
||||||
@ -797,6 +797,11 @@ glfwUpdateGamepadMappings(mappings);
|
|||||||
This function supports everything from single lines up to and including the
|
This function supports everything from single lines up to and including the
|
||||||
unmodified contents of the whole `gamecontrollerdb.txt` file.
|
unmodified contents of the whole `gamecontrollerdb.txt` file.
|
||||||
|
|
||||||
|
If you are compiling GLFW from source with CMake you can update the built-in mappings by
|
||||||
|
building the _update_mappings_ target. This runs the `GenerateMappings.cmake` CMake
|
||||||
|
script, which downloads `gamecontrollerdb.txt` and regenerates the `mappings.h` header
|
||||||
|
file.
|
||||||
|
|
||||||
Below is a description of the mapping format. Please keep in mind that __this
|
Below is a description of the mapping format. Please keep in mind that __this
|
||||||
description is not authoritative__. The format is defined by the SDL and
|
description is not authoritative__. The format is defined by the SDL and
|
||||||
SDL_GameControllerDB projects and their documentation and code takes precedence.
|
SDL_GameControllerDB projects and their documentation and code takes precedence.
|
||||||
|
@ -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
|
platform-independent part of the internal structs. Instead, it calls the event
|
||||||
interface when events interesting to GLFW are received.
|
interface when events interesting to GLFW are received.
|
||||||
|
|
||||||
The platform interface mirrors those parts of the public interface that needs to
|
The platform interface mostly mirrors those parts of the public interface that needs to
|
||||||
perform platform-specific operations on some or all platforms. The are also
|
perform platform-specific operations on some or all platforms.
|
||||||
named the same except that the glfw function prefix is replaced by
|
|
||||||
_glfwPlatform.
|
|
||||||
|
|
||||||
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
|
The platform interface also defines structs that contain platform-specific
|
||||||
global and per-object state. Their names mirror those of the internal
|
global and per-object state. Their names mirror those of the internal
|
||||||
@ -104,8 +113,7 @@ Examples: `isValidElementForJoystick`
|
|||||||
@section internals_config Configuration macros
|
@section internals_config Configuration macros
|
||||||
|
|
||||||
GLFW uses a number of configuration macros to select at compile time which
|
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,
|
interfaces and code paths to use. They are defined in the GLFW CMake target.
|
||||||
which is generated from the `glfw_config.h.in` file by CMake.
|
|
||||||
|
|
||||||
Configuration macros the same style as tokens in the public interface, except
|
Configuration macros the same style as tokens in the public interface, except
|
||||||
with a leading underscore.
|
with a leading underscore.
|
||||||
|
182
docs/intro.dox
182
docs/intro.dox
@ -22,17 +22,20 @@ There are also guides for the other areas of GLFW.
|
|||||||
|
|
||||||
Before most GLFW functions may be called, the library must be initialized.
|
Before most GLFW functions may be called, the library must be initialized.
|
||||||
This initialization checks what features are available on the machine,
|
This initialization checks what features are available on the machine,
|
||||||
enumerates monitors and joysticks, initializes the timer and performs any
|
enumerates monitors, initializes the timer and performs any required
|
||||||
required platform-specific initialization.
|
platform-specific initialization.
|
||||||
|
|
||||||
Only the following functions may be called before the library has been
|
Only the following functions may be called before the library has been
|
||||||
successfully initialized, and only from the main thread.
|
successfully initialized, and only from the main thread.
|
||||||
|
|
||||||
- @ref glfwGetVersion
|
- @ref glfwGetVersion
|
||||||
- @ref glfwGetVersionString
|
- @ref glfwGetVersionString
|
||||||
|
- @ref glfwPlatformSupported
|
||||||
- @ref glfwGetError
|
- @ref glfwGetError
|
||||||
- @ref glfwSetErrorCallback
|
- @ref glfwSetErrorCallback
|
||||||
- @ref glfwInitHint
|
- @ref glfwInitHint
|
||||||
|
- @ref glfwInitAllocator
|
||||||
|
- @ref glfwInitVulkanLoader
|
||||||
- @ref glfwInit
|
- @ref glfwInit
|
||||||
- @ref glfwTerminate
|
- @ref glfwTerminate
|
||||||
|
|
||||||
@ -88,10 +91,33 @@ Setting these hints requires no platform specific headers or functions.
|
|||||||
|
|
||||||
@subsubsection init_hints_shared Shared init hints
|
@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
|
@anchor GLFW_JOYSTICK_HAT_BUTTONS
|
||||||
__GLFW_JOYSTICK_HAT_BUTTONS__ specifies whether to also expose joystick hats as
|
__GLFW_JOYSTICK_HAT_BUTTONS__ specifies whether to also expose joystick hats as
|
||||||
buttons, for compatibility with earlier versions of GLFW that did not have @ref
|
buttons, for compatibility with earlier versions of GLFW that did not have @ref
|
||||||
glfwGetJoystickHats. Set this with @ref glfwInitHint.
|
glfwGetJoystickHats. Possible values are `GLFW_TRUE` and `GLFW_FALSE`.
|
||||||
|
|
||||||
|
@anchor GLFW_ANGLE_PLATFORM_TYPE_hint
|
||||||
|
__GLFW_ANGLE_PLATFORM_TYPE__ specifies the platform type (rendering backend) to
|
||||||
|
request when using OpenGL ES and EGL via
|
||||||
|
[ANGLE](https://chromium.googlesource.com/angle/angle/). If the requested
|
||||||
|
platform type is unavailable, ANGLE will use its default. Possible values are
|
||||||
|
one of `GLFW_ANGLE_PLATFORM_TYPE_NONE`, `GLFW_ANGLE_PLATFORM_TYPE_OPENGL`,
|
||||||
|
`GLFW_ANGLE_PLATFORM_TYPE_OPENGLES`, `GLFW_ANGLE_PLATFORM_TYPE_D3D9`,
|
||||||
|
`GLFW_ANGLE_PLATFORM_TYPE_D3D11`, `GLFW_ANGLE_PLATFORM_TYPE_VULKAN` and
|
||||||
|
`GLFW_ANGLE_PLATFORM_TYPE_METAL`.
|
||||||
|
|
||||||
|
The ANGLE platform type is specified via the `EGL_ANGLE_platform_angle`
|
||||||
|
extension. This extension is not used if this hint is
|
||||||
|
`GLFW_ANGLE_PLATFORM_TYPE_NONE`, which is the default value.
|
||||||
|
|
||||||
|
|
||||||
@subsubsection init_hints_osx macOS specific init hints
|
@subsubsection init_hints_osx macOS specific init hints
|
||||||
@ -99,21 +125,135 @@ glfwGetJoystickHats. Set this with @ref glfwInitHint.
|
|||||||
@anchor GLFW_COCOA_CHDIR_RESOURCES_hint
|
@anchor GLFW_COCOA_CHDIR_RESOURCES_hint
|
||||||
__GLFW_COCOA_CHDIR_RESOURCES__ specifies whether to set the current directory to
|
__GLFW_COCOA_CHDIR_RESOURCES__ specifies whether to set the current directory to
|
||||||
the application to the `Contents/Resources` subdirectory of the application's
|
the application to the `Contents/Resources` subdirectory of the application's
|
||||||
bundle, if present. Set this with @ref glfwInitHint.
|
bundle, if present. Possible values are `GLFW_TRUE` and `GLFW_FALSE`. This is
|
||||||
|
ignored on other platforms.
|
||||||
|
|
||||||
@anchor GLFW_COCOA_MENUBAR_hint
|
@anchor GLFW_COCOA_MENUBAR_hint
|
||||||
__GLFW_COCOA_MENUBAR__ specifies whether to create the menu bar and dock icon
|
__GLFW_COCOA_MENUBAR__ specifies whether to create the menu bar and dock icon
|
||||||
when GLFW is initialized. This applies whether the menu bar is created from
|
when GLFW is initialized. This applies whether the menu bar is created from
|
||||||
a nib or manually by GLFW. Set this with @ref glfwInitHint.
|
a nib or manually by GLFW. Possible values are `GLFW_TRUE` and `GLFW_FALSE`.
|
||||||
|
This is ignored on other platforms.
|
||||||
|
|
||||||
|
|
||||||
|
@subsubsection init_hints_x11 X11 specific init hints
|
||||||
|
|
||||||
|
@anchor GLFW_X11_XCB_VULKAN_SURFACE_hint
|
||||||
|
__GLFW_X11_XCB_VULKAN_SURFACE__ specifies whether to prefer the
|
||||||
|
`VK_KHR_xcb_surface` extension for creating Vulkan surfaces, or whether to use
|
||||||
|
the `VK_KHR_xlib_surface` extension. Possible values are `GLFW_TRUE` and
|
||||||
|
`GLFW_FALSE`. This is ignored on other platforms.
|
||||||
|
|
||||||
|
|
||||||
@subsubsection init_hints_values Supported and default values
|
@subsubsection init_hints_values Supported and default values
|
||||||
|
|
||||||
Initialization hint | Default value | Supported values
|
Initialization hint | Default value | Supported values
|
||||||
------------------------------- | ------------- | ----------------
|
-------------------------------- | ------------------------------- | ----------------
|
||||||
|
@ref GLFW_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_JOYSTICK_HAT_BUTTONS | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE`
|
||||||
|
@ref GLFW_ANGLE_PLATFORM_TYPE | `GLFW_ANGLE_PLATFORM_TYPE_NONE` | `GLFW_ANGLE_PLATFORM_TYPE_NONE`, `GLFW_ANGLE_PLATFORM_TYPE_OPENGL`, `GLFW_ANGLE_PLATFORM_TYPE_OPENGLES`, `GLFW_ANGLE_PLATFORM_TYPE_D3D9`, `GLFW_ANGLE_PLATFORM_TYPE_D3D11`, `GLFW_ANGLE_PLATFORM_TYPE_VULKAN` or `GLFW_ANGLE_PLATFORM_TYPE_METAL`
|
||||||
@ref GLFW_COCOA_CHDIR_RESOURCES | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE`
|
@ref GLFW_COCOA_CHDIR_RESOURCES | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE`
|
||||||
@ref GLFW_COCOA_MENUBAR | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE`
|
@ref GLFW_COCOA_MENUBAR | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE`
|
||||||
|
@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
|
||||||
|
glfwInitAllocator.
|
||||||
|
|
||||||
|
@code
|
||||||
|
GLFWallocator allocator;
|
||||||
|
allocator.allocate = my_malloc;
|
||||||
|
allocator.reallocate = my_realloc;
|
||||||
|
allocator.deallocate = my_free;
|
||||||
|
allocator.user = NULL;
|
||||||
|
|
||||||
|
glfwInitAllocator(&allocator);
|
||||||
|
@endcode
|
||||||
|
|
||||||
|
The allocator will be picked up at the beginning of initialization and will be
|
||||||
|
used until GLFW has been fully terminated. Any allocator set after
|
||||||
|
initialization will be picked up only at the next initialization.
|
||||||
|
|
||||||
|
The allocator will only be used for allocations that would have been made with
|
||||||
|
the C standard library. Memory allocations that must be made with platform
|
||||||
|
specific APIs will still use those.
|
||||||
|
|
||||||
|
The allocation function must have a signature matching @ref GLFWallocatefun. It receives
|
||||||
|
the desired size, in bytes, and the user pointer passed to @ref glfwInitAllocator and
|
||||||
|
returns the address to the allocated memory block.
|
||||||
|
|
||||||
|
@code
|
||||||
|
void* my_malloc(size_t size, void* user)
|
||||||
|
{
|
||||||
|
...
|
||||||
|
}
|
||||||
|
@endcode
|
||||||
|
|
||||||
|
The reallocation function must have a function signature matching @ref GLFWreallocatefun.
|
||||||
|
It receives the memory block to be reallocated, the new desired size, in bytes, and the user
|
||||||
|
pointer passed to @ref glfwInitAllocator and returns the address to the resized memory
|
||||||
|
block.
|
||||||
|
|
||||||
|
@code
|
||||||
|
void* my_realloc(void* block, size_t size, void* user)
|
||||||
|
{
|
||||||
|
...
|
||||||
|
}
|
||||||
|
@endcode
|
||||||
|
|
||||||
|
The deallocation function must have a function signature matching @ref GLFWdeallocatefun.
|
||||||
|
It receives the memory block to be deallocated and the user pointer passed to @ref
|
||||||
|
glfwInitAllocator.
|
||||||
|
|
||||||
|
@code
|
||||||
|
void my_free(void* block, void* user)
|
||||||
|
{
|
||||||
|
...
|
||||||
|
}
|
||||||
|
@endcode
|
||||||
|
|
||||||
|
|
||||||
@subsection intro_init_terminate Terminating GLFW
|
@subsection intro_init_terminate Terminating GLFW
|
||||||
@ -351,6 +491,11 @@ Library version information may be queried from any thread.
|
|||||||
- @ref glfwGetVersion
|
- @ref glfwGetVersion
|
||||||
- @ref glfwGetVersionString
|
- @ref glfwGetVersionString
|
||||||
|
|
||||||
|
Platform information may be queried from any thread.
|
||||||
|
|
||||||
|
- @ref glfwPlatformSupported
|
||||||
|
- @ref glfwGetPlatform
|
||||||
|
|
||||||
All Vulkan related functions may be called from any thread.
|
All Vulkan related functions may be called from any thread.
|
||||||
|
|
||||||
- @ref glfwVulkanSupported
|
- @ref glfwVulkanSupported
|
||||||
@ -443,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
|
glfwGetVersion function already provides the version of the running library
|
||||||
binary.
|
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 format of the string is as follows:
|
||||||
- The version of GLFW
|
- The version of GLFW
|
||||||
|
- For each supported platform:
|
||||||
- The name of the window system API
|
- The name of the window system API
|
||||||
- The name of the context creation API
|
- The name of the window system specific context creation API, if applicable
|
||||||
- Any additional options or APIs
|
- 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
|
For example, GLFW 3.4 compiled as a DLL for Windows with MinGW may have a version string
|
||||||
back ends, the version string may look something like this:
|
like this:
|
||||||
|
|
||||||
@code
|
@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
|
@endcode
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
@ -362,8 +362,8 @@ should be using the character callback instead, on both GLFW 2 and 3. This will
|
|||||||
give you the characters being input, as opposed to the keys being pressed.
|
give you the characters being input, as opposed to the keys being pressed.
|
||||||
|
|
||||||
GLFW 3 has key tokens for all keys on a standard 105 key keyboard, so instead of
|
GLFW 3 has key tokens for all keys on a standard 105 key keyboard, so instead of
|
||||||
having to remember whether to check for `'a'` or `'A'`, you now check for
|
having to remember whether to check for `a` or `A`, you now check for
|
||||||
`GLFW_KEY_A`.
|
@ref GLFW_KEY_A.
|
||||||
|
|
||||||
|
|
||||||
@subsection moving_joystick Joystick function changes
|
@subsection moving_joystick Joystick function changes
|
||||||
|
140
docs/news.dox
140
docs/news.dox
@ -9,6 +9,14 @@
|
|||||||
|
|
||||||
@subsection features_34 New features in version 3.4
|
@subsection features_34 New features in version 3.4
|
||||||
|
|
||||||
|
@subsubsection runtime_platform_34 Runtime platform selection
|
||||||
|
|
||||||
|
GLFW now supports being compiled for multiple backends and selecting between
|
||||||
|
them at runtime with the @ref GLFW_PLATFORM init hint. After initialization the
|
||||||
|
selected platform can be queried with @ref glfwGetPlatform. You can check if
|
||||||
|
support for a given platform is compiled in with @ref glfwPlatformSupported.
|
||||||
|
|
||||||
|
|
||||||
@subsubsection standard_cursors_34 More standard cursors
|
@subsubsection standard_cursors_34 More standard cursors
|
||||||
|
|
||||||
GLFW now provides the standard cursor shapes @ref GLFW_RESIZE_NWSE_CURSOR and
|
GLFW now provides the standard cursor shapes @ref GLFW_RESIZE_NWSE_CURSOR and
|
||||||
@ -27,6 +35,33 @@ are still available.
|
|||||||
For more information see @ref cursor_standard.
|
For more information see @ref cursor_standard.
|
||||||
|
|
||||||
|
|
||||||
|
@subsubsection mouse_passthrough_34 Mouse event passthrough
|
||||||
|
|
||||||
|
GLFW now provides the [GLFW_MOUSE_PASSTHROUGH](@ref GLFW_MOUSE_PASSTHROUGH_hint)
|
||||||
|
window hint for making a window transparent to mouse input, lettings events pass
|
||||||
|
to whatever window is behind it. This can also be changed after window
|
||||||
|
creation with the matching [window attribute](@ref GLFW_MOUSE_PASSTHROUGH_attrib).
|
||||||
|
|
||||||
|
|
||||||
|
@subsubsection features_34_angle_backend Support for ANGLE rendering backend selection
|
||||||
|
|
||||||
|
GLFW now provides the
|
||||||
|
[GLFW_ANGLE_PLATFORM_TYPE](@ref GLFW_ANGLE_PLATFORM_TYPE_hint) init hint for
|
||||||
|
requesting a specific rendering backend when using
|
||||||
|
[ANGLE](https://chromium.googlesource.com/angle/angle/) to create OpenGL ES
|
||||||
|
contexts.
|
||||||
|
|
||||||
|
|
||||||
|
@subsubsection features_34_init_allocator Support for custom memory allocator
|
||||||
|
|
||||||
|
GLFW now supports plugging a custom memory allocator at initialization with @ref
|
||||||
|
glfwInitAllocator. The allocator is a struct of type @ref GLFWallocator with
|
||||||
|
function pointers corresponding to the standard library functions `malloc`,
|
||||||
|
`realloc` and `free`.
|
||||||
|
|
||||||
|
For more information see @ref init_allocator.
|
||||||
|
|
||||||
|
|
||||||
@subsubsection features_34_win32_keymenu Support for keyboard access to Windows window menu
|
@subsubsection features_34_win32_keymenu Support for keyboard access to Windows window menu
|
||||||
|
|
||||||
GLFW now provides the
|
GLFW now provides the
|
||||||
@ -36,7 +71,38 @@ Alt-and-then-Space shortcuts. This may be useful for more GUI-oriented
|
|||||||
applications.
|
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
|
||||||
|
|
||||||
|
The joystick part of GLFW is now initialized when first used, primarily to work
|
||||||
|
around faulty Windows drivers that cause DirectInput to take up to several
|
||||||
|
seconds to enumerate devices.
|
||||||
|
|
||||||
|
This change will usually not be observable. However, if your application waits
|
||||||
|
for events without having first called any joystick function or created any
|
||||||
|
visible windows, the wait may never unblock as GLFW may not yet have subscribed
|
||||||
|
to joystick related OS events.
|
||||||
|
|
||||||
|
To work around this, call any joystick function before waiting for events, for
|
||||||
|
example by setting a [joystick callback](@ref joystick_event).
|
||||||
|
|
||||||
|
|
||||||
@subsubsection standalone_34 Tests and examples are disabled when built as a sub-project
|
@subsubsection standalone_34 Tests and examples are disabled when built as a sub-project
|
||||||
|
|
||||||
@ -65,25 +131,97 @@ GLFW no longer depends on the CoreVideo framework on macOS and it no longer
|
|||||||
needs to be specified during compilation or linking.
|
needs to be specified during compilation or linking.
|
||||||
|
|
||||||
|
|
||||||
|
@subsubsection caveat_fbtransparency_34 Framebuffer transparency requires DWM transparency
|
||||||
|
|
||||||
|
GLFW no longer supports framebuffer transparency enabled via @ref
|
||||||
|
GLFW_TRANSPARENT_FRAMEBUFFER on Windows 7 if DWM transparency is off
|
||||||
|
(the Transparency setting under Personalization > Window Color).
|
||||||
|
|
||||||
|
|
||||||
@subsection deprecations_34 Deprecations in version 3.4
|
@subsection deprecations_34 Deprecations in version 3.4
|
||||||
|
|
||||||
@subsection removals_34 Removals in 3.4
|
@subsection removals_34 Removals in 3.4
|
||||||
|
|
||||||
|
@subsubsection 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
|
||||||
|
the XDG-Shell protocol. If your Wayland compositor does not support XDG-Shell
|
||||||
|
then GLFW will fail to initialize.
|
||||||
|
|
||||||
|
|
||||||
@subsection symbols_34 New symbols in version 3.4
|
@subsection symbols_34 New symbols in version 3.4
|
||||||
|
|
||||||
@subsubsection functions_34 New functions in version 3.4
|
@subsubsection functions_34 New functions in version 3.4
|
||||||
|
|
||||||
|
- @ref glfwInitAllocator
|
||||||
|
- @ref glfwGetPlatform
|
||||||
|
- @ref glfwPlatformSupported
|
||||||
|
- @ref glfwInitVulkanLoader
|
||||||
|
|
||||||
|
|
||||||
@subsubsection types_34 New types in version 3.4
|
@subsubsection types_34 New types in version 3.4
|
||||||
|
|
||||||
|
- @ref GLFWallocator
|
||||||
|
- @ref GLFWallocatefun
|
||||||
|
- @ref GLFWreallocatefun
|
||||||
|
- @ref GLFWdeallocatefun
|
||||||
|
|
||||||
|
|
||||||
@subsubsection constants_34 New constants in version 3.4
|
@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_POINTING_HAND_CURSOR
|
||||||
- @ref GLFW_RESIZE_EW_CURSOR
|
- @ref GLFW_RESIZE_EW_CURSOR
|
||||||
- @ref GLFW_RESIZE_NS_CURSOR
|
- @ref GLFW_RESIZE_NS_CURSOR
|
||||||
- @ref GLFW_RESIZE_NWSE_CURSOR
|
- @ref GLFW_RESIZE_NWSE_CURSOR
|
||||||
- @ref GLFW_RESIZE_NESW_CURSOR
|
- @ref GLFW_RESIZE_NESW_CURSOR
|
||||||
- @ref GLFW_RESIZE_ALL_CURSOR
|
- @ref GLFW_RESIZE_ALL_CURSOR
|
||||||
|
- @ref GLFW_MOUSE_PASSTHROUGH
|
||||||
- @ref GLFW_NOT_ALLOWED_CURSOR
|
- @ref GLFW_NOT_ALLOWED_CURSOR
|
||||||
- @ref GLFW_CURSOR_UNAVAILABLE
|
- @ref GLFW_CURSOR_UNAVAILABLE
|
||||||
- @ref GLFW_WIN32_KEYBOARD_MENU
|
- @ref GLFW_WIN32_KEYBOARD_MENU
|
||||||
|
- @ref GLFW_CONTEXT_DEBUG
|
||||||
|
- @ref GLFW_FEATURE_UNAVAILABLE
|
||||||
|
- @ref GLFW_FEATURE_UNIMPLEMENTED
|
||||||
|
- @ref GLFW_ANGLE_PLATFORM_TYPE
|
||||||
|
- @ref GLFW_ANGLE_PLATFORM_TYPE_NONE
|
||||||
|
- @ref GLFW_ANGLE_PLATFORM_TYPE_OPENGL
|
||||||
|
- @ref GLFW_ANGLE_PLATFORM_TYPE_OPENGLES
|
||||||
|
- @ref GLFW_ANGLE_PLATFORM_TYPE_D3D9
|
||||||
|
- @ref GLFW_ANGLE_PLATFORM_TYPE_D3D11
|
||||||
|
- @ref GLFW_ANGLE_PLATFORM_TYPE_VULKAN
|
||||||
|
- @ref GLFW_ANGLE_PLATFORM_TYPE_METAL
|
||||||
|
- @ref GLFW_X11_XCB_VULKAN_SURFACE
|
||||||
|
|
||||||
|
|
||||||
@section news_archive Release notes for earlier versions
|
@section news_archive Release notes for earlier versions
|
||||||
|
@ -18,43 +18,42 @@ behave differently in GLFW 3.
|
|||||||
|
|
||||||
@subsection quick_include Including the GLFW header
|
@subsection quick_include Including the GLFW header
|
||||||
|
|
||||||
In the source files of your application where you use OpenGL or GLFW, you need
|
In the source files of your application where you use GLFW, you need to include
|
||||||
to include the GLFW 3 header file.
|
its header file.
|
||||||
|
|
||||||
@code
|
@code
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
@endcode
|
@endcode
|
||||||
|
|
||||||
This defines all the constants, types and function prototypes of the GLFW API.
|
This header provides all the constants, types and function prototypes of the
|
||||||
It also includes the OpenGL header from your development environment and
|
GLFW API.
|
||||||
defines all the constants and types necessary for it to work on your platform
|
|
||||||
without including any platform-specific headers.
|
|
||||||
|
|
||||||
In other words:
|
By default it also includes the OpenGL header from your development environment.
|
||||||
|
On some platforms this header only supports older versions of OpenGL. The most
|
||||||
|
extreme case is Windows, where it typically only supports OpenGL 1.2.
|
||||||
|
|
||||||
- Do _not_ include the OpenGL header yourself, as GLFW does this for you in
|
Most programs will instead use an
|
||||||
a platform-independent way
|
[extension loader library](@ref context_glext_auto) and include its header.
|
||||||
- Do _not_ include `windows.h` or other platform-specific headers unless
|
This example uses files generated by [glad](https://gen.glad.sh/). The GLFW
|
||||||
you plan on using those APIs yourself
|
header can detect most such headers if they are included first and will then not
|
||||||
- If you _do_ need to include such headers, include them _before_ the GLFW
|
include the one from your development environment.
|
||||||
header and it will detect this
|
|
||||||
|
|
||||||
On some platforms supported by GLFW the OpenGL header and link library only
|
|
||||||
expose older versions of OpenGL. The most extreme case is Windows, which only
|
|
||||||
exposes OpenGL 1.2. The easiest way to work around this is to use an
|
|
||||||
[extension loader library](@ref context_glext_auto).
|
|
||||||
|
|
||||||
If you are using such a library then you should include its header _before_ the
|
|
||||||
GLFW header. This lets it replace the OpenGL header included by GLFW without
|
|
||||||
conflicts. This example uses
|
|
||||||
[glad2](https://github.com/Dav1dde/glad), but the same rule applies to all such
|
|
||||||
libraries.
|
|
||||||
|
|
||||||
@code
|
@code
|
||||||
#include <glad/gl.h>
|
#include <glad/gl.h>
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
@endcode
|
@endcode
|
||||||
|
|
||||||
|
To make sure there will be no header conflicts, you can define @ref
|
||||||
|
GLFW_INCLUDE_NONE before the GLFW header to explicitly disable inclusion of the
|
||||||
|
development environment header. This also allows the two headers to be included
|
||||||
|
in any order.
|
||||||
|
|
||||||
|
@code
|
||||||
|
#define GLFW_INCLUDE_NONE
|
||||||
|
#include <GLFW/glfw3.h>
|
||||||
|
#include <glad/gl.h>
|
||||||
|
@endcode
|
||||||
|
|
||||||
|
|
||||||
@subsection quick_init_term Initializing and terminating GLFW
|
@subsection quick_init_term Initializing and terminating GLFW
|
||||||
|
|
||||||
@ -251,12 +250,16 @@ glViewport(0, 0, width, height);
|
|||||||
You can also set a framebuffer size callback using @ref
|
You can also set a framebuffer size callback using @ref
|
||||||
glfwSetFramebufferSizeCallback and be notified when the size changes.
|
glfwSetFramebufferSizeCallback and be notified when the size changes.
|
||||||
|
|
||||||
Actual rendering with OpenGL is outside the scope of this tutorial, but there
|
The details of how to render with OpenGL is outside the scope of this tutorial,
|
||||||
are [many](https://open.gl/) [excellent](https://learnopengl.com/)
|
but there are many excellent resources for learning modern OpenGL. Here are
|
||||||
[tutorial](http://openglbook.com/) [sites](http://ogldev.atspace.co.uk/) that
|
a few of them:
|
||||||
teach modern OpenGL. Some of them use GLFW to create the context and window
|
|
||||||
while others use GLUT or SDL, but remember that OpenGL itself always works the
|
- [Anton's OpenGL 4 Tutorials](https://antongerdelan.net/opengl/)
|
||||||
same.
|
- [Learn OpenGL](https://learnopengl.com/)
|
||||||
|
- [Open.GL](https://open.gl/)
|
||||||
|
|
||||||
|
These all happen to use GLFW, but OpenGL itself works the same whatever API you
|
||||||
|
use to create the window and context.
|
||||||
|
|
||||||
|
|
||||||
@subsection quick_timer Reading the timer
|
@subsection quick_timer Reading the timer
|
||||||
|
@ -4,8 +4,8 @@
|
|||||||
|
|
||||||
@tableofcontents
|
@tableofcontents
|
||||||
|
|
||||||
This guide is intended to fill the gaps between the [Vulkan
|
This guide is intended to fill the gaps between the official [Vulkan
|
||||||
documentation](https://www.khronos.org/vulkan/) and the rest of the GLFW
|
resources](https://www.khronos.org/vulkan/) and the rest of the GLFW
|
||||||
documentation and is not a replacement for either. It assumes some familiarity
|
documentation and is not a replacement for either. It assumes some familiarity
|
||||||
with Vulkan concepts like loaders, devices, queues and surfaces and leaves it to
|
with Vulkan concepts like loaders, devices, queues and surfaces and leaves it to
|
||||||
the Vulkan documentation to explain the details of Vulkan functions.
|
the Vulkan documentation to explain the details of Vulkan functions.
|
||||||
@ -14,7 +14,12 @@ To develop for Vulkan you should download the [LunarG Vulkan
|
|||||||
SDK](https://vulkan.lunarg.com/) for your platform. Apart from headers and link
|
SDK](https://vulkan.lunarg.com/) for your platform. Apart from headers and link
|
||||||
libraries, they also provide the validation layers necessary for development.
|
libraries, they also provide the validation layers necessary for development.
|
||||||
|
|
||||||
For details on a specific function in this category, see the @ref vulkan. There
|
The [Vulkan Tutorial](https://vulkan-tutorial.com/) has more information on how
|
||||||
|
to use GLFW and Vulkan. The [Khronos Vulkan
|
||||||
|
Samples](https://github.com/KhronosGroup/Vulkan-Samples) also use GLFW, although
|
||||||
|
with a small framework in between.
|
||||||
|
|
||||||
|
For details on a specific Vulkan support function, see the @ref vulkan. There
|
||||||
are also guides for the other areas of the GLFW API.
|
are also guides for the other areas of the GLFW API.
|
||||||
|
|
||||||
- @ref intro_guide
|
- @ref intro_guide
|
||||||
@ -24,28 +29,34 @@ are also guides for the other areas of the GLFW API.
|
|||||||
- @ref input_guide
|
- @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
|
GLFW itself does not ever need to be linked against the Vulkan loader.
|
||||||
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.
|
|
||||||
|
|
||||||
The @ref GLFW_VULKAN_STATIC CMake option makes GLFW call the Vulkan loader
|
By default, GLFW will load the Vulkan loader dynamically at runtime via its standard name:
|
||||||
directly instead of dynamically loading it at runtime. Not linking against the
|
`vulkan-1.dll` on Windows, `libvulkan.so.1` on Linux and other Unix-like systems and
|
||||||
Vulkan loader will then be a compile-time error.
|
`libvulkan.1.dylib` on macOS.
|
||||||
|
|
||||||
@macos Because the Vulkan loader and ICD are not installed globally on macOS,
|
@macos GLFW will also look up and search the executable subdirectory of your application
|
||||||
you need to set up the application bundle according to the LunarG SDK
|
bundle.
|
||||||
documentation. This is explained in more detail in the
|
|
||||||
|
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).
|
[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.
|
the GLFW header.
|
||||||
|
|
||||||
@code
|
@code
|
||||||
@ -61,8 +72,13 @@ your own custom Vulkan header then do this before the GLFW header.
|
|||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
@endcode
|
@endcode
|
||||||
|
|
||||||
Unless a Vulkan header is included, either by the GLFW header or above it, any
|
Unless a Vulkan header is included, either by the GLFW header or above it, the following
|
||||||
GLFW functions that take or return Vulkan types will not be declared.
|
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
|
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.
|
of GLFW to work. Define them only if you are using these extensions directly.
|
||||||
@ -88,7 +104,7 @@ if (glfwVulkanSupported())
|
|||||||
This function returns `GLFW_TRUE` if the Vulkan loader and any minimally
|
This function returns `GLFW_TRUE` if the Vulkan loader and any minimally
|
||||||
functional ICD was found.
|
functional ICD was found.
|
||||||
|
|
||||||
If if one or both were not found, calling any other Vulkan related GLFW function
|
If one or both were not found, calling any other Vulkan related GLFW function
|
||||||
will generate a @ref GLFW_API_UNAVAILABLE error.
|
will generate a @ref GLFW_API_UNAVAILABLE error.
|
||||||
|
|
||||||
|
|
||||||
|
158
docs/window.dox
158
docs/window.dox
@ -234,16 +234,10 @@ alpha channel will be used to combine the framebuffer with the background. This
|
|||||||
does not affect window decorations. Possible values are `GLFW_TRUE` and
|
does not affect window decorations. Possible values are `GLFW_TRUE` and
|
||||||
`GLFW_FALSE`.
|
`GLFW_FALSE`.
|
||||||
|
|
||||||
@par
|
|
||||||
@win32 GLFW sets a color key for the window to work around repainting issues
|
|
||||||
with a transparent framebuffer. The chosen color value is RGB 255,0,255
|
|
||||||
(magenta). This will make pixels with that exact color fully transparent
|
|
||||||
regardless of their alpha values. If this is a problem, make these pixels any
|
|
||||||
other color before buffer swap.
|
|
||||||
|
|
||||||
@anchor GLFW_FOCUS_ON_SHOW_hint
|
@anchor GLFW_FOCUS_ON_SHOW_hint
|
||||||
__GLFW_FOCUS_ON_SHOW__ specifies whether the window will be given input
|
__GLFW_FOCUS_ON_SHOW__ specifies whether the window will be given input
|
||||||
focus when @ref glfwShowWindow is called. Possible values are `GLFW_TRUE` and `GLFW_FALSE`.
|
focus when @ref glfwShowWindow is called. Possible values are `GLFW_TRUE` and
|
||||||
|
`GLFW_FALSE`.
|
||||||
|
|
||||||
@anchor GLFW_SCALE_TO_MONITOR
|
@anchor GLFW_SCALE_TO_MONITOR
|
||||||
__GLFW_SCALE_TO_MONITOR__ specified whether the window content area should be
|
__GLFW_SCALE_TO_MONITOR__ specified whether the window content area should be
|
||||||
@ -255,6 +249,13 @@ This hint only has an effect on platforms where screen coordinates and pixels
|
|||||||
always map 1:1 such as Windows and X11. On platforms like macOS the resolution
|
always map 1:1 such as Windows and X11. On platforms like macOS the resolution
|
||||||
of the framebuffer is changed independently of the window size.
|
of the framebuffer is changed independently of the window size.
|
||||||
|
|
||||||
|
@anchor GLFW_MOUSE_PASSTHROUGH_hint
|
||||||
|
__GLFW_MOUSE_PASSTHROUGH__ specifies whether the window is transparent to mouse
|
||||||
|
input, letting any mouse events pass through to whatever window is behind it.
|
||||||
|
This is only supported for undecorated windows. Decorated windows with this
|
||||||
|
enabled will behave differently between platforms. Possible values are
|
||||||
|
`GLFW_TRUE` and `GLFW_FALSE`.
|
||||||
|
|
||||||
|
|
||||||
@subsubsection window_hints_fb Framebuffer related hints
|
@subsubsection window_hints_fb Framebuffer related hints
|
||||||
|
|
||||||
@ -278,7 +279,6 @@ __GLFW_ACCUM_ALPHA_BITS__ specify the desired bit depths of the various
|
|||||||
components of the accumulation buffer. A value of `GLFW_DONT_CARE` means the
|
components of the accumulation buffer. A value of `GLFW_DONT_CARE` means the
|
||||||
application has no preference.
|
application has no preference.
|
||||||
|
|
||||||
@par
|
|
||||||
Accumulation buffers are a legacy OpenGL feature and should not be used in new
|
Accumulation buffers are a legacy OpenGL feature and should not be used in new
|
||||||
code.
|
code.
|
||||||
|
|
||||||
@ -286,7 +286,6 @@ code.
|
|||||||
__GLFW_AUX_BUFFERS__ specifies the desired number of auxiliary buffers. A value
|
__GLFW_AUX_BUFFERS__ specifies the desired number of auxiliary buffers. A value
|
||||||
of `GLFW_DONT_CARE` means the application has no preference.
|
of `GLFW_DONT_CARE` means the application has no preference.
|
||||||
|
|
||||||
@par
|
|
||||||
Auxiliary buffers are a legacy OpenGL feature and should not be used in new
|
Auxiliary buffers are a legacy OpenGL feature and should not be used in new
|
||||||
code.
|
code.
|
||||||
|
|
||||||
@ -303,16 +302,15 @@ the application has no preference.
|
|||||||
__GLFW_SRGB_CAPABLE__ specifies whether the framebuffer should be sRGB capable.
|
__GLFW_SRGB_CAPABLE__ specifies whether the framebuffer should be sRGB capable.
|
||||||
Possible values are `GLFW_TRUE` and `GLFW_FALSE`.
|
Possible values are `GLFW_TRUE` and `GLFW_FALSE`.
|
||||||
|
|
||||||
@par
|
@note __OpenGL:__ If enabled and supported by the system, the
|
||||||
__OpenGL:__ If enabled and supported by the system, the `GL_FRAMEBUFFER_SRGB`
|
`GL_FRAMEBUFFER_SRGB` enable will control sRGB rendering. By default, sRGB
|
||||||
enable will control sRGB rendering. By default, sRGB rendering will be
|
rendering will be disabled.
|
||||||
disabled.
|
|
||||||
|
|
||||||
@par
|
@note __OpenGL ES:__ If enabled and supported by the system, the context will
|
||||||
__OpenGL ES:__ If enabled and supported by the system, the context will always
|
always have sRGB rendering enabled.
|
||||||
have sRGB rendering enabled.
|
|
||||||
|
|
||||||
@anchor GLFW_DOUBLEBUFFER
|
@anchor GLFW_DOUBLEBUFFER
|
||||||
|
@anchor GLFW_DOUBLEBUFFER_hint
|
||||||
__GLFW_DOUBLEBUFFER__ specifies whether the framebuffer should be double
|
__GLFW_DOUBLEBUFFER__ specifies whether the framebuffer should be double
|
||||||
buffered. You nearly always want to use double buffering. This is a hard
|
buffered. You nearly always want to use double buffering. This is a hard
|
||||||
constraint. Possible values are `GLFW_TRUE` and `GLFW_FALSE`.
|
constraint. Possible values are `GLFW_TRUE` and `GLFW_FALSE`.
|
||||||
@ -339,28 +337,22 @@ create the context. Possible values are `GLFW_NATIVE_CONTEXT_API`,
|
|||||||
`GLFW_EGL_CONTEXT_API` and `GLFW_OSMESA_CONTEXT_API`. This is a hard
|
`GLFW_EGL_CONTEXT_API` and `GLFW_OSMESA_CONTEXT_API`. This is a hard
|
||||||
constraint. If no client API is requested, this hint is ignored.
|
constraint. If no client API is requested, this hint is ignored.
|
||||||
|
|
||||||
@par
|
An [extension loader library](@ref context_glext_auto) that assumes it knows
|
||||||
@macos The EGL API is not available on this platform and requests to use it
|
which API was used to create the current context may fail if you change this
|
||||||
will fail.
|
hint. This can be resolved by having it load functions via @ref
|
||||||
|
glfwGetProcAddress.
|
||||||
|
|
||||||
@par
|
@note @wayland The EGL API _is_ the native context creation API, so this hint
|
||||||
__Wayland:__ The EGL API _is_ the native context creation API, so this hint
|
|
||||||
will have no effect.
|
will have no effect.
|
||||||
|
|
||||||
@par
|
@note @x11 On some Linux systems, creating contexts via both the native and EGL
|
||||||
__OSMesa:__ As its name implies, an OpenGL context created with OSMesa does not
|
APIs in a single process will cause the application to segfault. Stick to one
|
||||||
update the window contents when its buffers are swapped. Use OpenGL functions
|
API or the other on Linux for now.
|
||||||
or the OSMesa native access functions @ref glfwGetOSMesaColorBuffer and @ref
|
|
||||||
glfwGetOSMesaDepthBuffer to retrieve the framebuffer contents.
|
|
||||||
|
|
||||||
@note An OpenGL extension loader library that assumes it knows which context
|
@note __OSMesa:__ As its name implies, an OpenGL context created with OSMesa
|
||||||
creation API is used on a given platform may fail if you change this hint. This
|
does not update the window contents when its buffers are swapped. Use OpenGL
|
||||||
can be resolved by having it load via @ref glfwGetProcAddress, which always uses
|
functions or the OSMesa native access functions @ref glfwGetOSMesaColorBuffer
|
||||||
the selected API.
|
and @ref glfwGetOSMesaDepthBuffer to retrieve the framebuffer contents.
|
||||||
|
|
||||||
@bug On some Linux systems, creating contexts via both the native and EGL APIs
|
|
||||||
in a single process will cause the application to segfault. Stick to one API or
|
|
||||||
the other on Linux for now.
|
|
||||||
|
|
||||||
@anchor GLFW_CONTEXT_VERSION_MAJOR_hint
|
@anchor GLFW_CONTEXT_VERSION_MAJOR_hint
|
||||||
@anchor GLFW_CONTEXT_VERSION_MINOR_hint
|
@anchor GLFW_CONTEXT_VERSION_MINOR_hint
|
||||||
@ -368,27 +360,24 @@ __GLFW_CONTEXT_VERSION_MAJOR__ and __GLFW_CONTEXT_VERSION_MINOR__ specify the
|
|||||||
client API version that the created context must be compatible with. The exact
|
client API version that the created context must be compatible with. The exact
|
||||||
behavior of these hints depend on the requested client API.
|
behavior of these hints depend on the requested client API.
|
||||||
|
|
||||||
@note Do not confuse these hints with `GLFW_VERSION_MAJOR` and
|
|
||||||
`GLFW_VERSION_MINOR`, which provide the API version of the GLFW header.
|
|
||||||
|
|
||||||
@par
|
|
||||||
__OpenGL:__ These hints are not hard constraints, but creation will fail if the
|
|
||||||
OpenGL version of the created context is less than the one requested. It is
|
|
||||||
therefore perfectly safe to use the default of version 1.0 for legacy code and
|
|
||||||
you will still get backwards-compatible contexts of version 3.0 and above when
|
|
||||||
available.
|
|
||||||
|
|
||||||
@par
|
|
||||||
While there is no way to ask the driver for a context of the highest supported
|
While there is no way to ask the driver for a context of the highest supported
|
||||||
version, GLFW will attempt to provide this when you ask for a version 1.0
|
version, GLFW will attempt to provide this when you ask for a version 1.0
|
||||||
context, which is the default for these hints.
|
context, which is the default for these hints.
|
||||||
|
|
||||||
@par
|
Do not confuse these hints with @ref GLFW_VERSION_MAJOR and @ref
|
||||||
__OpenGL ES:__ These hints are not hard constraints, but creation will fail if
|
GLFW_VERSION_MINOR, which provide the API version of the GLFW header.
|
||||||
the OpenGL ES version of the created context is less than the one requested.
|
|
||||||
Additionally, OpenGL ES 1.x cannot be returned if 2.0 or later was requested,
|
@note __OpenGL:__ These hints are not hard constraints, but creation will fail
|
||||||
and vice versa. This is because OpenGL ES 3.x is backward compatible with 2.0,
|
if the OpenGL version of the created context is less than the one requested. It
|
||||||
but OpenGL ES 2.0 is not backward compatible with 1.x.
|
is therefore perfectly safe to use the default of version 1.0 for legacy code
|
||||||
|
and you will still get backwards-compatible contexts of version 3.0 and above
|
||||||
|
when available.
|
||||||
|
|
||||||
|
@note __OpenGL ES:__ These hints are not hard constraints, but creation will
|
||||||
|
fail if the OpenGL ES version of the created context is less than the one
|
||||||
|
requested. Additionally, OpenGL ES 1.x cannot be returned if 2.0 or later was
|
||||||
|
requested, and vice versa. This is because OpenGL ES 3.x is backward compatible
|
||||||
|
with 2.0, but OpenGL ES 2.0 is not backward compatible with 1.x.
|
||||||
|
|
||||||
@note @macos The OS only supports core profile contexts for OpenGL versions 3.2
|
@note @macos The OS only supports core profile contexts for OpenGL versions 3.2
|
||||||
and later. Before creating an OpenGL context of version 3.2 or later you must
|
and later. Before creating an OpenGL context of version 3.2 or later you must
|
||||||
@ -401,15 +390,21 @@ forward-compatible, i.e. one where all functionality deprecated in the requested
|
|||||||
version of OpenGL is removed. This must only be used if the requested OpenGL
|
version of OpenGL is removed. This must only be used if the requested OpenGL
|
||||||
version is 3.0 or above. If OpenGL ES is requested, this hint is ignored.
|
version is 3.0 or above. If OpenGL ES is requested, this hint is ignored.
|
||||||
|
|
||||||
@par
|
|
||||||
Forward-compatibility is described in detail in the
|
Forward-compatibility is described in detail in the
|
||||||
[OpenGL Reference Manual](https://www.opengl.org/registry/).
|
[OpenGL Reference Manual](https://www.opengl.org/registry/).
|
||||||
|
|
||||||
|
@anchor GLFW_CONTEXT_DEBUG_hint
|
||||||
@anchor GLFW_OPENGL_DEBUG_CONTEXT_hint
|
@anchor GLFW_OPENGL_DEBUG_CONTEXT_hint
|
||||||
__GLFW_OPENGL_DEBUG_CONTEXT__ specifies whether to create a debug OpenGL
|
__GLFW_CONTEXT_DEBUG__ specifies whether the context should be created in debug
|
||||||
context, which may have additional error and performance issue reporting
|
mode, which may provide additional error and diagnostic reporting functionality.
|
||||||
functionality. Possible values are `GLFW_TRUE` and `GLFW_FALSE`. If OpenGL ES
|
Possible values are `GLFW_TRUE` and `GLFW_FALSE`.
|
||||||
is requested, this hint is ignored.
|
|
||||||
|
Debug contexts for OpenGL and OpenGL ES are described in detail by the
|
||||||
|
[GL_KHR_debug](https://www.khronos.org/registry/OpenGL/extensions/KHR/KHR_debug.txt)
|
||||||
|
extension.
|
||||||
|
|
||||||
|
@note `GLFW_CONTEXT_DEBUG` is the new name introduced in GLFW 3.4. The older
|
||||||
|
`GLFW_OPENGL_DEBUG_CONTEXT` name is also available for compatibility.
|
||||||
|
|
||||||
@anchor GLFW_OPENGL_PROFILE_hint
|
@anchor GLFW_OPENGL_PROFILE_hint
|
||||||
__GLFW_OPENGL_PROFILE__ specifies which OpenGL profile to create the context
|
__GLFW_OPENGL_PROFILE__ specifies which OpenGL profile to create the context
|
||||||
@ -419,7 +414,6 @@ a specific profile. If requesting an OpenGL version below 3.2,
|
|||||||
`GLFW_OPENGL_ANY_PROFILE` must be used. If OpenGL ES is requested, this hint
|
`GLFW_OPENGL_ANY_PROFILE` must be used. If OpenGL ES is requested, this hint
|
||||||
is ignored.
|
is ignored.
|
||||||
|
|
||||||
@par
|
|
||||||
OpenGL profiles are described in detail in the
|
OpenGL profiles are described in detail in the
|
||||||
[OpenGL Reference Manual](https://www.opengl.org/registry/).
|
[OpenGL Reference Manual](https://www.opengl.org/registry/).
|
||||||
|
|
||||||
@ -439,7 +433,6 @@ the pipeline will be flushed whenever the context is released from being the
|
|||||||
current one. If the behavior is `GLFW_RELEASE_BEHAVIOR_NONE`, the pipeline will
|
current one. If the behavior is `GLFW_RELEASE_BEHAVIOR_NONE`, the pipeline will
|
||||||
not be flushed on release.
|
not be flushed on release.
|
||||||
|
|
||||||
@par
|
|
||||||
Context release behaviors are described in detail by the
|
Context release behaviors are described in detail by the
|
||||||
[GL_KHR_context_flush_control](https://www.opengl.org/registry/specs/KHR/context_flush_control.txt)
|
[GL_KHR_context_flush_control](https://www.opengl.org/registry/specs/KHR/context_flush_control.txt)
|
||||||
extension.
|
extension.
|
||||||
@ -449,13 +442,12 @@ __GLFW_CONTEXT_NO_ERROR__ specifies whether errors should be generated by the
|
|||||||
context. Possible values are `GLFW_TRUE` and `GLFW_FALSE`. If enabled,
|
context. Possible values are `GLFW_TRUE` and `GLFW_FALSE`. If enabled,
|
||||||
situations that would have generated errors instead cause undefined behavior.
|
situations that would have generated errors instead cause undefined behavior.
|
||||||
|
|
||||||
@par
|
|
||||||
The no error mode for OpenGL and OpenGL ES is described in detail by the
|
The no error mode for OpenGL and OpenGL ES is described in detail by the
|
||||||
[GL_KHR_no_error](https://www.opengl.org/registry/specs/KHR/no_error.txt)
|
[GL_KHR_no_error](https://www.opengl.org/registry/specs/KHR/no_error.txt)
|
||||||
extension.
|
extension.
|
||||||
|
|
||||||
|
|
||||||
@subsubsection window_hints_win32 Windows specific window hints
|
@subsubsection window_hints_win32 Win32 specific hints
|
||||||
|
|
||||||
@anchor GLFW_WIN32_KEYBOARD_MENU_hint
|
@anchor GLFW_WIN32_KEYBOARD_MENU_hint
|
||||||
__GLFW_WIN32_KEYBOARD_MENU__ specifies whether to allow access to the window
|
__GLFW_WIN32_KEYBOARD_MENU__ specifies whether to allow access to the window
|
||||||
@ -463,7 +455,7 @@ menu via the Alt+Space and Alt-and-then-Space keyboard shortcuts. This is
|
|||||||
ignored on other platforms.
|
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
|
@anchor GLFW_COCOA_RETINA_FRAMEBUFFER_hint
|
||||||
__GLFW_COCOA_RETINA_FRAMEBUFFER__ specifies whether to use full resolution
|
__GLFW_COCOA_RETINA_FRAMEBUFFER__ specifies whether to use full resolution
|
||||||
@ -483,12 +475,10 @@ run on the discrete GPU. This only affects systems with both integrated and
|
|||||||
discrete GPUs. Possible values are `GLFW_TRUE` and `GLFW_FALSE`. This is
|
discrete GPUs. Possible values are `GLFW_TRUE` and `GLFW_FALSE`. This is
|
||||||
ignored on other platforms.
|
ignored on other platforms.
|
||||||
|
|
||||||
@par
|
|
||||||
Simpler programs and tools may want to enable this to save power, while games
|
Simpler programs and tools may want to enable this to save power, while games
|
||||||
and other applications performing advanced rendering will want to leave it
|
and other applications performing advanced rendering will want to leave it
|
||||||
disabled.
|
disabled.
|
||||||
|
|
||||||
@par
|
|
||||||
A bundled application that wishes to participate in Automatic Graphics Switching
|
A bundled application that wishes to participate in Automatic Graphics Switching
|
||||||
should also declare this in its `Info.plist` by setting the
|
should also declare this in its `Info.plist` by setting the
|
||||||
`NSSupportsAutomaticGraphicsSwitching` key to `true`.
|
`NSSupportsAutomaticGraphicsSwitching` key to `true`.
|
||||||
@ -518,6 +508,7 @@ GLFW_CENTER_CURSOR | `GLFW_TRUE` | `GLFW_TRUE` or `GL
|
|||||||
GLFW_TRANSPARENT_FRAMEBUFFER | `GLFW_FALSE` | `GLFW_TRUE` or `GLFW_FALSE`
|
GLFW_TRANSPARENT_FRAMEBUFFER | `GLFW_FALSE` | `GLFW_TRUE` or `GLFW_FALSE`
|
||||||
GLFW_FOCUS_ON_SHOW | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE`
|
GLFW_FOCUS_ON_SHOW | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE`
|
||||||
GLFW_SCALE_TO_MONITOR | `GLFW_FALSE` | `GLFW_TRUE` or `GLFW_FALSE`
|
GLFW_SCALE_TO_MONITOR | `GLFW_FALSE` | `GLFW_TRUE` or `GLFW_FALSE`
|
||||||
|
GLFW_MOUSE_PASSTHROUGH | `GLFW_FALSE` | `GLFW_TRUE` or `GLFW_FALSE`
|
||||||
GLFW_RED_BITS | 8 | 0 to `INT_MAX` or `GLFW_DONT_CARE`
|
GLFW_RED_BITS | 8 | 0 to `INT_MAX` or `GLFW_DONT_CARE`
|
||||||
GLFW_GREEN_BITS | 8 | 0 to `INT_MAX` or `GLFW_DONT_CARE`
|
GLFW_GREEN_BITS | 8 | 0 to `INT_MAX` or `GLFW_DONT_CARE`
|
||||||
GLFW_BLUE_BITS | 8 | 0 to `INT_MAX` or `GLFW_DONT_CARE`
|
GLFW_BLUE_BITS | 8 | 0 to `INT_MAX` or `GLFW_DONT_CARE`
|
||||||
@ -541,7 +532,7 @@ GLFW_CONTEXT_VERSION_MINOR | 0 | Any valid minor ve
|
|||||||
GLFW_CONTEXT_ROBUSTNESS | `GLFW_NO_ROBUSTNESS` | `GLFW_NO_ROBUSTNESS`, `GLFW_NO_RESET_NOTIFICATION` or `GLFW_LOSE_CONTEXT_ON_RESET`
|
GLFW_CONTEXT_ROBUSTNESS | `GLFW_NO_ROBUSTNESS` | `GLFW_NO_ROBUSTNESS`, `GLFW_NO_RESET_NOTIFICATION` or `GLFW_LOSE_CONTEXT_ON_RESET`
|
||||||
GLFW_CONTEXT_RELEASE_BEHAVIOR | `GLFW_ANY_RELEASE_BEHAVIOR` | `GLFW_ANY_RELEASE_BEHAVIOR`, `GLFW_RELEASE_BEHAVIOR_FLUSH` or `GLFW_RELEASE_BEHAVIOR_NONE`
|
GLFW_CONTEXT_RELEASE_BEHAVIOR | `GLFW_ANY_RELEASE_BEHAVIOR` | `GLFW_ANY_RELEASE_BEHAVIOR`, `GLFW_RELEASE_BEHAVIOR_FLUSH` or `GLFW_RELEASE_BEHAVIOR_NONE`
|
||||||
GLFW_OPENGL_FORWARD_COMPAT | `GLFW_FALSE` | `GLFW_TRUE` or `GLFW_FALSE`
|
GLFW_OPENGL_FORWARD_COMPAT | `GLFW_FALSE` | `GLFW_TRUE` or `GLFW_FALSE`
|
||||||
GLFW_OPENGL_DEBUG_CONTEXT | `GLFW_FALSE` | `GLFW_TRUE` or `GLFW_FALSE`
|
GLFW_CONTEXT_DEBUG | `GLFW_FALSE` | `GLFW_TRUE` or `GLFW_FALSE`
|
||||||
GLFW_OPENGL_PROFILE | `GLFW_OPENGL_ANY_PROFILE` | `GLFW_OPENGL_ANY_PROFILE`, `GLFW_OPENGL_COMPAT_PROFILE` or `GLFW_OPENGL_CORE_PROFILE`
|
GLFW_OPENGL_PROFILE | `GLFW_OPENGL_ANY_PROFILE` | `GLFW_OPENGL_ANY_PROFILE`, `GLFW_OPENGL_COMPAT_PROFILE` or `GLFW_OPENGL_CORE_PROFILE`
|
||||||
GLFW_WIN32_KEYBOARD_MENU | `GLFW_FALSE` | `GLFW_TRUE` or `GLFW_FALSE`
|
GLFW_WIN32_KEYBOARD_MENU | `GLFW_FALSE` | `GLFW_TRUE` or `GLFW_FALSE`
|
||||||
GLFW_COCOA_RETINA_FRAMEBUFFER | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE`
|
GLFW_COCOA_RETINA_FRAMEBUFFER | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE`
|
||||||
@ -1218,7 +1209,11 @@ If the system does not support whole window transparency, this function always
|
|||||||
returns one.
|
returns one.
|
||||||
|
|
||||||
GLFW comes with a test program that lets you control whole window transparency
|
GLFW comes with a test program that lets you control whole window transparency
|
||||||
at run-time called `opacity`.
|
at run-time called `window`.
|
||||||
|
|
||||||
|
If you want to use either of these transparency methods to display a temporary
|
||||||
|
overlay like for example a notification, the @ref GLFW_FLOATING and @ref
|
||||||
|
GLFW_MOUSE_PASSTHROUGH window hints and attributes may be useful.
|
||||||
|
|
||||||
|
|
||||||
@subsection window_attribs Window attributes
|
@subsection window_attribs Window attributes
|
||||||
@ -1308,6 +1303,15 @@ focus when @ref glfwShowWindow is called. This can be set before creation
|
|||||||
with the [GLFW_FOCUS_ON_SHOW](@ref GLFW_FOCUS_ON_SHOW_hint) window hint or
|
with the [GLFW_FOCUS_ON_SHOW](@ref GLFW_FOCUS_ON_SHOW_hint) window hint or
|
||||||
after with @ref glfwSetWindowAttrib.
|
after with @ref glfwSetWindowAttrib.
|
||||||
|
|
||||||
|
@anchor GLFW_MOUSE_PASSTHROUGH_attrib
|
||||||
|
__GLFW_MOUSE_PASSTHROUGH__ specifies whether the window is transparent to mouse
|
||||||
|
input, letting any mouse events pass through to whatever window is behind it.
|
||||||
|
This can be set before creation with the
|
||||||
|
[GLFW_MOUSE_PASSTHROUGH](@ref GLFW_MOUSE_PASSTHROUGH_hint) window hint or after
|
||||||
|
with @ref glfwSetWindowAttrib. This is only supported for undecorated windows.
|
||||||
|
Decorated windows with this enabled will behave differently between platforms.
|
||||||
|
|
||||||
|
|
||||||
@subsubsection window_attribs_ctx Context related attributes
|
@subsubsection window_attribs_ctx Context related attributes
|
||||||
|
|
||||||
@anchor GLFW_CLIENT_API_attrib
|
@anchor GLFW_CLIENT_API_attrib
|
||||||
@ -1334,9 +1338,14 @@ of the GLFW header.
|
|||||||
__GLFW_OPENGL_FORWARD_COMPAT__ is `GLFW_TRUE` if the window's context is an
|
__GLFW_OPENGL_FORWARD_COMPAT__ is `GLFW_TRUE` if the window's context is an
|
||||||
OpenGL forward-compatible one, or `GLFW_FALSE` otherwise.
|
OpenGL forward-compatible one, or `GLFW_FALSE` otherwise.
|
||||||
|
|
||||||
|
@anchor GLFW_CONTEXT_DEBUG_attrib
|
||||||
@anchor GLFW_OPENGL_DEBUG_CONTEXT_attrib
|
@anchor GLFW_OPENGL_DEBUG_CONTEXT_attrib
|
||||||
__GLFW_OPENGL_DEBUG_CONTEXT__ is `GLFW_TRUE` if the window's context is an
|
__GLFW_CONTEXT_DEBUG__ is `GLFW_TRUE` if the window's context is in debug
|
||||||
OpenGL debug context, or `GLFW_FALSE` otherwise.
|
mode, or `GLFW_FALSE` otherwise.
|
||||||
|
|
||||||
|
@par
|
||||||
|
This is the new name, introduced in GLFW 3.4. The older
|
||||||
|
`GLFW_OPENGL_DEBUG_CONTEXT` name is also available for compatibility.
|
||||||
|
|
||||||
@anchor GLFW_OPENGL_PROFILE_attrib
|
@anchor GLFW_OPENGL_PROFILE_attrib
|
||||||
__GLFW_OPENGL_PROFILE__ indicates the OpenGL profile used by the context. This
|
__GLFW_OPENGL_PROFILE__ indicates the OpenGL profile used by the context. This
|
||||||
@ -1369,9 +1378,11 @@ if the window's context supports robustness, or `GLFW_NO_ROBUSTNESS` otherwise.
|
|||||||
|
|
||||||
@subsubsection window_attribs_fb Framebuffer related attributes
|
@subsubsection window_attribs_fb Framebuffer related attributes
|
||||||
|
|
||||||
GLFW does not expose attributes of the default framebuffer (i.e. the framebuffer
|
GLFW does not expose most attributes of the default framebuffer (i.e. the
|
||||||
attached to the window) as these can be queried directly with either OpenGL,
|
framebuffer attached to the window) as these can be queried directly with either
|
||||||
OpenGL ES or Vulkan.
|
OpenGL, OpenGL ES or Vulkan. The one exception is
|
||||||
|
[GLFW_DOUBLEBUFFER](@ref GLFW_DOUBLEBUFFER_attrib), as this is not provided by
|
||||||
|
OpenGL ES.
|
||||||
|
|
||||||
If you are using version 3.0 or later of OpenGL or OpenGL ES, the
|
If you are using version 3.0 or later of OpenGL or OpenGL ES, the
|
||||||
`glGetFramebufferAttachmentParameteriv` function can be used to retrieve the
|
`glGetFramebufferAttachmentParameteriv` function can be used to retrieve the
|
||||||
@ -1397,6 +1408,11 @@ alpha sizes are queried from the `GL_BACK_LEFT`, while the depth and stencil
|
|||||||
sizes are queried from the `GL_DEPTH` and `GL_STENCIL` attachments,
|
sizes are queried from the `GL_DEPTH` and `GL_STENCIL` attachments,
|
||||||
respectively.
|
respectively.
|
||||||
|
|
||||||
|
@anchor GLFW_DOUBLEBUFFER_attrib
|
||||||
|
__GLFW_DOUBLEBUFFER__ indicates whether the specified window is double-buffered
|
||||||
|
when rendering with OpenGL or OpenGL ES. This can be set before creation with
|
||||||
|
the [GLFW_DOUBLEBUFFER](@ref GLFW_DOUBLEBUFFER_hint) window hint.
|
||||||
|
|
||||||
|
|
||||||
@section buffer_swap Buffer swapping
|
@section buffer_swap Buffer swapping
|
||||||
|
|
||||||
|
@ -7,7 +7,8 @@ if (MATH_LIBRARY)
|
|||||||
link_libraries("${MATH_LIBRARY}")
|
link_libraries("${MATH_LIBRARY}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (MSVC)
|
# Workaround for the MS CRT deprecating parts of the standard library
|
||||||
|
if (MSVC OR CMAKE_C_SIMULATE_ID STREQUAL "MSVC")
|
||||||
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
|
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@ -17,8 +18,8 @@ elseif (APPLE)
|
|||||||
set(ICON glfw.icns)
|
set(ICON glfw.icns)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(GLAD_GL "${GLFW_SOURCE_DIR}/deps/glad/gl.h"
|
set(GLAD_GL "${GLFW_SOURCE_DIR}/deps/glad/gl.h")
|
||||||
"${GLFW_SOURCE_DIR}/deps/glad_gl.c")
|
set(GLAD_GLES2 "${GLFW_SOURCE_DIR}/deps/glad/gles2.h")
|
||||||
set(GETOPT "${GLFW_SOURCE_DIR}/deps/getopt.h"
|
set(GETOPT "${GLFW_SOURCE_DIR}/deps/getopt.h"
|
||||||
"${GLFW_SOURCE_DIR}/deps/getopt.c")
|
"${GLFW_SOURCE_DIR}/deps/getopt.c")
|
||||||
set(TINYCTHREAD "${GLFW_SOURCE_DIR}/deps/tinycthread.h"
|
set(TINYCTHREAD "${GLFW_SOURCE_DIR}/deps/tinycthread.h"
|
||||||
@ -32,7 +33,9 @@ add_executable(particles WIN32 MACOSX_BUNDLE particles.c ${ICON} ${TINYCTHREAD}
|
|||||||
add_executable(sharing WIN32 MACOSX_BUNDLE sharing.c ${ICON} ${GLAD_GL})
|
add_executable(sharing WIN32 MACOSX_BUNDLE sharing.c ${ICON} ${GLAD_GL})
|
||||||
add_executable(splitview WIN32 MACOSX_BUNDLE splitview.c ${ICON} ${GLAD_GL})
|
add_executable(splitview WIN32 MACOSX_BUNDLE splitview.c ${ICON} ${GLAD_GL})
|
||||||
add_executable(triangle-opengl WIN32 MACOSX_BUNDLE triangle-opengl.c ${ICON} ${GLAD_GL})
|
add_executable(triangle-opengl WIN32 MACOSX_BUNDLE triangle-opengl.c ${ICON} ${GLAD_GL})
|
||||||
|
add_executable(triangle-opengles WIN32 MACOSX_BUNDLE triangle-opengles.c ${ICON} ${GLAD_GLES2})
|
||||||
add_executable(wave WIN32 MACOSX_BUNDLE wave.c ${ICON} ${GLAD_GL})
|
add_executable(wave WIN32 MACOSX_BUNDLE wave.c ${ICON} ${GLAD_GL})
|
||||||
|
add_executable(windows WIN32 MACOSX_BUNDLE windows.c ${ICON} ${GLAD_GL})
|
||||||
|
|
||||||
target_link_libraries(particles Threads::Threads)
|
target_link_libraries(particles Threads::Threads)
|
||||||
if (RT_LIBRARY)
|
if (RT_LIBRARY)
|
||||||
@ -40,7 +43,7 @@ if (RT_LIBRARY)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(GUI_ONLY_BINARIES boing gears heightmap particles sharing splitview
|
set(GUI_ONLY_BINARIES boing gears heightmap particles sharing splitview
|
||||||
triangle-opengl wave)
|
triangle-opengl triangle-opengles wave windows)
|
||||||
set(CONSOLE_BINARIES offscreen)
|
set(CONSOLE_BINARIES offscreen)
|
||||||
|
|
||||||
set_target_properties(${GUI_ONLY_BINARIES} ${CONSOLE_BINARIES} PROPERTIES
|
set_target_properties(${GUI_ONLY_BINARIES} ${CONSOLE_BINARIES} PROPERTIES
|
||||||
@ -48,13 +51,18 @@ set_target_properties(${GUI_ONLY_BINARIES} ${CONSOLE_BINARIES} PROPERTIES
|
|||||||
FOLDER "GLFW3/Examples")
|
FOLDER "GLFW3/Examples")
|
||||||
|
|
||||||
if (GLFW_USE_OSMESA)
|
if (GLFW_USE_OSMESA)
|
||||||
|
find_package(OSMesa REQUIRED)
|
||||||
target_compile_definitions(offscreen PRIVATE USE_NATIVE_OSMESA)
|
target_compile_definitions(offscreen PRIVATE USE_NATIVE_OSMESA)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (MSVC)
|
if (MSVC)
|
||||||
# Tell MSVC to use main instead of WinMain for Windows subsystem executables
|
# Tell MSVC to use main instead of WinMain
|
||||||
set_target_properties(${GUI_ONLY_BINARIES} PROPERTIES
|
set_target_properties(${GUI_ONLY_BINARIES} PROPERTIES
|
||||||
LINK_FLAGS "/ENTRY:mainCRTStartup")
|
LINK_FLAGS "/ENTRY:mainCRTStartup")
|
||||||
|
elseif (CMAKE_C_SIMULATE_ID STREQUAL "MSVC")
|
||||||
|
# Tell Clang using MS CRT to use main instead of WinMain
|
||||||
|
set_target_properties(${GUI_ONLY_BINARIES} PROPERTIES
|
||||||
|
LINK_FLAGS "-Wl,/entry:mainCRTStartup")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (APPLE)
|
if (APPLE)
|
||||||
@ -64,8 +72,10 @@ if (APPLE)
|
|||||||
set_target_properties(particles PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Particles")
|
set_target_properties(particles PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Particles")
|
||||||
set_target_properties(sharing PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Sharing")
|
set_target_properties(sharing PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Sharing")
|
||||||
set_target_properties(triangle-opengl PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "OpenGL Triangle")
|
set_target_properties(triangle-opengl PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "OpenGL Triangle")
|
||||||
|
set_target_properties(triangle-opengles PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "OpenGL ES Triangle")
|
||||||
set_target_properties(splitview PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "SplitView")
|
set_target_properties(splitview PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "SplitView")
|
||||||
set_target_properties(wave PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Wave")
|
set_target_properties(wave PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Wave")
|
||||||
|
set_target_properties(windows PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Windows")
|
||||||
|
|
||||||
set_source_files_properties(glfw.icns PROPERTIES
|
set_source_files_properties(glfw.icns PROPERTIES
|
||||||
MACOSX_PACKAGE_LOCATION "Resources")
|
MACOSX_PACKAGE_LOCATION "Resources")
|
||||||
|
@ -36,6 +36,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
|
#define GLAD_GL_IMPLEMENTATION
|
||||||
#include <glad/gl.h>
|
#include <glad/gl.h>
|
||||||
#define GLFW_INCLUDE_NONE
|
#define GLFW_INCLUDE_NONE
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#define GLAD_GL_IMPLEMENTATION
|
||||||
#include <glad/gl.h>
|
#include <glad/gl.h>
|
||||||
#define GLFW_INCLUDE_NONE
|
#define GLFW_INCLUDE_NONE
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
|
#define GLAD_GL_IMPLEMENTATION
|
||||||
#include <glad/gl.h>
|
#include <glad/gl.h>
|
||||||
#define GLFW_INCLUDE_NONE
|
#define GLFW_INCLUDE_NONE
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
@ -292,12 +293,12 @@ static void generate_heightmap__circle(float* center_x, float* center_y,
|
|||||||
{
|
{
|
||||||
float sign;
|
float sign;
|
||||||
/* random value for element in between [0-1.0] */
|
/* random value for element in between [0-1.0] */
|
||||||
*center_x = (MAP_SIZE * rand()) / (1.0f * RAND_MAX);
|
*center_x = (MAP_SIZE * rand()) / (float) RAND_MAX;
|
||||||
*center_y = (MAP_SIZE * rand()) / (1.0f * RAND_MAX);
|
*center_y = (MAP_SIZE * rand()) / (float) RAND_MAX;
|
||||||
*size = (MAX_CIRCLE_SIZE * rand()) / (1.0f * RAND_MAX);
|
*size = (MAX_CIRCLE_SIZE * rand()) / (float) RAND_MAX;
|
||||||
sign = (1.0f * rand()) / (1.0f * RAND_MAX);
|
sign = (1.0f * rand()) / (float) RAND_MAX;
|
||||||
sign = (sign < DISPLACEMENT_SIGN_LIMIT) ? -1.0f : 1.0f;
|
sign = (sign < DISPLACEMENT_SIGN_LIMIT) ? -1.0f : 1.0f;
|
||||||
*displacement = (sign * (MAX_DISPLACEMENT * rand())) / (1.0f * RAND_MAX);
|
*displacement = (sign * (MAX_DISPLACEMENT * rand())) / (float) RAND_MAX;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Run the specified number of iterations of the generation process for the
|
/* Run the specified number of iterations of the generation process for the
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
//
|
//
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
|
#define GLAD_GL_IMPLEMENTATION
|
||||||
#include <glad/gl.h>
|
#include <glad/gl.h>
|
||||||
#define GLFW_INCLUDE_NONE
|
#define GLFW_INCLUDE_NONE
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
|
@ -39,6 +39,7 @@
|
|||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
#include <linmath.h>
|
#include <linmath.h>
|
||||||
|
|
||||||
|
#define GLAD_GL_IMPLEMENTATION
|
||||||
#include <glad/gl.h>
|
#include <glad/gl.h>
|
||||||
#define GLFW_INCLUDE_NONE
|
#define GLFW_INCLUDE_NONE
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
//
|
//
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
|
#define GLAD_GL_IMPLEMENTATION
|
||||||
#include <glad/gl.h>
|
#include <glad/gl.h>
|
||||||
#define GLFW_INCLUDE_NONE
|
#define GLFW_INCLUDE_NONE
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
// This is an example program for the GLFW library
|
// This is an example program for the GLFW library
|
||||||
//
|
//
|
||||||
// The program uses a "split window" view, rendering four views of the
|
// The program uses a "split window" view, rendering four views of the
|
||||||
// same scene in one window (e.g. uesful for 3D modelling software). This
|
// same scene in one window (e.g. useful for 3D modelling software). This
|
||||||
// demo uses scissors to separate the four different rendering areas from
|
// demo uses scissors to separate the four different rendering areas from
|
||||||
// each other.
|
// each other.
|
||||||
//
|
//
|
||||||
@ -10,6 +10,7 @@
|
|||||||
// because I am not a friend of orthogonal projections)
|
// because I am not a friend of orthogonal projections)
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
|
#define GLAD_GL_IMPLEMENTATION
|
||||||
#include <glad/gl.h>
|
#include <glad/gl.h>
|
||||||
#define GLFW_INCLUDE_NONE
|
#define GLFW_INCLUDE_NONE
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
//========================================================================
|
//========================================================================
|
||||||
//! [code]
|
//! [code]
|
||||||
|
|
||||||
|
#define GLAD_GL_IMPLEMENTATION
|
||||||
#include <glad/gl.h>
|
#include <glad/gl.h>
|
||||||
#define GLFW_INCLUDE_NONE
|
#define GLFW_INCLUDE_NONE
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
|
170
examples/triangle-opengles.c
Normal file
170
examples/triangle-opengles.c
Normal file
@ -0,0 +1,170 @@
|
|||||||
|
//========================================================================
|
||||||
|
// OpenGL ES 2.0 triangle example
|
||||||
|
// Copyright (c) Camilla Löwy <elmindreda@glfw.org>
|
||||||
|
//
|
||||||
|
// This software is provided 'as-is', without any express or implied
|
||||||
|
// warranty. In no event will the authors be held liable for any damages
|
||||||
|
// arising from the use of this software.
|
||||||
|
//
|
||||||
|
// Permission is granted to anyone to use this software for any purpose,
|
||||||
|
// including commercial applications, and to alter it and redistribute it
|
||||||
|
// freely, subject to the following restrictions:
|
||||||
|
//
|
||||||
|
// 1. The origin of this software must not be misrepresented; you must not
|
||||||
|
// claim that you wrote the original software. If you use this software
|
||||||
|
// in a product, an acknowledgment in the product documentation would
|
||||||
|
// be appreciated but is not required.
|
||||||
|
//
|
||||||
|
// 2. Altered source versions must be plainly marked as such, and must not
|
||||||
|
// be misrepresented as being the original software.
|
||||||
|
//
|
||||||
|
// 3. This notice may not be removed or altered from any source
|
||||||
|
// distribution.
|
||||||
|
//
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
|
#define GLAD_GLES2_IMPLEMENTATION
|
||||||
|
#include <glad/gles2.h>
|
||||||
|
#define GLFW_INCLUDE_NONE
|
||||||
|
#include <GLFW/glfw3.h>
|
||||||
|
|
||||||
|
#include "linmath.h"
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
typedef struct Vertex
|
||||||
|
{
|
||||||
|
vec2 pos;
|
||||||
|
vec3 col;
|
||||||
|
} Vertex;
|
||||||
|
|
||||||
|
static const Vertex vertices[3] =
|
||||||
|
{
|
||||||
|
{ { -0.6f, -0.4f }, { 1.f, 0.f, 0.f } },
|
||||||
|
{ { 0.6f, -0.4f }, { 0.f, 1.f, 0.f } },
|
||||||
|
{ { 0.f, 0.6f }, { 0.f, 0.f, 1.f } }
|
||||||
|
};
|
||||||
|
|
||||||
|
static const char* vertex_shader_text =
|
||||||
|
"#version 100\n"
|
||||||
|
"precision mediump float;\n"
|
||||||
|
"uniform mat4 MVP;\n"
|
||||||
|
"attribute vec3 vCol;\n"
|
||||||
|
"attribute vec2 vPos;\n"
|
||||||
|
"varying vec3 color;\n"
|
||||||
|
"void main()\n"
|
||||||
|
"{\n"
|
||||||
|
" gl_Position = MVP * vec4(vPos, 0.0, 1.0);\n"
|
||||||
|
" color = vCol;\n"
|
||||||
|
"}\n";
|
||||||
|
|
||||||
|
static const char* fragment_shader_text =
|
||||||
|
"#version 100\n"
|
||||||
|
"precision mediump float;\n"
|
||||||
|
"varying vec3 color;\n"
|
||||||
|
"void main()\n"
|
||||||
|
"{\n"
|
||||||
|
" gl_FragColor = vec4(color, 1.0);\n"
|
||||||
|
"}\n";
|
||||||
|
|
||||||
|
static void error_callback(int error, const char* description)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "GLFW Error: %s\n", description);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
|
||||||
|
{
|
||||||
|
if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS)
|
||||||
|
glfwSetWindowShouldClose(window, GLFW_TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
glfwSetErrorCallback(error_callback);
|
||||||
|
|
||||||
|
if (!glfwInit())
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
|
||||||
|
glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_ES_API);
|
||||||
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2);
|
||||||
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);
|
||||||
|
glfwWindowHint(GLFW_CONTEXT_CREATION_API, GLFW_EGL_CONTEXT_API);
|
||||||
|
|
||||||
|
GLFWwindow* window = glfwCreateWindow(640, 480, "OpenGL ES 2.0 Triangle (EGL)", NULL, NULL);
|
||||||
|
if (!window)
|
||||||
|
{
|
||||||
|
glfwWindowHint(GLFW_CONTEXT_CREATION_API, GLFW_NATIVE_CONTEXT_API);
|
||||||
|
window = glfwCreateWindow(640, 480, "OpenGL ES 2.0 Triangle", NULL, NULL);
|
||||||
|
if (!window)
|
||||||
|
{
|
||||||
|
glfwTerminate();
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
glfwSetKeyCallback(window, key_callback);
|
||||||
|
|
||||||
|
glfwMakeContextCurrent(window);
|
||||||
|
gladLoadGLES2(glfwGetProcAddress);
|
||||||
|
glfwSwapInterval(1);
|
||||||
|
|
||||||
|
GLuint vertex_buffer;
|
||||||
|
glGenBuffers(1, &vertex_buffer);
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, vertex_buffer);
|
||||||
|
glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
|
||||||
|
|
||||||
|
const GLuint vertex_shader = glCreateShader(GL_VERTEX_SHADER);
|
||||||
|
glShaderSource(vertex_shader, 1, &vertex_shader_text, NULL);
|
||||||
|
glCompileShader(vertex_shader);
|
||||||
|
|
||||||
|
const GLuint fragment_shader = glCreateShader(GL_FRAGMENT_SHADER);
|
||||||
|
glShaderSource(fragment_shader, 1, &fragment_shader_text, NULL);
|
||||||
|
glCompileShader(fragment_shader);
|
||||||
|
|
||||||
|
const GLuint program = glCreateProgram();
|
||||||
|
glAttachShader(program, vertex_shader);
|
||||||
|
glAttachShader(program, fragment_shader);
|
||||||
|
glLinkProgram(program);
|
||||||
|
|
||||||
|
const GLint mvp_location = glGetUniformLocation(program, "MVP");
|
||||||
|
const GLint vpos_location = glGetAttribLocation(program, "vPos");
|
||||||
|
const GLint vcol_location = glGetAttribLocation(program, "vCol");
|
||||||
|
|
||||||
|
glEnableVertexAttribArray(vpos_location);
|
||||||
|
glEnableVertexAttribArray(vcol_location);
|
||||||
|
glVertexAttribPointer(vpos_location, 2, GL_FLOAT, GL_FALSE,
|
||||||
|
sizeof(Vertex), (void*) offsetof(Vertex, pos));
|
||||||
|
glVertexAttribPointer(vcol_location, 3, GL_FLOAT, GL_FALSE,
|
||||||
|
sizeof(Vertex), (void*) offsetof(Vertex, col));
|
||||||
|
|
||||||
|
while (!glfwWindowShouldClose(window))
|
||||||
|
{
|
||||||
|
int width, height;
|
||||||
|
glfwGetFramebufferSize(window, &width, &height);
|
||||||
|
const float ratio = width / (float) height;
|
||||||
|
|
||||||
|
glViewport(0, 0, width, height);
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
|
mat4x4 m, p, mvp;
|
||||||
|
mat4x4_identity(m);
|
||||||
|
mat4x4_rotate_Z(m, m, (float) glfwGetTime());
|
||||||
|
mat4x4_ortho(p, -ratio, ratio, -1.f, 1.f, 1.f, -1.f);
|
||||||
|
mat4x4_mul(mvp, p, m);
|
||||||
|
|
||||||
|
glUseProgram(program);
|
||||||
|
glUniformMatrix4fv(mvp_location, 1, GL_FALSE, (const GLfloat*) &mvp);
|
||||||
|
glDrawArrays(GL_TRIANGLES, 0, 3);
|
||||||
|
|
||||||
|
glfwSwapBuffers(window);
|
||||||
|
glfwPollEvents();
|
||||||
|
}
|
||||||
|
|
||||||
|
glfwDestroyWindow(window);
|
||||||
|
|
||||||
|
glfwTerminate();
|
||||||
|
exit(EXIT_SUCCESS);
|
||||||
|
}
|
||||||
|
|
@ -17,6 +17,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
|
#define GLAD_GL_IMPLEMENTATION
|
||||||
#include <glad/gl.h>
|
#include <glad/gl.h>
|
||||||
#define GLFW_INCLUDE_NONE
|
#define GLFW_INCLUDE_NONE
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
//========================================================================
|
//========================================================================
|
||||||
// Simple multi-window test
|
// Simple multi-window example
|
||||||
// Copyright (c) Camilla Löwy <elmindreda@glfw.org>
|
// Copyright (c) Camilla Löwy <elmindreda@glfw.org>
|
||||||
//
|
//
|
||||||
// This software is provided 'as-is', without any express or implied
|
// This software is provided 'as-is', without any express or implied
|
||||||
@ -22,11 +22,8 @@
|
|||||||
// distribution.
|
// distribution.
|
||||||
//
|
//
|
||||||
//========================================================================
|
//========================================================================
|
||||||
//
|
|
||||||
// This test creates four windows and clears each in a different color
|
|
||||||
//
|
|
||||||
//========================================================================
|
|
||||||
|
|
||||||
|
#define GLAD_GL_IMPLEMENTATION
|
||||||
#include <glad/gl.h>
|
#include <glad/gl.h>
|
||||||
#define GLFW_INCLUDE_NONE
|
#define GLFW_INCLUDE_NONE
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
@ -34,16 +31,28 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
static GLFWwindow* windows[4];
|
int main(int argc, char** argv)
|
||||||
static const char* titles[] =
|
|
||||||
{
|
{
|
||||||
"Red",
|
int xpos, ypos, height;
|
||||||
"Green",
|
const char* description;
|
||||||
"Blue",
|
GLFWwindow* windows[4];
|
||||||
"Yellow"
|
|
||||||
};
|
|
||||||
|
|
||||||
static const struct
|
if (!glfwInit())
|
||||||
|
{
|
||||||
|
glfwGetError(&description);
|
||||||
|
printf("Error: %s\n", description);
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE);
|
||||||
|
glfwWindowHint(GLFW_DECORATED, GLFW_FALSE);
|
||||||
|
|
||||||
|
glfwGetMonitorWorkarea(glfwGetPrimaryMonitor(), &xpos, &ypos, NULL, &height);
|
||||||
|
|
||||||
|
for (int i = 0; i < 4; i++)
|
||||||
|
{
|
||||||
|
const int size = height / 5;
|
||||||
|
const struct
|
||||||
{
|
{
|
||||||
float r, g, b;
|
float r, g, b;
|
||||||
} colors[] =
|
} colors[] =
|
||||||
@ -54,89 +63,28 @@ static const struct
|
|||||||
{ 0.98f, 0.74f, 0.04f }
|
{ 0.98f, 0.74f, 0.04f }
|
||||||
};
|
};
|
||||||
|
|
||||||
static void error_callback(int error, const char* description)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "Error: %s\n", description);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void arrange_windows(void)
|
|
||||||
{
|
|
||||||
int xbase, ybase;
|
|
||||||
glfwGetWindowPos(windows[0], &xbase, &ybase);
|
|
||||||
|
|
||||||
for (int i = 0; i < 4; i++)
|
|
||||||
{
|
|
||||||
int left, top, right, bottom;
|
|
||||||
glfwGetWindowFrameSize(windows[i], &left, &top, &right, &bottom);
|
|
||||||
glfwSetWindowPos(windows[i],
|
|
||||||
xbase + (i & 1) * (200 + left + right),
|
|
||||||
ybase + (i >> 1) * (200 + top + bottom));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
|
|
||||||
{
|
|
||||||
if (action != GLFW_PRESS)
|
|
||||||
return;
|
|
||||||
|
|
||||||
switch (key)
|
|
||||||
{
|
|
||||||
case GLFW_KEY_SPACE:
|
|
||||||
{
|
|
||||||
int xpos, ypos;
|
|
||||||
glfwGetWindowPos(window, &xpos, &ypos);
|
|
||||||
glfwSetWindowPos(window, xpos, ypos);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case GLFW_KEY_ESCAPE:
|
|
||||||
glfwSetWindowShouldClose(window, GLFW_TRUE);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case GLFW_KEY_D:
|
|
||||||
{
|
|
||||||
for (int i = 0; i < 4; i++)
|
|
||||||
{
|
|
||||||
const int decorated = glfwGetWindowAttrib(windows[i], GLFW_DECORATED);
|
|
||||||
glfwSetWindowAttrib(windows[i], GLFW_DECORATED, !decorated);
|
|
||||||
}
|
|
||||||
|
|
||||||
arrange_windows();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
|
||||||
{
|
|
||||||
glfwSetErrorCallback(error_callback);
|
|
||||||
|
|
||||||
if (!glfwInit())
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
|
|
||||||
glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE);
|
|
||||||
|
|
||||||
for (int i = 0; i < 4; i++)
|
|
||||||
{
|
|
||||||
if (i > 0)
|
if (i > 0)
|
||||||
glfwWindowHint(GLFW_FOCUS_ON_SHOW, GLFW_FALSE);
|
glfwWindowHint(GLFW_FOCUS_ON_SHOW, GLFW_FALSE);
|
||||||
|
|
||||||
windows[i] = glfwCreateWindow(200, 200, titles[i], NULL, NULL);
|
windows[i] = glfwCreateWindow(size, size, "Multi-Window Example", NULL, NULL);
|
||||||
if (!windows[i])
|
if (!windows[i])
|
||||||
{
|
{
|
||||||
|
glfwGetError(&description);
|
||||||
|
printf("Error: %s\n", description);
|
||||||
glfwTerminate();
|
glfwTerminate();
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
glfwSetKeyCallback(windows[i], key_callback);
|
glfwSetWindowPos(windows[i],
|
||||||
|
xpos + size * (1 + (i & 1)),
|
||||||
|
ypos + size * (1 + (i >> 1)));
|
||||||
|
glfwSetInputMode(windows[i], GLFW_STICKY_KEYS, GLFW_TRUE);
|
||||||
|
|
||||||
glfwMakeContextCurrent(windows[i]);
|
glfwMakeContextCurrent(windows[i]);
|
||||||
gladLoadGL(glfwGetProcAddress);
|
gladLoadGL(glfwGetProcAddress);
|
||||||
glClearColor(colors[i].r, colors[i].g, colors[i].b, 1.f);
|
glClearColor(colors[i].r, colors[i].g, colors[i].b, 1.f);
|
||||||
}
|
}
|
||||||
|
|
||||||
arrange_windows();
|
|
||||||
|
|
||||||
for (int i = 0; i < 4; i++)
|
for (int i = 0; i < 4; i++)
|
||||||
glfwShowWindow(windows[i]);
|
glfwShowWindow(windows[i]);
|
||||||
|
|
||||||
@ -148,7 +96,8 @@ int main(int argc, char** argv)
|
|||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
glfwSwapBuffers(windows[i]);
|
glfwSwapBuffers(windows[i]);
|
||||||
|
|
||||||
if (glfwWindowShouldClose(windows[i]))
|
if (glfwWindowShouldClose(windows[i]) ||
|
||||||
|
glfwGetKey(windows[i], GLFW_KEY_ESCAPE))
|
||||||
{
|
{
|
||||||
glfwTerminate();
|
glfwTerminate();
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
File diff suppressed because it is too large
Load Diff
@ -83,8 +83,8 @@ extern "C" {
|
|||||||
|
|
||||||
#if defined(GLFW_EXPOSE_NATIVE_WIN32) || defined(GLFW_EXPOSE_NATIVE_WGL)
|
#if defined(GLFW_EXPOSE_NATIVE_WIN32) || defined(GLFW_EXPOSE_NATIVE_WGL)
|
||||||
// This is a workaround for the fact that glfw3.h needs to export APIENTRY (for
|
// This is a workaround for the fact that glfw3.h needs to export APIENTRY (for
|
||||||
// example to allow applications to correctly declare a GL_ARB_debug_output
|
// example to allow applications to correctly declare a GL_KHR_debug callback)
|
||||||
// callback) but windows.h assumes no one will define APIENTRY before it does
|
// but windows.h assumes no one will define APIENTRY before it does
|
||||||
#if defined(GLFW_APIENTRY_DEFINED)
|
#if defined(GLFW_APIENTRY_DEFINED)
|
||||||
#undef APIENTRY
|
#undef APIENTRY
|
||||||
#undef GLFW_APIENTRY_DEFINED
|
#undef GLFW_APIENTRY_DEFINED
|
||||||
@ -132,6 +132,8 @@ extern "C" {
|
|||||||
* of the specified monitor, or `NULL` if an [error](@ref error_handling)
|
* of the specified monitor, or `NULL` if an [error](@ref error_handling)
|
||||||
* occurred.
|
* occurred.
|
||||||
*
|
*
|
||||||
|
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
|
||||||
|
*
|
||||||
* @thread_safety This function may be called from any thread. Access is not
|
* @thread_safety This function may be called from any thread. Access is not
|
||||||
* synchronized.
|
* synchronized.
|
||||||
*
|
*
|
||||||
@ -147,6 +149,8 @@ GLFWAPI const char* glfwGetWin32Adapter(GLFWmonitor* monitor);
|
|||||||
* `\\.\DISPLAY1\Monitor0`) of the specified monitor, or `NULL` if an
|
* `\\.\DISPLAY1\Monitor0`) of the specified monitor, or `NULL` if an
|
||||||
* [error](@ref error_handling) occurred.
|
* [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
|
* @thread_safety This function may be called from any thread. Access is not
|
||||||
* synchronized.
|
* synchronized.
|
||||||
*
|
*
|
||||||
@ -161,6 +165,16 @@ GLFWAPI const char* glfwGetWin32Monitor(GLFWmonitor* monitor);
|
|||||||
* @return The `HWND` of the specified window, or `NULL` if an
|
* @return The `HWND` of the specified window, or `NULL` if an
|
||||||
* [error](@ref error_handling) occurred.
|
* [error](@ref error_handling) occurred.
|
||||||
*
|
*
|
||||||
|
* @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.
|
||||||
|
* @code
|
||||||
|
* HDC dc = GetDC(glfwGetWin32Window(window));
|
||||||
|
* @endcode
|
||||||
|
* This DC is private and does not need to be released.
|
||||||
|
*
|
||||||
* @thread_safety This function may be called from any thread. Access is not
|
* @thread_safety This function may be called from any thread. Access is not
|
||||||
* synchronized.
|
* synchronized.
|
||||||
*
|
*
|
||||||
@ -177,6 +191,17 @@ GLFWAPI HWND glfwGetWin32Window(GLFWwindow* window);
|
|||||||
* @return The `HGLRC` of the specified window, or `NULL` if an
|
* @return The `HGLRC` of the specified window, or `NULL` if an
|
||||||
* [error](@ref error_handling) occurred.
|
* [error](@ref error_handling) occurred.
|
||||||
*
|
*
|
||||||
|
* @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.
|
||||||
|
* @code
|
||||||
|
* HDC dc = GetDC(glfwGetWin32Window(window));
|
||||||
|
* @endcode
|
||||||
|
* This DC is private and does not need to be released.
|
||||||
|
*
|
||||||
* @thread_safety This function may be called from any thread. Access is not
|
* @thread_safety This function may be called from any thread. Access is not
|
||||||
* synchronized.
|
* synchronized.
|
||||||
*
|
*
|
||||||
@ -193,6 +218,8 @@ GLFWAPI HGLRC glfwGetWGLContext(GLFWwindow* window);
|
|||||||
* @return The `CGDirectDisplayID` of the specified monitor, or
|
* @return The `CGDirectDisplayID` of the specified monitor, or
|
||||||
* `kCGNullDirectDisplay` if an [error](@ref error_handling) occurred.
|
* `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
|
* @thread_safety This function may be called from any thread. Access is not
|
||||||
* synchronized.
|
* synchronized.
|
||||||
*
|
*
|
||||||
@ -207,6 +234,8 @@ GLFWAPI CGDirectDisplayID glfwGetCocoaMonitor(GLFWmonitor* monitor);
|
|||||||
* @return The `NSWindow` of the specified window, or `nil` if an
|
* @return The `NSWindow` of the specified window, or `nil` if an
|
||||||
* [error](@ref error_handling) occurred.
|
* [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
|
* @thread_safety This function may be called from any thread. Access is not
|
||||||
* synchronized.
|
* synchronized.
|
||||||
*
|
*
|
||||||
@ -223,6 +252,9 @@ GLFWAPI id glfwGetCocoaWindow(GLFWwindow* window);
|
|||||||
* @return The `NSOpenGLContext` of the specified window, or `nil` if an
|
* @return The `NSOpenGLContext` of the specified window, or `nil` if an
|
||||||
* [error](@ref error_handling) occurred.
|
* [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
|
* @thread_safety This function may be called from any thread. Access is not
|
||||||
* synchronized.
|
* synchronized.
|
||||||
*
|
*
|
||||||
@ -239,6 +271,8 @@ GLFWAPI id glfwGetNSGLContext(GLFWwindow* window);
|
|||||||
* @return The `Display` used by GLFW, or `NULL` if an
|
* @return The `Display` used by GLFW, or `NULL` if an
|
||||||
* [error](@ref error_handling) occurred.
|
* [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
|
* @thread_safety This function may be called from any thread. Access is not
|
||||||
* synchronized.
|
* synchronized.
|
||||||
*
|
*
|
||||||
@ -253,6 +287,8 @@ GLFWAPI Display* glfwGetX11Display(void);
|
|||||||
* @return The `RRCrtc` of the specified monitor, or `None` if an
|
* @return The `RRCrtc` of the specified monitor, or `None` if an
|
||||||
* [error](@ref error_handling) occurred.
|
* [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
|
* @thread_safety This function may be called from any thread. Access is not
|
||||||
* synchronized.
|
* synchronized.
|
||||||
*
|
*
|
||||||
@ -267,6 +303,8 @@ GLFWAPI RRCrtc glfwGetX11Adapter(GLFWmonitor* monitor);
|
|||||||
* @return The `RROutput` of the specified monitor, or `None` if an
|
* @return The `RROutput` of the specified monitor, or `None` if an
|
||||||
* [error](@ref error_handling) occurred.
|
* [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
|
* @thread_safety This function may be called from any thread. Access is not
|
||||||
* synchronized.
|
* synchronized.
|
||||||
*
|
*
|
||||||
@ -281,6 +319,8 @@ GLFWAPI RROutput glfwGetX11Monitor(GLFWmonitor* monitor);
|
|||||||
* @return The `Window` of the specified window, or `None` if an
|
* @return The `Window` of the specified window, or `None` if an
|
||||||
* [error](@ref error_handling) occurred.
|
* [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
|
* @thread_safety This function may be called from any thread. Access is not
|
||||||
* synchronized.
|
* synchronized.
|
||||||
*
|
*
|
||||||
@ -347,6 +387,9 @@ GLFWAPI const char* glfwGetX11SelectionString(void);
|
|||||||
* @return The `GLXContext` of the specified window, or `NULL` if an
|
* @return The `GLXContext` of the specified window, or `NULL` if an
|
||||||
* [error](@ref error_handling) occurred.
|
* [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
|
* @thread_safety This function may be called from any thread. Access is not
|
||||||
* synchronized.
|
* synchronized.
|
||||||
*
|
*
|
||||||
@ -361,6 +404,9 @@ GLFWAPI GLXContext glfwGetGLXContext(GLFWwindow* window);
|
|||||||
* @return The `GLXWindow` of the specified window, or `None` if an
|
* @return The `GLXWindow` of the specified window, or `None` if an
|
||||||
* [error](@ref error_handling) occurred.
|
* [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
|
* @thread_safety This function may be called from any thread. Access is not
|
||||||
* synchronized.
|
* synchronized.
|
||||||
*
|
*
|
||||||
@ -377,6 +423,8 @@ GLFWAPI GLXWindow glfwGetGLXWindow(GLFWwindow* window);
|
|||||||
* @return The `struct wl_display*` used by GLFW, or `NULL` if an
|
* @return The `struct wl_display*` used by GLFW, or `NULL` if an
|
||||||
* [error](@ref error_handling) occurred.
|
* [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
|
* @thread_safety This function may be called from any thread. Access is not
|
||||||
* synchronized.
|
* synchronized.
|
||||||
*
|
*
|
||||||
@ -391,6 +439,8 @@ GLFWAPI struct wl_display* glfwGetWaylandDisplay(void);
|
|||||||
* @return The `struct wl_output*` of the specified monitor, or `NULL` if an
|
* @return The `struct wl_output*` of the specified monitor, or `NULL` if an
|
||||||
* [error](@ref error_handling) occurred.
|
* [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
|
* @thread_safety This function may be called from any thread. Access is not
|
||||||
* synchronized.
|
* synchronized.
|
||||||
*
|
*
|
||||||
@ -405,6 +455,8 @@ GLFWAPI struct wl_output* glfwGetWaylandMonitor(GLFWmonitor* monitor);
|
|||||||
* @return The main `struct wl_surface*` of the specified window, or `NULL` if
|
* @return The main `struct wl_surface*` of the specified window, or `NULL` if
|
||||||
* an [error](@ref error_handling) occurred.
|
* 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
|
* @thread_safety This function may be called from any thread. Access is not
|
||||||
* synchronized.
|
* synchronized.
|
||||||
*
|
*
|
||||||
@ -421,6 +473,8 @@ GLFWAPI struct wl_surface* glfwGetWaylandWindow(GLFWwindow* window);
|
|||||||
* @return The `EGLDisplay` used by GLFW, or `EGL_NO_DISPLAY` if an
|
* @return The `EGLDisplay` used by GLFW, or `EGL_NO_DISPLAY` if an
|
||||||
* [error](@ref error_handling) occurred.
|
* [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
|
* @thread_safety This function may be called from any thread. Access is not
|
||||||
* synchronized.
|
* synchronized.
|
||||||
*
|
*
|
||||||
@ -435,6 +489,9 @@ GLFWAPI EGLDisplay glfwGetEGLDisplay(void);
|
|||||||
* @return The `EGLContext` of the specified window, or `EGL_NO_CONTEXT` if an
|
* @return The `EGLContext` of the specified window, or `EGL_NO_CONTEXT` if an
|
||||||
* [error](@ref error_handling) occurred.
|
* [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
|
* @thread_safety This function may be called from any thread. Access is not
|
||||||
* synchronized.
|
* synchronized.
|
||||||
*
|
*
|
||||||
@ -449,6 +506,9 @@ GLFWAPI EGLContext glfwGetEGLContext(GLFWwindow* window);
|
|||||||
* @return The `EGLSurface` of the specified window, or `EGL_NO_SURFACE` if an
|
* @return The `EGLSurface` of the specified window, or `EGL_NO_SURFACE` if an
|
||||||
* [error](@ref error_handling) occurred.
|
* [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
|
* @thread_safety This function may be called from any thread. Access is not
|
||||||
* synchronized.
|
* synchronized.
|
||||||
*
|
*
|
||||||
@ -472,6 +532,9 @@ GLFWAPI EGLSurface glfwGetEGLSurface(GLFWwindow* window);
|
|||||||
* @return `GLFW_TRUE` if successful, or `GLFW_FALSE` if an
|
* @return `GLFW_TRUE` if successful, or `GLFW_FALSE` if an
|
||||||
* [error](@ref error_handling) occurred.
|
* [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
|
* @thread_safety This function may be called from any thread. Access is not
|
||||||
* synchronized.
|
* synchronized.
|
||||||
*
|
*
|
||||||
@ -493,6 +556,9 @@ GLFWAPI int glfwGetOSMesaColorBuffer(GLFWwindow* window, int* width, int* height
|
|||||||
* @return `GLFW_TRUE` if successful, or `GLFW_FALSE` if an
|
* @return `GLFW_TRUE` if successful, or `GLFW_FALSE` if an
|
||||||
* [error](@ref error_handling) occurred.
|
* [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
|
* @thread_safety This function may be called from any thread. Access is not
|
||||||
* synchronized.
|
* synchronized.
|
||||||
*
|
*
|
||||||
@ -507,6 +573,9 @@ GLFWAPI int glfwGetOSMesaDepthBuffer(GLFWwindow* window, int* width, int* height
|
|||||||
* @return The `OSMesaContext` of the specified window, or `NULL` if an
|
* @return The `OSMesaContext` of the specified window, or `NULL` if an
|
||||||
* [error](@ref error_handling) occurred.
|
* [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
|
* @thread_safety This function may be called from any thread. Access is not
|
||||||
* synchronized.
|
* synchronized.
|
||||||
*
|
*
|
||||||
|
@ -1,85 +1,130 @@
|
|||||||
|
|
||||||
add_library(glfw "${GLFW_SOURCE_DIR}/include/GLFW/glfw3.h"
|
add_library(glfw ${GLFW_LIBRARY_TYPE}
|
||||||
|
"${GLFW_SOURCE_DIR}/include/GLFW/glfw3.h"
|
||||||
"${GLFW_SOURCE_DIR}/include/GLFW/glfw3native.h"
|
"${GLFW_SOURCE_DIR}/include/GLFW/glfw3native.h"
|
||||||
internal.h mappings.h context.c init.c input.c monitor.c
|
internal.h platform.h mappings.h
|
||||||
vulkan.c window.c)
|
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)
|
||||||
|
|
||||||
if (_GLFW_COCOA)
|
# The time, thread and module code is shared between all backends on a given OS,
|
||||||
target_sources(glfw PRIVATE cocoa_platform.h cocoa_joystick.h posix_thread.h
|
# including the null backend, which still needs those bits to be functional
|
||||||
nsgl_context.h egl_context.h osmesa_context.h
|
if (APPLE)
|
||||||
cocoa_init.m cocoa_joystick.m cocoa_monitor.m
|
target_sources(glfw PRIVATE cocoa_time.h cocoa_time.c posix_thread.h
|
||||||
cocoa_window.m cocoa_time.c posix_thread.c
|
posix_module.c posix_thread.c)
|
||||||
nsgl_context.m egl_context.c osmesa_context.c)
|
elseif (WIN32)
|
||||||
elseif (_GLFW_WIN32)
|
target_sources(glfw PRIVATE win32_time.h win32_thread.h win32_module.c
|
||||||
target_sources(glfw PRIVATE win32_platform.h win32_joystick.h wgl_context.h
|
win32_time.c win32_thread.c)
|
||||||
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)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if (_GLFW_X11 OR _GLFW_WAYLAND)
|
|
||||||
if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
|
|
||||||
target_sources(glfw PRIVATE linux_joystick.h linux_joystick.c)
|
|
||||||
else()
|
else()
|
||||||
target_sources(glfw PRIVATE null_joystick.h null_joystick.c)
|
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
|
||||||
|
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||||
|
COMMENT "Updating gamepad mappings from upstream repository"
|
||||||
|
SOURCES mappings.h.in "${GLFW_SOURCE_DIR}/CMake/GenerateMappings.cmake"
|
||||||
|
VERBATIM)
|
||||||
|
|
||||||
|
set_target_properties(update_mappings PROPERTIES FOLDER "GLFW3")
|
||||||
|
|
||||||
|
if (GLFW_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_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)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (_GLFW_WAYLAND)
|
if (GLFW_BUILD_WAYLAND)
|
||||||
ecm_add_wayland_client_protocol(GLFW_WAYLAND_PROTOCOL_SOURCES
|
include(CheckIncludeFiles)
|
||||||
PROTOCOL
|
include(CheckFunctionExists)
|
||||||
"${WAYLAND_PROTOCOLS_PKGDATADIR}/stable/xdg-shell/xdg-shell.xml"
|
check_function_exists(memfd_create HAVE_MEMFD_CREATE)
|
||||||
BASENAME xdg-shell)
|
if (HAVE_MEMFD_CREATE)
|
||||||
ecm_add_wayland_client_protocol(GLFW_WAYLAND_PROTOCOL_SOURCES
|
target_compile_definitions(glfw PRIVATE HAVE_MEMFD_CREATE)
|
||||||
PROTOCOL
|
|
||||||
"${WAYLAND_PROTOCOLS_PKGDATADIR}/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml"
|
|
||||||
BASENAME xdg-decoration)
|
|
||||||
ecm_add_wayland_client_protocol(GLFW_WAYLAND_PROTOCOL_SOURCES
|
|
||||||
PROTOCOL
|
|
||||||
"${WAYLAND_PROTOCOLS_PKGDATADIR}/stable/viewporter/viewporter.xml"
|
|
||||||
BASENAME viewporter)
|
|
||||||
ecm_add_wayland_client_protocol(GLFW_WAYLAND_PROTOCOL_SOURCES
|
|
||||||
PROTOCOL
|
|
||||||
"${WAYLAND_PROTOCOLS_PKGDATADIR}/unstable/relative-pointer/relative-pointer-unstable-v1.xml"
|
|
||||||
BASENAME relative-pointer-unstable-v1)
|
|
||||||
ecm_add_wayland_client_protocol(GLFW_WAYLAND_PROTOCOL_SOURCES
|
|
||||||
PROTOCOL
|
|
||||||
"${WAYLAND_PROTOCOLS_PKGDATADIR}/unstable/pointer-constraints/pointer-constraints-unstable-v1.xml"
|
|
||||||
BASENAME pointer-constraints-unstable-v1)
|
|
||||||
ecm_add_wayland_client_protocol(GLFW_WAYLAND_PROTOCOL_SOURCES
|
|
||||||
PROTOCOL
|
|
||||||
"${WAYLAND_PROTOCOLS_PKGDATADIR}/unstable/idle-inhibit/idle-inhibit-unstable-v1.xml"
|
|
||||||
BASENAME idle-inhibit-unstable-v1)
|
|
||||||
target_sources(glfw PRIVATE ${GLFW_WAYLAND_PROTOCOL_SOURCES})
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (WIN32 AND BUILD_SHARED_LIBS)
|
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)
|
||||||
|
|
||||||
|
macro(wayland_generate protocol_file output_file)
|
||||||
|
add_custom_command(OUTPUT "${output_file}.h"
|
||||||
|
COMMAND "${WAYLAND_SCANNER_EXECUTABLE}" client-header "${protocol_file}" "${output_file}.h"
|
||||||
|
DEPENDS "${protocol_file}"
|
||||||
|
VERBATIM)
|
||||||
|
|
||||||
|
add_custom_command(OUTPUT "${output_file}-code.h"
|
||||||
|
COMMAND "${WAYLAND_SCANNER_EXECUTABLE}" private-code "${protocol_file}" "${output_file}-code.h"
|
||||||
|
DEPENDS "${protocol_file}"
|
||||||
|
VERBATIM)
|
||||||
|
|
||||||
|
target_sources(glfw PRIVATE "${output_file}.h" "${output_file}-code.h")
|
||||||
|
endmacro()
|
||||||
|
|
||||||
|
wayland_generate(
|
||||||
|
"${WAYLAND_CLIENT_PKGDATADIR}/wayland.xml"
|
||||||
|
"${GLFW_BINARY_DIR}/src/wayland-client-protocol")
|
||||||
|
wayland_generate(
|
||||||
|
"${WAYLAND_PROTOCOLS_BASE}/stable/xdg-shell/xdg-shell.xml"
|
||||||
|
"${GLFW_BINARY_DIR}/src/wayland-xdg-shell-client-protocol")
|
||||||
|
wayland_generate(
|
||||||
|
"${WAYLAND_PROTOCOLS_BASE}/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml"
|
||||||
|
"${GLFW_BINARY_DIR}/src/wayland-xdg-decoration-client-protocol")
|
||||||
|
wayland_generate(
|
||||||
|
"${WAYLAND_PROTOCOLS_BASE}/stable/viewporter/viewporter.xml"
|
||||||
|
"${GLFW_BINARY_DIR}/src/wayland-viewporter-client-protocol")
|
||||||
|
wayland_generate(
|
||||||
|
"${WAYLAND_PROTOCOLS_BASE}/unstable/relative-pointer/relative-pointer-unstable-v1.xml"
|
||||||
|
"${GLFW_BINARY_DIR}/src/wayland-relative-pointer-unstable-v1-client-protocol")
|
||||||
|
wayland_generate(
|
||||||
|
"${WAYLAND_PROTOCOLS_BASE}/unstable/pointer-constraints/pointer-constraints-unstable-v1.xml"
|
||||||
|
"${GLFW_BINARY_DIR}/src/wayland-pointer-constraints-unstable-v1-client-protocol")
|
||||||
|
wayland_generate(
|
||||||
|
"${WAYLAND_PROTOCOLS_BASE}/unstable/idle-inhibit/idle-inhibit-unstable-v1.xml"
|
||||||
|
"${GLFW_BINARY_DIR}/src/wayland-idle-inhibit-unstable-v1-client-protocol")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (WIN32 AND GLFW_BUILD_SHARED_LIBRARY)
|
||||||
configure_file(glfw.rc.in glfw.rc @ONLY)
|
configure_file(glfw.rc.in glfw.rc @ONLY)
|
||||||
target_sources(glfw PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/glfw.rc")
|
target_sources(glfw PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/glfw.rc")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
configure_file(glfw_config.h.in glfw_config.h @ONLY)
|
if (UNIX AND GLFW_BUILD_SHARED_LIBRARY)
|
||||||
target_compile_definitions(glfw PRIVATE _GLFW_USE_CONFIG_H)
|
# On Unix-like systems, shared libraries can use the soname system.
|
||||||
target_sources(glfw PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/glfw_config.h")
|
set(GLFW_LIB_NAME glfw)
|
||||||
|
else()
|
||||||
|
set(GLFW_LIB_NAME glfw3)
|
||||||
|
endif()
|
||||||
|
|
||||||
set_target_properties(glfw PROPERTIES
|
set_target_properties(glfw PROPERTIES
|
||||||
OUTPUT_NAME ${GLFW_LIB_NAME}
|
OUTPUT_NAME ${GLFW_LIB_NAME}
|
||||||
@ -96,36 +141,139 @@ target_include_directories(glfw PUBLIC
|
|||||||
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>")
|
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>")
|
||||||
target_include_directories(glfw PRIVATE
|
target_include_directories(glfw PRIVATE
|
||||||
"${GLFW_SOURCE_DIR}/src"
|
"${GLFW_SOURCE_DIR}/src"
|
||||||
"${GLFW_BINARY_DIR}/src"
|
"${GLFW_BINARY_DIR}/src")
|
||||||
${glfw_INCLUDE_DIRS})
|
target_link_libraries(glfw PRIVATE Threads::Threads)
|
||||||
target_link_libraries(glfw PRIVATE Threads::Threads ${glfw_LIBRARIES})
|
|
||||||
|
|
||||||
if (APPLE)
|
# Workaround for CMake not knowing about .m files before version 3.16
|
||||||
# For some reason CMake didn't know about .m until version 3.16
|
if (CMAKE_VERSION VERSION_LESS "3.16" AND APPLE)
|
||||||
set_source_files_properties(cocoa_init.m cocoa_joystick.m cocoa_monitor.m
|
set_source_files_properties(cocoa_init.m cocoa_joystick.m cocoa_monitor.m
|
||||||
cocoa_window.m nsgl_context.m PROPERTIES
|
cocoa_window.m nsgl_context.m PROPERTIES
|
||||||
LANGUAGE C)
|
LANGUAGE C)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" OR
|
if (GLFW_BUILD_WIN32)
|
||||||
"${CMAKE_C_COMPILER_ID}" STREQUAL "Clang" OR
|
list(APPEND glfw_PKG_LIBS "-lgdi32")
|
||||||
"${CMAKE_C_COMPILER_ID}" STREQUAL "AppleClang")
|
endif()
|
||||||
|
|
||||||
# Make GCC and Clang warn about declarations that VS 2010 and 2012 won't
|
if (GLFW_BUILD_COCOA)
|
||||||
# accept for all source files that VS will build
|
target_link_libraries(glfw PRIVATE "-framework Cocoa"
|
||||||
set_source_files_properties(context.c init.c input.c monitor.c vulkan.c
|
"-framework IOKit"
|
||||||
window.c win32_init.c win32_joystick.c
|
"-framework CoreFoundation")
|
||||||
win32_monitor.c win32_time.c win32_thread.c
|
|
||||||
win32_window.c wgl_context.c egl_context.c
|
set(glfw_PKG_DEPS "")
|
||||||
osmesa_context.c PROPERTIES
|
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 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)
|
COMPILE_FLAGS -Wdeclaration-after-statement)
|
||||||
|
|
||||||
# Enable a reasonable set of warnings (no, -Wextra is not reasonable)
|
|
||||||
target_compile_options(glfw PRIVATE "-Wall")
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
target_compile_definitions(glfw PRIVATE _UNICODE)
|
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)
|
||||||
|
target_compile_options(glfw PRIVATE "/W3")
|
||||||
|
elseif (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR
|
||||||
|
CMAKE_C_COMPILER_ID STREQUAL "Clang" OR
|
||||||
|
CMAKE_C_COMPILER_ID STREQUAL "AppleClang")
|
||||||
|
|
||||||
|
target_compile_options(glfw PRIVATE "-Wall")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (GLFW_BUILD_WIN32)
|
||||||
|
target_compile_definitions(glfw PRIVATE UNICODE _UNICODE)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# HACK: When building on MinGW, WINVER and UNICODE need to be defined before
|
# HACK: When building on MinGW, WINVER and UNICODE need to be defined before
|
||||||
@ -133,10 +281,46 @@ endif()
|
|||||||
# win32_platform.h. We define them here until a saner solution can be found
|
# win32_platform.h. We define them here until a saner solution can be found
|
||||||
# NOTE: MinGW-w64 and Visual C++ do /not/ need this hack.
|
# NOTE: MinGW-w64 and Visual C++ do /not/ need this hack.
|
||||||
if (MINGW)
|
if (MINGW)
|
||||||
target_compile_definitions(glfw PRIVATE UNICODE WINVER=0x0501)
|
target_compile_definitions(glfw PRIVATE WINVER=0x0501)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (BUILD_SHARED_LIBS)
|
# Workaround for legacy MinGW not providing XInput and DirectInput
|
||||||
|
if (MINGW)
|
||||||
|
include(CheckIncludeFile)
|
||||||
|
check_include_file(dinput.h DINPUT_H_FOUND)
|
||||||
|
check_include_file(xinput.h XINPUT_H_FOUND)
|
||||||
|
if (NOT DINPUT_H_FOUND OR NOT XINPUT_H_FOUND)
|
||||||
|
target_include_directories(glfw PRIVATE "${GLFW_SOURCE_DIR}/deps/mingw")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Workaround for the MS CRT deprecating parts of the standard library
|
||||||
|
if (MSVC OR CMAKE_C_SIMULATE_ID STREQUAL "MSVC")
|
||||||
|
target_compile_definitions(glfw PRIVATE _CRT_SECURE_NO_WARNINGS)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Workaround for VS 2008 not shipping with stdint.h
|
||||||
|
if (MSVC90)
|
||||||
|
target_include_directories(glfw PUBLIC "${GLFW_SOURCE_DIR}/deps/vs2008")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Check for the DirectX 9 SDK as it is not included with VS 2008
|
||||||
|
if (MSVC90)
|
||||||
|
include(CheckIncludeFile)
|
||||||
|
check_include_file(dinput.h DINPUT_H_FOUND)
|
||||||
|
if (NOT DINPUT_H_FOUND)
|
||||||
|
message(FATAL_ERROR "DirectX 9 headers not found; install DirectX 9 SDK")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Workaround for -std=c99 on Linux disabling _DEFAULT_SOURCE (POSIX 2008 and more)
|
||||||
|
if (GLFW_BUILD_X11 OR GLFW_BUILD_WAYLAND)
|
||||||
|
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||||
|
target_compile_definitions(glfw PRIVATE _DEFAULT_SOURCE)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (GLFW_BUILD_SHARED_LIBRARY)
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
if (MINGW)
|
if (MINGW)
|
||||||
# Remove the dependency on the shared version of libgcc
|
# Remove the dependency on the shared version of libgcc
|
||||||
@ -154,9 +338,35 @@ if (BUILD_SHARED_LIBS)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_compile_definitions(glfw INTERFACE GLFW_DLL)
|
target_compile_definitions(glfw INTERFACE GLFW_DLL)
|
||||||
elseif (APPLE)
|
endif()
|
||||||
set_target_properties(glfw PROPERTIES
|
|
||||||
INSTALL_NAME_DIR "${CMAKE_INSTALL_LIBDIR}")
|
if (MINGW)
|
||||||
|
# Enable link-time exploit mitigation features enabled by default on MSVC
|
||||||
|
include(CheckCCompilerFlag)
|
||||||
|
|
||||||
|
# Compatibility with data execution prevention (DEP)
|
||||||
|
set(CMAKE_REQUIRED_FLAGS "-Wl,--nxcompat")
|
||||||
|
check_c_compiler_flag("" _GLFW_HAS_DEP)
|
||||||
|
if (_GLFW_HAS_DEP)
|
||||||
|
target_link_libraries(glfw PRIVATE "-Wl,--nxcompat")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Compatibility with address space layout randomization (ASLR)
|
||||||
|
set(CMAKE_REQUIRED_FLAGS "-Wl,--dynamicbase")
|
||||||
|
check_c_compiler_flag("" _GLFW_HAS_ASLR)
|
||||||
|
if (_GLFW_HAS_ASLR)
|
||||||
|
target_link_libraries(glfw PRIVATE "-Wl,--dynamicbase")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Compatibility with 64-bit address space layout randomization (ASLR)
|
||||||
|
set(CMAKE_REQUIRED_FLAGS "-Wl,--high-entropy-va")
|
||||||
|
check_c_compiler_flag("" _GLFW_HAS_64ASLR)
|
||||||
|
if (_GLFW_HAS_64ASLR)
|
||||||
|
target_link_libraries(glfw PRIVATE "-Wl,--high-entropy-va")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Clear flags again to avoid breaking later tests
|
||||||
|
set(CMAKE_REQUIRED_FLAGS)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (UNIX)
|
if (UNIX)
|
||||||
@ -165,14 +375,24 @@ if (BUILD_SHARED_LIBS)
|
|||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (MSVC)
|
foreach(arg ${glfw_PKG_DEPS})
|
||||||
target_compile_definitions(glfw PRIVATE _CRT_SECURE_NO_WARNINGS)
|
string(APPEND deps " ${arg}")
|
||||||
endif()
|
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)
|
if (GLFW_INSTALL)
|
||||||
install(TARGETS glfw
|
install(TARGETS glfw
|
||||||
EXPORT glfwTargets
|
EXPORT glfwTargets
|
||||||
RUNTIME DESTINATION "bin"
|
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
|
||||||
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
||||||
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")
|
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")
|
||||||
endif()
|
endif()
|
||||||
|
147
src/cocoa_init.m
147
src/cocoa_init.m
@ -75,7 +75,6 @@ static void changeToResourcesDirectory(void)
|
|||||||
//
|
//
|
||||||
static void createMenuBar(void)
|
static void createMenuBar(void)
|
||||||
{
|
{
|
||||||
size_t i;
|
|
||||||
NSString* appName = nil;
|
NSString* appName = nil;
|
||||||
NSDictionary* bundleInfo = [[NSBundle mainBundle] infoDictionary];
|
NSDictionary* bundleInfo = [[NSBundle mainBundle] infoDictionary];
|
||||||
NSString* nameKeys[] =
|
NSString* nameKeys[] =
|
||||||
@ -87,7 +86,7 @@ static void createMenuBar(void)
|
|||||||
|
|
||||||
// Try to figure out what the calling application is called
|
// 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]];
|
id name = bundleInfo[nameKeys[i]];
|
||||||
if (name &&
|
if (name &&
|
||||||
@ -177,8 +176,6 @@ static void createMenuBar(void)
|
|||||||
//
|
//
|
||||||
static void createKeyTables(void)
|
static void createKeyTables(void)
|
||||||
{
|
{
|
||||||
int scancode;
|
|
||||||
|
|
||||||
memset(_glfw.ns.keycodes, -1, sizeof(_glfw.ns.keycodes));
|
memset(_glfw.ns.keycodes, -1, sizeof(_glfw.ns.keycodes));
|
||||||
memset(_glfw.ns.scancodes, -1, sizeof(_glfw.ns.scancodes));
|
memset(_glfw.ns.scancodes, -1, sizeof(_glfw.ns.scancodes));
|
||||||
|
|
||||||
@ -251,7 +248,7 @@ static void createKeyTables(void)
|
|||||||
_glfw.ns.keycodes[0x6D] = GLFW_KEY_F10;
|
_glfw.ns.keycodes[0x6D] = GLFW_KEY_F10;
|
||||||
_glfw.ns.keycodes[0x67] = GLFW_KEY_F11;
|
_glfw.ns.keycodes[0x67] = GLFW_KEY_F11;
|
||||||
_glfw.ns.keycodes[0x6F] = GLFW_KEY_F12;
|
_glfw.ns.keycodes[0x6F] = GLFW_KEY_F12;
|
||||||
_glfw.ns.keycodes[0x69] = GLFW_KEY_F13;
|
_glfw.ns.keycodes[0x69] = GLFW_KEY_PRINT_SCREEN;
|
||||||
_glfw.ns.keycodes[0x6B] = GLFW_KEY_F14;
|
_glfw.ns.keycodes[0x6B] = GLFW_KEY_F14;
|
||||||
_glfw.ns.keycodes[0x71] = GLFW_KEY_F15;
|
_glfw.ns.keycodes[0x71] = GLFW_KEY_F15;
|
||||||
_glfw.ns.keycodes[0x6A] = GLFW_KEY_F16;
|
_glfw.ns.keycodes[0x6A] = GLFW_KEY_F16;
|
||||||
@ -297,7 +294,7 @@ static void createKeyTables(void)
|
|||||||
_glfw.ns.keycodes[0x43] = GLFW_KEY_KP_MULTIPLY;
|
_glfw.ns.keycodes[0x43] = GLFW_KEY_KP_MULTIPLY;
|
||||||
_glfw.ns.keycodes[0x4E] = GLFW_KEY_KP_SUBTRACT;
|
_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
|
// Store the reverse translation for faster key name lookup
|
||||||
if (_glfw.ns.keycodes[scancode] >= 0)
|
if (_glfw.ns.keycodes[scancode] >= 0)
|
||||||
@ -307,7 +304,7 @@ static void createKeyTables(void)
|
|||||||
|
|
||||||
// Retrieve Unicode data for the current keyboard layout
|
// Retrieve Unicode data for the current keyboard layout
|
||||||
//
|
//
|
||||||
static GLFWbool updateUnicodeDataNS(void)
|
static GLFWbool updateUnicodeData(void)
|
||||||
{
|
{
|
||||||
if (_glfw.ns.inputSource)
|
if (_glfw.ns.inputSource)
|
||||||
{
|
{
|
||||||
@ -377,7 +374,7 @@ static GLFWbool initializeTIS(void)
|
|||||||
_glfw.ns.tis.kPropertyUnicodeKeyLayoutData =
|
_glfw.ns.tis.kPropertyUnicodeKeyLayoutData =
|
||||||
*kPropertyUnicodeKeyLayoutData;
|
*kPropertyUnicodeKeyLayoutData;
|
||||||
|
|
||||||
return updateUnicodeDataNS();
|
return updateUnicodeData();
|
||||||
}
|
}
|
||||||
|
|
||||||
@interface GLFWHelper : NSObject
|
@interface GLFWHelper : NSObject
|
||||||
@ -387,7 +384,7 @@ static GLFWbool initializeTIS(void)
|
|||||||
|
|
||||||
- (void)selectedKeyboardInputSourceChanged:(NSObject* )object
|
- (void)selectedKeyboardInputSourceChanged:(NSObject* )object
|
||||||
{
|
{
|
||||||
updateUnicodeDataNS();
|
updateUnicodeData();
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)doNothing:(id)object
|
- (void)doNothing:(id)object
|
||||||
@ -403,9 +400,7 @@ static GLFWbool initializeTIS(void)
|
|||||||
|
|
||||||
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender
|
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender
|
||||||
{
|
{
|
||||||
_GLFWwindow* window;
|
for (_GLFWwindow* window = _glfw.windowListHead; window; window = window->next)
|
||||||
|
|
||||||
for (window = _glfw.windowListHead; window; window = window->next)
|
|
||||||
_glfwInputWindowCloseRequest(window);
|
_glfwInputWindowCloseRequest(window);
|
||||||
|
|
||||||
return NSTerminateCancel;
|
return NSTerminateCancel;
|
||||||
@ -413,24 +408,19 @@ static GLFWbool initializeTIS(void)
|
|||||||
|
|
||||||
- (void)applicationDidChangeScreenParameters:(NSNotification *) notification
|
- (void)applicationDidChangeScreenParameters:(NSNotification *) notification
|
||||||
{
|
{
|
||||||
_GLFWwindow* window;
|
for (_GLFWwindow* window = _glfw.windowListHead; window; window = window->next)
|
||||||
|
|
||||||
for (window = _glfw.windowListHead; window; window = window->next)
|
|
||||||
{
|
{
|
||||||
if (window->context.client != GLFW_NO_API)
|
if (window->context.client != GLFW_NO_API)
|
||||||
[window->context.nsgl.object update];
|
[window->context.nsgl.object update];
|
||||||
}
|
}
|
||||||
|
|
||||||
_glfwPollMonitorsNS();
|
_glfwPollMonitorsCocoa();
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)applicationWillFinishLaunching:(NSNotification *)notification
|
- (void)applicationWillFinishLaunching:(NSNotification *)notification
|
||||||
{
|
{
|
||||||
if (_glfw.hints.init.ns.menubar)
|
if (_glfw.hints.init.ns.menubar)
|
||||||
{
|
{
|
||||||
// In case we are unbundled, make us a proper UI application
|
|
||||||
[NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
|
|
||||||
|
|
||||||
// Menu bar setup must go between sharedApplication and finishLaunching
|
// Menu bar setup must go between sharedApplication and finishLaunching
|
||||||
// in order to properly emulate the behavior of NSApplicationMain
|
// in order to properly emulate the behavior of NSApplicationMain
|
||||||
|
|
||||||
@ -447,16 +437,14 @@ static GLFWbool initializeTIS(void)
|
|||||||
|
|
||||||
- (void)applicationDidFinishLaunching:(NSNotification *)notification
|
- (void)applicationDidFinishLaunching:(NSNotification *)notification
|
||||||
{
|
{
|
||||||
_glfwPlatformPostEmptyEvent();
|
_glfwPostEmptyEventCocoa();
|
||||||
[NSApp stop:nil];
|
[NSApp stop:nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)applicationDidHide:(NSNotification *)notification
|
- (void)applicationDidHide:(NSNotification *)notification
|
||||||
{
|
{
|
||||||
int i;
|
for (int i = 0; i < _glfw.monitorCount; i++)
|
||||||
|
_glfwRestoreVideoModeCocoa(_glfw.monitors[i]);
|
||||||
for (i = 0; i < _glfw.monitorCount; i++)
|
|
||||||
_glfwRestoreVideoModeNS(_glfw.monitors[i]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@end // GLFWApplicationDelegate
|
@end // GLFWApplicationDelegate
|
||||||
@ -466,7 +454,7 @@ static GLFWbool initializeTIS(void)
|
|||||||
////// GLFW internal API //////
|
////// GLFW internal API //////
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void* _glfwLoadLocalVulkanLoaderNS(void)
|
void* _glfwLoadLocalVulkanLoaderCocoa(void)
|
||||||
{
|
{
|
||||||
CFBundleRef bundle = CFBundleGetMainBundle();
|
CFBundleRef bundle = CFBundleGetMainBundle();
|
||||||
if (!bundle)
|
if (!bundle)
|
||||||
@ -481,7 +469,7 @@ void* _glfwLoadLocalVulkanLoaderNS(void)
|
|||||||
void* handle = NULL;
|
void* handle = NULL;
|
||||||
|
|
||||||
if (CFURLGetFileSystemRepresentation(url, true, (UInt8*) path, sizeof(path) - 1))
|
if (CFURLGetFileSystemRepresentation(url, true, (UInt8*) path, sizeof(path) - 1))
|
||||||
handle = _glfw_dlopen(path);
|
handle = _glfwPlatformLoadModule(path);
|
||||||
|
|
||||||
CFRelease(url);
|
CFRelease(url);
|
||||||
return handle;
|
return handle;
|
||||||
@ -492,7 +480,89 @@ void* _glfwLoadLocalVulkanLoaderNS(void)
|
|||||||
////// GLFW platform API //////
|
////// GLFW platform API //////
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
int _glfwPlatformInit(void)
|
GLFWbool _glfwConnectCocoa(int platformID, _GLFWplatform* platform)
|
||||||
|
{
|
||||||
|
const _GLFWplatform cocoa =
|
||||||
|
{
|
||||||
|
GLFW_PLATFORM_COCOA,
|
||||||
|
_glfwInitCocoa,
|
||||||
|
_glfwTerminateCocoa,
|
||||||
|
_glfwGetCursorPosCocoa,
|
||||||
|
_glfwSetCursorPosCocoa,
|
||||||
|
_glfwSetCursorModeCocoa,
|
||||||
|
_glfwSetRawMouseMotionCocoa,
|
||||||
|
_glfwRawMouseMotionSupportedCocoa,
|
||||||
|
_glfwCreateCursorCocoa,
|
||||||
|
_glfwCreateStandardCursorCocoa,
|
||||||
|
_glfwDestroyCursorCocoa,
|
||||||
|
_glfwSetCursorCocoa,
|
||||||
|
_glfwGetScancodeNameCocoa,
|
||||||
|
_glfwGetKeyScancodeCocoa,
|
||||||
|
_glfwSetClipboardStringCocoa,
|
||||||
|
_glfwGetClipboardStringCocoa,
|
||||||
|
_glfwInitJoysticksCocoa,
|
||||||
|
_glfwTerminateJoysticksCocoa,
|
||||||
|
_glfwPollJoystickCocoa,
|
||||||
|
_glfwGetMappingNameCocoa,
|
||||||
|
_glfwUpdateGamepadGUIDCocoa,
|
||||||
|
_glfwFreeMonitorCocoa,
|
||||||
|
_glfwGetMonitorPosCocoa,
|
||||||
|
_glfwGetMonitorContentScaleCocoa,
|
||||||
|
_glfwGetMonitorWorkareaCocoa,
|
||||||
|
_glfwGetVideoModesCocoa,
|
||||||
|
_glfwGetVideoModeCocoa,
|
||||||
|
_glfwGetGammaRampCocoa,
|
||||||
|
_glfwSetGammaRampCocoa,
|
||||||
|
_glfwCreateWindowCocoa,
|
||||||
|
_glfwDestroyWindowCocoa,
|
||||||
|
_glfwSetWindowTitleCocoa,
|
||||||
|
_glfwSetWindowIconCocoa,
|
||||||
|
_glfwGetWindowPosCocoa,
|
||||||
|
_glfwSetWindowPosCocoa,
|
||||||
|
_glfwGetWindowSizeCocoa,
|
||||||
|
_glfwSetWindowSizeCocoa,
|
||||||
|
_glfwSetWindowSizeLimitsCocoa,
|
||||||
|
_glfwSetWindowAspectRatioCocoa,
|
||||||
|
_glfwGetFramebufferSizeCocoa,
|
||||||
|
_glfwGetWindowFrameSizeCocoa,
|
||||||
|
_glfwGetWindowContentScaleCocoa,
|
||||||
|
_glfwIconifyWindowCocoa,
|
||||||
|
_glfwRestoreWindowCocoa,
|
||||||
|
_glfwMaximizeWindowCocoa,
|
||||||
|
_glfwShowWindowCocoa,
|
||||||
|
_glfwHideWindowCocoa,
|
||||||
|
_glfwRequestWindowAttentionCocoa,
|
||||||
|
_glfwFocusWindowCocoa,
|
||||||
|
_glfwSetWindowMonitorCocoa,
|
||||||
|
_glfwWindowFocusedCocoa,
|
||||||
|
_glfwWindowIconifiedCocoa,
|
||||||
|
_glfwWindowVisibleCocoa,
|
||||||
|
_glfwWindowMaximizedCocoa,
|
||||||
|
_glfwWindowHoveredCocoa,
|
||||||
|
_glfwFramebufferTransparentCocoa,
|
||||||
|
_glfwGetWindowOpacityCocoa,
|
||||||
|
_glfwSetWindowResizableCocoa,
|
||||||
|
_glfwSetWindowDecoratedCocoa,
|
||||||
|
_glfwSetWindowFloatingCocoa,
|
||||||
|
_glfwSetWindowOpacityCocoa,
|
||||||
|
_glfwSetWindowMousePassthroughCocoa,
|
||||||
|
_glfwPollEventsCocoa,
|
||||||
|
_glfwWaitEventsCocoa,
|
||||||
|
_glfwWaitEventsTimeoutCocoa,
|
||||||
|
_glfwPostEmptyEventCocoa,
|
||||||
|
_glfwGetEGLPlatformCocoa,
|
||||||
|
_glfwGetEGLNativeDisplayCocoa,
|
||||||
|
_glfwGetEGLNativeWindowCocoa,
|
||||||
|
_glfwGetRequiredInstanceExtensionsCocoa,
|
||||||
|
_glfwGetPhysicalDevicePresentationSupportCocoa,
|
||||||
|
_glfwCreateWindowSurfaceCocoa,
|
||||||
|
};
|
||||||
|
|
||||||
|
*platform = cocoa;
|
||||||
|
return GLFW_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
int _glfwInitCocoa(void)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
|
|
||||||
@ -550,20 +620,21 @@ int _glfwPlatformInit(void)
|
|||||||
if (!initializeTIS())
|
if (!initializeTIS())
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
|
|
||||||
_glfwInitTimerNS();
|
_glfwPollMonitorsCocoa();
|
||||||
_glfwInitJoysticksNS();
|
|
||||||
|
|
||||||
_glfwPollMonitorsNS();
|
|
||||||
|
|
||||||
if (![[NSRunningApplication currentApplication] isFinishedLaunching])
|
if (![[NSRunningApplication currentApplication] isFinishedLaunching])
|
||||||
[NSApp run];
|
[NSApp run];
|
||||||
|
|
||||||
|
// In case we are unbundled, make us a proper UI application
|
||||||
|
if (_glfw.hints.init.ns.menubar)
|
||||||
|
[NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
|
||||||
|
|
||||||
return GLFW_TRUE;
|
return GLFW_TRUE;
|
||||||
|
|
||||||
} // autoreleasepool
|
} // autoreleasepool
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformTerminate(void)
|
void _glfwTerminateCocoa(void)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
|
|
||||||
@ -602,20 +673,10 @@ void _glfwPlatformTerminate(void)
|
|||||||
if (_glfw.ns.keyUpMonitor)
|
if (_glfw.ns.keyUpMonitor)
|
||||||
[NSEvent removeMonitor:_glfw.ns.keyUpMonitor];
|
[NSEvent removeMonitor:_glfw.ns.keyUpMonitor];
|
||||||
|
|
||||||
free(_glfw.ns.clipboardString);
|
_glfw_free(_glfw.ns.clipboardString);
|
||||||
|
|
||||||
_glfwTerminateNSGL();
|
_glfwTerminateNSGL();
|
||||||
_glfwTerminateJoysticksNS();
|
|
||||||
|
|
||||||
} // autoreleasepool
|
} // autoreleasepool
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* _glfwPlatformGetVersionString(void)
|
|
||||||
{
|
|
||||||
return _GLFW_VERSION_NUMBER " Cocoa NSGL EGL OSMesa"
|
|
||||||
#if defined(_GLFW_BUILD_DLL)
|
|
||||||
" dynamic"
|
|
||||||
#endif
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@ -26,13 +26,12 @@
|
|||||||
|
|
||||||
#include <IOKit/IOKitLib.h>
|
#include <IOKit/IOKitLib.h>
|
||||||
#include <IOKit/IOCFPlugIn.h>
|
#include <IOKit/IOCFPlugIn.h>
|
||||||
#include <IOKit/hid/IOHIDLib.h>
|
|
||||||
#include <IOKit/hid/IOHIDKeys.h>
|
#include <IOKit/hid/IOHIDKeys.h>
|
||||||
|
|
||||||
#define _GLFW_PLATFORM_JOYSTICK_STATE _GLFWjoystickNS ns
|
#define GLFW_COCOA_JOYSTICK_STATE _GLFWjoystickNS ns;
|
||||||
#define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE struct { int dummyJoystick; }
|
#define GLFW_COCOA_LIBRARY_JOYSTICK_STATE
|
||||||
|
|
||||||
#define _GLFW_PLATFORM_MAPPING_NAME "Mac OS X"
|
#define GLFW_BUILD_COCOA_MAPPINGS
|
||||||
|
|
||||||
// Cocoa-specific per-joystick data
|
// Cocoa-specific per-joystick data
|
||||||
//
|
//
|
||||||
@ -44,7 +43,9 @@ typedef struct _GLFWjoystickNS
|
|||||||
CFMutableArrayRef hats;
|
CFMutableArrayRef hats;
|
||||||
} _GLFWjoystickNS;
|
} _GLFWjoystickNS;
|
||||||
|
|
||||||
|
GLFWbool _glfwInitJoysticksCocoa(void);
|
||||||
void _glfwInitJoysticksNS(void);
|
void _glfwTerminateJoysticksCocoa(void);
|
||||||
void _glfwTerminateJoysticksNS(void);
|
int _glfwPollJoystickCocoa(_GLFWjoystick* js, int mode);
|
||||||
|
const char* _glfwGetMappingNameCocoa(void);
|
||||||
|
void _glfwUpdateGamepadGUIDCocoa(char* guid);
|
||||||
|
|
||||||
|
@ -96,21 +96,19 @@ static CFComparisonResult compareElements(const void* fp,
|
|||||||
//
|
//
|
||||||
static void closeJoystick(_GLFWjoystick* js)
|
static void closeJoystick(_GLFWjoystick* js)
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
|
|
||||||
if (!js->present)
|
if (!js->present)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (i = 0; i < CFArrayGetCount(js->ns.axes); i++)
|
for (int i = 0; i < CFArrayGetCount(js->ns.axes); i++)
|
||||||
free((void*) CFArrayGetValueAtIndex(js->ns.axes, i));
|
_glfw_free((void*) CFArrayGetValueAtIndex(js->ns.axes, i));
|
||||||
CFRelease(js->ns.axes);
|
CFRelease(js->ns.axes);
|
||||||
|
|
||||||
for (i = 0; i < CFArrayGetCount(js->ns.buttons); i++)
|
for (int i = 0; i < CFArrayGetCount(js->ns.buttons); i++)
|
||||||
free((void*) CFArrayGetValueAtIndex(js->ns.buttons, i));
|
_glfw_free((void*) CFArrayGetValueAtIndex(js->ns.buttons, i));
|
||||||
CFRelease(js->ns.buttons);
|
CFRelease(js->ns.buttons);
|
||||||
|
|
||||||
for (i = 0; i < CFArrayGetCount(js->ns.hats); i++)
|
for (int i = 0; i < CFArrayGetCount(js->ns.hats); i++)
|
||||||
free((void*) CFArrayGetValueAtIndex(js->ns.hats, i));
|
_glfw_free((void*) CFArrayGetValueAtIndex(js->ns.hats, i));
|
||||||
CFRelease(js->ns.hats);
|
CFRelease(js->ns.hats);
|
||||||
|
|
||||||
_glfwFreeJoystick(js);
|
_glfwFreeJoystick(js);
|
||||||
@ -127,7 +125,6 @@ static void matchCallback(void* context,
|
|||||||
int jid;
|
int jid;
|
||||||
char name[256];
|
char name[256];
|
||||||
char guid[33];
|
char guid[33];
|
||||||
CFIndex i;
|
|
||||||
CFTypeRef property;
|
CFTypeRef property;
|
||||||
uint32_t vendor = 0, product = 0, version = 0;
|
uint32_t vendor = 0, product = 0, version = 0;
|
||||||
_GLFWjoystick* js;
|
_GLFWjoystick* js;
|
||||||
@ -185,7 +182,7 @@ static void matchCallback(void* context,
|
|||||||
CFArrayRef elements =
|
CFArrayRef elements =
|
||||||
IOHIDDeviceCopyMatchingElements(device, NULL, kIOHIDOptionsTypeNone);
|
IOHIDDeviceCopyMatchingElements(device, NULL, kIOHIDOptionsTypeNone);
|
||||||
|
|
||||||
for (i = 0; i < CFArrayGetCount(elements); i++)
|
for (CFIndex i = 0; i < CFArrayGetCount(elements); i++)
|
||||||
{
|
{
|
||||||
IOHIDElementRef native = (IOHIDElementRef)
|
IOHIDElementRef native = (IOHIDElementRef)
|
||||||
CFArrayGetValueAtIndex(elements, i);
|
CFArrayGetValueAtIndex(elements, i);
|
||||||
@ -251,7 +248,7 @@ static void matchCallback(void* context,
|
|||||||
|
|
||||||
if (target)
|
if (target)
|
||||||
{
|
{
|
||||||
_GLFWjoyelementNS* element = calloc(1, sizeof(_GLFWjoyelementNS));
|
_GLFWjoyelementNS* element = _glfw_calloc(1, sizeof(_GLFWjoyelementNS));
|
||||||
element->native = native;
|
element->native = native;
|
||||||
element->usage = usage;
|
element->usage = usage;
|
||||||
element->index = (int) CFArrayGetCount(target);
|
element->index = (int) CFArrayGetCount(target);
|
||||||
@ -290,9 +287,7 @@ static void removeCallback(void* context,
|
|||||||
void* sender,
|
void* sender,
|
||||||
IOHIDDeviceRef device)
|
IOHIDDeviceRef device)
|
||||||
{
|
{
|
||||||
int jid;
|
for (int jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++)
|
||||||
|
|
||||||
for (jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++)
|
|
||||||
{
|
{
|
||||||
if (_glfw.joysticks[jid].ns.device == device)
|
if (_glfw.joysticks[jid].ns.device == device)
|
||||||
{
|
{
|
||||||
@ -304,12 +299,10 @@ static void removeCallback(void* context,
|
|||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
////// GLFW internal API //////
|
////// GLFW platform API //////
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// Initialize joystick interface
|
GLFWbool _glfwInitJoysticksCocoa(void)
|
||||||
//
|
|
||||||
void _glfwInitJoysticksNS(void)
|
|
||||||
{
|
{
|
||||||
CFMutableArrayRef matching;
|
CFMutableArrayRef matching;
|
||||||
const long usages[] =
|
const long usages[] =
|
||||||
@ -328,7 +321,7 @@ void _glfwInitJoysticksNS(void)
|
|||||||
if (!matching)
|
if (!matching)
|
||||||
{
|
{
|
||||||
_glfwInputError(GLFW_PLATFORM_ERROR, "Cocoa: Failed to create array");
|
_glfwInputError(GLFW_PLATFORM_ERROR, "Cocoa: Failed to create array");
|
||||||
return;
|
return GLFW_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t i = 0; i < sizeof(usages) / sizeof(long); i++)
|
for (size_t i = 0; i < sizeof(usages) / sizeof(long); i++)
|
||||||
@ -383,33 +376,27 @@ void _glfwInitJoysticksNS(void)
|
|||||||
// Execute the run loop once in order to register any initially-attached
|
// Execute the run loop once in order to register any initially-attached
|
||||||
// joysticks
|
// joysticks
|
||||||
CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, false);
|
CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, false);
|
||||||
|
return GLFW_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close all opened joystick handles
|
void _glfwTerminateJoysticksCocoa(void)
|
||||||
//
|
|
||||||
void _glfwTerminateJoysticksNS(void)
|
|
||||||
{
|
{
|
||||||
int jid;
|
for (int jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++)
|
||||||
|
|
||||||
for (jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++)
|
|
||||||
closeJoystick(_glfw.joysticks + jid);
|
closeJoystick(_glfw.joysticks + jid);
|
||||||
|
|
||||||
|
if (_glfw.ns.hidManager)
|
||||||
|
{
|
||||||
CFRelease(_glfw.ns.hidManager);
|
CFRelease(_glfw.ns.hidManager);
|
||||||
_glfw.ns.hidManager = NULL;
|
_glfw.ns.hidManager = NULL;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
int _glfwPollJoystickCocoa(_GLFWjoystick* js, int mode)
|
||||||
////// GLFW platform API //////
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
int _glfwPlatformPollJoystick(_GLFWjoystick* js, int mode)
|
|
||||||
{
|
{
|
||||||
if (mode & _GLFW_POLL_AXES)
|
if (mode & _GLFW_POLL_AXES)
|
||||||
{
|
{
|
||||||
CFIndex i;
|
for (CFIndex i = 0; i < CFArrayGetCount(js->ns.axes); i++)
|
||||||
|
|
||||||
for (i = 0; i < CFArrayGetCount(js->ns.axes); i++)
|
|
||||||
{
|
{
|
||||||
_GLFWjoyelementNS* axis = (_GLFWjoyelementNS*)
|
_GLFWjoyelementNS* axis = (_GLFWjoyelementNS*)
|
||||||
CFArrayGetValueAtIndex(js->ns.axes, i);
|
CFArrayGetValueAtIndex(js->ns.axes, i);
|
||||||
@ -434,9 +421,7 @@ int _glfwPlatformPollJoystick(_GLFWjoystick* js, int mode)
|
|||||||
|
|
||||||
if (mode & _GLFW_POLL_BUTTONS)
|
if (mode & _GLFW_POLL_BUTTONS)
|
||||||
{
|
{
|
||||||
CFIndex i;
|
for (CFIndex i = 0; i < CFArrayGetCount(js->ns.buttons); i++)
|
||||||
|
|
||||||
for (i = 0; i < CFArrayGetCount(js->ns.buttons); i++)
|
|
||||||
{
|
{
|
||||||
_GLFWjoyelementNS* button = (_GLFWjoyelementNS*)
|
_GLFWjoyelementNS* button = (_GLFWjoyelementNS*)
|
||||||
CFArrayGetValueAtIndex(js->ns.buttons, i);
|
CFArrayGetValueAtIndex(js->ns.buttons, i);
|
||||||
@ -445,7 +430,7 @@ int _glfwPlatformPollJoystick(_GLFWjoystick* js, int mode)
|
|||||||
_glfwInputJoystickButton(js, (int) i, state);
|
_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] =
|
const int states[9] =
|
||||||
{
|
{
|
||||||
@ -473,7 +458,12 @@ int _glfwPlatformPollJoystick(_GLFWjoystick* js, int mode)
|
|||||||
return js->present;
|
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) &&
|
if ((strncmp(guid + 4, "000000000000", 12) == 0) &&
|
||||||
(strncmp(guid + 20, "000000000000", 12) == 0))
|
(strncmp(guid + 20, "000000000000", 12) == 0))
|
||||||
|
@ -39,18 +39,31 @@
|
|||||||
|
|
||||||
// Get the name of the specified display, or NULL
|
// Get the name of the specified display, or NULL
|
||||||
//
|
//
|
||||||
static char* getDisplayName(CGDirectDisplayID displayID)
|
static char* getMonitorName(CGDirectDisplayID displayID, NSScreen* screen)
|
||||||
{
|
{
|
||||||
|
// IOKit doesn't work on Apple Silicon anymore
|
||||||
|
// Luckily, 10.15 introduced -[NSScreen localizedName].
|
||||||
|
// Use it if available, and fall back to IOKit otherwise.
|
||||||
|
if (screen)
|
||||||
|
{
|
||||||
|
if ([screen respondsToSelector:@selector(localizedName)])
|
||||||
|
{
|
||||||
|
NSString* name = [screen valueForKey:@"localizedName"];
|
||||||
|
if (name)
|
||||||
|
return _glfw_strdup([name UTF8String]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
io_iterator_t it;
|
io_iterator_t it;
|
||||||
io_service_t service;
|
io_service_t service;
|
||||||
CFDictionaryRef info;
|
CFDictionaryRef info;
|
||||||
|
|
||||||
if (IOServiceGetMatchingServices(kIOMasterPortDefault,
|
if (IOServiceGetMatchingServices(MACH_PORT_NULL,
|
||||||
IOServiceMatching("IODisplayConnect"),
|
IOServiceMatching("IODisplayConnect"),
|
||||||
&it) != 0)
|
&it) != 0)
|
||||||
{
|
{
|
||||||
// This may happen if a desktop Mac is running headless
|
// This may happen if a desktop Mac is running headless
|
||||||
return NULL;
|
return _glfw_strdup("Display");
|
||||||
}
|
}
|
||||||
|
|
||||||
while ((service = IOIteratorNext(it)) != 0)
|
while ((service = IOIteratorNext(it)) != 0)
|
||||||
@ -88,7 +101,7 @@ static char* getDisplayName(CGDirectDisplayID displayID)
|
|||||||
{
|
{
|
||||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||||
"Cocoa: Failed to find service port for display");
|
"Cocoa: Failed to find service port for display");
|
||||||
return NULL;
|
return _glfw_strdup("Display");
|
||||||
}
|
}
|
||||||
|
|
||||||
CFDictionaryRef names =
|
CFDictionaryRef names =
|
||||||
@ -101,13 +114,13 @@ static char* getDisplayName(CGDirectDisplayID displayID)
|
|||||||
{
|
{
|
||||||
// This may happen if a desktop Mac is running headless
|
// This may happen if a desktop Mac is running headless
|
||||||
CFRelease(info);
|
CFRelease(info);
|
||||||
return NULL;
|
return _glfw_strdup("Display");
|
||||||
}
|
}
|
||||||
|
|
||||||
const CFIndex size =
|
const CFIndex size =
|
||||||
CFStringGetMaximumSizeForEncoding(CFStringGetLength(nameRef),
|
CFStringGetMaximumSizeForEncoding(CFStringGetLength(nameRef),
|
||||||
kCFStringEncodingUTF8);
|
kCFStringEncodingUTF8);
|
||||||
char* name = calloc(size + 1, 1);
|
char* name = _glfw_calloc(size + 1, 1);
|
||||||
CFStringGetCString(nameRef, name, size, kCFStringEncodingUTF8);
|
CFStringGetCString(nameRef, name, size, kCFStringEncodingUTF8);
|
||||||
|
|
||||||
CFRelease(info);
|
CFRelease(info);
|
||||||
@ -209,31 +222,6 @@ static void endFadeReservation(CGDisplayFadeReservationToken token)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Finds and caches the NSScreen corresponding to the specified monitor
|
|
||||||
//
|
|
||||||
static GLFWbool refreshMonitorScreen(_GLFWmonitor* monitor)
|
|
||||||
{
|
|
||||||
if (monitor->ns.screen)
|
|
||||||
return GLFW_TRUE;
|
|
||||||
|
|
||||||
for (NSScreen* screen in [NSScreen screens])
|
|
||||||
{
|
|
||||||
NSNumber* displayID = [screen deviceDescription][@"NSScreenNumber"];
|
|
||||||
|
|
||||||
// HACK: Compare unit numbers instead of display IDs to work around
|
|
||||||
// display replacement on machines with automatic graphics
|
|
||||||
// switching
|
|
||||||
if (monitor->ns.unitNumber == CGDisplayUnitNumber([displayID unsignedIntValue]))
|
|
||||||
{
|
|
||||||
monitor->ns.screen = screen;
|
|
||||||
return GLFW_TRUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_glfwInputError(GLFW_PLATFORM_ERROR, "Cocoa: Failed to find a screen for monitor");
|
|
||||||
return GLFW_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Returns the display refresh rate queried from the I/O registry
|
// Returns the display refresh rate queried from the I/O registry
|
||||||
//
|
//
|
||||||
static double getFallbackRefreshRate(CGDirectDisplayID displayID)
|
static double getFallbackRefreshRate(CGDirectDisplayID displayID)
|
||||||
@ -243,7 +231,7 @@ static double getFallbackRefreshRate(CGDirectDisplayID displayID)
|
|||||||
io_iterator_t it;
|
io_iterator_t it;
|
||||||
io_service_t service;
|
io_service_t service;
|
||||||
|
|
||||||
if (IOServiceGetMatchingServices(kIOMasterPortDefault,
|
if (IOServiceGetMatchingServices(MACH_PORT_NULL,
|
||||||
IOServiceMatching("IOFramebuffer"),
|
IOServiceMatching("IOFramebuffer"),
|
||||||
&it) != 0)
|
&it) != 0)
|
||||||
{
|
{
|
||||||
@ -277,14 +265,20 @@ static double getFallbackRefreshRate(CGDirectDisplayID displayID)
|
|||||||
CFSTR("IOFBCurrentPixelCount"),
|
CFSTR("IOFBCurrentPixelCount"),
|
||||||
kCFAllocatorDefault,
|
kCFAllocatorDefault,
|
||||||
kNilOptions);
|
kNilOptions);
|
||||||
if (!clockRef || !countRef)
|
|
||||||
break;
|
|
||||||
|
|
||||||
uint32_t clock = 0, count = 0;
|
uint32_t clock = 0, count = 0;
|
||||||
|
|
||||||
|
if (clockRef)
|
||||||
|
{
|
||||||
CFNumberGetValue(clockRef, kCFNumberIntType, &clock);
|
CFNumberGetValue(clockRef, kCFNumberIntType, &clock);
|
||||||
CFNumberGetValue(countRef, kCFNumberIntType, &count);
|
|
||||||
CFRelease(clockRef);
|
CFRelease(clockRef);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (countRef)
|
||||||
|
{
|
||||||
|
CFNumberGetValue(countRef, kCFNumberIntType, &count);
|
||||||
CFRelease(countRef);
|
CFRelease(countRef);
|
||||||
|
}
|
||||||
|
|
||||||
if (clock > 0 && count > 0)
|
if (clock > 0 && count > 0)
|
||||||
refreshRate = clock / (double) count;
|
refreshRate = clock / (double) count;
|
||||||
@ -303,11 +297,11 @@ static double getFallbackRefreshRate(CGDirectDisplayID displayID)
|
|||||||
|
|
||||||
// Poll for changes in the set of connected monitors
|
// Poll for changes in the set of connected monitors
|
||||||
//
|
//
|
||||||
void _glfwPollMonitorsNS(void)
|
void _glfwPollMonitorsCocoa(void)
|
||||||
{
|
{
|
||||||
uint32_t displayCount;
|
uint32_t displayCount;
|
||||||
CGGetOnlineDisplayList(0, NULL, &displayCount);
|
CGGetOnlineDisplayList(0, NULL, &displayCount);
|
||||||
CGDirectDisplayID* displays = calloc(displayCount, sizeof(CGDirectDisplayID));
|
CGDirectDisplayID* displays = _glfw_calloc(displayCount, sizeof(CGDirectDisplayID));
|
||||||
CGGetOnlineDisplayList(displayCount, displays, &displayCount);
|
CGGetOnlineDisplayList(displayCount, displays, &displayCount);
|
||||||
|
|
||||||
for (int i = 0; i < _glfw.monitorCount; i++)
|
for (int i = 0; i < _glfw.monitorCount; i++)
|
||||||
@ -317,7 +311,7 @@ void _glfwPollMonitorsNS(void)
|
|||||||
uint32_t disconnectedCount = _glfw.monitorCount;
|
uint32_t disconnectedCount = _glfw.monitorCount;
|
||||||
if (disconnectedCount)
|
if (disconnectedCount)
|
||||||
{
|
{
|
||||||
disconnected = calloc(_glfw.monitorCount, sizeof(_GLFWmonitor*));
|
disconnected = _glfw_calloc(_glfw.monitorCount, sizeof(_GLFWmonitor*));
|
||||||
memcpy(disconnected,
|
memcpy(disconnected,
|
||||||
_glfw.monitors,
|
_glfw.monitors,
|
||||||
_glfw.monitorCount * sizeof(_GLFWmonitor*));
|
_glfw.monitorCount * sizeof(_GLFWmonitor*));
|
||||||
@ -328,29 +322,48 @@ void _glfwPollMonitorsNS(void)
|
|||||||
if (CGDisplayIsAsleep(displays[i]))
|
if (CGDisplayIsAsleep(displays[i]))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
const uint32_t unitNumber = CGDisplayUnitNumber(displays[i]);
|
||||||
|
NSScreen* screen = nil;
|
||||||
|
|
||||||
|
for (screen in [NSScreen screens])
|
||||||
|
{
|
||||||
|
NSNumber* screenNumber = [screen deviceDescription][@"NSScreenNumber"];
|
||||||
|
|
||||||
// HACK: Compare unit numbers instead of display IDs to work around
|
// HACK: Compare unit numbers instead of display IDs to work around
|
||||||
// display replacement on machines with automatic graphics
|
// display replacement on machines with automatic graphics
|
||||||
// switching
|
// switching
|
||||||
const uint32_t unitNumber = CGDisplayUnitNumber(displays[i]);
|
if (CGDisplayUnitNumber([screenNumber unsignedIntValue]) == unitNumber)
|
||||||
for (uint32_t j = 0; j < disconnectedCount; j++)
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// HACK: Compare unit numbers instead of display IDs to work around
|
||||||
|
// display replacement on machines with automatic graphics
|
||||||
|
// switching
|
||||||
|
uint32_t j;
|
||||||
|
for (j = 0; j < disconnectedCount; j++)
|
||||||
{
|
{
|
||||||
if (disconnected[j] && disconnected[j]->ns.unitNumber == unitNumber)
|
if (disconnected[j] && disconnected[j]->ns.unitNumber == unitNumber)
|
||||||
{
|
{
|
||||||
|
disconnected[j]->ns.screen = screen;
|
||||||
disconnected[j] = NULL;
|
disconnected[j] = NULL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (j < disconnectedCount)
|
||||||
|
continue;
|
||||||
|
|
||||||
const CGSize size = CGDisplayScreenSize(displays[i]);
|
const CGSize size = CGDisplayScreenSize(displays[i]);
|
||||||
char* name = getDisplayName(displays[i]);
|
char* name = getMonitorName(displays[i], screen);
|
||||||
if (!name)
|
if (!name)
|
||||||
name = _glfw_strdup("Unknown");
|
continue;
|
||||||
|
|
||||||
_GLFWmonitor* monitor = _glfwAllocMonitor(name, size.width, size.height);
|
_GLFWmonitor* monitor = _glfwAllocMonitor(name, size.width, size.height);
|
||||||
monitor->ns.displayID = displays[i];
|
monitor->ns.displayID = displays[i];
|
||||||
monitor->ns.unitNumber = unitNumber;
|
monitor->ns.unitNumber = unitNumber;
|
||||||
|
monitor->ns.screen = screen;
|
||||||
|
|
||||||
free(name);
|
_glfw_free(name);
|
||||||
|
|
||||||
CGDisplayModeRef mode = CGDisplayCopyDisplayMode(displays[i]);
|
CGDisplayModeRef mode = CGDisplayCopyDisplayMode(displays[i]);
|
||||||
if (CGDisplayModeGetRefreshRate(mode) == 0.0)
|
if (CGDisplayModeGetRefreshRate(mode) == 0.0)
|
||||||
@ -366,16 +379,16 @@ void _glfwPollMonitorsNS(void)
|
|||||||
_glfwInputMonitor(disconnected[i], GLFW_DISCONNECTED, 0);
|
_glfwInputMonitor(disconnected[i], GLFW_DISCONNECTED, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
free(disconnected);
|
_glfw_free(disconnected);
|
||||||
free(displays);
|
_glfw_free(displays);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Change the current video mode
|
// Change the current video mode
|
||||||
//
|
//
|
||||||
void _glfwSetVideoModeNS(_GLFWmonitor* monitor, const GLFWvidmode* desired)
|
void _glfwSetVideoModeCocoa(_GLFWmonitor* monitor, const GLFWvidmode* desired)
|
||||||
{
|
{
|
||||||
GLFWvidmode current;
|
GLFWvidmode current;
|
||||||
_glfwPlatformGetVideoMode(monitor, ¤t);
|
_glfwGetVideoModeCocoa(monitor, ¤t);
|
||||||
|
|
||||||
const GLFWvidmode* best = _glfwChooseVideoMode(monitor, desired);
|
const GLFWvidmode* best = _glfwChooseVideoMode(monitor, desired);
|
||||||
if (_glfwCompareVideoModes(¤t, best) == 0)
|
if (_glfwCompareVideoModes(¤t, best) == 0)
|
||||||
@ -415,7 +428,7 @@ void _glfwSetVideoModeNS(_GLFWmonitor* monitor, const GLFWvidmode* desired)
|
|||||||
|
|
||||||
// Restore the previously saved (original) video mode
|
// Restore the previously saved (original) video mode
|
||||||
//
|
//
|
||||||
void _glfwRestoreVideoModeNS(_GLFWmonitor* monitor)
|
void _glfwRestoreVideoModeCocoa(_GLFWmonitor* monitor)
|
||||||
{
|
{
|
||||||
if (monitor->ns.previousMode)
|
if (monitor->ns.previousMode)
|
||||||
{
|
{
|
||||||
@ -434,11 +447,11 @@ void _glfwRestoreVideoModeNS(_GLFWmonitor* monitor)
|
|||||||
////// GLFW platform API //////
|
////// 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 {
|
@autoreleasepool {
|
||||||
|
|
||||||
@ -452,13 +465,16 @@ void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos)
|
|||||||
} // autoreleasepool
|
} // autoreleasepool
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformGetMonitorContentScale(_GLFWmonitor* monitor,
|
void _glfwGetMonitorContentScaleCocoa(_GLFWmonitor* monitor,
|
||||||
float* xscale, float* yscale)
|
float* xscale, float* yscale)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
|
|
||||||
if (!refreshMonitorScreen(monitor))
|
if (!monitor->ns.screen)
|
||||||
return;
|
{
|
||||||
|
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||||
|
"Cocoa: Cannot query content scale without screen");
|
||||||
|
}
|
||||||
|
|
||||||
const NSRect points = [monitor->ns.screen frame];
|
const NSRect points = [monitor->ns.screen frame];
|
||||||
const NSRect pixels = [monitor->ns.screen convertRectToBacking:points];
|
const NSRect pixels = [monitor->ns.screen convertRectToBacking:points];
|
||||||
@ -471,21 +487,24 @@ void _glfwPlatformGetMonitorContentScale(_GLFWmonitor* monitor,
|
|||||||
} // autoreleasepool
|
} // autoreleasepool
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformGetMonitorWorkarea(_GLFWmonitor* monitor,
|
void _glfwGetMonitorWorkareaCocoa(_GLFWmonitor* monitor,
|
||||||
int* xpos, int* ypos,
|
int* xpos, int* ypos,
|
||||||
int* width, int* height)
|
int* width, int* height)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
|
|
||||||
if (!refreshMonitorScreen(monitor))
|
if (!monitor->ns.screen)
|
||||||
return;
|
{
|
||||||
|
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||||
|
"Cocoa: Cannot query workarea without screen");
|
||||||
|
}
|
||||||
|
|
||||||
const NSRect frameRect = [monitor->ns.screen visibleFrame];
|
const NSRect frameRect = [monitor->ns.screen visibleFrame];
|
||||||
|
|
||||||
if (xpos)
|
if (xpos)
|
||||||
*xpos = frameRect.origin.x;
|
*xpos = frameRect.origin.x;
|
||||||
if (ypos)
|
if (ypos)
|
||||||
*ypos = _glfwTransformYNS(frameRect.origin.y + frameRect.size.height - 1);
|
*ypos = _glfwTransformYCocoa(frameRect.origin.y + frameRect.size.height - 1);
|
||||||
if (width)
|
if (width)
|
||||||
*width = frameRect.size.width;
|
*width = frameRect.size.width;
|
||||||
if (height)
|
if (height)
|
||||||
@ -494,7 +513,7 @@ void _glfwPlatformGetMonitorWorkarea(_GLFWmonitor* monitor,
|
|||||||
} // autoreleasepool
|
} // autoreleasepool
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* count)
|
GLFWvidmode* _glfwGetVideoModesCocoa(_GLFWmonitor* monitor, int* count)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
|
|
||||||
@ -502,7 +521,7 @@ GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* count)
|
|||||||
|
|
||||||
CFArrayRef modes = CGDisplayCopyAllDisplayModes(monitor->ns.displayID, NULL);
|
CFArrayRef modes = CGDisplayCopyAllDisplayModes(monitor->ns.displayID, NULL);
|
||||||
const CFIndex found = CFArrayGetCount(modes);
|
const CFIndex found = CFArrayGetCount(modes);
|
||||||
GLFWvidmode* result = calloc(found, sizeof(GLFWvidmode));
|
GLFWvidmode* result = _glfw_calloc(found, sizeof(GLFWvidmode));
|
||||||
|
|
||||||
for (CFIndex i = 0; i < found; i++)
|
for (CFIndex i = 0; i < found; i++)
|
||||||
{
|
{
|
||||||
@ -521,7 +540,7 @@ GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* count)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Skip duplicate modes
|
// Skip duplicate modes
|
||||||
if (i < *count)
|
if (j < *count)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
(*count)++;
|
(*count)++;
|
||||||
@ -534,7 +553,7 @@ GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* count)
|
|||||||
} // autoreleasepool
|
} // autoreleasepool
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode *mode)
|
void _glfwGetVideoModeCocoa(_GLFWmonitor* monitor, GLFWvidmode *mode)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
|
|
||||||
@ -545,12 +564,12 @@ void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode *mode)
|
|||||||
} // autoreleasepool
|
} // autoreleasepool
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWbool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
|
GLFWbool _glfwGetGammaRampCocoa(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
|
|
||||||
uint32_t size = CGDisplayGammaTableCapacity(monitor->ns.displayID);
|
uint32_t size = CGDisplayGammaTableCapacity(monitor->ns.displayID);
|
||||||
CGGammaValue* values = calloc(size * 3, sizeof(CGGammaValue));
|
CGGammaValue* values = _glfw_calloc(size * 3, sizeof(CGGammaValue));
|
||||||
|
|
||||||
CGGetDisplayTransferByTable(monitor->ns.displayID,
|
CGGetDisplayTransferByTable(monitor->ns.displayID,
|
||||||
size,
|
size,
|
||||||
@ -568,17 +587,17 @@ GLFWbool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
|
|||||||
ramp->blue[i] = (unsigned short) (values[i + size * 2] * 65535);
|
ramp->blue[i] = (unsigned short) (values[i + size * 2] * 65535);
|
||||||
}
|
}
|
||||||
|
|
||||||
free(values);
|
_glfw_free(values);
|
||||||
return GLFW_TRUE;
|
return GLFW_TRUE;
|
||||||
|
|
||||||
} // autoreleasepool
|
} // autoreleasepool
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp)
|
void _glfwSetGammaRampCocoa(_GLFWmonitor* monitor, const GLFWgammaramp* ramp)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
|
|
||||||
CGGammaValue* values = calloc(ramp->size * 3, sizeof(CGGammaValue));
|
CGGammaValue* values = _glfw_calloc(ramp->size * 3, sizeof(CGGammaValue));
|
||||||
|
|
||||||
for (unsigned int i = 0; i < ramp->size; i++)
|
for (unsigned int i = 0; i < ramp->size; i++)
|
||||||
{
|
{
|
||||||
@ -593,7 +612,7 @@ void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp)
|
|||||||
values + ramp->size,
|
values + ramp->size,
|
||||||
values + ramp->size * 2);
|
values + ramp->size * 2);
|
||||||
|
|
||||||
free(values);
|
_glfw_free(values);
|
||||||
|
|
||||||
} // autoreleasepool
|
} // autoreleasepool
|
||||||
}
|
}
|
||||||
|
@ -25,13 +25,15 @@
|
|||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <dlfcn.h>
|
|
||||||
|
|
||||||
#include <Carbon/Carbon.h>
|
#include <Carbon/Carbon.h>
|
||||||
|
#include <IOKit/hid/IOHIDLib.h>
|
||||||
|
|
||||||
// NOTE: All of NSGL was deprecated in the 10.14 SDK
|
// NOTE: All of NSGL was deprecated in the 10.14 SDK
|
||||||
// This disables the pointless warnings for every symbol we use
|
// This disables the pointless warnings for every symbol we use
|
||||||
|
#ifndef GL_SILENCE_DEPRECATION
|
||||||
#define GL_SILENCE_DEPRECATION
|
#define GL_SILENCE_DEPRECATION
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(__OBJC__)
|
#if defined(__OBJC__)
|
||||||
#import <Cocoa/Cocoa.h>
|
#import <Cocoa/Cocoa.h>
|
||||||
@ -40,8 +42,15 @@ typedef void* id;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// NOTE: Many Cocoa enum values have been renamed and we need to build across
|
// NOTE: Many Cocoa enum values have been renamed and we need to build across
|
||||||
// SDK versions where one is unavailable or the other deprecated
|
// SDK versions where one is unavailable or deprecated.
|
||||||
// We use the newer names in code and these macros to handle compatibility
|
// 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
|
#if MAC_OS_X_VERSION_MAX_ALLOWED < 101200
|
||||||
#define NSBitmapFormatAlphaNonpremultiplied NSAlphaNonpremultipliedBitmapFormat
|
#define NSBitmapFormatAlphaNonpremultiplied NSAlphaNonpremultipliedBitmapFormat
|
||||||
#define NSEventMaskAny NSAnyEventMask
|
#define NSEventMaskAny NSAnyEventMask
|
||||||
@ -60,6 +69,15 @@ typedef void* id;
|
|||||||
#define NSWindowStyleMaskTitled NSTitledWindowMask
|
#define NSWindowStyleMaskTitled NSTitledWindowMask
|
||||||
#endif
|
#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 VkMacOSSurfaceCreateFlagsMVK;
|
||||||
typedef VkFlags VkMetalSurfaceCreateFlagsEXT;
|
typedef VkFlags VkMetalSurfaceCreateFlagsEXT;
|
||||||
|
|
||||||
@ -82,24 +100,13 @@ typedef struct VkMetalSurfaceCreateInfoEXT
|
|||||||
typedef VkResult (APIENTRY *PFN_vkCreateMacOSSurfaceMVK)(VkInstance,const VkMacOSSurfaceCreateInfoMVK*,const VkAllocationCallbacks*,VkSurfaceKHR*);
|
typedef VkResult (APIENTRY *PFN_vkCreateMacOSSurfaceMVK)(VkInstance,const VkMacOSSurfaceCreateInfoMVK*,const VkAllocationCallbacks*,VkSurfaceKHR*);
|
||||||
typedef VkResult (APIENTRY *PFN_vkCreateMetalSurfaceEXT)(VkInstance,const VkMetalSurfaceCreateInfoEXT*,const VkAllocationCallbacks*,VkSurfaceKHR*);
|
typedef VkResult (APIENTRY *PFN_vkCreateMetalSurfaceEXT)(VkInstance,const VkMetalSurfaceCreateInfoEXT*,const VkAllocationCallbacks*,VkSurfaceKHR*);
|
||||||
|
|
||||||
#include "posix_thread.h"
|
#define GLFW_COCOA_WINDOW_STATE _GLFWwindowNS ns;
|
||||||
#include "cocoa_joystick.h"
|
#define GLFW_COCOA_LIBRARY_WINDOW_STATE _GLFWlibraryNS ns;
|
||||||
#include "nsgl_context.h"
|
#define GLFW_COCOA_MONITOR_STATE _GLFWmonitorNS ns;
|
||||||
#include "egl_context.h"
|
#define GLFW_COCOA_CURSOR_STATE _GLFWcursorNS ns;
|
||||||
#include "osmesa_context.h"
|
|
||||||
|
|
||||||
#define _glfw_dlopen(name) dlopen(name, RTLD_LAZY | RTLD_LOCAL)
|
#define GLFW_NSGL_CONTEXT_STATE _GLFWcontextNSGL nsgl;
|
||||||
#define _glfw_dlclose(handle) dlclose(handle)
|
#define GLFW_NSGL_LIBRARY_CONTEXT_STATE _GLFWlibraryNSGL nsgl;
|
||||||
#define _glfw_dlsym(handle, name) dlsym(handle, name)
|
|
||||||
|
|
||||||
#define _GLFW_EGL_NATIVE_WINDOW ((EGLNativeWindowType) window->ns.view)
|
|
||||||
#define _GLFW_EGL_NATIVE_DISPLAY EGL_DEFAULT_DISPLAY
|
|
||||||
|
|
||||||
#define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowNS ns
|
|
||||||
#define _GLFW_PLATFORM_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
|
|
||||||
|
|
||||||
// HIToolbox.framework pointer typedefs
|
// HIToolbox.framework pointer typedefs
|
||||||
#define kTISPropertyUnicodeKeyLayoutData _glfw.ns.tis.kPropertyUnicodeKeyLayoutData
|
#define kTISPropertyUnicodeKeyLayoutData _glfw.ns.tis.kPropertyUnicodeKeyLayoutData
|
||||||
@ -111,6 +118,22 @@ typedef UInt8 (*PFN_LMGetKbdType)(void);
|
|||||||
#define LMGetKbdType _glfw.ns.tis.GetKbdType
|
#define LMGetKbdType _glfw.ns.tis.GetKbdType
|
||||||
|
|
||||||
|
|
||||||
|
// NSGL-specific per-context data
|
||||||
|
//
|
||||||
|
typedef struct _GLFWcontextNSGL
|
||||||
|
{
|
||||||
|
id pixelFormat;
|
||||||
|
id object;
|
||||||
|
} _GLFWcontextNSGL;
|
||||||
|
|
||||||
|
// NSGL-specific global data
|
||||||
|
//
|
||||||
|
typedef struct _GLFWlibraryNSGL
|
||||||
|
{
|
||||||
|
// dlopen handle for OpenGL.framework (for glfwGetProcAddress)
|
||||||
|
CFBundleRef framework;
|
||||||
|
} _GLFWlibraryNSGL;
|
||||||
|
|
||||||
// Cocoa-specific per-window data
|
// Cocoa-specific per-window data
|
||||||
//
|
//
|
||||||
typedef struct _GLFWwindowNS
|
typedef struct _GLFWwindowNS
|
||||||
@ -121,6 +144,7 @@ typedef struct _GLFWwindowNS
|
|||||||
id layer;
|
id layer;
|
||||||
|
|
||||||
GLFWbool maximized;
|
GLFWbool maximized;
|
||||||
|
GLFWbool occluded;
|
||||||
GLFWbool retina;
|
GLFWbool retina;
|
||||||
|
|
||||||
// Cached window properties to filter out duplicate events
|
// Cached window properties to filter out duplicate events
|
||||||
@ -132,7 +156,6 @@ typedef struct _GLFWwindowNS
|
|||||||
// since the last cursor motion event was processed
|
// since the last cursor motion event was processed
|
||||||
// This is kept to counteract Cocoa doing the same internally
|
// This is kept to counteract Cocoa doing the same internally
|
||||||
double cursorWarpDeltaX, cursorWarpDeltaY;
|
double cursorWarpDeltaX, cursorWarpDeltaY;
|
||||||
|
|
||||||
} _GLFWwindowNS;
|
} _GLFWwindowNS;
|
||||||
|
|
||||||
// Cocoa-specific global data
|
// Cocoa-specific global data
|
||||||
@ -166,7 +189,6 @@ typedef struct _GLFWlibraryNS
|
|||||||
PFN_LMGetKbdType GetKbdType;
|
PFN_LMGetKbdType GetKbdType;
|
||||||
CFStringRef kPropertyUnicodeKeyLayoutData;
|
CFStringRef kPropertyUnicodeKeyLayoutData;
|
||||||
} tis;
|
} tis;
|
||||||
|
|
||||||
} _GLFWlibraryNS;
|
} _GLFWlibraryNS;
|
||||||
|
|
||||||
// Cocoa-specific per-monitor data
|
// Cocoa-specific per-monitor data
|
||||||
@ -178,7 +200,6 @@ typedef struct _GLFWmonitorNS
|
|||||||
uint32_t unitNumber;
|
uint32_t unitNumber;
|
||||||
id screen;
|
id screen;
|
||||||
double fallbackRefreshRate;
|
double fallbackRefreshRate;
|
||||||
|
|
||||||
} _GLFWmonitorNS;
|
} _GLFWmonitorNS;
|
||||||
|
|
||||||
// Cocoa-specific per-cursor data
|
// Cocoa-specific per-cursor data
|
||||||
@ -186,25 +207,96 @@ typedef struct _GLFWmonitorNS
|
|||||||
typedef struct _GLFWcursorNS
|
typedef struct _GLFWcursorNS
|
||||||
{
|
{
|
||||||
id object;
|
id object;
|
||||||
|
|
||||||
} _GLFWcursorNS;
|
} _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 _glfwPollEventsCocoa(void);
|
||||||
void _glfwSetVideoModeNS(_GLFWmonitor* monitor, const GLFWvidmode* desired);
|
void _glfwWaitEventsCocoa(void);
|
||||||
void _glfwRestoreVideoModeNS(_GLFWmonitor* monitor);
|
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);
|
||||||
|
|
||||||
|
@ -32,12 +32,10 @@
|
|||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
////// GLFW internal API //////
|
////// GLFW platform API //////
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// Initialise timer
|
void _glfwPlatformInitTimer(void)
|
||||||
//
|
|
||||||
void _glfwInitTimerNS(void)
|
|
||||||
{
|
{
|
||||||
mach_timebase_info_data_t info;
|
mach_timebase_info_data_t info;
|
||||||
mach_timebase_info(&info);
|
mach_timebase_info(&info);
|
||||||
@ -45,11 +43,6 @@ void _glfwInitTimerNS(void)
|
|||||||
_glfw.timer.ns.frequency = (info.denom * 1e9) / info.numer;
|
_glfw.timer.ns.frequency = (info.denom * 1e9) / info.numer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
////// GLFW platform API //////
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
uint64_t _glfwPlatformGetTimerValue(void)
|
uint64_t _glfwPlatformGetTimerValue(void)
|
||||||
{
|
{
|
||||||
return mach_absolute_time();
|
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,7 +105,7 @@ static void updateCursorMode(_GLFWwindow* window)
|
|||||||
if (window->cursorMode == GLFW_CURSOR_DISABLED)
|
if (window->cursorMode == GLFW_CURSOR_DISABLED)
|
||||||
{
|
{
|
||||||
_glfw.ns.disabledCursorWindow = window;
|
_glfw.ns.disabledCursorWindow = window;
|
||||||
_glfwPlatformGetCursorPos(window,
|
_glfwGetCursorPosCocoa(window,
|
||||||
&_glfw.ns.restoreCursorPosX,
|
&_glfw.ns.restoreCursorPosX,
|
||||||
&_glfw.ns.restoreCursorPosY);
|
&_glfw.ns.restoreCursorPosY);
|
||||||
_glfwCenterCursorInContentArea(window);
|
_glfwCenterCursorInContentArea(window);
|
||||||
@ -114,10 +114,11 @@ static void updateCursorMode(_GLFWwindow* window)
|
|||||||
else if (_glfw.ns.disabledCursorWindow == window)
|
else if (_glfw.ns.disabledCursorWindow == window)
|
||||||
{
|
{
|
||||||
_glfw.ns.disabledCursorWindow = NULL;
|
_glfw.ns.disabledCursorWindow = NULL;
|
||||||
CGAssociateMouseAndMouseCursorPosition(true);
|
_glfwSetCursorPosCocoa(window,
|
||||||
_glfwPlatformSetCursorPos(window,
|
|
||||||
_glfw.ns.restoreCursorPosX,
|
_glfw.ns.restoreCursorPosX,
|
||||||
_glfw.ns.restoreCursorPosY);
|
_glfw.ns.restoreCursorPosY);
|
||||||
|
// NOTE: The matching CGAssociateMouseAndMouseCursorPosition call is
|
||||||
|
// made in _glfwSetCursorPosCocoa as part of a workaround
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cursorInContentArea(window))
|
if (cursorInContentArea(window))
|
||||||
@ -128,10 +129,10 @@ static void updateCursorMode(_GLFWwindow* window)
|
|||||||
//
|
//
|
||||||
static void acquireMonitor(_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 CGRect bounds = CGDisplayBounds(window->monitor->ns.displayID);
|
||||||
const NSRect frame = NSMakeRect(bounds.origin.x,
|
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.width,
|
||||||
bounds.size.height);
|
bounds.size.height);
|
||||||
|
|
||||||
@ -148,7 +149,7 @@ static void releaseMonitor(_GLFWwindow* window)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
_glfwInputMonitorWindow(window->monitor, NULL);
|
_glfwInputMonitorWindow(window->monitor, NULL);
|
||||||
_glfwRestoreVideoModeNS(window->monitor);
|
_glfwRestoreVideoModeCocoa(window->monitor);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Translates macOS key modifiers into GLFW ones
|
// Translates macOS key modifiers into GLFW ones
|
||||||
@ -243,7 +244,7 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
|
|||||||
|
|
||||||
- (void)windowDidResize:(NSNotification *)notification
|
- (void)windowDidResize:(NSNotification *)notification
|
||||||
{
|
{
|
||||||
if (window->context.client != GLFW_NO_API)
|
if (window->context.source == GLFW_NATIVE_CONTEXT_API)
|
||||||
[window->context.nsgl.object update];
|
[window->context.nsgl.object update];
|
||||||
|
|
||||||
if (_glfw.ns.disabledCursorWindow == window)
|
if (_glfw.ns.disabledCursorWindow == window)
|
||||||
@ -278,14 +279,14 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
|
|||||||
|
|
||||||
- (void)windowDidMove:(NSNotification *)notification
|
- (void)windowDidMove:(NSNotification *)notification
|
||||||
{
|
{
|
||||||
if (window->context.client != GLFW_NO_API)
|
if (window->context.source == GLFW_NATIVE_CONTEXT_API)
|
||||||
[window->context.nsgl.object update];
|
[window->context.nsgl.object update];
|
||||||
|
|
||||||
if (_glfw.ns.disabledCursorWindow == window)
|
if (_glfw.ns.disabledCursorWindow == window)
|
||||||
_glfwCenterCursorInContentArea(window);
|
_glfwCenterCursorInContentArea(window);
|
||||||
|
|
||||||
int x, y;
|
int x, y;
|
||||||
_glfwPlatformGetWindowPos(window, &x, &y);
|
_glfwGetWindowPosCocoa(window, &x, &y);
|
||||||
_glfwInputWindowPos(window, x, y);
|
_glfwInputWindowPos(window, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -317,11 +318,19 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
|
|||||||
- (void)windowDidResignKey:(NSNotification *)notification
|
- (void)windowDidResignKey:(NSNotification *)notification
|
||||||
{
|
{
|
||||||
if (window->monitor && window->autoIconify)
|
if (window->monitor && window->autoIconify)
|
||||||
_glfwPlatformIconifyWindow(window);
|
_glfwIconifyWindowCocoa(window);
|
||||||
|
|
||||||
_glfwInputWindowFocus(window, GLFW_FALSE);
|
_glfwInputWindowFocus(window, GLFW_FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)windowDidChangeOcclusionState:(NSNotification* )notification
|
||||||
|
{
|
||||||
|
if ([window->ns.object occlusionState] & NSWindowOcclusionStateVisible)
|
||||||
|
window->ns.occluded = GLFW_FALSE;
|
||||||
|
else
|
||||||
|
window->ns.occluded = GLFW_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
||||||
@ -352,9 +361,7 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
|
|||||||
markedText = [[NSMutableAttributedString alloc] init];
|
markedText = [[NSMutableAttributedString alloc] init];
|
||||||
|
|
||||||
[self updateTrackingAreas];
|
[self updateTrackingAreas];
|
||||||
// NOTE: kUTTypeURL corresponds to NSPasteboardTypeURL but is available
|
[self registerForDraggedTypes:@[NSPasteboardTypeURL]];
|
||||||
// on 10.7 without having been deprecated yet
|
|
||||||
[self registerForDraggedTypes:@[(__bridge NSString*) kUTTypeURL]];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
@ -389,7 +396,7 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
|
|||||||
|
|
||||||
- (void)updateLayer
|
- (void)updateLayer
|
||||||
{
|
{
|
||||||
if (window->context.client != GLFW_NO_API)
|
if (window->context.source == GLFW_NATIVE_CONTEXT_API)
|
||||||
[window->context.nsgl.object update];
|
[window->context.nsgl.object update];
|
||||||
|
|
||||||
_glfwInputWindowDamage(window);
|
_glfwInputWindowDamage(window);
|
||||||
@ -512,6 +519,18 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
|
|||||||
{
|
{
|
||||||
const NSRect contentRect = [window->ns.view frame];
|
const NSRect contentRect = [window->ns.view frame];
|
||||||
const NSRect fbRect = [window->ns.view convertRectToBacking:contentRect];
|
const NSRect fbRect = [window->ns.view convertRectToBacking:contentRect];
|
||||||
|
const float xscale = fbRect.size.width / contentRect.size.width;
|
||||||
|
const float yscale = fbRect.size.height / contentRect.size.height;
|
||||||
|
|
||||||
|
if (xscale != window->ns.xscale || yscale != window->ns.yscale)
|
||||||
|
{
|
||||||
|
if (window->ns.retina && window->ns.layer)
|
||||||
|
[window->ns.layer setContentsScale:[window->ns.object backingScaleFactor]];
|
||||||
|
|
||||||
|
window->ns.xscale = xscale;
|
||||||
|
window->ns.yscale = yscale;
|
||||||
|
_glfwInputWindowContentScale(window, xscale, yscale);
|
||||||
|
}
|
||||||
|
|
||||||
if (fbRect.size.width != window->ns.fbWidth ||
|
if (fbRect.size.width != window->ns.fbWidth ||
|
||||||
fbRect.size.height != window->ns.fbHeight)
|
fbRect.size.height != window->ns.fbHeight)
|
||||||
@ -520,19 +539,6 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
|
|||||||
window->ns.fbHeight = fbRect.size.height;
|
window->ns.fbHeight = fbRect.size.height;
|
||||||
_glfwInputFramebufferSize(window, fbRect.size.width, fbRect.size.height);
|
_glfwInputFramebufferSize(window, fbRect.size.width, fbRect.size.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
const float xscale = fbRect.size.width / contentRect.size.width;
|
|
||||||
const float yscale = fbRect.size.height / contentRect.size.height;
|
|
||||||
|
|
||||||
if (xscale != window->ns.xscale || yscale != window->ns.yscale)
|
|
||||||
{
|
|
||||||
window->ns.xscale = xscale;
|
|
||||||
window->ns.yscale = yscale;
|
|
||||||
_glfwInputWindowContentScale(window, xscale, yscale);
|
|
||||||
|
|
||||||
if (window->ns.retina && window->ns.layer)
|
|
||||||
[window->ns.layer setContentsScale:[window->ns.object backingScaleFactor]];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)drawRect:(NSRect)rect
|
- (void)drawRect:(NSRect)rect
|
||||||
@ -639,7 +645,7 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
|
|||||||
const NSUInteger count = [urls count];
|
const NSUInteger count = [urls count];
|
||||||
if (count)
|
if (count)
|
||||||
{
|
{
|
||||||
char** paths = calloc(count, sizeof(char*));
|
char** paths = _glfw_calloc(count, sizeof(char*));
|
||||||
|
|
||||||
for (NSUInteger i = 0; i < count; i++)
|
for (NSUInteger i = 0; i < count; i++)
|
||||||
paths[i] = _glfw_strdup([urls[i] fileSystemRepresentation]);
|
paths[i] = _glfw_strdup([urls[i] fileSystemRepresentation]);
|
||||||
@ -647,8 +653,8 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
|
|||||||
_glfwInputDrop(window, (int) count, (const char**) paths);
|
_glfwInputDrop(window, (int) count, (const char**) paths);
|
||||||
|
|
||||||
for (NSUInteger i = 0; i < count; i++)
|
for (NSUInteger i = 0; i < count; i++)
|
||||||
free(paths[i]);
|
_glfw_free(paths[i]);
|
||||||
free(paths);
|
_glfw_free(paths);
|
||||||
}
|
}
|
||||||
|
|
||||||
return YES;
|
return YES;
|
||||||
@ -723,16 +729,26 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
|
|||||||
else
|
else
|
||||||
characters = (NSString*) string;
|
characters = (NSString*) string;
|
||||||
|
|
||||||
const NSUInteger length = [characters length];
|
NSRange range = NSMakeRange(0, [characters length]);
|
||||||
for (NSUInteger i = 0; i < length; i++)
|
while (range.length)
|
||||||
{
|
{
|
||||||
const unichar codepoint = [characters characterAtIndex:i];
|
uint32_t codepoint = 0;
|
||||||
if ((codepoint & 0xff00) == 0xf700)
|
|
||||||
|
if ([characters getBytes:&codepoint
|
||||||
|
maxLength:sizeof(codepoint)
|
||||||
|
usedLength:NULL
|
||||||
|
encoding:NSUTF32StringEncoding
|
||||||
|
options:0
|
||||||
|
range:range
|
||||||
|
remainingRange:&range])
|
||||||
|
{
|
||||||
|
if (codepoint >= 0xf700 && codepoint <= 0xf7ff)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
_glfwInputChar(window, codepoint, mods, plain);
|
_glfwInputChar(window, codepoint, mods, plain);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
- (void)doCommandBySelector:(SEL)selector
|
- (void)doCommandBySelector:(SEL)selector
|
||||||
{
|
{
|
||||||
@ -785,8 +801,8 @@ static GLFWbool createNativeWindow(_GLFWwindow* window,
|
|||||||
GLFWvidmode mode;
|
GLFWvidmode mode;
|
||||||
int xpos, ypos;
|
int xpos, ypos;
|
||||||
|
|
||||||
_glfwPlatformGetVideoMode(window->monitor, &mode);
|
_glfwGetVideoModeCocoa(window->monitor, &mode);
|
||||||
_glfwPlatformGetMonitorPos(window->monitor, &xpos, &ypos);
|
_glfwGetMonitorPosCocoa(window->monitor, &xpos, &ypos);
|
||||||
|
|
||||||
contentRect = NSMakeRect(xpos, ypos, mode.width, mode.height);
|
contentRect = NSMakeRect(xpos, ypos, mode.width, mode.height);
|
||||||
}
|
}
|
||||||
@ -854,8 +870,8 @@ static GLFWbool createNativeWindow(_GLFWwindow* window,
|
|||||||
[window->ns.object setTabbingMode:NSWindowTabbingModeDisallowed];
|
[window->ns.object setTabbingMode:NSWindowTabbingModeDisallowed];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
_glfwPlatformGetWindowSize(window, &window->ns.width, &window->ns.height);
|
_glfwGetWindowSizeCocoa(window, &window->ns.width, &window->ns.height);
|
||||||
_glfwPlatformGetFramebufferSize(window, &window->ns.fbWidth, &window->ns.fbHeight);
|
_glfwGetFramebufferSizeCocoa(window, &window->ns.fbWidth, &window->ns.fbHeight);
|
||||||
|
|
||||||
return GLFW_TRUE;
|
return GLFW_TRUE;
|
||||||
}
|
}
|
||||||
@ -867,7 +883,7 @@ static GLFWbool createNativeWindow(_GLFWwindow* window,
|
|||||||
|
|
||||||
// Transforms a y-coordinate between the CG display and NS screen spaces
|
// 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;
|
return CGDisplayBounds(CGMainDisplayID()).size.height - y - 1;
|
||||||
}
|
}
|
||||||
@ -877,7 +893,7 @@ float _glfwTransformYNS(float y)
|
|||||||
////// GLFW platform API //////
|
////// GLFW platform API //////
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
int _glfwPlatformCreateWindow(_GLFWwindow* window,
|
int _glfwCreateWindowCocoa(_GLFWwindow* window,
|
||||||
const _GLFWwndconfig* wndconfig,
|
const _GLFWwndconfig* wndconfig,
|
||||||
const _GLFWctxconfig* ctxconfig,
|
const _GLFWctxconfig* ctxconfig,
|
||||||
const _GLFWfbconfig* fbconfig)
|
const _GLFWfbconfig* fbconfig)
|
||||||
@ -898,6 +914,11 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
|
|||||||
}
|
}
|
||||||
else if (ctxconfig->source == GLFW_EGL_CONTEXT_API)
|
else if (ctxconfig->source == GLFW_EGL_CONTEXT_API)
|
||||||
{
|
{
|
||||||
|
// EGL implementation on macOS use CALayer* EGLNativeWindowType so we
|
||||||
|
// need to get the layer for EGL window surface creation.
|
||||||
|
[window->ns.view setWantsLayer:YES];
|
||||||
|
window->ns.layer = [window->ns.view layer];
|
||||||
|
|
||||||
if (!_glfwInitEGL())
|
if (!_glfwInitEGL())
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
if (!_glfwCreateContextEGL(window, ctxconfig, fbconfig))
|
if (!_glfwCreateContextEGL(window, ctxconfig, fbconfig))
|
||||||
@ -914,8 +935,8 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
|
|||||||
|
|
||||||
if (window->monitor)
|
if (window->monitor)
|
||||||
{
|
{
|
||||||
_glfwPlatformShowWindow(window);
|
_glfwShowWindowCocoa(window);
|
||||||
_glfwPlatformFocusWindow(window);
|
_glfwFocusWindowCocoa(window);
|
||||||
acquireMonitor(window);
|
acquireMonitor(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -924,7 +945,7 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
|
|||||||
} // autoreleasepool
|
} // autoreleasepool
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformDestroyWindow(_GLFWwindow* window)
|
void _glfwDestroyWindowCocoa(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
|
|
||||||
@ -950,12 +971,12 @@ void _glfwPlatformDestroyWindow(_GLFWwindow* window)
|
|||||||
window->ns.object = nil;
|
window->ns.object = nil;
|
||||||
|
|
||||||
// HACK: Allow Cocoa to catch up before returning
|
// HACK: Allow Cocoa to catch up before returning
|
||||||
_glfwPlatformPollEvents();
|
_glfwPollEventsCocoa();
|
||||||
|
|
||||||
} // autoreleasepool
|
} // autoreleasepool
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title)
|
void _glfwSetWindowTitleCocoa(_GLFWwindow* window, const char* title)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
NSString* string = @(title);
|
NSString* string = @(title);
|
||||||
@ -966,13 +987,14 @@ void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title)
|
|||||||
} // autoreleasepool
|
} // autoreleasepool
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformSetWindowIcon(_GLFWwindow* window,
|
void _glfwSetWindowIconCocoa(_GLFWwindow* window,
|
||||||
int count, const GLFWimage* images)
|
int count, const GLFWimage* images)
|
||||||
{
|
{
|
||||||
// Regular windows do not have icons
|
_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 {
|
@autoreleasepool {
|
||||||
|
|
||||||
@ -982,24 +1004,24 @@ void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos)
|
|||||||
if (xpos)
|
if (xpos)
|
||||||
*xpos = contentRect.origin.x;
|
*xpos = contentRect.origin.x;
|
||||||
if (ypos)
|
if (ypos)
|
||||||
*ypos = _glfwTransformYNS(contentRect.origin.y + contentRect.size.height - 1);
|
*ypos = _glfwTransformYCocoa(contentRect.origin.y + contentRect.size.height - 1);
|
||||||
|
|
||||||
} // autoreleasepool
|
} // autoreleasepool
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformSetWindowPos(_GLFWwindow* window, int x, int y)
|
void _glfwSetWindowPosCocoa(_GLFWwindow* window, int x, int y)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
|
|
||||||
const NSRect contentRect = [window->ns.view frame];
|
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];
|
const NSRect frameRect = [window->ns.object frameRectForContentRect:dummyRect];
|
||||||
[window->ns.object setFrameOrigin:frameRect.origin];
|
[window->ns.object setFrameOrigin:frameRect.origin];
|
||||||
|
|
||||||
} // autoreleasepool
|
} // autoreleasepool
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformGetWindowSize(_GLFWwindow* window, int* width, int* height)
|
void _glfwGetWindowSizeCocoa(_GLFWwindow* window, int* width, int* height)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
|
|
||||||
@ -1013,7 +1035,7 @@ void _glfwPlatformGetWindowSize(_GLFWwindow* window, int* width, int* height)
|
|||||||
} // autoreleasepool
|
} // autoreleasepool
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
|
void _glfwSetWindowSizeCocoa(_GLFWwindow* window, int width, int height)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
|
|
||||||
@ -1035,7 +1057,7 @@ void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
|
|||||||
} // autoreleasepool
|
} // autoreleasepool
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformSetWindowSizeLimits(_GLFWwindow* window,
|
void _glfwSetWindowSizeLimitsCocoa(_GLFWwindow* window,
|
||||||
int minwidth, int minheight,
|
int minwidth, int minheight,
|
||||||
int maxwidth, int maxheight)
|
int maxwidth, int maxheight)
|
||||||
{
|
{
|
||||||
@ -1054,7 +1076,7 @@ void _glfwPlatformSetWindowSizeLimits(_GLFWwindow* window,
|
|||||||
} // autoreleasepool
|
} // autoreleasepool
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformSetWindowAspectRatio(_GLFWwindow* window, int numer, int denom)
|
void _glfwSetWindowAspectRatioCocoa(_GLFWwindow* window, int numer, int denom)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
if (numer == GLFW_DONT_CARE || denom == GLFW_DONT_CARE)
|
if (numer == GLFW_DONT_CARE || denom == GLFW_DONT_CARE)
|
||||||
@ -1064,7 +1086,7 @@ void _glfwPlatformSetWindowAspectRatio(_GLFWwindow* window, int numer, int denom
|
|||||||
} // autoreleasepool
|
} // autoreleasepool
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformGetFramebufferSize(_GLFWwindow* window, int* width, int* height)
|
void _glfwGetFramebufferSizeCocoa(_GLFWwindow* window, int* width, int* height)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
|
|
||||||
@ -1079,7 +1101,7 @@ void _glfwPlatformGetFramebufferSize(_GLFWwindow* window, int* width, int* heigh
|
|||||||
} // autoreleasepool
|
} // autoreleasepool
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformGetWindowFrameSize(_GLFWwindow* window,
|
void _glfwGetWindowFrameSizeCocoa(_GLFWwindow* window,
|
||||||
int* left, int* top,
|
int* left, int* top,
|
||||||
int* right, int* bottom)
|
int* right, int* bottom)
|
||||||
{
|
{
|
||||||
@ -1102,7 +1124,7 @@ void _glfwPlatformGetWindowFrameSize(_GLFWwindow* window,
|
|||||||
} // autoreleasepool
|
} // autoreleasepool
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformGetWindowContentScale(_GLFWwindow* window,
|
void _glfwGetWindowContentScaleCocoa(_GLFWwindow* window,
|
||||||
float* xscale, float* yscale)
|
float* xscale, float* yscale)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
@ -1118,14 +1140,14 @@ void _glfwPlatformGetWindowContentScale(_GLFWwindow* window,
|
|||||||
} // autoreleasepool
|
} // autoreleasepool
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformIconifyWindow(_GLFWwindow* window)
|
void _glfwIconifyWindowCocoa(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
[window->ns.object miniaturize:nil];
|
[window->ns.object miniaturize:nil];
|
||||||
} // autoreleasepool
|
} // autoreleasepool
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformRestoreWindow(_GLFWwindow* window)
|
void _glfwRestoreWindowCocoa(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
if ([window->ns.object isMiniaturized])
|
if ([window->ns.object isMiniaturized])
|
||||||
@ -1135,7 +1157,7 @@ void _glfwPlatformRestoreWindow(_GLFWwindow* window)
|
|||||||
} // autoreleasepool
|
} // autoreleasepool
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformMaximizeWindow(_GLFWwindow* window)
|
void _glfwMaximizeWindowCocoa(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
if (![window->ns.object isZoomed])
|
if (![window->ns.object isZoomed])
|
||||||
@ -1143,28 +1165,28 @@ void _glfwPlatformMaximizeWindow(_GLFWwindow* window)
|
|||||||
} // autoreleasepool
|
} // autoreleasepool
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformShowWindow(_GLFWwindow* window)
|
void _glfwShowWindowCocoa(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
[window->ns.object orderFront:nil];
|
[window->ns.object orderFront:nil];
|
||||||
} // autoreleasepool
|
} // autoreleasepool
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformHideWindow(_GLFWwindow* window)
|
void _glfwHideWindowCocoa(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
[window->ns.object orderOut:nil];
|
[window->ns.object orderOut:nil];
|
||||||
} // autoreleasepool
|
} // autoreleasepool
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformRequestWindowAttention(_GLFWwindow* window)
|
void _glfwRequestWindowAttentionCocoa(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
[NSApp requestUserAttention:NSInformationalRequest];
|
[NSApp requestUserAttention:NSInformationalRequest];
|
||||||
} // autoreleasepool
|
} // autoreleasepool
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformFocusWindow(_GLFWwindow* window)
|
void _glfwFocusWindowCocoa(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
// Make us the active application
|
// Make us the active application
|
||||||
@ -1176,7 +1198,7 @@ void _glfwPlatformFocusWindow(_GLFWwindow* window)
|
|||||||
} // autoreleasepool
|
} // autoreleasepool
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformSetWindowMonitor(_GLFWwindow* window,
|
void _glfwSetWindowMonitorCocoa(_GLFWwindow* window,
|
||||||
_GLFWmonitor* monitor,
|
_GLFWmonitor* monitor,
|
||||||
int xpos, int ypos,
|
int xpos, int ypos,
|
||||||
int width, int height,
|
int width, int height,
|
||||||
@ -1194,7 +1216,7 @@ void _glfwPlatformSetWindowMonitor(_GLFWwindow* window,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
const NSRect contentRect =
|
const NSRect contentRect =
|
||||||
NSMakeRect(xpos, _glfwTransformYNS(ypos + height - 1), width, height);
|
NSMakeRect(xpos, _glfwTransformYCocoa(ypos + height - 1), width, height);
|
||||||
const NSRect frameRect =
|
const NSRect frameRect =
|
||||||
[window->ns.object frameRectForContentRect:contentRect
|
[window->ns.object frameRectForContentRect:contentRect
|
||||||
styleMask:getStyleMask(window)];
|
styleMask:getStyleMask(window)];
|
||||||
@ -1212,7 +1234,7 @@ void _glfwPlatformSetWindowMonitor(_GLFWwindow* window,
|
|||||||
|
|
||||||
// HACK: Allow the state cached in Cocoa to catch up to reality
|
// HACK: Allow the state cached in Cocoa to catch up to reality
|
||||||
// TODO: Solve this in a less terrible way
|
// TODO: Solve this in a less terrible way
|
||||||
_glfwPlatformPollEvents();
|
_glfwPollEventsCocoa();
|
||||||
|
|
||||||
const NSUInteger styleMask = getStyleMask(window);
|
const NSUInteger styleMask = getStyleMask(window);
|
||||||
[window->ns.object setStyleMask:styleMask];
|
[window->ns.object setStyleMask:styleMask];
|
||||||
@ -1228,7 +1250,7 @@ void _glfwPlatformSetWindowMonitor(_GLFWwindow* window,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
NSRect contentRect = NSMakeRect(xpos, _glfwTransformYNS(ypos + height - 1),
|
NSRect contentRect = NSMakeRect(xpos, _glfwTransformYCocoa(ypos + height - 1),
|
||||||
width, height);
|
width, height);
|
||||||
NSRect frameRect = [window->ns.object frameRectForContentRect:contentRect
|
NSRect frameRect = [window->ns.object frameRectForContentRect:contentRect
|
||||||
styleMask:styleMask];
|
styleMask:styleMask];
|
||||||
@ -1269,35 +1291,35 @@ void _glfwPlatformSetWindowMonitor(_GLFWwindow* window,
|
|||||||
} // autoreleasepool
|
} // autoreleasepool
|
||||||
}
|
}
|
||||||
|
|
||||||
int _glfwPlatformWindowFocused(_GLFWwindow* window)
|
int _glfwWindowFocusedCocoa(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
return [window->ns.object isKeyWindow];
|
return [window->ns.object isKeyWindow];
|
||||||
} // autoreleasepool
|
} // autoreleasepool
|
||||||
}
|
}
|
||||||
|
|
||||||
int _glfwPlatformWindowIconified(_GLFWwindow* window)
|
int _glfwWindowIconifiedCocoa(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
return [window->ns.object isMiniaturized];
|
return [window->ns.object isMiniaturized];
|
||||||
} // autoreleasepool
|
} // autoreleasepool
|
||||||
}
|
}
|
||||||
|
|
||||||
int _glfwPlatformWindowVisible(_GLFWwindow* window)
|
int _glfwWindowVisibleCocoa(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
return [window->ns.object isVisible];
|
return [window->ns.object isVisible];
|
||||||
} // autoreleasepool
|
} // autoreleasepool
|
||||||
}
|
}
|
||||||
|
|
||||||
int _glfwPlatformWindowMaximized(_GLFWwindow* window)
|
int _glfwWindowMaximizedCocoa(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
return [window->ns.object isZoomed];
|
return [window->ns.object isZoomed];
|
||||||
} // autoreleasepool
|
} // autoreleasepool
|
||||||
}
|
}
|
||||||
|
|
||||||
int _glfwPlatformWindowHovered(_GLFWwindow* window)
|
int _glfwWindowHoveredCocoa(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
|
|
||||||
@ -1315,21 +1337,21 @@ int _glfwPlatformWindowHovered(_GLFWwindow* window)
|
|||||||
} // autoreleasepool
|
} // autoreleasepool
|
||||||
}
|
}
|
||||||
|
|
||||||
int _glfwPlatformFramebufferTransparent(_GLFWwindow* window)
|
int _glfwFramebufferTransparentCocoa(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
return ![window->ns.object isOpaque] && ![window->ns.view isOpaque];
|
return ![window->ns.object isOpaque] && ![window->ns.view isOpaque];
|
||||||
} // autoreleasepool
|
} // autoreleasepool
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformSetWindowResizable(_GLFWwindow* window, GLFWbool enabled)
|
void _glfwSetWindowResizableCocoa(_GLFWwindow* window, GLFWbool enabled)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
[window->ns.object setStyleMask:getStyleMask(window)];
|
[window->ns.object setStyleMask:getStyleMask(window)];
|
||||||
} // autoreleasepool
|
} // autoreleasepool
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformSetWindowDecorated(_GLFWwindow* window, GLFWbool enabled)
|
void _glfwSetWindowDecoratedCocoa(_GLFWwindow* window, GLFWbool enabled)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
[window->ns.object setStyleMask:getStyleMask(window)];
|
[window->ns.object setStyleMask:getStyleMask(window)];
|
||||||
@ -1354,30 +1376,39 @@ void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled)
|
|||||||
} // autoreleasepool
|
} // autoreleasepool
|
||||||
}
|
}
|
||||||
|
|
||||||
float _glfwPlatformGetWindowOpacity(_GLFWwindow* window)
|
void _glfwSetWindowMousePassthroughCocoa(_GLFWwindow* window, GLFWbool enabled)
|
||||||
|
{
|
||||||
|
@autoreleasepool {
|
||||||
|
[window->ns.object setIgnoresMouseEvents:enabled];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
float _glfwGetWindowOpacityCocoa(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
return (float) [window->ns.object alphaValue];
|
return (float) [window->ns.object alphaValue];
|
||||||
} // autoreleasepool
|
} // autoreleasepool
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformSetWindowOpacity(_GLFWwindow* window, float opacity)
|
void _glfwSetWindowOpacityCocoa(_GLFWwindow* window, float opacity)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
[window->ns.object setAlphaValue:opacity];
|
[window->ns.object setAlphaValue:opacity];
|
||||||
} // autoreleasepool
|
} // 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;
|
return GLFW_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformPollEvents(void)
|
void _glfwPollEventsCocoa(void)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
|
|
||||||
@ -1396,7 +1427,7 @@ void _glfwPlatformPollEvents(void)
|
|||||||
} // autoreleasepool
|
} // autoreleasepool
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformWaitEvents(void)
|
void _glfwWaitEventsCocoa(void)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
|
|
||||||
@ -1409,12 +1440,12 @@ void _glfwPlatformWaitEvents(void)
|
|||||||
dequeue:YES];
|
dequeue:YES];
|
||||||
[NSApp sendEvent:event];
|
[NSApp sendEvent:event];
|
||||||
|
|
||||||
_glfwPlatformPollEvents();
|
_glfwPollEventsCocoa();
|
||||||
|
|
||||||
} // autoreleasepool
|
} // autoreleasepool
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformWaitEventsTimeout(double timeout)
|
void _glfwWaitEventsTimeoutCocoa(double timeout)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
|
|
||||||
@ -1426,12 +1457,12 @@ void _glfwPlatformWaitEventsTimeout(double timeout)
|
|||||||
if (event)
|
if (event)
|
||||||
[NSApp sendEvent:event];
|
[NSApp sendEvent:event];
|
||||||
|
|
||||||
_glfwPlatformPollEvents();
|
_glfwPollEventsCocoa();
|
||||||
|
|
||||||
} // autoreleasepool
|
} // autoreleasepool
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformPostEmptyEvent(void)
|
void _glfwPostEmptyEventCocoa(void)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
|
|
||||||
@ -1449,7 +1480,7 @@ void _glfwPlatformPostEmptyEvent(void)
|
|||||||
} // autoreleasepool
|
} // autoreleasepool
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformGetCursorPos(_GLFWwindow* window, double* xpos, double* ypos)
|
void _glfwGetCursorPosCocoa(_GLFWwindow* window, double* xpos, double* ypos)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
|
|
||||||
@ -1465,7 +1496,7 @@ void _glfwPlatformGetCursorPos(_GLFWwindow* window, double* xpos, double* ypos)
|
|||||||
} // autoreleasepool
|
} // autoreleasepool
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformSetCursorPos(_GLFWwindow* window, double x, double y)
|
void _glfwSetCursorPosCocoa(_GLFWwindow* window, double x, double y)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
|
|
||||||
@ -1490,28 +1521,33 @@ void _glfwPlatformSetCursorPos(_GLFWwindow* window, double x, double y)
|
|||||||
const NSPoint globalPoint = globalRect.origin;
|
const NSPoint globalPoint = globalRect.origin;
|
||||||
|
|
||||||
CGWarpMouseCursorPosition(CGPointMake(globalPoint.x,
|
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
|
} // autoreleasepool
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode)
|
void _glfwSetCursorModeCocoa(_GLFWwindow* window, int mode)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
if (_glfwPlatformWindowFocused(window))
|
if (_glfwWindowFocusedCocoa(window))
|
||||||
updateCursorMode(window);
|
updateCursorMode(window);
|
||||||
} // autoreleasepool
|
} // autoreleasepool
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* _glfwPlatformGetScancodeName(int scancode)
|
const char* _glfwGetScancodeNameCocoa(int scancode)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
|
|
||||||
if (scancode < 0 || scancode > 0xff ||
|
if (scancode < 0 || scancode > 0xff ||
|
||||||
_glfw.ns.keycodes[scancode] == GLFW_KEY_UNKNOWN)
|
_glfw.ns.keycodes[scancode] == GLFW_KEY_UNKNOWN)
|
||||||
{
|
{
|
||||||
_glfwInputError(GLFW_INVALID_VALUE, "Invalid scancode");
|
_glfwInputError(GLFW_INVALID_VALUE, "Invalid scancode %i", scancode);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1553,12 +1589,12 @@ const char* _glfwPlatformGetScancodeName(int scancode)
|
|||||||
} // autoreleasepool
|
} // autoreleasepool
|
||||||
}
|
}
|
||||||
|
|
||||||
int _glfwPlatformGetKeyScancode(int key)
|
int _glfwGetKeyScancodeCocoa(int key)
|
||||||
{
|
{
|
||||||
return _glfw.ns.scancodes[key];
|
return _glfw.ns.scancodes[key];
|
||||||
}
|
}
|
||||||
|
|
||||||
int _glfwPlatformCreateCursor(_GLFWcursor* cursor,
|
int _glfwCreateCursorCocoa(_GLFWcursor* cursor,
|
||||||
const GLFWimage* image,
|
const GLFWimage* image,
|
||||||
int xhot, int yhot)
|
int xhot, int yhot)
|
||||||
{
|
{
|
||||||
@ -1602,21 +1638,28 @@ int _glfwPlatformCreateCursor(_GLFWcursor* cursor,
|
|||||||
} // autoreleasepool
|
} // autoreleasepool
|
||||||
}
|
}
|
||||||
|
|
||||||
int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape)
|
int _glfwCreateStandardCursorCocoa(_GLFWcursor* cursor, int shape)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
|
|
||||||
SEL cursorSelector = NULL;
|
SEL cursorSelector = NULL;
|
||||||
|
|
||||||
// HACK: Try to use a private message
|
// HACK: Try to use a private message
|
||||||
if (shape == GLFW_RESIZE_EW_CURSOR)
|
switch (shape)
|
||||||
|
{
|
||||||
|
case GLFW_RESIZE_EW_CURSOR:
|
||||||
cursorSelector = NSSelectorFromString(@"_windowResizeEastWestCursor");
|
cursorSelector = NSSelectorFromString(@"_windowResizeEastWestCursor");
|
||||||
else if (shape == GLFW_RESIZE_NS_CURSOR)
|
break;
|
||||||
|
case GLFW_RESIZE_NS_CURSOR:
|
||||||
cursorSelector = NSSelectorFromString(@"_windowResizeNorthSouthCursor");
|
cursorSelector = NSSelectorFromString(@"_windowResizeNorthSouthCursor");
|
||||||
else if (shape == GLFW_RESIZE_NWSE_CURSOR)
|
break;
|
||||||
|
case GLFW_RESIZE_NWSE_CURSOR:
|
||||||
cursorSelector = NSSelectorFromString(@"_windowResizeNorthWestSouthEastCursor");
|
cursorSelector = NSSelectorFromString(@"_windowResizeNorthWestSouthEastCursor");
|
||||||
else if (shape == GLFW_RESIZE_NESW_CURSOR)
|
break;
|
||||||
|
case GLFW_RESIZE_NESW_CURSOR:
|
||||||
cursorSelector = NSSelectorFromString(@"_windowResizeNorthEastSouthWestCursor");
|
cursorSelector = NSSelectorFromString(@"_windowResizeNorthEastSouthWestCursor");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (cursorSelector && [NSCursor respondsToSelector:cursorSelector])
|
if (cursorSelector && [NSCursor respondsToSelector:cursorSelector])
|
||||||
{
|
{
|
||||||
@ -1627,22 +1670,33 @@ int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape)
|
|||||||
|
|
||||||
if (!cursor->ns.object)
|
if (!cursor->ns.object)
|
||||||
{
|
{
|
||||||
if (shape == GLFW_ARROW_CURSOR)
|
switch (shape)
|
||||||
|
{
|
||||||
|
case GLFW_ARROW_CURSOR:
|
||||||
cursor->ns.object = [NSCursor arrowCursor];
|
cursor->ns.object = [NSCursor arrowCursor];
|
||||||
else if (shape == GLFW_IBEAM_CURSOR)
|
break;
|
||||||
|
case GLFW_IBEAM_CURSOR:
|
||||||
cursor->ns.object = [NSCursor IBeamCursor];
|
cursor->ns.object = [NSCursor IBeamCursor];
|
||||||
else if (shape == GLFW_CROSSHAIR_CURSOR)
|
break;
|
||||||
|
case GLFW_CROSSHAIR_CURSOR:
|
||||||
cursor->ns.object = [NSCursor crosshairCursor];
|
cursor->ns.object = [NSCursor crosshairCursor];
|
||||||
else if (shape == GLFW_POINTING_HAND_CURSOR)
|
break;
|
||||||
|
case GLFW_POINTING_HAND_CURSOR:
|
||||||
cursor->ns.object = [NSCursor pointingHandCursor];
|
cursor->ns.object = [NSCursor pointingHandCursor];
|
||||||
else if (shape == GLFW_RESIZE_EW_CURSOR)
|
break;
|
||||||
|
case GLFW_RESIZE_EW_CURSOR:
|
||||||
cursor->ns.object = [NSCursor resizeLeftRightCursor];
|
cursor->ns.object = [NSCursor resizeLeftRightCursor];
|
||||||
else if (shape == GLFW_RESIZE_NS_CURSOR)
|
break;
|
||||||
|
case GLFW_RESIZE_NS_CURSOR:
|
||||||
cursor->ns.object = [NSCursor resizeUpDownCursor];
|
cursor->ns.object = [NSCursor resizeUpDownCursor];
|
||||||
else if (shape == GLFW_RESIZE_ALL_CURSOR)
|
break;
|
||||||
|
case GLFW_RESIZE_ALL_CURSOR:
|
||||||
cursor->ns.object = [NSCursor closedHandCursor];
|
cursor->ns.object = [NSCursor closedHandCursor];
|
||||||
else if (shape == GLFW_NOT_ALLOWED_CURSOR)
|
break;
|
||||||
|
case GLFW_NOT_ALLOWED_CURSOR:
|
||||||
cursor->ns.object = [NSCursor operationNotAllowedCursor];
|
cursor->ns.object = [NSCursor operationNotAllowedCursor];
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!cursor->ns.object)
|
if (!cursor->ns.object)
|
||||||
@ -1658,7 +1712,7 @@ int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape)
|
|||||||
} // autoreleasepool
|
} // autoreleasepool
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformDestroyCursor(_GLFWcursor* cursor)
|
void _glfwDestroyCursorCocoa(_GLFWcursor* cursor)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
if (cursor->ns.object)
|
if (cursor->ns.object)
|
||||||
@ -1666,7 +1720,7 @@ void _glfwPlatformDestroyCursor(_GLFWcursor* cursor)
|
|||||||
} // autoreleasepool
|
} // autoreleasepool
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor)
|
void _glfwSetCursorCocoa(_GLFWwindow* window, _GLFWcursor* cursor)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
if (cursorInContentArea(window))
|
if (cursorInContentArea(window))
|
||||||
@ -1674,7 +1728,7 @@ void _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor)
|
|||||||
} // autoreleasepool
|
} // autoreleasepool
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformSetClipboardString(const char* string)
|
void _glfwSetClipboardStringCocoa(const char* string)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
NSPasteboard* pasteboard = [NSPasteboard generalPasteboard];
|
NSPasteboard* pasteboard = [NSPasteboard generalPasteboard];
|
||||||
@ -1683,7 +1737,7 @@ void _glfwPlatformSetClipboardString(const char* string)
|
|||||||
} // autoreleasepool
|
} // autoreleasepool
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* _glfwPlatformGetClipboardString(void)
|
const char* _glfwGetClipboardStringCocoa(void)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
|
|
||||||
@ -1704,7 +1758,7 @@ const char* _glfwPlatformGetClipboardString(void)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
free(_glfw.ns.clipboardString);
|
_glfw_free(_glfw.ns.clipboardString);
|
||||||
_glfw.ns.clipboardString = _glfw_strdup([object UTF8String]);
|
_glfw.ns.clipboardString = _glfw_strdup([object UTF8String]);
|
||||||
|
|
||||||
return _glfw.ns.clipboardString;
|
return _glfw.ns.clipboardString;
|
||||||
@ -1712,7 +1766,48 @@ const char* _glfwPlatformGetClipboardString(void)
|
|||||||
} // autoreleasepool
|
} // autoreleasepool
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformGetRequiredInstanceExtensions(char** extensions)
|
EGLenum _glfwGetEGLPlatformCocoa(EGLint** attribs)
|
||||||
|
{
|
||||||
|
if (_glfw.egl.ANGLE_platform_angle)
|
||||||
|
{
|
||||||
|
int type = 0;
|
||||||
|
|
||||||
|
if (_glfw.egl.ANGLE_platform_angle_opengl)
|
||||||
|
{
|
||||||
|
if (_glfw.hints.init.angleType == GLFW_ANGLE_PLATFORM_TYPE_OPENGL)
|
||||||
|
type = EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_glfw.egl.ANGLE_platform_angle_metal)
|
||||||
|
{
|
||||||
|
if (_glfw.hints.init.angleType == GLFW_ANGLE_PLATFORM_TYPE_METAL)
|
||||||
|
type = EGL_PLATFORM_ANGLE_TYPE_METAL_ANGLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (type)
|
||||||
|
{
|
||||||
|
*attribs = _glfw_calloc(3, sizeof(EGLint));
|
||||||
|
(*attribs)[0] = EGL_PLATFORM_ANGLE_TYPE_ANGLE;
|
||||||
|
(*attribs)[1] = type;
|
||||||
|
(*attribs)[2] = EGL_NONE;
|
||||||
|
return EGL_PLATFORM_ANGLE_ANGLE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
EGLNativeDisplayType _glfwGetEGLNativeDisplayCocoa(void)
|
||||||
|
{
|
||||||
|
return EGL_DEFAULT_DISPLAY;
|
||||||
|
}
|
||||||
|
|
||||||
|
EGLNativeWindowType _glfwGetEGLNativeWindowCocoa(_GLFWwindow* window)
|
||||||
|
{
|
||||||
|
return window->ns.layer;
|
||||||
|
}
|
||||||
|
|
||||||
|
void _glfwGetRequiredInstanceExtensionsCocoa(char** extensions)
|
||||||
{
|
{
|
||||||
if (_glfw.vk.KHR_surface && _glfw.vk.EXT_metal_surface)
|
if (_glfw.vk.KHR_surface && _glfw.vk.EXT_metal_surface)
|
||||||
{
|
{
|
||||||
@ -1726,14 +1821,14 @@ void _glfwPlatformGetRequiredInstanceExtensions(char** extensions)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int _glfwPlatformGetPhysicalDevicePresentationSupport(VkInstance instance,
|
int _glfwGetPhysicalDevicePresentationSupportCocoa(VkInstance instance,
|
||||||
VkPhysicalDevice device,
|
VkPhysicalDevice device,
|
||||||
uint32_t queuefamily)
|
uint32_t queuefamily)
|
||||||
{
|
{
|
||||||
return GLFW_TRUE;
|
return GLFW_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
VkResult _glfwPlatformCreateWindowSurface(VkInstance instance,
|
VkResult _glfwCreateWindowSurfaceCocoa(VkInstance instance,
|
||||||
_GLFWwindow* window,
|
_GLFWwindow* window,
|
||||||
const VkAllocationCallbacks* allocator,
|
const VkAllocationCallbacks* allocator,
|
||||||
VkSurfaceKHR* surface)
|
VkSurfaceKHR* surface)
|
||||||
@ -1833,6 +1928,14 @@ GLFWAPI id glfwGetCocoaWindow(GLFWwindow* handle)
|
|||||||
{
|
{
|
||||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||||
_GLFW_REQUIRE_INIT_OR_RETURN(nil);
|
_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;
|
return window->ns.object;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -196,12 +196,6 @@ const _GLFWfbconfig* _glfwChooseFBConfig(const _GLFWfbconfig* desired,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (desired->doublebuffer != current->doublebuffer)
|
|
||||||
{
|
|
||||||
// Double buffering is a hard constraint
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Count number of missing buffers
|
// Count number of missing buffers
|
||||||
{
|
{
|
||||||
missing = 0;
|
missing = 0;
|
||||||
@ -570,6 +564,8 @@ GLFWbool _glfwRefreshContextAttribs(_GLFWwindow* window,
|
|||||||
PFNGLCLEARPROC glClear = (PFNGLCLEARPROC)
|
PFNGLCLEARPROC glClear = (PFNGLCLEARPROC)
|
||||||
window->context.getProcAddress("glClear");
|
window->context.getProcAddress("glClear");
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
|
if (window->doublebuffer)
|
||||||
window->context.swapBuffers(window);
|
window->context.swapBuffers(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,10 +103,10 @@ static GLFWbool chooseEGLConfig(const _GLFWctxconfig* ctxconfig,
|
|||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
nativeConfigs = calloc(nativeCount, sizeof(EGLConfig));
|
nativeConfigs = _glfw_calloc(nativeCount, sizeof(EGLConfig));
|
||||||
eglGetConfigs(_glfw.egl.display, nativeConfigs, nativeCount, &nativeCount);
|
eglGetConfigs(_glfw.egl.display, nativeConfigs, nativeCount, &nativeCount);
|
||||||
|
|
||||||
usableConfigs = calloc(nativeCount, sizeof(_GLFWfbconfig));
|
usableConfigs = _glfw_calloc(nativeCount, sizeof(_GLFWfbconfig));
|
||||||
usableCount = 0;
|
usableCount = 0;
|
||||||
|
|
||||||
for (i = 0; i < nativeCount; i++)
|
for (i = 0; i < nativeCount; i++)
|
||||||
@ -123,6 +123,7 @@ static GLFWbool chooseEGLConfig(const _GLFWctxconfig* ctxconfig,
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
#if defined(_GLFW_X11)
|
#if defined(_GLFW_X11)
|
||||||
|
if (_glfw.platform.platformID == GLFW_PLATFORM_X11)
|
||||||
{
|
{
|
||||||
XVisualInfo vi = {0};
|
XVisualInfo vi = {0};
|
||||||
|
|
||||||
@ -173,7 +174,7 @@ static GLFWbool chooseEGLConfig(const _GLFWctxconfig* ctxconfig,
|
|||||||
u->stencilBits = getEGLConfigAttrib(n, EGL_STENCIL_SIZE);
|
u->stencilBits = getEGLConfigAttrib(n, EGL_STENCIL_SIZE);
|
||||||
|
|
||||||
u->samples = getEGLConfigAttrib(n, EGL_SAMPLES);
|
u->samples = getEGLConfigAttrib(n, EGL_SAMPLES);
|
||||||
u->doublebuffer = GLFW_TRUE;
|
u->doublebuffer = desired->doublebuffer;
|
||||||
|
|
||||||
u->handle = (uintptr_t) n;
|
u->handle = (uintptr_t) n;
|
||||||
usableCount++;
|
usableCount++;
|
||||||
@ -183,8 +184,8 @@ static GLFWbool chooseEGLConfig(const _GLFWctxconfig* ctxconfig,
|
|||||||
if (closest)
|
if (closest)
|
||||||
*result = (EGLConfig) closest->handle;
|
*result = (EGLConfig) closest->handle;
|
||||||
|
|
||||||
free(nativeConfigs);
|
_glfw_free(nativeConfigs);
|
||||||
free(usableConfigs);
|
_glfw_free(usableConfigs);
|
||||||
|
|
||||||
return closest != NULL;
|
return closest != NULL;
|
||||||
}
|
}
|
||||||
@ -230,6 +231,15 @@ static void swapBuffersEGL(_GLFWwindow* window)
|
|||||||
return;
|
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);
|
eglSwapBuffers(_glfw.egl.display, window->context.egl.surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -256,8 +266,8 @@ static GLFWglproc getProcAddressEGL(const char* procname)
|
|||||||
|
|
||||||
if (window->context.egl.client)
|
if (window->context.egl.client)
|
||||||
{
|
{
|
||||||
GLFWglproc proc = (GLFWglproc) _glfw_dlsym(window->context.egl.client,
|
GLFWglproc proc = (GLFWglproc)
|
||||||
procname);
|
_glfwPlatformGetModuleSymbol(window->context.egl.client, procname);
|
||||||
if (proc)
|
if (proc)
|
||||||
return proc;
|
return proc;
|
||||||
}
|
}
|
||||||
@ -267,15 +277,14 @@ static GLFWglproc getProcAddressEGL(const char* procname)
|
|||||||
|
|
||||||
static void destroyContextEGL(_GLFWwindow* window)
|
static void destroyContextEGL(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
#if defined(_GLFW_X11)
|
|
||||||
// NOTE: Do not unload libGL.so.1 while the X11 display is still open,
|
// NOTE: Do not unload libGL.so.1 while the X11 display is still open,
|
||||||
// as it will make XCloseDisplay segfault
|
// as it will make XCloseDisplay segfault
|
||||||
if (window->context.client != GLFW_OPENGL_API)
|
if (_glfw.platform.platformID != GLFW_PLATFORM_X11 ||
|
||||||
#endif // _GLFW_X11
|
window->context.client != GLFW_OPENGL_API)
|
||||||
{
|
{
|
||||||
if (window->context.egl.client)
|
if (window->context.egl.client)
|
||||||
{
|
{
|
||||||
_glfw_dlclose(window->context.egl.client);
|
_glfwPlatformFreeModule(window->context.egl.client);
|
||||||
window->context.egl.client = NULL;
|
window->context.egl.client = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -303,6 +312,8 @@ static void destroyContextEGL(_GLFWwindow* window)
|
|||||||
GLFWbool _glfwInitEGL(void)
|
GLFWbool _glfwInitEGL(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
EGLint* attribs = NULL;
|
||||||
|
const char* extensions;
|
||||||
const char* sonames[] =
|
const char* sonames[] =
|
||||||
{
|
{
|
||||||
#if defined(_GLFW_EGL_LIBRARY)
|
#if defined(_GLFW_EGL_LIBRARY)
|
||||||
@ -314,6 +325,8 @@ GLFWbool _glfwInitEGL(void)
|
|||||||
"libEGL.dylib",
|
"libEGL.dylib",
|
||||||
#elif defined(__CYGWIN__)
|
#elif defined(__CYGWIN__)
|
||||||
"libEGL-1.so",
|
"libEGL-1.so",
|
||||||
|
#elif defined(__OpenBSD__)
|
||||||
|
"libEGL.so",
|
||||||
#else
|
#else
|
||||||
"libEGL.so.1",
|
"libEGL.so.1",
|
||||||
#endif
|
#endif
|
||||||
@ -325,7 +338,7 @@ GLFWbool _glfwInitEGL(void)
|
|||||||
|
|
||||||
for (i = 0; sonames[i]; i++)
|
for (i = 0; sonames[i]; i++)
|
||||||
{
|
{
|
||||||
_glfw.egl.handle = _glfw_dlopen(sonames[i]);
|
_glfw.egl.handle = _glfwPlatformLoadModule(sonames[i]);
|
||||||
if (_glfw.egl.handle)
|
if (_glfw.egl.handle)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -339,37 +352,37 @@ GLFWbool _glfwInitEGL(void)
|
|||||||
_glfw.egl.prefix = (strncmp(sonames[i], "lib", 3) == 0);
|
_glfw.egl.prefix = (strncmp(sonames[i], "lib", 3) == 0);
|
||||||
|
|
||||||
_glfw.egl.GetConfigAttrib = (PFN_eglGetConfigAttrib)
|
_glfw.egl.GetConfigAttrib = (PFN_eglGetConfigAttrib)
|
||||||
_glfw_dlsym(_glfw.egl.handle, "eglGetConfigAttrib");
|
_glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglGetConfigAttrib");
|
||||||
_glfw.egl.GetConfigs = (PFN_eglGetConfigs)
|
_glfw.egl.GetConfigs = (PFN_eglGetConfigs)
|
||||||
_glfw_dlsym(_glfw.egl.handle, "eglGetConfigs");
|
_glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglGetConfigs");
|
||||||
_glfw.egl.GetDisplay = (PFN_eglGetDisplay)
|
_glfw.egl.GetDisplay = (PFN_eglGetDisplay)
|
||||||
_glfw_dlsym(_glfw.egl.handle, "eglGetDisplay");
|
_glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglGetDisplay");
|
||||||
_glfw.egl.GetError = (PFN_eglGetError)
|
_glfw.egl.GetError = (PFN_eglGetError)
|
||||||
_glfw_dlsym(_glfw.egl.handle, "eglGetError");
|
_glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglGetError");
|
||||||
_glfw.egl.Initialize = (PFN_eglInitialize)
|
_glfw.egl.Initialize = (PFN_eglInitialize)
|
||||||
_glfw_dlsym(_glfw.egl.handle, "eglInitialize");
|
_glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglInitialize");
|
||||||
_glfw.egl.Terminate = (PFN_eglTerminate)
|
_glfw.egl.Terminate = (PFN_eglTerminate)
|
||||||
_glfw_dlsym(_glfw.egl.handle, "eglTerminate");
|
_glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglTerminate");
|
||||||
_glfw.egl.BindAPI = (PFN_eglBindAPI)
|
_glfw.egl.BindAPI = (PFN_eglBindAPI)
|
||||||
_glfw_dlsym(_glfw.egl.handle, "eglBindAPI");
|
_glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglBindAPI");
|
||||||
_glfw.egl.CreateContext = (PFN_eglCreateContext)
|
_glfw.egl.CreateContext = (PFN_eglCreateContext)
|
||||||
_glfw_dlsym(_glfw.egl.handle, "eglCreateContext");
|
_glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglCreateContext");
|
||||||
_glfw.egl.DestroySurface = (PFN_eglDestroySurface)
|
_glfw.egl.DestroySurface = (PFN_eglDestroySurface)
|
||||||
_glfw_dlsym(_glfw.egl.handle, "eglDestroySurface");
|
_glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglDestroySurface");
|
||||||
_glfw.egl.DestroyContext = (PFN_eglDestroyContext)
|
_glfw.egl.DestroyContext = (PFN_eglDestroyContext)
|
||||||
_glfw_dlsym(_glfw.egl.handle, "eglDestroyContext");
|
_glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglDestroyContext");
|
||||||
_glfw.egl.CreateWindowSurface = (PFN_eglCreateWindowSurface)
|
_glfw.egl.CreateWindowSurface = (PFN_eglCreateWindowSurface)
|
||||||
_glfw_dlsym(_glfw.egl.handle, "eglCreateWindowSurface");
|
_glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglCreateWindowSurface");
|
||||||
_glfw.egl.MakeCurrent = (PFN_eglMakeCurrent)
|
_glfw.egl.MakeCurrent = (PFN_eglMakeCurrent)
|
||||||
_glfw_dlsym(_glfw.egl.handle, "eglMakeCurrent");
|
_glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglMakeCurrent");
|
||||||
_glfw.egl.SwapBuffers = (PFN_eglSwapBuffers)
|
_glfw.egl.SwapBuffers = (PFN_eglSwapBuffers)
|
||||||
_glfw_dlsym(_glfw.egl.handle, "eglSwapBuffers");
|
_glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglSwapBuffers");
|
||||||
_glfw.egl.SwapInterval = (PFN_eglSwapInterval)
|
_glfw.egl.SwapInterval = (PFN_eglSwapInterval)
|
||||||
_glfw_dlsym(_glfw.egl.handle, "eglSwapInterval");
|
_glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglSwapInterval");
|
||||||
_glfw.egl.QueryString = (PFN_eglQueryString)
|
_glfw.egl.QueryString = (PFN_eglQueryString)
|
||||||
_glfw_dlsym(_glfw.egl.handle, "eglQueryString");
|
_glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglQueryString");
|
||||||
_glfw.egl.GetProcAddress = (PFN_eglGetProcAddress)
|
_glfw.egl.GetProcAddress = (PFN_eglGetProcAddress)
|
||||||
_glfw_dlsym(_glfw.egl.handle, "eglGetProcAddress");
|
_glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglGetProcAddress");
|
||||||
|
|
||||||
if (!_glfw.egl.GetConfigAttrib ||
|
if (!_glfw.egl.GetConfigAttrib ||
|
||||||
!_glfw.egl.GetConfigs ||
|
!_glfw.egl.GetConfigs ||
|
||||||
@ -395,7 +408,51 @@ GLFWbool _glfwInitEGL(void)
|
|||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
_glfw.egl.display = eglGetDisplay(_GLFW_EGL_NATIVE_DISPLAY);
|
extensions = eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS);
|
||||||
|
if (extensions && eglGetError() == EGL_SUCCESS)
|
||||||
|
_glfw.egl.EXT_client_extensions = GLFW_TRUE;
|
||||||
|
|
||||||
|
if (_glfw.egl.EXT_client_extensions)
|
||||||
|
{
|
||||||
|
_glfw.egl.EXT_platform_base =
|
||||||
|
_glfwStringInExtensionString("EGL_EXT_platform_base", extensions);
|
||||||
|
_glfw.egl.EXT_platform_x11 =
|
||||||
|
_glfwStringInExtensionString("EGL_EXT_platform_x11", extensions);
|
||||||
|
_glfw.egl.EXT_platform_wayland =
|
||||||
|
_glfwStringInExtensionString("EGL_EXT_platform_wayland", extensions);
|
||||||
|
_glfw.egl.ANGLE_platform_angle =
|
||||||
|
_glfwStringInExtensionString("EGL_ANGLE_platform_angle", extensions);
|
||||||
|
_glfw.egl.ANGLE_platform_angle_opengl =
|
||||||
|
_glfwStringInExtensionString("EGL_ANGLE_platform_angle_opengl", extensions);
|
||||||
|
_glfw.egl.ANGLE_platform_angle_d3d =
|
||||||
|
_glfwStringInExtensionString("EGL_ANGLE_platform_angle_d3d", extensions);
|
||||||
|
_glfw.egl.ANGLE_platform_angle_vulkan =
|
||||||
|
_glfwStringInExtensionString("EGL_ANGLE_platform_angle_vulkan", extensions);
|
||||||
|
_glfw.egl.ANGLE_platform_angle_metal =
|
||||||
|
_glfwStringInExtensionString("EGL_ANGLE_platform_angle_metal", extensions);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_glfw.egl.EXT_platform_base)
|
||||||
|
{
|
||||||
|
_glfw.egl.GetPlatformDisplayEXT = (PFNEGLGETPLATFORMDISPLAYEXTPROC)
|
||||||
|
eglGetProcAddress("eglGetPlatformDisplayEXT");
|
||||||
|
_glfw.egl.CreatePlatformWindowSurfaceEXT = (PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC)
|
||||||
|
eglGetProcAddress("eglCreatePlatformWindowSurfaceEXT");
|
||||||
|
}
|
||||||
|
|
||||||
|
_glfw.egl.platform = _glfw.platform.getEGLPlatform(&attribs);
|
||||||
|
if (_glfw.egl.platform)
|
||||||
|
{
|
||||||
|
_glfw.egl.display =
|
||||||
|
eglGetPlatformDisplayEXT(_glfw.egl.platform,
|
||||||
|
_glfw.platform.getEGLNativeDisplay(),
|
||||||
|
attribs);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
_glfw.egl.display = eglGetDisplay(_glfw.platform.getEGLNativeDisplay());
|
||||||
|
|
||||||
|
_glfw_free(attribs);
|
||||||
|
|
||||||
if (_glfw.egl.display == EGL_NO_DISPLAY)
|
if (_glfw.egl.display == EGL_NO_DISPLAY)
|
||||||
{
|
{
|
||||||
_glfwInputError(GLFW_API_UNAVAILABLE,
|
_glfwInputError(GLFW_API_UNAVAILABLE,
|
||||||
@ -426,6 +483,8 @@ GLFWbool _glfwInitEGL(void)
|
|||||||
extensionSupportedEGL("EGL_KHR_get_all_proc_addresses");
|
extensionSupportedEGL("EGL_KHR_get_all_proc_addresses");
|
||||||
_glfw.egl.KHR_context_flush_control =
|
_glfw.egl.KHR_context_flush_control =
|
||||||
extensionSupportedEGL("EGL_KHR_context_flush_control");
|
extensionSupportedEGL("EGL_KHR_context_flush_control");
|
||||||
|
_glfw.egl.EXT_present_opaque =
|
||||||
|
extensionSupportedEGL("EGL_EXT_present_opaque");
|
||||||
|
|
||||||
return GLFW_TRUE;
|
return GLFW_TRUE;
|
||||||
}
|
}
|
||||||
@ -442,7 +501,7 @@ void _glfwTerminateEGL(void)
|
|||||||
|
|
||||||
if (_glfw.egl.handle)
|
if (_glfw.egl.handle)
|
||||||
{
|
{
|
||||||
_glfw_dlclose(_glfw.egl.handle);
|
_glfwPlatformFreeModule(_glfw.egl.handle);
|
||||||
_glfw.egl.handle = NULL;
|
_glfw.egl.handle = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -463,6 +522,7 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window,
|
|||||||
EGLint attribs[40];
|
EGLint attribs[40];
|
||||||
EGLConfig config;
|
EGLConfig config;
|
||||||
EGLContext share = NULL;
|
EGLContext share = NULL;
|
||||||
|
EGLNativeWindowType native;
|
||||||
int index = 0;
|
int index = 0;
|
||||||
|
|
||||||
if (!_glfw.egl.display)
|
if (!_glfw.egl.display)
|
||||||
@ -588,8 +648,7 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set up attributes for surface creation
|
// Set up attributes for surface creation
|
||||||
{
|
index = 0;
|
||||||
int index = 0;
|
|
||||||
|
|
||||||
if (fbconfig->sRGB)
|
if (fbconfig->sRGB)
|
||||||
{
|
{
|
||||||
@ -597,14 +656,28 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window,
|
|||||||
setAttrib(EGL_GL_COLORSPACE_KHR, EGL_GL_COLORSPACE_SRGB_KHR);
|
setAttrib(EGL_GL_COLORSPACE_KHR, EGL_GL_COLORSPACE_SRGB_KHR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!fbconfig->doublebuffer)
|
||||||
|
setAttrib(EGL_RENDER_BUFFER, EGL_SINGLE_BUFFER);
|
||||||
|
|
||||||
|
if (_glfw.egl.EXT_present_opaque)
|
||||||
|
setAttrib(EGL_PRESENT_OPAQUE_EXT, !fbconfig->transparent);
|
||||||
|
|
||||||
setAttrib(EGL_NONE, EGL_NONE);
|
setAttrib(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)
|
||||||
|
{
|
||||||
|
window->context.egl.surface =
|
||||||
|
eglCreatePlatformWindowSurfaceEXT(_glfw.egl.display, config, native, attribs);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
window->context.egl.surface =
|
||||||
|
eglCreateWindowSurface(_glfw.egl.display, config, native, attribs);
|
||||||
}
|
}
|
||||||
|
|
||||||
window->context.egl.surface =
|
|
||||||
eglCreateWindowSurface(_glfw.egl.display,
|
|
||||||
config,
|
|
||||||
_GLFW_EGL_NATIVE_WINDOW,
|
|
||||||
attribs);
|
|
||||||
if (window->context.egl.surface == EGL_NO_SURFACE)
|
if (window->context.egl.surface == EGL_NO_SURFACE)
|
||||||
{
|
{
|
||||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||||
@ -629,6 +702,8 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window,
|
|||||||
"libGLES_CM.dll",
|
"libGLES_CM.dll",
|
||||||
#elif defined(_GLFW_COCOA)
|
#elif defined(_GLFW_COCOA)
|
||||||
"libGLESv1_CM.dylib",
|
"libGLESv1_CM.dylib",
|
||||||
|
#elif defined(__OpenBSD__)
|
||||||
|
"libGLESv1_CM.so",
|
||||||
#else
|
#else
|
||||||
"libGLESv1_CM.so.1",
|
"libGLESv1_CM.so.1",
|
||||||
"libGLES_CM.so.1",
|
"libGLES_CM.so.1",
|
||||||
@ -646,6 +721,8 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window,
|
|||||||
"libGLESv2.dylib",
|
"libGLESv2.dylib",
|
||||||
#elif defined(__CYGWIN__)
|
#elif defined(__CYGWIN__)
|
||||||
"libGLESv2-2.so",
|
"libGLESv2-2.so",
|
||||||
|
#elif defined(__OpenBSD__)
|
||||||
|
"libGLESv2.so",
|
||||||
#else
|
#else
|
||||||
"libGLESv2.so.2",
|
"libGLESv2.so.2",
|
||||||
#endif
|
#endif
|
||||||
@ -657,6 +734,8 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window,
|
|||||||
_GLFW_OPENGL_LIBRARY,
|
_GLFW_OPENGL_LIBRARY,
|
||||||
#elif defined(_GLFW_WIN32)
|
#elif defined(_GLFW_WIN32)
|
||||||
#elif defined(_GLFW_COCOA)
|
#elif defined(_GLFW_COCOA)
|
||||||
|
#elif defined(__OpenBSD__)
|
||||||
|
"libGL.so",
|
||||||
#else
|
#else
|
||||||
"libGL.so.1",
|
"libGL.so.1",
|
||||||
#endif
|
#endif
|
||||||
@ -680,7 +759,7 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window,
|
|||||||
if (_glfw.egl.prefix != (strncmp(sonames[i], "lib", 3) == 0))
|
if (_glfw.egl.prefix != (strncmp(sonames[i], "lib", 3) == 0))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
window->context.egl.client = _glfw_dlopen(sonames[i]);
|
window->context.egl.client = _glfwPlatformLoadModule(sonames[i]);
|
||||||
if (window->context.egl.client)
|
if (window->context.egl.client)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -764,7 +843,7 @@ GLFWAPI EGLContext glfwGetEGLContext(GLFWwindow* handle)
|
|||||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||||
_GLFW_REQUIRE_INIT_OR_RETURN(EGL_NO_CONTEXT);
|
_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);
|
_glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL);
|
||||||
return EGL_NO_CONTEXT;
|
return EGL_NO_CONTEXT;
|
||||||
@ -778,7 +857,7 @@ GLFWAPI EGLSurface glfwGetEGLSurface(GLFWwindow* handle)
|
|||||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||||
_GLFW_REQUIRE_INIT_OR_RETURN(EGL_NO_SURFACE);
|
_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);
|
_glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL);
|
||||||
return EGL_NO_SURFACE;
|
return EGL_NO_SURFACE;
|
||||||
|
@ -1,215 +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_USE_EGLPLATFORM_H)
|
|
||||||
#include <EGL/eglplatform.h>
|
|
||||||
#elif defined(_GLFW_WIN32)
|
|
||||||
#define EGLAPIENTRY __stdcall
|
|
||||||
typedef HDC EGLNativeDisplayType;
|
|
||||||
typedef HWND EGLNativeWindowType;
|
|
||||||
#elif defined(_GLFW_COCOA)
|
|
||||||
#define EGLAPIENTRY
|
|
||||||
typedef void* EGLNativeDisplayType;
|
|
||||||
typedef id EGLNativeWindowType;
|
|
||||||
#elif defined(_GLFW_X11)
|
|
||||||
#define EGLAPIENTRY
|
|
||||||
typedef Display* EGLNativeDisplayType;
|
|
||||||
typedef Window EGLNativeWindowType;
|
|
||||||
#elif defined(_GLFW_WAYLAND)
|
|
||||||
#define EGLAPIENTRY
|
|
||||||
typedef struct wl_display* EGLNativeDisplayType;
|
|
||||||
typedef struct wl_egl_window* EGLNativeWindowType;
|
|
||||||
#else
|
|
||||||
#error "No supported EGL platform selected"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#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_EXTENSIONS 0x3055
|
|
||||||
#define EGL_CONTEXT_CLIENT_VERSION 0x3098
|
|
||||||
#define EGL_NATIVE_VISUAL_ID 0x302e
|
|
||||||
#define EGL_NO_SURFACE ((EGLSurface) 0)
|
|
||||||
#define EGL_NO_DISPLAY ((EGLDisplay) 0)
|
|
||||||
#define EGL_NO_CONTEXT ((EGLContext) 0)
|
|
||||||
#define EGL_DEFAULT_DISPLAY ((EGLNativeDisplayType) 0)
|
|
||||||
|
|
||||||
#define EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR 0x00000002
|
|
||||||
#define EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR 0x00000001
|
|
||||||
#define EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR 0x00000002
|
|
||||||
#define EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR 0x00000001
|
|
||||||
#define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR 0x31bd
|
|
||||||
#define EGL_NO_RESET_NOTIFICATION_KHR 0x31be
|
|
||||||
#define EGL_LOSE_CONTEXT_ON_RESET_KHR 0x31bf
|
|
||||||
#define EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR 0x00000004
|
|
||||||
#define EGL_CONTEXT_MAJOR_VERSION_KHR 0x3098
|
|
||||||
#define EGL_CONTEXT_MINOR_VERSION_KHR 0x30fb
|
|
||||||
#define EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR 0x30fd
|
|
||||||
#define EGL_CONTEXT_FLAGS_KHR 0x30fc
|
|
||||||
#define EGL_CONTEXT_OPENGL_NO_ERROR_KHR 0x31b3
|
|
||||||
#define EGL_GL_COLORSPACE_KHR 0x309d
|
|
||||||
#define EGL_GL_COLORSPACE_SRGB_KHR 0x3089
|
|
||||||
#define EGL_CONTEXT_RELEASE_BEHAVIOR_KHR 0x2097
|
|
||||||
#define EGL_CONTEXT_RELEASE_BEHAVIOR_NONE_KHR 0
|
|
||||||
#define EGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_KHR 0x2098
|
|
||||||
|
|
||||||
typedef int EGLint;
|
|
||||||
typedef unsigned int EGLBoolean;
|
|
||||||
typedef unsigned int EGLenum;
|
|
||||||
typedef void* EGLConfig;
|
|
||||||
typedef void* EGLContext;
|
|
||||||
typedef void* EGLDisplay;
|
|
||||||
typedef void* EGLSurface;
|
|
||||||
|
|
||||||
// EGL function pointer typedefs
|
|
||||||
typedef EGLBoolean (EGLAPIENTRY * PFN_eglGetConfigAttrib)(EGLDisplay,EGLConfig,EGLint,EGLint*);
|
|
||||||
typedef EGLBoolean (EGLAPIENTRY * PFN_eglGetConfigs)(EGLDisplay,EGLConfig*,EGLint,EGLint*);
|
|
||||||
typedef EGLDisplay (EGLAPIENTRY * PFN_eglGetDisplay)(EGLNativeDisplayType);
|
|
||||||
typedef EGLint (EGLAPIENTRY * PFN_eglGetError)(void);
|
|
||||||
typedef EGLBoolean (EGLAPIENTRY * PFN_eglInitialize)(EGLDisplay,EGLint*,EGLint*);
|
|
||||||
typedef EGLBoolean (EGLAPIENTRY * PFN_eglTerminate)(EGLDisplay);
|
|
||||||
typedef EGLBoolean (EGLAPIENTRY * PFN_eglBindAPI)(EGLenum);
|
|
||||||
typedef EGLContext (EGLAPIENTRY * PFN_eglCreateContext)(EGLDisplay,EGLConfig,EGLContext,const EGLint*);
|
|
||||||
typedef EGLBoolean (EGLAPIENTRY * PFN_eglDestroySurface)(EGLDisplay,EGLSurface);
|
|
||||||
typedef EGLBoolean (EGLAPIENTRY * PFN_eglDestroyContext)(EGLDisplay,EGLContext);
|
|
||||||
typedef EGLSurface (EGLAPIENTRY * PFN_eglCreateWindowSurface)(EGLDisplay,EGLConfig,EGLNativeWindowType,const EGLint*);
|
|
||||||
typedef EGLBoolean (EGLAPIENTRY * PFN_eglMakeCurrent)(EGLDisplay,EGLSurface,EGLSurface,EGLContext);
|
|
||||||
typedef EGLBoolean (EGLAPIENTRY * PFN_eglSwapBuffers)(EGLDisplay,EGLSurface);
|
|
||||||
typedef EGLBoolean (EGLAPIENTRY * PFN_eglSwapInterval)(EGLDisplay,EGLint);
|
|
||||||
typedef const char* (EGLAPIENTRY * PFN_eglQueryString)(EGLDisplay,EGLint);
|
|
||||||
typedef GLFWglproc (EGLAPIENTRY * PFN_eglGetProcAddress)(const char*);
|
|
||||||
#define eglGetConfigAttrib _glfw.egl.GetConfigAttrib
|
|
||||||
#define eglGetConfigs _glfw.egl.GetConfigs
|
|
||||||
#define eglGetDisplay _glfw.egl.GetDisplay
|
|
||||||
#define eglGetError _glfw.egl.GetError
|
|
||||||
#define eglInitialize _glfw.egl.Initialize
|
|
||||||
#define eglTerminate _glfw.egl.Terminate
|
|
||||||
#define eglBindAPI _glfw.egl.BindAPI
|
|
||||||
#define eglCreateContext _glfw.egl.CreateContext
|
|
||||||
#define eglDestroySurface _glfw.egl.DestroySurface
|
|
||||||
#define eglDestroyContext _glfw.egl.DestroyContext
|
|
||||||
#define eglCreateWindowSurface _glfw.egl.CreateWindowSurface
|
|
||||||
#define eglMakeCurrent _glfw.egl.MakeCurrent
|
|
||||||
#define eglSwapBuffers _glfw.egl.SwapBuffers
|
|
||||||
#define eglSwapInterval _glfw.egl.SwapInterval
|
|
||||||
#define eglQueryString _glfw.egl.QueryString
|
|
||||||
#define eglGetProcAddress _glfw.egl.GetProcAddress
|
|
||||||
|
|
||||||
#define _GLFW_EGL_CONTEXT_STATE _GLFWcontextEGL egl
|
|
||||||
#define _GLFW_EGL_LIBRARY_CONTEXT_STATE _GLFWlibraryEGL egl
|
|
||||||
|
|
||||||
|
|
||||||
// EGL-specific per-context data
|
|
||||||
//
|
|
||||||
typedef struct _GLFWcontextEGL
|
|
||||||
{
|
|
||||||
EGLConfig config;
|
|
||||||
EGLContext handle;
|
|
||||||
EGLSurface surface;
|
|
||||||
|
|
||||||
void* client;
|
|
||||||
|
|
||||||
} _GLFWcontextEGL;
|
|
||||||
|
|
||||||
// EGL-specific global data
|
|
||||||
//
|
|
||||||
typedef struct _GLFWlibraryEGL
|
|
||||||
{
|
|
||||||
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;
|
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
} _GLFWlibraryEGL;
|
|
||||||
|
|
||||||
|
|
||||||
GLFWbool _glfwInitEGL(void);
|
|
||||||
void _glfwTerminateEGL(void);
|
|
||||||
GLFWbool _glfwCreateContextEGL(_GLFWwindow* window,
|
|
||||||
const _GLFWctxconfig* ctxconfig,
|
|
||||||
const _GLFWfbconfig* fbconfig);
|
|
||||||
#if defined(_GLFW_X11)
|
|
||||||
GLFWbool _glfwChooseVisualEGL(const _GLFWwndconfig* wndconfig,
|
|
||||||
const _GLFWctxconfig* ctxconfig,
|
|
||||||
const _GLFWfbconfig* fbconfig,
|
|
||||||
Visual** visual, int* depth);
|
|
||||||
#endif /*_GLFW_X11*/
|
|
||||||
|
|
@ -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;
|
GLXFBConfig* nativeConfigs;
|
||||||
_GLFWfbconfig* usableConfigs;
|
_GLFWfbconfig* usableConfigs;
|
||||||
const _GLFWfbconfig* closest;
|
const _GLFWfbconfig* closest;
|
||||||
int i, nativeCount, usableCount;
|
int nativeCount, usableCount;
|
||||||
const char* vendor;
|
const char* vendor;
|
||||||
GLFWbool trustWindowBit = GLFW_TRUE;
|
GLFWbool trustWindowBit = GLFW_TRUE;
|
||||||
|
|
||||||
@ -73,10 +73,10 @@ static GLFWbool chooseGLXFBConfig(const _GLFWfbconfig* desired,
|
|||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
usableConfigs = calloc(nativeCount, sizeof(_GLFWfbconfig));
|
usableConfigs = _glfw_calloc(nativeCount, sizeof(_GLFWfbconfig));
|
||||||
usableCount = 0;
|
usableCount = 0;
|
||||||
|
|
||||||
for (i = 0; i < nativeCount; i++)
|
for (int i = 0; i < nativeCount; i++)
|
||||||
{
|
{
|
||||||
const GLXFBConfig n = nativeConfigs[i];
|
const GLXFBConfig n = nativeConfigs[i];
|
||||||
_GLFWfbconfig* u = usableConfigs + usableCount;
|
_GLFWfbconfig* u = usableConfigs + usableCount;
|
||||||
@ -92,6 +92,9 @@ static GLFWbool chooseGLXFBConfig(const _GLFWfbconfig* desired,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (getGLXFBConfigAttrib(n, GLX_DOUBLEBUFFER) != desired->doublebuffer)
|
||||||
|
continue;
|
||||||
|
|
||||||
if (desired->transparent)
|
if (desired->transparent)
|
||||||
{
|
{
|
||||||
XVisualInfo* vi = glXGetVisualFromFBConfig(_glfw.x11.display, n);
|
XVisualInfo* vi = glXGetVisualFromFBConfig(_glfw.x11.display, n);
|
||||||
@ -119,8 +122,6 @@ static GLFWbool chooseGLXFBConfig(const _GLFWfbconfig* desired,
|
|||||||
|
|
||||||
if (getGLXFBConfigAttrib(n, GLX_STEREO))
|
if (getGLXFBConfigAttrib(n, GLX_STEREO))
|
||||||
u->stereo = GLFW_TRUE;
|
u->stereo = GLFW_TRUE;
|
||||||
if (getGLXFBConfigAttrib(n, GLX_DOUBLEBUFFER))
|
|
||||||
u->doublebuffer = GLFW_TRUE;
|
|
||||||
|
|
||||||
if (_glfw.glx.ARB_multisample)
|
if (_glfw.glx.ARB_multisample)
|
||||||
u->samples = getGLXFBConfigAttrib(n, GLX_SAMPLES);
|
u->samples = getGLXFBConfigAttrib(n, GLX_SAMPLES);
|
||||||
@ -137,7 +138,7 @@ static GLFWbool chooseGLXFBConfig(const _GLFWfbconfig* desired,
|
|||||||
*result = (GLXFBConfig) closest->handle;
|
*result = (GLXFBConfig) closest->handle;
|
||||||
|
|
||||||
XFree(nativeConfigs);
|
XFree(nativeConfigs);
|
||||||
free(usableConfigs);
|
_glfw_free(usableConfigs);
|
||||||
|
|
||||||
return closest != NULL;
|
return closest != NULL;
|
||||||
}
|
}
|
||||||
@ -225,7 +226,7 @@ static GLFWglproc getProcAddressGLX(const char* procname)
|
|||||||
else if (_glfw.glx.GetProcAddressARB)
|
else if (_glfw.glx.GetProcAddressARB)
|
||||||
return _glfw.glx.GetProcAddressARB((const GLubyte*) procname);
|
return _glfw.glx.GetProcAddressARB((const GLubyte*) procname);
|
||||||
else
|
else
|
||||||
return _glfw_dlsym(_glfw.glx.handle, procname);
|
return _glfwPlatformGetModuleSymbol(_glfw.glx.handle, procname);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void destroyContextGLX(_GLFWwindow* window)
|
static void destroyContextGLX(_GLFWwindow* window)
|
||||||
@ -252,13 +253,14 @@ static void destroyContextGLX(_GLFWwindow* window)
|
|||||||
//
|
//
|
||||||
GLFWbool _glfwInitGLX(void)
|
GLFWbool _glfwInitGLX(void)
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
const char* sonames[] =
|
const char* sonames[] =
|
||||||
{
|
{
|
||||||
#if defined(_GLFW_GLX_LIBRARY)
|
#if defined(_GLFW_GLX_LIBRARY)
|
||||||
_GLFW_GLX_LIBRARY,
|
_GLFW_GLX_LIBRARY,
|
||||||
#elif defined(__CYGWIN__)
|
#elif defined(__CYGWIN__)
|
||||||
"libGL-1.so",
|
"libGL-1.so",
|
||||||
|
#elif defined(__OpenBSD__)
|
||||||
|
"libGL.so",
|
||||||
#else
|
#else
|
||||||
"libGL.so.1",
|
"libGL.so.1",
|
||||||
"libGL.so",
|
"libGL.so",
|
||||||
@ -269,9 +271,9 @@ GLFWbool _glfwInitGLX(void)
|
|||||||
if (_glfw.glx.handle)
|
if (_glfw.glx.handle)
|
||||||
return GLFW_TRUE;
|
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)
|
if (_glfw.glx.handle)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -282,36 +284,36 @@ GLFWbool _glfwInitGLX(void)
|
|||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
_glfw.glx.GetFBConfigs =
|
_glfw.glx.GetFBConfigs = (PFNGLXGETFBCONFIGSPROC)
|
||||||
_glfw_dlsym(_glfw.glx.handle, "glXGetFBConfigs");
|
_glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXGetFBConfigs");
|
||||||
_glfw.glx.GetFBConfigAttrib =
|
_glfw.glx.GetFBConfigAttrib = (PFNGLXGETFBCONFIGATTRIBPROC)
|
||||||
_glfw_dlsym(_glfw.glx.handle, "glXGetFBConfigAttrib");
|
_glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXGetFBConfigAttrib");
|
||||||
_glfw.glx.GetClientString =
|
_glfw.glx.GetClientString = (PFNGLXGETCLIENTSTRINGPROC)
|
||||||
_glfw_dlsym(_glfw.glx.handle, "glXGetClientString");
|
_glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXGetClientString");
|
||||||
_glfw.glx.QueryExtension =
|
_glfw.glx.QueryExtension = (PFNGLXQUERYEXTENSIONPROC)
|
||||||
_glfw_dlsym(_glfw.glx.handle, "glXQueryExtension");
|
_glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXQueryExtension");
|
||||||
_glfw.glx.QueryVersion =
|
_glfw.glx.QueryVersion = (PFNGLXQUERYVERSIONPROC)
|
||||||
_glfw_dlsym(_glfw.glx.handle, "glXQueryVersion");
|
_glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXQueryVersion");
|
||||||
_glfw.glx.DestroyContext =
|
_glfw.glx.DestroyContext = (PFNGLXDESTROYCONTEXTPROC)
|
||||||
_glfw_dlsym(_glfw.glx.handle, "glXDestroyContext");
|
_glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXDestroyContext");
|
||||||
_glfw.glx.MakeCurrent =
|
_glfw.glx.MakeCurrent = (PFNGLXMAKECURRENTPROC)
|
||||||
_glfw_dlsym(_glfw.glx.handle, "glXMakeCurrent");
|
_glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXMakeCurrent");
|
||||||
_glfw.glx.SwapBuffers =
|
_glfw.glx.SwapBuffers = (PFNGLXSWAPBUFFERSPROC)
|
||||||
_glfw_dlsym(_glfw.glx.handle, "glXSwapBuffers");
|
_glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXSwapBuffers");
|
||||||
_glfw.glx.QueryExtensionsString =
|
_glfw.glx.QueryExtensionsString = (PFNGLXQUERYEXTENSIONSSTRINGPROC)
|
||||||
_glfw_dlsym(_glfw.glx.handle, "glXQueryExtensionsString");
|
_glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXQueryExtensionsString");
|
||||||
_glfw.glx.CreateNewContext =
|
_glfw.glx.CreateNewContext = (PFNGLXCREATENEWCONTEXTPROC)
|
||||||
_glfw_dlsym(_glfw.glx.handle, "glXCreateNewContext");
|
_glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXCreateNewContext");
|
||||||
_glfw.glx.CreateWindow =
|
_glfw.glx.CreateWindow = (PFNGLXCREATEWINDOWPROC)
|
||||||
_glfw_dlsym(_glfw.glx.handle, "glXCreateWindow");
|
_glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXCreateWindow");
|
||||||
_glfw.glx.DestroyWindow =
|
_glfw.glx.DestroyWindow = (PFNGLXDESTROYWINDOWPROC)
|
||||||
_glfw_dlsym(_glfw.glx.handle, "glXDestroyWindow");
|
_glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXDestroyWindow");
|
||||||
_glfw.glx.GetProcAddress =
|
_glfw.glx.GetProcAddress = (PFNGLXGETPROCADDRESSPROC)
|
||||||
_glfw_dlsym(_glfw.glx.handle, "glXGetProcAddress");
|
_glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXGetProcAddress");
|
||||||
_glfw.glx.GetProcAddressARB =
|
_glfw.glx.GetProcAddressARB = (PFNGLXGETPROCADDRESSPROC)
|
||||||
_glfw_dlsym(_glfw.glx.handle, "glXGetProcAddressARB");
|
_glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXGetProcAddressARB");
|
||||||
_glfw.glx.GetVisualFromFBConfig =
|
_glfw.glx.GetVisualFromFBConfig = (PFNGLXGETVISUALFROMFBCONFIGPROC)
|
||||||
_glfw_dlsym(_glfw.glx.handle, "glXGetVisualFromFBConfig");
|
_glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXGetVisualFromFBConfig");
|
||||||
|
|
||||||
if (!_glfw.glx.GetFBConfigs ||
|
if (!_glfw.glx.GetFBConfigs ||
|
||||||
!_glfw.glx.GetFBConfigAttrib ||
|
!_glfw.glx.GetFBConfigAttrib ||
|
||||||
@ -424,11 +426,11 @@ GLFWbool _glfwInitGLX(void)
|
|||||||
void _glfwTerminateGLX(void)
|
void _glfwTerminateGLX(void)
|
||||||
{
|
{
|
||||||
// NOTE: This function must not call any X11 functions, as it is called
|
// 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)
|
if (_glfw.glx.handle)
|
||||||
{
|
{
|
||||||
_glfw_dlclose(_glfw.glx.handle);
|
_glfwPlatformFreeModule(_glfw.glx.handle);
|
||||||
_glfw.glx.handle = NULL;
|
_glfw.glx.handle = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -673,7 +675,13 @@ GLFWAPI GLXContext glfwGetGLXContext(GLFWwindow* handle)
|
|||||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
_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);
|
_glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL);
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -687,7 +695,13 @@ GLFWAPI GLXWindow glfwGetGLXWindow(GLFWwindow* handle)
|
|||||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||||
_GLFW_REQUIRE_INIT_OR_RETURN(None);
|
_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);
|
_glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL);
|
||||||
return None;
|
return None;
|
||||||
|
@ -1,181 +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
|
|
||||||
|
|
||||||
|
|
||||||
// GLX-specific per-context data
|
|
||||||
//
|
|
||||||
typedef struct _GLFWcontextGLX
|
|
||||||
{
|
|
||||||
GLXContext handle;
|
|
||||||
GLXWindow window;
|
|
||||||
|
|
||||||
} _GLFWcontextGLX;
|
|
||||||
|
|
||||||
// GLX-specific global data
|
|
||||||
//
|
|
||||||
typedef struct _GLFWlibraryGLX
|
|
||||||
{
|
|
||||||
int major, minor;
|
|
||||||
int eventBase;
|
|
||||||
int errorBase;
|
|
||||||
|
|
||||||
// dlopen handle for libGL.so.1
|
|
||||||
void* handle;
|
|
||||||
|
|
||||||
// GLX 1.3 functions
|
|
||||||
PFNGLXGETFBCONFIGSPROC GetFBConfigs;
|
|
||||||
PFNGLXGETFBCONFIGATTRIBPROC GetFBConfigAttrib;
|
|
||||||
PFNGLXGETCLIENTSTRINGPROC GetClientString;
|
|
||||||
PFNGLXQUERYEXTENSIONPROC QueryExtension;
|
|
||||||
PFNGLXQUERYVERSIONPROC QueryVersion;
|
|
||||||
PFNGLXDESTROYCONTEXTPROC DestroyContext;
|
|
||||||
PFNGLXMAKECURRENTPROC MakeCurrent;
|
|
||||||
PFNGLXSWAPBUFFERSPROC SwapBuffers;
|
|
||||||
PFNGLXQUERYEXTENSIONSSTRINGPROC QueryExtensionsString;
|
|
||||||
PFNGLXCREATENEWCONTEXTPROC CreateNewContext;
|
|
||||||
PFNGLXGETVISUALFROMFBCONFIGPROC GetVisualFromFBConfig;
|
|
||||||
PFNGLXCREATEWINDOWPROC CreateWindow;
|
|
||||||
PFNGLXDESTROYWINDOWPROC DestroyWindow;
|
|
||||||
|
|
||||||
// GLX 1.4 and extension functions
|
|
||||||
PFNGLXGETPROCADDRESSPROC GetProcAddress;
|
|
||||||
PFNGLXGETPROCADDRESSPROC GetProcAddressARB;
|
|
||||||
PFNGLXSWAPINTERVALSGIPROC SwapIntervalSGI;
|
|
||||||
PFNGLXSWAPINTERVALEXTPROC SwapIntervalEXT;
|
|
||||||
PFNGLXSWAPINTERVALMESAPROC SwapIntervalMESA;
|
|
||||||
PFNGLXCREATECONTEXTATTRIBSARBPROC CreateContextAttribsARB;
|
|
||||||
GLFWbool SGI_swap_control;
|
|
||||||
GLFWbool EXT_swap_control;
|
|
||||||
GLFWbool MESA_swap_control;
|
|
||||||
GLFWbool ARB_multisample;
|
|
||||||
GLFWbool ARB_framebuffer_sRGB;
|
|
||||||
GLFWbool EXT_framebuffer_sRGB;
|
|
||||||
GLFWbool ARB_create_context;
|
|
||||||
GLFWbool ARB_create_context_profile;
|
|
||||||
GLFWbool ARB_create_context_robustness;
|
|
||||||
GLFWbool EXT_create_context_es2_profile;
|
|
||||||
GLFWbool ARB_create_context_no_error;
|
|
||||||
GLFWbool ARB_context_flush_control;
|
|
||||||
|
|
||||||
} _GLFWlibraryGLX;
|
|
||||||
|
|
||||||
GLFWbool _glfwInitGLX(void);
|
|
||||||
void _glfwTerminateGLX(void);
|
|
||||||
GLFWbool _glfwCreateContextGLX(_GLFWwindow* window,
|
|
||||||
const _GLFWctxconfig* ctxconfig,
|
|
||||||
const _GLFWfbconfig* fbconfig);
|
|
||||||
void _glfwDestroyContextGLX(_GLFWwindow* window);
|
|
||||||
GLFWbool _glfwChooseVisualGLX(const _GLFWwndconfig* wndconfig,
|
|
||||||
const _GLFWctxconfig* ctxconfig,
|
|
||||||
const _GLFWfbconfig* fbconfig,
|
|
||||||
Visual** visual, int* depth);
|
|
||||||
|
|
212
src/init.c
212
src/init.c
@ -28,7 +28,6 @@
|
|||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
#include "mappings.h"
|
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -37,28 +36,55 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
|
|
||||||
// The global variables below comprise all mutable global data in GLFW
|
// NOTE: The global variables below comprise all mutable global data in GLFW
|
||||||
//
|
// Any other mutable global variable is a bug
|
||||||
// Any other 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 };
|
_GLFWlibrary _glfw = { GLFW_FALSE };
|
||||||
|
|
||||||
// These are outside of _glfw so they can be used before initialization and
|
// 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 _GLFWerror _glfwMainThreadError;
|
||||||
static GLFWerrorfun _glfwErrorCallback;
|
static GLFWerrorfun _glfwErrorCallback;
|
||||||
|
static GLFWallocator _glfwInitAllocator;
|
||||||
static _GLFWinitconfig _glfwInitHints =
|
static _GLFWinitconfig _glfwInitHints =
|
||||||
{
|
{
|
||||||
GLFW_TRUE, // hat buttons
|
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 menu bar
|
||||||
GLFW_TRUE // macOS bundle chdir
|
GLFW_TRUE // macOS bundle chdir
|
||||||
}
|
},
|
||||||
|
{
|
||||||
|
GLFW_TRUE, // X11 XCB Vulkan surface
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// The allocation function used when no custom allocator is set
|
||||||
|
//
|
||||||
|
static void* defaultAllocate(size_t size, void* user)
|
||||||
|
{
|
||||||
|
return malloc(size);
|
||||||
|
}
|
||||||
|
|
||||||
|
// The deallocation function used when no custom allocator is set
|
||||||
|
//
|
||||||
|
static void defaultDeallocate(void* block, void* user)
|
||||||
|
{
|
||||||
|
free(block);
|
||||||
|
}
|
||||||
|
|
||||||
|
// The reallocation function used when no custom allocator is set
|
||||||
|
//
|
||||||
|
static void* defaultReallocate(void* block, size_t size, void* user)
|
||||||
|
{
|
||||||
|
return realloc(block, size);
|
||||||
|
}
|
||||||
|
|
||||||
// Terminate the library
|
// Terminate the library
|
||||||
//
|
//
|
||||||
static void terminate(void)
|
static void terminate(void)
|
||||||
@ -77,20 +103,21 @@ static void terminate(void)
|
|||||||
{
|
{
|
||||||
_GLFWmonitor* monitor = _glfw.monitors[i];
|
_GLFWmonitor* monitor = _glfw.monitors[i];
|
||||||
if (monitor->originalRamp.size)
|
if (monitor->originalRamp.size)
|
||||||
_glfwPlatformSetGammaRamp(monitor, &monitor->originalRamp);
|
_glfw.platform.setGammaRamp(monitor, &monitor->originalRamp);
|
||||||
_glfwFreeMonitor(monitor);
|
_glfwFreeMonitor(monitor);
|
||||||
}
|
}
|
||||||
|
|
||||||
free(_glfw.monitors);
|
_glfw_free(_glfw.monitors);
|
||||||
_glfw.monitors = NULL;
|
_glfw.monitors = NULL;
|
||||||
_glfw.monitorCount = 0;
|
_glfw.monitorCount = 0;
|
||||||
|
|
||||||
free(_glfw.mappings);
|
_glfw_free(_glfw.mappings);
|
||||||
_glfw.mappings = NULL;
|
_glfw.mappings = NULL;
|
||||||
_glfw.mappingCount = 0;
|
_glfw.mappingCount = 0;
|
||||||
|
|
||||||
_glfwTerminateVulkan();
|
_glfwTerminateVulkan();
|
||||||
_glfwPlatformTerminate();
|
_glfw.platform.terminateJoysticks();
|
||||||
|
_glfw.platform.terminate();
|
||||||
|
|
||||||
_glfw.initialized = GLFW_FALSE;
|
_glfw.initialized = GLFW_FALSE;
|
||||||
|
|
||||||
@ -98,7 +125,7 @@ static void terminate(void)
|
|||||||
{
|
{
|
||||||
_GLFWerror* error = _glfw.errorListHead;
|
_GLFWerror* error = _glfw.errorListHead;
|
||||||
_glfw.errorListHead = error->next;
|
_glfw.errorListHead = error->next;
|
||||||
free(error);
|
_glfw_free(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
_glfwPlatformDestroyTls(&_glfw.contextSlot);
|
_glfwPlatformDestroyTls(&_glfw.contextSlot);
|
||||||
@ -113,10 +140,41 @@ static void terminate(void)
|
|||||||
////// GLFW internal API //////
|
////// 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)
|
char* _glfw_strdup(const char* source)
|
||||||
{
|
{
|
||||||
const size_t length = strlen(source);
|
const size_t length = strlen(source);
|
||||||
char* result = calloc(length + 1, 1);
|
char* result = _glfw_calloc(length + 1, 1);
|
||||||
strcpy(result, source);
|
strcpy(result, source);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -145,6 +203,59 @@ float _glfw_fmaxf(float a, float b)
|
|||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void* _glfw_calloc(size_t count, size_t size)
|
||||||
|
{
|
||||||
|
if (count && size)
|
||||||
|
{
|
||||||
|
void* block;
|
||||||
|
|
||||||
|
if (count > SIZE_MAX / size)
|
||||||
|
{
|
||||||
|
_glfwInputError(GLFW_INVALID_VALUE, "Allocation size overflow");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
block = _glfw.allocator.allocate(count * size, _glfw.allocator.user);
|
||||||
|
if (block)
|
||||||
|
return memset(block, 0, count * size);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_glfwInputError(GLFW_OUT_OF_MEMORY, NULL);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void* _glfw_realloc(void* block, size_t size)
|
||||||
|
{
|
||||||
|
if (block && size)
|
||||||
|
{
|
||||||
|
void* resized = _glfw.allocator.reallocate(block, size, _glfw.allocator.user);
|
||||||
|
if (resized)
|
||||||
|
return resized;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_glfwInputError(GLFW_OUT_OF_MEMORY, NULL);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (block)
|
||||||
|
{
|
||||||
|
_glfw_free(block);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return _glfw_calloc(1, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _glfw_free(void* block)
|
||||||
|
{
|
||||||
|
if (block)
|
||||||
|
_glfw.allocator.deallocate(block, _glfw.allocator.user);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
////// GLFW event API //////
|
////// GLFW event API //////
|
||||||
@ -191,6 +302,12 @@ void _glfwInputError(int code, const char* format, ...)
|
|||||||
strcpy(description, "The specified window has no context");
|
strcpy(description, "The specified window has no context");
|
||||||
else if (code == GLFW_CURSOR_UNAVAILABLE)
|
else if (code == GLFW_CURSOR_UNAVAILABLE)
|
||||||
strcpy(description, "The specified cursor shape is unavailable");
|
strcpy(description, "The specified cursor shape is unavailable");
|
||||||
|
else if (code == GLFW_FEATURE_UNAVAILABLE)
|
||||||
|
strcpy(description, "The requested feature cannot be implemented for this platform");
|
||||||
|
else if (code == GLFW_FEATURE_UNIMPLEMENTED)
|
||||||
|
strcpy(description, "The requested feature has not yet been implemented for this platform");
|
||||||
|
else if (code == GLFW_PLATFORM_UNAVAILABLE)
|
||||||
|
strcpy(description, "The requested platform is unavailable");
|
||||||
else
|
else
|
||||||
strcpy(description, "ERROR: UNKNOWN GLFW ERROR");
|
strcpy(description, "ERROR: UNKNOWN GLFW ERROR");
|
||||||
}
|
}
|
||||||
@ -200,7 +317,7 @@ void _glfwInputError(int code, const char* format, ...)
|
|||||||
error = _glfwPlatformGetTls(&_glfw.errorSlot);
|
error = _glfwPlatformGetTls(&_glfw.errorSlot);
|
||||||
if (!error)
|
if (!error)
|
||||||
{
|
{
|
||||||
error = calloc(1, sizeof(_GLFWerror));
|
error = _glfw_calloc(1, sizeof(_GLFWerror));
|
||||||
_glfwPlatformSetTls(&_glfw.errorSlot, error);
|
_glfwPlatformSetTls(&_glfw.errorSlot, error);
|
||||||
_glfwPlatformLockMutex(&_glfw.errorLock);
|
_glfwPlatformLockMutex(&_glfw.errorLock);
|
||||||
error->next = _glfw.errorListHead;
|
error->next = _glfw.errorListHead;
|
||||||
@ -231,7 +348,18 @@ GLFWAPI int glfwInit(void)
|
|||||||
memset(&_glfw, 0, sizeof(_glfw));
|
memset(&_glfw, 0, sizeof(_glfw));
|
||||||
_glfw.hints.init = _glfwInitHints;
|
_glfw.hints.init = _glfwInitHints;
|
||||||
|
|
||||||
if (!_glfwPlatformInit())
|
_glfw.allocator = _glfwInitAllocator;
|
||||||
|
if (!_glfw.allocator.allocate)
|
||||||
|
{
|
||||||
|
_glfw.allocator.allocate = defaultAllocate;
|
||||||
|
_glfw.allocator.reallocate = defaultReallocate;
|
||||||
|
_glfw.allocator.deallocate = defaultDeallocate;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!_glfwSelectPlatform(_glfw.hints.init.platformID, &_glfw.platform))
|
||||||
|
return GLFW_FALSE;
|
||||||
|
|
||||||
|
if (!_glfw.platform.init())
|
||||||
{
|
{
|
||||||
terminate();
|
terminate();
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
@ -247,24 +375,14 @@ GLFWAPI int glfwInit(void)
|
|||||||
|
|
||||||
_glfwPlatformSetTls(&_glfw.errorSlot, &_glfwMainThreadError);
|
_glfwPlatformSetTls(&_glfw.errorSlot, &_glfwMainThreadError);
|
||||||
|
|
||||||
_glfw.initialized = GLFW_TRUE;
|
_glfwInitGamepadMappings();
|
||||||
|
|
||||||
|
_glfwPlatformInitTimer();
|
||||||
_glfw.timer.offset = _glfwPlatformGetTimerValue();
|
_glfw.timer.offset = _glfwPlatformGetTimerValue();
|
||||||
|
|
||||||
|
_glfw.initialized = GLFW_TRUE;
|
||||||
|
|
||||||
glfwDefaultWindowHints();
|
glfwDefaultWindowHints();
|
||||||
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; _glfwDefaultMappings[i]; i++)
|
|
||||||
{
|
|
||||||
if (!glfwUpdateGamepadMappings(_glfwDefaultMappings[i]))
|
|
||||||
{
|
|
||||||
terminate();
|
|
||||||
return GLFW_FALSE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return GLFW_TRUE;
|
return GLFW_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -283,18 +401,45 @@ GLFWAPI void glfwInitHint(int hint, int value)
|
|||||||
case GLFW_JOYSTICK_HAT_BUTTONS:
|
case GLFW_JOYSTICK_HAT_BUTTONS:
|
||||||
_glfwInitHints.hatButtons = value;
|
_glfwInitHints.hatButtons = value;
|
||||||
return;
|
return;
|
||||||
|
case GLFW_ANGLE_PLATFORM_TYPE:
|
||||||
|
_glfwInitHints.angleType = value;
|
||||||
|
return;
|
||||||
|
case GLFW_PLATFORM:
|
||||||
|
_glfwInitHints.platformID = value;
|
||||||
|
return;
|
||||||
case GLFW_COCOA_CHDIR_RESOURCES:
|
case GLFW_COCOA_CHDIR_RESOURCES:
|
||||||
_glfwInitHints.ns.chdir = value;
|
_glfwInitHints.ns.chdir = value;
|
||||||
return;
|
return;
|
||||||
case GLFW_COCOA_MENUBAR:
|
case GLFW_COCOA_MENUBAR:
|
||||||
_glfwInitHints.ns.menubar = value;
|
_glfwInitHints.ns.menubar = value;
|
||||||
return;
|
return;
|
||||||
|
case GLFW_X11_XCB_VULKAN_SURFACE:
|
||||||
|
_glfwInitHints.x11.xcbVulkanSurface = value;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_glfwInputError(GLFW_INVALID_ENUM,
|
_glfwInputError(GLFW_INVALID_ENUM,
|
||||||
"Invalid init hint 0x%08X", hint);
|
"Invalid init hint 0x%08X", hint);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GLFWAPI void glfwInitAllocator(const GLFWallocator* allocator)
|
||||||
|
{
|
||||||
|
if (allocator)
|
||||||
|
{
|
||||||
|
if (allocator->allocate && allocator->reallocate && allocator->deallocate)
|
||||||
|
_glfwInitAllocator = *allocator;
|
||||||
|
else
|
||||||
|
_glfwInputError(GLFW_INVALID_VALUE, "Missing function in allocator");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
memset(&_glfwInitAllocator, 0, sizeof(GLFWallocator));
|
||||||
|
}
|
||||||
|
|
||||||
|
GLFWAPI void glfwInitVulkanLoader(PFN_vkGetInstanceProcAddr loader)
|
||||||
|
{
|
||||||
|
_glfwInitHints.vulkanLoader = loader;
|
||||||
|
}
|
||||||
|
|
||||||
GLFWAPI void glfwGetVersion(int* major, int* minor, int* rev)
|
GLFWAPI void glfwGetVersion(int* major, int* minor, int* rev)
|
||||||
{
|
{
|
||||||
if (major != NULL)
|
if (major != NULL)
|
||||||
@ -305,11 +450,6 @@ GLFWAPI void glfwGetVersion(int* major, int* minor, int* rev)
|
|||||||
*rev = GLFW_VERSION_REVISION;
|
*rev = GLFW_VERSION_REVISION;
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWAPI const char* glfwGetVersionString(void)
|
|
||||||
{
|
|
||||||
return _glfwPlatformGetVersionString();
|
|
||||||
}
|
|
||||||
|
|
||||||
GLFWAPI int glfwGetError(const char** description)
|
GLFWAPI int glfwGetError(const char** description)
|
||||||
{
|
{
|
||||||
_GLFWerror* error;
|
_GLFWerror* error;
|
||||||
@ -336,7 +476,7 @@ GLFWAPI int glfwGetError(const char** description)
|
|||||||
|
|
||||||
GLFWAPI GLFWerrorfun glfwSetErrorCallback(GLFWerrorfun cbfun)
|
GLFWAPI GLFWerrorfun glfwSetErrorCallback(GLFWerrorfun cbfun)
|
||||||
{
|
{
|
||||||
_GLFW_SWAP_POINTERS(_glfwErrorCallback, cbfun);
|
_GLFW_SWAP(GLFWerrorfun, _glfwErrorCallback, cbfun);
|
||||||
return cbfun;
|
return cbfun;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
205
src/input.c
205
src/input.c
@ -28,6 +28,7 @@
|
|||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
#include "mappings.h"
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <float.h>
|
#include <float.h>
|
||||||
@ -43,6 +44,22 @@
|
|||||||
#define _GLFW_JOYSTICK_BUTTON 2
|
#define _GLFW_JOYSTICK_BUTTON 2
|
||||||
#define _GLFW_JOYSTICK_HATBIT 3
|
#define _GLFW_JOYSTICK_HATBIT 3
|
||||||
|
|
||||||
|
// Initializes the platform joystick API if it has not been already
|
||||||
|
//
|
||||||
|
static GLFWbool initJoysticks(void)
|
||||||
|
{
|
||||||
|
if (!_glfw.joysticksInitialized)
|
||||||
|
{
|
||||||
|
if (!_glfw.platform.initJoysticks())
|
||||||
|
{
|
||||||
|
_glfw.platform.terminateJoysticks();
|
||||||
|
return GLFW_FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return _glfw.joysticksInitialized = GLFW_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
// Finds a mapping based on joystick GUID
|
// Finds a mapping based on joystick GUID
|
||||||
//
|
//
|
||||||
static _GLFWmapping* findMapping(const char* guid)
|
static _GLFWmapping* findMapping(const char* guid)
|
||||||
@ -85,27 +102,15 @@ static _GLFWmapping* findValidMapping(const _GLFWjoystick* js)
|
|||||||
for (i = 0; i <= GLFW_GAMEPAD_BUTTON_LAST; i++)
|
for (i = 0; i <= GLFW_GAMEPAD_BUTTON_LAST; i++)
|
||||||
{
|
{
|
||||||
if (!isValidElementForJoystick(mapping->buttons + i, js))
|
if (!isValidElementForJoystick(mapping->buttons + i, js))
|
||||||
{
|
|
||||||
_glfwInputError(GLFW_INVALID_VALUE,
|
|
||||||
"Invalid button in gamepad mapping %s (%s)",
|
|
||||||
mapping->guid,
|
|
||||||
mapping->name);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i <= GLFW_GAMEPAD_AXIS_LAST; i++)
|
for (i = 0; i <= GLFW_GAMEPAD_AXIS_LAST; i++)
|
||||||
{
|
{
|
||||||
if (!isValidElementForJoystick(mapping->axes + i, js))
|
if (!isValidElementForJoystick(mapping->axes + i, js))
|
||||||
{
|
|
||||||
_glfwInputError(GLFW_INVALID_VALUE,
|
|
||||||
"Invalid axis in gamepad mapping %s (%s)",
|
|
||||||
mapping->guid,
|
|
||||||
mapping->name);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return mapping;
|
return mapping;
|
||||||
}
|
}
|
||||||
@ -229,8 +234,9 @@ static GLFWbool parseMapping(_GLFWmapping* mapping, const char* string)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
length = strlen(_GLFW_PLATFORM_MAPPING_NAME);
|
const char* name = _glfw.platform.getMappingName();
|
||||||
if (strncmp(c, _GLFW_PLATFORM_MAPPING_NAME, length) != 0)
|
length = strlen(name);
|
||||||
|
if (strncmp(c, name, length) != 0)
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -247,7 +253,7 @@ static GLFWbool parseMapping(_GLFWmapping* mapping, const char* string)
|
|||||||
mapping->guid[i] += 'a' - 'A';
|
mapping->guid[i] += 'a' - 'A';
|
||||||
}
|
}
|
||||||
|
|
||||||
_glfwPlatformUpdateGamepadGUID(mapping->guid);
|
_glfw.platform.updateGamepadGUID(mapping->guid);
|
||||||
return GLFW_TRUE;
|
return GLFW_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -289,7 +295,7 @@ void _glfwInputKey(_GLFWwindow* window, int key, int scancode, int action, int m
|
|||||||
// Notifies shared code of a Unicode codepoint input event
|
// Notifies shared code of a Unicode codepoint input event
|
||||||
// The 'plain' parameter determines whether to emit a regular character 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))
|
if (codepoint < 32 || (codepoint > 126 && codepoint < 160))
|
||||||
return;
|
return;
|
||||||
@ -408,6 +414,21 @@ void _glfwInputJoystickHat(_GLFWjoystick* js, int hat, char value)
|
|||||||
////// GLFW internal API //////
|
////// GLFW internal API //////
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// Adds the built-in set of gamepad mappings
|
||||||
|
//
|
||||||
|
void _glfwInitGamepadMappings(void)
|
||||||
|
{
|
||||||
|
size_t i;
|
||||||
|
const size_t count = sizeof(_glfwDefaultMappings) / sizeof(char*);
|
||||||
|
_glfw.mappings = _glfw_calloc(count, sizeof(_GLFWmapping));
|
||||||
|
|
||||||
|
for (i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
if (parseMapping(&_glfw.mappings[_glfw.mappingCount], _glfwDefaultMappings[i]))
|
||||||
|
_glfw.mappingCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Returns an available joystick object with arrays and name allocated
|
// Returns an available joystick object with arrays and name allocated
|
||||||
//
|
//
|
||||||
_GLFWjoystick* _glfwAllocJoystick(const char* name,
|
_GLFWjoystick* _glfwAllocJoystick(const char* name,
|
||||||
@ -430,14 +451,14 @@ _GLFWjoystick* _glfwAllocJoystick(const char* name,
|
|||||||
|
|
||||||
js = _glfw.joysticks + jid;
|
js = _glfw.joysticks + jid;
|
||||||
js->present = GLFW_TRUE;
|
js->present = GLFW_TRUE;
|
||||||
js->name = _glfw_strdup(name);
|
js->axes = _glfw_calloc(axisCount, sizeof(float));
|
||||||
js->axes = calloc(axisCount, sizeof(float));
|
js->buttons = _glfw_calloc(buttonCount + (size_t) hatCount * 4, 1);
|
||||||
js->buttons = calloc(buttonCount + (size_t) hatCount * 4, 1);
|
js->hats = _glfw_calloc(hatCount, 1);
|
||||||
js->hats = calloc(hatCount, 1);
|
|
||||||
js->axisCount = axisCount;
|
js->axisCount = axisCount;
|
||||||
js->buttonCount = buttonCount;
|
js->buttonCount = buttonCount;
|
||||||
js->hatCount = hatCount;
|
js->hatCount = hatCount;
|
||||||
|
|
||||||
|
strncpy(js->name, name, sizeof(js->name) - 1);
|
||||||
strncpy(js->guid, guid, sizeof(js->guid) - 1);
|
strncpy(js->guid, guid, sizeof(js->guid) - 1);
|
||||||
js->mapping = findValidMapping(js);
|
js->mapping = findValidMapping(js);
|
||||||
|
|
||||||
@ -448,10 +469,9 @@ _GLFWjoystick* _glfwAllocJoystick(const char* name,
|
|||||||
//
|
//
|
||||||
void _glfwFreeJoystick(_GLFWjoystick* js)
|
void _glfwFreeJoystick(_GLFWjoystick* js)
|
||||||
{
|
{
|
||||||
free(js->name);
|
_glfw_free(js->axes);
|
||||||
free(js->axes);
|
_glfw_free(js->buttons);
|
||||||
free(js->buttons);
|
_glfw_free(js->hats);
|
||||||
free(js->hats);
|
|
||||||
memset(js, 0, sizeof(_GLFWjoystick));
|
memset(js, 0, sizeof(_GLFWjoystick));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -461,8 +481,8 @@ void _glfwCenterCursorInContentArea(_GLFWwindow* window)
|
|||||||
{
|
{
|
||||||
int width, height;
|
int width, height;
|
||||||
|
|
||||||
_glfwPlatformGetWindowSize(window, &width, &height);
|
_glfw.platform.getWindowSize(window, &width, &height);
|
||||||
_glfwPlatformSetCursorPos(window, width / 2.0, height / 2.0);
|
_glfw.platform.setCursorPos(window, width / 2.0, height / 2.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -502,7 +522,9 @@ GLFWAPI void glfwSetInputMode(GLFWwindow* handle, int mode, int value)
|
|||||||
|
|
||||||
_GLFW_REQUIRE_INIT();
|
_GLFW_REQUIRE_INIT();
|
||||||
|
|
||||||
if (mode == GLFW_CURSOR)
|
switch (mode)
|
||||||
|
{
|
||||||
|
case GLFW_CURSOR:
|
||||||
{
|
{
|
||||||
if (value != GLFW_CURSOR_NORMAL &&
|
if (value != GLFW_CURSOR_NORMAL &&
|
||||||
value != GLFW_CURSOR_HIDDEN &&
|
value != GLFW_CURSOR_HIDDEN &&
|
||||||
@ -519,12 +541,14 @@ GLFWAPI void glfwSetInputMode(GLFWwindow* handle, int mode, int value)
|
|||||||
|
|
||||||
window->cursorMode = value;
|
window->cursorMode = value;
|
||||||
|
|
||||||
_glfwPlatformGetCursorPos(window,
|
_glfw.platform.getCursorPos(window,
|
||||||
&window->virtualCursorPosX,
|
&window->virtualCursorPosX,
|
||||||
&window->virtualCursorPosY);
|
&window->virtualCursorPosY);
|
||||||
_glfwPlatformSetCursorMode(window, value);
|
_glfw.platform.setCursorMode(window, value);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else if (mode == GLFW_STICKY_KEYS)
|
|
||||||
|
case GLFW_STICKY_KEYS:
|
||||||
{
|
{
|
||||||
value = value ? GLFW_TRUE : GLFW_FALSE;
|
value = value ? GLFW_TRUE : GLFW_FALSE;
|
||||||
if (window->stickyKeys == value)
|
if (window->stickyKeys == value)
|
||||||
@ -543,8 +567,10 @@ GLFWAPI void glfwSetInputMode(GLFWwindow* handle, int mode, int value)
|
|||||||
}
|
}
|
||||||
|
|
||||||
window->stickyKeys = value;
|
window->stickyKeys = value;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else if (mode == GLFW_STICKY_MOUSE_BUTTONS)
|
|
||||||
|
case GLFW_STICKY_MOUSE_BUTTONS:
|
||||||
{
|
{
|
||||||
value = value ? GLFW_TRUE : GLFW_FALSE;
|
value = value ? GLFW_TRUE : GLFW_FALSE;
|
||||||
if (window->stickyMouseButtons == value)
|
if (window->stickyMouseButtons == value)
|
||||||
@ -563,14 +589,18 @@ GLFWAPI void glfwSetInputMode(GLFWwindow* handle, int mode, int value)
|
|||||||
}
|
}
|
||||||
|
|
||||||
window->stickyMouseButtons = value;
|
window->stickyMouseButtons = value;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else if (mode == GLFW_LOCK_KEY_MODS)
|
|
||||||
|
case GLFW_LOCK_KEY_MODS:
|
||||||
{
|
{
|
||||||
window->lockKeyMods = value ? GLFW_TRUE : GLFW_FALSE;
|
window->lockKeyMods = value ? GLFW_TRUE : GLFW_FALSE;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else if (mode == GLFW_RAW_MOUSE_MOTION)
|
|
||||||
|
case GLFW_RAW_MOUSE_MOTION:
|
||||||
{
|
{
|
||||||
if (!_glfwPlatformRawMouseMotionSupported())
|
if (!_glfw.platform.rawMouseMotionSupported())
|
||||||
{
|
{
|
||||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||||
"Raw mouse motion is not supported on this system");
|
"Raw mouse motion is not supported on this system");
|
||||||
@ -582,16 +612,18 @@ GLFWAPI void glfwSetInputMode(GLFWwindow* handle, int mode, int value)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
window->rawMouseMotion = value;
|
window->rawMouseMotion = value;
|
||||||
_glfwPlatformSetRawMouseMotion(window, 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)
|
GLFWAPI int glfwRawMouseMotionSupported(void)
|
||||||
{
|
{
|
||||||
_GLFW_REQUIRE_INIT_OR_RETURN(GLFW_FALSE);
|
_GLFW_REQUIRE_INIT_OR_RETURN(GLFW_FALSE);
|
||||||
return _glfwPlatformRawMouseMotionSupported();
|
return _glfw.platform.rawMouseMotionSupported();
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWAPI const char* glfwGetKeyName(int key, int scancode)
|
GLFWAPI const char* glfwGetKeyName(int key, int scancode)
|
||||||
@ -607,10 +639,10 @@ GLFWAPI const char* glfwGetKeyName(int key, int scancode)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
scancode = _glfwPlatformGetKeyScancode(key);
|
scancode = _glfw.platform.getKeyScancode(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
return _glfwPlatformGetScancodeName(scancode);
|
return _glfw.platform.getScancodeName(scancode);
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWAPI int glfwGetKeyScancode(int key)
|
GLFWAPI int glfwGetKeyScancode(int key)
|
||||||
@ -623,7 +655,7 @@ GLFWAPI int glfwGetKeyScancode(int key)
|
|||||||
return GLFW_RELEASE;
|
return GLFW_RELEASE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return _glfwPlatformGetKeyScancode(key);
|
return _glfw.platform.getKeyScancode(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWAPI int glfwGetKey(GLFWwindow* handle, int key)
|
GLFWAPI int glfwGetKey(GLFWwindow* handle, int key)
|
||||||
@ -692,7 +724,7 @@ GLFWAPI void glfwGetCursorPos(GLFWwindow* handle, double* xpos, double* ypos)
|
|||||||
*ypos = window->virtualCursorPosY;
|
*ypos = window->virtualCursorPosY;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
_glfwPlatformGetCursorPos(window, xpos, ypos);
|
_glfw.platform.getCursorPos(window, xpos, ypos);
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWAPI void glfwSetCursorPos(GLFWwindow* handle, double xpos, double ypos)
|
GLFWAPI void glfwSetCursorPos(GLFWwindow* handle, double xpos, double ypos)
|
||||||
@ -711,7 +743,7 @@ GLFWAPI void glfwSetCursorPos(GLFWwindow* handle, double xpos, double ypos)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_glfwPlatformWindowFocused(window))
|
if (!_glfw.platform.windowFocused(window))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (window->cursorMode == GLFW_CURSOR_DISABLED)
|
if (window->cursorMode == GLFW_CURSOR_DISABLED)
|
||||||
@ -723,7 +755,7 @@ GLFWAPI void glfwSetCursorPos(GLFWwindow* handle, double xpos, double ypos)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Update system cursor position
|
// Update system cursor position
|
||||||
_glfwPlatformSetCursorPos(window, xpos, ypos);
|
_glfw.platform.setCursorPos(window, xpos, ypos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -735,11 +767,11 @@ GLFWAPI GLFWcursor* glfwCreateCursor(const GLFWimage* image, int xhot, int yhot)
|
|||||||
|
|
||||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||||
|
|
||||||
cursor = calloc(1, sizeof(_GLFWcursor));
|
cursor = _glfw_calloc(1, sizeof(_GLFWcursor));
|
||||||
cursor->next = _glfw.cursorListHead;
|
cursor->next = _glfw.cursorListHead;
|
||||||
_glfw.cursorListHead = cursor;
|
_glfw.cursorListHead = cursor;
|
||||||
|
|
||||||
if (!_glfwPlatformCreateCursor(cursor, image, xhot, yhot))
|
if (!_glfw.platform.createCursor(cursor, image, xhot, yhot))
|
||||||
{
|
{
|
||||||
glfwDestroyCursor((GLFWcursor*) cursor);
|
glfwDestroyCursor((GLFWcursor*) cursor);
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -769,11 +801,11 @@ GLFWAPI GLFWcursor* glfwCreateStandardCursor(int shape)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
cursor = calloc(1, sizeof(_GLFWcursor));
|
cursor = _glfw_calloc(1, sizeof(_GLFWcursor));
|
||||||
cursor->next = _glfw.cursorListHead;
|
cursor->next = _glfw.cursorListHead;
|
||||||
_glfw.cursorListHead = cursor;
|
_glfw.cursorListHead = cursor;
|
||||||
|
|
||||||
if (!_glfwPlatformCreateStandardCursor(cursor, shape))
|
if (!_glfw.platform.createStandardCursor(cursor, shape))
|
||||||
{
|
{
|
||||||
glfwDestroyCursor((GLFWcursor*) cursor);
|
glfwDestroyCursor((GLFWcursor*) cursor);
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -802,7 +834,7 @@ GLFWAPI void glfwDestroyCursor(GLFWcursor* handle)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_glfwPlatformDestroyCursor(cursor);
|
_glfw.platform.destroyCursor(cursor);
|
||||||
|
|
||||||
// Unlink cursor from global linked list
|
// Unlink cursor from global linked list
|
||||||
{
|
{
|
||||||
@ -814,7 +846,7 @@ GLFWAPI void glfwDestroyCursor(GLFWcursor* handle)
|
|||||||
*prev = cursor->next;
|
*prev = cursor->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
free(cursor);
|
_glfw_free(cursor);
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWAPI void glfwSetCursor(GLFWwindow* windowHandle, GLFWcursor* cursorHandle)
|
GLFWAPI void glfwSetCursor(GLFWwindow* windowHandle, GLFWcursor* cursorHandle)
|
||||||
@ -827,7 +859,7 @@ GLFWAPI void glfwSetCursor(GLFWwindow* windowHandle, GLFWcursor* cursorHandle)
|
|||||||
|
|
||||||
window->cursor = cursor;
|
window->cursor = cursor;
|
||||||
|
|
||||||
_glfwPlatformSetCursor(window, cursor);
|
_glfw.platform.setCursor(window, cursor);
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWAPI GLFWkeyfun glfwSetKeyCallback(GLFWwindow* handle, GLFWkeyfun cbfun)
|
GLFWAPI GLFWkeyfun glfwSetKeyCallback(GLFWwindow* handle, GLFWkeyfun cbfun)
|
||||||
@ -836,7 +868,7 @@ GLFWAPI GLFWkeyfun glfwSetKeyCallback(GLFWwindow* handle, GLFWkeyfun cbfun)
|
|||||||
assert(window != NULL);
|
assert(window != NULL);
|
||||||
|
|
||||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||||
_GLFW_SWAP_POINTERS(window->callbacks.key, cbfun);
|
_GLFW_SWAP(GLFWkeyfun, window->callbacks.key, cbfun);
|
||||||
return cbfun;
|
return cbfun;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -846,7 +878,7 @@ GLFWAPI GLFWcharfun glfwSetCharCallback(GLFWwindow* handle, GLFWcharfun cbfun)
|
|||||||
assert(window != NULL);
|
assert(window != NULL);
|
||||||
|
|
||||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||||
_GLFW_SWAP_POINTERS(window->callbacks.character, cbfun);
|
_GLFW_SWAP(GLFWcharfun, window->callbacks.character, cbfun);
|
||||||
return cbfun;
|
return cbfun;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -856,7 +888,7 @@ GLFWAPI GLFWcharmodsfun glfwSetCharModsCallback(GLFWwindow* handle, GLFWcharmods
|
|||||||
assert(window != NULL);
|
assert(window != NULL);
|
||||||
|
|
||||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||||
_GLFW_SWAP_POINTERS(window->callbacks.charmods, cbfun);
|
_GLFW_SWAP(GLFWcharmodsfun, window->callbacks.charmods, cbfun);
|
||||||
return cbfun;
|
return cbfun;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -867,7 +899,7 @@ GLFWAPI GLFWmousebuttonfun glfwSetMouseButtonCallback(GLFWwindow* handle,
|
|||||||
assert(window != NULL);
|
assert(window != NULL);
|
||||||
|
|
||||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||||
_GLFW_SWAP_POINTERS(window->callbacks.mouseButton, cbfun);
|
_GLFW_SWAP(GLFWmousebuttonfun, window->callbacks.mouseButton, cbfun);
|
||||||
return cbfun;
|
return cbfun;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -878,7 +910,7 @@ GLFWAPI GLFWcursorposfun glfwSetCursorPosCallback(GLFWwindow* handle,
|
|||||||
assert(window != NULL);
|
assert(window != NULL);
|
||||||
|
|
||||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||||
_GLFW_SWAP_POINTERS(window->callbacks.cursorPos, cbfun);
|
_GLFW_SWAP(GLFWcursorposfun, window->callbacks.cursorPos, cbfun);
|
||||||
return cbfun;
|
return cbfun;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -889,7 +921,7 @@ GLFWAPI GLFWcursorenterfun glfwSetCursorEnterCallback(GLFWwindow* handle,
|
|||||||
assert(window != NULL);
|
assert(window != NULL);
|
||||||
|
|
||||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||||
_GLFW_SWAP_POINTERS(window->callbacks.cursorEnter, cbfun);
|
_GLFW_SWAP(GLFWcursorenterfun, window->callbacks.cursorEnter, cbfun);
|
||||||
return cbfun;
|
return cbfun;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -900,7 +932,7 @@ GLFWAPI GLFWscrollfun glfwSetScrollCallback(GLFWwindow* handle,
|
|||||||
assert(window != NULL);
|
assert(window != NULL);
|
||||||
|
|
||||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||||
_GLFW_SWAP_POINTERS(window->callbacks.scroll, cbfun);
|
_GLFW_SWAP(GLFWscrollfun, window->callbacks.scroll, cbfun);
|
||||||
return cbfun;
|
return cbfun;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -910,7 +942,7 @@ GLFWAPI GLFWdropfun glfwSetDropCallback(GLFWwindow* handle, GLFWdropfun cbfun)
|
|||||||
assert(window != NULL);
|
assert(window != NULL);
|
||||||
|
|
||||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||||
_GLFW_SWAP_POINTERS(window->callbacks.drop, cbfun);
|
_GLFW_SWAP(GLFWdropfun, window->callbacks.drop, cbfun);
|
||||||
return cbfun;
|
return cbfun;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -929,11 +961,14 @@ GLFWAPI int glfwJoystickPresent(int jid)
|
|||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!initJoysticks())
|
||||||
|
return GLFW_FALSE;
|
||||||
|
|
||||||
js = _glfw.joysticks + jid;
|
js = _glfw.joysticks + jid;
|
||||||
if (!js->present)
|
if (!js->present)
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
|
|
||||||
return _glfwPlatformPollJoystick(js, _GLFW_POLL_PRESENCE);
|
return _glfw.platform.pollJoystick(js, _GLFW_POLL_PRESENCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWAPI const float* glfwGetJoystickAxes(int jid, int* count)
|
GLFWAPI const float* glfwGetJoystickAxes(int jid, int* count)
|
||||||
@ -954,11 +989,14 @@ GLFWAPI const float* glfwGetJoystickAxes(int jid, int* count)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!initJoysticks())
|
||||||
|
return NULL;
|
||||||
|
|
||||||
js = _glfw.joysticks + jid;
|
js = _glfw.joysticks + jid;
|
||||||
if (!js->present)
|
if (!js->present)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (!_glfwPlatformPollJoystick(js, _GLFW_POLL_AXES))
|
if (!_glfw.platform.pollJoystick(js, _GLFW_POLL_AXES))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
*count = js->axisCount;
|
*count = js->axisCount;
|
||||||
@ -983,11 +1021,14 @@ GLFWAPI const unsigned char* glfwGetJoystickButtons(int jid, int* count)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!initJoysticks())
|
||||||
|
return NULL;
|
||||||
|
|
||||||
js = _glfw.joysticks + jid;
|
js = _glfw.joysticks + jid;
|
||||||
if (!js->present)
|
if (!js->present)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (!_glfwPlatformPollJoystick(js, _GLFW_POLL_BUTTONS))
|
if (!_glfw.platform.pollJoystick(js, _GLFW_POLL_BUTTONS))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (_glfw.hints.init.hatButtons)
|
if (_glfw.hints.init.hatButtons)
|
||||||
@ -1016,11 +1057,14 @@ GLFWAPI const unsigned char* glfwGetJoystickHats(int jid, int* count)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!initJoysticks())
|
||||||
|
return NULL;
|
||||||
|
|
||||||
js = _glfw.joysticks + jid;
|
js = _glfw.joysticks + jid;
|
||||||
if (!js->present)
|
if (!js->present)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (!_glfwPlatformPollJoystick(js, _GLFW_POLL_BUTTONS))
|
if (!_glfw.platform.pollJoystick(js, _GLFW_POLL_BUTTONS))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
*count = js->hatCount;
|
*count = js->hatCount;
|
||||||
@ -1042,11 +1086,14 @@ GLFWAPI const char* glfwGetJoystickName(int jid)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!initJoysticks())
|
||||||
|
return NULL;
|
||||||
|
|
||||||
js = _glfw.joysticks + jid;
|
js = _glfw.joysticks + jid;
|
||||||
if (!js->present)
|
if (!js->present)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (!_glfwPlatformPollJoystick(js, _GLFW_POLL_PRESENCE))
|
if (!_glfw.platform.pollJoystick(js, _GLFW_POLL_PRESENCE))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return js->name;
|
return js->name;
|
||||||
@ -1067,11 +1114,14 @@ GLFWAPI const char* glfwGetJoystickGUID(int jid)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!initJoysticks())
|
||||||
|
return NULL;
|
||||||
|
|
||||||
js = _glfw.joysticks + jid;
|
js = _glfw.joysticks + jid;
|
||||||
if (!js->present)
|
if (!js->present)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (!_glfwPlatformPollJoystick(js, _GLFW_POLL_PRESENCE))
|
if (!_glfw.platform.pollJoystick(js, _GLFW_POLL_PRESENCE))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return js->guid;
|
return js->guid;
|
||||||
@ -1112,7 +1162,11 @@ GLFWAPI void* glfwGetJoystickUserPointer(int jid)
|
|||||||
GLFWAPI GLFWjoystickfun glfwSetJoystickCallback(GLFWjoystickfun cbfun)
|
GLFWAPI GLFWjoystickfun glfwSetJoystickCallback(GLFWjoystickfun cbfun)
|
||||||
{
|
{
|
||||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||||
_GLFW_SWAP_POINTERS(_glfw.callbacks.joystick, cbfun);
|
|
||||||
|
if (!initJoysticks())
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
_GLFW_SWAP(GLFWjoystickfun, _glfw.callbacks.joystick, cbfun);
|
||||||
return cbfun;
|
return cbfun;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1150,7 +1204,7 @@ GLFWAPI int glfwUpdateGamepadMappings(const char* string)
|
|||||||
{
|
{
|
||||||
_glfw.mappingCount++;
|
_glfw.mappingCount++;
|
||||||
_glfw.mappings =
|
_glfw.mappings =
|
||||||
realloc(_glfw.mappings,
|
_glfw_realloc(_glfw.mappings,
|
||||||
sizeof(_GLFWmapping) * _glfw.mappingCount);
|
sizeof(_GLFWmapping) * _glfw.mappingCount);
|
||||||
_glfw.mappings[_glfw.mappingCount - 1] = mapping;
|
_glfw.mappings[_glfw.mappingCount - 1] = mapping;
|
||||||
}
|
}
|
||||||
@ -1191,11 +1245,14 @@ GLFWAPI int glfwJoystickIsGamepad(int jid)
|
|||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!initJoysticks())
|
||||||
|
return GLFW_FALSE;
|
||||||
|
|
||||||
js = _glfw.joysticks + jid;
|
js = _glfw.joysticks + jid;
|
||||||
if (!js->present)
|
if (!js->present)
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
|
|
||||||
if (!_glfwPlatformPollJoystick(js, _GLFW_POLL_PRESENCE))
|
if (!_glfw.platform.pollJoystick(js, _GLFW_POLL_PRESENCE))
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
|
|
||||||
return js->mapping != NULL;
|
return js->mapping != NULL;
|
||||||
@ -1216,11 +1273,14 @@ GLFWAPI const char* glfwGetGamepadName(int jid)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!initJoysticks())
|
||||||
|
return NULL;
|
||||||
|
|
||||||
js = _glfw.joysticks + jid;
|
js = _glfw.joysticks + jid;
|
||||||
if (!js->present)
|
if (!js->present)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (!_glfwPlatformPollJoystick(js, _GLFW_POLL_PRESENCE))
|
if (!_glfw.platform.pollJoystick(js, _GLFW_POLL_PRESENCE))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (!js->mapping)
|
if (!js->mapping)
|
||||||
@ -1248,11 +1308,14 @@ GLFWAPI int glfwGetGamepadState(int jid, GLFWgamepadstate* state)
|
|||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!initJoysticks())
|
||||||
|
return GLFW_FALSE;
|
||||||
|
|
||||||
js = _glfw.joysticks + jid;
|
js = _glfw.joysticks + jid;
|
||||||
if (!js->present)
|
if (!js->present)
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
|
|
||||||
if (!_glfwPlatformPollJoystick(js, _GLFW_POLL_ALL))
|
if (!_glfw.platform.pollJoystick(js, _GLFW_POLL_ALL))
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
|
|
||||||
if (!js->mapping)
|
if (!js->mapping)
|
||||||
@ -1317,13 +1380,13 @@ GLFWAPI void glfwSetClipboardString(GLFWwindow* handle, const char* string)
|
|||||||
assert(string != NULL);
|
assert(string != NULL);
|
||||||
|
|
||||||
_GLFW_REQUIRE_INIT();
|
_GLFW_REQUIRE_INIT();
|
||||||
_glfwPlatformSetClipboardString(string);
|
_glfw.platform.setClipboardString(string);
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWAPI const char* glfwGetClipboardString(GLFWwindow* handle)
|
GLFWAPI const char* glfwGetClipboardString(GLFWwindow* handle)
|
||||||
{
|
{
|
||||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||||
return _glfwPlatformGetClipboardString();
|
return _glfw.platform.getClipboardString();
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWAPI double glfwGetTime(void)
|
GLFWAPI double glfwGetTime(void)
|
||||||
|
508
src/internal.h
508
src/internal.h
@ -59,6 +59,7 @@
|
|||||||
#define _GLFW_MESSAGE_SIZE 1024
|
#define _GLFW_MESSAGE_SIZE 1024
|
||||||
|
|
||||||
typedef int GLFWbool;
|
typedef int GLFWbool;
|
||||||
|
typedef void (*GLFWproc)(void);
|
||||||
|
|
||||||
typedef struct _GLFWerror _GLFWerror;
|
typedef struct _GLFWerror _GLFWerror;
|
||||||
typedef struct _GLFWinitconfig _GLFWinitconfig;
|
typedef struct _GLFWinitconfig _GLFWinitconfig;
|
||||||
@ -67,6 +68,7 @@ typedef struct _GLFWctxconfig _GLFWctxconfig;
|
|||||||
typedef struct _GLFWfbconfig _GLFWfbconfig;
|
typedef struct _GLFWfbconfig _GLFWfbconfig;
|
||||||
typedef struct _GLFWcontext _GLFWcontext;
|
typedef struct _GLFWcontext _GLFWcontext;
|
||||||
typedef struct _GLFWwindow _GLFWwindow;
|
typedef struct _GLFWwindow _GLFWwindow;
|
||||||
|
typedef struct _GLFWplatform _GLFWplatform;
|
||||||
typedef struct _GLFWlibrary _GLFWlibrary;
|
typedef struct _GLFWlibrary _GLFWlibrary;
|
||||||
typedef struct _GLFWmonitor _GLFWmonitor;
|
typedef struct _GLFWmonitor _GLFWmonitor;
|
||||||
typedef struct _GLFWcursor _GLFWcursor;
|
typedef struct _GLFWcursor _GLFWcursor;
|
||||||
@ -76,13 +78,6 @@ typedef struct _GLFWjoystick _GLFWjoystick;
|
|||||||
typedef struct _GLFWtls _GLFWtls;
|
typedef struct _GLFWtls _GLFWtls;
|
||||||
typedef struct _GLFWmutex _GLFWmutex;
|
typedef struct _GLFWmutex _GLFWmutex;
|
||||||
|
|
||||||
typedef void (* _GLFWmakecontextcurrentfun)(_GLFWwindow*);
|
|
||||||
typedef void (* _GLFWswapbuffersfun)(_GLFWwindow*);
|
|
||||||
typedef void (* _GLFWswapintervalfun)(int);
|
|
||||||
typedef int (* _GLFWextensionsupportedfun)(const char*);
|
|
||||||
typedef GLFWglproc (* _GLFWgetprocaddressfun)(const char*);
|
|
||||||
typedef void (* _GLFWdestroycontextfun)(_GLFWwindow*);
|
|
||||||
|
|
||||||
#define GL_VERSION 0x1f02
|
#define GL_VERSION 0x1f02
|
||||||
#define GL_NONE 0
|
#define GL_NONE 0
|
||||||
#define GL_COLOR_BUFFER_BIT 0x00004000
|
#define GL_COLOR_BUFFER_BIT 0x00004000
|
||||||
@ -113,6 +108,165 @@ typedef const GLubyte* (APIENTRY * PFNGLGETSTRINGPROC)(GLenum);
|
|||||||
typedef void (APIENTRY * PFNGLGETINTEGERVPROC)(GLenum,GLint*);
|
typedef void (APIENTRY * PFNGLGETINTEGERVPROC)(GLenum,GLint*);
|
||||||
typedef const GLubyte* (APIENTRY * PFNGLGETSTRINGIPROC)(GLenum,GLuint);
|
typedef const GLubyte* (APIENTRY * PFNGLGETSTRINGIPROC)(GLenum,GLuint);
|
||||||
|
|
||||||
|
#if defined(_GLFW_WIN32)
|
||||||
|
#define EGLAPIENTRY __stdcall
|
||||||
|
#else
|
||||||
|
#define EGLAPIENTRY
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define EGL_SUCCESS 0x3000
|
||||||
|
#define EGL_NOT_INITIALIZED 0x3001
|
||||||
|
#define EGL_BAD_ACCESS 0x3002
|
||||||
|
#define EGL_BAD_ALLOC 0x3003
|
||||||
|
#define EGL_BAD_ATTRIBUTE 0x3004
|
||||||
|
#define EGL_BAD_CONFIG 0x3005
|
||||||
|
#define EGL_BAD_CONTEXT 0x3006
|
||||||
|
#define EGL_BAD_CURRENT_SURFACE 0x3007
|
||||||
|
#define EGL_BAD_DISPLAY 0x3008
|
||||||
|
#define EGL_BAD_MATCH 0x3009
|
||||||
|
#define EGL_BAD_NATIVE_PIXMAP 0x300a
|
||||||
|
#define EGL_BAD_NATIVE_WINDOW 0x300b
|
||||||
|
#define EGL_BAD_PARAMETER 0x300c
|
||||||
|
#define EGL_BAD_SURFACE 0x300d
|
||||||
|
#define EGL_CONTEXT_LOST 0x300e
|
||||||
|
#define EGL_COLOR_BUFFER_TYPE 0x303f
|
||||||
|
#define EGL_RGB_BUFFER 0x308e
|
||||||
|
#define EGL_SURFACE_TYPE 0x3033
|
||||||
|
#define EGL_WINDOW_BIT 0x0004
|
||||||
|
#define EGL_RENDERABLE_TYPE 0x3040
|
||||||
|
#define EGL_OPENGL_ES_BIT 0x0001
|
||||||
|
#define EGL_OPENGL_ES2_BIT 0x0004
|
||||||
|
#define EGL_OPENGL_BIT 0x0008
|
||||||
|
#define EGL_ALPHA_SIZE 0x3021
|
||||||
|
#define EGL_BLUE_SIZE 0x3022
|
||||||
|
#define EGL_GREEN_SIZE 0x3023
|
||||||
|
#define EGL_RED_SIZE 0x3024
|
||||||
|
#define EGL_DEPTH_SIZE 0x3025
|
||||||
|
#define EGL_STENCIL_SIZE 0x3026
|
||||||
|
#define EGL_SAMPLES 0x3031
|
||||||
|
#define EGL_OPENGL_ES_API 0x30a0
|
||||||
|
#define EGL_OPENGL_API 0x30a2
|
||||||
|
#define EGL_NONE 0x3038
|
||||||
|
#define EGL_RENDER_BUFFER 0x3086
|
||||||
|
#define EGL_SINGLE_BUFFER 0x3085
|
||||||
|
#define EGL_EXTENSIONS 0x3055
|
||||||
|
#define EGL_CONTEXT_CLIENT_VERSION 0x3098
|
||||||
|
#define EGL_NATIVE_VISUAL_ID 0x302e
|
||||||
|
#define EGL_NO_SURFACE ((EGLSurface) 0)
|
||||||
|
#define EGL_NO_DISPLAY ((EGLDisplay) 0)
|
||||||
|
#define EGL_NO_CONTEXT ((EGLContext) 0)
|
||||||
|
#define EGL_DEFAULT_DISPLAY ((EGLNativeDisplayType) 0)
|
||||||
|
|
||||||
|
#define EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR 0x00000002
|
||||||
|
#define EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR 0x00000001
|
||||||
|
#define EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR 0x00000002
|
||||||
|
#define EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR 0x00000001
|
||||||
|
#define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR 0x31bd
|
||||||
|
#define EGL_NO_RESET_NOTIFICATION_KHR 0x31be
|
||||||
|
#define EGL_LOSE_CONTEXT_ON_RESET_KHR 0x31bf
|
||||||
|
#define EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR 0x00000004
|
||||||
|
#define EGL_CONTEXT_MAJOR_VERSION_KHR 0x3098
|
||||||
|
#define EGL_CONTEXT_MINOR_VERSION_KHR 0x30fb
|
||||||
|
#define EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR 0x30fd
|
||||||
|
#define EGL_CONTEXT_FLAGS_KHR 0x30fc
|
||||||
|
#define EGL_CONTEXT_OPENGL_NO_ERROR_KHR 0x31b3
|
||||||
|
#define EGL_GL_COLORSPACE_KHR 0x309d
|
||||||
|
#define EGL_GL_COLORSPACE_SRGB_KHR 0x3089
|
||||||
|
#define EGL_CONTEXT_RELEASE_BEHAVIOR_KHR 0x2097
|
||||||
|
#define EGL_CONTEXT_RELEASE_BEHAVIOR_NONE_KHR 0
|
||||||
|
#define EGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_KHR 0x2098
|
||||||
|
#define EGL_PLATFORM_X11_EXT 0x31d5
|
||||||
|
#define EGL_PLATFORM_WAYLAND_EXT 0x31d8
|
||||||
|
#define EGL_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*);
|
||||||
|
#define eglGetConfigAttrib _glfw.egl.GetConfigAttrib
|
||||||
|
#define eglGetConfigs _glfw.egl.GetConfigs
|
||||||
|
#define eglGetDisplay _glfw.egl.GetDisplay
|
||||||
|
#define eglGetError _glfw.egl.GetError
|
||||||
|
#define eglInitialize _glfw.egl.Initialize
|
||||||
|
#define eglTerminate _glfw.egl.Terminate
|
||||||
|
#define eglBindAPI _glfw.egl.BindAPI
|
||||||
|
#define eglCreateContext _glfw.egl.CreateContext
|
||||||
|
#define eglDestroySurface _glfw.egl.DestroySurface
|
||||||
|
#define eglDestroyContext _glfw.egl.DestroyContext
|
||||||
|
#define eglCreateWindowSurface _glfw.egl.CreateWindowSurface
|
||||||
|
#define eglMakeCurrent _glfw.egl.MakeCurrent
|
||||||
|
#define eglSwapBuffers _glfw.egl.SwapBuffers
|
||||||
|
#define eglSwapInterval _glfw.egl.SwapInterval
|
||||||
|
#define eglQueryString _glfw.egl.QueryString
|
||||||
|
#define eglGetProcAddress _glfw.egl.GetProcAddress
|
||||||
|
|
||||||
|
typedef EGLDisplay (EGLAPIENTRY * PFNEGLGETPLATFORMDISPLAYEXTPROC)(EGLenum,void*,const EGLint*);
|
||||||
|
typedef EGLSurface (EGLAPIENTRY * PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC)(EGLDisplay,EGLConfig,void*,const EGLint*);
|
||||||
|
#define eglGetPlatformDisplayEXT _glfw.egl.GetPlatformDisplayEXT
|
||||||
|
#define eglCreatePlatformWindowSurfaceEXT _glfw.egl.CreatePlatformWindowSurfaceEXT
|
||||||
|
|
||||||
|
#define OSMESA_RGBA 0x1908
|
||||||
|
#define OSMESA_FORMAT 0x22
|
||||||
|
#define OSMESA_DEPTH_BITS 0x30
|
||||||
|
#define OSMESA_STENCIL_BITS 0x31
|
||||||
|
#define OSMESA_ACCUM_BITS 0x32
|
||||||
|
#define OSMESA_PROFILE 0x33
|
||||||
|
#define OSMESA_CORE_PROFILE 0x34
|
||||||
|
#define OSMESA_COMPAT_PROFILE 0x35
|
||||||
|
#define OSMESA_CONTEXT_MAJOR_VERSION 0x36
|
||||||
|
#define OSMESA_CONTEXT_MINOR_VERSION 0x37
|
||||||
|
|
||||||
|
typedef void* OSMesaContext;
|
||||||
|
typedef void (*OSMESAproc)(void);
|
||||||
|
|
||||||
|
typedef OSMesaContext (GLAPIENTRY * PFN_OSMesaCreateContextExt)(GLenum,GLint,GLint,GLint,OSMesaContext);
|
||||||
|
typedef OSMesaContext (GLAPIENTRY * PFN_OSMesaCreateContextAttribs)(const int*,OSMesaContext);
|
||||||
|
typedef void (GLAPIENTRY * PFN_OSMesaDestroyContext)(OSMesaContext);
|
||||||
|
typedef int (GLAPIENTRY * PFN_OSMesaMakeCurrent)(OSMesaContext,void*,int,int,int);
|
||||||
|
typedef int (GLAPIENTRY * PFN_OSMesaGetColorBuffer)(OSMesaContext,int*,int*,int*,void**);
|
||||||
|
typedef int (GLAPIENTRY * PFN_OSMesaGetDepthBuffer)(OSMesaContext,int*,int*,int*,void**);
|
||||||
|
typedef GLFWglproc (GLAPIENTRY * PFN_OSMesaGetProcAddress)(const char*);
|
||||||
|
#define OSMesaCreateContextExt _glfw.osmesa.CreateContextExt
|
||||||
|
#define OSMesaCreateContextAttribs _glfw.osmesa.CreateContextAttribs
|
||||||
|
#define OSMesaDestroyContext _glfw.osmesa.DestroyContext
|
||||||
|
#define OSMesaMakeCurrent _glfw.osmesa.MakeCurrent
|
||||||
|
#define OSMesaGetColorBuffer _glfw.osmesa.GetColorBuffer
|
||||||
|
#define OSMesaGetDepthBuffer _glfw.osmesa.GetDepthBuffer
|
||||||
|
#define OSMesaGetProcAddress _glfw.osmesa.GetProcAddress
|
||||||
|
|
||||||
#define VK_NULL_HANDLE 0
|
#define VK_NULL_HANDLE 0
|
||||||
|
|
||||||
typedef void* VkInstance;
|
typedef void* VkInstance;
|
||||||
@ -170,29 +324,11 @@ typedef struct VkExtensionProperties
|
|||||||
|
|
||||||
typedef void (APIENTRY * PFN_vkVoidFunction)(void);
|
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 PFN_vkVoidFunction (APIENTRY * PFN_vkGetInstanceProcAddr)(VkInstance,const char*);
|
||||||
typedef VkResult (APIENTRY * PFN_vkEnumerateInstanceExtensionProperties)(const char*,uint32_t*,VkExtensionProperties*);
|
typedef VkResult (APIENTRY * PFN_vkEnumerateInstanceExtensionProperties)(const char*,uint32_t*,VkExtensionProperties*);
|
||||||
#define vkEnumerateInstanceExtensionProperties _glfw.vk.EnumerateInstanceExtensionProperties
|
|
||||||
#define vkGetInstanceProcAddr _glfw.vk.GetInstanceProcAddr
|
#define vkGetInstanceProcAddr _glfw.vk.GetInstanceProcAddr
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(_GLFW_COCOA)
|
#include "platform.h"
|
||||||
#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
|
|
||||||
|
|
||||||
// Constructs a version number string from the public header macros
|
// Constructs a version number string from the public header macros
|
||||||
#define _GLFW_CONCAT_VERSION(m, n, r) #m "." #n "." #r
|
#define _GLFW_CONCAT_VERSION(m, n, r) #m "." #n "." #r
|
||||||
@ -216,9 +352,9 @@ typedef void (APIENTRY * PFN_vkVoidFunction)(void);
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Swaps the provided pointers
|
// Swaps the provided pointers
|
||||||
#define _GLFW_SWAP_POINTERS(x, y) \
|
#define _GLFW_SWAP(type, x, y) \
|
||||||
{ \
|
{ \
|
||||||
void* t; \
|
type t; \
|
||||||
t = x; \
|
t = x; \
|
||||||
x = y; \
|
x = y; \
|
||||||
y = t; \
|
y = t; \
|
||||||
@ -240,10 +376,16 @@ struct _GLFWerror
|
|||||||
struct _GLFWinitconfig
|
struct _GLFWinitconfig
|
||||||
{
|
{
|
||||||
GLFWbool hatButtons;
|
GLFWbool hatButtons;
|
||||||
|
int angleType;
|
||||||
|
int platformID;
|
||||||
|
PFN_vkGetInstanceProcAddr vulkanLoader;
|
||||||
struct {
|
struct {
|
||||||
GLFWbool menubar;
|
GLFWbool menubar;
|
||||||
GLFWbool chdir;
|
GLFWbool chdir;
|
||||||
} ns;
|
} ns;
|
||||||
|
struct {
|
||||||
|
GLFWbool xcbVulkanSurface;
|
||||||
|
} x11;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Window configuration
|
// Window configuration
|
||||||
@ -267,6 +409,7 @@ struct _GLFWwndconfig
|
|||||||
GLFWbool maximized;
|
GLFWbool maximized;
|
||||||
GLFWbool centerCursor;
|
GLFWbool centerCursor;
|
||||||
GLFWbool focusOnShow;
|
GLFWbool focusOnShow;
|
||||||
|
GLFWbool mousePassthrough;
|
||||||
GLFWbool scaleToMonitor;
|
GLFWbool scaleToMonitor;
|
||||||
struct {
|
struct {
|
||||||
GLFWbool retina;
|
GLFWbool retina;
|
||||||
@ -350,19 +493,29 @@ struct _GLFWcontext
|
|||||||
PFNGLGETINTEGERVPROC GetIntegerv;
|
PFNGLGETINTEGERVPROC GetIntegerv;
|
||||||
PFNGLGETSTRINGPROC GetString;
|
PFNGLGETSTRINGPROC GetString;
|
||||||
|
|
||||||
_GLFWmakecontextcurrentfun makeCurrent;
|
void (*makeCurrent)(_GLFWwindow*);
|
||||||
_GLFWswapbuffersfun swapBuffers;
|
void (*swapBuffers)(_GLFWwindow*);
|
||||||
_GLFWswapintervalfun swapInterval;
|
void (*swapInterval)(int);
|
||||||
_GLFWextensionsupportedfun extensionSupported;
|
int (*extensionSupported)(const char*);
|
||||||
_GLFWgetprocaddressfun getProcAddress;
|
GLFWglproc (*getProcAddress)(const char*);
|
||||||
_GLFWdestroycontextfun destroy;
|
void (*destroy)(_GLFWwindow*);
|
||||||
|
|
||||||
// This is defined in the context API's context.h
|
struct {
|
||||||
_GLFW_PLATFORM_CONTEXT_STATE;
|
EGLConfig config;
|
||||||
// This is defined in egl_context.h
|
EGLContext handle;
|
||||||
_GLFW_EGL_CONTEXT_STATE;
|
EGLSurface surface;
|
||||||
// This is defined in osmesa_context.h
|
void* client;
|
||||||
_GLFW_OSMESA_CONTEXT_STATE;
|
} egl;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
OSMesaContext handle;
|
||||||
|
int width;
|
||||||
|
int height;
|
||||||
|
void* buffer;
|
||||||
|
} osmesa;
|
||||||
|
|
||||||
|
// This is defined in platform.h
|
||||||
|
GLFW_PLATFORM_CONTEXT_STATE
|
||||||
};
|
};
|
||||||
|
|
||||||
// Window and context structure
|
// Window and context structure
|
||||||
@ -378,8 +531,10 @@ struct _GLFWwindow
|
|||||||
GLFWbool autoIconify;
|
GLFWbool autoIconify;
|
||||||
GLFWbool floating;
|
GLFWbool floating;
|
||||||
GLFWbool focusOnShow;
|
GLFWbool focusOnShow;
|
||||||
|
GLFWbool mousePassthrough;
|
||||||
GLFWbool shouldClose;
|
GLFWbool shouldClose;
|
||||||
void* userPointer;
|
void* userPointer;
|
||||||
|
GLFWbool doublebuffer;
|
||||||
GLFWvidmode videoMode;
|
GLFWvidmode videoMode;
|
||||||
_GLFWmonitor* monitor;
|
_GLFWmonitor* monitor;
|
||||||
_GLFWcursor* cursor;
|
_GLFWcursor* cursor;
|
||||||
@ -421,15 +576,15 @@ struct _GLFWwindow
|
|||||||
GLFWdropfun drop;
|
GLFWdropfun drop;
|
||||||
} callbacks;
|
} callbacks;
|
||||||
|
|
||||||
// This is defined in the window API's platform.h
|
// This is defined in platform.h
|
||||||
_GLFW_PLATFORM_WINDOW_STATE;
|
GLFW_PLATFORM_WINDOW_STATE
|
||||||
};
|
};
|
||||||
|
|
||||||
// Monitor structure
|
// Monitor structure
|
||||||
//
|
//
|
||||||
struct _GLFWmonitor
|
struct _GLFWmonitor
|
||||||
{
|
{
|
||||||
char* name;
|
char name[128];
|
||||||
void* userPointer;
|
void* userPointer;
|
||||||
|
|
||||||
// Physical dimensions in millimeters.
|
// Physical dimensions in millimeters.
|
||||||
@ -445,8 +600,8 @@ struct _GLFWmonitor
|
|||||||
GLFWgammaramp originalRamp;
|
GLFWgammaramp originalRamp;
|
||||||
GLFWgammaramp currentRamp;
|
GLFWgammaramp currentRamp;
|
||||||
|
|
||||||
// This is defined in the window API's platform.h
|
// This is defined in platform.h
|
||||||
_GLFW_PLATFORM_MONITOR_STATE;
|
GLFW_PLATFORM_MONITOR_STATE
|
||||||
};
|
};
|
||||||
|
|
||||||
// Cursor structure
|
// Cursor structure
|
||||||
@ -454,9 +609,8 @@ struct _GLFWmonitor
|
|||||||
struct _GLFWcursor
|
struct _GLFWcursor
|
||||||
{
|
{
|
||||||
_GLFWcursor* next;
|
_GLFWcursor* next;
|
||||||
|
// This is defined in platform.h
|
||||||
// This is defined in the window API's platform.h
|
GLFW_PLATFORM_CURSOR_STATE
|
||||||
_GLFW_PLATFORM_CURSOR_STATE;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Gamepad mapping element structure
|
// Gamepad mapping element structure
|
||||||
@ -490,29 +644,117 @@ struct _GLFWjoystick
|
|||||||
int buttonCount;
|
int buttonCount;
|
||||||
unsigned char* hats;
|
unsigned char* hats;
|
||||||
int hatCount;
|
int hatCount;
|
||||||
char* name;
|
char name[128];
|
||||||
void* userPointer;
|
void* userPointer;
|
||||||
char guid[33];
|
char guid[33];
|
||||||
_GLFWmapping* mapping;
|
_GLFWmapping* mapping;
|
||||||
|
|
||||||
// This is defined in the joystick API's joystick.h
|
// This is defined in platform.h
|
||||||
_GLFW_PLATFORM_JOYSTICK_STATE;
|
GLFW_PLATFORM_JOYSTICK_STATE
|
||||||
};
|
};
|
||||||
|
|
||||||
// Thread local storage structure
|
// Thread local storage structure
|
||||||
//
|
//
|
||||||
struct _GLFWtls
|
struct _GLFWtls
|
||||||
{
|
{
|
||||||
// This is defined in the platform's thread.h
|
// This is defined in platform.h
|
||||||
_GLFW_PLATFORM_TLS_STATE;
|
GLFW_PLATFORM_TLS_STATE
|
||||||
};
|
};
|
||||||
|
|
||||||
// Mutex structure
|
// Mutex structure
|
||||||
//
|
//
|
||||||
struct _GLFWmutex
|
struct _GLFWmutex
|
||||||
{
|
{
|
||||||
// This is defined in the platform's thread.h
|
// This is defined in platform.h
|
||||||
_GLFW_PLATFORM_MUTEX_STATE;
|
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);
|
||||||
|
|
||||||
|
// Hazel
|
||||||
|
void (*setWindowTitleBar)(_GLFWwindow*,GLFWbool);
|
||||||
|
|
||||||
|
// 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
|
// Library global data
|
||||||
@ -520,6 +762,9 @@ struct _GLFWmutex
|
|||||||
struct _GLFWlibrary
|
struct _GLFWlibrary
|
||||||
{
|
{
|
||||||
GLFWbool initialized;
|
GLFWbool initialized;
|
||||||
|
GLFWallocator allocator;
|
||||||
|
|
||||||
|
_GLFWplatform platform;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
_GLFWinitconfig init;
|
_GLFWinitconfig init;
|
||||||
@ -536,6 +781,7 @@ struct _GLFWlibrary
|
|||||||
_GLFWmonitor** monitors;
|
_GLFWmonitor** monitors;
|
||||||
int monitorCount;
|
int monitorCount;
|
||||||
|
|
||||||
|
GLFWbool joysticksInitialized;
|
||||||
_GLFWjoystick joysticks[GLFW_JOYSTICK_LAST + 1];
|
_GLFWjoystick joysticks[GLFW_JOYSTICK_LAST + 1];
|
||||||
_GLFWmapping* mappings;
|
_GLFWmapping* mappings;
|
||||||
int mappingCount;
|
int mappingCount;
|
||||||
@ -546,30 +792,80 @@ struct _GLFWlibrary
|
|||||||
|
|
||||||
struct {
|
struct {
|
||||||
uint64_t offset;
|
uint64_t offset;
|
||||||
// This is defined in the platform's time.h
|
// This is defined in platform.h
|
||||||
_GLFW_PLATFORM_LIBRARY_TIMER_STATE;
|
GLFW_PLATFORM_LIBRARY_TIMER_STATE
|
||||||
} timer;
|
} 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;
|
||||||
|
|
||||||
|
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 {
|
struct {
|
||||||
GLFWbool available;
|
GLFWbool available;
|
||||||
void* handle;
|
void* handle;
|
||||||
char* extensions[2];
|
char* extensions[2];
|
||||||
#if !defined(_GLFW_VULKAN_STATIC)
|
|
||||||
PFN_vkEnumerateInstanceExtensionProperties EnumerateInstanceExtensionProperties;
|
|
||||||
PFN_vkGetInstanceProcAddr GetInstanceProcAddr;
|
PFN_vkGetInstanceProcAddr GetInstanceProcAddr;
|
||||||
#endif
|
|
||||||
GLFWbool KHR_surface;
|
GLFWbool KHR_surface;
|
||||||
#if defined(_GLFW_WIN32)
|
|
||||||
GLFWbool KHR_win32_surface;
|
GLFWbool KHR_win32_surface;
|
||||||
#elif defined(_GLFW_COCOA)
|
|
||||||
GLFWbool MVK_macos_surface;
|
GLFWbool MVK_macos_surface;
|
||||||
GLFWbool EXT_metal_surface;
|
GLFWbool EXT_metal_surface;
|
||||||
#elif defined(_GLFW_X11)
|
|
||||||
GLFWbool KHR_xlib_surface;
|
GLFWbool KHR_xlib_surface;
|
||||||
GLFWbool KHR_xcb_surface;
|
GLFWbool KHR_xcb_surface;
|
||||||
#elif defined(_GLFW_WAYLAND)
|
|
||||||
GLFWbool KHR_wayland_surface;
|
GLFWbool KHR_wayland_surface;
|
||||||
#endif
|
|
||||||
} vk;
|
} vk;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
@ -577,16 +873,10 @@ struct _GLFWlibrary
|
|||||||
GLFWjoystickfun joystick;
|
GLFWjoystickfun joystick;
|
||||||
} callbacks;
|
} callbacks;
|
||||||
|
|
||||||
// This is defined in the window API's platform.h
|
// These are defined in platform.h
|
||||||
_GLFW_PLATFORM_LIBRARY_WINDOW_STATE;
|
GLFW_PLATFORM_LIBRARY_WINDOW_STATE
|
||||||
// This is defined in the context API's context.h
|
GLFW_PLATFORM_LIBRARY_CONTEXT_STATE
|
||||||
_GLFW_PLATFORM_LIBRARY_CONTEXT_STATE;
|
GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE
|
||||||
// This is defined in the platform's joystick.h
|
|
||||||
_GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE;
|
|
||||||
// This is defined in egl_context.h
|
|
||||||
_GLFW_EGL_LIBRARY_CONTEXT_STATE;
|
|
||||||
// This is defined in osmesa_context.h
|
|
||||||
_GLFW_OSMESA_LIBRARY_CONTEXT_STATE;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Global state shared between compilation units of GLFW
|
// Global state shared between compilation units of GLFW
|
||||||
@ -598,40 +888,7 @@ extern _GLFWlibrary _glfw;
|
|||||||
////// GLFW platform API //////
|
////// GLFW platform API //////
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
int _glfwPlatformInit(void);
|
void _glfwPlatformInitTimer(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);
|
|
||||||
|
|
||||||
int _glfwPlatformPollJoystick(_GLFWjoystick* js, int mode);
|
|
||||||
void _glfwPlatformUpdateGamepadGUID(char* guid);
|
|
||||||
|
|
||||||
uint64_t _glfwPlatformGetTimerValue(void);
|
uint64_t _glfwPlatformGetTimerValue(void);
|
||||||
uint64_t _glfwPlatformGetTimerFrequency(void);
|
uint64_t _glfwPlatformGetTimerFrequency(void);
|
||||||
|
|
||||||
@ -704,6 +961,10 @@ void _glfwPlatformDestroyMutex(_GLFWmutex* mutex);
|
|||||||
void _glfwPlatformLockMutex(_GLFWmutex* mutex);
|
void _glfwPlatformLockMutex(_GLFWmutex* mutex);
|
||||||
void _glfwPlatformUnlockMutex(_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 //////
|
////// GLFW event API //////
|
||||||
@ -725,7 +986,7 @@ void _glfwInputWindowMonitor(_GLFWwindow* window, _GLFWmonitor* monitor);
|
|||||||
void _glfwInputKey(_GLFWwindow* window,
|
void _glfwInputKey(_GLFWwindow* window,
|
||||||
int key, int scancode, int action, int mods);
|
int key, int scancode, int action, int mods);
|
||||||
void _glfwInputChar(_GLFWwindow* window,
|
void _glfwInputChar(_GLFWwindow* window,
|
||||||
unsigned int codepoint, int mods, GLFWbool plain);
|
uint32_t codepoint, int mods, GLFWbool plain);
|
||||||
void _glfwInputScroll(_GLFWwindow* window, double xoffset, double yoffset);
|
void _glfwInputScroll(_GLFWwindow* window, double xoffset, double yoffset);
|
||||||
void _glfwInputMouseClick(_GLFWwindow* window, int button, int action, int mods);
|
void _glfwInputMouseClick(_GLFWwindow* window, int button, int action, int mods);
|
||||||
void _glfwInputCursorPos(_GLFWwindow* window, double xpos, double ypos);
|
void _glfwInputCursorPos(_GLFWwindow* window, double xpos, double ypos);
|
||||||
@ -751,6 +1012,8 @@ void _glfwInputError(int code, const char* format, ...);
|
|||||||
////// GLFW internal API //////
|
////// GLFW internal API //////
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
GLFWbool _glfwSelectPlatform(int platformID, _GLFWplatform* platform);
|
||||||
|
|
||||||
GLFWbool _glfwStringInExtensionString(const char* string, const char* extensions);
|
GLFWbool _glfwStringInExtensionString(const char* string, const char* extensions);
|
||||||
const _GLFWfbconfig* _glfwChooseFBConfig(const _GLFWfbconfig* desired,
|
const _GLFWfbconfig* _glfwChooseFBConfig(const _GLFWfbconfig* desired,
|
||||||
const _GLFWfbconfig* alternatives,
|
const _GLFWfbconfig* alternatives,
|
||||||
@ -768,6 +1031,7 @@ void _glfwAllocGammaArrays(GLFWgammaramp* ramp, unsigned int size);
|
|||||||
void _glfwFreeGammaArrays(GLFWgammaramp* ramp);
|
void _glfwFreeGammaArrays(GLFWgammaramp* ramp);
|
||||||
void _glfwSplitBPP(int bpp, int* red, int* green, int* blue);
|
void _glfwSplitBPP(int bpp, int* red, int* green, int* blue);
|
||||||
|
|
||||||
|
void _glfwInitGamepadMappings(void);
|
||||||
_GLFWjoystick* _glfwAllocJoystick(const char* name,
|
_GLFWjoystick* _glfwAllocJoystick(const char* name,
|
||||||
const char* guid,
|
const char* guid,
|
||||||
int axisCount,
|
int axisCount,
|
||||||
@ -776,11 +1040,35 @@ _GLFWjoystick* _glfwAllocJoystick(const char* name,
|
|||||||
void _glfwFreeJoystick(_GLFWjoystick* js);
|
void _glfwFreeJoystick(_GLFWjoystick* js);
|
||||||
void _glfwCenterCursorInContentArea(_GLFWwindow* window);
|
void _glfwCenterCursorInContentArea(_GLFWwindow* window);
|
||||||
|
|
||||||
|
GLFWbool _glfwInitEGL(void);
|
||||||
|
void _glfwTerminateEGL(void);
|
||||||
|
GLFWbool _glfwCreateContextEGL(_GLFWwindow* window,
|
||||||
|
const _GLFWctxconfig* ctxconfig,
|
||||||
|
const _GLFWfbconfig* fbconfig);
|
||||||
|
#if defined(_GLFW_X11)
|
||||||
|
GLFWbool _glfwChooseVisualEGL(const _GLFWwndconfig* wndconfig,
|
||||||
|
const _GLFWctxconfig* ctxconfig,
|
||||||
|
const _GLFWfbconfig* fbconfig,
|
||||||
|
Visual** visual, int* depth);
|
||||||
|
#endif /*_GLFW_X11*/
|
||||||
|
|
||||||
|
GLFWbool _glfwInitOSMesa(void);
|
||||||
|
void _glfwTerminateOSMesa(void);
|
||||||
|
GLFWbool _glfwCreateContextOSMesa(_GLFWwindow* window,
|
||||||
|
const _GLFWctxconfig* ctxconfig,
|
||||||
|
const _GLFWfbconfig* fbconfig);
|
||||||
|
|
||||||
GLFWbool _glfwInitVulkan(int mode);
|
GLFWbool _glfwInitVulkan(int mode);
|
||||||
void _glfwTerminateVulkan(void);
|
void _glfwTerminateVulkan(void);
|
||||||
const char* _glfwGetVulkanResultString(VkResult result);
|
const char* _glfwGetVulkanResultString(VkResult result);
|
||||||
|
|
||||||
|
size_t _glfwEncodeUTF8(char* s, uint32_t codepoint);
|
||||||
|
|
||||||
char* _glfw_strdup(const char* source);
|
char* _glfw_strdup(const char* source);
|
||||||
float _glfw_fminf(float a, float b);
|
float _glfw_fminf(float a, float b);
|
||||||
float _glfw_fmaxf(float a, float b);
|
float _glfw_fmaxf(float a, float b);
|
||||||
|
|
||||||
|
void* _glfw_calloc(size_t count, size_t size);
|
||||||
|
void* _glfw_realloc(void* pointer, size_t size);
|
||||||
|
void _glfw_free(void* pointer);
|
||||||
|
|
||||||
|
@ -264,8 +264,49 @@ static int compareJoysticks(const void* fp, const void* sp)
|
|||||||
////// GLFW internal API //////
|
////// GLFW internal API //////
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// Initialize joystick interface
|
void _glfwDetectJoystickConnectionLinux(void)
|
||||||
//
|
{
|
||||||
|
if (_glfw.linjs.inotify <= 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
ssize_t offset = 0;
|
||||||
|
char buffer[16384];
|
||||||
|
const ssize_t size = read(_glfw.linjs.inotify, buffer, sizeof(buffer));
|
||||||
|
|
||||||
|
while (size > offset)
|
||||||
|
{
|
||||||
|
regmatch_t match;
|
||||||
|
const struct inotify_event* e = (struct inotify_event*) (buffer + offset);
|
||||||
|
|
||||||
|
offset += sizeof(struct inotify_event) + e->len;
|
||||||
|
|
||||||
|
if (regexec(&_glfw.linjs.regex, e->name, 1, &match, 0) != 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
char path[PATH_MAX];
|
||||||
|
snprintf(path, sizeof(path), "/dev/input/%s", e->name);
|
||||||
|
|
||||||
|
if (e->mask & (IN_CREATE | IN_ATTRIB))
|
||||||
|
openJoystickDevice(path);
|
||||||
|
else if (e->mask & IN_DELETE)
|
||||||
|
{
|
||||||
|
for (int jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++)
|
||||||
|
{
|
||||||
|
if (strcmp(_glfw.joysticks[jid].linjs.path, path) == 0)
|
||||||
|
{
|
||||||
|
closeJoystick(_glfw.joysticks + jid);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
////// GLFW platform API //////
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
GLFWbool _glfwInitJoysticksLinux(void)
|
GLFWbool _glfwInitJoysticksLinux(void)
|
||||||
{
|
{
|
||||||
const char* dirname = "/dev/input";
|
const char* dirname = "/dev/input";
|
||||||
@ -320,74 +361,26 @@ GLFWbool _glfwInitJoysticksLinux(void)
|
|||||||
return GLFW_TRUE;
|
return GLFW_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close all opened joystick handles
|
|
||||||
//
|
|
||||||
void _glfwTerminateJoysticksLinux(void)
|
void _glfwTerminateJoysticksLinux(void)
|
||||||
{
|
{
|
||||||
int jid;
|
for (int jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++)
|
||||||
|
|
||||||
for (jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++)
|
|
||||||
{
|
{
|
||||||
_GLFWjoystick* js = _glfw.joysticks + jid;
|
_GLFWjoystick* js = _glfw.joysticks + jid;
|
||||||
if (js->present)
|
if (js->present)
|
||||||
closeJoystick(js);
|
closeJoystick(js);
|
||||||
}
|
}
|
||||||
|
|
||||||
regfree(&_glfw.linjs.regex);
|
|
||||||
|
|
||||||
if (_glfw.linjs.inotify > 0)
|
if (_glfw.linjs.inotify > 0)
|
||||||
{
|
{
|
||||||
if (_glfw.linjs.watch > 0)
|
if (_glfw.linjs.watch > 0)
|
||||||
inotify_rm_watch(_glfw.linjs.inotify, _glfw.linjs.watch);
|
inotify_rm_watch(_glfw.linjs.inotify, _glfw.linjs.watch);
|
||||||
|
|
||||||
close(_glfw.linjs.inotify);
|
close(_glfw.linjs.inotify);
|
||||||
|
regfree(&_glfw.linjs.regex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwDetectJoystickConnectionLinux(void)
|
int _glfwPollJoystickLinux(_GLFWjoystick* js, int mode)
|
||||||
{
|
|
||||||
if (_glfw.linjs.inotify <= 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
ssize_t offset = 0;
|
|
||||||
char buffer[16384];
|
|
||||||
const ssize_t size = read(_glfw.linjs.inotify, buffer, sizeof(buffer));
|
|
||||||
|
|
||||||
while (size > offset)
|
|
||||||
{
|
|
||||||
regmatch_t match;
|
|
||||||
const struct inotify_event* e = (struct inotify_event*) (buffer + offset);
|
|
||||||
|
|
||||||
offset += sizeof(struct inotify_event) + e->len;
|
|
||||||
|
|
||||||
if (regexec(&_glfw.linjs.regex, e->name, 1, &match, 0) != 0)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
char path[PATH_MAX];
|
|
||||||
snprintf(path, sizeof(path), "/dev/input/%s", e->name);
|
|
||||||
|
|
||||||
if (e->mask & (IN_CREATE | IN_ATTRIB))
|
|
||||||
openJoystickDevice(path);
|
|
||||||
else if (e->mask & IN_DELETE)
|
|
||||||
{
|
|
||||||
for (int jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++)
|
|
||||||
{
|
|
||||||
if (strcmp(_glfw.joysticks[jid].linjs.path, path) == 0)
|
|
||||||
{
|
|
||||||
closeJoystick(_glfw.joysticks + jid);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
////// GLFW platform API //////
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
int _glfwPlatformPollJoystick(_GLFWjoystick* js, int mode)
|
|
||||||
{
|
{
|
||||||
// Read all queued events (non-blocking)
|
// Read all queued events (non-blocking)
|
||||||
for (;;)
|
for (;;)
|
||||||
@ -427,7 +420,12 @@ int _glfwPlatformPollJoystick(_GLFWjoystick* js, int mode)
|
|||||||
return js->present;
|
return js->present;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformUpdateGamepadGUID(char* guid)
|
const char* _glfwGetMappingNameLinux(void)
|
||||||
|
{
|
||||||
|
return "Linux";
|
||||||
|
}
|
||||||
|
|
||||||
|
void _glfwUpdateGamepadGUIDLinux(char* guid)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,10 +28,10 @@
|
|||||||
#include <linux/limits.h>
|
#include <linux/limits.h>
|
||||||
#include <regex.h>
|
#include <regex.h>
|
||||||
|
|
||||||
#define _GLFW_PLATFORM_JOYSTICK_STATE _GLFWjoystickLinux linjs
|
#define GLFW_LINUX_JOYSTICK_STATE _GLFWjoystickLinux linjs;
|
||||||
#define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE _GLFWlibraryLinux linjs
|
#define GLFW_LINUX_LIBRARY_JOYSTICK_STATE _GLFWlibraryLinux linjs;
|
||||||
|
|
||||||
#define _GLFW_PLATFORM_MAPPING_NAME "Linux"
|
#define GLFW_BUILD_LINUX_MAPPINGS
|
||||||
|
|
||||||
// Linux-specific joystick data
|
// Linux-specific joystick data
|
||||||
//
|
//
|
||||||
@ -55,8 +55,11 @@ typedef struct _GLFWlibraryLinux
|
|||||||
GLFWbool dropped;
|
GLFWbool dropped;
|
||||||
} _GLFWlibraryLinux;
|
} _GLFWlibraryLinux;
|
||||||
|
|
||||||
|
void _glfwDetectJoystickConnectionLinux(void);
|
||||||
|
|
||||||
GLFWbool _glfwInitJoysticksLinux(void);
|
GLFWbool _glfwInitJoysticksLinux(void);
|
||||||
void _glfwTerminateJoysticksLinux(void);
|
void _glfwTerminateJoysticksLinux(void);
|
||||||
void _glfwDetectJoystickConnectionLinux(void);
|
int _glfwPollJoystickLinux(_GLFWjoystick* js, int mode);
|
||||||
|
const char* _glfwGetMappingNameLinux(void);
|
||||||
|
void _glfwUpdateGamepadGUIDLinux(char* guid);
|
||||||
|
|
||||||
|
1117
src/mappings.h
1117
src/mappings.h
File diff suppressed because it is too large
Load Diff
@ -31,7 +31,7 @@
|
|||||||
// all available in SDL_GameControllerDB. Do not edit this file. Any gamepad
|
// all available in SDL_GameControllerDB. Do not edit this file. Any gamepad
|
||||||
// mappings not specific to GLFW should be submitted to SDL_GameControllerDB.
|
// mappings not specific to GLFW should be submitted to SDL_GameControllerDB.
|
||||||
// This file can be re-generated from mappings.h.in and the upstream
|
// This file can be re-generated from mappings.h.in and the upstream
|
||||||
// gamecontrollerdb.txt with the GenerateMappings.cmake script.
|
// gamecontrollerdb.txt with the 'update_mappings' CMake target.
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
// All gamepad mappings not labeled GLFW are copied from the
|
// All gamepad mappings not labeled GLFW are copied from the
|
||||||
@ -60,7 +60,8 @@
|
|||||||
|
|
||||||
const char* _glfwDefaultMappings[] =
|
const char* _glfwDefaultMappings[] =
|
||||||
{
|
{
|
||||||
@GLFW_GAMEPAD_MAPPINGS@
|
#if defined(GLFW_BUILD_WIN32_MAPPINGS)
|
||||||
|
@GLFW_WIN32_MAPPINGS@
|
||||||
"78696e70757401000000000000000000,XInput Gamepad (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,",
|
"78696e70757401000000000000000000,XInput Gamepad (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,",
|
||||||
"78696e70757402000000000000000000,XInput Wheel (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,",
|
"78696e70757402000000000000000000,XInput Wheel (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,",
|
||||||
"78696e70757403000000000000000000,XInput Arcade Stick (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,",
|
"78696e70757403000000000000000000,XInput Arcade Stick (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,",
|
||||||
@ -68,6 +69,14 @@ const char* _glfwDefaultMappings[] =
|
|||||||
"78696e70757405000000000000000000,XInput Dance Pad (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,",
|
"78696e70757405000000000000000000,XInput Dance Pad (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,",
|
||||||
"78696e70757406000000000000000000,XInput Guitar (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,",
|
"78696e70757406000000000000000000,XInput Guitar (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,",
|
||||||
"78696e70757408000000000000000000,XInput Drum Kit (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,",
|
"78696e70757408000000000000000000,XInput Drum Kit (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,",
|
||||||
NULL
|
#endif // GLFW_BUILD_WIN32_MAPPINGS
|
||||||
|
|
||||||
|
#if defined(GLFW_BUILD_COCOA_MAPPINGS)
|
||||||
|
@GLFW_COCOA_MAPPINGS@
|
||||||
|
#endif // GLFW_BUILD_COCOA_MAPPINGS
|
||||||
|
|
||||||
|
#if defined(GLFW_BUILD_LINUX_MAPPINGS)
|
||||||
|
@GLFW_LINUX_MAPPINGS@
|
||||||
|
#endif // GLFW_BUILD_LINUX_MAPPINGS
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -74,13 +74,13 @@ static GLFWbool refreshVideoModes(_GLFWmonitor* monitor)
|
|||||||
if (monitor->modes)
|
if (monitor->modes)
|
||||||
return GLFW_TRUE;
|
return GLFW_TRUE;
|
||||||
|
|
||||||
modes = _glfwPlatformGetVideoModes(monitor, &modeCount);
|
modes = _glfw.platform.getVideoModes(monitor, &modeCount);
|
||||||
if (!modes)
|
if (!modes)
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
|
|
||||||
qsort(modes, modeCount, sizeof(GLFWvidmode), compareVideoModes);
|
qsort(modes, modeCount, sizeof(GLFWvidmode), compareVideoModes);
|
||||||
|
|
||||||
free(monitor->modes);
|
_glfw_free(monitor->modes);
|
||||||
monitor->modes = modes;
|
monitor->modes = modes;
|
||||||
monitor->modeCount = modeCount;
|
monitor->modeCount = modeCount;
|
||||||
|
|
||||||
@ -100,7 +100,8 @@ void _glfwInputMonitor(_GLFWmonitor* monitor, int action, int placement)
|
|||||||
{
|
{
|
||||||
_glfw.monitorCount++;
|
_glfw.monitorCount++;
|
||||||
_glfw.monitors =
|
_glfw.monitors =
|
||||||
realloc(_glfw.monitors, sizeof(_GLFWmonitor*) * _glfw.monitorCount);
|
_glfw_realloc(_glfw.monitors,
|
||||||
|
sizeof(_GLFWmonitor*) * _glfw.monitorCount);
|
||||||
|
|
||||||
if (placement == _GLFW_INSERT_FIRST)
|
if (placement == _GLFW_INSERT_FIRST)
|
||||||
{
|
{
|
||||||
@ -122,10 +123,10 @@ void _glfwInputMonitor(_GLFWmonitor* monitor, int action, int placement)
|
|||||||
if (window->monitor == monitor)
|
if (window->monitor == monitor)
|
||||||
{
|
{
|
||||||
int width, height, xoff, yoff;
|
int width, height, xoff, yoff;
|
||||||
_glfwPlatformGetWindowSize(window, &width, &height);
|
_glfw.platform.getWindowSize(window, &width, &height);
|
||||||
_glfwPlatformSetWindowMonitor(window, NULL, 0, 0, width, height, 0);
|
_glfw.platform.setWindowMonitor(window, NULL, 0, 0, width, height, 0);
|
||||||
_glfwPlatformGetWindowFrameSize(window, &xoff, &yoff, NULL, NULL);
|
_glfw.platform.getWindowFrameSize(window, &xoff, &yoff, NULL, NULL);
|
||||||
_glfwPlatformSetWindowPos(window, xoff, yoff);
|
_glfw.platform.setWindowPos(window, xoff, yoff);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,12 +167,11 @@ void _glfwInputMonitorWindow(_GLFWmonitor* monitor, _GLFWwindow* window)
|
|||||||
//
|
//
|
||||||
_GLFWmonitor* _glfwAllocMonitor(const char* name, int widthMM, int heightMM)
|
_GLFWmonitor* _glfwAllocMonitor(const char* name, int widthMM, int heightMM)
|
||||||
{
|
{
|
||||||
_GLFWmonitor* monitor = calloc(1, sizeof(_GLFWmonitor));
|
_GLFWmonitor* monitor = _glfw_calloc(1, sizeof(_GLFWmonitor));
|
||||||
monitor->widthMM = widthMM;
|
monitor->widthMM = widthMM;
|
||||||
monitor->heightMM = heightMM;
|
monitor->heightMM = heightMM;
|
||||||
|
|
||||||
if (name)
|
strncpy(monitor->name, name, sizeof(monitor->name) - 1);
|
||||||
monitor->name = _glfw_strdup(name);
|
|
||||||
|
|
||||||
return monitor;
|
return monitor;
|
||||||
}
|
}
|
||||||
@ -183,23 +183,22 @@ void _glfwFreeMonitor(_GLFWmonitor* monitor)
|
|||||||
if (monitor == NULL)
|
if (monitor == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_glfwPlatformFreeMonitor(monitor);
|
_glfw.platform.freeMonitor(monitor);
|
||||||
|
|
||||||
_glfwFreeGammaArrays(&monitor->originalRamp);
|
_glfwFreeGammaArrays(&monitor->originalRamp);
|
||||||
_glfwFreeGammaArrays(&monitor->currentRamp);
|
_glfwFreeGammaArrays(&monitor->currentRamp);
|
||||||
|
|
||||||
free(monitor->modes);
|
_glfw_free(monitor->modes);
|
||||||
free(monitor->name);
|
_glfw_free(monitor);
|
||||||
free(monitor);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allocates red, green and blue value arrays of the specified size
|
// Allocates red, green and blue value arrays of the specified size
|
||||||
//
|
//
|
||||||
void _glfwAllocGammaArrays(GLFWgammaramp* ramp, unsigned int size)
|
void _glfwAllocGammaArrays(GLFWgammaramp* ramp, unsigned int size)
|
||||||
{
|
{
|
||||||
ramp->red = calloc(size, sizeof(unsigned short));
|
ramp->red = _glfw_calloc(size, sizeof(unsigned short));
|
||||||
ramp->green = calloc(size, sizeof(unsigned short));
|
ramp->green = _glfw_calloc(size, sizeof(unsigned short));
|
||||||
ramp->blue = calloc(size, sizeof(unsigned short));
|
ramp->blue = _glfw_calloc(size, sizeof(unsigned short));
|
||||||
ramp->size = size;
|
ramp->size = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -207,9 +206,9 @@ void _glfwAllocGammaArrays(GLFWgammaramp* ramp, unsigned int size)
|
|||||||
//
|
//
|
||||||
void _glfwFreeGammaArrays(GLFWgammaramp* ramp)
|
void _glfwFreeGammaArrays(GLFWgammaramp* ramp)
|
||||||
{
|
{
|
||||||
free(ramp->red);
|
_glfw_free(ramp->red);
|
||||||
free(ramp->green);
|
_glfw_free(ramp->green);
|
||||||
free(ramp->blue);
|
_glfw_free(ramp->blue);
|
||||||
|
|
||||||
memset(ramp, 0, sizeof(GLFWgammaramp));
|
memset(ramp, 0, sizeof(GLFWgammaramp));
|
||||||
}
|
}
|
||||||
@ -333,7 +332,7 @@ GLFWAPI void glfwGetMonitorPos(GLFWmonitor* handle, int* xpos, int* ypos)
|
|||||||
|
|
||||||
_GLFW_REQUIRE_INIT();
|
_GLFW_REQUIRE_INIT();
|
||||||
|
|
||||||
_glfwPlatformGetMonitorPos(monitor, xpos, ypos);
|
_glfw.platform.getMonitorPos(monitor, xpos, ypos);
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWAPI void glfwGetMonitorWorkarea(GLFWmonitor* handle,
|
GLFWAPI void glfwGetMonitorWorkarea(GLFWmonitor* handle,
|
||||||
@ -354,7 +353,7 @@ GLFWAPI void glfwGetMonitorWorkarea(GLFWmonitor* handle,
|
|||||||
|
|
||||||
_GLFW_REQUIRE_INIT();
|
_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)
|
GLFWAPI void glfwGetMonitorPhysicalSize(GLFWmonitor* handle, int* widthMM, int* heightMM)
|
||||||
@ -387,7 +386,7 @@ GLFWAPI void glfwGetMonitorContentScale(GLFWmonitor* handle,
|
|||||||
*yscale = 0.f;
|
*yscale = 0.f;
|
||||||
|
|
||||||
_GLFW_REQUIRE_INIT();
|
_GLFW_REQUIRE_INIT();
|
||||||
_glfwPlatformGetMonitorContentScale(monitor, xscale, yscale);
|
_glfw.platform.getMonitorContentScale(monitor, xscale, yscale);
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWAPI const char* glfwGetMonitorName(GLFWmonitor* handle)
|
GLFWAPI const char* glfwGetMonitorName(GLFWmonitor* handle)
|
||||||
@ -420,7 +419,7 @@ GLFWAPI void* glfwGetMonitorUserPointer(GLFWmonitor* handle)
|
|||||||
GLFWAPI GLFWmonitorfun glfwSetMonitorCallback(GLFWmonitorfun cbfun)
|
GLFWAPI GLFWmonitorfun glfwSetMonitorCallback(GLFWmonitorfun cbfun)
|
||||||
{
|
{
|
||||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||||
_GLFW_SWAP_POINTERS(_glfw.callbacks.monitor, cbfun);
|
_GLFW_SWAP(GLFWmonitorfun, _glfw.callbacks.monitor, cbfun);
|
||||||
return cbfun;
|
return cbfun;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -448,7 +447,7 @@ GLFWAPI const GLFWvidmode* glfwGetVideoMode(GLFWmonitor* handle)
|
|||||||
|
|
||||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||||
|
|
||||||
_glfwPlatformGetVideoMode(monitor, &monitor->currentMode);
|
_glfw.platform.getVideoMode(monitor, &monitor->currentMode);
|
||||||
return &monitor->currentMode;
|
return &monitor->currentMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -474,7 +473,7 @@ GLFWAPI void glfwSetGamma(GLFWmonitor* handle, float gamma)
|
|||||||
if (!original)
|
if (!original)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
values = calloc(original->size, sizeof(unsigned short));
|
values = _glfw_calloc(original->size, sizeof(unsigned short));
|
||||||
|
|
||||||
for (i = 0; i < original->size; i++)
|
for (i = 0; i < original->size; i++)
|
||||||
{
|
{
|
||||||
@ -496,7 +495,7 @@ GLFWAPI void glfwSetGamma(GLFWmonitor* handle, float gamma)
|
|||||||
ramp.size = original->size;
|
ramp.size = original->size;
|
||||||
|
|
||||||
glfwSetGammaRamp(handle, &ramp);
|
glfwSetGammaRamp(handle, &ramp);
|
||||||
free(values);
|
_glfw_free(values);
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWAPI const GLFWgammaramp* glfwGetGammaRamp(GLFWmonitor* handle)
|
GLFWAPI const GLFWgammaramp* glfwGetGammaRamp(GLFWmonitor* handle)
|
||||||
@ -507,7 +506,7 @@ GLFWAPI const GLFWgammaramp* glfwGetGammaRamp(GLFWmonitor* handle)
|
|||||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||||
|
|
||||||
_glfwFreeGammaArrays(&monitor->currentRamp);
|
_glfwFreeGammaArrays(&monitor->currentRamp);
|
||||||
if (!_glfwPlatformGetGammaRamp(monitor, &monitor->currentRamp))
|
if (!_glfw.platform.getGammaRamp(monitor, &monitor->currentRamp))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return &monitor->currentRamp;
|
return &monitor->currentRamp;
|
||||||
@ -535,10 +534,10 @@ GLFWAPI void glfwSetGammaRamp(GLFWmonitor* handle, const GLFWgammaramp* ramp)
|
|||||||
|
|
||||||
if (!monitor->originalRamp.size)
|
if (!monitor->originalRamp.size)
|
||||||
{
|
{
|
||||||
if (!_glfwPlatformGetGammaRamp(monitor, &monitor->originalRamp))
|
if (!_glfw.platform.getGammaRamp(monitor, &monitor->originalRamp))
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_glfwPlatformSetGammaRamp(monitor, ramp);
|
_glfw.platform.setGammaRamp(monitor, ramp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,66 +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
|
|
||||||
|
|
||||||
#include <stdatomic.h>
|
|
||||||
|
|
||||||
|
|
||||||
// NSGL-specific per-context data
|
|
||||||
//
|
|
||||||
typedef struct _GLFWcontextNSGL
|
|
||||||
{
|
|
||||||
id pixelFormat;
|
|
||||||
id object;
|
|
||||||
|
|
||||||
} _GLFWcontextNSGL;
|
|
||||||
|
|
||||||
// NSGL-specific global data
|
|
||||||
//
|
|
||||||
typedef struct _GLFWlibraryNSGL
|
|
||||||
{
|
|
||||||
// dlopen handle for OpenGL.framework (for glfwGetProcAddress)
|
|
||||||
CFBundleRef framework;
|
|
||||||
|
|
||||||
} _GLFWlibraryNSGL;
|
|
||||||
|
|
||||||
|
|
||||||
GLFWbool _glfwInitNSGL(void);
|
|
||||||
void _glfwTerminateNSGL(void);
|
|
||||||
GLFWbool _glfwCreateContextNSGL(_GLFWwindow* window,
|
|
||||||
const _GLFWctxconfig* ctxconfig,
|
|
||||||
const _GLFWfbconfig* fbconfig);
|
|
||||||
void _glfwDestroyContextNSGL(_GLFWwindow* window);
|
|
||||||
|
|
@ -51,7 +51,7 @@ static void swapBuffersNSGL(_GLFWwindow* window)
|
|||||||
|
|
||||||
// HACK: Simulate vsync with usleep as NSGL swap interval does not apply to
|
// HACK: Simulate vsync with usleep as NSGL swap interval does not apply to
|
||||||
// windows with a non-visible occlusion state
|
// windows with a non-visible occlusion state
|
||||||
if (!([window->ns.object occlusionState] & NSWindowOcclusionStateVisible))
|
if (window->ns.occluded)
|
||||||
{
|
{
|
||||||
int interval = 0;
|
int interval = 0;
|
||||||
[window->context.nsgl.object getValues:&interval
|
[window->context.nsgl.object getValues:&interval
|
||||||
@ -358,7 +358,14 @@ GLFWAPI id glfwGetNSGLContext(GLFWwindow* handle)
|
|||||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||||
_GLFW_REQUIRE_INIT_OR_RETURN(nil);
|
_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);
|
_glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL);
|
||||||
return nil;
|
return nil;
|
||||||
|
@ -29,24 +29,105 @@
|
|||||||
|
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
////// GLFW platform API //////
|
////// GLFW platform API //////
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
int _glfwPlatformInit(void)
|
GLFWbool _glfwConnectNull(int platformID, _GLFWplatform* platform)
|
||||||
{
|
{
|
||||||
_glfwInitTimerPOSIX();
|
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;
|
return GLFW_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformTerminate(void)
|
int _glfwInitNull(void)
|
||||||
{
|
{
|
||||||
|
_glfwPollMonitorsNull();
|
||||||
|
return GLFW_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void _glfwTerminateNull(void)
|
||||||
|
{
|
||||||
|
free(_glfw.null.clipboardString);
|
||||||
_glfwTerminateOSMesa();
|
_glfwTerminateOSMesa();
|
||||||
}
|
_glfwTerminateEGL();
|
||||||
|
|
||||||
const char* _glfwPlatformGetVersionString(void)
|
|
||||||
{
|
|
||||||
return _GLFW_VERSION_NUMBER " null OSMesa";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,12 +33,26 @@
|
|||||||
////// GLFW platform API //////
|
////// GLFW platform API //////
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
int _glfwPlatformPollJoystick(_GLFWjoystick* js, int mode)
|
GLFWbool _glfwInitJoysticksNull(void)
|
||||||
|
{
|
||||||
|
return GLFW_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void _glfwTerminateJoysticksNull(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
int _glfwPollJoystickNull(_GLFWjoystick* js, int mode)
|
||||||
{
|
{
|
||||||
return GLFW_FALSE;
|
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; }
|
GLFWbool _glfwInitJoysticksNull(void);
|
||||||
#define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE struct { int dummyLibraryJoystick; }
|
void _glfwTerminateJoysticksNull(void);
|
||||||
|
int _glfwPollJoystickNull(_GLFWjoystick* js, int mode);
|
||||||
#define _GLFW_PLATFORM_MAPPING_NAME ""
|
const char* _glfwGetMappingNameNull(void);
|
||||||
|
void _glfwUpdateGamepadGUIDNull(char* guid);
|
||||||
|
|
||||||
|
@ -29,20 +29,56 @@
|
|||||||
|
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
// The the sole (fake) video mode of our (sole) fake monitor
|
||||||
|
//
|
||||||
|
static GLFWvidmode getVideoMode(void)
|
||||||
|
{
|
||||||
|
GLFWvidmode mode;
|
||||||
|
mode.width = 1920;
|
||||||
|
mode.height = 1080;
|
||||||
|
mode.redBits = 8;
|
||||||
|
mode.greenBits = 8;
|
||||||
|
mode.blueBits = 8;
|
||||||
|
mode.refreshRate = 60;
|
||||||
|
return mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
////// GLFW internal API //////
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void _glfwPollMonitorsNull(void)
|
||||||
|
{
|
||||||
|
const float dpi = 141.f;
|
||||||
|
const GLFWvidmode mode = getVideoMode();
|
||||||
|
_GLFWmonitor* monitor = _glfwAllocMonitor("Null SuperNoop 0",
|
||||||
|
(int) (mode.width * 25.4f / dpi),
|
||||||
|
(int) (mode.height * 25.4f / dpi));
|
||||||
|
_glfwInputMonitor(monitor, GLFW_CONNECTED, _GLFW_INSERT_FIRST);
|
||||||
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
////// GLFW platform API //////
|
////// GLFW platform API //////
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
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;
|
||||||
|
if (ypos)
|
||||||
|
*ypos = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformGetMonitorContentScale(_GLFWmonitor* monitor,
|
void _glfwGetMonitorContentScaleNull(_GLFWmonitor* monitor,
|
||||||
float* xscale, float* yscale)
|
float* xscale, float* yscale)
|
||||||
{
|
{
|
||||||
if (xscale)
|
if (xscale)
|
||||||
@ -51,27 +87,75 @@ void _glfwPlatformGetMonitorContentScale(_GLFWmonitor* monitor,
|
|||||||
*yscale = 1.f;
|
*yscale = 1.f;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformGetMonitorWorkarea(_GLFWmonitor* monitor,
|
void _glfwGetMonitorWorkareaNull(_GLFWmonitor* monitor,
|
||||||
int* xpos, int* ypos,
|
int* xpos, int* ypos,
|
||||||
int* width, int* height)
|
int* width, int* height)
|
||||||
{
|
{
|
||||||
|
const GLFWvidmode mode = getVideoMode();
|
||||||
|
|
||||||
|
if (xpos)
|
||||||
|
*xpos = 0;
|
||||||
|
if (ypos)
|
||||||
|
*ypos = 10;
|
||||||
|
if (width)
|
||||||
|
*width = mode.width;
|
||||||
|
if (height)
|
||||||
|
*height = mode.height - 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* found)
|
GLFWvidmode* _glfwGetVideoModesNull(_GLFWmonitor* monitor, int* found)
|
||||||
{
|
{
|
||||||
return NULL;
|
GLFWvidmode* mode = _glfw_calloc(1, sizeof(GLFWvidmode));
|
||||||
|
*mode = getVideoMode();
|
||||||
|
*found = 1;
|
||||||
|
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)
|
||||||
{
|
{
|
||||||
return GLFW_FALSE;
|
if (!monitor->null.ramp.size)
|
||||||
}
|
|
||||||
|
|
||||||
void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp)
|
|
||||||
{
|
{
|
||||||
|
unsigned int i;
|
||||||
|
|
||||||
|
_glfwAllocGammaArrays(&monitor->null.ramp, 256);
|
||||||
|
|
||||||
|
for (i = 0; i < monitor->null.ramp.size; i++)
|
||||||
|
{
|
||||||
|
const float gamma = 2.2f;
|
||||||
|
float value;
|
||||||
|
value = i / (float) (monitor->null.ramp.size - 1);
|
||||||
|
value = powf(value, 1.f / gamma) * 65535.f + 0.5f;
|
||||||
|
value = _glfw_fminf(value, 65535.f);
|
||||||
|
|
||||||
|
monitor->null.ramp.red[i] = (unsigned short) value;
|
||||||
|
monitor->null.ramp.green[i] = (unsigned short) value;
|
||||||
|
monitor->null.ramp.blue[i] = (unsigned short) value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_glfwAllocGammaArrays(ramp, monitor->null.ramp.size);
|
||||||
|
memcpy(ramp->red, monitor->null.ramp.red, sizeof(short) * ramp->size);
|
||||||
|
memcpy(ramp->green, monitor->null.ramp.green, sizeof(short) * ramp->size);
|
||||||
|
memcpy(ramp->blue, monitor->null.ramp.blue, sizeof(short) * ramp->size);
|
||||||
|
return GLFW_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void _glfwSetGammaRampNull(_GLFWmonitor* monitor, const GLFWgammaramp* ramp)
|
||||||
|
{
|
||||||
|
if (monitor->null.ramp.size != ramp->size)
|
||||||
|
{
|
||||||
|
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||||
|
"Null: Gamma ramp size must match current ramp size");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
memcpy(monitor->null.ramp.red, ramp->red, sizeof(short) * ramp->size);
|
||||||
|
memcpy(monitor->null.ramp.green, ramp->green, sizeof(short) * ramp->size);
|
||||||
|
memcpy(monitor->null.ramp.blue, ramp->blue, sizeof(short) * ramp->size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,38 +25,130 @@
|
|||||||
//
|
//
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
#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_NULL_CONTEXT_STATE
|
||||||
|
#define GLFW_NULL_CURSOR_STATE
|
||||||
|
#define GLFW_NULL_LIBRARY_CONTEXT_STATE
|
||||||
|
|
||||||
#define _GLFW_PLATFORM_CONTEXT_STATE struct { int dummyContext; }
|
|
||||||
#define _GLFW_PLATFORM_MONITOR_STATE struct { int dummyMonitor; }
|
|
||||||
#define _GLFW_PLATFORM_CURSOR_STATE struct { int dummyCursor; }
|
|
||||||
#define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE struct { int dummyLibraryWindow; }
|
|
||||||
#define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE struct { int dummyLibraryContext; }
|
|
||||||
#define _GLFW_EGL_CONTEXT_STATE struct { int dummyEGLContext; }
|
|
||||||
#define _GLFW_EGL_LIBRARY_CONTEXT_STATE struct { int dummyEGLLibraryContext; }
|
|
||||||
|
|
||||||
#include "osmesa_context.h"
|
|
||||||
#include "posix_time.h"
|
|
||||||
#include "posix_thread.h"
|
|
||||||
#include "null_joystick.h"
|
|
||||||
|
|
||||||
#if defined(_GLFW_WIN32)
|
|
||||||
#define _glfw_dlopen(name) LoadLibraryA(name)
|
|
||||||
#define _glfw_dlclose(handle) FreeLibrary((HMODULE) handle)
|
|
||||||
#define _glfw_dlsym(handle, name) GetProcAddress((HMODULE) handle, name)
|
|
||||||
#else
|
|
||||||
#define _glfw_dlopen(name) dlopen(name, RTLD_LAZY | RTLD_LOCAL)
|
|
||||||
#define _glfw_dlclose(handle) dlclose(handle)
|
|
||||||
#define _glfw_dlsym(handle, name) dlsym(handle, name)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Null-specific per-window data
|
// Null-specific per-window data
|
||||||
//
|
//
|
||||||
typedef struct _GLFWwindowNull
|
typedef struct _GLFWwindowNull
|
||||||
{
|
{
|
||||||
|
int xpos;
|
||||||
|
int ypos;
|
||||||
int width;
|
int width;
|
||||||
int height;
|
int height;
|
||||||
|
char* title;
|
||||||
|
GLFWbool visible;
|
||||||
|
GLFWbool iconified;
|
||||||
|
GLFWbool maximized;
|
||||||
|
GLFWbool resizable;
|
||||||
|
GLFWbool decorated;
|
||||||
|
GLFWbool titlebar;
|
||||||
|
GLFWbool floating;
|
||||||
|
GLFWbool transparent;
|
||||||
|
float opacity;
|
||||||
} _GLFWwindowNull;
|
} _GLFWwindowNull;
|
||||||
|
|
||||||
|
// Null-specific per-monitor data
|
||||||
|
//
|
||||||
|
typedef struct _GLFWmonitorNull
|
||||||
|
{
|
||||||
|
GLFWgammaramp ramp;
|
||||||
|
} _GLFWmonitorNull;
|
||||||
|
|
||||||
|
// Null-specific global data
|
||||||
|
//
|
||||||
|
typedef struct _GLFWlibraryNull
|
||||||
|
{
|
||||||
|
int xcursor;
|
||||||
|
int ycursor;
|
||||||
|
char* clipboardString;
|
||||||
|
_GLFWwindow* focusedWindow;
|
||||||
|
} _GLFWlibraryNull;
|
||||||
|
|
||||||
|
void _glfwPollMonitorsNull(void);
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
// Hazel
|
||||||
|
void _glfwSetWindowTitlebarNull(_GLFWwindow* window, GLFWbool enabled);
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
@ -29,12 +29,71 @@
|
|||||||
|
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
static void applySizeLimits(_GLFWwindow* window, int* width, int* height)
|
||||||
|
{
|
||||||
|
if (window->numer != GLFW_DONT_CARE && window->denom != GLFW_DONT_CARE)
|
||||||
|
{
|
||||||
|
const float ratio = (float) window->numer / (float) window->denom;
|
||||||
|
*height = (int) (*width / ratio);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (window->minwidth != GLFW_DONT_CARE && *width < window->minwidth)
|
||||||
|
*width = window->minwidth;
|
||||||
|
else if (window->maxwidth != GLFW_DONT_CARE && *width > window->maxwidth)
|
||||||
|
*width = window->maxwidth;
|
||||||
|
|
||||||
|
if (window->minheight != GLFW_DONT_CARE && *height < window->minheight)
|
||||||
|
*height = window->minheight;
|
||||||
|
else if (window->maxheight != GLFW_DONT_CARE && *height > window->maxheight)
|
||||||
|
*height = window->maxheight;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void fitToMonitor(_GLFWwindow* window)
|
||||||
|
{
|
||||||
|
GLFWvidmode mode;
|
||||||
|
_glfwGetVideoModeNull(window->monitor, &mode);
|
||||||
|
_glfwGetMonitorPosNull(window->monitor,
|
||||||
|
&window->null.xpos,
|
||||||
|
&window->null.ypos);
|
||||||
|
window->null.width = mode.width;
|
||||||
|
window->null.height = mode.height;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void acquireMonitor(_GLFWwindow* window)
|
||||||
|
{
|
||||||
|
_glfwInputMonitorWindow(window->monitor, window);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void releaseMonitor(_GLFWwindow* window)
|
||||||
|
{
|
||||||
|
if (window->monitor->window != window)
|
||||||
|
return;
|
||||||
|
|
||||||
|
_glfwInputMonitorWindow(window->monitor, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
static int createNativeWindow(_GLFWwindow* window,
|
static int createNativeWindow(_GLFWwindow* window,
|
||||||
const _GLFWwndconfig* wndconfig)
|
const _GLFWwndconfig* wndconfig,
|
||||||
|
const _GLFWfbconfig* fbconfig)
|
||||||
{
|
{
|
||||||
|
if (window->monitor)
|
||||||
|
fitToMonitor(window);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
window->null.xpos = 17;
|
||||||
|
window->null.ypos = 17;
|
||||||
window->null.width = wndconfig->width;
|
window->null.width = wndconfig->width;
|
||||||
window->null.height = wndconfig->height;
|
window->null.height = wndconfig->height;
|
||||||
|
}
|
||||||
|
|
||||||
|
window->null.visible = wndconfig->visible;
|
||||||
|
window->null.decorated = wndconfig->decorated;
|
||||||
|
window->null.maximized = wndconfig->maximized;
|
||||||
|
window->null.floating = wndconfig->floating;
|
||||||
|
window->null.transparent = fbconfig->transparent;
|
||||||
|
window->null.opacity = 1.f;
|
||||||
|
|
||||||
return GLFW_TRUE;
|
return GLFW_TRUE;
|
||||||
}
|
}
|
||||||
@ -44,12 +103,12 @@ static int createNativeWindow(_GLFWwindow* window,
|
|||||||
////// GLFW platform API //////
|
////// GLFW platform API //////
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
int _glfwPlatformCreateWindow(_GLFWwindow* window,
|
int _glfwCreateWindowNull(_GLFWwindow* window,
|
||||||
const _GLFWwndconfig* wndconfig,
|
const _GLFWwndconfig* wndconfig,
|
||||||
const _GLFWctxconfig* ctxconfig,
|
const _GLFWctxconfig* ctxconfig,
|
||||||
const _GLFWfbconfig* fbconfig)
|
const _GLFWfbconfig* fbconfig)
|
||||||
{
|
{
|
||||||
if (!createNativeWindow(window, wndconfig))
|
if (!createNativeWindow(window, wndconfig, fbconfig))
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
|
|
||||||
if (ctxconfig->client != GLFW_NO_API)
|
if (ctxconfig->client != GLFW_NO_API)
|
||||||
@ -62,48 +121,102 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
|
|||||||
if (!_glfwCreateContextOSMesa(window, ctxconfig, fbconfig))
|
if (!_glfwCreateContextOSMesa(window, ctxconfig, fbconfig))
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
}
|
}
|
||||||
else
|
else if (ctxconfig->source == GLFW_EGL_CONTEXT_API)
|
||||||
{
|
{
|
||||||
_glfwInputError(GLFW_API_UNAVAILABLE, "Null: EGL not available");
|
if (!_glfwInitEGL())
|
||||||
|
return GLFW_FALSE;
|
||||||
|
if (!_glfwCreateContextEGL(window, ctxconfig, fbconfig))
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (window->monitor)
|
||||||
|
{
|
||||||
|
_glfwShowWindowNull(window);
|
||||||
|
_glfwFocusWindowNull(window);
|
||||||
|
acquireMonitor(window);
|
||||||
|
}
|
||||||
|
|
||||||
return GLFW_TRUE;
|
return GLFW_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformDestroyWindow(_GLFWwindow* window)
|
void _glfwDestroyWindowNull(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
|
if (window->monitor)
|
||||||
|
releaseMonitor(window);
|
||||||
|
|
||||||
|
if (_glfw.null.focusedWindow == window)
|
||||||
|
_glfw.null.focusedWindow = NULL;
|
||||||
|
|
||||||
if (window->context.destroy)
|
if (window->context.destroy)
|
||||||
window->context.destroy(window);
|
window->context.destroy(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title)
|
void _glfwSetWindowTitleNull(_GLFWwindow* window, const char* title)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformSetWindowIcon(_GLFWwindow* window, int count,
|
void _glfwSetWindowIconNull(_GLFWwindow* window, int count, const GLFWimage* images)
|
||||||
const GLFWimage* images)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformSetWindowMonitor(_GLFWwindow* window,
|
void _glfwSetWindowMonitorNull(_GLFWwindow* window,
|
||||||
_GLFWmonitor* monitor,
|
_GLFWmonitor* monitor,
|
||||||
int xpos, int ypos,
|
int xpos, int ypos,
|
||||||
int width, int height,
|
int width, int height,
|
||||||
int refreshRate)
|
int refreshRate)
|
||||||
{
|
{
|
||||||
}
|
if (window->monitor == monitor)
|
||||||
|
|
||||||
void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos)
|
|
||||||
{
|
{
|
||||||
}
|
if (!monitor)
|
||||||
|
|
||||||
void _glfwPlatformSetWindowPos(_GLFWwindow* window, int xpos, int ypos)
|
|
||||||
{
|
{
|
||||||
|
_glfwSetWindowPosNull(window, xpos, ypos);
|
||||||
|
_glfwSetWindowSizeNull(window, width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformGetWindowSize(_GLFWwindow* window, int* width, int* height)
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (window->monitor)
|
||||||
|
releaseMonitor(window);
|
||||||
|
|
||||||
|
_glfwInputWindowMonitor(window, monitor);
|
||||||
|
|
||||||
|
if (window->monitor)
|
||||||
|
{
|
||||||
|
window->null.visible = GLFW_TRUE;
|
||||||
|
acquireMonitor(window);
|
||||||
|
fitToMonitor(window);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_glfwSetWindowPosNull(window, xpos, ypos);
|
||||||
|
_glfwSetWindowSizeNull(window, width, height);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _glfwGetWindowPosNull(_GLFWwindow* window, int* xpos, int* ypos)
|
||||||
|
{
|
||||||
|
if (xpos)
|
||||||
|
*xpos = window->null.xpos;
|
||||||
|
if (ypos)
|
||||||
|
*ypos = window->null.ypos;
|
||||||
|
}
|
||||||
|
|
||||||
|
void _glfwSetWindowPosNull(_GLFWwindow* window, int xpos, int ypos)
|
||||||
|
{
|
||||||
|
if (window->monitor)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (window->null.xpos != xpos || window->null.ypos != ypos)
|
||||||
|
{
|
||||||
|
window->null.xpos = xpos;
|
||||||
|
window->null.ypos = ypos;
|
||||||
|
_glfwInputWindowPos(window, xpos, ypos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _glfwGetWindowSizeNull(_GLFWwindow* window, int* width, int* height)
|
||||||
{
|
{
|
||||||
if (width)
|
if (width)
|
||||||
*width = window->null.width;
|
*width = window->null.width;
|
||||||
@ -111,23 +224,39 @@ void _glfwPlatformGetWindowSize(_GLFWwindow* window, int* width, int* height)
|
|||||||
*height = window->null.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;
|
||||||
|
|
||||||
|
if (window->null.width != width || window->null.height != height)
|
||||||
{
|
{
|
||||||
window->null.width = width;
|
window->null.width = width;
|
||||||
window->null.height = height;
|
window->null.height = height;
|
||||||
|
_glfwInputWindowSize(window, width, height);
|
||||||
|
_glfwInputFramebufferSize(window, width, height);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformSetWindowSizeLimits(_GLFWwindow* window,
|
void _glfwSetWindowSizeLimitsNull(_GLFWwindow* window,
|
||||||
int minwidth, int minheight,
|
int minwidth, int minheight,
|
||||||
int maxwidth, int maxheight)
|
int maxwidth, int maxheight)
|
||||||
{
|
{
|
||||||
|
int width = window->null.width;
|
||||||
|
int height = window->null.height;
|
||||||
|
applySizeLimits(window, &width, &height);
|
||||||
|
_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);
|
||||||
|
_glfwSetWindowSizeNull(window, width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformGetFramebufferSize(_GLFWwindow* window, int* width, int* height)
|
void _glfwGetFramebufferSizeNull(_GLFWwindow* window, int* width, int* height)
|
||||||
{
|
{
|
||||||
if (width)
|
if (width)
|
||||||
*width = window->null.width;
|
*width = window->null.width;
|
||||||
@ -135,14 +264,35 @@ void _glfwPlatformGetFramebufferSize(_GLFWwindow* window, int* width, int* heigh
|
|||||||
*height = window->null.height;
|
*height = window->null.height;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformGetWindowFrameSize(_GLFWwindow* window,
|
void _glfwGetWindowFrameSizeNull(_GLFWwindow* window,
|
||||||
int* left, int* top,
|
int* left, int* top,
|
||||||
int* right, int* bottom)
|
int* right, int* bottom)
|
||||||
{
|
{
|
||||||
|
if (window->null.decorated && !window->monitor)
|
||||||
|
{
|
||||||
|
if (left)
|
||||||
|
*left = 1;
|
||||||
|
if (top)
|
||||||
|
*top = 10;
|
||||||
|
if (right)
|
||||||
|
*right = 1;
|
||||||
|
if (bottom)
|
||||||
|
*bottom = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (left)
|
||||||
|
*left = 0;
|
||||||
|
if (top)
|
||||||
|
*top = 0;
|
||||||
|
if (right)
|
||||||
|
*right = 0;
|
||||||
|
if (bottom)
|
||||||
|
*bottom = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformGetWindowContentScale(_GLFWwindow* window,
|
void _glfwGetWindowContentScaleNull(_GLFWwindow* window, float* xscale, float* yscale)
|
||||||
float* xscale, float* yscale)
|
|
||||||
{
|
{
|
||||||
if (xscale)
|
if (xscale)
|
||||||
*xscale = 1.f;
|
*xscale = 1.f;
|
||||||
@ -150,187 +300,399 @@ void _glfwPlatformGetWindowContentScale(_GLFWwindow* window,
|
|||||||
*yscale = 1.f;
|
*yscale = 1.f;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformIconifyWindow(_GLFWwindow* window)
|
void _glfwIconifyWindowNull(_GLFWwindow* window)
|
||||||
|
{
|
||||||
|
if (_glfw.null.focusedWindow == window)
|
||||||
|
{
|
||||||
|
_glfw.null.focusedWindow = NULL;
|
||||||
|
_glfwInputWindowFocus(window, GLFW_FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!window->null.iconified)
|
||||||
|
{
|
||||||
|
window->null.iconified = GLFW_TRUE;
|
||||||
|
_glfwInputWindowIconify(window, GLFW_TRUE);
|
||||||
|
|
||||||
|
if (window->monitor)
|
||||||
|
releaseMonitor(window);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _glfwRestoreWindowNull(_GLFWwindow* window)
|
||||||
|
{
|
||||||
|
if (window->null.iconified)
|
||||||
|
{
|
||||||
|
window->null.iconified = GLFW_FALSE;
|
||||||
|
_glfwInputWindowIconify(window, GLFW_FALSE);
|
||||||
|
|
||||||
|
if (window->monitor)
|
||||||
|
acquireMonitor(window);
|
||||||
|
}
|
||||||
|
else if (window->null.maximized)
|
||||||
|
{
|
||||||
|
window->null.maximized = GLFW_FALSE;
|
||||||
|
_glfwInputWindowMaximize(window, GLFW_FALSE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _glfwMaximizeWindowNull(_GLFWwindow* window)
|
||||||
|
{
|
||||||
|
if (!window->null.maximized)
|
||||||
|
{
|
||||||
|
window->null.maximized = GLFW_TRUE;
|
||||||
|
_glfwInputWindowMaximize(window, GLFW_TRUE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int _glfwWindowMaximizedNull(_GLFWwindow* window)
|
||||||
|
{
|
||||||
|
return window->null.maximized;
|
||||||
|
}
|
||||||
|
|
||||||
|
int _glfwWindowHoveredNull(_GLFWwindow* window)
|
||||||
|
{
|
||||||
|
return _glfw.null.xcursor >= window->null.xpos &&
|
||||||
|
_glfw.null.ycursor >= window->null.ypos &&
|
||||||
|
_glfw.null.xcursor <= window->null.xpos + window->null.width - 1 &&
|
||||||
|
_glfw.null.ycursor <= window->null.ypos + window->null.height - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int _glfwFramebufferTransparentNull(_GLFWwindow* window)
|
||||||
|
{
|
||||||
|
return window->null.transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
void _glfwSetWindowResizableNull(_GLFWwindow* window, GLFWbool enabled)
|
||||||
|
{
|
||||||
|
window->null.resizable = enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
void _glfwSetWindowDecoratedNull(_GLFWwindow* window, GLFWbool enabled)
|
||||||
|
{
|
||||||
|
window->null.decorated = enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
void _glfwSetWindowTitlebarNull(_GLFWwindow* window, GLFWbool enabled)
|
||||||
|
{
|
||||||
|
window->null.titlebar = enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
void _glfwSetWindowFloatingNull(_GLFWwindow* window, GLFWbool enabled)
|
||||||
|
{
|
||||||
|
window->null.floating = enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
void _glfwSetWindowMousePassthroughNull(_GLFWwindow* window, GLFWbool enabled)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformRestoreWindow(_GLFWwindow* window)
|
float _glfwGetWindowOpacityNull(_GLFWwindow* window)
|
||||||
|
{
|
||||||
|
return window->null.opacity;
|
||||||
|
}
|
||||||
|
|
||||||
|
void _glfwSetWindowOpacityNull(_GLFWwindow* window, float opacity)
|
||||||
|
{
|
||||||
|
window->null.opacity = opacity;
|
||||||
|
}
|
||||||
|
|
||||||
|
void _glfwSetRawMouseMotionNull(_GLFWwindow *window, GLFWbool enabled)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformMaximizeWindow(_GLFWwindow* window)
|
GLFWbool _glfwRawMouseMotionSupportedNull(void)
|
||||||
|
{
|
||||||
|
return GLFW_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void _glfwShowWindowNull(_GLFWwindow* window)
|
||||||
|
{
|
||||||
|
window->null.visible = GLFW_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void _glfwRequestWindowAttentionNull(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
int _glfwPlatformWindowMaximized(_GLFWwindow* window)
|
void _glfwHideWindowNull(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
return GLFW_FALSE;
|
if (_glfw.null.focusedWindow == window)
|
||||||
|
{
|
||||||
|
_glfw.null.focusedWindow = NULL;
|
||||||
|
_glfwInputWindowFocus(window, GLFW_FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
int _glfwPlatformWindowHovered(_GLFWwindow* window)
|
window->null.visible = GLFW_FALSE;
|
||||||
{
|
|
||||||
return GLFW_FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int _glfwPlatformFramebufferTransparent(_GLFWwindow* window)
|
void _glfwFocusWindowNull(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
return GLFW_FALSE;
|
_GLFWwindow* previous;
|
||||||
|
|
||||||
|
if (_glfw.null.focusedWindow == window)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!window->null.visible)
|
||||||
|
return;
|
||||||
|
|
||||||
|
previous = _glfw.null.focusedWindow;
|
||||||
|
_glfw.null.focusedWindow = window;
|
||||||
|
|
||||||
|
if (previous)
|
||||||
|
{
|
||||||
|
_glfwInputWindowFocus(previous, GLFW_FALSE);
|
||||||
|
if (previous->monitor && previous->autoIconify)
|
||||||
|
_glfwIconifyWindowNull(previous);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformSetWindowResizable(_GLFWwindow* window, GLFWbool enabled)
|
_glfwInputWindowFocus(window, GLFW_TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
int _glfwWindowFocusedNull(_GLFWwindow* window)
|
||||||
|
{
|
||||||
|
return _glfw.null.focusedWindow == window;
|
||||||
|
}
|
||||||
|
|
||||||
|
int _glfwWindowIconifiedNull(_GLFWwindow* window)
|
||||||
|
{
|
||||||
|
return window->null.iconified;
|
||||||
|
}
|
||||||
|
|
||||||
|
int _glfwWindowVisibleNull(_GLFWwindow* window)
|
||||||
|
{
|
||||||
|
return window->null.visible;
|
||||||
|
}
|
||||||
|
|
||||||
|
void _glfwPollEventsNull(void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformSetWindowDecorated(_GLFWwindow* window, GLFWbool enabled)
|
void _glfwWaitEventsNull(void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformSetWindowTitlebar(_GLFWwindow* window, GLFWbool enabled)
|
void _glfwWaitEventsTimeoutNull(double timeout)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled)
|
void _glfwPostEmptyEventNull(void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
float _glfwPlatformGetWindowOpacity(_GLFWwindow* window)
|
void _glfwGetCursorPosNull(_GLFWwindow* window, double* xpos, double* ypos)
|
||||||
{
|
{
|
||||||
return 1.f;
|
if (xpos)
|
||||||
|
*xpos = _glfw.null.xcursor - window->null.xpos;
|
||||||
|
if (ypos)
|
||||||
|
*ypos = _glfw.null.ycursor - window->null.ypos;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformSetWindowOpacity(_GLFWwindow* window, float opacity)
|
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 _glfwSetCursorModeNull(_GLFWwindow* window, int mode)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformSetRawMouseMotion(_GLFWwindow *window, GLFWbool enabled)
|
int _glfwCreateCursorNull(_GLFWcursor* cursor,
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
GLFWbool _glfwPlatformRawMouseMotionSupported(void)
|
|
||||||
{
|
|
||||||
return GLFW_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
void _glfwPlatformShowWindow(_GLFWwindow* window)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void _glfwPlatformRequestWindowAttention(_GLFWwindow* window)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void _glfwPlatformUnhideWindow(_GLFWwindow* window)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void _glfwPlatformHideWindow(_GLFWwindow* window)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void _glfwPlatformFocusWindow(_GLFWwindow* window)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
int _glfwPlatformWindowFocused(_GLFWwindow* window)
|
|
||||||
{
|
|
||||||
return GLFW_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
int _glfwPlatformWindowIconified(_GLFWwindow* window)
|
|
||||||
{
|
|
||||||
return GLFW_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
int _glfwPlatformWindowVisible(_GLFWwindow* window)
|
|
||||||
{
|
|
||||||
return GLFW_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
void _glfwPlatformPollEvents(void)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void _glfwPlatformWaitEvents(void)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void _glfwPlatformWaitEventsTimeout(double timeout)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void _glfwPlatformPostEmptyEvent(void)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void _glfwPlatformGetCursorPos(_GLFWwindow* window, double* xpos, double* ypos)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void _glfwPlatformSetCursorPos(_GLFWwindow* window, double x, double y)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
int _glfwPlatformCreateCursor(_GLFWcursor* cursor,
|
|
||||||
const GLFWimage* image,
|
const GLFWimage* image,
|
||||||
int xhot, int yhot)
|
int xhot, int yhot)
|
||||||
{
|
{
|
||||||
return GLFW_TRUE;
|
return GLFW_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape)
|
int _glfwCreateStandardCursorNull(_GLFWcursor* cursor, int shape)
|
||||||
{
|
{
|
||||||
return GLFW_TRUE;
|
return GLFW_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformDestroyCursor(_GLFWcursor* cursor)
|
void _glfwDestroyCursorNull(_GLFWcursor* cursor)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor)
|
void _glfwSetCursorNull(_GLFWwindow* window, _GLFWcursor* cursor)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformSetClipboardString(const char* string)
|
void _glfwSetClipboardStringNull(const char* string)
|
||||||
{
|
{
|
||||||
|
char* copy = _glfw_strdup(string);
|
||||||
|
_glfw_free(_glfw.null.clipboardString);
|
||||||
|
_glfw.null.clipboardString = copy;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* _glfwPlatformGetClipboardString(void)
|
const char* _glfwGetClipboardStringNull(void)
|
||||||
{
|
{
|
||||||
|
return _glfw.null.clipboardString;
|
||||||
|
}
|
||||||
|
|
||||||
|
EGLenum _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)
|
||||||
|
{
|
||||||
|
_glfwInputError(GLFW_INVALID_VALUE, "Invalid scancode %i", scancode);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* _glfwPlatformGetScancodeName(int scancode)
|
switch (scancode)
|
||||||
{
|
{
|
||||||
return "";
|
case GLFW_KEY_APOSTROPHE:
|
||||||
|
return "'";
|
||||||
|
case GLFW_KEY_COMMA:
|
||||||
|
return ",";
|
||||||
|
case GLFW_KEY_MINUS:
|
||||||
|
case GLFW_KEY_KP_SUBTRACT:
|
||||||
|
return "-";
|
||||||
|
case GLFW_KEY_PERIOD:
|
||||||
|
case GLFW_KEY_KP_DECIMAL:
|
||||||
|
return ".";
|
||||||
|
case GLFW_KEY_SLASH:
|
||||||
|
case GLFW_KEY_KP_DIVIDE:
|
||||||
|
return "/";
|
||||||
|
case GLFW_KEY_SEMICOLON:
|
||||||
|
return ";";
|
||||||
|
case GLFW_KEY_EQUAL:
|
||||||
|
case GLFW_KEY_KP_EQUAL:
|
||||||
|
return "=";
|
||||||
|
case GLFW_KEY_LEFT_BRACKET:
|
||||||
|
return "[";
|
||||||
|
case GLFW_KEY_RIGHT_BRACKET:
|
||||||
|
return "]";
|
||||||
|
case GLFW_KEY_KP_MULTIPLY:
|
||||||
|
return "*";
|
||||||
|
case GLFW_KEY_KP_ADD:
|
||||||
|
return "+";
|
||||||
|
case GLFW_KEY_BACKSLASH:
|
||||||
|
case GLFW_KEY_WORLD_1:
|
||||||
|
case GLFW_KEY_WORLD_2:
|
||||||
|
return "\\";
|
||||||
|
case GLFW_KEY_0:
|
||||||
|
case GLFW_KEY_KP_0:
|
||||||
|
return "0";
|
||||||
|
case GLFW_KEY_1:
|
||||||
|
case GLFW_KEY_KP_1:
|
||||||
|
return "1";
|
||||||
|
case GLFW_KEY_2:
|
||||||
|
case GLFW_KEY_KP_2:
|
||||||
|
return "2";
|
||||||
|
case GLFW_KEY_3:
|
||||||
|
case GLFW_KEY_KP_3:
|
||||||
|
return "3";
|
||||||
|
case GLFW_KEY_4:
|
||||||
|
case GLFW_KEY_KP_4:
|
||||||
|
return "4";
|
||||||
|
case GLFW_KEY_5:
|
||||||
|
case GLFW_KEY_KP_5:
|
||||||
|
return "5";
|
||||||
|
case GLFW_KEY_6:
|
||||||
|
case GLFW_KEY_KP_6:
|
||||||
|
return "6";
|
||||||
|
case GLFW_KEY_7:
|
||||||
|
case GLFW_KEY_KP_7:
|
||||||
|
return "7";
|
||||||
|
case GLFW_KEY_8:
|
||||||
|
case GLFW_KEY_KP_8:
|
||||||
|
return "8";
|
||||||
|
case GLFW_KEY_9:
|
||||||
|
case GLFW_KEY_KP_9:
|
||||||
|
return "9";
|
||||||
|
case GLFW_KEY_A:
|
||||||
|
return "a";
|
||||||
|
case GLFW_KEY_B:
|
||||||
|
return "b";
|
||||||
|
case GLFW_KEY_C:
|
||||||
|
return "c";
|
||||||
|
case GLFW_KEY_D:
|
||||||
|
return "d";
|
||||||
|
case GLFW_KEY_E:
|
||||||
|
return "e";
|
||||||
|
case GLFW_KEY_F:
|
||||||
|
return "f";
|
||||||
|
case GLFW_KEY_G:
|
||||||
|
return "g";
|
||||||
|
case GLFW_KEY_H:
|
||||||
|
return "h";
|
||||||
|
case GLFW_KEY_I:
|
||||||
|
return "i";
|
||||||
|
case GLFW_KEY_J:
|
||||||
|
return "j";
|
||||||
|
case GLFW_KEY_K:
|
||||||
|
return "k";
|
||||||
|
case GLFW_KEY_L:
|
||||||
|
return "l";
|
||||||
|
case GLFW_KEY_M:
|
||||||
|
return "m";
|
||||||
|
case GLFW_KEY_N:
|
||||||
|
return "n";
|
||||||
|
case GLFW_KEY_O:
|
||||||
|
return "o";
|
||||||
|
case GLFW_KEY_P:
|
||||||
|
return "p";
|
||||||
|
case GLFW_KEY_Q:
|
||||||
|
return "q";
|
||||||
|
case GLFW_KEY_R:
|
||||||
|
return "r";
|
||||||
|
case GLFW_KEY_S:
|
||||||
|
return "s";
|
||||||
|
case GLFW_KEY_T:
|
||||||
|
return "t";
|
||||||
|
case GLFW_KEY_U:
|
||||||
|
return "u";
|
||||||
|
case GLFW_KEY_V:
|
||||||
|
return "v";
|
||||||
|
case GLFW_KEY_W:
|
||||||
|
return "w";
|
||||||
|
case GLFW_KEY_X:
|
||||||
|
return "x";
|
||||||
|
case GLFW_KEY_Y:
|
||||||
|
return "y";
|
||||||
|
case GLFW_KEY_Z:
|
||||||
|
return "z";
|
||||||
}
|
}
|
||||||
|
|
||||||
int _glfwPlatformGetKeyScancode(int key)
|
return NULL;
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformGetRequiredInstanceExtensions(char** extensions)
|
int _glfwGetKeyScancodeNull(int key)
|
||||||
|
{
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
|
||||||
|
void _glfwGetRequiredInstanceExtensionsNull(char** extensions)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
int _glfwPlatformGetPhysicalDevicePresentationSupport(VkInstance instance,
|
int _glfwGetPhysicalDevicePresentationSupportNull(VkInstance instance,
|
||||||
VkPhysicalDevice device,
|
VkPhysicalDevice device,
|
||||||
uint32_t queuefamily)
|
uint32_t queuefamily)
|
||||||
{
|
{
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
VkResult _glfwPlatformCreateWindowSurface(VkInstance instance,
|
VkResult _glfwCreateWindowSurfaceNull(VkInstance instance,
|
||||||
_GLFWwindow* window,
|
_GLFWwindow* window,
|
||||||
const VkAllocationCallbacks* allocator,
|
const VkAllocationCallbacks* allocator,
|
||||||
VkSurfaceKHR* surface)
|
VkSurfaceKHR* surface)
|
||||||
{
|
{
|
||||||
// This seems like the most appropriate error to return here
|
// This seems like the most appropriate error to return here
|
||||||
return VK_ERROR_INITIALIZATION_FAILED;
|
return VK_ERROR_EXTENSION_NOT_PRESENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,17 +39,17 @@ static void makeContextCurrentOSMesa(_GLFWwindow* window)
|
|||||||
if (window)
|
if (window)
|
||||||
{
|
{
|
||||||
int width, height;
|
int width, height;
|
||||||
_glfwPlatformGetFramebufferSize(window, &width, &height);
|
_glfw.platform.getFramebufferSize(window, &width, &height);
|
||||||
|
|
||||||
// Check to see if we need to allocate a new buffer
|
// Check to see if we need to allocate a new buffer
|
||||||
if ((window->context.osmesa.buffer == NULL) ||
|
if ((window->context.osmesa.buffer == NULL) ||
|
||||||
(width != window->context.osmesa.width) ||
|
(width != window->context.osmesa.width) ||
|
||||||
(height != window->context.osmesa.height))
|
(height != window->context.osmesa.height))
|
||||||
{
|
{
|
||||||
free(window->context.osmesa.buffer);
|
_glfw_free(window->context.osmesa.buffer);
|
||||||
|
|
||||||
// Allocate the new buffer (width * height * 8-bit RGBA)
|
// Allocate the new buffer (width * height * 8-bit RGBA)
|
||||||
window->context.osmesa.buffer = calloc(4, (size_t) width * height);
|
window->context.osmesa.buffer = _glfw_calloc(4, (size_t) width * height);
|
||||||
window->context.osmesa.width = width;
|
window->context.osmesa.width = width;
|
||||||
window->context.osmesa.height = height;
|
window->context.osmesa.height = height;
|
||||||
}
|
}
|
||||||
@ -83,7 +83,7 @@ static void destroyContextOSMesa(_GLFWwindow* window)
|
|||||||
|
|
||||||
if (window->context.osmesa.buffer)
|
if (window->context.osmesa.buffer)
|
||||||
{
|
{
|
||||||
free(window->context.osmesa.buffer);
|
_glfw_free(window->context.osmesa.buffer);
|
||||||
window->context.osmesa.width = 0;
|
window->context.osmesa.width = 0;
|
||||||
window->context.osmesa.height = 0;
|
window->context.osmesa.height = 0;
|
||||||
}
|
}
|
||||||
@ -124,6 +124,8 @@ GLFWbool _glfwInitOSMesa(void)
|
|||||||
"libOSMesa.8.dylib",
|
"libOSMesa.8.dylib",
|
||||||
#elif defined(__CYGWIN__)
|
#elif defined(__CYGWIN__)
|
||||||
"libOSMesa-8.so",
|
"libOSMesa-8.so",
|
||||||
|
#elif defined(__OpenBSD__)
|
||||||
|
"libOSMesa.so",
|
||||||
#else
|
#else
|
||||||
"libOSMesa.so.8",
|
"libOSMesa.so.8",
|
||||||
"libOSMesa.so.6",
|
"libOSMesa.so.6",
|
||||||
@ -136,7 +138,7 @@ GLFWbool _glfwInitOSMesa(void)
|
|||||||
|
|
||||||
for (i = 0; sonames[i]; i++)
|
for (i = 0; sonames[i]; i++)
|
||||||
{
|
{
|
||||||
_glfw.osmesa.handle = _glfw_dlopen(sonames[i]);
|
_glfw.osmesa.handle = _glfwPlatformLoadModule(sonames[i]);
|
||||||
if (_glfw.osmesa.handle)
|
if (_glfw.osmesa.handle)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -148,19 +150,19 @@ GLFWbool _glfwInitOSMesa(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
_glfw.osmesa.CreateContextExt = (PFN_OSMesaCreateContextExt)
|
_glfw.osmesa.CreateContextExt = (PFN_OSMesaCreateContextExt)
|
||||||
_glfw_dlsym(_glfw.osmesa.handle, "OSMesaCreateContextExt");
|
_glfwPlatformGetModuleSymbol(_glfw.osmesa.handle, "OSMesaCreateContextExt");
|
||||||
_glfw.osmesa.CreateContextAttribs = (PFN_OSMesaCreateContextAttribs)
|
_glfw.osmesa.CreateContextAttribs = (PFN_OSMesaCreateContextAttribs)
|
||||||
_glfw_dlsym(_glfw.osmesa.handle, "OSMesaCreateContextAttribs");
|
_glfwPlatformGetModuleSymbol(_glfw.osmesa.handle, "OSMesaCreateContextAttribs");
|
||||||
_glfw.osmesa.DestroyContext = (PFN_OSMesaDestroyContext)
|
_glfw.osmesa.DestroyContext = (PFN_OSMesaDestroyContext)
|
||||||
_glfw_dlsym(_glfw.osmesa.handle, "OSMesaDestroyContext");
|
_glfwPlatformGetModuleSymbol(_glfw.osmesa.handle, "OSMesaDestroyContext");
|
||||||
_glfw.osmesa.MakeCurrent = (PFN_OSMesaMakeCurrent)
|
_glfw.osmesa.MakeCurrent = (PFN_OSMesaMakeCurrent)
|
||||||
_glfw_dlsym(_glfw.osmesa.handle, "OSMesaMakeCurrent");
|
_glfwPlatformGetModuleSymbol(_glfw.osmesa.handle, "OSMesaMakeCurrent");
|
||||||
_glfw.osmesa.GetColorBuffer = (PFN_OSMesaGetColorBuffer)
|
_glfw.osmesa.GetColorBuffer = (PFN_OSMesaGetColorBuffer)
|
||||||
_glfw_dlsym(_glfw.osmesa.handle, "OSMesaGetColorBuffer");
|
_glfwPlatformGetModuleSymbol(_glfw.osmesa.handle, "OSMesaGetColorBuffer");
|
||||||
_glfw.osmesa.GetDepthBuffer = (PFN_OSMesaGetDepthBuffer)
|
_glfw.osmesa.GetDepthBuffer = (PFN_OSMesaGetDepthBuffer)
|
||||||
_glfw_dlsym(_glfw.osmesa.handle, "OSMesaGetDepthBuffer");
|
_glfwPlatformGetModuleSymbol(_glfw.osmesa.handle, "OSMesaGetDepthBuffer");
|
||||||
_glfw.osmesa.GetProcAddress = (PFN_OSMesaGetProcAddress)
|
_glfw.osmesa.GetProcAddress = (PFN_OSMesaGetProcAddress)
|
||||||
_glfw_dlsym(_glfw.osmesa.handle, "OSMesaGetProcAddress");
|
_glfwPlatformGetModuleSymbol(_glfw.osmesa.handle, "OSMesaGetProcAddress");
|
||||||
|
|
||||||
if (!_glfw.osmesa.CreateContextExt ||
|
if (!_glfw.osmesa.CreateContextExt ||
|
||||||
!_glfw.osmesa.DestroyContext ||
|
!_glfw.osmesa.DestroyContext ||
|
||||||
@ -183,7 +185,7 @@ void _glfwTerminateOSMesa(void)
|
|||||||
{
|
{
|
||||||
if (_glfw.osmesa.handle)
|
if (_glfw.osmesa.handle)
|
||||||
{
|
{
|
||||||
_glfw_dlclose(_glfw.osmesa.handle);
|
_glfwPlatformFreeModule(_glfw.osmesa.handle);
|
||||||
_glfw.osmesa.handle = NULL;
|
_glfw.osmesa.handle = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -302,6 +304,12 @@ GLFWAPI int glfwGetOSMesaColorBuffer(GLFWwindow* handle, int* width,
|
|||||||
|
|
||||||
_GLFW_REQUIRE_INIT_OR_RETURN(GLFW_FALSE);
|
_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,
|
if (!OSMesaGetColorBuffer(window->context.osmesa.handle,
|
||||||
&mesaWidth, &mesaHeight,
|
&mesaWidth, &mesaHeight,
|
||||||
&mesaFormat, &mesaBuffer))
|
&mesaFormat, &mesaBuffer))
|
||||||
@ -335,6 +343,12 @@ GLFWAPI int glfwGetOSMesaDepthBuffer(GLFWwindow* handle,
|
|||||||
|
|
||||||
_GLFW_REQUIRE_INIT_OR_RETURN(GLFW_FALSE);
|
_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,
|
if (!OSMesaGetDepthBuffer(window->context.osmesa.handle,
|
||||||
&mesaWidth, &mesaHeight,
|
&mesaWidth, &mesaHeight,
|
||||||
&mesaBytes, &mesaBuffer))
|
&mesaBytes, &mesaBuffer))
|
||||||
@ -361,7 +375,7 @@ GLFWAPI OSMesaContext glfwGetOSMesaContext(GLFWwindow* handle)
|
|||||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
_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);
|
_glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -1,94 +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
|
|
||||||
|
|
||||||
#define _GLFW_OSMESA_CONTEXT_STATE _GLFWcontextOSMesa osmesa
|
|
||||||
#define _GLFW_OSMESA_LIBRARY_CONTEXT_STATE _GLFWlibraryOSMesa osmesa
|
|
||||||
|
|
||||||
|
|
||||||
// OSMesa-specific per-context data
|
|
||||||
//
|
|
||||||
typedef struct _GLFWcontextOSMesa
|
|
||||||
{
|
|
||||||
OSMesaContext handle;
|
|
||||||
int width;
|
|
||||||
int height;
|
|
||||||
void* buffer;
|
|
||||||
|
|
||||||
} _GLFWcontextOSMesa;
|
|
||||||
|
|
||||||
// OSMesa-specific global data
|
|
||||||
//
|
|
||||||
typedef struct _GLFWlibraryOSMesa
|
|
||||||
{
|
|
||||||
void* handle;
|
|
||||||
|
|
||||||
PFN_OSMesaCreateContextExt CreateContextExt;
|
|
||||||
PFN_OSMesaCreateContextAttribs CreateContextAttribs;
|
|
||||||
PFN_OSMesaDestroyContext DestroyContext;
|
|
||||||
PFN_OSMesaMakeCurrent MakeCurrent;
|
|
||||||
PFN_OSMesaGetColorBuffer GetColorBuffer;
|
|
||||||
PFN_OSMesaGetDepthBuffer GetDepthBuffer;
|
|
||||||
PFN_OSMesaGetProcAddress GetProcAddress;
|
|
||||||
|
|
||||||
} _GLFWlibraryOSMesa;
|
|
||||||
|
|
||||||
|
|
||||||
GLFWbool _glfwInitOSMesa(void);
|
|
||||||
void _glfwTerminateOSMesa(void);
|
|
||||||
GLFWbool _glfwCreateContextOSMesa(_GLFWwindow* window,
|
|
||||||
const _GLFWctxconfig* ctxconfig,
|
|
||||||
const _GLFWfbconfig* fbconfig);
|
|
||||||
|
|
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
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
179
src/platform.h
Normal file
179
src/platform.h
Normal file
@ -0,0 +1,179 @@
|
|||||||
|
//========================================================================
|
||||||
|
// 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
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(_GLFW_COCOA)
|
||||||
|
#include "cocoa_platform.h"
|
||||||
|
#else
|
||||||
|
#define GLFW_COCOA_WINDOW_STATE
|
||||||
|
#define GLFW_COCOA_MONITOR_STATE
|
||||||
|
#define GLFW_COCOA_CURSOR_STATE
|
||||||
|
#define GLFW_COCOA_LIBRARY_WINDOW_STATE
|
||||||
|
#define GLFW_NSGL_CONTEXT_STATE
|
||||||
|
#define GLFW_NSGL_LIBRARY_CONTEXT_STATE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(_GLFW_WAYLAND)
|
||||||
|
#include "wl_platform.h"
|
||||||
|
#else
|
||||||
|
#define GLFW_WAYLAND_WINDOW_STATE
|
||||||
|
#define GLFW_WAYLAND_MONITOR_STATE
|
||||||
|
#define GLFW_WAYLAND_CURSOR_STATE
|
||||||
|
#define GLFW_WAYLAND_LIBRARY_WINDOW_STATE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(_GLFW_X11)
|
||||||
|
#include "x11_platform.h"
|
||||||
|
#else
|
||||||
|
#define GLFW_X11_WINDOW_STATE
|
||||||
|
#define GLFW_X11_MONITOR_STATE
|
||||||
|
#define GLFW_X11_CURSOR_STATE
|
||||||
|
#define GLFW_X11_LIBRARY_WINDOW_STATE
|
||||||
|
#define GLFW_GLX_CONTEXT_STATE
|
||||||
|
#define GLFW_GLX_LIBRARY_CONTEXT_STATE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "null_joystick.h"
|
||||||
|
|
||||||
|
#if defined(_GLFW_WIN32)
|
||||||
|
#include "win32_joystick.h"
|
||||||
|
#else
|
||||||
|
#define GLFW_WIN32_JOYSTICK_STATE
|
||||||
|
#define GLFW_WIN32_LIBRARY_JOYSTICK_STATE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(_GLFW_COCOA)
|
||||||
|
#include "cocoa_joystick.h"
|
||||||
|
#else
|
||||||
|
#define GLFW_COCOA_JOYSTICK_STATE
|
||||||
|
#define GLFW_COCOA_LIBRARY_JOYSTICK_STATE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if (defined(_GLFW_X11) || defined(_GLFW_WAYLAND)) && defined(__linux__)
|
||||||
|
#include "linux_joystick.h"
|
||||||
|
#else
|
||||||
|
#define GLFW_LINUX_JOYSTICK_STATE
|
||||||
|
#define GLFW_LINUX_LIBRARY_JOYSTICK_STATE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(_WIN32)
|
||||||
|
#include "win32_thread.h"
|
||||||
|
#define GLFW_POSIX_TLS_STATE
|
||||||
|
#define GLFW_POSIX_MUTEX_STATE
|
||||||
|
#else
|
||||||
|
#include "posix_thread.h"
|
||||||
|
#define GLFW_WIN32_TLS_STATE
|
||||||
|
#define GLFW_WIN32_MUTEX_STATE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(_WIN32)
|
||||||
|
#include "win32_time.h"
|
||||||
|
#define GLFW_POSIX_LIBRARY_TIMER_STATE
|
||||||
|
#define GLFW_COCOA_LIBRARY_TIMER_STATE
|
||||||
|
#elif defined(__APPLE__)
|
||||||
|
#include "cocoa_time.h"
|
||||||
|
#define GLFW_WIN32_LIBRARY_TIMER_STATE
|
||||||
|
#define GLFW_POSIX_LIBRARY_TIMER_STATE
|
||||||
|
#else
|
||||||
|
#include "posix_time.h"
|
||||||
|
#define GLFW_WIN32_LIBRARY_TIMER_STATE
|
||||||
|
#define GLFW_COCOA_LIBRARY_TIMER_STATE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define GLFW_PLATFORM_WINDOW_STATE \
|
||||||
|
GLFW_WIN32_WINDOW_STATE \
|
||||||
|
GLFW_COCOA_WINDOW_STATE \
|
||||||
|
GLFW_WAYLAND_WINDOW_STATE \
|
||||||
|
GLFW_X11_WINDOW_STATE \
|
||||||
|
GLFW_NULL_WINDOW_STATE \
|
||||||
|
|
||||||
|
#define GLFW_PLATFORM_MONITOR_STATE \
|
||||||
|
GLFW_WIN32_MONITOR_STATE \
|
||||||
|
GLFW_COCOA_MONITOR_STATE \
|
||||||
|
GLFW_WAYLAND_MONITOR_STATE \
|
||||||
|
GLFW_X11_MONITOR_STATE \
|
||||||
|
GLFW_NULL_MONITOR_STATE \
|
||||||
|
|
||||||
|
#define GLFW_PLATFORM_CURSOR_STATE \
|
||||||
|
GLFW_WIN32_CURSOR_STATE \
|
||||||
|
GLFW_COCOA_CURSOR_STATE \
|
||||||
|
GLFW_WAYLAND_CURSOR_STATE \
|
||||||
|
GLFW_X11_CURSOR_STATE \
|
||||||
|
GLFW_NULL_CURSOR_STATE \
|
||||||
|
|
||||||
|
#define GLFW_PLATFORM_JOYSTICK_STATE \
|
||||||
|
GLFW_WIN32_JOYSTICK_STATE \
|
||||||
|
GLFW_COCOA_JOYSTICK_STATE \
|
||||||
|
GLFW_LINUX_JOYSTICK_STATE
|
||||||
|
|
||||||
|
#define GLFW_PLATFORM_TLS_STATE \
|
||||||
|
GLFW_WIN32_TLS_STATE \
|
||||||
|
GLFW_POSIX_TLS_STATE \
|
||||||
|
|
||||||
|
#define GLFW_PLATFORM_MUTEX_STATE \
|
||||||
|
GLFW_WIN32_MUTEX_STATE \
|
||||||
|
GLFW_POSIX_MUTEX_STATE \
|
||||||
|
|
||||||
|
#define GLFW_PLATFORM_LIBRARY_WINDOW_STATE \
|
||||||
|
GLFW_WIN32_LIBRARY_WINDOW_STATE \
|
||||||
|
GLFW_COCOA_LIBRARY_WINDOW_STATE \
|
||||||
|
GLFW_WAYLAND_LIBRARY_WINDOW_STATE \
|
||||||
|
GLFW_X11_LIBRARY_WINDOW_STATE \
|
||||||
|
GLFW_NULL_LIBRARY_WINDOW_STATE \
|
||||||
|
|
||||||
|
#define GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE \
|
||||||
|
GLFW_WIN32_LIBRARY_JOYSTICK_STATE \
|
||||||
|
GLFW_COCOA_LIBRARY_JOYSTICK_STATE \
|
||||||
|
GLFW_LINUX_LIBRARY_JOYSTICK_STATE
|
||||||
|
|
||||||
|
#define GLFW_PLATFORM_LIBRARY_TIMER_STATE \
|
||||||
|
GLFW_WIN32_LIBRARY_TIMER_STATE \
|
||||||
|
GLFW_COCOA_LIBRARY_TIMER_STATE \
|
||||||
|
GLFW_POSIX_LIBRARY_TIMER_STATE \
|
||||||
|
|
||||||
|
#define GLFW_PLATFORM_CONTEXT_STATE \
|
||||||
|
GLFW_WGL_CONTEXT_STATE \
|
||||||
|
GLFW_NSGL_CONTEXT_STATE \
|
||||||
|
GLFW_GLX_CONTEXT_STATE
|
||||||
|
|
||||||
|
#define GLFW_PLATFORM_LIBRARY_CONTEXT_STATE \
|
||||||
|
GLFW_WGL_LIBRARY_CONTEXT_STATE \
|
||||||
|
GLFW_NSGL_LIBRARY_CONTEXT_STATE \
|
||||||
|
GLFW_GLX_LIBRARY_CONTEXT_STATE
|
||||||
|
|
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);
|
||||||
|
}
|
||||||
|
|
@ -27,8 +27,8 @@
|
|||||||
|
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
#define _GLFW_PLATFORM_TLS_STATE _GLFWtlsPOSIX posix
|
#define GLFW_POSIX_TLS_STATE _GLFWtlsPOSIX posix;
|
||||||
#define _GLFW_PLATFORM_MUTEX_STATE _GLFWmutexPOSIX posix
|
#define GLFW_POSIX_MUTEX_STATE _GLFWmutexPOSIX posix;
|
||||||
|
|
||||||
|
|
||||||
// POSIX-specific thread local storage data
|
// POSIX-specific thread local storage data
|
||||||
@ -37,7 +37,6 @@ typedef struct _GLFWtlsPOSIX
|
|||||||
{
|
{
|
||||||
GLFWbool allocated;
|
GLFWbool allocated;
|
||||||
pthread_key_t key;
|
pthread_key_t key;
|
||||||
|
|
||||||
} _GLFWtlsPOSIX;
|
} _GLFWtlsPOSIX;
|
||||||
|
|
||||||
// POSIX-specific mutex data
|
// POSIX-specific mutex data
|
||||||
@ -46,6 +45,5 @@ typedef struct _GLFWmutexPOSIX
|
|||||||
{
|
{
|
||||||
GLFWbool allocated;
|
GLFWbool allocated;
|
||||||
pthread_mutex_t handle;
|
pthread_mutex_t handle;
|
||||||
|
|
||||||
} _GLFWmutexPOSIX;
|
} _GLFWmutexPOSIX;
|
||||||
|
|
||||||
|
@ -27,60 +27,33 @@
|
|||||||
// It is fine to use C99 in this file because it will not be built with VS
|
// It is fine to use C99 in this file because it will not be built with VS
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
#define _POSIX_C_SOURCE 199309L
|
|
||||||
|
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <time.h>
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
////// GLFW internal API //////
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
// Initialise timer
|
|
||||||
//
|
|
||||||
void _glfwInitTimerPOSIX(void)
|
|
||||||
{
|
|
||||||
#if defined(_POSIX_TIMERS) && defined(_POSIX_MONOTONIC_CLOCK)
|
|
||||||
struct timespec ts;
|
|
||||||
|
|
||||||
if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0)
|
|
||||||
{
|
|
||||||
_glfw.timer.posix.monotonic = GLFW_TRUE;
|
|
||||||
_glfw.timer.posix.frequency = 1000000000;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
_glfw.timer.posix.monotonic = GLFW_FALSE;
|
|
||||||
_glfw.timer.posix.frequency = 1000000;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
////// GLFW platform API //////
|
////// GLFW platform API //////
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void _glfwPlatformInitTimer(void)
|
||||||
|
{
|
||||||
|
_glfw.timer.posix.clock = CLOCK_REALTIME;
|
||||||
|
_glfw.timer.posix.frequency = 1000000000;
|
||||||
|
|
||||||
|
#if defined(_POSIX_MONOTONIC_CLOCK)
|
||||||
|
struct timespec ts;
|
||||||
|
if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0)
|
||||||
|
_glfw.timer.posix.clock = CLOCK_MONOTONIC;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
uint64_t _glfwPlatformGetTimerValue(void)
|
uint64_t _glfwPlatformGetTimerValue(void)
|
||||||
{
|
|
||||||
#if defined(_POSIX_TIMERS) && defined(_POSIX_MONOTONIC_CLOCK)
|
|
||||||
if (_glfw.timer.posix.monotonic)
|
|
||||||
{
|
{
|
||||||
struct timespec ts;
|
struct timespec ts;
|
||||||
clock_gettime(CLOCK_MONOTONIC, &ts);
|
clock_gettime(_glfw.timer.posix.clock, &ts);
|
||||||
return (uint64_t) ts.tv_sec * (uint64_t) 1000000000 + (uint64_t) ts.tv_nsec;
|
return (uint64_t) ts.tv_sec * _glfw.timer.posix.frequency + (uint64_t) ts.tv_nsec;
|
||||||
}
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
struct timeval tv;
|
|
||||||
gettimeofday(&tv, NULL);
|
|
||||||
return (uint64_t) tv.tv_sec * (uint64_t) 1000000 + (uint64_t) tv.tv_usec;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t _glfwPlatformGetTimerFrequency(void)
|
uint64_t _glfwPlatformGetTimerFrequency(void)
|
||||||
|
@ -25,20 +25,17 @@
|
|||||||
//
|
//
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
#define _GLFW_PLATFORM_LIBRARY_TIMER_STATE _GLFWtimerPOSIX posix
|
#define GLFW_POSIX_LIBRARY_TIMER_STATE _GLFWtimerPOSIX posix;
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
|
|
||||||
// POSIX-specific global timer data
|
// POSIX-specific global timer data
|
||||||
//
|
//
|
||||||
typedef struct _GLFWtimerPOSIX
|
typedef struct _GLFWtimerPOSIX
|
||||||
{
|
{
|
||||||
GLFWbool monotonic;
|
clockid_t clock;
|
||||||
uint64_t frequency;
|
uint64_t frequency;
|
||||||
|
|
||||||
} _GLFWtimerPOSIX;
|
} _GLFWtimerPOSIX;
|
||||||
|
|
||||||
|
|
||||||
void _glfwInitTimerPOSIX(void);
|
|
||||||
|
|
||||||
|
62
src/vulkan.c
62
src/vulkan.c
@ -45,22 +45,28 @@ GLFWbool _glfwInitVulkan(int mode)
|
|||||||
{
|
{
|
||||||
VkResult err;
|
VkResult err;
|
||||||
VkExtensionProperties* ep;
|
VkExtensionProperties* ep;
|
||||||
|
PFN_vkEnumerateInstanceExtensionProperties vkEnumerateInstanceExtensionProperties;
|
||||||
uint32_t i, count;
|
uint32_t i, count;
|
||||||
|
|
||||||
if (_glfw.vk.available)
|
if (_glfw.vk.available)
|
||||||
return GLFW_TRUE;
|
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)
|
#if defined(_GLFW_VULKAN_LIBRARY)
|
||||||
_glfw.vk.handle = _glfw_dlopen(_GLFW_VULKAN_LIBRARY);
|
_glfw.vk.handle = _glfwPlatformLoadModule(_GLFW_VULKAN_LIBRARY);
|
||||||
#elif defined(_GLFW_WIN32)
|
#elif defined(_GLFW_WIN32)
|
||||||
_glfw.vk.handle = _glfw_dlopen("vulkan-1.dll");
|
_glfw.vk.handle = _glfwPlatformLoadModule("vulkan-1.dll");
|
||||||
#elif defined(_GLFW_COCOA)
|
#elif defined(_GLFW_COCOA)
|
||||||
_glfw.vk.handle = _glfw_dlopen("libvulkan.1.dylib");
|
_glfw.vk.handle = _glfwPlatformLoadModule("libvulkan.1.dylib");
|
||||||
if (!_glfw.vk.handle)
|
if (!_glfw.vk.handle)
|
||||||
_glfw.vk.handle = _glfwLoadLocalVulkanLoaderNS();
|
_glfw.vk.handle = _glfwLoadLocalVulkanLoaderCocoa();
|
||||||
|
#elif defined(__OpenBSD__)
|
||||||
|
_glfw.vk.handle = _glfwPlatformLoadModule("libvulkan.so");
|
||||||
#else
|
#else
|
||||||
_glfw.vk.handle = _glfw_dlopen("libvulkan.so.1");
|
_glfw.vk.handle = _glfwPlatformLoadModule("libvulkan.so.1");
|
||||||
#endif
|
#endif
|
||||||
if (!_glfw.vk.handle)
|
if (!_glfw.vk.handle)
|
||||||
{
|
{
|
||||||
@ -71,7 +77,7 @@ GLFWbool _glfwInitVulkan(int mode)
|
|||||||
}
|
}
|
||||||
|
|
||||||
_glfw.vk.GetInstanceProcAddr = (PFN_vkGetInstanceProcAddr)
|
_glfw.vk.GetInstanceProcAddr = (PFN_vkGetInstanceProcAddr)
|
||||||
_glfw_dlsym(_glfw.vk.handle, "vkGetInstanceProcAddr");
|
_glfwPlatformGetModuleSymbol(_glfw.vk.handle, "vkGetInstanceProcAddr");
|
||||||
if (!_glfw.vk.GetInstanceProcAddr)
|
if (!_glfw.vk.GetInstanceProcAddr)
|
||||||
{
|
{
|
||||||
_glfwInputError(GLFW_API_UNAVAILABLE,
|
_glfwInputError(GLFW_API_UNAVAILABLE,
|
||||||
@ -80,10 +86,11 @@ GLFWbool _glfwInitVulkan(int mode)
|
|||||||
_glfwTerminateVulkan();
|
_glfwTerminateVulkan();
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
_glfw.vk.EnumerateInstanceExtensionProperties = (PFN_vkEnumerateInstanceExtensionProperties)
|
vkEnumerateInstanceExtensionProperties = (PFN_vkEnumerateInstanceExtensionProperties)
|
||||||
vkGetInstanceProcAddr(NULL, "vkEnumerateInstanceExtensionProperties");
|
vkGetInstanceProcAddr(NULL, "vkEnumerateInstanceExtensionProperties");
|
||||||
if (!_glfw.vk.EnumerateInstanceExtensionProperties)
|
if (!vkEnumerateInstanceExtensionProperties)
|
||||||
{
|
{
|
||||||
_glfwInputError(GLFW_API_UNAVAILABLE,
|
_glfwInputError(GLFW_API_UNAVAILABLE,
|
||||||
"Vulkan: Failed to retrieve vkEnumerateInstanceExtensionProperties");
|
"Vulkan: Failed to retrieve vkEnumerateInstanceExtensionProperties");
|
||||||
@ -91,7 +98,6 @@ GLFWbool _glfwInitVulkan(int mode)
|
|||||||
_glfwTerminateVulkan();
|
_glfwTerminateVulkan();
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
}
|
}
|
||||||
#endif // _GLFW_VULKAN_STATIC
|
|
||||||
|
|
||||||
err = vkEnumerateInstanceExtensionProperties(NULL, &count, NULL);
|
err = vkEnumerateInstanceExtensionProperties(NULL, &count, NULL);
|
||||||
if (err)
|
if (err)
|
||||||
@ -108,7 +114,7 @@ GLFWbool _glfwInitVulkan(int mode)
|
|||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
ep = calloc(count, sizeof(VkExtensionProperties));
|
ep = _glfw_calloc(count, sizeof(VkExtensionProperties));
|
||||||
|
|
||||||
err = vkEnumerateInstanceExtensionProperties(NULL, &count, ep);
|
err = vkEnumerateInstanceExtensionProperties(NULL, &count, ep);
|
||||||
if (err)
|
if (err)
|
||||||
@ -117,7 +123,7 @@ GLFWbool _glfwInitVulkan(int mode)
|
|||||||
"Vulkan: Failed to query instance extensions: %s",
|
"Vulkan: Failed to query instance extensions: %s",
|
||||||
_glfwGetVulkanResultString(err));
|
_glfwGetVulkanResultString(err));
|
||||||
|
|
||||||
free(ep);
|
_glfw_free(ep);
|
||||||
_glfwTerminateVulkan();
|
_glfwTerminateVulkan();
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
}
|
}
|
||||||
@ -126,40 +132,33 @@ GLFWbool _glfwInitVulkan(int mode)
|
|||||||
{
|
{
|
||||||
if (strcmp(ep[i].extensionName, "VK_KHR_surface") == 0)
|
if (strcmp(ep[i].extensionName, "VK_KHR_surface") == 0)
|
||||||
_glfw.vk.KHR_surface = GLFW_TRUE;
|
_glfw.vk.KHR_surface = GLFW_TRUE;
|
||||||
#if defined(_GLFW_WIN32)
|
|
||||||
else if (strcmp(ep[i].extensionName, "VK_KHR_win32_surface") == 0)
|
else if (strcmp(ep[i].extensionName, "VK_KHR_win32_surface") == 0)
|
||||||
_glfw.vk.KHR_win32_surface = GLFW_TRUE;
|
_glfw.vk.KHR_win32_surface = GLFW_TRUE;
|
||||||
#elif defined(_GLFW_COCOA)
|
|
||||||
else if (strcmp(ep[i].extensionName, "VK_MVK_macos_surface") == 0)
|
else if (strcmp(ep[i].extensionName, "VK_MVK_macos_surface") == 0)
|
||||||
_glfw.vk.MVK_macos_surface = GLFW_TRUE;
|
_glfw.vk.MVK_macos_surface = GLFW_TRUE;
|
||||||
else if (strcmp(ep[i].extensionName, "VK_EXT_metal_surface") == 0)
|
else if (strcmp(ep[i].extensionName, "VK_EXT_metal_surface") == 0)
|
||||||
_glfw.vk.EXT_metal_surface = GLFW_TRUE;
|
_glfw.vk.EXT_metal_surface = GLFW_TRUE;
|
||||||
#elif defined(_GLFW_X11)
|
|
||||||
else if (strcmp(ep[i].extensionName, "VK_KHR_xlib_surface") == 0)
|
else if (strcmp(ep[i].extensionName, "VK_KHR_xlib_surface") == 0)
|
||||||
_glfw.vk.KHR_xlib_surface = GLFW_TRUE;
|
_glfw.vk.KHR_xlib_surface = GLFW_TRUE;
|
||||||
else if (strcmp(ep[i].extensionName, "VK_KHR_xcb_surface") == 0)
|
else if (strcmp(ep[i].extensionName, "VK_KHR_xcb_surface") == 0)
|
||||||
_glfw.vk.KHR_xcb_surface = GLFW_TRUE;
|
_glfw.vk.KHR_xcb_surface = GLFW_TRUE;
|
||||||
#elif defined(_GLFW_WAYLAND)
|
|
||||||
else if (strcmp(ep[i].extensionName, "VK_KHR_wayland_surface") == 0)
|
else if (strcmp(ep[i].extensionName, "VK_KHR_wayland_surface") == 0)
|
||||||
_glfw.vk.KHR_wayland_surface = GLFW_TRUE;
|
_glfw.vk.KHR_wayland_surface = GLFW_TRUE;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
free(ep);
|
_glfw_free(ep);
|
||||||
|
|
||||||
_glfw.vk.available = GLFW_TRUE;
|
_glfw.vk.available = GLFW_TRUE;
|
||||||
|
|
||||||
_glfwPlatformGetRequiredInstanceExtensions(_glfw.vk.extensions);
|
_glfw.platform.getRequiredInstanceExtensions(_glfw.vk.extensions);
|
||||||
|
|
||||||
return GLFW_TRUE;
|
return GLFW_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwTerminateVulkan(void)
|
void _glfwTerminateVulkan(void)
|
||||||
{
|
{
|
||||||
#if !defined(_GLFW_VULKAN_STATIC)
|
|
||||||
if (_glfw.vk.handle)
|
if (_glfw.vk.handle)
|
||||||
_glfw_dlclose(_glfw.vk.handle);
|
_glfwPlatformFreeModule(_glfw.vk.handle);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* _glfwGetVulkanResultString(VkResult result)
|
const char* _glfwGetVulkanResultString(VkResult result)
|
||||||
@ -257,17 +256,16 @@ GLFWAPI GLFWvkproc glfwGetInstanceProcAddress(VkInstance instance,
|
|||||||
if (!_glfwInitVulkan(_GLFW_REQUIRE_LOADER))
|
if (!_glfwInitVulkan(_GLFW_REQUIRE_LOADER))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
proc = (GLFWvkproc) vkGetInstanceProcAddr(instance, procname);
|
// NOTE: Vulkan 1.0 and 1.1 vkGetInstanceProcAddr cannot return itself
|
||||||
#if defined(_GLFW_VULKAN_STATIC)
|
|
||||||
if (!proc)
|
|
||||||
{
|
|
||||||
if (strcmp(procname, "vkGetInstanceProcAddr") == 0)
|
if (strcmp(procname, "vkGetInstanceProcAddr") == 0)
|
||||||
return (GLFWvkproc) vkGetInstanceProcAddr;
|
return (GLFWvkproc) vkGetInstanceProcAddr;
|
||||||
}
|
|
||||||
#else
|
proc = (GLFWvkproc) vkGetInstanceProcAddr(instance, procname);
|
||||||
if (!proc)
|
if (!proc)
|
||||||
proc = (GLFWvkproc) _glfw_dlsym(_glfw.vk.handle, procname);
|
{
|
||||||
#endif
|
if (_glfw.vk.handle)
|
||||||
|
proc = (GLFWvkproc) _glfwPlatformGetModuleSymbol(_glfw.vk.handle, procname);
|
||||||
|
}
|
||||||
|
|
||||||
return proc;
|
return proc;
|
||||||
}
|
}
|
||||||
@ -291,7 +289,7 @@ GLFWAPI int glfwGetPhysicalDevicePresentationSupport(VkInstance instance,
|
|||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return _glfwPlatformGetPhysicalDevicePresentationSupport(instance,
|
return _glfw.platform.getPhysicalDevicePresentationSupport(instance,
|
||||||
device,
|
device,
|
||||||
queuefamily);
|
queuefamily);
|
||||||
}
|
}
|
||||||
@ -327,6 +325,6 @@ GLFWAPI VkResult glfwCreateWindowSurface(VkInstance instance,
|
|||||||
return VK_ERROR_NATIVE_WINDOW_IN_USE_KHR;
|
return VK_ERROR_NATIVE_WINDOW_IN_USE_KHR;
|
||||||
}
|
}
|
||||||
|
|
||||||
return _glfwPlatformCreateWindowSurface(instance, window, allocator, surface);
|
return _glfw.platform.createWindowSurface(instance, window, allocator, surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,12 +30,11 @@
|
|||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <malloc.h>
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
// Return the value corresponding to the specified attribute
|
// Return the value corresponding to the specified attribute
|
||||||
//
|
//
|
||||||
static int findPixelFormatAttribValue(const int* attribs,
|
static int findPixelFormatAttribValueWGL(const int* attribs,
|
||||||
int attribCount,
|
int attribCount,
|
||||||
const int* values,
|
const int* values,
|
||||||
int attrib)
|
int attrib)
|
||||||
@ -59,11 +58,11 @@ static int findPixelFormatAttribValue(const int* attribs,
|
|||||||
attribs[attribCount++] = a; \
|
attribs[attribCount++] = a; \
|
||||||
}
|
}
|
||||||
#define findAttribValue(a) \
|
#define findAttribValue(a) \
|
||||||
findPixelFormatAttribValue(attribs, attribCount, values, a)
|
findPixelFormatAttribValueWGL(attribs, attribCount, values, a)
|
||||||
|
|
||||||
// Return a list of available and usable framebuffer configs
|
// Return a list of available and usable framebuffer configs
|
||||||
//
|
//
|
||||||
static int choosePixelFormat(_GLFWwindow* window,
|
static int choosePixelFormatWGL(_GLFWwindow* window,
|
||||||
const _GLFWctxconfig* ctxconfig,
|
const _GLFWctxconfig* ctxconfig,
|
||||||
const _GLFWfbconfig* fbconfig)
|
const _GLFWfbconfig* fbconfig)
|
||||||
{
|
{
|
||||||
@ -130,7 +129,7 @@ static int choosePixelFormat(_GLFWwindow* window,
|
|||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
usableConfigs = calloc(nativeCount, sizeof(_GLFWfbconfig));
|
usableConfigs = _glfw_calloc(nativeCount, sizeof(_GLFWfbconfig));
|
||||||
|
|
||||||
for (i = 0; i < nativeCount; i++)
|
for (i = 0; i < nativeCount; i++)
|
||||||
{
|
{
|
||||||
@ -149,7 +148,7 @@ static int choosePixelFormat(_GLFWwindow* window,
|
|||||||
_glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
|
_glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
|
||||||
"WGL: Failed to retrieve pixel format attributes");
|
"WGL: Failed to retrieve pixel format attributes");
|
||||||
|
|
||||||
free(usableConfigs);
|
_glfw_free(usableConfigs);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -165,6 +164,9 @@ static int choosePixelFormat(_GLFWwindow* window,
|
|||||||
if (findAttribValue(WGL_ACCELERATION_ARB) == WGL_NO_ACCELERATION_ARB)
|
if (findAttribValue(WGL_ACCELERATION_ARB) == WGL_NO_ACCELERATION_ARB)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if (findAttribValue(WGL_DOUBLE_BUFFER_ARB) != fbconfig->doublebuffer)
|
||||||
|
continue;
|
||||||
|
|
||||||
u->redBits = findAttribValue(WGL_RED_BITS_ARB);
|
u->redBits = findAttribValue(WGL_RED_BITS_ARB);
|
||||||
u->greenBits = findAttribValue(WGL_GREEN_BITS_ARB);
|
u->greenBits = findAttribValue(WGL_GREEN_BITS_ARB);
|
||||||
u->blueBits = findAttribValue(WGL_BLUE_BITS_ARB);
|
u->blueBits = findAttribValue(WGL_BLUE_BITS_ARB);
|
||||||
@ -182,8 +184,6 @@ static int choosePixelFormat(_GLFWwindow* window,
|
|||||||
|
|
||||||
if (findAttribValue(WGL_STEREO_ARB))
|
if (findAttribValue(WGL_STEREO_ARB))
|
||||||
u->stereo = GLFW_TRUE;
|
u->stereo = GLFW_TRUE;
|
||||||
if (findAttribValue(WGL_DOUBLE_BUFFER_ARB))
|
|
||||||
u->doublebuffer = GLFW_TRUE;
|
|
||||||
|
|
||||||
if (_glfw.wgl.ARB_multisample)
|
if (_glfw.wgl.ARB_multisample)
|
||||||
u->samples = findAttribValue(WGL_SAMPLES_ARB);
|
u->samples = findAttribValue(WGL_SAMPLES_ARB);
|
||||||
@ -220,7 +220,7 @@ static int choosePixelFormat(_GLFWwindow* window,
|
|||||||
_glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
|
_glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
|
||||||
"WGL: Failed to describe pixel format");
|
"WGL: Failed to describe pixel format");
|
||||||
|
|
||||||
free(usableConfigs);
|
_glfw_free(usableConfigs);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -239,6 +239,9 @@ static int choosePixelFormat(_GLFWwindow* window,
|
|||||||
if (pfd.iPixelType != PFD_TYPE_RGBA)
|
if (pfd.iPixelType != PFD_TYPE_RGBA)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if (!!(pfd.dwFlags & PFD_DOUBLEBUFFER) != fbconfig->doublebuffer)
|
||||||
|
continue;
|
||||||
|
|
||||||
u->redBits = pfd.cRedBits;
|
u->redBits = pfd.cRedBits;
|
||||||
u->greenBits = pfd.cGreenBits;
|
u->greenBits = pfd.cGreenBits;
|
||||||
u->blueBits = pfd.cBlueBits;
|
u->blueBits = pfd.cBlueBits;
|
||||||
@ -256,8 +259,6 @@ static int choosePixelFormat(_GLFWwindow* window,
|
|||||||
|
|
||||||
if (pfd.dwFlags & PFD_STEREO)
|
if (pfd.dwFlags & PFD_STEREO)
|
||||||
u->stereo = GLFW_TRUE;
|
u->stereo = GLFW_TRUE;
|
||||||
if (pfd.dwFlags & PFD_DOUBLEBUFFER)
|
|
||||||
u->doublebuffer = GLFW_TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
u->handle = pixelFormat;
|
u->handle = pixelFormat;
|
||||||
@ -269,7 +270,7 @@ static int choosePixelFormat(_GLFWwindow* window,
|
|||||||
_glfwInputError(GLFW_API_UNAVAILABLE,
|
_glfwInputError(GLFW_API_UNAVAILABLE,
|
||||||
"WGL: The driver does not appear to support OpenGL");
|
"WGL: The driver does not appear to support OpenGL");
|
||||||
|
|
||||||
free(usableConfigs);
|
_glfw_free(usableConfigs);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -279,12 +280,12 @@ static int choosePixelFormat(_GLFWwindow* window,
|
|||||||
_glfwInputError(GLFW_FORMAT_UNAVAILABLE,
|
_glfwInputError(GLFW_FORMAT_UNAVAILABLE,
|
||||||
"WGL: Failed to find a suitable pixel format");
|
"WGL: Failed to find a suitable pixel format");
|
||||||
|
|
||||||
free(usableConfigs);
|
_glfw_free(usableConfigs);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
pixelFormat = (int) closest->handle;
|
pixelFormat = (int) closest->handle;
|
||||||
free(usableConfigs);
|
_glfw_free(usableConfigs);
|
||||||
|
|
||||||
return pixelFormat;
|
return pixelFormat;
|
||||||
}
|
}
|
||||||
@ -321,14 +322,12 @@ static void swapBuffersWGL(_GLFWwindow* window)
|
|||||||
{
|
{
|
||||||
if (!window->monitor)
|
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 = FALSE;
|
||||||
BOOL enabled = IsWindows8OrGreater();
|
|
||||||
|
|
||||||
// HACK: Use DwmFlush when desktop composition is enabled
|
if (SUCCEEDED(DwmIsCompositionEnabled(&enabled)) && enabled)
|
||||||
if (enabled ||
|
|
||||||
(SUCCEEDED(DwmIsCompositionEnabled(&enabled)) && enabled))
|
|
||||||
{
|
{
|
||||||
int count = abs(window->context.wgl.interval);
|
int count = abs(window->context.wgl.interval);
|
||||||
while (count--)
|
while (count--)
|
||||||
@ -348,15 +347,13 @@ static void swapIntervalWGL(int interval)
|
|||||||
|
|
||||||
if (!window->monitor)
|
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 = FALSE;
|
||||||
BOOL enabled = IsWindows8OrGreater();
|
|
||||||
|
|
||||||
// HACK: Disable WGL swap interval when desktop composition is enabled to
|
if (SUCCEEDED(DwmIsCompositionEnabled(&enabled)) && enabled)
|
||||||
// avoid interfering with DWM vsync
|
|
||||||
if (enabled ||
|
|
||||||
(SUCCEEDED(DwmIsCompositionEnabled(&enabled)) && enabled))
|
|
||||||
interval = 0;
|
interval = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -386,7 +383,7 @@ static GLFWglproc getProcAddressWGL(const char* procname)
|
|||||||
if (proc)
|
if (proc)
|
||||||
return proc;
|
return proc;
|
||||||
|
|
||||||
return (GLFWglproc) GetProcAddress(_glfw.wgl.instance, procname);
|
return (GLFWglproc) _glfwPlatformGetModuleSymbol(_glfw.wgl.instance, procname);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void destroyContextWGL(_GLFWwindow* window)
|
static void destroyContextWGL(_GLFWwindow* window)
|
||||||
@ -398,11 +395,6 @@ static void destroyContextWGL(_GLFWwindow* window)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
////// GLFW internal API //////
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
// Initialize WGL
|
// Initialize WGL
|
||||||
//
|
//
|
||||||
GLFWbool _glfwInitWGL(void)
|
GLFWbool _glfwInitWGL(void)
|
||||||
@ -414,7 +406,7 @@ GLFWbool _glfwInitWGL(void)
|
|||||||
if (_glfw.wgl.instance)
|
if (_glfw.wgl.instance)
|
||||||
return GLFW_TRUE;
|
return GLFW_TRUE;
|
||||||
|
|
||||||
_glfw.wgl.instance = LoadLibraryA("opengl32.dll");
|
_glfw.wgl.instance = _glfwPlatformLoadModule("opengl32.dll");
|
||||||
if (!_glfw.wgl.instance)
|
if (!_glfw.wgl.instance)
|
||||||
{
|
{
|
||||||
_glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
|
_glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
|
||||||
@ -423,19 +415,19 @@ GLFWbool _glfwInitWGL(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
_glfw.wgl.CreateContext = (PFN_wglCreateContext)
|
_glfw.wgl.CreateContext = (PFN_wglCreateContext)
|
||||||
GetProcAddress(_glfw.wgl.instance, "wglCreateContext");
|
_glfwPlatformGetModuleSymbol(_glfw.wgl.instance, "wglCreateContext");
|
||||||
_glfw.wgl.DeleteContext = (PFN_wglDeleteContext)
|
_glfw.wgl.DeleteContext = (PFN_wglDeleteContext)
|
||||||
GetProcAddress(_glfw.wgl.instance, "wglDeleteContext");
|
_glfwPlatformGetModuleSymbol(_glfw.wgl.instance, "wglDeleteContext");
|
||||||
_glfw.wgl.GetProcAddress = (PFN_wglGetProcAddress)
|
_glfw.wgl.GetProcAddress = (PFN_wglGetProcAddress)
|
||||||
GetProcAddress(_glfw.wgl.instance, "wglGetProcAddress");
|
_glfwPlatformGetModuleSymbol(_glfw.wgl.instance, "wglGetProcAddress");
|
||||||
_glfw.wgl.GetCurrentDC = (PFN_wglGetCurrentDC)
|
_glfw.wgl.GetCurrentDC = (PFN_wglGetCurrentDC)
|
||||||
GetProcAddress(_glfw.wgl.instance, "wglGetCurrentDC");
|
_glfwPlatformGetModuleSymbol(_glfw.wgl.instance, "wglGetCurrentDC");
|
||||||
_glfw.wgl.GetCurrentContext = (PFN_wglGetCurrentContext)
|
_glfw.wgl.GetCurrentContext = (PFN_wglGetCurrentContext)
|
||||||
GetProcAddress(_glfw.wgl.instance, "wglGetCurrentContext");
|
_glfwPlatformGetModuleSymbol(_glfw.wgl.instance, "wglGetCurrentContext");
|
||||||
_glfw.wgl.MakeCurrent = (PFN_wglMakeCurrent)
|
_glfw.wgl.MakeCurrent = (PFN_wglMakeCurrent)
|
||||||
GetProcAddress(_glfw.wgl.instance, "wglMakeCurrent");
|
_glfwPlatformGetModuleSymbol(_glfw.wgl.instance, "wglMakeCurrent");
|
||||||
_glfw.wgl.ShareLists = (PFN_wglShareLists)
|
_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
|
// NOTE: A dummy context has to be created for opengl32.dll to load the
|
||||||
// OpenGL ICD, from which we can then query WGL extensions
|
// OpenGL ICD, from which we can then query WGL extensions
|
||||||
@ -528,7 +520,7 @@ GLFWbool _glfwInitWGL(void)
|
|||||||
void _glfwTerminateWGL(void)
|
void _glfwTerminateWGL(void)
|
||||||
{
|
{
|
||||||
if (_glfw.wgl.instance)
|
if (_glfw.wgl.instance)
|
||||||
FreeLibrary(_glfw.wgl.instance);
|
_glfwPlatformFreeModule(_glfw.wgl.instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define setAttrib(a, v) \
|
#define setAttrib(a, v) \
|
||||||
@ -560,7 +552,7 @@ GLFWbool _glfwCreateContextWGL(_GLFWwindow* window,
|
|||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
pixelFormat = choosePixelFormat(window, ctxconfig, fbconfig);
|
pixelFormat = choosePixelFormatWGL(window, ctxconfig, fbconfig);
|
||||||
if (!pixelFormat)
|
if (!pixelFormat)
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
|
|
||||||
@ -775,17 +767,19 @@ GLFWbool _glfwCreateContextWGL(_GLFWwindow* window,
|
|||||||
|
|
||||||
#undef setAttrib
|
#undef setAttrib
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
////// GLFW native API //////
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
GLFWAPI HGLRC glfwGetWGLContext(GLFWwindow* handle)
|
GLFWAPI HGLRC glfwGetWGLContext(GLFWwindow* handle)
|
||||||
{
|
{
|
||||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
_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);
|
_glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -1,160 +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
|
|
||||||
|
|
||||||
|
|
||||||
// WGL-specific per-context data
|
|
||||||
//
|
|
||||||
typedef struct _GLFWcontextWGL
|
|
||||||
{
|
|
||||||
HDC dc;
|
|
||||||
HGLRC handle;
|
|
||||||
int interval;
|
|
||||||
|
|
||||||
} _GLFWcontextWGL;
|
|
||||||
|
|
||||||
// WGL-specific global data
|
|
||||||
//
|
|
||||||
typedef struct _GLFWlibraryWGL
|
|
||||||
{
|
|
||||||
HINSTANCE instance;
|
|
||||||
PFN_wglCreateContext CreateContext;
|
|
||||||
PFN_wglDeleteContext DeleteContext;
|
|
||||||
PFN_wglGetProcAddress GetProcAddress;
|
|
||||||
PFN_wglGetCurrentDC GetCurrentDC;
|
|
||||||
PFN_wglGetCurrentContext GetCurrentContext;
|
|
||||||
PFN_wglMakeCurrent MakeCurrent;
|
|
||||||
PFN_wglShareLists ShareLists;
|
|
||||||
|
|
||||||
PFNWGLSWAPINTERVALEXTPROC SwapIntervalEXT;
|
|
||||||
PFNWGLGETPIXELFORMATATTRIBIVARBPROC GetPixelFormatAttribivARB;
|
|
||||||
PFNWGLGETEXTENSIONSSTRINGEXTPROC GetExtensionsStringEXT;
|
|
||||||
PFNWGLGETEXTENSIONSSTRINGARBPROC GetExtensionsStringARB;
|
|
||||||
PFNWGLCREATECONTEXTATTRIBSARBPROC CreateContextAttribsARB;
|
|
||||||
GLFWbool EXT_swap_control;
|
|
||||||
GLFWbool EXT_colorspace;
|
|
||||||
GLFWbool ARB_multisample;
|
|
||||||
GLFWbool ARB_framebuffer_sRGB;
|
|
||||||
GLFWbool EXT_framebuffer_sRGB;
|
|
||||||
GLFWbool ARB_pixel_format;
|
|
||||||
GLFWbool ARB_create_context;
|
|
||||||
GLFWbool ARB_create_context_profile;
|
|
||||||
GLFWbool EXT_create_context_es2_profile;
|
|
||||||
GLFWbool ARB_create_context_robustness;
|
|
||||||
GLFWbool ARB_create_context_no_error;
|
|
||||||
GLFWbool ARB_context_flush_control;
|
|
||||||
|
|
||||||
} _GLFWlibraryWGL;
|
|
||||||
|
|
||||||
|
|
||||||
GLFWbool _glfwInitWGL(void);
|
|
||||||
void _glfwTerminateWGL(void);
|
|
||||||
GLFWbool _glfwCreateContextWGL(_GLFWwindow* window,
|
|
||||||
const _GLFWctxconfig* ctxconfig,
|
|
||||||
const _GLFWfbconfig* fbconfig);
|
|
||||||
|
|
212
src/win32_init.c
212
src/win32_init.c
@ -30,7 +30,6 @@
|
|||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <malloc.h>
|
|
||||||
|
|
||||||
static const GUID _glfw_GUID_DEVINTERFACE_HID =
|
static const GUID _glfw_GUID_DEVINTERFACE_HID =
|
||||||
{0x4d1e55b2,0xf16f,0x11cf,{0x88,0xcb,0x00,0x11,0x11,0x00,0x00,0x30}};
|
{0x4d1e55b2,0xf16f,0x11cf,{0x88,0xcb,0x00,0x11,0x11,0x00,0x00,0x30}};
|
||||||
@ -39,6 +38,10 @@ static const GUID _glfw_GUID_DEVINTERFACE_HID =
|
|||||||
|
|
||||||
#if defined(_GLFW_USE_HYBRID_HPG) || defined(_GLFW_USE_OPTIMUS_HPG)
|
#if defined(_GLFW_USE_HYBRID_HPG) || defined(_GLFW_USE_OPTIMUS_HPG)
|
||||||
|
|
||||||
|
#if defined(_GLFW_BUILD_DLL)
|
||||||
|
#pragma message("These symbols must be exported by the executable and have no effect in a DLL")
|
||||||
|
#endif
|
||||||
|
|
||||||
// Executables (but not DLLs) exporting this symbol with this value will be
|
// Executables (but not DLLs) exporting this symbol with this value will be
|
||||||
// automatically directed to the high-performance GPU on Nvidia Optimus systems
|
// automatically directed to the high-performance GPU on Nvidia Optimus systems
|
||||||
// with up-to-date drivers
|
// with up-to-date drivers
|
||||||
@ -68,18 +71,7 @@ BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID reserved)
|
|||||||
//
|
//
|
||||||
static GLFWbool loadLibraries(void)
|
static GLFWbool loadLibraries(void)
|
||||||
{
|
{
|
||||||
_glfw.win32.winmm.instance = LoadLibraryA("winmm.dll");
|
_glfw.win32.user32.instance = _glfwPlatformLoadModule("user32.dll");
|
||||||
if (!_glfw.win32.winmm.instance)
|
|
||||||
{
|
|
||||||
_glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
|
|
||||||
"Win32: Failed to load winmm.dll");
|
|
||||||
return GLFW_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
_glfw.win32.winmm.GetTime = (PFN_timeGetTime)
|
|
||||||
GetProcAddress(_glfw.win32.winmm.instance, "timeGetTime");
|
|
||||||
|
|
||||||
_glfw.win32.user32.instance = LoadLibraryA("user32.dll");
|
|
||||||
if (!_glfw.win32.user32.instance)
|
if (!_glfw.win32.user32.instance)
|
||||||
{
|
{
|
||||||
_glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
|
_glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
|
||||||
@ -88,23 +80,23 @@ static GLFWbool loadLibraries(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
_glfw.win32.user32.SetProcessDPIAware_ = (PFN_SetProcessDPIAware)
|
_glfw.win32.user32.SetProcessDPIAware_ = (PFN_SetProcessDPIAware)
|
||||||
GetProcAddress(_glfw.win32.user32.instance, "SetProcessDPIAware");
|
_glfwPlatformGetModuleSymbol(_glfw.win32.user32.instance, "SetProcessDPIAware");
|
||||||
_glfw.win32.user32.ChangeWindowMessageFilterEx_ = (PFN_ChangeWindowMessageFilterEx)
|
_glfw.win32.user32.ChangeWindowMessageFilterEx_ = (PFN_ChangeWindowMessageFilterEx)
|
||||||
GetProcAddress(_glfw.win32.user32.instance, "ChangeWindowMessageFilterEx");
|
_glfwPlatformGetModuleSymbol(_glfw.win32.user32.instance, "ChangeWindowMessageFilterEx");
|
||||||
_glfw.win32.user32.EnableNonClientDpiScaling_ = (PFN_EnableNonClientDpiScaling)
|
_glfw.win32.user32.EnableNonClientDpiScaling_ = (PFN_EnableNonClientDpiScaling)
|
||||||
GetProcAddress(_glfw.win32.user32.instance, "EnableNonClientDpiScaling");
|
_glfwPlatformGetModuleSymbol(_glfw.win32.user32.instance, "EnableNonClientDpiScaling");
|
||||||
_glfw.win32.user32.SetProcessDpiAwarenessContext_ = (PFN_SetProcessDpiAwarenessContext)
|
_glfw.win32.user32.SetProcessDpiAwarenessContext_ = (PFN_SetProcessDpiAwarenessContext)
|
||||||
GetProcAddress(_glfw.win32.user32.instance, "SetProcessDpiAwarenessContext");
|
_glfwPlatformGetModuleSymbol(_glfw.win32.user32.instance, "SetProcessDpiAwarenessContext");
|
||||||
_glfw.win32.user32.GetDpiForWindow_ = (PFN_GetDpiForWindow)
|
_glfw.win32.user32.GetDpiForWindow_ = (PFN_GetDpiForWindow)
|
||||||
GetProcAddress(_glfw.win32.user32.instance, "GetDpiForWindow");
|
_glfwPlatformGetModuleSymbol(_glfw.win32.user32.instance, "GetDpiForWindow");
|
||||||
_glfw.win32.user32.AdjustWindowRectExForDpi_ = (PFN_AdjustWindowRectExForDpi)
|
_glfw.win32.user32.AdjustWindowRectExForDpi_ = (PFN_AdjustWindowRectExForDpi)
|
||||||
GetProcAddress(_glfw.win32.user32.instance, "AdjustWindowRectExForDpi");
|
_glfwPlatformGetModuleSymbol(_glfw.win32.user32.instance, "AdjustWindowRectExForDpi");
|
||||||
|
|
||||||
_glfw.win32.dinput8.instance = LoadLibraryA("dinput8.dll");
|
_glfw.win32.dinput8.instance = _glfwPlatformLoadModule("dinput8.dll");
|
||||||
if (_glfw.win32.dinput8.instance)
|
if (_glfw.win32.dinput8.instance)
|
||||||
{
|
{
|
||||||
_glfw.win32.dinput8.Create = (PFN_DirectInput8Create)
|
_glfw.win32.dinput8.Create = (PFN_DirectInput8Create)
|
||||||
GetProcAddress(_glfw.win32.dinput8.instance, "DirectInput8Create");
|
_glfwPlatformGetModuleSymbol(_glfw.win32.dinput8.instance, "DirectInput8Create");
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -121,44 +113,46 @@ static GLFWbool loadLibraries(void)
|
|||||||
|
|
||||||
for (i = 0; names[i]; i++)
|
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)
|
if (_glfw.win32.xinput.instance)
|
||||||
{
|
{
|
||||||
_glfw.win32.xinput.GetCapabilities = (PFN_XInputGetCapabilities)
|
_glfw.win32.xinput.GetCapabilities = (PFN_XInputGetCapabilities)
|
||||||
GetProcAddress(_glfw.win32.xinput.instance, "XInputGetCapabilities");
|
_glfwPlatformGetModuleSymbol(_glfw.win32.xinput.instance, "XInputGetCapabilities");
|
||||||
_glfw.win32.xinput.GetState = (PFN_XInputGetState)
|
_glfw.win32.xinput.GetState = (PFN_XInputGetState)
|
||||||
GetProcAddress(_glfw.win32.xinput.instance, "XInputGetState");
|
_glfwPlatformGetModuleSymbol(_glfw.win32.xinput.instance, "XInputGetState");
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_glfw.win32.dwmapi.instance = LoadLibraryA("dwmapi.dll");
|
_glfw.win32.dwmapi.instance = _glfwPlatformLoadModule("dwmapi.dll");
|
||||||
if (_glfw.win32.dwmapi.instance)
|
if (_glfw.win32.dwmapi.instance)
|
||||||
{
|
{
|
||||||
_glfw.win32.dwmapi.IsCompositionEnabled = (PFN_DwmIsCompositionEnabled)
|
_glfw.win32.dwmapi.IsCompositionEnabled = (PFN_DwmIsCompositionEnabled)
|
||||||
GetProcAddress(_glfw.win32.dwmapi.instance, "DwmIsCompositionEnabled");
|
_glfwPlatformGetModuleSymbol(_glfw.win32.dwmapi.instance, "DwmIsCompositionEnabled");
|
||||||
_glfw.win32.dwmapi.Flush = (PFN_DwmFlush)
|
_glfw.win32.dwmapi.Flush = (PFN_DwmFlush)
|
||||||
GetProcAddress(_glfw.win32.dwmapi.instance, "DwmFlush");
|
_glfwPlatformGetModuleSymbol(_glfw.win32.dwmapi.instance, "DwmFlush");
|
||||||
_glfw.win32.dwmapi.EnableBlurBehindWindow = (PFN_DwmEnableBlurBehindWindow)
|
_glfw.win32.dwmapi.EnableBlurBehindWindow = (PFN_DwmEnableBlurBehindWindow)
|
||||||
GetProcAddress(_glfw.win32.dwmapi.instance, "DwmEnableBlurBehindWindow");
|
_glfwPlatformGetModuleSymbol(_glfw.win32.dwmapi.instance, "DwmEnableBlurBehindWindow");
|
||||||
|
_glfw.win32.dwmapi.GetColorizationColor = (PFN_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)
|
if (_glfw.win32.shcore.instance)
|
||||||
{
|
{
|
||||||
_glfw.win32.shcore.SetProcessDpiAwareness_ = (PFN_SetProcessDpiAwareness)
|
_glfw.win32.shcore.SetProcessDpiAwareness_ = (PFN_SetProcessDpiAwareness)
|
||||||
GetProcAddress(_glfw.win32.shcore.instance, "SetProcessDpiAwareness");
|
_glfwPlatformGetModuleSymbol(_glfw.win32.shcore.instance, "SetProcessDpiAwareness");
|
||||||
_glfw.win32.shcore.GetDpiForMonitor_ = (PFN_GetDpiForMonitor)
|
_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)
|
if (_glfw.win32.ntdll.instance)
|
||||||
{
|
{
|
||||||
_glfw.win32.ntdll.RtlVerifyVersionInfo_ = (PFN_RtlVerifyVersionInfo)
|
_glfw.win32.ntdll.RtlVerifyVersionInfo_ = (PFN_RtlVerifyVersionInfo)
|
||||||
GetProcAddress(_glfw.win32.ntdll.instance, "RtlVerifyVersionInfo");
|
_glfwPlatformGetModuleSymbol(_glfw.win32.ntdll.instance, "RtlVerifyVersionInfo");
|
||||||
}
|
}
|
||||||
|
|
||||||
return GLFW_TRUE;
|
return GLFW_TRUE;
|
||||||
@ -169,25 +163,22 @@ static GLFWbool loadLibraries(void)
|
|||||||
static void freeLibraries(void)
|
static void freeLibraries(void)
|
||||||
{
|
{
|
||||||
if (_glfw.win32.xinput.instance)
|
if (_glfw.win32.xinput.instance)
|
||||||
FreeLibrary(_glfw.win32.xinput.instance);
|
_glfwPlatformFreeModule(_glfw.win32.xinput.instance);
|
||||||
|
|
||||||
if (_glfw.win32.dinput8.instance)
|
if (_glfw.win32.dinput8.instance)
|
||||||
FreeLibrary(_glfw.win32.dinput8.instance);
|
_glfwPlatformFreeModule(_glfw.win32.dinput8.instance);
|
||||||
|
|
||||||
if (_glfw.win32.winmm.instance)
|
|
||||||
FreeLibrary(_glfw.win32.winmm.instance);
|
|
||||||
|
|
||||||
if (_glfw.win32.user32.instance)
|
if (_glfw.win32.user32.instance)
|
||||||
FreeLibrary(_glfw.win32.user32.instance);
|
_glfwPlatformFreeModule(_glfw.win32.user32.instance);
|
||||||
|
|
||||||
if (_glfw.win32.dwmapi.instance)
|
if (_glfw.win32.dwmapi.instance)
|
||||||
FreeLibrary(_glfw.win32.dwmapi.instance);
|
_glfwPlatformFreeModule(_glfw.win32.dwmapi.instance);
|
||||||
|
|
||||||
if (_glfw.win32.shcore.instance)
|
if (_glfw.win32.shcore.instance)
|
||||||
FreeLibrary(_glfw.win32.shcore.instance);
|
_glfwPlatformFreeModule(_glfw.win32.shcore.instance);
|
||||||
|
|
||||||
if (_glfw.win32.ntdll.instance)
|
if (_glfw.win32.ntdll.instance)
|
||||||
FreeLibrary(_glfw.win32.ntdll.instance);
|
_glfwPlatformFreeModule(_glfw.win32.ntdll.instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create key code translation tables
|
// Create key code translation tables
|
||||||
@ -399,13 +390,13 @@ WCHAR* _glfwCreateWideStringFromUTF8Win32(const char* source)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
target = calloc(count, sizeof(WCHAR));
|
target = _glfw_calloc(count, sizeof(WCHAR));
|
||||||
|
|
||||||
if (!MultiByteToWideChar(CP_UTF8, 0, source, -1, target, count))
|
if (!MultiByteToWideChar(CP_UTF8, 0, source, -1, target, count))
|
||||||
{
|
{
|
||||||
_glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
|
_glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
|
||||||
"Win32: Failed to convert string from UTF-8");
|
"Win32: Failed to convert string from UTF-8");
|
||||||
free(target);
|
_glfw_free(target);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -427,13 +418,13 @@ char* _glfwCreateUTF8FromWideStringWin32(const WCHAR* source)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
target = calloc(size, 1);
|
target = _glfw_calloc(size, 1);
|
||||||
|
|
||||||
if (!WideCharToMultiByte(CP_UTF8, 0, source, -1, target, size, NULL, NULL))
|
if (!WideCharToMultiByte(CP_UTF8, 0, source, -1, target, size, NULL, NULL))
|
||||||
{
|
{
|
||||||
_glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
|
_glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
|
||||||
"Win32: Failed to convert string to UTF-8");
|
"Win32: Failed to convert string to UTF-8");
|
||||||
free(target);
|
_glfw_free(target);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -545,21 +536,91 @@ BOOL _glfwIsWindows10BuildOrGreaterWin32(WORD build)
|
|||||||
return RtlVerifyVersionInfo(&osvi, mask, cond) == 0;
|
return RtlVerifyVersionInfo(&osvi, mask, cond) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GLFWbool _glfwConnectWin32(int platformID, _GLFWplatform* platform)
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
////// GLFW platform API //////
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
int _glfwPlatformInit(void)
|
|
||||||
{
|
{
|
||||||
// To make SetForegroundWindow work as we want, we need to fiddle
|
const _GLFWplatform win32 =
|
||||||
// with the FOREGROUNDLOCKTIMEOUT system setting (we do this as early
|
{
|
||||||
// as possible in the hope of still being the foreground process)
|
GLFW_PLATFORM_WIN32,
|
||||||
SystemParametersInfoW(SPI_GETFOREGROUNDLOCKTIMEOUT, 0,
|
_glfwInitWin32,
|
||||||
&_glfw.win32.foregroundLockTimeout, 0);
|
_glfwTerminateWin32,
|
||||||
SystemParametersInfoW(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, UIntToPtr(0),
|
_glfwGetCursorPosWin32,
|
||||||
SPIF_SENDCHANGE);
|
_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,
|
||||||
|
_glfwSetWindowTitlebarWin32,
|
||||||
|
_glfwGetEGLPlatformWin32,
|
||||||
|
_glfwGetEGLNativeDisplayWin32,
|
||||||
|
_glfwGetEGLNativeWindowWin32,
|
||||||
|
_glfwGetRequiredInstanceExtensionsWin32,
|
||||||
|
_glfwGetPhysicalDevicePresentationSupportWin32,
|
||||||
|
_glfwCreateWindowSurfaceWin32,
|
||||||
|
};
|
||||||
|
|
||||||
|
*platform = win32;
|
||||||
|
return GLFW_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
int _glfwInitWin32(void)
|
||||||
|
{
|
||||||
if (!loadLibraries())
|
if (!loadLibraries())
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
|
|
||||||
@ -579,14 +640,11 @@ int _glfwPlatformInit(void)
|
|||||||
if (!createHelperWindow())
|
if (!createHelperWindow())
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
|
|
||||||
_glfwInitTimerWin32();
|
|
||||||
_glfwInitJoysticksWin32();
|
|
||||||
|
|
||||||
_glfwPollMonitorsWin32();
|
_glfwPollMonitorsWin32();
|
||||||
return GLFW_TRUE;
|
return GLFW_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformTerminate(void)
|
void _glfwTerminateWin32(void)
|
||||||
{
|
{
|
||||||
if (_glfw.win32.deviceNotificationHandle)
|
if (_glfw.win32.deviceNotificationHandle)
|
||||||
UnregisterDeviceNotification(_glfw.win32.deviceNotificationHandle);
|
UnregisterDeviceNotification(_glfw.win32.deviceNotificationHandle);
|
||||||
@ -596,36 +654,12 @@ void _glfwPlatformTerminate(void)
|
|||||||
|
|
||||||
_glfwUnregisterWindowClassWin32();
|
_glfwUnregisterWindowClassWin32();
|
||||||
|
|
||||||
// Restore previous foreground lock timeout system setting
|
_glfw_free(_glfw.win32.clipboardString);
|
||||||
SystemParametersInfoW(SPI_SETFOREGROUNDLOCKTIMEOUT, 0,
|
_glfw_free(_glfw.win32.rawInput);
|
||||||
UIntToPtr(_glfw.win32.foregroundLockTimeout),
|
|
||||||
SPIF_SENDCHANGE);
|
|
||||||
|
|
||||||
free(_glfw.win32.clipboardString);
|
|
||||||
free(_glfw.win32.rawInput);
|
|
||||||
|
|
||||||
_glfwTerminateWGL();
|
_glfwTerminateWGL();
|
||||||
_glfwTerminateEGL();
|
_glfwTerminateEGL();
|
||||||
|
|
||||||
_glfwTerminateJoysticksWin32();
|
|
||||||
|
|
||||||
freeLibraries();
|
freeLibraries();
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* _glfwPlatformGetVersionString(void)
|
|
||||||
{
|
|
||||||
return _GLFW_VERSION_NUMBER " Win32 WGL EGL OSMesa"
|
|
||||||
#if 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
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user