mirror of
https://github.com/gwm17/glfw.git
synced 2024-11-22 18:28:52 -05:00
Merge branch 'glfw:master' into master
This commit is contained in:
commit
441c15250f
0
docs/CODEOWNERS → .github/CODEOWNERS
vendored
0
docs/CODEOWNERS → .github/CODEOWNERS
vendored
41
.github/workflows/build.yml
vendored
41
.github/workflows/build.yml
vendored
|
@ -31,8 +31,8 @@ jobs:
|
||||||
- name: Build shared library
|
- name: Build shared library
|
||||||
run: cmake --build build-shared --parallel
|
run: cmake --build build-shared --parallel
|
||||||
|
|
||||||
build-linux-wayland-clang:
|
build-linux-full-clang:
|
||||||
name: Wayland (Linux, Clang)
|
name: X11+Wayland (Linux, Clang)
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
env:
|
env:
|
||||||
CC: clang
|
CC: clang
|
||||||
|
@ -42,38 +42,15 @@ jobs:
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
sudo apt update
|
sudo apt update
|
||||||
sudo apt install wayland-protocols libwayland-dev libxkbcommon-dev
|
sudo apt install libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev libxext-dev wayland-protocols libwayland-dev libxkbcommon-dev
|
||||||
|
|
||||||
- name: Configure static library
|
- name: Configure static library
|
||||||
run: cmake -S . -B build-static -D GLFW_USE_WAYLAND=ON
|
run: cmake -S . -B build-static -D GLFW_BUILD_WAYLAND=ON
|
||||||
- name: Build static library
|
- name: Build static library
|
||||||
run: cmake --build build-static --parallel
|
run: cmake --build build-static --parallel
|
||||||
|
|
||||||
- name: Configure shared library
|
- name: Configure shared library
|
||||||
run: cmake -S . -B build-shared -D GLFW_USE_WAYLAND=ON -D BUILD_SHARED_LIBS=ON
|
run: cmake -S . -B build-shared -D GLFW_BUILD_WAYLAND=ON -D BUILD_SHARED_LIBS=ON
|
||||||
- name: Build shared library
|
|
||||||
run: cmake --build build-shared --parallel
|
|
||||||
|
|
||||||
build-linux-null-clang:
|
|
||||||
name: Null (Linux, Clang)
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
env:
|
|
||||||
CC: clang
|
|
||||||
CFLAGS: -Werror
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
- name: Install dependencies
|
|
||||||
run: |
|
|
||||||
sudo apt update
|
|
||||||
sudo apt install libosmesa6-dev
|
|
||||||
|
|
||||||
- name: Configure static library
|
|
||||||
run: cmake -S . -B build-static -D GLFW_USE_OSMESA=ON
|
|
||||||
- name: Build static library
|
|
||||||
run: cmake --build build-static --parallel
|
|
||||||
|
|
||||||
- name: Configure shared library
|
|
||||||
run: cmake -S . -B build-shared -D GLFW_USE_OSMESA=ON -D BUILD_SHARED_LIBS=ON
|
|
||||||
- name: Build shared library
|
- name: Build shared library
|
||||||
run: cmake --build build-shared --parallel
|
run: cmake --build build-shared --parallel
|
||||||
|
|
||||||
|
@ -96,8 +73,8 @@ jobs:
|
||||||
- name: Build shared library
|
- name: Build shared library
|
||||||
run: cmake --build build-shared --parallel
|
run: cmake --build build-shared --parallel
|
||||||
|
|
||||||
build-windows-win32-vs2019:
|
build-windows-win32-vs2022:
|
||||||
name: Win32 (Windows, VS2019)
|
name: Win32 (Windows, VS2022)
|
||||||
runs-on: windows-latest
|
runs-on: windows-latest
|
||||||
env:
|
env:
|
||||||
CFLAGS: /WX
|
CFLAGS: /WX
|
||||||
|
@ -105,12 +82,12 @@ jobs:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
- name: Configure static library
|
- name: Configure static library
|
||||||
run: cmake -S . -B build-static -G "Visual Studio 16 2019"
|
run: cmake -S . -B build-static -G "Visual Studio 17 2022"
|
||||||
- name: Build static library
|
- name: Build static library
|
||||||
run: cmake --build build-static --parallel
|
run: cmake --build build-static --parallel
|
||||||
|
|
||||||
- name: Configure shared library
|
- name: Configure shared library
|
||||||
run: cmake -S . -B build-shared -G "Visual Studio 16 2019" -D BUILD_SHARED_LIBS=ON
|
run: cmake -S . -B build-shared -G "Visual Studio 17 2022" -D BUILD_SHARED_LIBS=ON
|
||||||
- name: Build shared library
|
- name: Build shared library
|
||||||
run: cmake --build build-shared --parallel
|
run: cmake --build build-shared --parallel
|
||||||
|
|
||||||
|
|
|
@ -23,22 +23,22 @@ endif()
|
||||||
|
|
||||||
file(STRINGS "${source_path}" lines)
|
file(STRINGS "${source_path}" lines)
|
||||||
foreach(line ${lines})
|
foreach(line ${lines})
|
||||||
if ("${line}" MATCHES "^[0-9a-fA-F].*$")
|
if (line MATCHES "^[0-9a-fA-F]")
|
||||||
if ("${line}" MATCHES "platform:Windows")
|
if (line MATCHES "platform:Windows")
|
||||||
if (GLFW_WIN32_MAPPINGS)
|
if (GLFW_WIN32_MAPPINGS)
|
||||||
set(GLFW_WIN32_MAPPINGS "${GLFW_WIN32_MAPPINGS}\n")
|
string(APPEND GLFW_WIN32_MAPPINGS "\n")
|
||||||
endif()
|
endif()
|
||||||
set(GLFW_WIN32_MAPPINGS "${GLFW_WIN32_MAPPINGS}\"${line}\",")
|
string(APPEND GLFW_WIN32_MAPPINGS "\"${line}\",")
|
||||||
elseif ("${line}" MATCHES "platform:Mac OS X")
|
elseif (line MATCHES "platform:Mac OS X")
|
||||||
if (GLFW_COCOA_MAPPINGS)
|
if (GLFW_COCOA_MAPPINGS)
|
||||||
set(GLFW_COCOA_MAPPINGS "${GLFW_COCOA_MAPPINGS}\n")
|
string(APPEND GLFW_COCOA_MAPPINGS "\n")
|
||||||
endif()
|
endif()
|
||||||
set(GLFW_COCOA_MAPPINGS "${GLFW_COCOA_MAPPINGS}\"${line}\",")
|
string(APPEND GLFW_COCOA_MAPPINGS "\"${line}\",")
|
||||||
elseif ("${line}" MATCHES "platform:Linux")
|
elseif (line MATCHES "platform:Linux")
|
||||||
if (GLFW_LINUX_MAPPINGS)
|
if (GLFW_LINUX_MAPPINGS)
|
||||||
set(GLFW_LINUX_MAPPINGS "${GLFW_LINUX_MAPPINGS}\n")
|
string(APPEND GLFW_LINUX_MAPPINGS "\n")
|
||||||
endif()
|
endif()
|
||||||
set(GLFW_LINUX_MAPPINGS "${GLFW_LINUX_MAPPINGS}\"${line}\",")
|
string(APPEND GLFW_LINUX_MAPPINGS "\"${line}\",")
|
||||||
endif()
|
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}
|
||||||
|
|
217
CMakeLists.txt
217
CMakeLists.txt
|
@ -1,4 +1,4 @@
|
||||||
cmake_minimum_required(VERSION 3.1...3.17 FATAL_ERROR)
|
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)
|
||||||
|
|
||||||
|
@ -27,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")
|
||||||
|
@ -66,6 +68,22 @@ if (GLFW_BUILD_DOCS)
|
||||||
find_package(Doxygen)
|
find_package(Doxygen)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
#--------------------------------------------------------------------
|
||||||
|
# Report backend selection
|
||||||
|
#--------------------------------------------------------------------
|
||||||
|
if (GLFW_BUILD_WIN32)
|
||||||
|
message(STATUS "Including Win32 support")
|
||||||
|
endif()
|
||||||
|
if (GLFW_BUILD_COCOA)
|
||||||
|
message(STATUS "Including Cocoa support")
|
||||||
|
endif()
|
||||||
|
if (GLFW_BUILD_WAYLAND)
|
||||||
|
message(STATUS "Including Wayland support")
|
||||||
|
endif()
|
||||||
|
if (GLFW_BUILD_X11)
|
||||||
|
message(STATUS "Including X11 support")
|
||||||
|
endif()
|
||||||
|
|
||||||
#--------------------------------------------------------------------
|
#--------------------------------------------------------------------
|
||||||
# Apply Microsoft C runtime library option
|
# Apply Microsoft C runtime library option
|
||||||
# This is here because it also applies to tests and examples
|
# This is here because it also applies to tests and examples
|
||||||
|
@ -91,167 +109,6 @@ if (MSVC AND NOT USE_MSVC_RUNTIME_LIBRARY_DLL)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
#--------------------------------------------------------------------
|
|
||||||
# Detect and select backend APIs
|
|
||||||
#--------------------------------------------------------------------
|
|
||||||
if (GLFW_USE_WAYLAND)
|
|
||||||
set(_GLFW_WAYLAND 1)
|
|
||||||
message(STATUS "Using Wayland for window creation")
|
|
||||||
elseif (GLFW_USE_OSMESA)
|
|
||||||
set(_GLFW_OSMESA 1)
|
|
||||||
message(STATUS "Using OSMesa for headless context creation")
|
|
||||||
elseif (WIN32)
|
|
||||||
set(_GLFW_WIN32 1)
|
|
||||||
message(STATUS "Using Win32 for window creation")
|
|
||||||
elseif (APPLE)
|
|
||||||
set(_GLFW_COCOA 1)
|
|
||||||
message(STATUS "Using Cocoa for window creation")
|
|
||||||
elseif (UNIX)
|
|
||||||
set(_GLFW_X11 1)
|
|
||||||
message(STATUS "Using X11 for window creation")
|
|
||||||
else()
|
|
||||||
message(FATAL_ERROR "No supported platform was detected")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
#--------------------------------------------------------------------
|
|
||||||
# Find and add Unix math and time libraries
|
|
||||||
#--------------------------------------------------------------------
|
|
||||||
if (UNIX AND NOT APPLE)
|
|
||||||
find_library(RT_LIBRARY rt)
|
|
||||||
mark_as_advanced(RT_LIBRARY)
|
|
||||||
if (RT_LIBRARY)
|
|
||||||
list(APPEND glfw_LIBRARIES "${RT_LIBRARY}")
|
|
||||||
list(APPEND glfw_PKG_LIBS "-lrt")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
find_library(MATH_LIBRARY m)
|
|
||||||
mark_as_advanced(MATH_LIBRARY)
|
|
||||||
if (MATH_LIBRARY)
|
|
||||||
list(APPEND glfw_LIBRARIES "${MATH_LIBRARY}")
|
|
||||||
list(APPEND glfw_PKG_LIBS "-lm")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if (CMAKE_DL_LIBS)
|
|
||||||
list(APPEND glfw_LIBRARIES "${CMAKE_DL_LIBS}")
|
|
||||||
list(APPEND glfw_PKG_LIBS "-l${CMAKE_DL_LIBS}")
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
#--------------------------------------------------------------------
|
|
||||||
# Use Win32 for window creation
|
|
||||||
#--------------------------------------------------------------------
|
|
||||||
if (_GLFW_WIN32)
|
|
||||||
|
|
||||||
list(APPEND glfw_PKG_LIBS "-lgdi32")
|
|
||||||
|
|
||||||
if (GLFW_USE_HYBRID_HPG)
|
|
||||||
set(_GLFW_USE_HYBRID_HPG 1)
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
#--------------------------------------------------------------------
|
|
||||||
# Use X11 for window creation
|
|
||||||
#--------------------------------------------------------------------
|
|
||||||
if (_GLFW_X11)
|
|
||||||
|
|
||||||
find_package(X11 REQUIRED)
|
|
||||||
|
|
||||||
# Set up library and include paths
|
|
||||||
list(APPEND glfw_INCLUDE_DIRS "${X11_X11_INCLUDE_PATH}")
|
|
||||||
|
|
||||||
# Check for XRandR (modern resolution switching and gamma control)
|
|
||||||
if (NOT X11_Xrandr_INCLUDE_PATH)
|
|
||||||
message(FATAL_ERROR "RandR headers not found; install libxrandr development package")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Check for Xinerama (legacy multi-monitor support)
|
|
||||||
if (NOT X11_Xinerama_INCLUDE_PATH)
|
|
||||||
message(FATAL_ERROR "Xinerama headers not found; install libxinerama development package")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Check for Xkb (X keyboard extension)
|
|
||||||
if (NOT X11_Xkb_INCLUDE_PATH)
|
|
||||||
message(FATAL_ERROR "XKB headers not found; install X11 development package")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Check for Xcursor (cursor creation from RGBA images)
|
|
||||||
if (NOT X11_Xcursor_INCLUDE_PATH)
|
|
||||||
message(FATAL_ERROR "Xcursor headers not found; install libxcursor development package")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Check for XInput (modern HID input)
|
|
||||||
if (NOT X11_Xi_INCLUDE_PATH)
|
|
||||||
message(FATAL_ERROR "XInput headers not found; install libxi development package")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Check for X Shape (custom window input shape)
|
|
||||||
if (NOT X11_Xshape_INCLUDE_PATH)
|
|
||||||
message(FATAL_ERROR "X Shape headers not found; install libxext development package")
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
#--------------------------------------------------------------------
|
|
||||||
# Use Wayland for window creation
|
|
||||||
#--------------------------------------------------------------------
|
|
||||||
if (_GLFW_WAYLAND)
|
|
||||||
|
|
||||||
include(FindPkgConfig)
|
|
||||||
pkg_check_modules(Wayland REQUIRED
|
|
||||||
wayland-client>=0.2.7
|
|
||||||
wayland-cursor>=0.2.7
|
|
||||||
wayland-egl>=0.2.7
|
|
||||||
xkbcommon)
|
|
||||||
|
|
||||||
list(APPEND glfw_PKG_DEPS "wayland-client")
|
|
||||||
|
|
||||||
list(APPEND glfw_INCLUDE_DIRS "${Wayland_INCLUDE_DIRS}")
|
|
||||||
list(APPEND glfw_LIBRARIES "${Wayland_LINK_LIBRARIES}")
|
|
||||||
|
|
||||||
include(CheckIncludeFiles)
|
|
||||||
include(CheckFunctionExists)
|
|
||||||
check_include_files(xkbcommon/xkbcommon-compose.h HAVE_XKBCOMMON_COMPOSE_H)
|
|
||||||
check_function_exists(memfd_create HAVE_MEMFD_CREATE)
|
|
||||||
|
|
||||||
if (NOT CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
|
||||||
find_package(EpollShim)
|
|
||||||
if (EPOLLSHIM_FOUND)
|
|
||||||
list(APPEND glfw_INCLUDE_DIRS "${EPOLLSHIM_INCLUDE_DIRS}")
|
|
||||||
list(APPEND glfw_LIBRARIES "${EPOLLSHIM_LIBRARIES}")
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
#--------------------------------------------------------------------
|
|
||||||
# Use Cocoa for window creation and NSOpenGL for context creation
|
|
||||||
#--------------------------------------------------------------------
|
|
||||||
if (_GLFW_COCOA)
|
|
||||||
|
|
||||||
list(APPEND glfw_LIBRARIES
|
|
||||||
"-framework Cocoa"
|
|
||||||
"-framework IOKit"
|
|
||||||
"-framework CoreFoundation")
|
|
||||||
|
|
||||||
set(glfw_PKG_DEPS "")
|
|
||||||
set(glfw_PKG_LIBS "-framework Cocoa -framework IOKit -framework CoreFoundation")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
#--------------------------------------------------------------------
|
|
||||||
# Add the Vulkan loader as a dependency if necessary
|
|
||||||
#--------------------------------------------------------------------
|
|
||||||
if (GLFW_VULKAN_STATIC)
|
|
||||||
list(APPEND glfw_PKG_DEPS "vulkan")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
#--------------------------------------------------------------------
|
|
||||||
# Export GLFW library dependencies
|
|
||||||
#--------------------------------------------------------------------
|
|
||||||
foreach(arg ${glfw_PKG_DEPS})
|
|
||||||
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
|
||||||
#--------------------------------------------------------------------
|
#--------------------------------------------------------------------
|
||||||
|
@ -268,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
|
||||||
#--------------------------------------------------------------------
|
#--------------------------------------------------------------------
|
||||||
|
|
248
CONTRIBUTORS.md
Normal file
248
CONTRIBUTORS.md
Normal file
|
@ -0,0 +1,248 @@
|
||||||
|
# Acknowledgements
|
||||||
|
|
||||||
|
GLFW exists because people around the world donated their time and lent their
|
||||||
|
skills. This list only includes contributions to the main repository and
|
||||||
|
excludes other invaluable contributions like language bindings and text and
|
||||||
|
video tutorials.
|
||||||
|
|
||||||
|
- Bobyshev Alexander
|
||||||
|
- Laurent Aphecetche
|
||||||
|
- Matt Arsenault
|
||||||
|
- ashishgamedev
|
||||||
|
- David Avedissian
|
||||||
|
- Luca Bacci
|
||||||
|
- Keith Bauer
|
||||||
|
- John Bartholomew
|
||||||
|
- Coşku Baş
|
||||||
|
- Niklas Behrens
|
||||||
|
- Andrew Belt
|
||||||
|
- Nevyn Bengtsson
|
||||||
|
- Niklas Bergström
|
||||||
|
- Denis Bernard
|
||||||
|
- Doug Binks
|
||||||
|
- blanco
|
||||||
|
- Waris Boonyasiriwat
|
||||||
|
- Kyle Brenneman
|
||||||
|
- Rok Breulj
|
||||||
|
- Kai Burjack
|
||||||
|
- Martin Capitanio
|
||||||
|
- Nicolas Caramelli
|
||||||
|
- David Carlier
|
||||||
|
- Arturo Castro
|
||||||
|
- Chi-kwan Chan
|
||||||
|
- TheChocolateOre
|
||||||
|
- Joseph Chua
|
||||||
|
- Ian Clarkson
|
||||||
|
- Michał Cichoń
|
||||||
|
- Lambert Clara
|
||||||
|
- Anna Clarke
|
||||||
|
- Josh Codd
|
||||||
|
- Yaron Cohen-Tal
|
||||||
|
- Omar Cornut
|
||||||
|
- Andrew Corrigan
|
||||||
|
- Bailey Cosier
|
||||||
|
- Noel Cower
|
||||||
|
- CuriouserThing
|
||||||
|
- Jason Daly
|
||||||
|
- danhambleton
|
||||||
|
- Jarrod Davis
|
||||||
|
- Olivier Delannoy
|
||||||
|
- Paul R. Deppe
|
||||||
|
- Michael Dickens
|
||||||
|
- Роман Донченко
|
||||||
|
- Mario Dorn
|
||||||
|
- Wolfgang Draxinger
|
||||||
|
- Jonathan Dummer
|
||||||
|
- Ralph Eastwood
|
||||||
|
- Fredrik Ehnbom
|
||||||
|
- Robin Eklind
|
||||||
|
- Jan Ekström
|
||||||
|
- Siavash Eliasi
|
||||||
|
- Ahmad Fatoum
|
||||||
|
- Felipe Ferreira
|
||||||
|
- Michael Fogleman
|
||||||
|
- Jason Francis
|
||||||
|
- Gerald Franz
|
||||||
|
- Mário Freitas
|
||||||
|
- GeO4d
|
||||||
|
- Marcus Geelnard
|
||||||
|
- ghuser404
|
||||||
|
- Charles Giessen
|
||||||
|
- Ryan C. Gordon
|
||||||
|
- Stephen Gowen
|
||||||
|
- Kovid Goyal
|
||||||
|
- Kevin Grandemange
|
||||||
|
- Eloi Marín Gratacós
|
||||||
|
- Stefan Gustavson
|
||||||
|
- Andrew Gutekanst
|
||||||
|
- Stephen Gutekanst
|
||||||
|
- Jonathan Hale
|
||||||
|
- hdf89shfdfs
|
||||||
|
- Sylvain Hellegouarch
|
||||||
|
- Matthew Henry
|
||||||
|
- heromyth
|
||||||
|
- Lucas Hinderberger
|
||||||
|
- Paul Holden
|
||||||
|
- Warren Hu
|
||||||
|
- Charles Huber
|
||||||
|
- Brent Huisman
|
||||||
|
- illustris
|
||||||
|
- InKryption
|
||||||
|
- IntellectualKitty
|
||||||
|
- Aaron Jacobs
|
||||||
|
- JannikGM
|
||||||
|
- Erik S. V. Jansson
|
||||||
|
- jjYBdx4IL
|
||||||
|
- Toni Jovanoski
|
||||||
|
- Arseny Kapoulkine
|
||||||
|
- Cem Karan
|
||||||
|
- Osman Keskin
|
||||||
|
- Koray Kilinc
|
||||||
|
- Josh Kilmer
|
||||||
|
- Byunghoon Kim
|
||||||
|
- Cameron King
|
||||||
|
- Peter Knut
|
||||||
|
- Christoph Kubisch
|
||||||
|
- Yuri Kunde Schlesner
|
||||||
|
- Rokas Kupstys
|
||||||
|
- Konstantin Käfer
|
||||||
|
- Eric Larson
|
||||||
|
- Francis Lecavalier
|
||||||
|
- Jong Won Lee
|
||||||
|
- Robin Leffmann
|
||||||
|
- Glenn Lewis
|
||||||
|
- Shane Liesegang
|
||||||
|
- Anders Lindqvist
|
||||||
|
- Leon Linhart
|
||||||
|
- Marco Lizza
|
||||||
|
- Eyal Lotem
|
||||||
|
- Aaron Loucks
|
||||||
|
- Luflosi
|
||||||
|
- lukect
|
||||||
|
- Tristam MacDonald
|
||||||
|
- Hans Mackowiak
|
||||||
|
- Дмитри Малышев
|
||||||
|
- Zbigniew Mandziejewicz
|
||||||
|
- Adam Marcus
|
||||||
|
- Célestin Marot
|
||||||
|
- Kyle McDonald
|
||||||
|
- David V. McKay
|
||||||
|
- David Medlock
|
||||||
|
- Bryce Mehring
|
||||||
|
- Jonathan Mercier
|
||||||
|
- Marcel Metz
|
||||||
|
- Liam Middlebrook
|
||||||
|
- Ave Milia
|
||||||
|
- Jonathan Miller
|
||||||
|
- Kenneth Miller
|
||||||
|
- Bruce Mitchener
|
||||||
|
- Jack Moffitt
|
||||||
|
- Jeff Molofee
|
||||||
|
- Alexander Monakov
|
||||||
|
- Pierre Morel
|
||||||
|
- Jon Morton
|
||||||
|
- Pierre Moulon
|
||||||
|
- Martins Mozeiko
|
||||||
|
- Pascal Muetschard
|
||||||
|
- Julian Møller
|
||||||
|
- ndogxj
|
||||||
|
- n3rdopolis
|
||||||
|
- Kristian Nielsen
|
||||||
|
- Kamil Nowakowski
|
||||||
|
- onox
|
||||||
|
- Denis Ovod
|
||||||
|
- Ozzy
|
||||||
|
- Andri Pálsson
|
||||||
|
- luz paz
|
||||||
|
- Peoro
|
||||||
|
- Braden Pellett
|
||||||
|
- Christopher Pelloux
|
||||||
|
- Arturo J. Pérez
|
||||||
|
- Vladimir Perminov
|
||||||
|
- Anthony Pesch
|
||||||
|
- Orson Peters
|
||||||
|
- Emmanuel Gil Peyrot
|
||||||
|
- Cyril Pichard
|
||||||
|
- Pilzschaf
|
||||||
|
- Keith Pitt
|
||||||
|
- Stanislav Podgorskiy
|
||||||
|
- Konstantin Podsvirov
|
||||||
|
- Nathan Poirier
|
||||||
|
- Alexandre Pretyman
|
||||||
|
- Pablo Prietz
|
||||||
|
- przemekmirek
|
||||||
|
- pthom
|
||||||
|
- Guillaume Racicot
|
||||||
|
- Philip Rideout
|
||||||
|
- Eddie Ringle
|
||||||
|
- Max Risuhin
|
||||||
|
- Jorge Rodriguez
|
||||||
|
- Jari Ronkainen
|
||||||
|
- Luca Rood
|
||||||
|
- Ed Ropple
|
||||||
|
- Aleksey Rybalkin
|
||||||
|
- Mikko Rytkönen
|
||||||
|
- Riku Salminen
|
||||||
|
- Brandon Schaefer
|
||||||
|
- Sebastian Schuberth
|
||||||
|
- Christian Sdunek
|
||||||
|
- Matt Sealey
|
||||||
|
- Steve Sexton
|
||||||
|
- Arkady Shapkin
|
||||||
|
- Ali Sherief
|
||||||
|
- Yoshiki Shibukawa
|
||||||
|
- Dmitri Shuralyov
|
||||||
|
- Joao da Silva
|
||||||
|
- Daniel Sieger
|
||||||
|
- Daniel Skorupski
|
||||||
|
- Slemmie
|
||||||
|
- Anthony Smith
|
||||||
|
- Bradley Smith
|
||||||
|
- Cliff Smolinsky
|
||||||
|
- Patrick Snape
|
||||||
|
- Erlend Sogge Heggen
|
||||||
|
- Olivier Sohn
|
||||||
|
- Julian Squires
|
||||||
|
- Johannes Stein
|
||||||
|
- Pontus Stenetorp
|
||||||
|
- Michael Stocker
|
||||||
|
- Justin Stoecker
|
||||||
|
- Elviss Strazdins
|
||||||
|
- Paul Sultana
|
||||||
|
- Nathan Sweet
|
||||||
|
- TTK-Bandit
|
||||||
|
- Jared Tiala
|
||||||
|
- Sergey Tikhomirov
|
||||||
|
- Arthur Tombs
|
||||||
|
- TronicLabs
|
||||||
|
- Ioannis Tsakpinis
|
||||||
|
- Samuli Tuomola
|
||||||
|
- Matthew Turner
|
||||||
|
- urraka
|
||||||
|
- Elias Vanderstuyft
|
||||||
|
- Stef Velzel
|
||||||
|
- Jari Vetoniemi
|
||||||
|
- Ricardo Vieira
|
||||||
|
- Nicholas Vitovitch
|
||||||
|
- Simon Voordouw
|
||||||
|
- Corentin Wallez
|
||||||
|
- Torsten Walluhn
|
||||||
|
- Patrick Walton
|
||||||
|
- Xo Wang
|
||||||
|
- Jay Weisskopf
|
||||||
|
- Frank Wille
|
||||||
|
- Andy Williams
|
||||||
|
- Joel Winarske
|
||||||
|
- Richard A. Wilkes
|
||||||
|
- Tatsuya Yatagawa
|
||||||
|
- Ryogo Yoshimura
|
||||||
|
- Lukas Zanner
|
||||||
|
- Andrey Zholos
|
||||||
|
- Aihui Zhu
|
||||||
|
- Santi Zupancic
|
||||||
|
- Jonas Ådahl
|
||||||
|
- Lasse Öörni
|
||||||
|
- Leonard König
|
||||||
|
- All the unmentioned and anonymous contributors in the GLFW community, for bug
|
||||||
|
reports, patches, feedback, testing and encouragement
|
||||||
|
|
316
README.md
316
README.md
|
@ -39,6 +39,11 @@ you have used GLFW 2 in the past, there is a [transition
|
||||||
guide](https://www.glfw.org/docs/latest/moving.html) for moving to the GLFW
|
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
|
||||||
|
|
||||||
|
@ -116,6 +121,17 @@ 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)
|
||||||
|
@ -123,16 +139,28 @@ information on what to include when reporting a bug.
|
||||||
- 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
|
- Added `GLFW_MOUSE_PASSTHROUGH` window hint for letting mouse input pass
|
||||||
through the window (#1236,#1568)
|
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_UNAVAILABLE` error for platform limitations (#1692)
|
||||||
- Added `GLFW_FEATURE_UNIMPLEMENTED` error for incomplete backends (#1692)
|
- Added `GLFW_FEATURE_UNIMPLEMENTED` error for incomplete backends (#1692)
|
||||||
- Added `GLFW_ANGLE_PLATFORM_TYPE` init hint and `GLFW_ANGLE_PLATFORM_TYPE_*`
|
- Added `GLFW_ANGLE_PLATFORM_TYPE` init hint and `GLFW_ANGLE_PLATFORM_TYPE_*`
|
||||||
values to select ANGLE backend (#1380)
|
values to select ANGLE backend (#1380)
|
||||||
- Added `GLFW_X11_XCB_VULKAN_SURFACE` init hint for selecting X11 Vulkan
|
- Added `GLFW_X11_XCB_VULKAN_SURFACE` init hint for selecting X11 Vulkan
|
||||||
surface extension (#1793)
|
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 joystick subsystem initialize at first use (#1284,#1646)
|
||||||
- Made `GLFW_DOUBLEBUFFER` a read-only window attribute
|
- 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)
|
||||||
|
@ -143,6 +171,9 @@ information on what to include when reporting a bug.
|
||||||
- Bugfix: Buffers were swapped at creation on single-buffered windows (#1873)
|
- Bugfix: Buffers were swapped at creation on single-buffered windows (#1873)
|
||||||
- Bugfix: Gamepad mapping updates could spam `GLFW_INVALID_VALUE` due to
|
- Bugfix: Gamepad mapping updates could spam `GLFW_INVALID_VALUE` due to
|
||||||
incompatible controllers sharing hardware ID (#1763)
|
incompatible controllers sharing hardware ID (#1763)
|
||||||
|
- Bugfix: Native access functions for context handles did not check that the API matched
|
||||||
|
- Bugfix: `glfwMakeContextCurrent` would access TLS slot before initialization
|
||||||
|
- Bugfix: `glfwSetGammaRamp` could emit `GLFW_INVALID_VALUE` before initialization
|
||||||
- [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
|
||||||
|
@ -173,6 +204,20 @@ information on what to include when reporting a bug.
|
||||||
later (#1783,#1796)
|
later (#1783,#1796)
|
||||||
- [Win32] Bugfix: Compilation with LLVM for Windows failed (#1807,#1824,#1874)
|
- [Win32] Bugfix: Compilation with LLVM for Windows failed (#1807,#1824,#1874)
|
||||||
- [Win32] Bugfix: The foreground lock timeout was overridden, ignoring the user
|
- [Win32] Bugfix: The foreground lock timeout was overridden, ignoring the user
|
||||||
|
- [Win32] Bugfix: Content scale queries could fail silently (#1615)
|
||||||
|
- [Win32] Bugfix: Content scales could have garbage values if monitor was recently
|
||||||
|
disconnected (#1615)
|
||||||
|
- [Win32] Bugfix: A window created maximized and undecorated would cover the whole
|
||||||
|
monitor (#1806)
|
||||||
|
- [Win32] Bugfix: The default restored window position was lost when creating a maximized
|
||||||
|
window
|
||||||
|
- [Win32] Bugfix: `glfwMaximizeWindow` would make a hidden window visible
|
||||||
|
- [Win32] Bugfix: `Alt+PrtSc` would emit `GLFW_KEY_UNKNOWN` and a different
|
||||||
|
scancode than `PrtSc` (#1993)
|
||||||
|
- [Win32] Bugfix: `GLFW_KEY_PAUSE` scancode from `glfwGetKeyScancode` did not
|
||||||
|
match event scancode (#1993)
|
||||||
|
- [Win32] Bugfix: Instance-local operations used executable instance (#469,#1296,#1395)
|
||||||
|
- [Win32] Bugfix: The OSMesa library was not unloaded on termination
|
||||||
- [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)
|
||||||
|
@ -193,12 +238,18 @@ information on what to include when reporting a bug.
|
||||||
could leak memory
|
could leak memory
|
||||||
- [Cocoa] Bugfix: Objective-C files were compiled as C with CMake 3.19 (#1787)
|
- [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: Duplicate video modes were not filtered out (#1830)
|
||||||
- [Cocoa] Bugfix: Menubar was not clickable on macOS 10.15+ until it lost and
|
- [Cocoa] Bugfix: Menu bar was not clickable on macOS 10.15+ until it lost and
|
||||||
regained focus (#1648,#1802)
|
regained focus (#1648,#1802)
|
||||||
- [Cocoa] Bugfix: Monitor name query could segfault on macOS 11 (#1809,#1833)
|
- [Cocoa] Bugfix: Monitor name query could segfault on macOS 11 (#1809,#1833)
|
||||||
- [Cocoa] Bugfix: The install name of the installed dylib was relative (#1504)
|
- [Cocoa] Bugfix: The install name of the installed dylib was relative (#1504)
|
||||||
- [Cocoa] Bugfix: The MoltenVK layer contents scale was updated only after
|
- [Cocoa] Bugfix: The MoltenVK layer contents scale was updated only after
|
||||||
related events were emitted
|
related events were emitted
|
||||||
|
- [Cocoa] Bugfix: Moving the cursor programmatically would freeze it for
|
||||||
|
a fraction of a second (#1962)
|
||||||
|
- [Cocoa] Bugfix: `kIOMasterPortDefault` was deprecated in macOS 12.0 (#1980)
|
||||||
|
- [Cocoa] Bugfix: `kUTTypeURL` was deprecated in macOS 12.0 (#2003)
|
||||||
|
- [Cocoa] Bugfix: A connected Apple AirPlay would emit a useless error (#1791)
|
||||||
|
- [Cocoa] Bugfix: The EGL and OSMesa libraries were not unloaded on termination
|
||||||
- [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)
|
||||||
|
@ -221,11 +272,28 @@ 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
|
- [X11] Bugfix: Keys pressed simultaneously with others were not always
|
||||||
reported (#1112,#1415,#1472,#1616)
|
reported (#1112,#1415,#1472,#1616)
|
||||||
- [X11] Bugfix: Some window attributes were not applied on leaving fullscreen
|
- [X11] Bugfix: Some window attributes were not applied on leaving fullscreen
|
||||||
(#1863)
|
(#1863)
|
||||||
|
- [X11] Bugfix: Changing `GLFW_FLOATING` could leak memory
|
||||||
|
- [X11] Bugfix: Icon pixel format conversion worked only by accident, relying on
|
||||||
|
undefined behavior (#1986)
|
||||||
|
- [X11] Bugfix: Dynamic loading on OpenBSD failed due to soname differences
|
||||||
|
- [X11] Bugfix: Waiting for events would fail if file descriptor was too large
|
||||||
|
(#2024)
|
||||||
|
- [X11] Bugfix: Joystick events could lead to busy-waiting (#1872)
|
||||||
|
- [X11] Bugfix: `glfwWaitEvents*` did not continue for joystick events
|
||||||
|
- [X11] Bugfix: `glfwPostEmptyEvent` could be ignored due to race condition
|
||||||
|
(#379,#1281,#1285,#2033)
|
||||||
|
- [X11] Bugfix: Dynamic loading on NetBSD failed due to soname differences
|
||||||
|
- [X11] Bugfix: Left shift of int constant relied on undefined behavior (#1951)
|
||||||
|
- [X11] Bugfix: The OSMesa libray was not unloaded on termination
|
||||||
|
- [X11] Bugfix: A malformed response during selection transfer could cause a segfault
|
||||||
|
- [Wayland] Added dynamic loading of all Wayland libraries
|
||||||
|
- [Wayland] Added support for key names via xkbcommon
|
||||||
|
- [Wayland] Added support for file path drop events (#2040)
|
||||||
- [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
|
||||||
|
@ -233,11 +301,34 @@ information on what to include when reporting a bug.
|
||||||
- [Wayland] Bugfix: Retrieving partial framebuffer size would segfault
|
- [Wayland] Bugfix: Retrieving partial framebuffer size would segfault
|
||||||
- [Wayland] Bugfix: Scrolling offsets were inverted compared to other platforms
|
- [Wayland] Bugfix: Scrolling offsets were inverted compared to other platforms
|
||||||
(#1463)
|
(#1463)
|
||||||
- [Wayland] Bugfix: Client-Side Decorations were destroyed in the wrong worder
|
- [Wayland] Bugfix: Client-Side Decorations were destroyed in the wrong order
|
||||||
(#1798)
|
(#1798)
|
||||||
- [Wayland] Bugfix: Monitors physical size could report zero (#1784,#1792)
|
- [Wayland] Bugfix: Monitors physical size could report zero (#1784,#1792)
|
||||||
|
- [Wayland] Bugfix: Some keys were not repeating in Wayland (#1908)
|
||||||
|
- [Wayland] Bugfix: Non-arrow cursors are offset from the hotspot (#1706,#1899)
|
||||||
|
- [Wayland] Bugfix: The `O_CLOEXEC` flag was not defined on FreeBSD
|
||||||
|
- [Wayland] Bugfix: Key repeat could lead to a race condition (#1710)
|
||||||
|
- [Wayland] Bugfix: Activating a window would emit two input focus events
|
||||||
|
- [Wayland] Bugfix: Disable key repeat mechanism when window loses input focus
|
||||||
|
- [Wayland] Bugfix: Window hiding and showing did not work (#1492,#1731)
|
||||||
|
- [Wayland] Bugfix: A key being repeated was not released when window lost focus
|
||||||
|
- [Wayland] Bugfix: Showing a hidden window did not emit a window refresh event
|
||||||
|
- [Wayland] Bugfix: Full screen window creation did not ignore `GLFW_VISIBLE`
|
||||||
|
- [Wayland] Bugfix: Some keys were reported as wrong key or `GLFW_KEY_UNKNOWN`
|
||||||
|
- [Wayland] Bugfix: Text input did not repeat along with key repeat
|
||||||
|
- [Wayland] Bugfix: `glfwPostEmptyEvent` sometimes had no effect (#1520,#1521)
|
||||||
|
- [Wayland] Bugfix: `glfwSetClipboardString` would fail if set to result of
|
||||||
|
`glfwGetClipboardString`
|
||||||
|
- [Wayland] Bugfix: Data source creation error would cause double free at termination
|
||||||
|
- [Wayland] Bugfix: Partial writes of clipboard string would cause beginning to repeat
|
||||||
|
- [Wayland] Bugfix: Some errors would cause clipboard string transfer to hang
|
||||||
|
- [Wayland] Bugfix: Drag and drop data was misinterpreted as clipboard string
|
||||||
|
- [Wayland] Bugfix: MIME type matching was not performed for clipboard string
|
||||||
|
- [Wayland] Bugfix: The OSMesa library was not unloaded on termination
|
||||||
|
- [Wayland] Bugfix: `glfwCreateWindow` could emit `GLFW_FEATURE_UNAVAILABLE`
|
||||||
- [POSIX] Removed use of deprecated function `gettimeofday`
|
- [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)
|
||||||
|
@ -249,6 +340,7 @@ information on what to include when reporting a bug.
|
||||||
- [EGL] Added ANGLE backend selection via `EGL_ANGLE_platform_angle` extension
|
- [EGL] Added ANGLE backend selection via `EGL_ANGLE_platform_angle` extension
|
||||||
(#1380)
|
(#1380)
|
||||||
- [EGL] Bugfix: The `GLFW_DOUBLEBUFFER` context attribute was ignored (#1843)
|
- [EGL] Bugfix: The `GLFW_DOUBLEBUFFER` context attribute was ignored (#1843)
|
||||||
|
- [GLX] Bugfix: Context creation failed if GLX 1.4 was not exported by GLX library
|
||||||
|
|
||||||
|
|
||||||
## Contact
|
## Contact
|
||||||
|
@ -267,221 +359,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
|
|
||||||
- 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
|
|
||||||
- Kyle Brenneman
|
|
||||||
- Rok Breulj
|
|
||||||
- Kai Burjack
|
|
||||||
- Martin Capitanio
|
|
||||||
- Nicolas Caramelli
|
|
||||||
- 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
|
|
||||||
- CuriouserThing
|
|
||||||
- Jason Daly
|
|
||||||
- Jarrod Davis
|
|
||||||
- Olivier Delannoy
|
|
||||||
- Paul R. Deppe
|
|
||||||
- Michael Dickens
|
|
||||||
- Роман Донченко
|
|
||||||
- Mario Dorn
|
|
||||||
- Wolfgang Draxinger
|
|
||||||
- Jonathan Dummer
|
|
||||||
- Ralph Eastwood
|
|
||||||
- Fredrik Ehnbom
|
|
||||||
- Robin Eklind
|
|
||||||
- Siavash Eliasi
|
|
||||||
- Felipe Ferreira
|
|
||||||
- Michael Fogleman
|
|
||||||
- Gerald Franz
|
|
||||||
- Mário Freitas
|
|
||||||
- GeO4d
|
|
||||||
- Marcus Geelnard
|
|
||||||
- Charles Giessen
|
|
||||||
- Ryan C. Gordon
|
|
||||||
- Stephen Gowen
|
|
||||||
- Kovid Goyal
|
|
||||||
- Eloi Marín Gratacós
|
|
||||||
- Stefan Gustavson
|
|
||||||
- Jonathan Hale
|
|
||||||
- hdf89shfdfs
|
|
||||||
- Sylvain Hellegouarch
|
|
||||||
- Matthew Henry
|
|
||||||
- heromyth
|
|
||||||
- Lucas Hinderberger
|
|
||||||
- Paul Holden
|
|
||||||
- Warren Hu
|
|
||||||
- Charles Huber
|
|
||||||
- IntellectualKitty
|
|
||||||
- Aaron Jacobs
|
|
||||||
- Erik S. V. Jansson
|
|
||||||
- Toni Jovanoski
|
|
||||||
- Arseny Kapoulkine
|
|
||||||
- Cem Karan
|
|
||||||
- Osman Keskin
|
|
||||||
- Josh Kilmer
|
|
||||||
- Byunghoon Kim
|
|
||||||
- Cameron King
|
|
||||||
- Peter Knut
|
|
||||||
- Christoph Kubisch
|
|
||||||
- Yuri Kunde Schlesner
|
|
||||||
- Rokas Kupstys
|
|
||||||
- Konstantin Käfer
|
|
||||||
- Eric Larson
|
|
||||||
- Francis Lecavalier
|
|
||||||
- Jong Won Lee
|
|
||||||
- Robin Leffmann
|
|
||||||
- Glenn Lewis
|
|
||||||
- Shane Liesegang
|
|
||||||
- Anders Lindqvist
|
|
||||||
- Leon Linhart
|
|
||||||
- Marco Lizza
|
|
||||||
- Eyal Lotem
|
|
||||||
- Aaron Loucks
|
|
||||||
- Luflosi
|
|
||||||
- lukect
|
|
||||||
- Tristam MacDonald
|
|
||||||
- Hans Mackowiak
|
|
||||||
- Дмитри Малышев
|
|
||||||
- Zbigniew Mandziejewicz
|
|
||||||
- Adam Marcus
|
|
||||||
- Célestin Marot
|
|
||||||
- Kyle McDonald
|
|
||||||
- David V. McKay
|
|
||||||
- David Medlock
|
|
||||||
- Bryce Mehring
|
|
||||||
- Jonathan Mercier
|
|
||||||
- Marcel Metz
|
|
||||||
- Liam Middlebrook
|
|
||||||
- Ave Milia
|
|
||||||
- Jonathan Miller
|
|
||||||
- Kenneth Miller
|
|
||||||
- Bruce Mitchener
|
|
||||||
- Jack Moffitt
|
|
||||||
- Jeff Molofee
|
|
||||||
- Alexander Monakov
|
|
||||||
- Pierre Morel
|
|
||||||
- Jon Morton
|
|
||||||
- Pierre Moulon
|
|
||||||
- Martins Mozeiko
|
|
||||||
- Julian Møller
|
|
||||||
- ndogxj
|
|
||||||
- Kristian Nielsen
|
|
||||||
- Kamil Nowakowski
|
|
||||||
- onox
|
|
||||||
- Denis Ovod
|
|
||||||
- Ozzy
|
|
||||||
- Andri Pálsson
|
|
||||||
- Peoro
|
|
||||||
- Braden Pellett
|
|
||||||
- Christopher Pelloux
|
|
||||||
- Arturo J. Pérez
|
|
||||||
- Vladimir Perminov
|
|
||||||
- Anthony Pesch
|
|
||||||
- Orson Peters
|
|
||||||
- Emmanuel Gil Peyrot
|
|
||||||
- Cyril Pichard
|
|
||||||
- Keith Pitt
|
|
||||||
- Stanislav Podgorskiy
|
|
||||||
- Konstantin Podsvirov
|
|
||||||
- Nathan Poirier
|
|
||||||
- Alexandre Pretyman
|
|
||||||
- Pablo Prietz
|
|
||||||
- przemekmirek
|
|
||||||
- pthom
|
|
||||||
- Guillaume Racicot
|
|
||||||
- Philip Rideout
|
|
||||||
- Eddie Ringle
|
|
||||||
- Max Risuhin
|
|
||||||
- Jorge Rodriguez
|
|
||||||
- Luca Rood
|
|
||||||
- Ed Ropple
|
|
||||||
- Aleksey Rybalkin
|
|
||||||
- Mikko Rytkönen
|
|
||||||
- Riku Salminen
|
|
||||||
- Brandon Schaefer
|
|
||||||
- Sebastian Schuberth
|
|
||||||
- Christian Sdunek
|
|
||||||
- Matt Sealey
|
|
||||||
- Steve Sexton
|
|
||||||
- Arkady Shapkin
|
|
||||||
- Ali Sherief
|
|
||||||
- Yoshiki Shibukawa
|
|
||||||
- Dmitri Shuralyov
|
|
||||||
- Daniel Skorupski
|
|
||||||
- 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
|
|
||||||
- Waris
|
|
||||||
- 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
|
|
||||||
|
|
||||||
|
|
3676
deps/glad/gl.h
vendored
3676
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
|
|
1550
deps/glad/vulkan.h
vendored
1550
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
930
deps/stb_image_write.h
vendored
930
deps/stb_image_write.h
vendored
File diff suppressed because it is too large
Load Diff
|
@ -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")
|
||||||
|
|
||||||
|
|
|
@ -93,14 +93,6 @@ ALLOW_UNICODE_NAMES = NO
|
||||||
|
|
||||||
OUTPUT_LANGUAGE = English
|
OUTPUT_LANGUAGE = English
|
||||||
|
|
||||||
# The OUTPUT_TEXT_DIRECTION tag is used to specify the direction in which all
|
|
||||||
# documentation generated by doxygen is written. Doxygen will use this
|
|
||||||
# information to generate all generated output in the proper direction.
|
|
||||||
# Possible values are: None, LTR, RTL and Context.
|
|
||||||
# The default value is: None.
|
|
||||||
|
|
||||||
OUTPUT_TEXT_DIRECTION = None
|
|
||||||
|
|
||||||
# If the BRIEF_MEMBER_DESC tag is set to YES, doxygen will include brief member
|
# If the BRIEF_MEMBER_DESC tag is set to YES, doxygen will include brief member
|
||||||
# descriptions after the members that are listed in the file and class
|
# descriptions after the members that are listed in the file and class
|
||||||
# documentation (similar to Javadoc). Set to NO to disable this.
|
# documentation (similar to Javadoc). Set to NO to disable this.
|
||||||
|
@ -1811,16 +1803,6 @@ LATEX_BATCHMODE = NO
|
||||||
|
|
||||||
LATEX_HIDE_INDICES = NO
|
LATEX_HIDE_INDICES = NO
|
||||||
|
|
||||||
# If the LATEX_SOURCE_CODE tag is set to YES then doxygen will include source
|
|
||||||
# code with syntax highlighting in the LaTeX output.
|
|
||||||
#
|
|
||||||
# Note that which sources are shown also depends on other settings such as
|
|
||||||
# SOURCE_BROWSER.
|
|
||||||
# The default value is: NO.
|
|
||||||
# This tag requires that the tag GENERATE_LATEX is set to YES.
|
|
||||||
|
|
||||||
LATEX_SOURCE_CODE = NO
|
|
||||||
|
|
||||||
# The LATEX_BIB_STYLE tag can be used to specify the style to use for the
|
# The LATEX_BIB_STYLE tag can be used to specify the style to use for the
|
||||||
# bibliography, e.g. plainnat, or ieeetr. See
|
# bibliography, e.g. plainnat, or ieeetr. See
|
||||||
# https://en.wikipedia.org/wiki/BibTeX and \cite for more info.
|
# https://en.wikipedia.org/wiki/BibTeX and \cite for more info.
|
||||||
|
@ -1901,16 +1883,6 @@ RTF_STYLESHEET_FILE =
|
||||||
|
|
||||||
RTF_EXTENSIONS_FILE =
|
RTF_EXTENSIONS_FILE =
|
||||||
|
|
||||||
# If the RTF_SOURCE_CODE tag is set to YES then doxygen will include source code
|
|
||||||
# with syntax highlighting in the RTF output.
|
|
||||||
#
|
|
||||||
# Note that which sources are shown also depends on other settings such as
|
|
||||||
# SOURCE_BROWSER.
|
|
||||||
# The default value is: NO.
|
|
||||||
# This tag requires that the tag GENERATE_RTF is set to YES.
|
|
||||||
|
|
||||||
RTF_SOURCE_CODE = NO
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
# Configuration options related to the man page output
|
# Configuration options related to the man page output
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
|
@ -2007,15 +1979,6 @@ GENERATE_DOCBOOK = NO
|
||||||
|
|
||||||
DOCBOOK_OUTPUT = docbook
|
DOCBOOK_OUTPUT = docbook
|
||||||
|
|
||||||
# If the DOCBOOK_PROGRAMLISTING tag is set to YES, doxygen will include the
|
|
||||||
# program listings (including syntax highlighting and cross-referencing
|
|
||||||
# information) to the DOCBOOK output. Note that enabling this will significantly
|
|
||||||
# increase the size of the DOCBOOK output.
|
|
||||||
# The default value is: NO.
|
|
||||||
# This tag requires that the tag GENERATE_DOCBOOK is set to YES.
|
|
||||||
|
|
||||||
DOCBOOK_PROGRAMLISTING = NO
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
# Configuration options for the AutoGen Definitions output
|
# Configuration options for the AutoGen Definitions output
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
|
@ -2204,15 +2167,6 @@ EXTERNAL_PAGES = YES
|
||||||
# Configuration options related to the dot tool
|
# Configuration options related to the dot tool
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
# If the CLASS_DIAGRAMS tag is set to YES, doxygen will generate a class diagram
|
|
||||||
# (in HTML and LaTeX) for classes with base or super classes. Setting the tag to
|
|
||||||
# NO turns the diagrams off. Note that this option also works with HAVE_DOT
|
|
||||||
# disabled, but it is recommended to install and use dot, since it yields more
|
|
||||||
# powerful graphs.
|
|
||||||
# The default value is: YES.
|
|
||||||
|
|
||||||
CLASS_DIAGRAMS = YES
|
|
||||||
|
|
||||||
# You can include diagrams made with dia in doxygen documentation. Doxygen will
|
# You can include diagrams made with dia in doxygen documentation. Doxygen will
|
||||||
# then run dia to produce the diagram and insert it in the documentation. The
|
# then run dia to produce the diagram and insert it in the documentation. The
|
||||||
# DIA_PATH tag allows you to specify the directory where the dia binary resides.
|
# DIA_PATH tag allows you to specify the directory where the dia binary resides.
|
||||||
|
|
|
@ -104,9 +104,8 @@ integration by libwayland-egl, and keyboard handling by
|
||||||
from wayland-protocols to provide additional features if the compositor
|
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)
|
||||||
|
|
139
docs/compile.dox
139
docs/compile.dox
|
@ -10,8 +10,8 @@ build applications that use GLFW, see @ref build_guide.
|
||||||
|
|
||||||
@section compile_cmake Using CMake
|
@section compile_cmake Using CMake
|
||||||
|
|
||||||
@note GLFW behaves like most other libraries that use CMake so this guide mostly
|
GLFW behaves like most other libraries that use CMake so this guide mostly
|
||||||
describes the basic configure/generate/compile sequence. If you are already
|
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
|
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.
|
compile_deps and @ref compile_options sections for GLFW-specific information.
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ all necessary dependencies for compiling GLFW, but on Unix-like systems like
|
||||||
Linux and FreeBSD you will need a few extra packages.
|
Linux and FreeBSD you will need a few extra packages.
|
||||||
|
|
||||||
|
|
||||||
@subsubsection compile_deps_x11 Dependencies for X11 on Unix-like systems
|
@subsubsection compile_deps_x11 Dependencies for X11
|
||||||
|
|
||||||
To compile GLFW for X11, you need to have the X11 development packages
|
To compile GLFW for X11, you need to have the X11 development packages
|
||||||
installed. They are not needed to build or run programs that use GLFW.
|
installed. They are not needed to build or run programs that use GLFW.
|
||||||
|
@ -68,40 +68,47 @@ install the `xorgproto` package.
|
||||||
pkg install xorgproto
|
pkg install xorgproto
|
||||||
@endcode
|
@endcode
|
||||||
|
|
||||||
On Cygwin the `xorgproto` package in the Devel section of the GUI installer will
|
On Cygwin the `libXcursor-devel`, `libXi-devel`, `libXinerama-devel`,
|
||||||
install the headers and other development related files for all of X11.
|
`libXrandr-devel` and `libXrender-devel` packages in the Libs section of the GUI
|
||||||
|
installer will install all the headers and other development related files GLFW
|
||||||
|
requires for X11.
|
||||||
|
|
||||||
Once you have the required depdendencies, move on to @ref compile_generate.
|
Once you have the required dependencies, move on to @ref compile_generate.
|
||||||
|
|
||||||
|
|
||||||
@subsubsection compile_deps_wayland Dependencies for Wayland on Unix-like systems
|
@subsubsection compile_deps_wayland Dependencies for Wayland and X11
|
||||||
|
|
||||||
To compile GLFW for Wayland, you need to have the Wayland and xkbcommon
|
To compile GLFW for both Wayland and X11, you need to have the X11, Wayland and xkbcommon
|
||||||
development packages installed. They are not needed to build or run programs
|
development packages installed. They are not needed to build or run programs that use
|
||||||
that use GLFW.
|
GLFW. You will also need to set the @ref GLFW_BUILD_WAYLAND CMake option in the next
|
||||||
|
step when generating build files.
|
||||||
|
|
||||||
On Debian and derivates like Ubuntu and Linux Mint you will need the
|
On Debian and derivates like Ubuntu and Linux Mint you will need the `libwayland-dev`,
|
||||||
`libwayland-dev`, `libxkbcommon-dev` and `wayland-protocols` packages.
|
`libxkbcommon-dev` and `wayland-protocols` packages and the `xorg-dev` meta-package.
|
||||||
|
These will pull in all other dependencies.
|
||||||
|
|
||||||
@code{.sh}
|
@code{.sh}
|
||||||
sudo apt install libwayland-dev libxkbcommon-dev wayland-protocols
|
sudo apt install libwayland-dev libxkbcommon-dev wayland-protocols xorg-dev
|
||||||
@endcode
|
@endcode
|
||||||
|
|
||||||
On Fedora and derivatives like Red Hat you will need the `wayland-devel`,
|
On Fedora and derivatives like Red Hat you will need the `wayland-devel`,
|
||||||
`libxkbcommon-devel` and `wayland-protocols-devel` packages.
|
`libxkbcommon-devel`, `wayland-protocols-devel`, `libXcursor-devel`, `libXi-devel`,
|
||||||
|
`libXinerama-devel` and `libXrandr-devel` packages. These will pull in all other
|
||||||
|
dependencies.
|
||||||
|
|
||||||
@code{.sh}
|
@code{.sh}
|
||||||
sudo dnf install wayland-devel libxkbcommon-devel wayland-protocols-devel
|
sudo dnf install wayland-devel libxkbcommon-devel wayland-protocols-devel libXcursor-devel libXi-devel libXinerama-devel libXrandr-devel
|
||||||
@endcode
|
@endcode
|
||||||
|
|
||||||
On FreeBSD you will need the `wayland`, `libxkbcommon` and `wayland-protocols`
|
On FreeBSD you will need the `wayland`, `libxkbcommon` and `wayland-protocols` packages.
|
||||||
packages.
|
The X11 headers are installed along the end-user X11 packages, so if you have an X server
|
||||||
|
running you should have the headers as well. If not, install the `xorgproto` package.
|
||||||
|
|
||||||
@code{.sh}
|
@code{.sh}
|
||||||
pkg install wayland libxkbcommon wayland-protocols
|
pkg install wayland libxkbcommon wayland-protocols xorgproto
|
||||||
@endcode
|
@endcode
|
||||||
|
|
||||||
Once you have the required depdendencies, move on to @ref compile_generate.
|
Once you have the required dependencies, move on to @ref compile_generate.
|
||||||
|
|
||||||
|
|
||||||
@subsection compile_generate Generating build files with CMake
|
@subsection compile_generate Generating build files with CMake
|
||||||
|
@ -126,7 +133,7 @@ A common pattern when building a single configuration is to have a build
|
||||||
directory named `build` in the root of the source tree.
|
directory named `build` in the root of the source tree.
|
||||||
|
|
||||||
|
|
||||||
@subsubsection compile_generate_gui Generating files with the CMake GUI
|
@subsubsection compile_generate_gui Generating with the CMake GUI
|
||||||
|
|
||||||
Start the CMake GUI and set the paths to the source and build directories
|
Start the CMake GUI and set the paths to the source and build directories
|
||||||
described above. Then press _Configure_ and _Generate_.
|
described above. Then press _Configure_ and _Generate_.
|
||||||
|
@ -135,15 +142,15 @@ If you wish change any CMake variables in the list, press _Configure_ and then
|
||||||
_Generate_ to have the new values take effect. The variable list will be
|
_Generate_ to have the new values take effect. The variable list will be
|
||||||
populated after the first configure step.
|
populated after the first configure step.
|
||||||
|
|
||||||
By default GLFW will use X11 on Linux and other Unix-like systems other
|
By default GLFW will use X11 on Linux and other Unix-like systems other than macOS. To
|
||||||
than macOS. To use Wayland instead, set the `GLFW_USE_WAYLAND` option in the
|
include support for Wayland as well, set the @ref GLFW_BUILD_WAYLAND option in the GLFW
|
||||||
GLFW section of the variable list, then apply the new value as described above.
|
section of the variable list, then apply the new value as described above.
|
||||||
|
|
||||||
Once you have generated the project files or makefiles for your chosen
|
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_cli Generating files with the CMake command-line tool
|
@subsubsection compile_generate_cli Generating with command-line CMake
|
||||||
|
|
||||||
To make a build directory, pass the source and build directories to the `cmake`
|
To make a build directory, pass the source and build directories to the `cmake`
|
||||||
command. These can be relative or absolute paths. The build directory is
|
command. These can be relative or absolute paths. The build directory is
|
||||||
|
@ -170,10 +177,11 @@ cmake -S path/to/glfw -B path/to/build -G Xcode
|
||||||
@endcode
|
@endcode
|
||||||
|
|
||||||
By default GLFW will use X11 on Linux and other Unix-like systems other
|
By default GLFW will use X11 on Linux and other Unix-like systems other
|
||||||
than macOS. To use Wayland instead, set the `GLFW_USE_WAYLAND` CMake option.
|
than macOS. To also include support for Wayland, set the @ref GLFW_BUILD_WAYLAND CMake
|
||||||
|
option.
|
||||||
|
|
||||||
@code{.sh}
|
@code{.sh}
|
||||||
cmake -S path/to/glfw -B path/to/build -D GLFW_USE_WAYLAND=1
|
cmake -S path/to/glfw -B path/to/build -D GLFW_BUILD_WAYLAND=1
|
||||||
@endcode
|
@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
|
||||||
|
@ -239,9 +247,18 @@ cmake -S path/to/glfw -B path/to/build -D BUILD_SHARED_LIBS=ON
|
||||||
@subsection 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. This is disabled by
|
a DLL / shared library / dynamic library. This is disabled by default,
|
||||||
default, producing a static GLFW library.
|
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
|
||||||
|
@ -258,12 +275,13 @@ __GLFW_BUILD_DOCS__ determines whether the GLFW documentation is built along
|
||||||
with the library. This is enabled by default if
|
with the library. This is enabled by default if
|
||||||
[Doxygen](https://www.doxygen.nl/) is found by CMake during configuration.
|
[Doxygen](https://www.doxygen.nl/) is found by CMake during configuration.
|
||||||
|
|
||||||
@anchor GLFW_VULKAN_STATIC
|
|
||||||
__GLFW_VULKAN_STATIC__ determines whether to use the Vulkan loader linked
|
|
||||||
directly with the application. This is disabled by default.
|
|
||||||
|
|
||||||
|
@subsection compile_options_win32 Win32 specific CMake options
|
||||||
|
|
||||||
@subsection compile_options_win32 Windows specific CMake options
|
@anchor GLFW_BUILD_WIN32
|
||||||
|
__GLFW_BUILD_WIN32__ determines whether to include support for Win32 when compiling the
|
||||||
|
library. This option is only available when compiling for Windows. This is enabled by
|
||||||
|
default.
|
||||||
|
|
||||||
@anchor USE_MSVC_RUNTIME_LIBRARY_DLL
|
@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
|
||||||
|
@ -283,12 +301,25 @@ will not work if GLFW is built as a DLL. This is disabled by default, letting
|
||||||
the operating system and driver decide.
|
the operating system and driver decide.
|
||||||
|
|
||||||
|
|
||||||
@subsection compile_options_wayland Wayland specific CMake options
|
@subsection compile_options_macos macOS specific CMake options
|
||||||
|
|
||||||
@anchor GLFW_USE_WAYLAND
|
@anchor GLFW_BUILD_COCOA
|
||||||
__GLFW_USE_WAYLAND__ determines whether to compile the library for Wayland.
|
__GLFW_BUILD_COCOA__ determines whether to include support for Cocoa when compiling the
|
||||||
This option is only available on Linux and other Unix-like systems other than
|
library. This option is only available when compiling for macOS. This is enabled by
|
||||||
macOS. This is disabled by default.
|
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
|
@section compile_mingw_cross Cross-compilation with CMake and MinGW
|
||||||
|
@ -326,34 +357,30 @@ For more details see the
|
||||||
|
|
||||||
@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 is
|
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
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1 +1,7 @@
|
||||||
{"version":3,"sourceRoot":"","sources":["extra.scss"],"names":[],"mappings":"AA8EA,4GACI,gBACA,iBAGJ,yBACC,yDAGD,6HACC,sDAGD,yIACC,sDAGD,mBACI,WA9EuB,KA+EvB,iBAGJ,uBACC,MAzFoB,QA0FjB,iBAGJ,6UACC,gBAGD,mJACC,YAGD,yHACC,iBAGD,sBACC,gBAGD,4LACC,UAGD,yCACC,aAGD,kMACC,WAnHgC,QAsHjC,KACC,MA1HoB,QA6HrB,sDACC,MA/Ge,QAgHf,mBAGD,GACE,iBACA,eAGF,GACE,iBACA,gBACA,eAGF,GACE,iBACA,gBACA,eAGF,YACC,eACA,gBACA,gBACA,eACA,cAEA,aACA,mBACA,eACA,2BACA,mBACA,sBAGD,UACC,iBACA,mBACA,MA/J0B,KAgK1B,gBACA,qEAGD,YACC,qBACA,kBACA,YAGD,yBACC,WAGD,oCACC,iBACA,gBACA,cACA,MAlL0B,KAqL3B,YACC,eAGD,8CACC,qBAGD,mBACC,MA9L0B,KAiM3B,eACC,kBACA,YACA,eAGD,KACC,WAxM0B,KA2M3B,UACC,gBACA,cACA,eAGD,WACC,gBACA,cACA,eAGD,UACI,aAGJ,mBACI,iBACA,iBAGJ,WACC,gBACA,aACA,mBACA,eACA,2BACA,mBACA,sBAGD,mEACC,MA9OgC,QAiPjC,gCACC,MArPoB,QAwPrB,sCACC,MAjOoB,KAoOrB,yBACC,kBAGD,UACC,iBAGD,wBACC,gBACA,cACA,eACA,qBAGD,uDACC,gEACA,+BACA,+BACA,gBACA,MArPgB,KAwPjB,mBACC,MA5PoB,KA6PpB,aACA,kBACA,yBAGD,QACC,WACA,WAGD,WACC,iBAGD,WACC,mBAGD,WACC,cACA,eACA,qBAGD,oCACC,gEACA,kCACA,2BACA,MAlSe,QAmSf,yBACA,kBAGD,WACC,MA3QuB,QA8QxB,cACC,sBACA,2BACA,4BACA,mBAGD,cACC,sBACA,+BACA,8BACA,gBAGD,mCACC,wBACA,iBACA,sBACA,kBAGD,gIACC,MAxToB,KAyTpB,qBAGD,cACC,wBACA,iBACA,sBACA,kBAGD,iBACC,WACA,4EAGD,oCApSC,gEACA,kCACA,cACA,yBAqSD,wBAxSC,gEACA,kCACA,cACA,yBAySD,qBA5SC,gEACA,kCACA,cACA,yBA6SD,gBAhTC,gEACA,kCACA,cACA,yBAiTD,iGACC,kBACA,YACA,2BACA,aAGD,kRACC,cAGD,SACC,oBAGD,0BACC,mBACA,kBACA,YACA,YACA,cACA,2BACA,aAGD,+CACC,MA1YoB,QA6YrB,+BACC,cAGD,sBACC,cAGD,+CACC,cACA,iBAGD,mBACC,cAGD,KACC,aACA","file":"extra.css"}
|
{
|
||||||
|
"version": 3,
|
||||||
|
"mappings": "AA8EA,2GAA4G,CAC3G,UAAU,CAAC,IAAI,CACf,WAAW,CAAC,IAAI,CAGjB,wBAAyB,CACxB,YAAY,CAAC,2CAAsD,CAGpE,4HAA6H,CAC5H,YAAY,CAAC,wCAAuD,CAGrE,wIAAyI,CACxI,YAAY,CAAC,wCAAuD,CAGrE,kBAAmB,CAClB,UAAU,CA9EgB,IAAa,CA+EvC,WAAW,CAAC,IAAI,CAGjB,sBAAuB,CACtB,KAAK,CAzFe,OAAa,CA0FjC,WAAW,CAAC,IAAI,CAGjB,4UAA6U,CAC5U,UAAU,CAAC,IAAI,CAGhB,kJAAmJ,CAClJ,MAAM,CAAC,IAAI,CAGZ,wHAAyH,CACxH,WAAW,CAAC,IAAI,CAGjB,qBAAsB,CACrB,UAAU,CAAC,IAAI,CAGhB,2LAA4L,CAC3L,OAAO,CAAC,CAAC,CAGV,wCAAyC,CACxC,OAAO,CAAC,IAAI,CAGb,iMAAkM,CACjM,UAAU,CApGW,OAA+B,CAuGrD,IAAK,CACJ,KAAK,CA1He,OAAa,CA6HlC,SAAU,CACN,SAAS,CAAE,IAAI,CACf,MAAM,CAAE,aAAa,CAGzB,qDAAsD,CACrD,KAAK,CApHU,OAAa,CAqH5B,aAAa,CAAC,IAAI,CAGnB,EAAG,CACF,WAAW,CAAC,KAAK,CACjB,SAAS,CAAC,IAAI,CAGf,EAAG,CACF,WAAW,CAAC,KAAK,CACjB,aAAa,CAAC,CAAC,CACf,SAAS,CAAC,IAAI,CAGf,EAAG,CACF,WAAW,CAAC,KAAK,CACjB,aAAa,CAAC,CAAC,CACf,SAAS,CAAC,IAAI,CAGf,WAAY,CACX,SAAS,CAAC,IAAI,CACd,UAAU,CAAC,IAAI,CACf,SAAS,CAAC,KAAK,CACf,OAAO,CAAC,MAAM,CACd,MAAM,CAAC,MAAM,CAEb,OAAO,CAAE,IAAI,CACb,cAAc,CAAE,GAAG,CACnB,SAAS,CAAE,IAAI,CACf,eAAe,CAAE,UAAU,CAC3B,WAAW,CAAE,MAAM,CACnB,aAAa,CAAE,OAAO,CAGvB,SAAU,CACT,WAAW,CAAC,IAAI,CAChB,aAAa,CAAC,IAAI,CAClB,KAAK,CApKqB,IAAa,CAqKvC,SAAS,CAAC,KAAK,CACf,UAAU,CAAC,yDAAyD,CAGrE,WAAY,CACX,eAAe,CAAC,IAAI,CACpB,MAAM,CAAC,UAAU,CACjB,KAAK,CAAC,KAAK,CAGZ,wBAAyB,CACxB,KAAK,CAAC,IAAI,CAGX,mCAAoC,CACnC,WAAW,CAAC,IAAI,CAChB,WAAW,CAAC,GAAG,CACf,OAAO,CAAC,KAAK,CACb,KAAK,CAvLqB,IAAa,CA0LxC,WAAY,CACX,YAAY,CAAE,CAAC,CAGhB,6CAA8C,CAC7C,UAAU,CAAC,SAAS,CAGrB,kBAAmB,CAClB,KAAK,CAnMqB,IAAa,CAsMxC,cAAe,CACd,UAAU,CAAC,MAAM,CACjB,OAAO,CAAC,GAAG,CACX,UAAU,CAAC,GAAG,CAGf,IAAK,CACJ,UAAU,CA7MgB,IAAa,CAgNxC,SAAU,CACT,SAAS,CAAC,KAAK,CACf,MAAM,CAAC,MAAM,CACb,SAAS,CAAC,IAAI,CAGf,UAAW,CACV,SAAS,CAAC,KAAK,CACf,MAAM,CAAC,MAAM,CACb,SAAS,CAAC,IAAI,CAGf,SAAU,CACT,OAAO,CAAC,IAAI,CAGb,kBAAmB,CAClB,WAAW,CAAC,IAAI,CAChB,WAAW,CAAC,IAAI,CAGjB,UAAW,CACV,UAAU,CAAC,IAAI,CACf,OAAO,CAAE,IAAI,CACb,cAAc,CAAE,GAAG,CACnB,SAAS,CAAE,IAAI,CACf,eAAe,CAAE,UAAU,CAC3B,WAAW,CAAE,MAAM,CACnB,aAAa,CAAE,OAAO,CAGvB,kEAAmE,CAClE,KAAK,CApOgB,OAA+B,CAuOrD,+BAAgC,CAC/B,KAAK,CA1Pe,OAAa,CA6PlC,qCAAsC,CACrC,KAAK,CA1NoB,IAAsB,CA6NhD,wBAA2B,CAC1B,MAAM,CAAE,UAAU,CAGnB,SAAU,CACT,UAAU,CAAC,KAAK,CAGjB,uBAAwB,CACvB,SAAS,CAAC,KAAK,CACf,MAAM,CAAC,MAAM,CACb,OAAO,CAAC,MAAM,CACd,UAAU,CAAC,SAA8B,CAG1C,sDAAuD,CACtD,UAAU,CAAC,iDAAoF,CAC/F,UAAU,CAAC,mBAAuC,CAClD,WAAW,CAAC,kBAAgD,CAC5D,UAAU,CAAC,IAAI,CACf,KAAK,CAlPa,IAAe,CAqPlC,kBAAmB,CAClB,KAAK,CArPoB,IAAsB,CAsP/C,OAAO,CAAC,IAAI,CACZ,aAAa,CAAC,GAAG,CACjB,gBAAgB,CAAC,OAAiC,CAGnD,OAAQ,CACP,KAAK,CAAC,KAAK,CACX,KAAK,CAAC,GAAG,CAGV,oCAAoC,CACnC,OAAQ,CACP,KAAK,CAAC,IAAI,CACV,KAAK,CAAC,OAAO,CACb,MAAM,CAAC,CAAC,EAIV,UAAW,CACV,SAAS,CAAC,MAAM,CAGjB,UAAW,CACV,YAAY,CAAC,KAAK,CAGnB,UAAW,CACV,SAAS,CAAC,GAAG,CACb,YAAY,CAAC,CAAC,CACd,eAAe,CAAC,IAAI,CAIjB,mCAAqB,CACjB,WAAW,CAAC,KAAK,CAIzB,mCAAoC,CACnC,UAAU,CAAC,oDAAgF,CAC3F,UAAU,CAAC,sBAAqC,CAChD,WAAW,CAAC,cAA8C,CAC1D,KAAK,CArTU,OAAa,CAsT5B,MAAM,CAAC,iBAAgC,CACvC,aAAa,CAAC,GAAG,CAGlB,UAAW,CACV,KAAK,CA9RkB,OAAgC,CAiSxD,aAAc,CACb,MAAM,CAAC,cAA+B,CACtC,sBAAsB,CAAC,GAAG,CAC1B,uBAAuB,CAAC,GAAG,CAC3B,aAAa,CAAC,IAAI,CAGnB,aAAc,CACb,MAAM,CAAC,cAA+B,CACtC,0BAA0B,CAAC,GAAG,CAC9B,yBAAyB,CAAC,GAAG,CAC7B,UAAU,CAAC,IAAI,CAGhB,kCAAmC,CAClC,eAAe,CAAC,OAAO,CACvB,cAAc,CAAC,CAAC,CAChB,MAAM,CAAC,cAA+B,CACtC,aAAa,CAAC,GAAG,CAGlB,+HAAgI,CAC/H,KAAK,CA/ToB,IAAsB,CAgU/C,eAAe,CAAC,IAAI,CAGrB,aAAc,CACb,eAAe,CAAC,OAAO,CACvB,cAAc,CAAC,CAAC,CAChB,MAAM,CAAC,cAA+B,CACtC,aAAa,CAAC,GAAG,CAGlB,gBAAiB,CAChB,MAAM,CAAC,GAAG,CACV,UAAU,CAAC,gEAAiH,CAG7H,mCAAoC,CAvTnC,UAAU,CAAC,oDAAuE,CAClF,UAAU,CAAC,sBAAsC,CACjD,KAAK,CAAC,OAAwB,CAC9B,MAAM,CAAC,iBAAmD,CAwT3D,uBAAwB,CA3TvB,UAAU,CAAC,oDAAuE,CAClF,UAAU,CAAC,sBAAsC,CACjD,KAAK,CAAC,OAAwB,CAC9B,MAAM,CAAC,iBAAmD,CA4T3D,oBAAqB,CA/TpB,UAAU,CAAC,oDAAuE,CAClF,UAAU,CAAC,sBAAsC,CACjD,KAAK,CAAC,OAAwB,CAC9B,MAAM,CAAC,iBAAmD,CAgU3D,eAAgB,CAnUf,UAAU,CAAC,oDAAuE,CAClF,UAAU,CAAC,sBAAsC,CACjD,KAAK,CAAC,OAAwB,CAC9B,MAAM,CAAC,iBAAmD,CAoU3D,gGAAiG,CAChG,aAAa,CAAC,GAAG,CACjB,OAAO,CAAC,GAAG,CACX,WAAW,CAAC,cAAwB,CACpC,MAAM,CAAC,KAAK,CAGb,iRAAkR,CACjR,KAAK,CAAC,OAAO,CAGd,QAAS,CACR,WAAW,CAAC,OAAO,CAGpB,yBAA0B,CACzB,UAAU,CAAC,OAAa,CACxB,aAAa,CAAC,GAAG,CACjB,MAAM,CAAC,IAAI,CACX,OAAO,CAAC,GAAG,CACX,QAAQ,CAAC,IAAI,CACb,WAAW,CAAC,cAAuB,CACnC,MAAM,CAAC,KAAK,CAGb,8CAA+C,CAC9C,KAAK,CA7Ze,OAAa,CAgalC,8BAA+B,CAC9B,KAAK,CAAC,OAAiB,CAGxB,qBAAsB,CACrB,KAAK,CAAC,OAAgB,CAGvB,8CAA+C,CAC9C,KAAK,CAAC,OAA+B,CACrC,WAAW,CAAC,IAAI,CAGjB,kBAAmB,CAClB,KAAK,CAAC,OAAiB,CAGxB,IAAK,CACJ,OAAO,CAAC,IAAI,CACZ,aAAa,CAAC,GAAG",
|
||||||
|
"sources": ["extra.scss"],
|
||||||
|
"names": [],
|
||||||
|
"file": "extra.css"
|
||||||
|
}
|
||||||
|
|
|
@ -135,6 +135,11 @@ body {
|
||||||
color:$default-text-color;
|
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;
|
||||||
|
@ -142,13 +147,13 @@ h1,h2,h2.groupheader,h3,div.toc h3,h4,h5,h6,strong,em {
|
||||||
|
|
||||||
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 {
|
||||||
|
@ -293,8 +298,16 @@ dl.reflist dt a.el {
|
||||||
}
|
}
|
||||||
|
|
||||||
div.toc {
|
div.toc {
|
||||||
float:none;
|
float:right;
|
||||||
width:auto;
|
width:35%;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media screen and (max-width:600px) {
|
||||||
|
div.toc {
|
||||||
|
float:none;
|
||||||
|
width:inherit;
|
||||||
|
margin:0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
div.toc h3 {
|
div.toc h3 {
|
||||||
|
@ -311,6 +324,12 @@ 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;
|
||||||
|
|
|
@ -821,7 +821,7 @@ The second value is always the human-readable name of the gamepad.
|
||||||
All subsequent values are in the form `<field>:<value>` and describe the layout
|
All subsequent values are in the form `<field>:<value>` and describe the layout
|
||||||
of the mapping. These fields may not all be present and may occur in any order.
|
of the mapping. These fields may not all be present and may occur in any order.
|
||||||
|
|
||||||
The button fields are `a`, `b`, `c`, `d`, `back`, `start`, `guide`, `dpup`,
|
The button fields are `a`, `b`, `x`, `y`, `back`, `start`, `guide`, `dpup`,
|
||||||
`dpright`, `dpdown`, `dpleft`, `leftshoulder`, `rightshoulder`, `leftstick` and
|
`dpright`, `dpdown`, `dpleft`, `leftshoulder`, `rightshoulder`, `leftstick` and
|
||||||
`rightstick`.
|
`rightstick`.
|
||||||
|
|
||||||
|
|
|
@ -61,12 +61,21 @@ application-provided callbacks. It is also prohibited from modifying the
|
||||||
platform-independent part of the internal structs. Instead, it calls the event
|
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.
|
||||||
|
|
145
docs/intro.dox
145
docs/intro.dox
|
@ -30,9 +30,12 @@ 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,6 +91,15 @@ 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
|
||||||
|
@ -136,6 +148,7 @@ the `VK_KHR_xlib_surface` extension. Possible values are `GLFW_TRUE` and
|
||||||
|
|
||||||
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_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`
|
||||||
|
@ -143,6 +156,106 @@ Initialization hint | Default value | Supported v
|
||||||
@ref GLFW_X11_XCB_VULKAN_SURFACE | `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
|
||||||
|
|
||||||
Before your application exits, you should terminate the GLFW library if it has
|
Before your application exits, you should terminate the GLFW library if it has
|
||||||
|
@ -378,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
|
||||||
|
@ -470,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
|
||||||
- The name of the window system API
|
- For each supported platform:
|
||||||
- The name of the context creation API
|
- The name of the window system API
|
||||||
- Any additional options or APIs
|
- The name of the window system specific context creation API, if applicable
|
||||||
|
- The names of the always supported context creation APIs EGL and OSMesa
|
||||||
|
- Any additional compile-time options, APIs and (on Windows) what compiler was used
|
||||||
|
|
||||||
For example, when compiling GLFW 3.0 with MinGW using the Win32 and WGL
|
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
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -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
|
||||||
|
@ -44,6 +52,16 @@ requesting a specific rendering backend when using
|
||||||
contexts.
|
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
|
||||||
|
@ -53,7 +71,23 @@ 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
|
@subsubsection joysticks_34 Joystick support is initialized on demand
|
||||||
|
|
||||||
|
@ -104,10 +138,39 @@ GLFW_TRANSPARENT_FRAMEBUFFER on Windows 7 if DWM transparency is off
|
||||||
(the Transparency setting under Personalization > Window Color).
|
(the Transparency setting under Personalization > Window Color).
|
||||||
|
|
||||||
|
|
||||||
|
@subsubsection emptyevents_34 Empty events on X11 no longer roundtrip to server
|
||||||
|
|
||||||
|
Events posted with @ref glfwPostEmptyEvent now use a separate unnamed pipe
|
||||||
|
instead of sending an X11 client event to the helper window.
|
||||||
|
|
||||||
|
|
||||||
@subsection deprecations_34 Deprecations in version 3.4
|
@subsection 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
|
@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
|
Support for the wl_shell protocol has been removed and GLFW now only supports
|
||||||
|
@ -118,9 +181,31 @@ 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
|
||||||
|
|
|
@ -29,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
|
||||||
|
@ -66,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.
|
||||||
|
|
|
@ -447,7 +447,7 @@ The no error mode for OpenGL and OpenGL ES is described in detail by the
|
||||||
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
|
||||||
|
@ -455,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
|
||||||
|
|
|
@ -18,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"
|
||||||
|
@ -33,6 +33,7 @@ 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})
|
add_executable(windows WIN32 MACOSX_BUNDLE windows.c ${ICON} ${GLAD_GL})
|
||||||
|
|
||||||
|
@ -42,18 +43,13 @@ if (RT_LIBRARY)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(GUI_ONLY_BINARIES boing gears heightmap particles sharing splitview
|
set(GUI_ONLY_BINARIES boing gears heightmap particles sharing splitview
|
||||||
triangle-opengl wave windows)
|
triangle-opengl 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
|
||||||
C_STANDARD 99
|
C_STANDARD 99
|
||||||
FOLDER "GLFW3/Examples")
|
FOLDER "GLFW3/Examples")
|
||||||
|
|
||||||
if (GLFW_USE_OSMESA)
|
|
||||||
find_package(OSMesa REQUIRED)
|
|
||||||
target_compile_definitions(offscreen PRIVATE USE_NATIVE_OSMESA)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if (MSVC)
|
if (MSVC)
|
||||||
# Tell MSVC to use main instead of WinMain
|
# Tell MSVC to use main instead of WinMain
|
||||||
set_target_properties(${GUI_ONLY_BINARIES} PROPERTIES
|
set_target_properties(${GUI_ONLY_BINARIES} PROPERTIES
|
||||||
|
@ -71,6 +67,7 @@ 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_target_properties(windows PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Windows")
|
||||||
|
|
|
@ -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>
|
||||||
|
|
|
@ -23,15 +23,11 @@
|
||||||
//
|
//
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
|
#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>
|
||||||
|
|
||||||
#if USE_NATIVE_OSMESA
|
|
||||||
#define GLFW_EXPOSE_NATIVE_OSMESA
|
|
||||||
#include <GLFW/glfw3native.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "linmath.h"
|
#include "linmath.h"
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
@ -150,12 +146,8 @@ int main(void)
|
||||||
glDrawArrays(GL_TRIANGLES, 0, 3);
|
glDrawArrays(GL_TRIANGLES, 0, 3);
|
||||||
glFinish();
|
glFinish();
|
||||||
|
|
||||||
#if USE_NATIVE_OSMESA
|
|
||||||
glfwGetOSMesaColorBuffer(window, &width, &height, NULL, (void**) &buffer);
|
|
||||||
#else
|
|
||||||
buffer = calloc(4, width * height);
|
buffer = calloc(4, width * height);
|
||||||
glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
|
glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
|
||||||
#endif
|
|
||||||
|
|
||||||
// Write image Y-flipped because OpenGL
|
// Write image Y-flipped because OpenGL
|
||||||
stbi_write_png("offscreen.png",
|
stbi_write_png("offscreen.png",
|
||||||
|
@ -163,11 +155,7 @@ int main(void)
|
||||||
buffer + (width * 4 * (height - 1)),
|
buffer + (width * 4 * (height - 1)),
|
||||||
-width * 4);
|
-width * 4);
|
||||||
|
|
||||||
#if USE_NATIVE_OSMESA
|
|
||||||
// Here is where there's nothing
|
|
||||||
#else
|
|
||||||
free(buffer);
|
free(buffer);
|
||||||
#endif
|
|
||||||
|
|
||||||
glfwDestroyWindow(window);
|
glfwDestroyWindow(window);
|
||||||
|
|
||||||
|
|
|
@ -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>
|
||||||
|
|
|
@ -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>
|
||||||
|
|
|
@ -190,6 +190,9 @@ extern "C" {
|
||||||
#else /*__APPLE__*/
|
#else /*__APPLE__*/
|
||||||
|
|
||||||
#include <GL/glcorearb.h>
|
#include <GL/glcorearb.h>
|
||||||
|
#if defined(GLFW_INCLUDE_GLEXT)
|
||||||
|
#include <GL/glext.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /*__APPLE__*/
|
#endif /*__APPLE__*/
|
||||||
|
|
||||||
|
@ -259,13 +262,12 @@ extern "C" {
|
||||||
/* We are building GLFW as a Win32 DLL */
|
/* We are building GLFW as a Win32 DLL */
|
||||||
#define GLFWAPI __declspec(dllexport)
|
#define GLFWAPI __declspec(dllexport)
|
||||||
#elif defined(_WIN32) && defined(GLFW_DLL)
|
#elif defined(_WIN32) && defined(GLFW_DLL)
|
||||||
/* We are calling GLFW as a Win32 DLL */
|
/* We are calling a GLFW Win32 DLL */
|
||||||
#define GLFWAPI __declspec(dllimport)
|
#define GLFWAPI __declspec(dllimport)
|
||||||
#elif defined(__GNUC__) && defined(_GLFW_BUILD_DLL)
|
#elif defined(__GNUC__) && defined(_GLFW_BUILD_DLL)
|
||||||
/* We are building GLFW as a shared / dynamic library */
|
/* We are building GLFW as a Unix shared library */
|
||||||
#define GLFWAPI __attribute__((visibility("default")))
|
#define GLFWAPI __attribute__((visibility("default")))
|
||||||
#else
|
#else
|
||||||
/* We are building or calling GLFW as a static library */
|
|
||||||
#define GLFWAPI
|
#define GLFWAPI
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -372,7 +374,7 @@ extern "C" {
|
||||||
*
|
*
|
||||||
* The naming of the key codes follow these rules:
|
* The naming of the key codes follow these rules:
|
||||||
* - The US keyboard layout is used
|
* - The US keyboard layout is used
|
||||||
* - Names of printable alpha-numeric characters are used (e.g. "A", "R",
|
* - Names of printable alphanumeric characters are used (e.g. "A", "R",
|
||||||
* "3", etc.)
|
* "3", etc.)
|
||||||
* - For non-alphanumeric characters, Unicode:ish names are used (e.g.
|
* - For non-alphanumeric characters, Unicode:ish names are used (e.g.
|
||||||
* "COMMA", "LEFT_SQUARE_BRACKET", etc.). Note that some names do not
|
* "COMMA", "LEFT_SQUARE_BRACKET", etc.). Note that some names do not
|
||||||
|
@ -717,7 +719,7 @@ extern "C" {
|
||||||
* GLFW could not find support for the requested API on the system.
|
* GLFW could not find support for the requested API on the system.
|
||||||
*
|
*
|
||||||
* @analysis The installed graphics driver does not support the requested
|
* @analysis The installed graphics driver does not support the requested
|
||||||
* API, or does not support it via the chosen context creation backend.
|
* API, or does not support it via the chosen context creation API.
|
||||||
* Below are a few examples.
|
* Below are a few examples.
|
||||||
*
|
*
|
||||||
* @par
|
* @par
|
||||||
|
@ -786,7 +788,7 @@ extern "C" {
|
||||||
/*! @brief The specified cursor shape is not available.
|
/*! @brief The specified cursor shape is not available.
|
||||||
*
|
*
|
||||||
* The specified standard cursor shape is not available, either because the
|
* The specified standard cursor shape is not available, either because the
|
||||||
* current system cursor theme does not provide it or because it is not
|
* current platform cursor theme does not provide it or because it is not
|
||||||
* available on the platform.
|
* available on the platform.
|
||||||
*
|
*
|
||||||
* @analysis Platform or system settings limitation. Pick another
|
* @analysis Platform or system settings limitation. Pick another
|
||||||
|
@ -821,6 +823,28 @@ extern "C" {
|
||||||
* updating any existing out parameters.
|
* updating any existing out parameters.
|
||||||
*/
|
*/
|
||||||
#define GLFW_FEATURE_UNIMPLEMENTED 0x0001000D
|
#define GLFW_FEATURE_UNIMPLEMENTED 0x0001000D
|
||||||
|
/*! @brief Platform unavailable or no matching platform was found.
|
||||||
|
*
|
||||||
|
* If emitted during initialization, no matching platform was found. If @ref
|
||||||
|
* GLFW_PLATFORM is set to `GLFW_ANY_PLATFORM`, GLFW could not detect any of the
|
||||||
|
* platforms supported by this library binary, except for the Null platform. If set to
|
||||||
|
* a specific platform, it is either not supported by this library binary or GLFW was not
|
||||||
|
* able to detect it.
|
||||||
|
*
|
||||||
|
* If emitted by a native access function, GLFW was initialized for a different platform
|
||||||
|
* than the function is for.
|
||||||
|
*
|
||||||
|
* @analysis Failure to detect any platform usually only happens on non-macOS Unix
|
||||||
|
* systems, either when no window system is running or the program was run from
|
||||||
|
* a terminal that does not have the necessary environment variables. Fall back to
|
||||||
|
* a different platform if possible or notify the user that no usable platform was
|
||||||
|
* detected.
|
||||||
|
*
|
||||||
|
* Failure to detect a specific platform may have the same cause as above or be because
|
||||||
|
* support for that platform was not compiled in. Call @ref glfwPlatformSupported to
|
||||||
|
* check whether a specific platform is supported by a library binary.
|
||||||
|
*/
|
||||||
|
#define GLFW_PLATFORM_UNAVAILABLE 0x0001000E
|
||||||
/*! @} */
|
/*! @} */
|
||||||
|
|
||||||
/*! @addtogroup window
|
/*! @addtogroup window
|
||||||
|
@ -1003,7 +1027,7 @@ extern "C" {
|
||||||
* and [attribute](@ref GLFW_CONTEXT_VERSION_MINOR_attrib).
|
* and [attribute](@ref GLFW_CONTEXT_VERSION_MINOR_attrib).
|
||||||
*/
|
*/
|
||||||
#define GLFW_CONTEXT_VERSION_MINOR 0x00022003
|
#define GLFW_CONTEXT_VERSION_MINOR 0x00022003
|
||||||
/*! @brief Context client API revision number hint and attribute.
|
/*! @brief Context client API revision number attribute.
|
||||||
*
|
*
|
||||||
* Context client API revision number
|
* Context client API revision number
|
||||||
* [attribute](@ref GLFW_CONTEXT_REVISION_attrib).
|
* [attribute](@ref GLFW_CONTEXT_REVISION_attrib).
|
||||||
|
@ -1125,7 +1149,7 @@ extern "C" {
|
||||||
* @brief Standard system cursor shapes.
|
* @brief Standard system cursor shapes.
|
||||||
*
|
*
|
||||||
* These are the [standard cursor shapes](@ref cursor_standard) that can be
|
* These are the [standard cursor shapes](@ref cursor_standard) that can be
|
||||||
* requested from the window system.
|
* requested from the platform (window system).
|
||||||
*
|
*
|
||||||
* @ingroup input
|
* @ingroup input
|
||||||
* @{ */
|
* @{ */
|
||||||
|
@ -1242,6 +1266,11 @@ extern "C" {
|
||||||
* ANGLE rendering backend [init hint](@ref GLFW_ANGLE_PLATFORM_TYPE_hint).
|
* ANGLE rendering backend [init hint](@ref GLFW_ANGLE_PLATFORM_TYPE_hint).
|
||||||
*/
|
*/
|
||||||
#define GLFW_ANGLE_PLATFORM_TYPE 0x00050002
|
#define GLFW_ANGLE_PLATFORM_TYPE 0x00050002
|
||||||
|
/*! @brief Platform selection init hint.
|
||||||
|
*
|
||||||
|
* Platform selection [init hint](@ref GLFW_PLATFORM).
|
||||||
|
*/
|
||||||
|
#define GLFW_PLATFORM 0x00050003
|
||||||
/*! @brief macOS specific init hint.
|
/*! @brief macOS specific init hint.
|
||||||
*
|
*
|
||||||
* macOS specific [init hint](@ref GLFW_COCOA_CHDIR_RESOURCES_hint).
|
* macOS specific [init hint](@ref GLFW_COCOA_CHDIR_RESOURCES_hint).
|
||||||
|
@ -1259,6 +1288,20 @@ extern "C" {
|
||||||
#define GLFW_X11_XCB_VULKAN_SURFACE 0x00052001
|
#define GLFW_X11_XCB_VULKAN_SURFACE 0x00052001
|
||||||
/*! @} */
|
/*! @} */
|
||||||
|
|
||||||
|
/*! @addtogroup init
|
||||||
|
* @{ */
|
||||||
|
/*! @brief Hint value that enables automatic platform selection.
|
||||||
|
*
|
||||||
|
* Hint value for @ref GLFW_PLATFORM that enables automatic platform selection.
|
||||||
|
*/
|
||||||
|
#define GLFW_ANY_PLATFORM 0x00060000
|
||||||
|
#define GLFW_PLATFORM_WIN32 0x00060001
|
||||||
|
#define GLFW_PLATFORM_COCOA 0x00060002
|
||||||
|
#define GLFW_PLATFORM_WAYLAND 0x00060003
|
||||||
|
#define GLFW_PLATFORM_X11 0x00060004
|
||||||
|
#define GLFW_PLATFORM_NULL 0x00060005
|
||||||
|
/*! @} */
|
||||||
|
|
||||||
#define GLFW_DONT_CARE -1
|
#define GLFW_DONT_CARE -1
|
||||||
|
|
||||||
|
|
||||||
|
@ -1330,6 +1373,131 @@ typedef struct GLFWwindow GLFWwindow;
|
||||||
*/
|
*/
|
||||||
typedef struct GLFWcursor GLFWcursor;
|
typedef struct GLFWcursor GLFWcursor;
|
||||||
|
|
||||||
|
/*! @brief The function pointer type for memory allocation callbacks.
|
||||||
|
*
|
||||||
|
* This is the function pointer type for memory allocation callbacks. A memory
|
||||||
|
* allocation callback function has the following signature:
|
||||||
|
* @code
|
||||||
|
* void* function_name(size_t size, void* user)
|
||||||
|
* @endcode
|
||||||
|
*
|
||||||
|
* This function must return either a memory block at least `size` bytes long,
|
||||||
|
* or `NULL` if allocation failed. Note that not all parts of GLFW handle allocation
|
||||||
|
* failures gracefully yet.
|
||||||
|
*
|
||||||
|
* This function may be called during @ref glfwInit but before the library is
|
||||||
|
* flagged as initialized, as well as during @ref glfwTerminate after the
|
||||||
|
* library is no longer flagged as initialized.
|
||||||
|
*
|
||||||
|
* Any memory allocated by this function will be deallocated during library
|
||||||
|
* termination or earlier.
|
||||||
|
*
|
||||||
|
* The size will always be greater than zero. Allocations of size zero are filtered out
|
||||||
|
* before reaching the custom allocator.
|
||||||
|
*
|
||||||
|
* @param[in] size The minimum size, in bytes, of the memory block.
|
||||||
|
* @param[in] user The user-defined pointer from the allocator.
|
||||||
|
* @return The address of the newly allocated memory block, or `NULL` if an
|
||||||
|
* error occurred.
|
||||||
|
*
|
||||||
|
* @pointer_lifetime The returned memory block must be valid at least until it
|
||||||
|
* is deallocated.
|
||||||
|
*
|
||||||
|
* @reentrancy This function should not call any GLFW function.
|
||||||
|
*
|
||||||
|
* @thread_safety This function may be called from any thread that calls GLFW functions.
|
||||||
|
*
|
||||||
|
* @sa @ref init_allocator
|
||||||
|
* @sa @ref GLFWallocator
|
||||||
|
*
|
||||||
|
* @since Added in version 3.4.
|
||||||
|
*
|
||||||
|
* @ingroup init
|
||||||
|
*/
|
||||||
|
typedef void* (* GLFWallocatefun)(size_t size, void* user);
|
||||||
|
|
||||||
|
/*! @brief The function pointer type for memory reallocation callbacks.
|
||||||
|
*
|
||||||
|
* This is the function pointer type for memory reallocation callbacks.
|
||||||
|
* A memory reallocation callback function has the following signature:
|
||||||
|
* @code
|
||||||
|
* void* function_name(void* block, size_t size, void* user)
|
||||||
|
* @endcode
|
||||||
|
*
|
||||||
|
* This function must return a memory block at least `size` bytes long, or
|
||||||
|
* `NULL` if allocation failed. Note that not all parts of GLFW handle allocation
|
||||||
|
* failures gracefully yet.
|
||||||
|
*
|
||||||
|
* This function may be called during @ref glfwInit but before the library is
|
||||||
|
* flagged as initialized, as well as during @ref glfwTerminate after the
|
||||||
|
* library is no longer flagged as initialized.
|
||||||
|
*
|
||||||
|
* Any memory allocated by this function will be deallocated during library
|
||||||
|
* termination or earlier.
|
||||||
|
*
|
||||||
|
* The block address will never be `NULL` and the size will always be greater than zero.
|
||||||
|
* Reallocations of a block to size zero are converted into deallocations. Reallocations
|
||||||
|
* of `NULL` to a non-zero size are converted into regular allocations.
|
||||||
|
*
|
||||||
|
* @param[in] block The address of the memory block to reallocate.
|
||||||
|
* @param[in] size The new minimum size, in bytes, of the memory block.
|
||||||
|
* @param[in] user The user-defined pointer from the allocator.
|
||||||
|
* @return The address of the newly allocated or resized memory block, or
|
||||||
|
* `NULL` if an error occurred.
|
||||||
|
*
|
||||||
|
* @pointer_lifetime The returned memory block must be valid at least until it
|
||||||
|
* is deallocated.
|
||||||
|
*
|
||||||
|
* @reentrancy This function should not call any GLFW function.
|
||||||
|
*
|
||||||
|
* @thread_safety This function may be called from any thread that calls GLFW functions.
|
||||||
|
*
|
||||||
|
* @sa @ref init_allocator
|
||||||
|
* @sa @ref GLFWallocator
|
||||||
|
*
|
||||||
|
* @since Added in version 3.4.
|
||||||
|
*
|
||||||
|
* @ingroup init
|
||||||
|
*/
|
||||||
|
typedef void* (* GLFWreallocatefun)(void* block, size_t size, void* user);
|
||||||
|
|
||||||
|
/*! @brief The function pointer type for memory deallocation callbacks.
|
||||||
|
*
|
||||||
|
* This is the function pointer type for memory deallocation callbacks.
|
||||||
|
* A memory deallocation callback function has the following signature:
|
||||||
|
* @code
|
||||||
|
* void function_name(void* block, void* user)
|
||||||
|
* @endcode
|
||||||
|
*
|
||||||
|
* This function may deallocate the specified memory block. This memory block
|
||||||
|
* will have been allocated with the same allocator.
|
||||||
|
*
|
||||||
|
* This function may be called during @ref glfwInit but before the library is
|
||||||
|
* flagged as initialized, as well as during @ref glfwTerminate after the
|
||||||
|
* library is no longer flagged as initialized.
|
||||||
|
*
|
||||||
|
* The block address will never be `NULL`. Deallocations of `NULL` are filtered out
|
||||||
|
* before reaching the custom allocator.
|
||||||
|
*
|
||||||
|
* @param[in] block The address of the memory block to deallocate.
|
||||||
|
* @param[in] user The user-defined pointer from the allocator.
|
||||||
|
*
|
||||||
|
* @pointer_lifetime The specified memory block will not be accessed by GLFW
|
||||||
|
* after this function is called.
|
||||||
|
*
|
||||||
|
* @reentrancy This function should not call any GLFW function.
|
||||||
|
*
|
||||||
|
* @thread_safety This function may be called from any thread that calls GLFW functions.
|
||||||
|
*
|
||||||
|
* @sa @ref init_allocator
|
||||||
|
* @sa @ref GLFWallocator
|
||||||
|
*
|
||||||
|
* @since Added in version 3.4.
|
||||||
|
*
|
||||||
|
* @ingroup init
|
||||||
|
*/
|
||||||
|
typedef void (* GLFWdeallocatefun)(void* block, void* user);
|
||||||
|
|
||||||
/*! @brief The function pointer type for error callbacks.
|
/*! @brief The function pointer type for error callbacks.
|
||||||
*
|
*
|
||||||
* This is the function pointer type for error callbacks. An error callback
|
* This is the function pointer type for error callbacks. An error callback
|
||||||
|
@ -1352,7 +1520,7 @@ typedef struct GLFWcursor GLFWcursor;
|
||||||
*
|
*
|
||||||
* @ingroup init
|
* @ingroup init
|
||||||
*/
|
*/
|
||||||
typedef void (* GLFWerrorfun)(int,const char*);
|
typedef void (* GLFWerrorfun)(int error_code, const char* description);
|
||||||
|
|
||||||
/*! @brief The function pointer type for window position callbacks.
|
/*! @brief The function pointer type for window position callbacks.
|
||||||
*
|
*
|
||||||
|
@ -1375,7 +1543,7 @@ typedef void (* GLFWerrorfun)(int,const char*);
|
||||||
*
|
*
|
||||||
* @ingroup window
|
* @ingroup window
|
||||||
*/
|
*/
|
||||||
typedef void (* GLFWwindowposfun)(GLFWwindow*,int,int);
|
typedef void (* GLFWwindowposfun)(GLFWwindow* window, int xpos, int ypos);
|
||||||
|
|
||||||
/*! @brief The function pointer type for window size callbacks.
|
/*! @brief The function pointer type for window size callbacks.
|
||||||
*
|
*
|
||||||
|
@ -1397,7 +1565,7 @@ typedef void (* GLFWwindowposfun)(GLFWwindow*,int,int);
|
||||||
*
|
*
|
||||||
* @ingroup window
|
* @ingroup window
|
||||||
*/
|
*/
|
||||||
typedef void (* GLFWwindowsizefun)(GLFWwindow*,int,int);
|
typedef void (* GLFWwindowsizefun)(GLFWwindow* window, int width, int height);
|
||||||
|
|
||||||
/*! @brief The function pointer type for window close callbacks.
|
/*! @brief The function pointer type for window close callbacks.
|
||||||
*
|
*
|
||||||
|
@ -1417,7 +1585,7 @@ typedef void (* GLFWwindowsizefun)(GLFWwindow*,int,int);
|
||||||
*
|
*
|
||||||
* @ingroup window
|
* @ingroup window
|
||||||
*/
|
*/
|
||||||
typedef void (* GLFWwindowclosefun)(GLFWwindow*);
|
typedef void (* GLFWwindowclosefun)(GLFWwindow* window);
|
||||||
|
|
||||||
/*! @brief The function pointer type for window content refresh callbacks.
|
/*! @brief The function pointer type for window content refresh callbacks.
|
||||||
*
|
*
|
||||||
|
@ -1437,7 +1605,7 @@ typedef void (* GLFWwindowclosefun)(GLFWwindow*);
|
||||||
*
|
*
|
||||||
* @ingroup window
|
* @ingroup window
|
||||||
*/
|
*/
|
||||||
typedef void (* GLFWwindowrefreshfun)(GLFWwindow*);
|
typedef void (* GLFWwindowrefreshfun)(GLFWwindow* window);
|
||||||
|
|
||||||
/*! @brief The function pointer type for window focus callbacks.
|
/*! @brief The function pointer type for window focus callbacks.
|
||||||
*
|
*
|
||||||
|
@ -1458,7 +1626,7 @@ typedef void (* GLFWwindowrefreshfun)(GLFWwindow*);
|
||||||
*
|
*
|
||||||
* @ingroup window
|
* @ingroup window
|
||||||
*/
|
*/
|
||||||
typedef void (* GLFWwindowfocusfun)(GLFWwindow*,int);
|
typedef void (* GLFWwindowfocusfun)(GLFWwindow* window, int focused);
|
||||||
|
|
||||||
/*! @brief The function pointer type for window iconify callbacks.
|
/*! @brief The function pointer type for window iconify callbacks.
|
||||||
*
|
*
|
||||||
|
@ -1479,7 +1647,7 @@ typedef void (* GLFWwindowfocusfun)(GLFWwindow*,int);
|
||||||
*
|
*
|
||||||
* @ingroup window
|
* @ingroup window
|
||||||
*/
|
*/
|
||||||
typedef void (* GLFWwindowiconifyfun)(GLFWwindow*,int);
|
typedef void (* GLFWwindowiconifyfun)(GLFWwindow* window, int iconified);
|
||||||
|
|
||||||
/*! @brief The function pointer type for window maximize callbacks.
|
/*! @brief The function pointer type for window maximize callbacks.
|
||||||
*
|
*
|
||||||
|
@ -1500,7 +1668,7 @@ typedef void (* GLFWwindowiconifyfun)(GLFWwindow*,int);
|
||||||
*
|
*
|
||||||
* @ingroup window
|
* @ingroup window
|
||||||
*/
|
*/
|
||||||
typedef void (* GLFWwindowmaximizefun)(GLFWwindow*,int);
|
typedef void (* GLFWwindowmaximizefun)(GLFWwindow* window, int maximized);
|
||||||
|
|
||||||
/*! @brief The function pointer type for framebuffer size callbacks.
|
/*! @brief The function pointer type for framebuffer size callbacks.
|
||||||
*
|
*
|
||||||
|
@ -1521,7 +1689,7 @@ typedef void (* GLFWwindowmaximizefun)(GLFWwindow*,int);
|
||||||
*
|
*
|
||||||
* @ingroup window
|
* @ingroup window
|
||||||
*/
|
*/
|
||||||
typedef void (* GLFWframebuffersizefun)(GLFWwindow*,int,int);
|
typedef void (* GLFWframebuffersizefun)(GLFWwindow* window, int width, int height);
|
||||||
|
|
||||||
/*! @brief The function pointer type for window content scale callbacks.
|
/*! @brief The function pointer type for window content scale callbacks.
|
||||||
*
|
*
|
||||||
|
@ -1542,7 +1710,7 @@ typedef void (* GLFWframebuffersizefun)(GLFWwindow*,int,int);
|
||||||
*
|
*
|
||||||
* @ingroup window
|
* @ingroup window
|
||||||
*/
|
*/
|
||||||
typedef void (* GLFWwindowcontentscalefun)(GLFWwindow*,float,float);
|
typedef void (* GLFWwindowcontentscalefun)(GLFWwindow* window, float xscale, float yscale);
|
||||||
|
|
||||||
/*! @brief The function pointer type for mouse button callbacks.
|
/*! @brief The function pointer type for mouse button callbacks.
|
||||||
*
|
*
|
||||||
|
@ -1568,7 +1736,7 @@ typedef void (* GLFWwindowcontentscalefun)(GLFWwindow*,float,float);
|
||||||
*
|
*
|
||||||
* @ingroup input
|
* @ingroup input
|
||||||
*/
|
*/
|
||||||
typedef void (* GLFWmousebuttonfun)(GLFWwindow*,int,int,int);
|
typedef void (* GLFWmousebuttonfun)(GLFWwindow* window, int button, int action, int mods);
|
||||||
|
|
||||||
/*! @brief The function pointer type for cursor position callbacks.
|
/*! @brief The function pointer type for cursor position callbacks.
|
||||||
*
|
*
|
||||||
|
@ -1591,7 +1759,7 @@ typedef void (* GLFWmousebuttonfun)(GLFWwindow*,int,int,int);
|
||||||
*
|
*
|
||||||
* @ingroup input
|
* @ingroup input
|
||||||
*/
|
*/
|
||||||
typedef void (* GLFWcursorposfun)(GLFWwindow*,double,double);
|
typedef void (* GLFWcursorposfun)(GLFWwindow* window, double xpos, double ypos);
|
||||||
|
|
||||||
/*! @brief The function pointer type for cursor enter/leave callbacks.
|
/*! @brief The function pointer type for cursor enter/leave callbacks.
|
||||||
*
|
*
|
||||||
|
@ -1612,7 +1780,7 @@ typedef void (* GLFWcursorposfun)(GLFWwindow*,double,double);
|
||||||
*
|
*
|
||||||
* @ingroup input
|
* @ingroup input
|
||||||
*/
|
*/
|
||||||
typedef void (* GLFWcursorenterfun)(GLFWwindow*,int);
|
typedef void (* GLFWcursorenterfun)(GLFWwindow* window, int entered);
|
||||||
|
|
||||||
/*! @brief The function pointer type for scroll callbacks.
|
/*! @brief The function pointer type for scroll callbacks.
|
||||||
*
|
*
|
||||||
|
@ -1633,7 +1801,7 @@ typedef void (* GLFWcursorenterfun)(GLFWwindow*,int);
|
||||||
*
|
*
|
||||||
* @ingroup input
|
* @ingroup input
|
||||||
*/
|
*/
|
||||||
typedef void (* GLFWscrollfun)(GLFWwindow*,double,double);
|
typedef void (* GLFWscrollfun)(GLFWwindow* window, double xoffset, double yoffset);
|
||||||
|
|
||||||
/*! @brief The function pointer type for keyboard key callbacks.
|
/*! @brief The function pointer type for keyboard key callbacks.
|
||||||
*
|
*
|
||||||
|
@ -1645,7 +1813,7 @@ typedef void (* GLFWscrollfun)(GLFWwindow*,double,double);
|
||||||
*
|
*
|
||||||
* @param[in] window The window that received the event.
|
* @param[in] window The window that received the event.
|
||||||
* @param[in] key The [keyboard key](@ref keys) that was pressed or released.
|
* @param[in] key The [keyboard key](@ref keys) that was pressed or released.
|
||||||
* @param[in] scancode The system-specific scancode of the key.
|
* @param[in] scancode The platform-specific scancode of the key.
|
||||||
* @param[in] action `GLFW_PRESS`, `GLFW_RELEASE` or `GLFW_REPEAT`. Future
|
* @param[in] action `GLFW_PRESS`, `GLFW_RELEASE` or `GLFW_REPEAT`. Future
|
||||||
* releases may add more actions.
|
* releases may add more actions.
|
||||||
* @param[in] mods Bit field describing which [modifier keys](@ref mods) were
|
* @param[in] mods Bit field describing which [modifier keys](@ref mods) were
|
||||||
|
@ -1659,7 +1827,7 @@ typedef void (* GLFWscrollfun)(GLFWwindow*,double,double);
|
||||||
*
|
*
|
||||||
* @ingroup input
|
* @ingroup input
|
||||||
*/
|
*/
|
||||||
typedef void (* GLFWkeyfun)(GLFWwindow*,int,int,int,int);
|
typedef void (* GLFWkeyfun)(GLFWwindow* window, int key, int scancode, int action, int mods);
|
||||||
|
|
||||||
/*! @brief The function pointer type for Unicode character callbacks.
|
/*! @brief The function pointer type for Unicode character callbacks.
|
||||||
*
|
*
|
||||||
|
@ -1680,7 +1848,7 @@ typedef void (* GLFWkeyfun)(GLFWwindow*,int,int,int,int);
|
||||||
*
|
*
|
||||||
* @ingroup input
|
* @ingroup input
|
||||||
*/
|
*/
|
||||||
typedef void (* GLFWcharfun)(GLFWwindow*,unsigned int);
|
typedef void (* GLFWcharfun)(GLFWwindow* window, unsigned int codepoint);
|
||||||
|
|
||||||
/*! @brief The function pointer type for Unicode character with modifiers
|
/*! @brief The function pointer type for Unicode character with modifiers
|
||||||
* callbacks.
|
* callbacks.
|
||||||
|
@ -1707,7 +1875,7 @@ typedef void (* GLFWcharfun)(GLFWwindow*,unsigned int);
|
||||||
*
|
*
|
||||||
* @ingroup input
|
* @ingroup input
|
||||||
*/
|
*/
|
||||||
typedef void (* GLFWcharmodsfun)(GLFWwindow*,unsigned int,int);
|
typedef void (* GLFWcharmodsfun)(GLFWwindow* window, unsigned int codepoint, int mods);
|
||||||
|
|
||||||
/*! @brief The function pointer type for path drop callbacks.
|
/*! @brief The function pointer type for path drop callbacks.
|
||||||
*
|
*
|
||||||
|
@ -1731,7 +1899,7 @@ typedef void (* GLFWcharmodsfun)(GLFWwindow*,unsigned int,int);
|
||||||
*
|
*
|
||||||
* @ingroup input
|
* @ingroup input
|
||||||
*/
|
*/
|
||||||
typedef void (* GLFWdropfun)(GLFWwindow*,int,const char*[]);
|
typedef void (* GLFWdropfun)(GLFWwindow* window, int path_count, const char* paths[]);
|
||||||
|
|
||||||
/*! @brief The function pointer type for monitor configuration callbacks.
|
/*! @brief The function pointer type for monitor configuration callbacks.
|
||||||
*
|
*
|
||||||
|
@ -1752,7 +1920,7 @@ typedef void (* GLFWdropfun)(GLFWwindow*,int,const char*[]);
|
||||||
*
|
*
|
||||||
* @ingroup monitor
|
* @ingroup monitor
|
||||||
*/
|
*/
|
||||||
typedef void (* GLFWmonitorfun)(GLFWmonitor*,int);
|
typedef void (* GLFWmonitorfun)(GLFWmonitor* monitor, int event);
|
||||||
|
|
||||||
/*! @brief The function pointer type for joystick configuration callbacks.
|
/*! @brief The function pointer type for joystick configuration callbacks.
|
||||||
*
|
*
|
||||||
|
@ -1773,7 +1941,7 @@ typedef void (* GLFWmonitorfun)(GLFWmonitor*,int);
|
||||||
*
|
*
|
||||||
* @ingroup input
|
* @ingroup input
|
||||||
*/
|
*/
|
||||||
typedef void (* GLFWjoystickfun)(int,int);
|
typedef void (* GLFWjoystickfun)(int jid, int event);
|
||||||
|
|
||||||
/*! @brief Video mode type.
|
/*! @brief Video mode type.
|
||||||
*
|
*
|
||||||
|
@ -1887,6 +2055,23 @@ typedef struct GLFWgamepadstate
|
||||||
float axes[6];
|
float axes[6];
|
||||||
} GLFWgamepadstate;
|
} GLFWgamepadstate;
|
||||||
|
|
||||||
|
/*! @brief
|
||||||
|
*
|
||||||
|
* @sa @ref init_allocator
|
||||||
|
* @sa @ref glfwInitAllocator
|
||||||
|
*
|
||||||
|
* @since Added in version 3.4.
|
||||||
|
*
|
||||||
|
* @ingroup init
|
||||||
|
*/
|
||||||
|
typedef struct GLFWallocator
|
||||||
|
{
|
||||||
|
GLFWallocatefun allocate;
|
||||||
|
GLFWreallocatefun reallocate;
|
||||||
|
GLFWdeallocatefun deallocate;
|
||||||
|
void* user;
|
||||||
|
} GLFWallocator;
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
* GLFW API functions
|
* GLFW API functions
|
||||||
|
@ -1905,10 +2090,15 @@ typedef struct GLFWgamepadstate
|
||||||
* Additional calls to this function after successful initialization but before
|
* Additional calls to this function after successful initialization but before
|
||||||
* termination will return `GLFW_TRUE` immediately.
|
* termination will return `GLFW_TRUE` immediately.
|
||||||
*
|
*
|
||||||
|
* The @ref GLFW_PLATFORM init hint controls which platforms are considered during
|
||||||
|
* initialization. This also depends on which platforms the library was compiled to
|
||||||
|
* support.
|
||||||
|
*
|
||||||
* @return `GLFW_TRUE` if successful, or `GLFW_FALSE` if an
|
* @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_PLATFORM_ERROR.
|
* @errors Possible errors include @ref GLFW_PLATFORM_UNAVAILABLE and @ref
|
||||||
|
* GLFW_PLATFORM_ERROR.
|
||||||
*
|
*
|
||||||
* @remark @macos This function will change the current directory of the
|
* @remark @macos This function will change the current directory of the
|
||||||
* application to the `Contents/Resources` subdirectory of the application's
|
* application to the `Contents/Resources` subdirectory of the application's
|
||||||
|
@ -1930,6 +2120,8 @@ typedef struct GLFWgamepadstate
|
||||||
* @thread_safety This function must only be called from the main thread.
|
* @thread_safety This function must only be called from the main thread.
|
||||||
*
|
*
|
||||||
* @sa @ref intro_init
|
* @sa @ref intro_init
|
||||||
|
* @sa @ref glfwInitHint
|
||||||
|
* @sa @ref glfwInitAllocator
|
||||||
* @sa @ref glfwTerminate
|
* @sa @ref glfwTerminate
|
||||||
*
|
*
|
||||||
* @since Added in version 1.0.
|
* @since Added in version 1.0.
|
||||||
|
@ -2004,6 +2196,81 @@ GLFWAPI void glfwTerminate(void);
|
||||||
*/
|
*/
|
||||||
GLFWAPI void glfwInitHint(int hint, int value);
|
GLFWAPI void glfwInitHint(int hint, int value);
|
||||||
|
|
||||||
|
/*! @brief Sets the init allocator to the desired value.
|
||||||
|
*
|
||||||
|
* To use the default allocator, call this function with a `NULL` argument.
|
||||||
|
*
|
||||||
|
* If you specify an allocator struct, every member must be a valid function
|
||||||
|
* pointer. If any member is `NULL`, this function emits @ref
|
||||||
|
* GLFW_INVALID_VALUE and the init allocator is unchanged.
|
||||||
|
*
|
||||||
|
* @param[in] allocator The allocator to use at the next initialization, or
|
||||||
|
* `NULL` to use the default one.
|
||||||
|
*
|
||||||
|
* @errors Possible errors include @ref GLFW_INVALID_VALUE.
|
||||||
|
*
|
||||||
|
* @pointer_lifetime The specified allocator is copied before this function
|
||||||
|
* returns.
|
||||||
|
*
|
||||||
|
* @thread_safety This function must only be called from the main thread.
|
||||||
|
*
|
||||||
|
* @sa @ref init_allocator
|
||||||
|
* @sa @ref glfwInit
|
||||||
|
*
|
||||||
|
* @since Added in version 3.4.
|
||||||
|
*
|
||||||
|
* @ingroup init
|
||||||
|
*/
|
||||||
|
GLFWAPI void glfwInitAllocator(const GLFWallocator* allocator);
|
||||||
|
|
||||||
|
#if defined(VK_VERSION_1_0)
|
||||||
|
|
||||||
|
/*! @brief Sets the desired Vulkan `vkGetInstanceProcAddr` function.
|
||||||
|
*
|
||||||
|
* This function sets the `vkGetInstanceProcAddr` function that GLFW will use for all
|
||||||
|
* Vulkan related entry point queries.
|
||||||
|
*
|
||||||
|
* This feature is mostly useful on macOS, if your copy of the Vulkan loader is in
|
||||||
|
* a location where GLFW cannot find it through dynamic loading, or if you are still
|
||||||
|
* using the static library version of the loader.
|
||||||
|
*
|
||||||
|
* If set to `NULL`, GLFW will try to load the Vulkan loader dynamically by its standard
|
||||||
|
* name and get this function from there. This is the default behavior.
|
||||||
|
*
|
||||||
|
* The standard name of the loader is `vulkan-1.dll` on Windows, `libvulkan.so.1` on
|
||||||
|
* Linux and other Unix-like systems and `libvulkan.1.dylib` on macOS. If your code is
|
||||||
|
* also loading it via these names then you probably don't need to use this function.
|
||||||
|
*
|
||||||
|
* The function address you set is never reset by GLFW, but it only takes effect during
|
||||||
|
* initialization. Once GLFW has been initialized, any updates will be ignored until the
|
||||||
|
* library is terminated and initialized again.
|
||||||
|
*
|
||||||
|
* @param[in] loader The address of the function to use, or `NULL`.
|
||||||
|
*
|
||||||
|
* @par Loader function signature
|
||||||
|
* @code
|
||||||
|
* PFN_vkVoidFunction vkGetInstanceProcAddr(VkInstance instance, const char* name)
|
||||||
|
* @endcode
|
||||||
|
* For more information about this function, see the
|
||||||
|
* [Vulkan Registry](https://www.khronos.org/registry/vulkan/).
|
||||||
|
*
|
||||||
|
* @errors None.
|
||||||
|
*
|
||||||
|
* @remark This function may be called before @ref glfwInit.
|
||||||
|
*
|
||||||
|
* @thread_safety This function must only be called from the main thread.
|
||||||
|
*
|
||||||
|
* @sa @ref vulkan_loader
|
||||||
|
* @sa @ref glfwInit
|
||||||
|
*
|
||||||
|
* @since Added in version 3.4.
|
||||||
|
*
|
||||||
|
* @ingroup init
|
||||||
|
*/
|
||||||
|
GLFWAPI void glfwInitVulkanLoader(PFN_vkGetInstanceProcAddr loader);
|
||||||
|
|
||||||
|
#endif /*VK_VERSION_1_0*/
|
||||||
|
|
||||||
/*! @brief Retrieves the version of the GLFW library.
|
/*! @brief Retrieves the version of the GLFW library.
|
||||||
*
|
*
|
||||||
* This function retrieves the major, minor and revision numbers of the GLFW
|
* This function retrieves the major, minor and revision numbers of the GLFW
|
||||||
|
@ -2034,15 +2301,18 @@ GLFWAPI void glfwGetVersion(int* major, int* minor, int* rev);
|
||||||
/*! @brief Returns a string describing the compile-time configuration.
|
/*! @brief Returns a string describing the compile-time configuration.
|
||||||
*
|
*
|
||||||
* This function returns the compile-time generated
|
* This function returns the compile-time generated
|
||||||
* [version string](@ref intro_version_string) of the GLFW library binary. It
|
* [version string](@ref intro_version_string) of the GLFW library binary. It describes
|
||||||
* describes the version, platform, compiler and any platform-specific
|
* the version, platforms, compiler and any platform or operating system specific
|
||||||
* compile-time options. It should not be confused with the OpenGL or OpenGL
|
* compile-time options. It should not be confused with the OpenGL or OpenGL ES version
|
||||||
* ES version string, queried with `glGetString`.
|
* string, queried with `glGetString`.
|
||||||
*
|
*
|
||||||
* __Do not use the version string__ to parse the GLFW library version. The
|
* __Do not use the version string__ to parse the GLFW library version. The
|
||||||
* @ref glfwGetVersion function provides the version of the running library
|
* @ref glfwGetVersion function provides the version of the running library
|
||||||
* binary in numerical format.
|
* binary in numerical format.
|
||||||
*
|
*
|
||||||
|
* __Do not use the version string__ to parse what platforms are supported. The @ref
|
||||||
|
* glfwPlatformSupported function lets you query platform support.
|
||||||
|
*
|
||||||
* @return The ASCII encoded GLFW version string.
|
* @return The ASCII encoded GLFW version string.
|
||||||
*
|
*
|
||||||
* @errors None.
|
* @errors None.
|
||||||
|
@ -2139,6 +2409,51 @@ GLFWAPI int glfwGetError(const char** description);
|
||||||
*/
|
*/
|
||||||
GLFWAPI GLFWerrorfun glfwSetErrorCallback(GLFWerrorfun callback);
|
GLFWAPI GLFWerrorfun glfwSetErrorCallback(GLFWerrorfun callback);
|
||||||
|
|
||||||
|
/*! @brief Returns the currently selected platform.
|
||||||
|
*
|
||||||
|
* This function returns the platform that was selected during initialization. The
|
||||||
|
* returned value will be one of `GLFW_PLATFORM_WIN32`, `GLFW_PLATFORM_COCOA`,
|
||||||
|
* `GLFW_PLATFORM_WAYLAND`, `GLFW_PLATFORM_X11` or `GLFW_PLATFORM_NULL`.
|
||||||
|
*
|
||||||
|
* @return The currently selected platform, or zero if an error occurred.
|
||||||
|
*
|
||||||
|
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
|
||||||
|
*
|
||||||
|
* @thread_safety This function may be called from any thread.
|
||||||
|
*
|
||||||
|
* @sa @ref platform
|
||||||
|
* @sa @ref glfwPlatformSupported
|
||||||
|
*
|
||||||
|
* @since Added in version 3.4.
|
||||||
|
*
|
||||||
|
* @ingroup init
|
||||||
|
*/
|
||||||
|
GLFWAPI int glfwGetPlatform(void);
|
||||||
|
|
||||||
|
/*! @brief Returns whether the library includes support for the specified platform.
|
||||||
|
*
|
||||||
|
* This function returns whether the library was compiled with support for the specified
|
||||||
|
* platform. The platform must be one of `GLFW_PLATFORM_WIN32`, `GLFW_PLATFORM_COCOA`,
|
||||||
|
* `GLFW_PLATFORM_WAYLAND`, `GLFW_PLATFORM_X11` or `GLFW_PLATFORM_NULL`.
|
||||||
|
*
|
||||||
|
* @param[in] platform The platform to query.
|
||||||
|
* @return `GLFW_TRUE` if the platform is supported, or `GLFW_FALSE` otherwise.
|
||||||
|
*
|
||||||
|
* @errors Possible errors include @ref GLFW_INVALID_ENUM.
|
||||||
|
*
|
||||||
|
* @remark This function may be called before @ref glfwInit.
|
||||||
|
*
|
||||||
|
* @thread_safety This function may be called from any thread.
|
||||||
|
*
|
||||||
|
* @sa @ref platform
|
||||||
|
* @sa @ref glfwGetPlatform
|
||||||
|
*
|
||||||
|
* @since Added in version 3.4.
|
||||||
|
*
|
||||||
|
* @ingroup init
|
||||||
|
*/
|
||||||
|
GLFWAPI int glfwPlatformSupported(int platform);
|
||||||
|
|
||||||
/*! @brief Returns the currently connected monitors.
|
/*! @brief Returns the currently connected monitors.
|
||||||
*
|
*
|
||||||
* This function returns an array of handles for all currently connected
|
* This function returns an array of handles for all currently connected
|
||||||
|
@ -2222,7 +2537,7 @@ GLFWAPI void glfwGetMonitorPos(GLFWmonitor* monitor, int* xpos, int* ypos);
|
||||||
* This function returns the position, in screen coordinates, of the upper-left
|
* This function returns the position, in screen coordinates, of the upper-left
|
||||||
* corner of the work area of the specified monitor along with the work area
|
* corner of the work area of the specified monitor along with the work area
|
||||||
* size in screen coordinates. The work area is defined as the area of the
|
* size in screen coordinates. The work area is defined as the area of the
|
||||||
* monitor not occluded by the operating system task bar where present. If no
|
* monitor not occluded by the window system task bar where present. If no
|
||||||
* task bar exists then the work area is the monitor resolution in screen
|
* task bar exists then the work area is the monitor resolution in screen
|
||||||
* coordinates.
|
* coordinates.
|
||||||
*
|
*
|
||||||
|
@ -2253,7 +2568,7 @@ GLFWAPI void glfwGetMonitorWorkarea(GLFWmonitor* monitor, int* xpos, int* ypos,
|
||||||
* This function returns the size, in millimetres, of the display area of the
|
* This function returns the size, in millimetres, of the display area of the
|
||||||
* specified monitor.
|
* specified monitor.
|
||||||
*
|
*
|
||||||
* Some systems do not provide accurate monitor size information, either
|
* Some platforms do not provide accurate monitor size information, either
|
||||||
* because the monitor
|
* because the monitor
|
||||||
* [EDID](https://en.wikipedia.org/wiki/Extended_display_identification_data)
|
* [EDID](https://en.wikipedia.org/wiki/Extended_display_identification_data)
|
||||||
* data is incorrect or because the driver does not report it accurately.
|
* data is incorrect or because the driver does not report it accurately.
|
||||||
|
@ -2269,8 +2584,8 @@ GLFWAPI void glfwGetMonitorWorkarea(GLFWmonitor* monitor, int* xpos, int* ypos,
|
||||||
*
|
*
|
||||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
|
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
|
||||||
*
|
*
|
||||||
* @remark @win32 calculates the returned physical size from the
|
* @remark @win32 On Windows 8 and earlier the physical size is calculated from
|
||||||
* current resolution and system DPI instead of querying the monitor EDID data.
|
* the current resolution and system DPI instead of querying the monitor EDID data.
|
||||||
*
|
*
|
||||||
* @thread_safety This function must only be called from the main thread.
|
* @thread_safety This function must only be called from the main thread.
|
||||||
*
|
*
|
||||||
|
@ -2942,7 +3257,8 @@ GLFWAPI void glfwSetWindowTitle(GLFWwindow* window, const char* title);
|
||||||
* count is zero.
|
* count is zero.
|
||||||
*
|
*
|
||||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
|
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
|
||||||
* GLFW_PLATFORM_ERROR and @ref GLFW_FEATURE_UNAVAILABLE (see remarks).
|
* GLFW_INVALID_VALUE, @ref GLFW_PLATFORM_ERROR and @ref
|
||||||
|
* GLFW_FEATURE_UNAVAILABLE (see remarks).
|
||||||
*
|
*
|
||||||
* @pointer_lifetime The specified image data is copied before this function
|
* @pointer_lifetime The specified image data is copied before this function
|
||||||
* returns.
|
* returns.
|
||||||
|
@ -3267,7 +3583,7 @@ GLFWAPI void glfwGetWindowFrameSize(GLFWwindow* window, int* left, int* top, int
|
||||||
* regardless of their DPI and scaling settings. This relies on the system DPI
|
* regardless of their DPI and scaling settings. This relies on the system DPI
|
||||||
* and scaling settings being somewhat correct.
|
* and scaling settings being somewhat correct.
|
||||||
*
|
*
|
||||||
* On systems where each monitors can have its own content scale, the window
|
* On platforms where each monitors can have its own content scale, the window
|
||||||
* content scale will depend on which monitor the system considers the window
|
* content scale will depend on which monitor the system considers the window
|
||||||
* to be on.
|
* to be on.
|
||||||
*
|
*
|
||||||
|
@ -3448,6 +3764,11 @@ GLFWAPI void glfwMaximizeWindow(GLFWwindow* window);
|
||||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
|
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
|
||||||
* GLFW_PLATFORM_ERROR.
|
* GLFW_PLATFORM_ERROR.
|
||||||
*
|
*
|
||||||
|
* @remark @wayland Because Wayland wants every frame of the desktop to be
|
||||||
|
* complete, this function does not immediately make the window visible.
|
||||||
|
* Instead it will become visible the next time the window framebuffer is
|
||||||
|
* updated after this call.
|
||||||
|
*
|
||||||
* @thread_safety This function must only be called from the main thread.
|
* @thread_safety This function must only be called from the main thread.
|
||||||
*
|
*
|
||||||
* @sa @ref window_hide
|
* @sa @ref window_hide
|
||||||
|
@ -4571,8 +4892,8 @@ GLFWAPI void glfwSetCursorPos(GLFWwindow* window, double xpos, double ypos);
|
||||||
* @return The handle of the created cursor, or `NULL` if an
|
* @return The handle of the created cursor, or `NULL` if an
|
||||||
* [error](@ref error_handling) occurred.
|
* [error](@ref error_handling) occurred.
|
||||||
*
|
*
|
||||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
|
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
|
||||||
* GLFW_PLATFORM_ERROR.
|
* GLFW_INVALID_VALUE and @ref GLFW_PLATFORM_ERROR.
|
||||||
*
|
*
|
||||||
* @pointer_lifetime The specified image data is copied before this function
|
* @pointer_lifetime The specified image data is copied before this function
|
||||||
* returns.
|
* returns.
|
||||||
|
@ -5387,6 +5708,8 @@ GLFWAPI int glfwUpdateGamepadMappings(const char* string);
|
||||||
* joystick is not present, does not have a mapping or an
|
* joystick is not present, does not have a mapping or an
|
||||||
* [error](@ref error_handling) occurred.
|
* [error](@ref error_handling) occurred.
|
||||||
*
|
*
|
||||||
|
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref GLFW_INVALID_ENUM.
|
||||||
|
*
|
||||||
* @pointer_lifetime The returned string is allocated and freed by GLFW. You
|
* @pointer_lifetime The returned string is allocated and freed by GLFW. You
|
||||||
* should not free it yourself. It is valid until the specified joystick is
|
* should not free it yourself. It is valid until the specified joystick is
|
||||||
* disconnected, the gamepad mappings are updated or the library is terminated.
|
* disconnected, the gamepad mappings are updated or the library is terminated.
|
||||||
|
@ -5476,8 +5799,8 @@ GLFWAPI void glfwSetClipboardString(GLFWwindow* window, const char* string);
|
||||||
* @return The contents of the clipboard as a UTF-8 encoded string, or `NULL`
|
* @return The contents of the clipboard as a UTF-8 encoded string, or `NULL`
|
||||||
* if an [error](@ref error_handling) occurred.
|
* if an [error](@ref error_handling) occurred.
|
||||||
*
|
*
|
||||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
|
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
|
||||||
* GLFW_PLATFORM_ERROR.
|
* GLFW_FORMAT_UNAVAILABLE and @ref GLFW_PLATFORM_ERROR.
|
||||||
*
|
*
|
||||||
* @pointer_lifetime The returned string is allocated and freed by GLFW. You
|
* @pointer_lifetime The returned string is allocated and freed by GLFW. You
|
||||||
* should not free it yourself. It is valid until the next call to @ref
|
* should not free it yourself. It is valid until the next call to @ref
|
||||||
|
@ -5506,7 +5829,7 @@ GLFWAPI const char* glfwGetClipboardString(GLFWwindow* window);
|
||||||
*
|
*
|
||||||
* The resolution of the timer is system dependent, but is usually on the order
|
* The resolution of the timer is system dependent, but is usually on the order
|
||||||
* of a few micro- or nanoseconds. It uses the highest-resolution monotonic
|
* of a few micro- or nanoseconds. It uses the highest-resolution monotonic
|
||||||
* time source on each supported platform.
|
* time source on each operating system.
|
||||||
*
|
*
|
||||||
* @return The current time, in seconds, or zero if an
|
* @return The current time, in seconds, or zero if an
|
||||||
* [error](@ref error_handling) occurred.
|
* [error](@ref error_handling) occurred.
|
||||||
|
@ -5717,7 +6040,7 @@ GLFWAPI void glfwSwapBuffers(GLFWwindow* window);
|
||||||
* GLFW_NO_CURRENT_CONTEXT and @ref GLFW_PLATFORM_ERROR.
|
* GLFW_NO_CURRENT_CONTEXT and @ref GLFW_PLATFORM_ERROR.
|
||||||
*
|
*
|
||||||
* @remark This function is not called during context creation, leaving the
|
* @remark This function is not called during context creation, leaving the
|
||||||
* swap interval set to whatever is the default on that platform. This is done
|
* swap interval set to whatever is the default for that API. This is done
|
||||||
* because some swap interval extensions used by GLFW do not allow the swap
|
* because some swap interval extensions used by GLFW do not allow the swap
|
||||||
* interval to be reset to zero once it has been set to a non-zero value.
|
* interval to be reset to zero once it has been set to a non-zero value.
|
||||||
*
|
*
|
||||||
|
@ -5821,13 +6144,11 @@ GLFWAPI GLFWglproc glfwGetProcAddress(const char* procname);
|
||||||
* This function returns whether the Vulkan loader and any minimally functional
|
* This function returns whether the Vulkan loader and any minimally functional
|
||||||
* ICD have been found.
|
* ICD have been found.
|
||||||
*
|
*
|
||||||
* The availability of a Vulkan loader and even an ICD does not by itself
|
* The availability of a Vulkan loader and even an ICD does not by itself guarantee that
|
||||||
* guarantee that surface creation or even instance creation is possible.
|
* surface creation or even instance creation is possible. Call @ref
|
||||||
* For example, on Fermi systems Nvidia will install an ICD that provides no
|
* glfwGetRequiredInstanceExtensions to check whether the extensions necessary for Vulkan
|
||||||
* actual Vulkan support. Call @ref glfwGetRequiredInstanceExtensions to check
|
* surface creation are available and @ref glfwGetPhysicalDevicePresentationSupport to
|
||||||
* whether the extensions necessary for Vulkan surface creation are available
|
* check whether a queue family of a physical device supports image presentation.
|
||||||
* and @ref glfwGetPhysicalDevicePresentationSupport to check whether a queue
|
|
||||||
* family of a physical device supports image presentation.
|
|
||||||
*
|
*
|
||||||
* @return `GLFW_TRUE` if Vulkan is minimally available, or `GLFW_FALSE`
|
* @return `GLFW_TRUE` if Vulkan is minimally available, or `GLFW_FALSE`
|
||||||
* otherwise.
|
* otherwise.
|
||||||
|
@ -5873,9 +6194,6 @@ GLFWAPI int glfwVulkanSupported(void);
|
||||||
* returned array, as it is an error to specify an extension more than once in
|
* returned array, as it is an error to specify an extension more than once in
|
||||||
* the `VkInstanceCreateInfo` struct.
|
* the `VkInstanceCreateInfo` struct.
|
||||||
*
|
*
|
||||||
* @remark @macos GLFW currently supports both the `VK_MVK_macos_surface` and
|
|
||||||
* the newer `VK_EXT_metal_surface` extensions.
|
|
||||||
*
|
|
||||||
* @pointer_lifetime The returned array is allocated and freed by GLFW. You
|
* @pointer_lifetime The returned array is allocated and freed by GLFW. You
|
||||||
* should not free it yourself. It is guaranteed to be valid only until the
|
* should not free it yourself. It is guaranteed to be valid only until the
|
||||||
* library is terminated.
|
* library is terminated.
|
||||||
|
@ -6014,17 +6332,20 @@ GLFWAPI int glfwGetPhysicalDevicePresentationSupport(VkInstance instance, VkPhys
|
||||||
* @ref glfwVulkanSupported and @ref glfwGetRequiredInstanceExtensions should
|
* @ref glfwVulkanSupported and @ref glfwGetRequiredInstanceExtensions should
|
||||||
* eliminate almost all occurrences of these errors.
|
* eliminate almost all occurrences of these errors.
|
||||||
*
|
*
|
||||||
* @remark @macos This function currently only supports the
|
* @remark @macos GLFW prefers the `VK_EXT_metal_surface` extension, with the
|
||||||
* `VK_MVK_macos_surface` extension from MoltenVK.
|
* `VK_MVK_macos_surface` extension as a fallback. The name of the selected
|
||||||
|
* extension, if any, is included in the array returned by @ref
|
||||||
|
* glfwGetRequiredInstanceExtensions.
|
||||||
*
|
*
|
||||||
* @remark @macos This function creates and sets a `CAMetalLayer` instance for
|
* @remark @macos This function creates and sets a `CAMetalLayer` instance for
|
||||||
* the window content view, which is required for MoltenVK to function.
|
* the window content view, which is required for MoltenVK to function.
|
||||||
*
|
*
|
||||||
* @remark @x11 GLFW by default attempts to use the `VK_KHR_xcb_surface`
|
* @remark @x11 By default GLFW prefers the `VK_KHR_xcb_surface` extension,
|
||||||
* extension, if available. You can make it prefer the `VK_KHR_xlib_surface`
|
* with the `VK_KHR_xlib_surface` extension as a fallback. You can make
|
||||||
* extension by setting the
|
* `VK_KHR_xlib_surface` the preferred extension by setting the
|
||||||
* [GLFW_X11_XCB_VULKAN_SURFACE](@ref GLFW_X11_XCB_VULKAN_SURFACE_hint) init
|
* [GLFW_X11_XCB_VULKAN_SURFACE](@ref GLFW_X11_XCB_VULKAN_SURFACE_hint) init
|
||||||
* hint.
|
* hint. The name of the selected extension, if any, is included in the array
|
||||||
|
* returned by @ref glfwGetRequiredInstanceExtensions.
|
||||||
*
|
*
|
||||||
* @thread_safety This function may be called from any thread. For
|
* @thread_safety This function may be called from any thread. For
|
||||||
* synchronization details of Vulkan objects, see the Vulkan specification.
|
* synchronization details of Vulkan objects, see the Vulkan specification.
|
||||||
|
@ -6062,6 +6383,7 @@ GLFWAPI VkResult glfwCreateWindowSurface(VkInstance instance, GLFWwindow* window
|
||||||
*/
|
*/
|
||||||
#ifndef GLAPIENTRY
|
#ifndef GLAPIENTRY
|
||||||
#define GLAPIENTRY APIENTRY
|
#define GLAPIENTRY APIENTRY
|
||||||
|
#define GLFW_GLAPIENTRY_DEFINED
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* -------------------- END SYSTEM/COMPILER SPECIFIC --------------------- */
|
/* -------------------- END SYSTEM/COMPILER SPECIFIC --------------------- */
|
||||||
|
|
|
@ -82,9 +82,10 @@ 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_KHR_debug callback)
|
* example to allow applications to correctly declare a GL_KHR_debug 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
|
||||||
|
@ -111,12 +112,28 @@ extern "C" {
|
||||||
/* NSGL is declared by Cocoa.h */
|
/* NSGL is declared by Cocoa.h */
|
||||||
#endif
|
#endif
|
||||||
#if defined(GLFW_EXPOSE_NATIVE_GLX)
|
#if defined(GLFW_EXPOSE_NATIVE_GLX)
|
||||||
|
/* This is a workaround for the fact that glfw3.h defines GLAPIENTRY because by
|
||||||
|
* default it also acts as an OpenGL header
|
||||||
|
* However, glx.h will include gl.h, which will define it unconditionally
|
||||||
|
*/
|
||||||
|
#if defined(GLFW_GLAPIENTRY_DEFINED)
|
||||||
|
#undef GLAPIENTRY
|
||||||
|
#undef GLFW_GLAPIENTRY_DEFINED
|
||||||
|
#endif
|
||||||
#include <GL/glx.h>
|
#include <GL/glx.h>
|
||||||
#endif
|
#endif
|
||||||
#if defined(GLFW_EXPOSE_NATIVE_EGL)
|
#if defined(GLFW_EXPOSE_NATIVE_EGL)
|
||||||
#include <EGL/egl.h>
|
#include <EGL/egl.h>
|
||||||
#endif
|
#endif
|
||||||
#if defined(GLFW_EXPOSE_NATIVE_OSMESA)
|
#if defined(GLFW_EXPOSE_NATIVE_OSMESA)
|
||||||
|
/* This is a workaround for the fact that glfw3.h defines GLAPIENTRY because by
|
||||||
|
* default it also acts as an OpenGL header
|
||||||
|
* However, osmesa.h will include gl.h, which will define it unconditionally
|
||||||
|
*/
|
||||||
|
#if defined(GLFW_GLAPIENTRY_DEFINED)
|
||||||
|
#undef GLAPIENTRY
|
||||||
|
#undef GLFW_GLAPIENTRY_DEFINED
|
||||||
|
#endif
|
||||||
#include <GL/osmesa.h>
|
#include <GL/osmesa.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -132,6 +149,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 +166,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 +182,8 @@ 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
|
* @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)
|
* [GetDC](https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getdc)
|
||||||
* function.
|
* function.
|
||||||
|
@ -185,6 +208,9 @@ 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
|
* @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)
|
* [GetDC](https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getdc)
|
||||||
* function.
|
* function.
|
||||||
|
@ -209,6 +235,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.
|
||||||
*
|
*
|
||||||
|
@ -223,6 +251,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.
|
||||||
*
|
*
|
||||||
|
@ -239,6 +269,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.
|
||||||
*
|
*
|
||||||
|
@ -255,6 +288,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.
|
||||||
*
|
*
|
||||||
|
@ -269,6 +304,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.
|
||||||
*
|
*
|
||||||
|
@ -283,6 +320,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.
|
||||||
*
|
*
|
||||||
|
@ -297,6 +336,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.
|
||||||
*
|
*
|
||||||
|
@ -363,6 +404,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.
|
||||||
*
|
*
|
||||||
|
@ -377,6 +421,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.
|
||||||
*
|
*
|
||||||
|
@ -393,6 +440,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.
|
||||||
*
|
*
|
||||||
|
@ -407,6 +456,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.
|
||||||
*
|
*
|
||||||
|
@ -421,6 +472,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.
|
||||||
*
|
*
|
||||||
|
@ -437,6 +490,11 @@ 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.
|
||||||
|
*
|
||||||
|
* @remark Because EGL is initialized on demand, this function will return
|
||||||
|
* `EGL_NO_DISPLAY` until the first context has been created via EGL.
|
||||||
|
*
|
||||||
* @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.
|
||||||
*
|
*
|
||||||
|
@ -451,6 +509,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.
|
||||||
*
|
*
|
||||||
|
@ -465,6 +526,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.
|
||||||
*
|
*
|
||||||
|
@ -488,6 +552,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.
|
||||||
*
|
*
|
||||||
|
@ -509,6 +576,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.
|
||||||
*
|
*
|
||||||
|
@ -523,6 +593,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,8 +1,24 @@
|
||||||
|
|
||||||
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)
|
||||||
|
|
||||||
|
# The time, thread and module code is shared between all backends on a given OS,
|
||||||
|
# including the null backend, which still needs those bits to be functional
|
||||||
|
if (APPLE)
|
||||||
|
target_sources(glfw PRIVATE cocoa_time.h cocoa_time.c posix_thread.h
|
||||||
|
posix_module.c posix_thread.c)
|
||||||
|
elseif (WIN32)
|
||||||
|
target_sources(glfw PRIVATE win32_time.h win32_thread.h win32_module.c
|
||||||
|
win32_time.c win32_thread.c)
|
||||||
|
else()
|
||||||
|
target_sources(glfw PRIVATE posix_time.h posix_thread.h posix_module.c
|
||||||
|
posix_time.c posix_thread.c)
|
||||||
|
endif()
|
||||||
|
|
||||||
add_custom_target(update_mappings
|
add_custom_target(update_mappings
|
||||||
COMMAND "${CMAKE_COMMAND}" -P "${GLFW_SOURCE_DIR}/CMake/GenerateMappings.cmake" mappings.h.in mappings.h
|
COMMAND "${CMAKE_COMMAND}" -P "${GLFW_SOURCE_DIR}/CMake/GenerateMappings.cmake" mappings.h.in mappings.h
|
||||||
|
@ -13,50 +29,54 @@ add_custom_target(update_mappings
|
||||||
|
|
||||||
set_target_properties(update_mappings PROPERTIES FOLDER "GLFW3")
|
set_target_properties(update_mappings PROPERTIES FOLDER "GLFW3")
|
||||||
|
|
||||||
if (_GLFW_COCOA)
|
if (GLFW_BUILD_COCOA)
|
||||||
target_sources(glfw PRIVATE cocoa_platform.h cocoa_joystick.h posix_thread.h
|
target_compile_definitions(glfw PRIVATE _GLFW_COCOA)
|
||||||
nsgl_context.h egl_context.h osmesa_context.h
|
target_sources(glfw PRIVATE cocoa_platform.h cocoa_joystick.h cocoa_init.m
|
||||||
cocoa_init.m cocoa_joystick.m cocoa_monitor.m
|
cocoa_joystick.m cocoa_monitor.m cocoa_window.m
|
||||||
cocoa_window.m cocoa_time.c posix_thread.c
|
nsgl_context.m)
|
||||||
nsgl_context.m egl_context.c osmesa_context.c)
|
|
||||||
elseif (_GLFW_WIN32)
|
|
||||||
target_sources(glfw PRIVATE win32_platform.h win32_joystick.h wgl_context.h
|
|
||||||
egl_context.h osmesa_context.h win32_init.c
|
|
||||||
win32_joystick.c win32_monitor.c win32_time.c
|
|
||||||
win32_thread.c win32_window.c wgl_context.c
|
|
||||||
egl_context.c osmesa_context.c)
|
|
||||||
elseif (_GLFW_X11)
|
|
||||||
target_sources(glfw PRIVATE x11_platform.h xkb_unicode.h posix_time.h
|
|
||||||
posix_thread.h glx_context.h egl_context.h
|
|
||||||
osmesa_context.h x11_init.c x11_monitor.c
|
|
||||||
x11_window.c xkb_unicode.c posix_time.c
|
|
||||||
posix_thread.c glx_context.c egl_context.c
|
|
||||||
osmesa_context.c)
|
|
||||||
elseif (_GLFW_WAYLAND)
|
|
||||||
target_sources(glfw PRIVATE wl_platform.h posix_time.h posix_thread.h
|
|
||||||
xkb_unicode.h egl_context.h osmesa_context.h
|
|
||||||
wl_init.c wl_monitor.c wl_window.c posix_time.c
|
|
||||||
posix_thread.c xkb_unicode.c egl_context.c
|
|
||||||
osmesa_context.c)
|
|
||||||
elseif (_GLFW_OSMESA)
|
|
||||||
target_sources(glfw PRIVATE null_platform.h null_joystick.h posix_time.h
|
|
||||||
posix_thread.h osmesa_context.h null_init.c
|
|
||||||
null_monitor.c null_window.c null_joystick.c
|
|
||||||
posix_time.c posix_thread.c osmesa_context.c)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (_GLFW_X11 OR _GLFW_WAYLAND)
|
if (GLFW_BUILD_WIN32)
|
||||||
|
target_compile_definitions(glfw PRIVATE _GLFW_WIN32)
|
||||||
|
target_sources(glfw PRIVATE win32_platform.h win32_joystick.h win32_init.c
|
||||||
|
win32_joystick.c win32_monitor.c win32_window.c
|
||||||
|
wgl_context.c)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (GLFW_BUILD_X11)
|
||||||
|
target_compile_definitions(glfw PRIVATE _GLFW_X11)
|
||||||
|
target_sources(glfw PRIVATE x11_platform.h xkb_unicode.h x11_init.c
|
||||||
|
x11_monitor.c x11_window.c xkb_unicode.c
|
||||||
|
glx_context.c)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (GLFW_BUILD_WAYLAND)
|
||||||
|
target_compile_definitions(glfw PRIVATE _GLFW_WAYLAND)
|
||||||
|
target_sources(glfw PRIVATE wl_platform.h xkb_unicode.h wl_init.c
|
||||||
|
wl_monitor.c wl_window.c xkb_unicode.c)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (GLFW_BUILD_X11 OR GLFW_BUILD_WAYLAND)
|
||||||
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||||
target_sources(glfw PRIVATE linux_joystick.h linux_joystick.c)
|
target_sources(glfw PRIVATE linux_joystick.h linux_joystick.c)
|
||||||
else()
|
|
||||||
target_sources(glfw PRIVATE null_joystick.h null_joystick.c)
|
|
||||||
endif()
|
endif()
|
||||||
|
target_sources(glfw PRIVATE posix_poll.h posix_poll.c)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (_GLFW_WAYLAND)
|
if (GLFW_BUILD_WAYLAND)
|
||||||
|
include(CheckIncludeFiles)
|
||||||
|
include(CheckFunctionExists)
|
||||||
|
check_function_exists(memfd_create HAVE_MEMFD_CREATE)
|
||||||
|
if (HAVE_MEMFD_CREATE)
|
||||||
|
target_compile_definitions(glfw PRIVATE HAVE_MEMFD_CREATE)
|
||||||
|
endif()
|
||||||
|
|
||||||
find_program(WAYLAND_SCANNER_EXECUTABLE NAMES wayland-scanner)
|
find_program(WAYLAND_SCANNER_EXECUTABLE NAMES wayland-scanner)
|
||||||
|
|
||||||
|
include(FindPkgConfig)
|
||||||
pkg_check_modules(WAYLAND_PROTOCOLS REQUIRED wayland-protocols>=1.15)
|
pkg_check_modules(WAYLAND_PROTOCOLS REQUIRED wayland-protocols>=1.15)
|
||||||
pkg_get_variable(WAYLAND_PROTOCOLS_BASE wayland-protocols pkgdatadir)
|
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)
|
macro(wayland_generate protocol_file output_file)
|
||||||
add_custom_command(OUTPUT "${output_file}.h"
|
add_custom_command(OUTPUT "${output_file}.h"
|
||||||
|
@ -64,14 +84,17 @@ if (_GLFW_WAYLAND)
|
||||||
DEPENDS "${protocol_file}"
|
DEPENDS "${protocol_file}"
|
||||||
VERBATIM)
|
VERBATIM)
|
||||||
|
|
||||||
add_custom_command(OUTPUT "${output_file}.c"
|
add_custom_command(OUTPUT "${output_file}-code.h"
|
||||||
COMMAND "${WAYLAND_SCANNER_EXECUTABLE}" private-code "${protocol_file}" "${output_file}.c"
|
COMMAND "${WAYLAND_SCANNER_EXECUTABLE}" private-code "${protocol_file}" "${output_file}-code.h"
|
||||||
DEPENDS "${protocol_file}"
|
DEPENDS "${protocol_file}"
|
||||||
VERBATIM)
|
VERBATIM)
|
||||||
|
|
||||||
target_sources(glfw PRIVATE "${output_file}.h" "${output_file}.c")
|
target_sources(glfw PRIVATE "${output_file}.h" "${output_file}-code.h")
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
|
wayland_generate(
|
||||||
|
"${WAYLAND_CLIENT_PKGDATADIR}/wayland.xml"
|
||||||
|
"${GLFW_BINARY_DIR}/src/wayland-client-protocol")
|
||||||
wayland_generate(
|
wayland_generate(
|
||||||
"${WAYLAND_PROTOCOLS_BASE}/stable/xdg-shell/xdg-shell.xml"
|
"${WAYLAND_PROTOCOLS_BASE}/stable/xdg-shell/xdg-shell.xml"
|
||||||
"${GLFW_BINARY_DIR}/src/wayland-xdg-shell-client-protocol")
|
"${GLFW_BINARY_DIR}/src/wayland-xdg-shell-client-protocol")
|
||||||
|
@ -92,14 +115,17 @@ if (_GLFW_WAYLAND)
|
||||||
"${GLFW_BINARY_DIR}/src/wayland-idle-inhibit-unstable-v1-client-protocol")
|
"${GLFW_BINARY_DIR}/src/wayland-idle-inhibit-unstable-v1-client-protocol")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (WIN32 AND BUILD_SHARED_LIBS)
|
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}
|
||||||
|
@ -116,9 +142,8 @@ 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})
|
|
||||||
|
|
||||||
# Workaround for CMake not knowing about .m files before version 3.16
|
# Workaround for CMake not knowing about .m files before version 3.16
|
||||||
if (CMAKE_VERSION VERSION_LESS "3.16" AND APPLE)
|
if (CMAKE_VERSION VERSION_LESS "3.16" AND APPLE)
|
||||||
|
@ -127,17 +152,116 @@ if (CMAKE_VERSION VERSION_LESS "3.16" AND APPLE)
|
||||||
LANGUAGE C)
|
LANGUAGE C)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if (GLFW_BUILD_WIN32)
|
||||||
|
list(APPEND glfw_PKG_LIBS "-lgdi32")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (GLFW_BUILD_COCOA)
|
||||||
|
target_link_libraries(glfw PRIVATE "-framework Cocoa"
|
||||||
|
"-framework IOKit"
|
||||||
|
"-framework CoreFoundation")
|
||||||
|
|
||||||
|
set(glfw_PKG_DEPS "")
|
||||||
|
set(glfw_PKG_LIBS "-framework Cocoa -framework IOKit -framework CoreFoundation")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (GLFW_BUILD_WAYLAND)
|
||||||
|
pkg_check_modules(Wayland REQUIRED
|
||||||
|
wayland-client>=0.2.7
|
||||||
|
wayland-cursor>=0.2.7
|
||||||
|
wayland-egl>=0.2.7
|
||||||
|
xkbcommon>=0.5.0)
|
||||||
|
|
||||||
|
target_include_directories(glfw PRIVATE ${Wayland_INCLUDE_DIRS})
|
||||||
|
|
||||||
|
if (NOT CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||||
|
find_package(EpollShim)
|
||||||
|
if (EPOLLSHIM_FOUND)
|
||||||
|
target_include_directories(glfw PRIVATE ${EPOLLSHIM_INCLUDE_DIRS})
|
||||||
|
target_link_libraries(glfw PRIVATE ${EPOLLSHIM_LIBRARIES})
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (GLFW_BUILD_X11)
|
||||||
|
find_package(X11 REQUIRED)
|
||||||
|
target_include_directories(glfw PRIVATE "${X11_X11_INCLUDE_PATH}")
|
||||||
|
|
||||||
|
# Check for XRandR (modern resolution switching and gamma control)
|
||||||
|
if (NOT X11_Xrandr_INCLUDE_PATH)
|
||||||
|
message(FATAL_ERROR "RandR headers not found; install libxrandr development package")
|
||||||
|
endif()
|
||||||
|
target_include_directories(glfw PRIVATE "${X11_Xrandr_INCLUDE_PATH}")
|
||||||
|
|
||||||
|
# Check for Xinerama (legacy multi-monitor support)
|
||||||
|
if (NOT X11_Xinerama_INCLUDE_PATH)
|
||||||
|
message(FATAL_ERROR "Xinerama headers not found; install libxinerama development package")
|
||||||
|
endif()
|
||||||
|
target_include_directories(glfw PRIVATE "${X11_Xinerama_INCLUDE_PATH}")
|
||||||
|
|
||||||
|
# Check for Xkb (X keyboard extension)
|
||||||
|
if (NOT X11_Xkb_INCLUDE_PATH)
|
||||||
|
message(FATAL_ERROR "XKB headers not found; install X11 development package")
|
||||||
|
endif()
|
||||||
|
target_include_directories(glfw PRIVATE "${X11_Xkb_INCLUDE_PATH}")
|
||||||
|
|
||||||
|
# Check for Xcursor (cursor creation from RGBA images)
|
||||||
|
if (NOT X11_Xcursor_INCLUDE_PATH)
|
||||||
|
message(FATAL_ERROR "Xcursor headers not found; install libxcursor development package")
|
||||||
|
endif()
|
||||||
|
target_include_directories(glfw PRIVATE "${X11_Xcursor_INCLUDE_PATH}")
|
||||||
|
|
||||||
|
# Check for XInput (modern HID input)
|
||||||
|
if (NOT X11_Xi_INCLUDE_PATH)
|
||||||
|
message(FATAL_ERROR "XInput headers not found; install libxi development package")
|
||||||
|
endif()
|
||||||
|
target_include_directories(glfw PRIVATE "${X11_Xi_INCLUDE_PATH}")
|
||||||
|
|
||||||
|
# Check for X Shape (custom window input shape)
|
||||||
|
if (NOT X11_Xshape_INCLUDE_PATH)
|
||||||
|
message(FATAL_ERROR "X Shape headers not found; install libxext development package")
|
||||||
|
endif()
|
||||||
|
target_include_directories(glfw PRIVATE "${X11_Xshape_INCLUDE_PATH}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (UNIX AND NOT APPLE)
|
||||||
|
find_library(RT_LIBRARY rt)
|
||||||
|
mark_as_advanced(RT_LIBRARY)
|
||||||
|
if (RT_LIBRARY)
|
||||||
|
target_link_libraries(glfw PRIVATE "${RT_LIBRARY}")
|
||||||
|
list(APPEND glfw_PKG_LIBS "-lrt")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
find_library(MATH_LIBRARY m)
|
||||||
|
mark_as_advanced(MATH_LIBRARY)
|
||||||
|
if (MATH_LIBRARY)
|
||||||
|
target_link_libraries(glfw PRIVATE "${MATH_LIBRARY}")
|
||||||
|
list(APPEND glfw_PKG_LIBS "-lm")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (CMAKE_DL_LIBS)
|
||||||
|
target_link_libraries(glfw PRIVATE "${CMAKE_DL_LIBS}")
|
||||||
|
list(APPEND glfw_PKG_LIBS "-l${CMAKE_DL_LIBS}")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
# Make GCC warn about declarations that VS 2010 and 2012 won't accept for all
|
# 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)
|
# source files that VS will build (Clang ignores this because we set -std=c99)
|
||||||
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
|
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
|
||||||
set_source_files_properties(context.c init.c input.c monitor.c vulkan.c
|
set_source_files_properties(context.c init.c input.c monitor.c platform.c vulkan.c
|
||||||
window.c win32_init.c win32_joystick.c
|
window.c null_init.c null_joystick.c null_monitor.c
|
||||||
win32_monitor.c win32_time.c win32_thread.c
|
null_window.c win32_init.c win32_joystick.c win32_module.c
|
||||||
win32_window.c wgl_context.c egl_context.c
|
win32_monitor.c win32_time.c win32_thread.c win32_window.c
|
||||||
osmesa_context.c PROPERTIES
|
wgl_context.c egl_context.c osmesa_context.c PROPERTIES
|
||||||
COMPILE_FLAGS -Wdeclaration-after-statement)
|
COMPILE_FLAGS -Wdeclaration-after-statement)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if (WIN32)
|
||||||
|
if (GLFW_USE_HYBRID_HPG)
|
||||||
|
target_compile_definitions(glfw PRIVATE _GLFW_USE_HYBRID_HPG)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
# Enable a reasonable set of warnings
|
# Enable a reasonable set of warnings
|
||||||
# NOTE: The order matters here, Clang-CL matches both MSVC and Clang
|
# NOTE: The order matters here, Clang-CL matches both MSVC and Clang
|
||||||
if (MSVC)
|
if (MSVC)
|
||||||
|
@ -149,7 +273,7 @@ elseif (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR
|
||||||
target_compile_options(glfw PRIVATE "-Wall")
|
target_compile_options(glfw PRIVATE "-Wall")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (_GLFW_WIN32)
|
if (GLFW_BUILD_WIN32)
|
||||||
target_compile_definitions(glfw PRIVATE UNICODE _UNICODE)
|
target_compile_definitions(glfw PRIVATE UNICODE _UNICODE)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@ -191,13 +315,13 @@ if (MSVC90)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Workaround for -std=c99 on Linux disabling _DEFAULT_SOURCE (POSIX 2008 and more)
|
# Workaround for -std=c99 on Linux disabling _DEFAULT_SOURCE (POSIX 2008 and more)
|
||||||
if (_GLFW_X11 OR _GLFW_WAYLAND OR _GLFW_OSMESA)
|
if (GLFW_BUILD_X11 OR GLFW_BUILD_WAYLAND)
|
||||||
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||||
target_compile_definitions(glfw PRIVATE _DEFAULT_SOURCE)
|
target_compile_definitions(glfw PRIVATE _DEFAULT_SOURCE)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (BUILD_SHARED_LIBS)
|
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
|
||||||
|
@ -252,6 +376,20 @@ if (BUILD_SHARED_LIBS)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
foreach(arg ${glfw_PKG_DEPS})
|
||||||
|
string(APPEND deps " ${arg}")
|
||||||
|
endforeach()
|
||||||
|
foreach(arg ${glfw_PKG_LIBS})
|
||||||
|
string(APPEND libs " ${arg}")
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
set(GLFW_PKG_CONFIG_REQUIRES_PRIVATE "${deps}" CACHE INTERNAL
|
||||||
|
"GLFW pkg-config Requires.private")
|
||||||
|
set(GLFW_PKG_CONFIG_LIBS_PRIVATE "${libs}" CACHE INTERNAL
|
||||||
|
"GLFW pkg-config Libs.private")
|
||||||
|
|
||||||
|
configure_file("${GLFW_SOURCE_DIR}/CMake/glfw3.pc.in" glfw3.pc @ONLY)
|
||||||
|
|
||||||
if (GLFW_INSTALL)
|
if (GLFW_INSTALL)
|
||||||
install(TARGETS glfw
|
install(TARGETS glfw
|
||||||
EXPORT glfwTargets
|
EXPORT glfwTargets
|
||||||
|
|
138
src/cocoa_init.m
138
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));
|
||||||
|
|
||||||
|
@ -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,15 +408,13 @@ 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
|
||||||
|
@ -444,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
|
||||||
|
@ -463,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)
|
||||||
|
@ -478,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;
|
||||||
|
@ -489,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 {
|
||||||
|
|
||||||
|
@ -547,9 +620,7 @@ int _glfwPlatformInit(void)
|
||||||
if (!initializeTIS())
|
if (!initializeTIS())
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
|
|
||||||
_glfwInitTimerNS();
|
_glfwPollMonitorsCocoa();
|
||||||
|
|
||||||
_glfwPollMonitorsNS();
|
|
||||||
|
|
||||||
if (![[NSRunningApplication currentApplication] isFinishedLaunching])
|
if (![[NSRunningApplication currentApplication] isFinishedLaunching])
|
||||||
[NSApp run];
|
[NSApp run];
|
||||||
|
@ -563,7 +634,7 @@ int _glfwPlatformInit(void)
|
||||||
} // autoreleasepool
|
} // autoreleasepool
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformTerminate(void)
|
void _glfwTerminateCocoa(void)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
|
|
||||||
|
@ -602,19 +673,12 @@ 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();
|
||||||
|
_glfwTerminateEGL();
|
||||||
|
_glfwTerminateOSMesa();
|
||||||
|
|
||||||
} // autoreleasepool
|
} // autoreleasepool
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* _glfwPlatformGetVersionString(void)
|
|
||||||
{
|
|
||||||
return _GLFW_VERSION_NUMBER " Cocoa NSGL EGL OSMesa"
|
|
||||||
#if defined(_GLFW_BUILD_DLL)
|
|
||||||
" dynamic"
|
|
||||||
#endif
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -26,13 +26,11 @@
|
||||||
|
|
||||||
#include <IOKit/IOKitLib.h>
|
#include <IOKit/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
|
#define GLFW_BUILD_COCOA_MAPPINGS
|
||||||
|
|
||||||
// Cocoa-specific per-joystick data
|
// Cocoa-specific per-joystick data
|
||||||
|
@ -45,3 +43,9 @@ typedef struct _GLFWjoystickNS
|
||||||
CFMutableArrayRef hats;
|
CFMutableArrayRef hats;
|
||||||
} _GLFWjoystickNS;
|
} _GLFWjoystickNS;
|
||||||
|
|
||||||
|
GLFWbool _glfwInitJoysticksCocoa(void);
|
||||||
|
void _glfwTerminateJoysticksCocoa(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)
|
||||||
{
|
{
|
||||||
|
@ -307,7 +302,7 @@ static void removeCallback(void* context,
|
||||||
////// GLFW platform API //////
|
////// GLFW platform API //////
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
GLFWbool _glfwPlatformInitJoysticks(void)
|
GLFWbool _glfwInitJoysticksCocoa(void)
|
||||||
{
|
{
|
||||||
CFMutableArrayRef matching;
|
CFMutableArrayRef matching;
|
||||||
const long usages[] =
|
const long usages[] =
|
||||||
|
@ -384,11 +379,9 @@ GLFWbool _glfwPlatformInitJoysticks(void)
|
||||||
return GLFW_TRUE;
|
return GLFW_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformTerminateJoysticks(void)
|
void _glfwTerminateJoysticksCocoa(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)
|
if (_glfw.ns.hidManager)
|
||||||
|
@ -399,13 +392,11 @@ void _glfwPlatformTerminateJoysticks(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int _glfwPlatformPollJoystick(_GLFWjoystick* js, int mode)
|
int _glfwPollJoystickCocoa(_GLFWjoystick* js, int mode)
|
||||||
{
|
{
|
||||||
if (mode & _GLFW_POLL_AXES)
|
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);
|
||||||
|
@ -430,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);
|
||||||
|
@ -441,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] =
|
||||||
{
|
{
|
||||||
|
@ -469,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))
|
||||||
|
|
|
@ -58,7 +58,7 @@ static char* getMonitorName(CGDirectDisplayID displayID, NSScreen* screen)
|
||||||
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)
|
||||||
{
|
{
|
||||||
|
@ -98,11 +98,7 @@ static char* getMonitorName(CGDirectDisplayID displayID, NSScreen* screen)
|
||||||
IOObjectRelease(it);
|
IOObjectRelease(it);
|
||||||
|
|
||||||
if (!service)
|
if (!service)
|
||||||
{
|
|
||||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
|
||||||
"Cocoa: Failed to find service port for display");
|
|
||||||
return _glfw_strdup("Display");
|
return _glfw_strdup("Display");
|
||||||
}
|
|
||||||
|
|
||||||
CFDictionaryRef names =
|
CFDictionaryRef names =
|
||||||
CFDictionaryGetValue(info, CFSTR(kDisplayProductName));
|
CFDictionaryGetValue(info, CFSTR(kDisplayProductName));
|
||||||
|
@ -120,7 +116,7 @@ static char* getMonitorName(CGDirectDisplayID displayID, NSScreen* screen)
|
||||||
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);
|
||||||
|
@ -231,7 +227,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)
|
||||||
{
|
{
|
||||||
|
@ -297,11 +293,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++)
|
||||||
|
@ -311,7 +307,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*));
|
||||||
|
@ -363,7 +359,7 @@ void _glfwPollMonitorsNS(void)
|
||||||
monitor->ns.unitNumber = unitNumber;
|
monitor->ns.unitNumber = unitNumber;
|
||||||
monitor->ns.screen = screen;
|
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)
|
||||||
|
@ -379,16 +375,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)
|
||||||
|
@ -428,7 +424,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)
|
||||||
{
|
{
|
||||||
|
@ -447,11 +443,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 {
|
||||||
|
|
||||||
|
@ -465,8 +461,8 @@ 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 {
|
||||||
|
|
||||||
|
@ -487,9 +483,9 @@ 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 {
|
||||||
|
|
||||||
|
@ -504,7 +500,7 @@ void _glfwPlatformGetMonitorWorkarea(_GLFWmonitor* monitor,
|
||||||
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)
|
||||||
|
@ -513,7 +509,7 @@ void _glfwPlatformGetMonitorWorkarea(_GLFWmonitor* monitor,
|
||||||
} // autoreleasepool
|
} // autoreleasepool
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* count)
|
GLFWvidmode* _glfwGetVideoModesCocoa(_GLFWmonitor* monitor, int* count)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
|
|
||||||
|
@ -521,7 +517,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++)
|
||||||
{
|
{
|
||||||
|
@ -553,7 +549,7 @@ GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* count)
|
||||||
} // autoreleasepool
|
} // autoreleasepool
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode *mode)
|
void _glfwGetVideoModeCocoa(_GLFWmonitor* monitor, GLFWvidmode *mode)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
|
|
||||||
|
@ -564,12 +560,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,
|
||||||
|
@ -587,17 +583,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++)
|
||||||
{
|
{
|
||||||
|
@ -612,7 +608,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,9 +25,9 @@
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
#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
|
||||||
|
@ -42,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
|
||||||
|
@ -62,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;
|
||||||
|
|
||||||
|
@ -84,19 +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;
|
||||||
|
#define GLFW_COCOA_CURSOR_STATE _GLFWcursorNS ns;
|
||||||
|
|
||||||
#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_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
|
||||||
|
@ -108,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
|
||||||
|
@ -130,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
|
||||||
|
@ -164,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
|
||||||
|
@ -176,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
|
||||||
|
@ -184,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,19 +105,20 @@ 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);
|
||||||
CGAssociateMouseAndMouseCursorPosition(false);
|
CGAssociateMouseAndMouseCursorPosition(false);
|
||||||
}
|
}
|
||||||
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
|
||||||
|
@ -285,7 +286,7 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
|
||||||
_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,7 +318,7 @@ 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);
|
||||||
}
|
}
|
||||||
|
@ -360,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;
|
||||||
|
@ -646,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]);
|
||||||
|
@ -654,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;
|
||||||
|
@ -802,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);
|
||||||
}
|
}
|
||||||
|
@ -871,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;
|
||||||
}
|
}
|
||||||
|
@ -884,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;
|
||||||
}
|
}
|
||||||
|
@ -894,10 +893,10 @@ 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)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
|
|
||||||
|
@ -932,13 +931,31 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
|
||||||
if (!_glfwCreateContextOSMesa(window, ctxconfig, fbconfig))
|
if (!_glfwCreateContextOSMesa(window, ctxconfig, fbconfig))
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!_glfwRefreshContextAttribs(window, ctxconfig))
|
||||||
|
return GLFW_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (wndconfig->mousePassthrough)
|
||||||
|
_glfwSetWindowMousePassthroughCocoa(window, GLFW_TRUE);
|
||||||
|
|
||||||
if (window->monitor)
|
if (window->monitor)
|
||||||
{
|
{
|
||||||
_glfwPlatformShowWindow(window);
|
_glfwShowWindowCocoa(window);
|
||||||
_glfwPlatformFocusWindow(window);
|
_glfwFocusWindowCocoa(window);
|
||||||
acquireMonitor(window);
|
acquireMonitor(window);
|
||||||
|
|
||||||
|
if (wndconfig->centerCursor)
|
||||||
|
_glfwCenterCursorInContentArea(window);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (wndconfig->visible)
|
||||||
|
{
|
||||||
|
_glfwShowWindowCocoa(window);
|
||||||
|
if (wndconfig->focused)
|
||||||
|
_glfwFocusWindowCocoa(window);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return GLFW_TRUE;
|
return GLFW_TRUE;
|
||||||
|
@ -946,7 +963,7 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
|
||||||
} // autoreleasepool
|
} // autoreleasepool
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformDestroyWindow(_GLFWwindow* window)
|
void _glfwDestroyWindowCocoa(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
|
|
||||||
|
@ -972,12 +989,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);
|
||||||
|
@ -988,14 +1005,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)
|
||||||
{
|
{
|
||||||
_glfwInputError(GLFW_FEATURE_UNAVAILABLE,
|
_glfwInputError(GLFW_FEATURE_UNAVAILABLE,
|
||||||
"Cocoa: Regular windows do not have icons on macOS");
|
"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 {
|
||||||
|
|
||||||
|
@ -1005,24 +1022,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 {
|
||||||
|
|
||||||
|
@ -1036,7 +1053,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 {
|
||||||
|
|
||||||
|
@ -1058,9 +1075,9 @@ 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)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
|
|
||||||
|
@ -1077,7 +1094,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)
|
||||||
|
@ -1087,7 +1104,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 {
|
||||||
|
|
||||||
|
@ -1102,9 +1119,9 @@ 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)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
|
|
||||||
|
@ -1125,8 +1142,8 @@ void _glfwPlatformGetWindowFrameSize(_GLFWwindow* window,
|
||||||
} // autoreleasepool
|
} // autoreleasepool
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformGetWindowContentScale(_GLFWwindow* window,
|
void _glfwGetWindowContentScaleCocoa(_GLFWwindow* window,
|
||||||
float* xscale, float* yscale)
|
float* xscale, float* yscale)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
|
|
||||||
|
@ -1141,14 +1158,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])
|
||||||
|
@ -1158,7 +1175,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])
|
||||||
|
@ -1166,28 +1183,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
|
||||||
|
@ -1199,11 +1216,11 @@ 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,
|
||||||
int refreshRate)
|
int refreshRate)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
|
|
||||||
|
@ -1217,7 +1234,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)];
|
||||||
|
@ -1235,7 +1252,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];
|
||||||
|
@ -1251,7 +1268,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];
|
||||||
|
@ -1292,35 +1309,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 {
|
||||||
|
|
||||||
|
@ -1338,21 +1355,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)];
|
||||||
|
@ -1360,7 +1377,7 @@ void _glfwPlatformSetWindowDecorated(_GLFWwindow* window, GLFWbool enabled)
|
||||||
} // autoreleasepool
|
} // autoreleasepool
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled)
|
void _glfwSetWindowFloatingCocoa(_GLFWwindow* window, GLFWbool enabled)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
if (enabled)
|
if (enabled)
|
||||||
|
@ -1370,39 +1387,39 @@ void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled)
|
||||||
} // autoreleasepool
|
} // autoreleasepool
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformSetWindowMousePassthrough(_GLFWwindow* window, GLFWbool enabled)
|
void _glfwSetWindowMousePassthroughCocoa(_GLFWwindow* window, GLFWbool enabled)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
[window->ns.object setIgnoresMouseEvents:enabled];
|
[window->ns.object setIgnoresMouseEvents:enabled];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float _glfwPlatformGetWindowOpacity(_GLFWwindow* window)
|
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,
|
_glfwInputError(GLFW_FEATURE_UNIMPLEMENTED,
|
||||||
"Cocoa: Raw mouse motion not yet implemented");
|
"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 {
|
||||||
|
|
||||||
|
@ -1421,7 +1438,7 @@ void _glfwPlatformPollEvents(void)
|
||||||
} // autoreleasepool
|
} // autoreleasepool
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformWaitEvents(void)
|
void _glfwWaitEventsCocoa(void)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
|
|
||||||
|
@ -1434,12 +1451,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 {
|
||||||
|
|
||||||
|
@ -1451,12 +1468,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 {
|
||||||
|
|
||||||
|
@ -1474,7 +1491,7 @@ void _glfwPlatformPostEmptyEvent(void)
|
||||||
} // autoreleasepool
|
} // autoreleasepool
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformGetCursorPos(_GLFWwindow* window, double* xpos, double* ypos)
|
void _glfwGetCursorPosCocoa(_GLFWwindow* window, double* xpos, double* ypos)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
|
|
||||||
|
@ -1490,7 +1507,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 {
|
||||||
|
|
||||||
|
@ -1515,21 +1532,26 @@ 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 {
|
||||||
|
|
||||||
|
@ -1578,14 +1600,14 @@ 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)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
|
|
||||||
|
@ -1627,7 +1649,7 @@ int _glfwPlatformCreateCursor(_GLFWcursor* cursor,
|
||||||
} // autoreleasepool
|
} // autoreleasepool
|
||||||
}
|
}
|
||||||
|
|
||||||
int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape)
|
int _glfwCreateStandardCursorCocoa(_GLFWcursor* cursor, int shape)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
|
|
||||||
|
@ -1701,7 +1723,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)
|
||||||
|
@ -1709,7 +1731,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))
|
||||||
|
@ -1717,7 +1739,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];
|
||||||
|
@ -1726,7 +1748,7 @@ void _glfwPlatformSetClipboardString(const char* string)
|
||||||
} // autoreleasepool
|
} // autoreleasepool
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* _glfwPlatformGetClipboardString(void)
|
const char* _glfwGetClipboardStringCocoa(void)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
|
|
||||||
|
@ -1747,7 +1769,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;
|
||||||
|
@ -1755,7 +1777,7 @@ const char* _glfwPlatformGetClipboardString(void)
|
||||||
} // autoreleasepool
|
} // autoreleasepool
|
||||||
}
|
}
|
||||||
|
|
||||||
EGLenum _glfwPlatformGetEGLPlatform(EGLint** attribs)
|
EGLenum _glfwGetEGLPlatformCocoa(EGLint** attribs)
|
||||||
{
|
{
|
||||||
if (_glfw.egl.ANGLE_platform_angle)
|
if (_glfw.egl.ANGLE_platform_angle)
|
||||||
{
|
{
|
||||||
|
@ -1775,7 +1797,7 @@ EGLenum _glfwPlatformGetEGLPlatform(EGLint** attribs)
|
||||||
|
|
||||||
if (type)
|
if (type)
|
||||||
{
|
{
|
||||||
*attribs = calloc(3, sizeof(EGLint));
|
*attribs = _glfw_calloc(3, sizeof(EGLint));
|
||||||
(*attribs)[0] = EGL_PLATFORM_ANGLE_TYPE_ANGLE;
|
(*attribs)[0] = EGL_PLATFORM_ANGLE_TYPE_ANGLE;
|
||||||
(*attribs)[1] = type;
|
(*attribs)[1] = type;
|
||||||
(*attribs)[2] = EGL_NONE;
|
(*attribs)[2] = EGL_NONE;
|
||||||
|
@ -1786,17 +1808,17 @@ EGLenum _glfwPlatformGetEGLPlatform(EGLint** attribs)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
EGLNativeDisplayType _glfwPlatformGetEGLNativeDisplay(void)
|
EGLNativeDisplayType _glfwGetEGLNativeDisplayCocoa(void)
|
||||||
{
|
{
|
||||||
return EGL_DEFAULT_DISPLAY;
|
return EGL_DEFAULT_DISPLAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
EGLNativeWindowType _glfwPlatformGetEGLNativeWindow(_GLFWwindow* window)
|
EGLNativeWindowType _glfwGetEGLNativeWindowCocoa(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
return window->ns.layer;
|
return window->ns.layer;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformGetRequiredInstanceExtensions(char** extensions)
|
void _glfwGetRequiredInstanceExtensionsCocoa(char** extensions)
|
||||||
{
|
{
|
||||||
if (_glfw.vk.KHR_surface && _glfw.vk.EXT_metal_surface)
|
if (_glfw.vk.KHR_surface && _glfw.vk.EXT_metal_surface)
|
||||||
{
|
{
|
||||||
|
@ -1810,17 +1832,17 @@ 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)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
|
|
||||||
|
@ -1917,6 +1939,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -609,10 +609,12 @@ GLFWbool _glfwStringInExtensionString(const char* string, const char* extensions
|
||||||
GLFWAPI void glfwMakeContextCurrent(GLFWwindow* handle)
|
GLFWAPI void glfwMakeContextCurrent(GLFWwindow* handle)
|
||||||
{
|
{
|
||||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||||
_GLFWwindow* previous = _glfwPlatformGetTls(&_glfw.contextSlot);
|
_GLFWwindow* previous;
|
||||||
|
|
||||||
_GLFW_REQUIRE_INIT();
|
_GLFW_REQUIRE_INIT();
|
||||||
|
|
||||||
|
previous = _glfwPlatformGetTls(&_glfw.contextSlot);
|
||||||
|
|
||||||
if (window && window->context.client == GLFW_NO_API)
|
if (window && window->context.client == GLFW_NO_API)
|
||||||
{
|
{
|
||||||
_glfwInputError(GLFW_NO_WINDOW_CONTEXT,
|
_glfwInputError(GLFW_NO_WINDOW_CONTEXT,
|
||||||
|
|
|
@ -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};
|
||||||
|
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -316,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__) || defined(__NetBSD__)
|
||||||
|
"libEGL.so",
|
||||||
#else
|
#else
|
||||||
"libEGL.so.1",
|
"libEGL.so.1",
|
||||||
#endif
|
#endif
|
||||||
|
@ -327,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;
|
||||||
}
|
}
|
||||||
|
@ -341,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 ||
|
||||||
|
@ -429,18 +440,18 @@ GLFWbool _glfwInitEGL(void)
|
||||||
eglGetProcAddress("eglCreatePlatformWindowSurfaceEXT");
|
eglGetProcAddress("eglCreatePlatformWindowSurfaceEXT");
|
||||||
}
|
}
|
||||||
|
|
||||||
_glfw.egl.platform = _glfwPlatformGetEGLPlatform(&attribs);
|
_glfw.egl.platform = _glfw.platform.getEGLPlatform(&attribs);
|
||||||
if (_glfw.egl.platform)
|
if (_glfw.egl.platform)
|
||||||
{
|
{
|
||||||
_glfw.egl.display =
|
_glfw.egl.display =
|
||||||
eglGetPlatformDisplayEXT(_glfw.egl.platform,
|
eglGetPlatformDisplayEXT(_glfw.egl.platform,
|
||||||
_glfwPlatformGetEGLNativeDisplay(),
|
_glfw.platform.getEGLNativeDisplay(),
|
||||||
attribs);
|
attribs);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
_glfw.egl.display = eglGetDisplay(_glfwPlatformGetEGLNativeDisplay());
|
_glfw.egl.display = eglGetDisplay(_glfw.platform.getEGLNativeDisplay());
|
||||||
|
|
||||||
free(attribs);
|
_glfw_free(attribs);
|
||||||
|
|
||||||
if (_glfw.egl.display == EGL_NO_DISPLAY)
|
if (_glfw.egl.display == EGL_NO_DISPLAY)
|
||||||
{
|
{
|
||||||
|
@ -472,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;
|
||||||
}
|
}
|
||||||
|
@ -488,12 +501,12 @@ 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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#define setAttrib(a, v) \
|
#define SET_ATTRIB(a, v) \
|
||||||
{ \
|
{ \
|
||||||
assert(((size_t) index + 1) < sizeof(attribs) / sizeof(attribs[0])); \
|
assert(((size_t) index + 1) < sizeof(attribs) / sizeof(attribs[0])); \
|
||||||
attribs[index++] = a; \
|
attribs[index++] = a; \
|
||||||
|
@ -571,13 +584,13 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window,
|
||||||
{
|
{
|
||||||
if (ctxconfig->robustness == GLFW_NO_RESET_NOTIFICATION)
|
if (ctxconfig->robustness == GLFW_NO_RESET_NOTIFICATION)
|
||||||
{
|
{
|
||||||
setAttrib(EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR,
|
SET_ATTRIB(EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR,
|
||||||
EGL_NO_RESET_NOTIFICATION_KHR);
|
EGL_NO_RESET_NOTIFICATION_KHR);
|
||||||
}
|
}
|
||||||
else if (ctxconfig->robustness == GLFW_LOSE_CONTEXT_ON_RESET)
|
else if (ctxconfig->robustness == GLFW_LOSE_CONTEXT_ON_RESET)
|
||||||
{
|
{
|
||||||
setAttrib(EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR,
|
SET_ATTRIB(EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR,
|
||||||
EGL_LOSE_CONTEXT_ON_RESET_KHR);
|
EGL_LOSE_CONTEXT_ON_RESET_KHR);
|
||||||
}
|
}
|
||||||
|
|
||||||
flags |= EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR;
|
flags |= EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR;
|
||||||
|
@ -586,42 +599,42 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window,
|
||||||
if (ctxconfig->noerror)
|
if (ctxconfig->noerror)
|
||||||
{
|
{
|
||||||
if (_glfw.egl.KHR_create_context_no_error)
|
if (_glfw.egl.KHR_create_context_no_error)
|
||||||
setAttrib(EGL_CONTEXT_OPENGL_NO_ERROR_KHR, GLFW_TRUE);
|
SET_ATTRIB(EGL_CONTEXT_OPENGL_NO_ERROR_KHR, GLFW_TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctxconfig->major != 1 || ctxconfig->minor != 0)
|
if (ctxconfig->major != 1 || ctxconfig->minor != 0)
|
||||||
{
|
{
|
||||||
setAttrib(EGL_CONTEXT_MAJOR_VERSION_KHR, ctxconfig->major);
|
SET_ATTRIB(EGL_CONTEXT_MAJOR_VERSION_KHR, ctxconfig->major);
|
||||||
setAttrib(EGL_CONTEXT_MINOR_VERSION_KHR, ctxconfig->minor);
|
SET_ATTRIB(EGL_CONTEXT_MINOR_VERSION_KHR, ctxconfig->minor);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mask)
|
if (mask)
|
||||||
setAttrib(EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR, mask);
|
SET_ATTRIB(EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR, mask);
|
||||||
|
|
||||||
if (flags)
|
if (flags)
|
||||||
setAttrib(EGL_CONTEXT_FLAGS_KHR, flags);
|
SET_ATTRIB(EGL_CONTEXT_FLAGS_KHR, flags);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (ctxconfig->client == GLFW_OPENGL_ES_API)
|
if (ctxconfig->client == GLFW_OPENGL_ES_API)
|
||||||
setAttrib(EGL_CONTEXT_CLIENT_VERSION, ctxconfig->major);
|
SET_ATTRIB(EGL_CONTEXT_CLIENT_VERSION, ctxconfig->major);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_glfw.egl.KHR_context_flush_control)
|
if (_glfw.egl.KHR_context_flush_control)
|
||||||
{
|
{
|
||||||
if (ctxconfig->release == GLFW_RELEASE_BEHAVIOR_NONE)
|
if (ctxconfig->release == GLFW_RELEASE_BEHAVIOR_NONE)
|
||||||
{
|
{
|
||||||
setAttrib(EGL_CONTEXT_RELEASE_BEHAVIOR_KHR,
|
SET_ATTRIB(EGL_CONTEXT_RELEASE_BEHAVIOR_KHR,
|
||||||
EGL_CONTEXT_RELEASE_BEHAVIOR_NONE_KHR);
|
EGL_CONTEXT_RELEASE_BEHAVIOR_NONE_KHR);
|
||||||
}
|
}
|
||||||
else if (ctxconfig->release == GLFW_RELEASE_BEHAVIOR_FLUSH)
|
else if (ctxconfig->release == GLFW_RELEASE_BEHAVIOR_FLUSH)
|
||||||
{
|
{
|
||||||
setAttrib(EGL_CONTEXT_RELEASE_BEHAVIOR_KHR,
|
SET_ATTRIB(EGL_CONTEXT_RELEASE_BEHAVIOR_KHR,
|
||||||
EGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_KHR);
|
EGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_KHR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setAttrib(EGL_NONE, EGL_NONE);
|
SET_ATTRIB(EGL_NONE, EGL_NONE);
|
||||||
|
|
||||||
window->context.egl.handle = eglCreateContext(_glfw.egl.display,
|
window->context.egl.handle = eglCreateContext(_glfw.egl.display,
|
||||||
config, share, attribs);
|
config, share, attribs);
|
||||||
|
@ -640,15 +653,18 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window,
|
||||||
if (fbconfig->sRGB)
|
if (fbconfig->sRGB)
|
||||||
{
|
{
|
||||||
if (_glfw.egl.KHR_gl_colorspace)
|
if (_glfw.egl.KHR_gl_colorspace)
|
||||||
setAttrib(EGL_GL_COLORSPACE_KHR, EGL_GL_COLORSPACE_SRGB_KHR);
|
SET_ATTRIB(EGL_GL_COLORSPACE_KHR, EGL_GL_COLORSPACE_SRGB_KHR);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!fbconfig->doublebuffer)
|
if (!fbconfig->doublebuffer)
|
||||||
setAttrib(EGL_RENDER_BUFFER, EGL_SINGLE_BUFFER);
|
SET_ATTRIB(EGL_RENDER_BUFFER, EGL_SINGLE_BUFFER);
|
||||||
|
|
||||||
setAttrib(EGL_NONE, EGL_NONE);
|
if (_glfw.egl.EXT_present_opaque)
|
||||||
|
SET_ATTRIB(EGL_PRESENT_OPAQUE_EXT, !fbconfig->transparent);
|
||||||
|
|
||||||
native = _glfwPlatformGetEGLNativeWindow(window);
|
SET_ATTRIB(EGL_NONE, EGL_NONE);
|
||||||
|
|
||||||
|
native = _glfw.platform.getEGLNativeWindow(window);
|
||||||
// HACK: ANGLE does not implement eglCreatePlatformWindowSurfaceEXT
|
// HACK: ANGLE does not implement eglCreatePlatformWindowSurfaceEXT
|
||||||
// despite reporting EGL_EXT_platform_base
|
// despite reporting EGL_EXT_platform_base
|
||||||
if (_glfw.egl.platform && _glfw.egl.platform != EGL_PLATFORM_ANGLE_ANGLE)
|
if (_glfw.egl.platform && _glfw.egl.platform != EGL_PLATFORM_ANGLE_ANGLE)
|
||||||
|
@ -686,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__) || defined(__NetBSD__)
|
||||||
|
"libGLESv1_CM.so",
|
||||||
#else
|
#else
|
||||||
"libGLESv1_CM.so.1",
|
"libGLESv1_CM.so.1",
|
||||||
"libGLES_CM.so.1",
|
"libGLES_CM.so.1",
|
||||||
|
@ -703,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__) || defined(__NetBSD__)
|
||||||
|
"libGLESv2.so",
|
||||||
#else
|
#else
|
||||||
"libGLESv2.so.2",
|
"libGLESv2.so.2",
|
||||||
#endif
|
#endif
|
||||||
|
@ -714,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__) || defined(__NetBSD__)
|
||||||
|
"libGL.so",
|
||||||
#else
|
#else
|
||||||
"libGL.so.1",
|
"libGL.so.1",
|
||||||
#endif
|
#endif
|
||||||
|
@ -737,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;
|
||||||
}
|
}
|
||||||
|
@ -760,7 +782,7 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window,
|
||||||
return GLFW_TRUE;
|
return GLFW_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef setAttrib
|
#undef SET_ATTRIB
|
||||||
|
|
||||||
// Returns the Visual and depth of the chosen EGLConfig
|
// Returns the Visual and depth of the chosen EGLConfig
|
||||||
//
|
//
|
||||||
|
@ -821,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;
|
||||||
|
@ -835,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,229 +0,0 @@
|
||||||
//========================================================================
|
|
||||||
// GLFW 3.4 EGL - www.glfw.org
|
|
||||||
//------------------------------------------------------------------------
|
|
||||||
// Copyright (c) 2002-2006 Marcus Geelnard
|
|
||||||
// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>
|
|
||||||
//
|
|
||||||
// This software is provided 'as-is', without any express or implied
|
|
||||||
// warranty. In no event will the authors be held liable for any damages
|
|
||||||
// arising from the use of this software.
|
|
||||||
//
|
|
||||||
// Permission is granted to anyone to use this software for any purpose,
|
|
||||||
// including commercial applications, and to alter it and redistribute it
|
|
||||||
// freely, subject to the following restrictions:
|
|
||||||
//
|
|
||||||
// 1. The origin of this software must not be misrepresented; you must not
|
|
||||||
// claim that you wrote the original software. If you use this software
|
|
||||||
// in a product, an acknowledgment in the product documentation would
|
|
||||||
// be appreciated but is not required.
|
|
||||||
//
|
|
||||||
// 2. Altered source versions must be plainly marked as such, and must not
|
|
||||||
// be misrepresented as being the original software.
|
|
||||||
//
|
|
||||||
// 3. This notice may not be removed or altered from any source
|
|
||||||
// distribution.
|
|
||||||
//
|
|
||||||
//========================================================================
|
|
||||||
|
|
||||||
#if defined(_GLFW_WIN32)
|
|
||||||
#define EGLAPIENTRY __stdcall
|
|
||||||
#else
|
|
||||||
#define EGLAPIENTRY
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define EGL_SUCCESS 0x3000
|
|
||||||
#define EGL_NOT_INITIALIZED 0x3001
|
|
||||||
#define EGL_BAD_ACCESS 0x3002
|
|
||||||
#define EGL_BAD_ALLOC 0x3003
|
|
||||||
#define EGL_BAD_ATTRIBUTE 0x3004
|
|
||||||
#define EGL_BAD_CONFIG 0x3005
|
|
||||||
#define EGL_BAD_CONTEXT 0x3006
|
|
||||||
#define EGL_BAD_CURRENT_SURFACE 0x3007
|
|
||||||
#define EGL_BAD_DISPLAY 0x3008
|
|
||||||
#define EGL_BAD_MATCH 0x3009
|
|
||||||
#define EGL_BAD_NATIVE_PIXMAP 0x300a
|
|
||||||
#define EGL_BAD_NATIVE_WINDOW 0x300b
|
|
||||||
#define EGL_BAD_PARAMETER 0x300c
|
|
||||||
#define EGL_BAD_SURFACE 0x300d
|
|
||||||
#define EGL_CONTEXT_LOST 0x300e
|
|
||||||
#define EGL_COLOR_BUFFER_TYPE 0x303f
|
|
||||||
#define EGL_RGB_BUFFER 0x308e
|
|
||||||
#define EGL_SURFACE_TYPE 0x3033
|
|
||||||
#define EGL_WINDOW_BIT 0x0004
|
|
||||||
#define EGL_RENDERABLE_TYPE 0x3040
|
|
||||||
#define EGL_OPENGL_ES_BIT 0x0001
|
|
||||||
#define EGL_OPENGL_ES2_BIT 0x0004
|
|
||||||
#define EGL_OPENGL_BIT 0x0008
|
|
||||||
#define EGL_ALPHA_SIZE 0x3021
|
|
||||||
#define EGL_BLUE_SIZE 0x3022
|
|
||||||
#define EGL_GREEN_SIZE 0x3023
|
|
||||||
#define EGL_RED_SIZE 0x3024
|
|
||||||
#define EGL_DEPTH_SIZE 0x3025
|
|
||||||
#define EGL_STENCIL_SIZE 0x3026
|
|
||||||
#define EGL_SAMPLES 0x3031
|
|
||||||
#define EGL_OPENGL_ES_API 0x30a0
|
|
||||||
#define EGL_OPENGL_API 0x30a2
|
|
||||||
#define EGL_NONE 0x3038
|
|
||||||
#define EGL_RENDER_BUFFER 0x3086
|
|
||||||
#define EGL_SINGLE_BUFFER 0x3085
|
|
||||||
#define EGL_EXTENSIONS 0x3055
|
|
||||||
#define EGL_CONTEXT_CLIENT_VERSION 0x3098
|
|
||||||
#define EGL_NATIVE_VISUAL_ID 0x302e
|
|
||||||
#define EGL_NO_SURFACE ((EGLSurface) 0)
|
|
||||||
#define EGL_NO_DISPLAY ((EGLDisplay) 0)
|
|
||||||
#define EGL_NO_CONTEXT ((EGLContext) 0)
|
|
||||||
#define EGL_DEFAULT_DISPLAY ((EGLNativeDisplayType) 0)
|
|
||||||
|
|
||||||
#define EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR 0x00000002
|
|
||||||
#define EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR 0x00000001
|
|
||||||
#define EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR 0x00000002
|
|
||||||
#define EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR 0x00000001
|
|
||||||
#define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR 0x31bd
|
|
||||||
#define EGL_NO_RESET_NOTIFICATION_KHR 0x31be
|
|
||||||
#define EGL_LOSE_CONTEXT_ON_RESET_KHR 0x31bf
|
|
||||||
#define EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR 0x00000004
|
|
||||||
#define EGL_CONTEXT_MAJOR_VERSION_KHR 0x3098
|
|
||||||
#define EGL_CONTEXT_MINOR_VERSION_KHR 0x30fb
|
|
||||||
#define EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR 0x30fd
|
|
||||||
#define EGL_CONTEXT_FLAGS_KHR 0x30fc
|
|
||||||
#define EGL_CONTEXT_OPENGL_NO_ERROR_KHR 0x31b3
|
|
||||||
#define EGL_GL_COLORSPACE_KHR 0x309d
|
|
||||||
#define EGL_GL_COLORSPACE_SRGB_KHR 0x3089
|
|
||||||
#define EGL_CONTEXT_RELEASE_BEHAVIOR_KHR 0x2097
|
|
||||||
#define EGL_CONTEXT_RELEASE_BEHAVIOR_NONE_KHR 0
|
|
||||||
#define EGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_KHR 0x2098
|
|
||||||
#define EGL_PLATFORM_X11_EXT 0x31d5
|
|
||||||
#define EGL_PLATFORM_WAYLAND_EXT 0x31d8
|
|
||||||
#define EGL_PLATFORM_ANGLE_ANGLE 0x3202
|
|
||||||
#define EGL_PLATFORM_ANGLE_TYPE_ANGLE 0x3203
|
|
||||||
#define EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE 0x320d
|
|
||||||
#define EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE 0x320e
|
|
||||||
#define EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE 0x3207
|
|
||||||
#define EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE 0x3208
|
|
||||||
#define EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE 0x3450
|
|
||||||
#define EGL_PLATFORM_ANGLE_TYPE_METAL_ANGLE 0x3489
|
|
||||||
#define EGL_PLATFORM_ANGLE_NATIVE_PLATFORM_TYPE_ANGLE 0x348f
|
|
||||||
|
|
||||||
typedef int EGLint;
|
|
||||||
typedef unsigned int EGLBoolean;
|
|
||||||
typedef unsigned int EGLenum;
|
|
||||||
typedef void* EGLConfig;
|
|
||||||
typedef void* EGLContext;
|
|
||||||
typedef void* EGLDisplay;
|
|
||||||
typedef void* EGLSurface;
|
|
||||||
|
|
||||||
typedef void* EGLNativeDisplayType;
|
|
||||||
typedef void* EGLNativeWindowType;
|
|
||||||
|
|
||||||
// EGL function pointer typedefs
|
|
||||||
typedef EGLBoolean (EGLAPIENTRY * PFN_eglGetConfigAttrib)(EGLDisplay,EGLConfig,EGLint,EGLint*);
|
|
||||||
typedef EGLBoolean (EGLAPIENTRY * PFN_eglGetConfigs)(EGLDisplay,EGLConfig*,EGLint,EGLint*);
|
|
||||||
typedef EGLDisplay (EGLAPIENTRY * PFN_eglGetDisplay)(EGLNativeDisplayType);
|
|
||||||
typedef EGLint (EGLAPIENTRY * PFN_eglGetError)(void);
|
|
||||||
typedef EGLBoolean (EGLAPIENTRY * PFN_eglInitialize)(EGLDisplay,EGLint*,EGLint*);
|
|
||||||
typedef EGLBoolean (EGLAPIENTRY * PFN_eglTerminate)(EGLDisplay);
|
|
||||||
typedef EGLBoolean (EGLAPIENTRY * PFN_eglBindAPI)(EGLenum);
|
|
||||||
typedef EGLContext (EGLAPIENTRY * PFN_eglCreateContext)(EGLDisplay,EGLConfig,EGLContext,const EGLint*);
|
|
||||||
typedef EGLBoolean (EGLAPIENTRY * PFN_eglDestroySurface)(EGLDisplay,EGLSurface);
|
|
||||||
typedef EGLBoolean (EGLAPIENTRY * PFN_eglDestroyContext)(EGLDisplay,EGLContext);
|
|
||||||
typedef EGLSurface (EGLAPIENTRY * PFN_eglCreateWindowSurface)(EGLDisplay,EGLConfig,EGLNativeWindowType,const EGLint*);
|
|
||||||
typedef EGLBoolean (EGLAPIENTRY * PFN_eglMakeCurrent)(EGLDisplay,EGLSurface,EGLSurface,EGLContext);
|
|
||||||
typedef EGLBoolean (EGLAPIENTRY * PFN_eglSwapBuffers)(EGLDisplay,EGLSurface);
|
|
||||||
typedef EGLBoolean (EGLAPIENTRY * PFN_eglSwapInterval)(EGLDisplay,EGLint);
|
|
||||||
typedef const char* (EGLAPIENTRY * PFN_eglQueryString)(EGLDisplay,EGLint);
|
|
||||||
typedef GLFWglproc (EGLAPIENTRY * PFN_eglGetProcAddress)(const char*);
|
|
||||||
#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
|
|
||||||
|
|
||||||
// EGL-specific per-context data
|
|
||||||
//
|
|
||||||
typedef struct _GLFWcontextEGL
|
|
||||||
{
|
|
||||||
EGLConfig config;
|
|
||||||
EGLContext handle;
|
|
||||||
EGLSurface surface;
|
|
||||||
|
|
||||||
void* client;
|
|
||||||
|
|
||||||
} _GLFWcontextEGL;
|
|
||||||
|
|
||||||
// EGL-specific global data
|
|
||||||
//
|
|
||||||
typedef struct _GLFWlibraryEGL
|
|
||||||
{
|
|
||||||
EGLenum platform;
|
|
||||||
EGLDisplay display;
|
|
||||||
EGLint major, minor;
|
|
||||||
GLFWbool prefix;
|
|
||||||
|
|
||||||
GLFWbool KHR_create_context;
|
|
||||||
GLFWbool KHR_create_context_no_error;
|
|
||||||
GLFWbool KHR_gl_colorspace;
|
|
||||||
GLFWbool KHR_get_all_proc_addresses;
|
|
||||||
GLFWbool KHR_context_flush_control;
|
|
||||||
GLFWbool EXT_client_extensions;
|
|
||||||
GLFWbool EXT_platform_base;
|
|
||||||
GLFWbool EXT_platform_x11;
|
|
||||||
GLFWbool EXT_platform_wayland;
|
|
||||||
GLFWbool ANGLE_platform_angle;
|
|
||||||
GLFWbool ANGLE_platform_angle_opengl;
|
|
||||||
GLFWbool ANGLE_platform_angle_d3d;
|
|
||||||
GLFWbool ANGLE_platform_angle_vulkan;
|
|
||||||
GLFWbool ANGLE_platform_angle_metal;
|
|
||||||
|
|
||||||
void* handle;
|
|
||||||
|
|
||||||
PFN_eglGetConfigAttrib GetConfigAttrib;
|
|
||||||
PFN_eglGetConfigs GetConfigs;
|
|
||||||
PFN_eglGetDisplay GetDisplay;
|
|
||||||
PFN_eglGetError GetError;
|
|
||||||
PFN_eglInitialize Initialize;
|
|
||||||
PFN_eglTerminate Terminate;
|
|
||||||
PFN_eglBindAPI BindAPI;
|
|
||||||
PFN_eglCreateContext CreateContext;
|
|
||||||
PFN_eglDestroySurface DestroySurface;
|
|
||||||
PFN_eglDestroyContext DestroyContext;
|
|
||||||
PFN_eglCreateWindowSurface CreateWindowSurface;
|
|
||||||
PFN_eglMakeCurrent MakeCurrent;
|
|
||||||
PFN_eglSwapBuffers SwapBuffers;
|
|
||||||
PFN_eglSwapInterval SwapInterval;
|
|
||||||
PFN_eglQueryString QueryString;
|
|
||||||
PFN_eglGetProcAddress GetProcAddress;
|
|
||||||
|
|
||||||
PFNEGLGETPLATFORMDISPLAYEXTPROC GetPlatformDisplayEXT;
|
|
||||||
PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC CreatePlatformWindowSurfaceEXT;
|
|
||||||
|
|
||||||
} _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;
|
||||||
|
@ -138,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;
|
||||||
}
|
}
|
||||||
|
@ -226,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)
|
||||||
|
@ -253,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__) || defined(__NetBSD__)
|
||||||
|
"libGL.so",
|
||||||
#else
|
#else
|
||||||
"libGL.so.1",
|
"libGL.so.1",
|
||||||
"libGL.so",
|
"libGL.so",
|
||||||
|
@ -270,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;
|
||||||
}
|
}
|
||||||
|
@ -283,36 +284,32 @@ 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.GetVisualFromFBConfig = (PFNGLXGETVISUALFROMFBCONFIGPROC)
|
||||||
_glfw_dlsym(_glfw.glx.handle, "glXGetProcAddress");
|
_glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXGetVisualFromFBConfig");
|
||||||
_glfw.glx.GetProcAddressARB =
|
|
||||||
_glfw_dlsym(_glfw.glx.handle, "glXGetProcAddressARB");
|
|
||||||
_glfw.glx.GetVisualFromFBConfig =
|
|
||||||
_glfw_dlsym(_glfw.glx.handle, "glXGetVisualFromFBConfig");
|
|
||||||
|
|
||||||
if (!_glfw.glx.GetFBConfigs ||
|
if (!_glfw.glx.GetFBConfigs ||
|
||||||
!_glfw.glx.GetFBConfigAttrib ||
|
!_glfw.glx.GetFBConfigAttrib ||
|
||||||
|
@ -326,8 +323,6 @@ GLFWbool _glfwInitGLX(void)
|
||||||
!_glfw.glx.CreateNewContext ||
|
!_glfw.glx.CreateNewContext ||
|
||||||
!_glfw.glx.CreateWindow ||
|
!_glfw.glx.CreateWindow ||
|
||||||
!_glfw.glx.DestroyWindow ||
|
!_glfw.glx.DestroyWindow ||
|
||||||
!_glfw.glx.GetProcAddress ||
|
|
||||||
!_glfw.glx.GetProcAddressARB ||
|
|
||||||
!_glfw.glx.GetVisualFromFBConfig)
|
!_glfw.glx.GetVisualFromFBConfig)
|
||||||
{
|
{
|
||||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||||
|
@ -335,6 +330,12 @@ GLFWbool _glfwInitGLX(void)
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NOTE: Unlike GLX 1.3 entry points these are not required to be present
|
||||||
|
_glfw.glx.GetProcAddress = (PFNGLXGETPROCADDRESSPROC)
|
||||||
|
_glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXGetProcAddress");
|
||||||
|
_glfw.glx.GetProcAddressARB = (PFNGLXGETPROCADDRESSPROC)
|
||||||
|
_glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXGetProcAddressARB");
|
||||||
|
|
||||||
if (!glXQueryExtension(_glfw.x11.display,
|
if (!glXQueryExtension(_glfw.x11.display,
|
||||||
&_glfw.glx.errorBase,
|
&_glfw.glx.errorBase,
|
||||||
&_glfw.glx.eventBase))
|
&_glfw.glx.eventBase))
|
||||||
|
@ -425,16 +426,16 @@ 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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#define setAttrib(a, v) \
|
#define SET_ATTRIB(a, v) \
|
||||||
{ \
|
{ \
|
||||||
assert(((size_t) index + 1) < sizeof(attribs) / sizeof(attribs[0])); \
|
assert(((size_t) index + 1) < sizeof(attribs) / sizeof(attribs[0])); \
|
||||||
attribs[index++] = a; \
|
attribs[index++] = a; \
|
||||||
|
@ -522,13 +523,13 @@ GLFWbool _glfwCreateContextGLX(_GLFWwindow* window,
|
||||||
{
|
{
|
||||||
if (ctxconfig->robustness == GLFW_NO_RESET_NOTIFICATION)
|
if (ctxconfig->robustness == GLFW_NO_RESET_NOTIFICATION)
|
||||||
{
|
{
|
||||||
setAttrib(GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB,
|
SET_ATTRIB(GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB,
|
||||||
GLX_NO_RESET_NOTIFICATION_ARB);
|
GLX_NO_RESET_NOTIFICATION_ARB);
|
||||||
}
|
}
|
||||||
else if (ctxconfig->robustness == GLFW_LOSE_CONTEXT_ON_RESET)
|
else if (ctxconfig->robustness == GLFW_LOSE_CONTEXT_ON_RESET)
|
||||||
{
|
{
|
||||||
setAttrib(GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB,
|
SET_ATTRIB(GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB,
|
||||||
GLX_LOSE_CONTEXT_ON_RESET_ARB);
|
GLX_LOSE_CONTEXT_ON_RESET_ARB);
|
||||||
}
|
}
|
||||||
|
|
||||||
flags |= GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB;
|
flags |= GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB;
|
||||||
|
@ -541,13 +542,13 @@ GLFWbool _glfwCreateContextGLX(_GLFWwindow* window,
|
||||||
{
|
{
|
||||||
if (ctxconfig->release == GLFW_RELEASE_BEHAVIOR_NONE)
|
if (ctxconfig->release == GLFW_RELEASE_BEHAVIOR_NONE)
|
||||||
{
|
{
|
||||||
setAttrib(GLX_CONTEXT_RELEASE_BEHAVIOR_ARB,
|
SET_ATTRIB(GLX_CONTEXT_RELEASE_BEHAVIOR_ARB,
|
||||||
GLX_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB);
|
GLX_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB);
|
||||||
}
|
}
|
||||||
else if (ctxconfig->release == GLFW_RELEASE_BEHAVIOR_FLUSH)
|
else if (ctxconfig->release == GLFW_RELEASE_BEHAVIOR_FLUSH)
|
||||||
{
|
{
|
||||||
setAttrib(GLX_CONTEXT_RELEASE_BEHAVIOR_ARB,
|
SET_ATTRIB(GLX_CONTEXT_RELEASE_BEHAVIOR_ARB,
|
||||||
GLX_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB);
|
GLX_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -555,7 +556,7 @@ GLFWbool _glfwCreateContextGLX(_GLFWwindow* window,
|
||||||
if (ctxconfig->noerror)
|
if (ctxconfig->noerror)
|
||||||
{
|
{
|
||||||
if (_glfw.glx.ARB_create_context_no_error)
|
if (_glfw.glx.ARB_create_context_no_error)
|
||||||
setAttrib(GLX_CONTEXT_OPENGL_NO_ERROR_ARB, GLFW_TRUE);
|
SET_ATTRIB(GLX_CONTEXT_OPENGL_NO_ERROR_ARB, GLFW_TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: Only request an explicitly versioned context when necessary, as
|
// NOTE: Only request an explicitly versioned context when necessary, as
|
||||||
|
@ -563,17 +564,17 @@ GLFWbool _glfwCreateContextGLX(_GLFWwindow* window,
|
||||||
// highest version supported by the driver
|
// highest version supported by the driver
|
||||||
if (ctxconfig->major != 1 || ctxconfig->minor != 0)
|
if (ctxconfig->major != 1 || ctxconfig->minor != 0)
|
||||||
{
|
{
|
||||||
setAttrib(GLX_CONTEXT_MAJOR_VERSION_ARB, ctxconfig->major);
|
SET_ATTRIB(GLX_CONTEXT_MAJOR_VERSION_ARB, ctxconfig->major);
|
||||||
setAttrib(GLX_CONTEXT_MINOR_VERSION_ARB, ctxconfig->minor);
|
SET_ATTRIB(GLX_CONTEXT_MINOR_VERSION_ARB, ctxconfig->minor);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mask)
|
if (mask)
|
||||||
setAttrib(GLX_CONTEXT_PROFILE_MASK_ARB, mask);
|
SET_ATTRIB(GLX_CONTEXT_PROFILE_MASK_ARB, mask);
|
||||||
|
|
||||||
if (flags)
|
if (flags)
|
||||||
setAttrib(GLX_CONTEXT_FLAGS_ARB, flags);
|
SET_ATTRIB(GLX_CONTEXT_FLAGS_ARB, flags);
|
||||||
|
|
||||||
setAttrib(None, None);
|
SET_ATTRIB(None, None);
|
||||||
|
|
||||||
window->context.glx.handle =
|
window->context.glx.handle =
|
||||||
_glfw.glx.CreateContextAttribsARB(_glfw.x11.display,
|
_glfw.glx.CreateContextAttribsARB(_glfw.x11.display,
|
||||||
|
@ -630,7 +631,7 @@ GLFWbool _glfwCreateContextGLX(_GLFWwindow* window,
|
||||||
return GLFW_TRUE;
|
return GLFW_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef setAttrib
|
#undef SET_ATTRIB
|
||||||
|
|
||||||
// Returns the Visual and depth of the chosen GLXFBConfig
|
// Returns the Visual and depth of the chosen GLXFBConfig
|
||||||
//
|
//
|
||||||
|
@ -674,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;
|
||||||
|
@ -688,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);
|
|
||||||
|
|
243
src/init.c
243
src/init.c
|
@ -36,23 +36,25 @@
|
||||||
#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_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
|
||||||
|
@ -62,6 +64,27 @@ static _GLFWinitconfig _glfwInitHints =
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 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)
|
||||||
|
@ -80,21 +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();
|
||||||
_glfwPlatformTerminateJoysticks();
|
_glfw.platform.terminateJoysticks();
|
||||||
_glfwPlatformTerminate();
|
_glfw.platform.terminate();
|
||||||
|
|
||||||
_glfw.initialized = GLFW_FALSE;
|
_glfw.initialized = GLFW_FALSE;
|
||||||
|
|
||||||
|
@ -102,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);
|
||||||
|
@ -117,14 +140,108 @@ 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Splits and translates a text/uri-list into separate file paths
|
||||||
|
// NOTE: This function destroys the provided string
|
||||||
|
//
|
||||||
|
char** _glfwParseUriList(char* text, int* count)
|
||||||
|
{
|
||||||
|
const char* prefix = "file://";
|
||||||
|
char** paths = NULL;
|
||||||
|
char* line;
|
||||||
|
|
||||||
|
*count = 0;
|
||||||
|
|
||||||
|
while ((line = strtok(text, "\r\n")))
|
||||||
|
{
|
||||||
|
char* path;
|
||||||
|
|
||||||
|
text = NULL;
|
||||||
|
|
||||||
|
if (line[0] == '#')
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (strncmp(line, prefix, strlen(prefix)) == 0)
|
||||||
|
{
|
||||||
|
line += strlen(prefix);
|
||||||
|
// TODO: Validate hostname
|
||||||
|
while (*line != '/')
|
||||||
|
line++;
|
||||||
|
}
|
||||||
|
|
||||||
|
(*count)++;
|
||||||
|
|
||||||
|
path = _glfw_calloc(strlen(line) + 1, 1);
|
||||||
|
paths = _glfw_realloc(paths, *count * sizeof(char*));
|
||||||
|
paths[*count - 1] = path;
|
||||||
|
|
||||||
|
while (*line)
|
||||||
|
{
|
||||||
|
if (line[0] == '%' && line[1] && line[2])
|
||||||
|
{
|
||||||
|
const char digits[3] = { line[1], line[2], '\0' };
|
||||||
|
*path = (char) strtol(digits, NULL, 16);
|
||||||
|
line += 2;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
*path = *line;
|
||||||
|
|
||||||
|
path++;
|
||||||
|
line++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return paths;
|
||||||
|
}
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int _glfw_min(int a, int b)
|
||||||
|
{
|
||||||
|
return a < b ? a : b;
|
||||||
|
}
|
||||||
|
|
||||||
|
int _glfw_max(int a, int b)
|
||||||
|
{
|
||||||
|
return a > b ? a : b;
|
||||||
|
}
|
||||||
|
|
||||||
float _glfw_fminf(float a, float b)
|
float _glfw_fminf(float a, float b)
|
||||||
{
|
{
|
||||||
if (a != a)
|
if (a != a)
|
||||||
|
@ -149,6 +266,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 //////
|
||||||
|
@ -199,6 +369,8 @@ void _glfwInputError(int code, const char* format, ...)
|
||||||
strcpy(description, "The requested feature cannot be implemented for this platform");
|
strcpy(description, "The requested feature cannot be implemented for this platform");
|
||||||
else if (code == GLFW_FEATURE_UNIMPLEMENTED)
|
else if (code == GLFW_FEATURE_UNIMPLEMENTED)
|
||||||
strcpy(description, "The requested feature has not yet been implemented for this platform");
|
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");
|
||||||
}
|
}
|
||||||
|
@ -208,7 +380,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;
|
||||||
|
@ -239,7 +411,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;
|
||||||
|
@ -257,9 +440,11 @@ GLFWAPI int glfwInit(void)
|
||||||
|
|
||||||
_glfwInitGamepadMappings();
|
_glfwInitGamepadMappings();
|
||||||
|
|
||||||
_glfw.initialized = GLFW_TRUE;
|
_glfwPlatformInitTimer();
|
||||||
_glfw.timer.offset = _glfwPlatformGetTimerValue();
|
_glfw.timer.offset = _glfwPlatformGetTimerValue();
|
||||||
|
|
||||||
|
_glfw.initialized = GLFW_TRUE;
|
||||||
|
|
||||||
glfwDefaultWindowHints();
|
glfwDefaultWindowHints();
|
||||||
return GLFW_TRUE;
|
return GLFW_TRUE;
|
||||||
}
|
}
|
||||||
|
@ -282,6 +467,9 @@ GLFWAPI void glfwInitHint(int hint, int value)
|
||||||
case GLFW_ANGLE_PLATFORM_TYPE:
|
case GLFW_ANGLE_PLATFORM_TYPE:
|
||||||
_glfwInitHints.angleType = value;
|
_glfwInitHints.angleType = value;
|
||||||
return;
|
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;
|
||||||
|
@ -297,6 +485,24 @@ GLFWAPI void glfwInitHint(int hint, int value)
|
||||||
"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)
|
||||||
|
@ -307,11 +513,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;
|
||||||
|
@ -338,7 +539,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
253
src/input.c
253
src/input.c
|
@ -50,9 +50,9 @@ static GLFWbool initJoysticks(void)
|
||||||
{
|
{
|
||||||
if (!_glfw.joysticksInitialized)
|
if (!_glfw.joysticksInitialized)
|
||||||
{
|
{
|
||||||
if (!_glfwPlatformInitJoysticks())
|
if (!_glfw.platform.initJoysticks())
|
||||||
{
|
{
|
||||||
_glfwPlatformTerminateJoysticks();
|
_glfw.platform.terminateJoysticks();
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -234,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -252,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -294,7 +295,7 @@ void _glfwInputKey(_GLFWwindow* window, int key, int scancode, int action, int m
|
||||||
// Notifies shared code of a Unicode codepoint input event
|
// 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;
|
||||||
|
@ -419,7 +420,7 @@ void _glfwInitGamepadMappings(void)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
const size_t count = sizeof(_glfwDefaultMappings) / sizeof(char*);
|
const size_t count = sizeof(_glfwDefaultMappings) / sizeof(char*);
|
||||||
_glfw.mappings = calloc(count, sizeof(_GLFWmapping));
|
_glfw.mappings = _glfw_calloc(count, sizeof(_GLFWmapping));
|
||||||
|
|
||||||
for (i = 0; i < count; i++)
|
for (i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
|
@ -450,9 +451,9 @@ _GLFWjoystick* _glfwAllocJoystick(const char* name,
|
||||||
|
|
||||||
js = _glfw.joysticks + jid;
|
js = _glfw.joysticks + jid;
|
||||||
js->present = GLFW_TRUE;
|
js->present = GLFW_TRUE;
|
||||||
js->axes = calloc(axisCount, sizeof(float));
|
js->axes = _glfw_calloc(axisCount, sizeof(float));
|
||||||
js->buttons = calloc(buttonCount + (size_t) hatCount * 4, 1);
|
js->buttons = _glfw_calloc(buttonCount + (size_t) hatCount * 4, 1);
|
||||||
js->hats = calloc(hatCount, 1);
|
js->hats = _glfw_calloc(hatCount, 1);
|
||||||
js->axisCount = axisCount;
|
js->axisCount = axisCount;
|
||||||
js->buttonCount = buttonCount;
|
js->buttonCount = buttonCount;
|
||||||
js->hatCount = hatCount;
|
js->hatCount = hatCount;
|
||||||
|
@ -468,9 +469,9 @@ _GLFWjoystick* _glfwAllocJoystick(const char* name,
|
||||||
//
|
//
|
||||||
void _glfwFreeJoystick(_GLFWjoystick* js)
|
void _glfwFreeJoystick(_GLFWjoystick* js)
|
||||||
{
|
{
|
||||||
free(js->axes);
|
_glfw_free(js->axes);
|
||||||
free(js->buttons);
|
_glfw_free(js->buttons);
|
||||||
free(js->hats);
|
_glfw_free(js->hats);
|
||||||
memset(js, 0, sizeof(_GLFWjoystick));
|
memset(js, 0, sizeof(_GLFWjoystick));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -480,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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -521,96 +522,108 @@ GLFWAPI void glfwSetInputMode(GLFWwindow* handle, int mode, int value)
|
||||||
|
|
||||||
_GLFW_REQUIRE_INIT();
|
_GLFW_REQUIRE_INIT();
|
||||||
|
|
||||||
if (mode == GLFW_CURSOR)
|
switch (mode)
|
||||||
{
|
{
|
||||||
if (value != GLFW_CURSOR_NORMAL &&
|
case GLFW_CURSOR:
|
||||||
value != GLFW_CURSOR_HIDDEN &&
|
|
||||||
value != GLFW_CURSOR_DISABLED)
|
|
||||||
{
|
{
|
||||||
_glfwInputError(GLFW_INVALID_ENUM,
|
if (value != GLFW_CURSOR_NORMAL &&
|
||||||
"Invalid cursor mode 0x%08X",
|
value != GLFW_CURSOR_HIDDEN &&
|
||||||
value);
|
value != GLFW_CURSOR_DISABLED)
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (window->cursorMode == value)
|
|
||||||
return;
|
|
||||||
|
|
||||||
window->cursorMode = value;
|
|
||||||
|
|
||||||
_glfwPlatformGetCursorPos(window,
|
|
||||||
&window->virtualCursorPosX,
|
|
||||||
&window->virtualCursorPosY);
|
|
||||||
_glfwPlatformSetCursorMode(window, value);
|
|
||||||
}
|
|
||||||
else if (mode == GLFW_STICKY_KEYS)
|
|
||||||
{
|
|
||||||
value = value ? GLFW_TRUE : GLFW_FALSE;
|
|
||||||
if (window->stickyKeys == value)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!value)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
// Release all sticky keys
|
|
||||||
for (i = 0; i <= GLFW_KEY_LAST; i++)
|
|
||||||
{
|
{
|
||||||
if (window->keys[i] == _GLFW_STICK)
|
_glfwInputError(GLFW_INVALID_ENUM,
|
||||||
window->keys[i] = GLFW_RELEASE;
|
"Invalid cursor mode 0x%08X",
|
||||||
|
value);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (window->cursorMode == value)
|
||||||
|
return;
|
||||||
|
|
||||||
|
window->cursorMode = value;
|
||||||
|
|
||||||
|
_glfw.platform.getCursorPos(window,
|
||||||
|
&window->virtualCursorPosX,
|
||||||
|
&window->virtualCursorPosY);
|
||||||
|
_glfw.platform.setCursorMode(window, value);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
window->stickyKeys = value;
|
case GLFW_STICKY_KEYS:
|
||||||
}
|
|
||||||
else if (mode == GLFW_STICKY_MOUSE_BUTTONS)
|
|
||||||
{
|
|
||||||
value = value ? GLFW_TRUE : GLFW_FALSE;
|
|
||||||
if (window->stickyMouseButtons == value)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!value)
|
|
||||||
{
|
{
|
||||||
int i;
|
value = value ? GLFW_TRUE : GLFW_FALSE;
|
||||||
|
if (window->stickyKeys == value)
|
||||||
|
return;
|
||||||
|
|
||||||
// Release all sticky mouse buttons
|
if (!value)
|
||||||
for (i = 0; i <= GLFW_MOUSE_BUTTON_LAST; i++)
|
|
||||||
{
|
{
|
||||||
if (window->mouseButtons[i] == _GLFW_STICK)
|
int i;
|
||||||
window->mouseButtons[i] = GLFW_RELEASE;
|
|
||||||
|
// Release all sticky keys
|
||||||
|
for (i = 0; i <= GLFW_KEY_LAST; i++)
|
||||||
|
{
|
||||||
|
if (window->keys[i] == _GLFW_STICK)
|
||||||
|
window->keys[i] = GLFW_RELEASE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
window->stickyKeys = value;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
window->stickyMouseButtons = value;
|
case GLFW_STICKY_MOUSE_BUTTONS:
|
||||||
}
|
|
||||||
else if (mode == GLFW_LOCK_KEY_MODS)
|
|
||||||
{
|
|
||||||
window->lockKeyMods = value ? GLFW_TRUE : GLFW_FALSE;
|
|
||||||
}
|
|
||||||
else if (mode == GLFW_RAW_MOUSE_MOTION)
|
|
||||||
{
|
|
||||||
if (!_glfwPlatformRawMouseMotionSupported())
|
|
||||||
{
|
{
|
||||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
value = value ? GLFW_TRUE : GLFW_FALSE;
|
||||||
"Raw mouse motion is not supported on this system");
|
if (window->stickyMouseButtons == value)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!value)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
// Release all sticky mouse buttons
|
||||||
|
for (i = 0; i <= GLFW_MOUSE_BUTTON_LAST; i++)
|
||||||
|
{
|
||||||
|
if (window->mouseButtons[i] == _GLFW_STICK)
|
||||||
|
window->mouseButtons[i] = GLFW_RELEASE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
window->stickyMouseButtons = value;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
value = value ? GLFW_TRUE : GLFW_FALSE;
|
case GLFW_LOCK_KEY_MODS:
|
||||||
if (window->rawMouseMotion == value)
|
{
|
||||||
|
window->lockKeyMods = value ? GLFW_TRUE : GLFW_FALSE;
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
window->rawMouseMotion = value;
|
case GLFW_RAW_MOUSE_MOTION:
|
||||||
_glfwPlatformSetRawMouseMotion(window, value);
|
{
|
||||||
|
if (!_glfw.platform.rawMouseMotionSupported())
|
||||||
|
{
|
||||||
|
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||||
|
"Raw mouse motion is not supported on this system");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
value = value ? GLFW_TRUE : GLFW_FALSE;
|
||||||
|
if (window->rawMouseMotion == value)
|
||||||
|
return;
|
||||||
|
|
||||||
|
window->rawMouseMotion = value;
|
||||||
|
_glfw.platform.setRawMouseMotion(window, value);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
_glfwInputError(GLFW_INVALID_ENUM, "Invalid input mode 0x%08X", mode);
|
_glfwInputError(GLFW_INVALID_ENUM, "Invalid input mode 0x%08X", mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWAPI int glfwRawMouseMotionSupported(void)
|
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)
|
||||||
|
@ -626,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)
|
||||||
|
@ -642,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)
|
||||||
|
@ -711,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)
|
||||||
|
@ -730,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)
|
||||||
|
@ -742,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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -751,14 +764,21 @@ GLFWAPI GLFWcursor* glfwCreateCursor(const GLFWimage* image, int xhot, int yhot)
|
||||||
_GLFWcursor* cursor;
|
_GLFWcursor* cursor;
|
||||||
|
|
||||||
assert(image != NULL);
|
assert(image != NULL);
|
||||||
|
assert(image->pixels != NULL);
|
||||||
|
|
||||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||||
|
|
||||||
cursor = calloc(1, sizeof(_GLFWcursor));
|
if (image->width <= 0 || image->height <= 0)
|
||||||
|
{
|
||||||
|
_glfwInputError(GLFW_INVALID_VALUE, "Invalid image dimensions for cursor");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
cursor = _glfw_calloc(1, sizeof(_GLFWcursor));
|
||||||
cursor->next = _glfw.cursorListHead;
|
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;
|
||||||
|
@ -788,11 +808,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;
|
||||||
|
@ -821,7 +841,7 @@ GLFWAPI void glfwDestroyCursor(GLFWcursor* handle)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_glfwPlatformDestroyCursor(cursor);
|
_glfw.platform.destroyCursor(cursor);
|
||||||
|
|
||||||
// Unlink cursor from global linked list
|
// Unlink cursor from global linked list
|
||||||
{
|
{
|
||||||
|
@ -833,7 +853,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)
|
||||||
|
@ -846,7 +866,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)
|
||||||
|
@ -855,7 +875,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -865,7 +885,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -875,7 +895,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -886,7 +906,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -897,7 +917,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -908,7 +928,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -919,7 +939,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -929,7 +949,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -955,7 +975,7 @@ GLFWAPI int glfwJoystickPresent(int 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)
|
||||||
|
@ -983,7 +1003,7 @@ GLFWAPI const float* glfwGetJoystickAxes(int jid, int* count)
|
||||||
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;
|
||||||
|
@ -1015,7 +1035,7 @@ GLFWAPI const unsigned char* glfwGetJoystickButtons(int jid, int* count)
|
||||||
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)
|
||||||
|
@ -1051,7 +1071,7 @@ GLFWAPI const unsigned char* glfwGetJoystickHats(int jid, int* count)
|
||||||
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;
|
||||||
|
@ -1080,7 +1100,7 @@ GLFWAPI const char* glfwGetJoystickName(int 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;
|
||||||
|
@ -1108,7 +1128,7 @@ GLFWAPI const char* glfwGetJoystickGUID(int 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;
|
||||||
|
@ -1153,7 +1173,7 @@ GLFWAPI GLFWjoystickfun glfwSetJoystickCallback(GLFWjoystickfun cbfun)
|
||||||
if (!initJoysticks())
|
if (!initJoysticks())
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
_GLFW_SWAP_POINTERS(_glfw.callbacks.joystick, cbfun);
|
_GLFW_SWAP(GLFWjoystickfun, _glfw.callbacks.joystick, cbfun);
|
||||||
return cbfun;
|
return cbfun;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1191,8 +1211,8 @@ 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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1239,7 +1259,7 @@ GLFWAPI int glfwJoystickIsGamepad(int 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;
|
||||||
|
@ -1267,7 +1287,7 @@ GLFWAPI const char* glfwGetGamepadName(int 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)
|
||||||
|
@ -1302,7 +1322,7 @@ GLFWAPI int glfwGetGamepadState(int jid, GLFWgamepadstate* state)
|
||||||
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)
|
||||||
|
@ -1367,13 +1387,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)
|
||||||
|
@ -1408,3 +1428,4 @@ GLFWAPI uint64_t glfwGetTimerFrequency(void)
|
||||||
_GLFW_REQUIRE_INIT_OR_RETURN(0);
|
_GLFW_REQUIRE_INIT_OR_RETURN(0);
|
||||||
return _glfwPlatformGetTimerFrequency();
|
return _glfwPlatformGetTimerFrequency();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
576
src/internal.h
576
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,32 +324,11 @@ typedef struct VkExtensionProperties
|
||||||
|
|
||||||
typedef void (APIENTRY * PFN_vkVoidFunction)(void);
|
typedef void (APIENTRY * PFN_vkVoidFunction)(void);
|
||||||
|
|
||||||
#if defined(_GLFW_VULKAN_STATIC)
|
typedef PFN_vkVoidFunction (APIENTRY * PFN_vkGetInstanceProcAddr)(VkInstance,const char*);
|
||||||
PFN_vkVoidFunction vkGetInstanceProcAddr(VkInstance,const char*);
|
typedef VkResult (APIENTRY * PFN_vkEnumerateInstanceExtensionProperties)(const char*,uint32_t*,VkExtensionProperties*);
|
||||||
VkResult vkEnumerateInstanceExtensionProperties(const char*,uint32_t*,VkExtensionProperties*);
|
#define vkGetInstanceProcAddr _glfw.vk.GetInstanceProcAddr
|
||||||
#else
|
|
||||||
typedef PFN_vkVoidFunction (APIENTRY * PFN_vkGetInstanceProcAddr)(VkInstance,const char*);
|
|
||||||
typedef VkResult (APIENTRY * PFN_vkEnumerateInstanceExtensionProperties)(const char*,uint32_t*,VkExtensionProperties*);
|
|
||||||
#define vkEnumerateInstanceExtensionProperties _glfw.vk.EnumerateInstanceExtensionProperties
|
|
||||||
#define vkGetInstanceProcAddr _glfw.vk.GetInstanceProcAddr
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#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
|
|
||||||
|
|
||||||
#include "egl_context.h"
|
|
||||||
#include "osmesa_context.h"
|
|
||||||
|
|
||||||
// Constructs a version number string from the public header macros
|
// Constructs a version number string from the public header macros
|
||||||
#define _GLFW_CONCAT_VERSION(m, n, r) #m "." #n "." #r
|
#define _GLFW_CONCAT_VERSION(m, n, r) #m "." #n "." #r
|
||||||
|
@ -219,12 +352,12 @@ 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; \
|
||||||
}
|
}
|
||||||
|
|
||||||
// Per-thread error structure
|
// Per-thread error structure
|
||||||
|
@ -244,6 +377,8 @@ struct _GLFWinitconfig
|
||||||
{
|
{
|
||||||
GLFWbool hatButtons;
|
GLFWbool hatButtons;
|
||||||
int angleType;
|
int angleType;
|
||||||
|
int platformID;
|
||||||
|
PFN_vkGetInstanceProcAddr vulkanLoader;
|
||||||
struct {
|
struct {
|
||||||
GLFWbool menubar;
|
GLFWbool menubar;
|
||||||
GLFWbool chdir;
|
GLFWbool chdir;
|
||||||
|
@ -357,19 +492,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;
|
||||||
_GLFWcontextEGL egl;
|
EGLSurface surface;
|
||||||
// This is defined in osmesa_context.h
|
void* client;
|
||||||
_GLFWcontextOSMesa osmesa;
|
} 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
|
||||||
|
@ -428,8 +573,8 @@ 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
|
||||||
|
@ -452,8 +597,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
|
||||||
|
@ -461,9 +606,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
|
||||||
|
@ -502,24 +646,108 @@ struct _GLFWjoystick
|
||||||
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);
|
||||||
|
// 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
|
||||||
|
@ -527,6 +755,9 @@ struct _GLFWmutex
|
||||||
struct _GLFWlibrary
|
struct _GLFWlibrary
|
||||||
{
|
{
|
||||||
GLFWbool initialized;
|
GLFWbool initialized;
|
||||||
|
GLFWallocator allocator;
|
||||||
|
|
||||||
|
_GLFWplatform platform;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
_GLFWinitconfig init;
|
_GLFWinitconfig init;
|
||||||
|
@ -554,30 +785,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 {
|
||||||
|
@ -585,16 +866,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
|
|
||||||
_GLFWlibraryEGL egl;
|
|
||||||
// This is defined in osmesa_context.h
|
|
||||||
_GLFWlibraryOSMesa osmesa;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Global state shared between compilation units of GLFW
|
// Global state shared between compilation units of GLFW
|
||||||
|
@ -606,108 +881,10 @@ 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);
|
|
||||||
|
|
||||||
GLFWbool _glfwPlatformInitJoysticks(void);
|
|
||||||
void _glfwPlatformTerminateJoysticks(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);
|
||||||
|
|
||||||
int _glfwPlatformCreateWindow(_GLFWwindow* window,
|
|
||||||
const _GLFWwndconfig* wndconfig,
|
|
||||||
const _GLFWctxconfig* ctxconfig,
|
|
||||||
const _GLFWfbconfig* fbconfig);
|
|
||||||
void _glfwPlatformDestroyWindow(_GLFWwindow* window);
|
|
||||||
void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title);
|
|
||||||
void _glfwPlatformSetWindowIcon(_GLFWwindow* window,
|
|
||||||
int count, const GLFWimage* images);
|
|
||||||
void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos);
|
|
||||||
void _glfwPlatformSetWindowPos(_GLFWwindow* window, int xpos, int ypos);
|
|
||||||
void _glfwPlatformGetWindowSize(_GLFWwindow* window, int* width, int* height);
|
|
||||||
void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height);
|
|
||||||
void _glfwPlatformSetWindowSizeLimits(_GLFWwindow* window,
|
|
||||||
int minwidth, int minheight,
|
|
||||||
int maxwidth, int maxheight);
|
|
||||||
void _glfwPlatformSetWindowAspectRatio(_GLFWwindow* window, int numer, int denom);
|
|
||||||
void _glfwPlatformGetFramebufferSize(_GLFWwindow* window, int* width, int* height);
|
|
||||||
void _glfwPlatformGetWindowFrameSize(_GLFWwindow* window,
|
|
||||||
int* left, int* top,
|
|
||||||
int* right, int* bottom);
|
|
||||||
void _glfwPlatformGetWindowContentScale(_GLFWwindow* window,
|
|
||||||
float* xscale, float* yscale);
|
|
||||||
void _glfwPlatformIconifyWindow(_GLFWwindow* window);
|
|
||||||
void _glfwPlatformRestoreWindow(_GLFWwindow* window);
|
|
||||||
void _glfwPlatformMaximizeWindow(_GLFWwindow* window);
|
|
||||||
void _glfwPlatformShowWindow(_GLFWwindow* window);
|
|
||||||
void _glfwPlatformHideWindow(_GLFWwindow* window);
|
|
||||||
void _glfwPlatformRequestWindowAttention(_GLFWwindow* window);
|
|
||||||
void _glfwPlatformFocusWindow(_GLFWwindow* window);
|
|
||||||
void _glfwPlatformSetWindowMonitor(_GLFWwindow* window, _GLFWmonitor* monitor,
|
|
||||||
int xpos, int ypos, int width, int height,
|
|
||||||
int refreshRate);
|
|
||||||
int _glfwPlatformWindowFocused(_GLFWwindow* window);
|
|
||||||
int _glfwPlatformWindowIconified(_GLFWwindow* window);
|
|
||||||
int _glfwPlatformWindowVisible(_GLFWwindow* window);
|
|
||||||
int _glfwPlatformWindowMaximized(_GLFWwindow* window);
|
|
||||||
int _glfwPlatformWindowHovered(_GLFWwindow* window);
|
|
||||||
int _glfwPlatformFramebufferTransparent(_GLFWwindow* window);
|
|
||||||
float _glfwPlatformGetWindowOpacity(_GLFWwindow* window);
|
|
||||||
void _glfwPlatformSetWindowResizable(_GLFWwindow* window, GLFWbool enabled);
|
|
||||||
void _glfwPlatformSetWindowDecorated(_GLFWwindow* window, GLFWbool enabled);
|
|
||||||
void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled);
|
|
||||||
void _glfwPlatformSetWindowMousePassthrough(_GLFWwindow* window, GLFWbool enabled);
|
|
||||||
void _glfwPlatformSetWindowOpacity(_GLFWwindow* window, float opacity);
|
|
||||||
|
|
||||||
void _glfwPlatformPollEvents(void);
|
|
||||||
void _glfwPlatformWaitEvents(void);
|
|
||||||
void _glfwPlatformWaitEventsTimeout(double timeout);
|
|
||||||
void _glfwPlatformPostEmptyEvent(void);
|
|
||||||
|
|
||||||
EGLenum _glfwPlatformGetEGLPlatform(EGLint** attribs);
|
|
||||||
EGLNativeDisplayType _glfwPlatformGetEGLNativeDisplay(void);
|
|
||||||
EGLNativeWindowType _glfwPlatformGetEGLNativeWindow(_GLFWwindow* window);
|
|
||||||
|
|
||||||
void _glfwPlatformGetRequiredInstanceExtensions(char** extensions);
|
|
||||||
int _glfwPlatformGetPhysicalDevicePresentationSupport(VkInstance instance,
|
|
||||||
VkPhysicalDevice device,
|
|
||||||
uint32_t queuefamily);
|
|
||||||
VkResult _glfwPlatformCreateWindowSurface(VkInstance instance,
|
|
||||||
_GLFWwindow* window,
|
|
||||||
const VkAllocationCallbacks* allocator,
|
|
||||||
VkSurfaceKHR* surface);
|
|
||||||
|
|
||||||
GLFWbool _glfwPlatformCreateTls(_GLFWtls* tls);
|
GLFWbool _glfwPlatformCreateTls(_GLFWtls* tls);
|
||||||
void _glfwPlatformDestroyTls(_GLFWtls* tls);
|
void _glfwPlatformDestroyTls(_GLFWtls* tls);
|
||||||
void* _glfwPlatformGetTls(_GLFWtls* tls);
|
void* _glfwPlatformGetTls(_GLFWtls* tls);
|
||||||
|
@ -718,6 +895,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 //////
|
||||||
|
@ -738,7 +919,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);
|
||||||
|
@ -764,6 +945,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,
|
||||||
|
@ -790,11 +973,38 @@ _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** _glfwParseUriList(char* text, int* count);
|
||||||
|
|
||||||
char* _glfw_strdup(const char* source);
|
char* _glfw_strdup(const char* source);
|
||||||
|
int _glfw_min(int a, int b);
|
||||||
|
int _glfw_max(int a, int b);
|
||||||
float _glfw_fminf(float a, float b);
|
float _glfw_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);
|
||||||
|
|
||||||
|
|
|
@ -307,7 +307,7 @@ void _glfwDetectJoystickConnectionLinux(void)
|
||||||
////// GLFW platform API //////
|
////// GLFW platform API //////
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
GLFWbool _glfwPlatformInitJoysticks(void)
|
GLFWbool _glfwInitJoysticksLinux(void)
|
||||||
{
|
{
|
||||||
const char* dirname = "/dev/input";
|
const char* dirname = "/dev/input";
|
||||||
|
|
||||||
|
@ -361,11 +361,9 @@ GLFWbool _glfwPlatformInitJoysticks(void)
|
||||||
return GLFW_TRUE;
|
return GLFW_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformTerminateJoysticks(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)
|
||||||
|
@ -382,7 +380,7 @@ void _glfwPlatformTerminateJoysticks(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int _glfwPlatformPollJoystick(_GLFWjoystick* js, int mode)
|
int _glfwPollJoystickLinux(_GLFWjoystick* js, int mode)
|
||||||
{
|
{
|
||||||
// Read all queued events (non-blocking)
|
// Read all queued events (non-blocking)
|
||||||
for (;;)
|
for (;;)
|
||||||
|
@ -422,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,9 @@
|
||||||
#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
|
#define GLFW_BUILD_LINUX_MAPPINGS
|
||||||
|
|
||||||
// Linux-specific joystick data
|
// Linux-specific joystick data
|
||||||
|
@ -58,3 +57,9 @@ typedef struct _GLFWlibraryLinux
|
||||||
|
|
||||||
void _glfwDetectJoystickConnectionLinux(void);
|
void _glfwDetectJoystickConnectionLinux(void);
|
||||||
|
|
||||||
|
GLFWbool _glfwInitJoysticksLinux(void);
|
||||||
|
void _glfwTerminateJoysticksLinux(void);
|
||||||
|
int _glfwPollJoystickLinux(_GLFWjoystick* js, int mode);
|
||||||
|
const char* _glfwGetMappingNameLinux(void);
|
||||||
|
void _glfwUpdateGamepadGUIDLinux(char* guid);
|
||||||
|
|
||||||
|
|
|
@ -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,7 +167,7 @@ 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;
|
||||||
|
|
||||||
|
@ -182,22 +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);
|
_glfw_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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -205,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));
|
||||||
}
|
}
|
||||||
|
@ -331,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,
|
||||||
|
@ -352,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)
|
||||||
|
@ -385,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)
|
||||||
|
@ -418,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -446,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -472,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++)
|
||||||
{
|
{
|
||||||
|
@ -494,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)
|
||||||
|
@ -505,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;
|
||||||
|
@ -521,6 +522,8 @@ GLFWAPI void glfwSetGammaRamp(GLFWmonitor* handle, const GLFWgammaramp* ramp)
|
||||||
assert(ramp->green != NULL);
|
assert(ramp->green != NULL);
|
||||||
assert(ramp->blue != NULL);
|
assert(ramp->blue != NULL);
|
||||||
|
|
||||||
|
_GLFW_REQUIRE_INIT();
|
||||||
|
|
||||||
if (ramp->size <= 0)
|
if (ramp->size <= 0)
|
||||||
{
|
{
|
||||||
_glfwInputError(GLFW_INVALID_VALUE,
|
_glfwInputError(GLFW_INVALID_VALUE,
|
||||||
|
@ -529,14 +532,12 @@ GLFWAPI void glfwSetGammaRamp(GLFWmonitor* handle, const GLFWgammaramp* ramp)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_GLFW_REQUIRE_INIT();
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
|
@ -188,45 +188,45 @@ GLFWbool _glfwCreateContextNSGL(_GLFWwindow* window,
|
||||||
// No-error contexts (GL_KHR_no_error) are not yet supported by macOS but
|
// No-error contexts (GL_KHR_no_error) are not yet supported by macOS but
|
||||||
// are not a hard constraint, so ignore and continue
|
// are not a hard constraint, so ignore and continue
|
||||||
|
|
||||||
#define addAttrib(a) \
|
#define ADD_ATTRIB(a) \
|
||||||
{ \
|
{ \
|
||||||
assert((size_t) index < sizeof(attribs) / sizeof(attribs[0])); \
|
assert((size_t) index < sizeof(attribs) / sizeof(attribs[0])); \
|
||||||
attribs[index++] = a; \
|
attribs[index++] = a; \
|
||||||
}
|
}
|
||||||
#define setAttrib(a, v) { addAttrib(a); addAttrib(v); }
|
#define SET_ATTRIB(a, v) { ADD_ATTRIB(a); ADD_ATTRIB(v); }
|
||||||
|
|
||||||
NSOpenGLPixelFormatAttribute attribs[40];
|
NSOpenGLPixelFormatAttribute attribs[40];
|
||||||
int index = 0;
|
int index = 0;
|
||||||
|
|
||||||
addAttrib(NSOpenGLPFAAccelerated);
|
ADD_ATTRIB(NSOpenGLPFAAccelerated);
|
||||||
addAttrib(NSOpenGLPFAClosestPolicy);
|
ADD_ATTRIB(NSOpenGLPFAClosestPolicy);
|
||||||
|
|
||||||
if (ctxconfig->nsgl.offline)
|
if (ctxconfig->nsgl.offline)
|
||||||
{
|
{
|
||||||
addAttrib(NSOpenGLPFAAllowOfflineRenderers);
|
ADD_ATTRIB(NSOpenGLPFAAllowOfflineRenderers);
|
||||||
// NOTE: This replaces the NSSupportsAutomaticGraphicsSwitching key in
|
// NOTE: This replaces the NSSupportsAutomaticGraphicsSwitching key in
|
||||||
// Info.plist for unbundled applications
|
// Info.plist for unbundled applications
|
||||||
// HACK: This assumes that NSOpenGLPixelFormat will remain
|
// HACK: This assumes that NSOpenGLPixelFormat will remain
|
||||||
// a straightforward wrapper of its CGL counterpart
|
// a straightforward wrapper of its CGL counterpart
|
||||||
addAttrib(kCGLPFASupportsAutomaticGraphicsSwitching);
|
ADD_ATTRIB(kCGLPFASupportsAutomaticGraphicsSwitching);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101000
|
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101000
|
||||||
if (ctxconfig->major >= 4)
|
if (ctxconfig->major >= 4)
|
||||||
{
|
{
|
||||||
setAttrib(NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion4_1Core);
|
SET_ATTRIB(NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion4_1Core);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif /*MAC_OS_X_VERSION_MAX_ALLOWED*/
|
#endif /*MAC_OS_X_VERSION_MAX_ALLOWED*/
|
||||||
if (ctxconfig->major >= 3)
|
if (ctxconfig->major >= 3)
|
||||||
{
|
{
|
||||||
setAttrib(NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion3_2Core);
|
SET_ATTRIB(NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion3_2Core);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctxconfig->major <= 2)
|
if (ctxconfig->major <= 2)
|
||||||
{
|
{
|
||||||
if (fbconfig->auxBuffers != GLFW_DONT_CARE)
|
if (fbconfig->auxBuffers != GLFW_DONT_CARE)
|
||||||
setAttrib(NSOpenGLPFAAuxBuffers, fbconfig->auxBuffers);
|
SET_ATTRIB(NSOpenGLPFAAuxBuffers, fbconfig->auxBuffers);
|
||||||
|
|
||||||
if (fbconfig->accumRedBits != GLFW_DONT_CARE &&
|
if (fbconfig->accumRedBits != GLFW_DONT_CARE &&
|
||||||
fbconfig->accumGreenBits != GLFW_DONT_CARE &&
|
fbconfig->accumGreenBits != GLFW_DONT_CARE &&
|
||||||
|
@ -238,7 +238,7 @@ GLFWbool _glfwCreateContextNSGL(_GLFWwindow* window,
|
||||||
fbconfig->accumBlueBits +
|
fbconfig->accumBlueBits +
|
||||||
fbconfig->accumAlphaBits;
|
fbconfig->accumAlphaBits;
|
||||||
|
|
||||||
setAttrib(NSOpenGLPFAAccumSize, accumBits);
|
SET_ATTRIB(NSOpenGLPFAAccumSize, accumBits);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -256,17 +256,17 @@ GLFWbool _glfwCreateContextNSGL(_GLFWwindow* window,
|
||||||
else if (colorBits < 15)
|
else if (colorBits < 15)
|
||||||
colorBits = 15;
|
colorBits = 15;
|
||||||
|
|
||||||
setAttrib(NSOpenGLPFAColorSize, colorBits);
|
SET_ATTRIB(NSOpenGLPFAColorSize, colorBits);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fbconfig->alphaBits != GLFW_DONT_CARE)
|
if (fbconfig->alphaBits != GLFW_DONT_CARE)
|
||||||
setAttrib(NSOpenGLPFAAlphaSize, fbconfig->alphaBits);
|
SET_ATTRIB(NSOpenGLPFAAlphaSize, fbconfig->alphaBits);
|
||||||
|
|
||||||
if (fbconfig->depthBits != GLFW_DONT_CARE)
|
if (fbconfig->depthBits != GLFW_DONT_CARE)
|
||||||
setAttrib(NSOpenGLPFADepthSize, fbconfig->depthBits);
|
SET_ATTRIB(NSOpenGLPFADepthSize, fbconfig->depthBits);
|
||||||
|
|
||||||
if (fbconfig->stencilBits != GLFW_DONT_CARE)
|
if (fbconfig->stencilBits != GLFW_DONT_CARE)
|
||||||
setAttrib(NSOpenGLPFAStencilSize, fbconfig->stencilBits);
|
SET_ATTRIB(NSOpenGLPFAStencilSize, fbconfig->stencilBits);
|
||||||
|
|
||||||
if (fbconfig->stereo)
|
if (fbconfig->stereo)
|
||||||
{
|
{
|
||||||
|
@ -275,33 +275,33 @@ GLFWbool _glfwCreateContextNSGL(_GLFWwindow* window,
|
||||||
"NSGL: Stereo rendering is deprecated");
|
"NSGL: Stereo rendering is deprecated");
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
#else
|
#else
|
||||||
addAttrib(NSOpenGLPFAStereo);
|
ADD_ATTRIB(NSOpenGLPFAStereo);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fbconfig->doublebuffer)
|
if (fbconfig->doublebuffer)
|
||||||
addAttrib(NSOpenGLPFADoubleBuffer);
|
ADD_ATTRIB(NSOpenGLPFADoubleBuffer);
|
||||||
|
|
||||||
if (fbconfig->samples != GLFW_DONT_CARE)
|
if (fbconfig->samples != GLFW_DONT_CARE)
|
||||||
{
|
{
|
||||||
if (fbconfig->samples == 0)
|
if (fbconfig->samples == 0)
|
||||||
{
|
{
|
||||||
setAttrib(NSOpenGLPFASampleBuffers, 0);
|
SET_ATTRIB(NSOpenGLPFASampleBuffers, 0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
setAttrib(NSOpenGLPFASampleBuffers, 1);
|
SET_ATTRIB(NSOpenGLPFASampleBuffers, 1);
|
||||||
setAttrib(NSOpenGLPFASamples, fbconfig->samples);
|
SET_ATTRIB(NSOpenGLPFASamples, fbconfig->samples);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: All NSOpenGLPixelFormats on the relevant cards support sRGB
|
// NOTE: All NSOpenGLPixelFormats on the relevant cards support sRGB
|
||||||
// framebuffer, so there's no need (and no way) to request it
|
// framebuffer, so there's no need (and no way) to request it
|
||||||
|
|
||||||
addAttrib(0);
|
ADD_ATTRIB(0);
|
||||||
|
|
||||||
#undef addAttrib
|
#undef ADD_ATTRIB
|
||||||
#undef setAttrib
|
#undef SET_ATTRIB
|
||||||
|
|
||||||
window->context.nsgl.pixelFormat =
|
window->context.nsgl.pixelFormat =
|
||||||
[[NSOpenGLPixelFormat alloc] initWithAttributes:attribs];
|
[[NSOpenGLPixelFormat alloc] initWithAttributes:attribs];
|
||||||
|
@ -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;
|
||||||
|
|
|
@ -36,22 +36,98 @@
|
||||||
////// GLFW platform API //////
|
////// GLFW platform API //////
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
int _glfwPlatformInit(void)
|
GLFWbool _glfwConnectNull(int platformID, _GLFWplatform* platform)
|
||||||
{
|
{
|
||||||
_glfwInitTimerPOSIX();
|
const _GLFWplatform null =
|
||||||
_glfwPollMonitorsNull();
|
{
|
||||||
|
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);
|
free(_glfw.null.clipboardString);
|
||||||
_glfwTerminateOSMesa();
|
_glfwTerminateOSMesa();
|
||||||
}
|
_glfwTerminateEGL();
|
||||||
|
|
||||||
const char* _glfwPlatformGetVersionString(void)
|
|
||||||
{
|
|
||||||
return _GLFW_VERSION_NUMBER " null OSMesa";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,21 +33,26 @@
|
||||||
////// GLFW platform API //////
|
////// GLFW platform API //////
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
GLFWbool _glfwPlatformInitJoysticks(void)
|
GLFWbool _glfwInitJoysticksNull(void)
|
||||||
{
|
{
|
||||||
return GLFW_TRUE;
|
return GLFW_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformTerminateJoysticks(void)
|
void _glfwTerminateJoysticksNull(void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
int _glfwPlatformPollJoystick(_GLFWjoystick* js, int mode)
|
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);
|
||||||
|
|
||||||
|
|
|
@ -65,12 +65,12 @@ void _glfwPollMonitorsNull(void)
|
||||||
////// GLFW platform API //////
|
////// GLFW platform API //////
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void _glfwPlatformFreeMonitor(_GLFWmonitor* monitor)
|
void _glfwFreeMonitorNull(_GLFWmonitor* monitor)
|
||||||
{
|
{
|
||||||
_glfwFreeGammaArrays(&monitor->null.ramp);
|
_glfwFreeGammaArrays(&monitor->null.ramp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos)
|
void _glfwGetMonitorPosNull(_GLFWmonitor* monitor, int* xpos, int* ypos)
|
||||||
{
|
{
|
||||||
if (xpos)
|
if (xpos)
|
||||||
*xpos = 0;
|
*xpos = 0;
|
||||||
|
@ -78,8 +78,8 @@ void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos)
|
||||||
*ypos = 0;
|
*ypos = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformGetMonitorContentScale(_GLFWmonitor* monitor,
|
void _glfwGetMonitorContentScaleNull(_GLFWmonitor* monitor,
|
||||||
float* xscale, float* yscale)
|
float* xscale, float* yscale)
|
||||||
{
|
{
|
||||||
if (xscale)
|
if (xscale)
|
||||||
*xscale = 1.f;
|
*xscale = 1.f;
|
||||||
|
@ -87,9 +87,9 @@ 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();
|
const GLFWvidmode mode = getVideoMode();
|
||||||
|
|
||||||
|
@ -103,26 +103,28 @@ void _glfwPlatformGetMonitorWorkarea(_GLFWmonitor* monitor,
|
||||||
*height = mode.height - 10;
|
*height = mode.height - 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* found)
|
GLFWvidmode* _glfwGetVideoModesNull(_GLFWmonitor* monitor, int* found)
|
||||||
{
|
{
|
||||||
GLFWvidmode* mode = calloc(1, sizeof(GLFWvidmode));
|
GLFWvidmode* mode = _glfw_calloc(1, sizeof(GLFWvidmode));
|
||||||
*mode = getVideoMode();
|
*mode = getVideoMode();
|
||||||
*found = 1;
|
*found = 1;
|
||||||
return mode;
|
return mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode)
|
void _glfwGetVideoModeNull(_GLFWmonitor* monitor, GLFWvidmode* mode)
|
||||||
{
|
{
|
||||||
*mode = getVideoMode();
|
*mode = getVideoMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWbool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
|
GLFWbool _glfwGetGammaRampNull(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
|
||||||
{
|
{
|
||||||
if (!monitor->null.ramp.size)
|
if (!monitor->null.ramp.size)
|
||||||
{
|
{
|
||||||
|
unsigned int i;
|
||||||
|
|
||||||
_glfwAllocGammaArrays(&monitor->null.ramp, 256);
|
_glfwAllocGammaArrays(&monitor->null.ramp, 256);
|
||||||
|
|
||||||
for (unsigned int i = 0; i < monitor->null.ramp.size; i++)
|
for (i = 0; i < monitor->null.ramp.size; i++)
|
||||||
{
|
{
|
||||||
const float gamma = 2.2f;
|
const float gamma = 2.2f;
|
||||||
float value;
|
float value;
|
||||||
|
@ -143,7 +145,7 @@ GLFWbool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
|
||||||
return GLFW_TRUE;
|
return GLFW_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp)
|
void _glfwSetGammaRampNull(_GLFWmonitor* monitor, const GLFWgammaramp* ramp)
|
||||||
{
|
{
|
||||||
if (monitor->null.ramp.size != ramp->size)
|
if (monitor->null.ramp.size != ramp->size)
|
||||||
{
|
{
|
||||||
|
|
|
@ -25,29 +25,14 @@
|
||||||
//
|
//
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
#include <dlfcn.h>
|
#define GLFW_NULL_WINDOW_STATE _GLFWwindowNull null;
|
||||||
|
#define GLFW_NULL_LIBRARY_WINDOW_STATE _GLFWlibraryNull null;
|
||||||
|
#define GLFW_NULL_MONITOR_STATE _GLFWmonitorNull null;
|
||||||
|
|
||||||
#define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowNull null
|
#define GLFW_NULL_CONTEXT_STATE
|
||||||
#define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryNull null
|
#define GLFW_NULL_CURSOR_STATE
|
||||||
#define _GLFW_PLATFORM_MONITOR_STATE _GLFWmonitorNull null
|
#define GLFW_NULL_LIBRARY_CONTEXT_STATE
|
||||||
|
|
||||||
#define _GLFW_PLATFORM_CONTEXT_STATE struct { int dummyContext; }
|
|
||||||
#define _GLFW_PLATFORM_CURSOR_STATE struct { int dummyCursor; }
|
|
||||||
#define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE struct { int dummyLibraryContext; }
|
|
||||||
|
|
||||||
#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
|
||||||
//
|
//
|
||||||
|
@ -87,3 +72,78 @@ typedef struct _GLFWlibraryNull
|
||||||
|
|
||||||
void _glfwPollMonitorsNull(void);
|
void _glfwPollMonitorsNull(void);
|
||||||
|
|
||||||
|
GLFWbool _glfwConnectNull(int platformID, _GLFWplatform* platform);
|
||||||
|
int _glfwInitNull(void);
|
||||||
|
void _glfwTerminateNull(void);
|
||||||
|
|
||||||
|
void _glfwFreeMonitorNull(_GLFWmonitor* monitor);
|
||||||
|
void _glfwGetMonitorPosNull(_GLFWmonitor* monitor, int* xpos, int* ypos);
|
||||||
|
void _glfwGetMonitorContentScaleNull(_GLFWmonitor* monitor, float* xscale, float* yscale);
|
||||||
|
void _glfwGetMonitorWorkareaNull(_GLFWmonitor* monitor, int* xpos, int* ypos, int* width, int* height);
|
||||||
|
GLFWvidmode* _glfwGetVideoModesNull(_GLFWmonitor* monitor, int* found);
|
||||||
|
void _glfwGetVideoModeNull(_GLFWmonitor* monitor, GLFWvidmode* mode);
|
||||||
|
GLFWbool _glfwGetGammaRampNull(_GLFWmonitor* monitor, GLFWgammaramp* ramp);
|
||||||
|
void _glfwSetGammaRampNull(_GLFWmonitor* monitor, const GLFWgammaramp* ramp);
|
||||||
|
|
||||||
|
int _glfwCreateWindowNull(_GLFWwindow* window, const _GLFWwndconfig* wndconfig, const _GLFWctxconfig* ctxconfig, const _GLFWfbconfig* fbconfig);
|
||||||
|
void _glfwDestroyWindowNull(_GLFWwindow* window);
|
||||||
|
void _glfwSetWindowTitleNull(_GLFWwindow* window, const char* title);
|
||||||
|
void _glfwSetWindowIconNull(_GLFWwindow* window, int count, const GLFWimage* images);
|
||||||
|
void _glfwSetWindowMonitorNull(_GLFWwindow* window, _GLFWmonitor* monitor, int xpos, int ypos, int width, int height, int refreshRate);
|
||||||
|
void _glfwGetWindowPosNull(_GLFWwindow* window, int* xpos, int* ypos);
|
||||||
|
void _glfwSetWindowPosNull(_GLFWwindow* window, int xpos, int ypos);
|
||||||
|
void _glfwGetWindowSizeNull(_GLFWwindow* window, int* width, int* height);
|
||||||
|
void _glfwSetWindowSizeNull(_GLFWwindow* window, int width, int height);
|
||||||
|
void _glfwSetWindowSizeLimitsNull(_GLFWwindow* window, int minwidth, int minheight, int maxwidth, int maxheight);
|
||||||
|
void _glfwSetWindowAspectRatioNull(_GLFWwindow* window, int n, int d);
|
||||||
|
void _glfwGetFramebufferSizeNull(_GLFWwindow* window, int* width, int* height);
|
||||||
|
void _glfwGetWindowFrameSizeNull(_GLFWwindow* window, int* left, int* top, int* right, int* bottom);
|
||||||
|
void _glfwGetWindowContentScaleNull(_GLFWwindow* window, float* xscale, float* yscale);
|
||||||
|
void _glfwIconifyWindowNull(_GLFWwindow* window);
|
||||||
|
void _glfwRestoreWindowNull(_GLFWwindow* window);
|
||||||
|
void _glfwMaximizeWindowNull(_GLFWwindow* window);
|
||||||
|
int _glfwWindowMaximizedNull(_GLFWwindow* window);
|
||||||
|
int _glfwWindowHoveredNull(_GLFWwindow* window);
|
||||||
|
int _glfwFramebufferTransparentNull(_GLFWwindow* window);
|
||||||
|
void _glfwSetWindowResizableNull(_GLFWwindow* window, GLFWbool enabled);
|
||||||
|
void _glfwSetWindowDecoratedNull(_GLFWwindow* window, GLFWbool enabled);
|
||||||
|
void _glfwSetWindowFloatingNull(_GLFWwindow* window, GLFWbool enabled);
|
||||||
|
void _glfwSetWindowMousePassthroughNull(_GLFWwindow* window, GLFWbool enabled);
|
||||||
|
float _glfwGetWindowOpacityNull(_GLFWwindow* window);
|
||||||
|
void _glfwSetWindowOpacityNull(_GLFWwindow* window, float opacity);
|
||||||
|
void _glfwSetRawMouseMotionNull(_GLFWwindow *window, GLFWbool enabled);
|
||||||
|
GLFWbool _glfwRawMouseMotionSupportedNull(void);
|
||||||
|
void _glfwShowWindowNull(_GLFWwindow* window);
|
||||||
|
void _glfwRequestWindowAttentionNull(_GLFWwindow* window);
|
||||||
|
void _glfwRequestWindowAttentionNull(_GLFWwindow* window);
|
||||||
|
void _glfwHideWindowNull(_GLFWwindow* window);
|
||||||
|
void _glfwFocusWindowNull(_GLFWwindow* window);
|
||||||
|
int _glfwWindowFocusedNull(_GLFWwindow* window);
|
||||||
|
int _glfwWindowIconifiedNull(_GLFWwindow* window);
|
||||||
|
int _glfwWindowVisibleNull(_GLFWwindow* window);
|
||||||
|
void _glfwPollEventsNull(void);
|
||||||
|
void _glfwWaitEventsNull(void);
|
||||||
|
void _glfwWaitEventsTimeoutNull(double timeout);
|
||||||
|
void _glfwPostEmptyEventNull(void);
|
||||||
|
void _glfwGetCursorPosNull(_GLFWwindow* window, double* xpos, double* ypos);
|
||||||
|
void _glfwSetCursorPosNull(_GLFWwindow* window, double x, double y);
|
||||||
|
void _glfwSetCursorModeNull(_GLFWwindow* window, int mode);
|
||||||
|
int _glfwCreateCursorNull(_GLFWcursor* cursor, const GLFWimage* image, int xhot, int yhot);
|
||||||
|
int _glfwCreateStandardCursorNull(_GLFWcursor* cursor, int shape);
|
||||||
|
void _glfwDestroyCursorNull(_GLFWcursor* cursor);
|
||||||
|
void _glfwSetCursorNull(_GLFWwindow* window, _GLFWcursor* cursor);
|
||||||
|
void _glfwSetClipboardStringNull(const char* string);
|
||||||
|
const char* _glfwGetClipboardStringNull(void);
|
||||||
|
const char* _glfwGetScancodeNameNull(int scancode);
|
||||||
|
int _glfwGetKeyScancodeNull(int key);
|
||||||
|
|
||||||
|
EGLenum _glfwGetEGLPlatformNull(EGLint** attribs);
|
||||||
|
EGLNativeDisplayType _glfwGetEGLNativeDisplayNull(void);
|
||||||
|
EGLNativeWindowType _glfwGetEGLNativeWindowNull(_GLFWwindow* window);
|
||||||
|
|
||||||
|
void _glfwGetRequiredInstanceExtensionsNull(char** extensions);
|
||||||
|
int _glfwGetPhysicalDevicePresentationSupportNull(VkInstance instance, VkPhysicalDevice device, uint32_t queuefamily);
|
||||||
|
VkResult _glfwCreateWindowSurfaceNull(VkInstance instance, _GLFWwindow* window, const VkAllocationCallbacks* allocator, VkSurfaceKHR* surface);
|
||||||
|
|
||||||
|
void _glfwPollMonitorsNull(void);
|
||||||
|
|
||||||
|
|
|
@ -39,24 +39,24 @@ static void applySizeLimits(_GLFWwindow* window, int* width, int* height)
|
||||||
*height = (int) (*width / ratio);
|
*height = (int) (*width / ratio);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (window->minwidth != GLFW_DONT_CARE && *width < window->minwidth)
|
if (window->minwidth != GLFW_DONT_CARE)
|
||||||
*width = window->minwidth;
|
*width = _glfw_max(*width, window->minwidth);
|
||||||
else if (window->maxwidth != GLFW_DONT_CARE && *width > window->maxwidth)
|
else if (window->maxwidth != GLFW_DONT_CARE)
|
||||||
*width = window->maxwidth;
|
*width = _glfw_min(*width, window->maxwidth);
|
||||||
|
|
||||||
if (window->minheight != GLFW_DONT_CARE && *height < window->minheight)
|
if (window->minheight != GLFW_DONT_CARE)
|
||||||
*height = window->minheight;
|
*height = _glfw_min(*height, window->minheight);
|
||||||
else if (window->maxheight != GLFW_DONT_CARE && *height > window->maxheight)
|
else if (window->maxheight != GLFW_DONT_CARE)
|
||||||
*height = window->maxheight;
|
*height = _glfw_max(*height, window->maxheight);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void fitToMonitor(_GLFWwindow* window)
|
static void fitToMonitor(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
GLFWvidmode mode;
|
GLFWvidmode mode;
|
||||||
_glfwPlatformGetVideoMode(window->monitor, &mode);
|
_glfwGetVideoModeNull(window->monitor, &mode);
|
||||||
_glfwPlatformGetMonitorPos(window->monitor,
|
_glfwGetMonitorPosNull(window->monitor,
|
||||||
&window->null.xpos,
|
&window->null.xpos,
|
||||||
&window->null.ypos);
|
&window->null.ypos);
|
||||||
window->null.width = mode.width;
|
window->null.width = mode.width;
|
||||||
window->null.height = mode.height;
|
window->null.height = mode.height;
|
||||||
}
|
}
|
||||||
|
@ -103,10 +103,10 @@ 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, fbconfig))
|
if (!createNativeWindow(window, wndconfig, fbconfig))
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
|
@ -121,24 +121,44 @@ 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;
|
return GLFW_FALSE;
|
||||||
|
if (!_glfwCreateContextEGL(window, ctxconfig, fbconfig))
|
||||||
|
return GLFW_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!_glfwRefreshContextAttribs(window, ctxconfig))
|
||||||
|
return GLFW_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (wndconfig->mousePassthrough)
|
||||||
|
_glfwSetWindowMousePassthroughNull(window, GLFW_TRUE);
|
||||||
|
|
||||||
if (window->monitor)
|
if (window->monitor)
|
||||||
{
|
{
|
||||||
_glfwPlatformShowWindow(window);
|
_glfwShowWindowNull(window);
|
||||||
_glfwPlatformFocusWindow(window);
|
_glfwFocusWindowNull(window);
|
||||||
acquireMonitor(window);
|
acquireMonitor(window);
|
||||||
|
|
||||||
|
if (wndconfig->centerCursor)
|
||||||
|
_glfwCenterCursorInContentArea(window);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (wndconfig->visible)
|
||||||
|
{
|
||||||
|
_glfwShowWindowNull(window);
|
||||||
|
if (wndconfig->focused)
|
||||||
|
_glfwFocusWindowNull(window);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return GLFW_TRUE;
|
return GLFW_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformDestroyWindow(_GLFWwindow* window)
|
void _glfwDestroyWindowNull(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
if (window->monitor)
|
if (window->monitor)
|
||||||
releaseMonitor(window);
|
releaseMonitor(window);
|
||||||
|
@ -150,27 +170,26 @@ void _glfwPlatformDestroyWindow(_GLFWwindow* window)
|
||||||
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)
|
if (window->monitor == monitor)
|
||||||
{
|
{
|
||||||
if (!monitor)
|
if (!monitor)
|
||||||
{
|
{
|
||||||
_glfwPlatformSetWindowPos(window, xpos, ypos);
|
_glfwSetWindowPosNull(window, xpos, ypos);
|
||||||
_glfwPlatformSetWindowSize(window, width, height);
|
_glfwSetWindowSizeNull(window, width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -189,12 +208,12 @@ void _glfwPlatformSetWindowMonitor(_GLFWwindow* window,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_glfwPlatformSetWindowPos(window, xpos, ypos);
|
_glfwSetWindowPosNull(window, xpos, ypos);
|
||||||
_glfwPlatformSetWindowSize(window, width, height);
|
_glfwSetWindowSizeNull(window, width, height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos)
|
void _glfwGetWindowPosNull(_GLFWwindow* window, int* xpos, int* ypos)
|
||||||
{
|
{
|
||||||
if (xpos)
|
if (xpos)
|
||||||
*xpos = window->null.xpos;
|
*xpos = window->null.xpos;
|
||||||
|
@ -202,7 +221,7 @@ void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos)
|
||||||
*ypos = window->null.ypos;
|
*ypos = window->null.ypos;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformSetWindowPos(_GLFWwindow* window, int xpos, int ypos)
|
void _glfwSetWindowPosNull(_GLFWwindow* window, int xpos, int ypos)
|
||||||
{
|
{
|
||||||
if (window->monitor)
|
if (window->monitor)
|
||||||
return;
|
return;
|
||||||
|
@ -215,7 +234,7 @@ void _glfwPlatformSetWindowPos(_GLFWwindow* window, int xpos, int ypos)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformGetWindowSize(_GLFWwindow* window, int* width, int* height)
|
void _glfwGetWindowSizeNull(_GLFWwindow* window, int* width, int* height)
|
||||||
{
|
{
|
||||||
if (width)
|
if (width)
|
||||||
*width = window->null.width;
|
*width = window->null.width;
|
||||||
|
@ -223,7 +242,7 @@ 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)
|
if (window->monitor)
|
||||||
return;
|
return;
|
||||||
|
@ -237,25 +256,25 @@ void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int 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 width = window->null.width;
|
||||||
int height = window->null.height;
|
int height = window->null.height;
|
||||||
applySizeLimits(window, &width, &height);
|
applySizeLimits(window, &width, &height);
|
||||||
_glfwPlatformSetWindowSize(window, width, height);
|
_glfwSetWindowSizeNull(window, width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformSetWindowAspectRatio(_GLFWwindow* window, int n, int d)
|
void _glfwSetWindowAspectRatioNull(_GLFWwindow* window, int n, int d)
|
||||||
{
|
{
|
||||||
int width = window->null.width;
|
int width = window->null.width;
|
||||||
int height = window->null.height;
|
int height = window->null.height;
|
||||||
applySizeLimits(window, &width, &height);
|
applySizeLimits(window, &width, &height);
|
||||||
_glfwPlatformSetWindowSize(window, width, height);
|
_glfwSetWindowSizeNull(window, width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformGetFramebufferSize(_GLFWwindow* window, int* width, int* height)
|
void _glfwGetFramebufferSizeNull(_GLFWwindow* window, int* width, int* height)
|
||||||
{
|
{
|
||||||
if (width)
|
if (width)
|
||||||
*width = window->null.width;
|
*width = window->null.width;
|
||||||
|
@ -263,9 +282,9 @@ 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 (window->null.decorated && !window->monitor)
|
||||||
{
|
{
|
||||||
|
@ -291,8 +310,7 @@ void _glfwPlatformGetWindowFrameSize(_GLFWwindow* window,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
|
@ -300,7 +318,7 @@ void _glfwPlatformGetWindowContentScale(_GLFWwindow* window,
|
||||||
*yscale = 1.f;
|
*yscale = 1.f;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformIconifyWindow(_GLFWwindow* window)
|
void _glfwIconifyWindowNull(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
if (_glfw.null.focusedWindow == window)
|
if (_glfw.null.focusedWindow == window)
|
||||||
{
|
{
|
||||||
|
@ -318,7 +336,7 @@ void _glfwPlatformIconifyWindow(_GLFWwindow* window)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformRestoreWindow(_GLFWwindow* window)
|
void _glfwRestoreWindowNull(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
if (window->null.iconified)
|
if (window->null.iconified)
|
||||||
{
|
{
|
||||||
|
@ -335,7 +353,7 @@ void _glfwPlatformRestoreWindow(_GLFWwindow* window)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformMaximizeWindow(_GLFWwindow* window)
|
void _glfwMaximizeWindowNull(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
if (!window->null.maximized)
|
if (!window->null.maximized)
|
||||||
{
|
{
|
||||||
|
@ -344,12 +362,12 @@ void _glfwPlatformMaximizeWindow(_GLFWwindow* window)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int _glfwPlatformWindowMaximized(_GLFWwindow* window)
|
int _glfwWindowMaximizedNull(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
return window->null.maximized;
|
return window->null.maximized;
|
||||||
}
|
}
|
||||||
|
|
||||||
int _glfwPlatformWindowHovered(_GLFWwindow* window)
|
int _glfwWindowHoveredNull(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
return _glfw.null.xcursor >= window->null.xpos &&
|
return _glfw.null.xcursor >= window->null.xpos &&
|
||||||
_glfw.null.ycursor >= window->null.ypos &&
|
_glfw.null.ycursor >= window->null.ypos &&
|
||||||
|
@ -357,59 +375,59 @@ int _glfwPlatformWindowHovered(_GLFWwindow* window)
|
||||||
_glfw.null.ycursor <= window->null.ypos + window->null.height - 1;
|
_glfw.null.ycursor <= window->null.ypos + window->null.height - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int _glfwPlatformFramebufferTransparent(_GLFWwindow* window)
|
int _glfwFramebufferTransparentNull(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
return window->null.transparent;
|
return window->null.transparent;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformSetWindowResizable(_GLFWwindow* window, GLFWbool enabled)
|
void _glfwSetWindowResizableNull(_GLFWwindow* window, GLFWbool enabled)
|
||||||
{
|
{
|
||||||
window->null.resizable = enabled;
|
window->null.resizable = enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformSetWindowDecorated(_GLFWwindow* window, GLFWbool enabled)
|
void _glfwSetWindowDecoratedNull(_GLFWwindow* window, GLFWbool enabled)
|
||||||
{
|
{
|
||||||
window->null.decorated = enabled;
|
window->null.decorated = enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled)
|
void _glfwSetWindowFloatingNull(_GLFWwindow* window, GLFWbool enabled)
|
||||||
{
|
{
|
||||||
window->null.floating = enabled;
|
window->null.floating = enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformSetWindowMousePassthrough(_GLFWwindow* window, GLFWbool enabled)
|
void _glfwSetWindowMousePassthroughNull(_GLFWwindow* window, GLFWbool enabled)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
float _glfwPlatformGetWindowOpacity(_GLFWwindow* window)
|
float _glfwGetWindowOpacityNull(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
return window->null.opacity;
|
return window->null.opacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformSetWindowOpacity(_GLFWwindow* window, float opacity)
|
void _glfwSetWindowOpacityNull(_GLFWwindow* window, float opacity)
|
||||||
{
|
{
|
||||||
window->null.opacity = opacity;
|
window->null.opacity = opacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformSetRawMouseMotion(_GLFWwindow *window, GLFWbool enabled)
|
void _glfwSetRawMouseMotionNull(_GLFWwindow *window, GLFWbool enabled)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWbool _glfwPlatformRawMouseMotionSupported(void)
|
GLFWbool _glfwRawMouseMotionSupportedNull(void)
|
||||||
{
|
{
|
||||||
return GLFW_TRUE;
|
return GLFW_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformShowWindow(_GLFWwindow* window)
|
void _glfwShowWindowNull(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
window->null.visible = GLFW_TRUE;
|
window->null.visible = GLFW_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformRequestWindowAttention(_GLFWwindow* window)
|
void _glfwRequestWindowAttentionNull(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformHideWindow(_GLFWwindow* window)
|
void _glfwHideWindowNull(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
if (_glfw.null.focusedWindow == window)
|
if (_glfw.null.focusedWindow == window)
|
||||||
{
|
{
|
||||||
|
@ -420,59 +438,61 @@ void _glfwPlatformHideWindow(_GLFWwindow* window)
|
||||||
window->null.visible = GLFW_FALSE;
|
window->null.visible = GLFW_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformFocusWindow(_GLFWwindow* window)
|
void _glfwFocusWindowNull(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
|
_GLFWwindow* previous;
|
||||||
|
|
||||||
if (_glfw.null.focusedWindow == window)
|
if (_glfw.null.focusedWindow == window)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!window->null.visible)
|
if (!window->null.visible)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_GLFWwindow* previous = _glfw.null.focusedWindow;
|
previous = _glfw.null.focusedWindow;
|
||||||
_glfw.null.focusedWindow = window;
|
_glfw.null.focusedWindow = window;
|
||||||
|
|
||||||
if (previous)
|
if (previous)
|
||||||
{
|
{
|
||||||
_glfwInputWindowFocus(previous, GLFW_FALSE);
|
_glfwInputWindowFocus(previous, GLFW_FALSE);
|
||||||
if (previous->monitor && previous->autoIconify)
|
if (previous->monitor && previous->autoIconify)
|
||||||
_glfwPlatformIconifyWindow(previous);
|
_glfwIconifyWindowNull(previous);
|
||||||
}
|
}
|
||||||
|
|
||||||
_glfwInputWindowFocus(window, GLFW_TRUE);
|
_glfwInputWindowFocus(window, GLFW_TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
int _glfwPlatformWindowFocused(_GLFWwindow* window)
|
int _glfwWindowFocusedNull(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
return _glfw.null.focusedWindow == window;
|
return _glfw.null.focusedWindow == window;
|
||||||
}
|
}
|
||||||
|
|
||||||
int _glfwPlatformWindowIconified(_GLFWwindow* window)
|
int _glfwWindowIconifiedNull(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
return window->null.iconified;
|
return window->null.iconified;
|
||||||
}
|
}
|
||||||
|
|
||||||
int _glfwPlatformWindowVisible(_GLFWwindow* window)
|
int _glfwWindowVisibleNull(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
return window->null.visible;
|
return window->null.visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformPollEvents(void)
|
void _glfwPollEventsNull(void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformWaitEvents(void)
|
void _glfwWaitEventsNull(void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformWaitEventsTimeout(double timeout)
|
void _glfwWaitEventsTimeoutNull(double timeout)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformPostEmptyEvent(void)
|
void _glfwPostEmptyEventNull(void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformGetCursorPos(_GLFWwindow* window, double* xpos, double* ypos)
|
void _glfwGetCursorPosNull(_GLFWwindow* window, double* xpos, double* ypos)
|
||||||
{
|
{
|
||||||
if (xpos)
|
if (xpos)
|
||||||
*xpos = _glfw.null.xcursor - window->null.xpos;
|
*xpos = _glfw.null.xcursor - window->null.xpos;
|
||||||
|
@ -480,49 +500,64 @@ void _glfwPlatformGetCursorPos(_GLFWwindow* window, double* xpos, double* ypos)
|
||||||
*ypos = _glfw.null.ycursor - window->null.ypos;
|
*ypos = _glfw.null.ycursor - window->null.ypos;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformSetCursorPos(_GLFWwindow* window, double x, double y)
|
void _glfwSetCursorPosNull(_GLFWwindow* window, double x, double y)
|
||||||
{
|
{
|
||||||
_glfw.null.xcursor = window->null.xpos + (int) x;
|
_glfw.null.xcursor = window->null.xpos + (int) x;
|
||||||
_glfw.null.ycursor = window->null.ypos + (int) y;
|
_glfw.null.ycursor = window->null.ypos + (int) y;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode)
|
void _glfwSetCursorModeNull(_GLFWwindow* window, int mode)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
int _glfwPlatformCreateCursor(_GLFWcursor* cursor,
|
int _glfwCreateCursorNull(_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);
|
char* copy = _glfw_strdup(string);
|
||||||
free(_glfw.null.clipboardString);
|
_glfw_free(_glfw.null.clipboardString);
|
||||||
_glfw.null.clipboardString = copy;
|
_glfw.null.clipboardString = copy;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* _glfwPlatformGetClipboardString(void)
|
const char* _glfwGetClipboardStringNull(void)
|
||||||
{
|
{
|
||||||
return _glfw.null.clipboardString;
|
return _glfw.null.clipboardString;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* _glfwPlatformGetScancodeName(int scancode)
|
EGLenum _glfwGetEGLPlatformNull(EGLint** attribs)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
EGLNativeDisplayType _glfwGetEGLNativeDisplayNull(void)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
EGLNativeWindowType _glfwGetEGLNativeWindowNull(_GLFWwindow* window)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* _glfwGetScancodeNameNull(int scancode)
|
||||||
{
|
{
|
||||||
if (scancode < GLFW_KEY_SPACE || scancode > GLFW_KEY_LAST)
|
if (scancode < GLFW_KEY_SPACE || scancode > GLFW_KEY_LAST)
|
||||||
{
|
{
|
||||||
|
@ -649,26 +684,26 @@ const char* _glfwPlatformGetScancodeName(int scancode)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int _glfwPlatformGetKeyScancode(int key)
|
int _glfwGetKeyScancodeNull(int key)
|
||||||
{
|
{
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformGetRequiredInstanceExtensions(char** extensions)
|
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_EXTENSION_NOT_PRESENT;
|
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__) || defined(__NetBSD__)
|
||||||
|
"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,12 +185,12 @@ 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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#define setAttrib(a, v) \
|
#define SET_ATTRIB(a, v) \
|
||||||
{ \
|
{ \
|
||||||
assert(((size_t) index + 1) < sizeof(attribs) / sizeof(attribs[0])); \
|
assert(((size_t) index + 1) < sizeof(attribs) / sizeof(attribs[0])); \
|
||||||
attribs[index++] = a; \
|
attribs[index++] = a; \
|
||||||
|
@ -219,24 +221,24 @@ GLFWbool _glfwCreateContextOSMesa(_GLFWwindow* window,
|
||||||
{
|
{
|
||||||
int index = 0, attribs[40];
|
int index = 0, attribs[40];
|
||||||
|
|
||||||
setAttrib(OSMESA_FORMAT, OSMESA_RGBA);
|
SET_ATTRIB(OSMESA_FORMAT, OSMESA_RGBA);
|
||||||
setAttrib(OSMESA_DEPTH_BITS, fbconfig->depthBits);
|
SET_ATTRIB(OSMESA_DEPTH_BITS, fbconfig->depthBits);
|
||||||
setAttrib(OSMESA_STENCIL_BITS, fbconfig->stencilBits);
|
SET_ATTRIB(OSMESA_STENCIL_BITS, fbconfig->stencilBits);
|
||||||
setAttrib(OSMESA_ACCUM_BITS, accumBits);
|
SET_ATTRIB(OSMESA_ACCUM_BITS, accumBits);
|
||||||
|
|
||||||
if (ctxconfig->profile == GLFW_OPENGL_CORE_PROFILE)
|
if (ctxconfig->profile == GLFW_OPENGL_CORE_PROFILE)
|
||||||
{
|
{
|
||||||
setAttrib(OSMESA_PROFILE, OSMESA_CORE_PROFILE);
|
SET_ATTRIB(OSMESA_PROFILE, OSMESA_CORE_PROFILE);
|
||||||
}
|
}
|
||||||
else if (ctxconfig->profile == GLFW_OPENGL_COMPAT_PROFILE)
|
else if (ctxconfig->profile == GLFW_OPENGL_COMPAT_PROFILE)
|
||||||
{
|
{
|
||||||
setAttrib(OSMESA_PROFILE, OSMESA_COMPAT_PROFILE);
|
SET_ATTRIB(OSMESA_PROFILE, OSMESA_COMPAT_PROFILE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctxconfig->major != 1 || ctxconfig->minor != 0)
|
if (ctxconfig->major != 1 || ctxconfig->minor != 0)
|
||||||
{
|
{
|
||||||
setAttrib(OSMESA_CONTEXT_MAJOR_VERSION, ctxconfig->major);
|
SET_ATTRIB(OSMESA_CONTEXT_MAJOR_VERSION, ctxconfig->major);
|
||||||
setAttrib(OSMESA_CONTEXT_MINOR_VERSION, ctxconfig->minor);
|
SET_ATTRIB(OSMESA_CONTEXT_MINOR_VERSION, ctxconfig->minor);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctxconfig->forward)
|
if (ctxconfig->forward)
|
||||||
|
@ -246,7 +248,7 @@ GLFWbool _glfwCreateContextOSMesa(_GLFWwindow* window,
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
setAttrib(0, 0);
|
SET_ATTRIB(0, 0);
|
||||||
|
|
||||||
window->context.osmesa.handle =
|
window->context.osmesa.handle =
|
||||||
OSMesaCreateContextAttribs(attribs, share);
|
OSMesaCreateContextAttribs(attribs, share);
|
||||||
|
@ -285,7 +287,7 @@ GLFWbool _glfwCreateContextOSMesa(_GLFWwindow* window,
|
||||||
return GLFW_TRUE;
|
return GLFW_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef setAttrib
|
#undef SET_ATTRIB
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -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,90 +0,0 @@
|
||||||
//========================================================================
|
|
||||||
// GLFW 3.4 OSMesa - www.glfw.org
|
|
||||||
//------------------------------------------------------------------------
|
|
||||||
// Copyright (c) 2016 Google Inc.
|
|
||||||
// Copyright (c) 2016-2017 Camilla Löwy <elmindreda@glfw.org>
|
|
||||||
//
|
|
||||||
// This software is provided 'as-is', without any express or implied
|
|
||||||
// warranty. In no event will the authors be held liable for any damages
|
|
||||||
// arising from the use of this software.
|
|
||||||
//
|
|
||||||
// Permission is granted to anyone to use this software for any purpose,
|
|
||||||
// including commercial applications, and to alter it and redistribute it
|
|
||||||
// freely, subject to the following restrictions:
|
|
||||||
//
|
|
||||||
// 1. The origin of this software must not be misrepresented; you must not
|
|
||||||
// claim that you wrote the original software. If you use this software
|
|
||||||
// in a product, an acknowledgment in the product documentation would
|
|
||||||
// be appreciated but is not required.
|
|
||||||
//
|
|
||||||
// 2. Altered source versions must be plainly marked as such, and must not
|
|
||||||
// be misrepresented as being the original software.
|
|
||||||
//
|
|
||||||
// 3. This notice may not be removed or altered from any source
|
|
||||||
// distribution.
|
|
||||||
//
|
|
||||||
//========================================================================
|
|
||||||
|
|
||||||
#define OSMESA_RGBA 0x1908
|
|
||||||
#define OSMESA_FORMAT 0x22
|
|
||||||
#define OSMESA_DEPTH_BITS 0x30
|
|
||||||
#define OSMESA_STENCIL_BITS 0x31
|
|
||||||
#define OSMESA_ACCUM_BITS 0x32
|
|
||||||
#define OSMESA_PROFILE 0x33
|
|
||||||
#define OSMESA_CORE_PROFILE 0x34
|
|
||||||
#define OSMESA_COMPAT_PROFILE 0x35
|
|
||||||
#define OSMESA_CONTEXT_MAJOR_VERSION 0x36
|
|
||||||
#define OSMESA_CONTEXT_MINOR_VERSION 0x37
|
|
||||||
|
|
||||||
typedef void* OSMesaContext;
|
|
||||||
typedef void (*OSMESAproc)(void);
|
|
||||||
|
|
||||||
typedef OSMesaContext (GLAPIENTRY * PFN_OSMesaCreateContextExt)(GLenum,GLint,GLint,GLint,OSMesaContext);
|
|
||||||
typedef OSMesaContext (GLAPIENTRY * PFN_OSMesaCreateContextAttribs)(const int*,OSMesaContext);
|
|
||||||
typedef void (GLAPIENTRY * PFN_OSMesaDestroyContext)(OSMesaContext);
|
|
||||||
typedef int (GLAPIENTRY * PFN_OSMesaMakeCurrent)(OSMesaContext,void*,int,int,int);
|
|
||||||
typedef int (GLAPIENTRY * PFN_OSMesaGetColorBuffer)(OSMesaContext,int*,int*,int*,void**);
|
|
||||||
typedef int (GLAPIENTRY * PFN_OSMesaGetDepthBuffer)(OSMesaContext,int*,int*,int*,void**);
|
|
||||||
typedef GLFWglproc (GLAPIENTRY * PFN_OSMesaGetProcAddress)(const char*);
|
|
||||||
#define OSMesaCreateContextExt _glfw.osmesa.CreateContextExt
|
|
||||||
#define OSMesaCreateContextAttribs _glfw.osmesa.CreateContextAttribs
|
|
||||||
#define OSMesaDestroyContext _glfw.osmesa.DestroyContext
|
|
||||||
#define OSMesaMakeCurrent _glfw.osmesa.MakeCurrent
|
|
||||||
#define OSMesaGetColorBuffer _glfw.osmesa.GetColorBuffer
|
|
||||||
#define OSMesaGetDepthBuffer _glfw.osmesa.GetDepthBuffer
|
|
||||||
#define OSMesaGetProcAddress _glfw.osmesa.GetProcAddress
|
|
||||||
|
|
||||||
// OSMesa-specific per-context data
|
|
||||||
//
|
|
||||||
typedef struct _GLFWcontextOSMesa
|
|
||||||
{
|
|
||||||
OSMesaContext handle;
|
|
||||||
int width;
|
|
||||||
int height;
|
|
||||||
void* buffer;
|
|
||||||
|
|
||||||
} _GLFWcontextOSMesa;
|
|
||||||
|
|
||||||
// OSMesa-specific 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
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
163
src/platform.h
Normal file
163
src/platform.h
Normal file
|
@ -0,0 +1,163 @@
|
||||||
|
//========================================================================
|
||||||
|
// 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
|
||||||
|
|
||||||
|
#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_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_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
|
||||||
|
|
||||||
|
#if defined(_WIN32)
|
||||||
|
#include "win32_thread.h"
|
||||||
|
#define GLFW_PLATFORM_TLS_STATE GLFW_WIN32_TLS_STATE
|
||||||
|
#define GLFW_PLATFORM_MUTEX_STATE GLFW_WIN32_MUTEX_STATE
|
||||||
|
#else
|
||||||
|
#include "posix_thread.h"
|
||||||
|
#define GLFW_PLATFORM_TLS_STATE GLFW_POSIX_TLS_STATE
|
||||||
|
#define GLFW_PLATFORM_MUTEX_STATE GLFW_POSIX_MUTEX_STATE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(_WIN32)
|
||||||
|
#include "win32_time.h"
|
||||||
|
#define GLFW_PLATFORM_LIBRARY_TIMER_STATE GLFW_WIN32_LIBRARY_TIMER_STATE
|
||||||
|
#elif defined(__APPLE__)
|
||||||
|
#include "cocoa_time.h"
|
||||||
|
#define GLFW_PLATFORM_LIBRARY_TIMER_STATE GLFW_COCOA_LIBRARY_TIMER_STATE
|
||||||
|
#else
|
||||||
|
#include "posix_time.h"
|
||||||
|
#define GLFW_PLATFORM_LIBRARY_TIMER_STATE GLFW_POSIX_LIBRARY_TIMER_STATE
|
||||||
|
#endif
|
||||||
|
|
51
src/posix_module.c
Normal file
51
src/posix_module.c
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
//========================================================================
|
||||||
|
// GLFW 3.4 POSIX - www.glfw.org
|
||||||
|
//------------------------------------------------------------------------
|
||||||
|
// Copyright (c) 2021 Camilla Löwy <elmindreda@glfw.org>
|
||||||
|
//
|
||||||
|
// This software is provided 'as-is', without any express or implied
|
||||||
|
// warranty. In no event will the authors be held liable for any damages
|
||||||
|
// arising from the use of this software.
|
||||||
|
//
|
||||||
|
// Permission is granted to anyone to use this software for any purpose,
|
||||||
|
// including commercial applications, and to alter it and redistribute it
|
||||||
|
// freely, subject to the following restrictions:
|
||||||
|
//
|
||||||
|
// 1. The origin of this software must not be misrepresented; you must not
|
||||||
|
// claim that you wrote the original software. If you use this software
|
||||||
|
// in a product, an acknowledgment in the product documentation would
|
||||||
|
// be appreciated but is not required.
|
||||||
|
//
|
||||||
|
// 2. Altered source versions must be plainly marked as such, and must not
|
||||||
|
// be misrepresented as being the original software.
|
||||||
|
//
|
||||||
|
// 3. This notice may not be removed or altered from any source
|
||||||
|
// distribution.
|
||||||
|
//
|
||||||
|
//========================================================================
|
||||||
|
// It is fine to use C99 in this file because it will not be built with VS
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
|
#include "internal.h"
|
||||||
|
|
||||||
|
#include <dlfcn.h>
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
////// GLFW platform API //////
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void* _glfwPlatformLoadModule(const char* path)
|
||||||
|
{
|
||||||
|
return dlopen(path, RTLD_LAZY | RTLD_LOCAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _glfwPlatformFreeModule(void* module)
|
||||||
|
{
|
||||||
|
dlclose(module);
|
||||||
|
}
|
||||||
|
|
||||||
|
GLFWproc _glfwPlatformGetModuleSymbol(void* module, const char* name)
|
||||||
|
{
|
||||||
|
return dlsym(module, name);
|
||||||
|
}
|
||||||
|
|
81
src/posix_poll.c
Normal file
81
src/posix_poll.c
Normal file
|
@ -0,0 +1,81 @@
|
||||||
|
//========================================================================
|
||||||
|
// GLFW 3.4 POSIX - www.glfw.org
|
||||||
|
//------------------------------------------------------------------------
|
||||||
|
// Copyright (c) 2022 Camilla Löwy <elmindreda@glfw.org>
|
||||||
|
//
|
||||||
|
// This software is provided 'as-is', without any express or implied
|
||||||
|
// warranty. In no event will the authors be held liable for any damages
|
||||||
|
// arising from the use of this software.
|
||||||
|
//
|
||||||
|
// Permission is granted to anyone to use this software for any purpose,
|
||||||
|
// including commercial applications, and to alter it and redistribute it
|
||||||
|
// freely, subject to the following restrictions:
|
||||||
|
//
|
||||||
|
// 1. The origin of this software must not be misrepresented; you must not
|
||||||
|
// claim that you wrote the original software. If you use this software
|
||||||
|
// in a product, an acknowledgment in the product documentation would
|
||||||
|
// be appreciated but is not required.
|
||||||
|
//
|
||||||
|
// 2. Altered source versions must be plainly marked as such, and must not
|
||||||
|
// be misrepresented as being the original software.
|
||||||
|
//
|
||||||
|
// 3. This notice may not be removed or altered from any source
|
||||||
|
// distribution.
|
||||||
|
//
|
||||||
|
//========================================================================
|
||||||
|
// It is fine to use C99 in this file because it will not be built with VS
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
|
#define _GNU_SOURCE
|
||||||
|
|
||||||
|
#include "internal.h"
|
||||||
|
|
||||||
|
#include <signal.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
|
GLFWbool _glfwPollPOSIX(struct pollfd* fds, nfds_t count, double* timeout)
|
||||||
|
{
|
||||||
|
for (;;)
|
||||||
|
{
|
||||||
|
if (timeout)
|
||||||
|
{
|
||||||
|
const uint64_t base = _glfwPlatformGetTimerValue();
|
||||||
|
|
||||||
|
#if defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__CYGWIN__)
|
||||||
|
const time_t seconds = (time_t) *timeout;
|
||||||
|
const long nanoseconds = (long) ((*timeout - seconds) * 1e9);
|
||||||
|
const struct timespec ts = { seconds, nanoseconds };
|
||||||
|
const int result = ppoll(fds, count, &ts, NULL);
|
||||||
|
#elif defined(__NetBSD__)
|
||||||
|
const time_t seconds = (time_t) *timeout;
|
||||||
|
const long nanoseconds = (long) ((*timeout - seconds) * 1e9);
|
||||||
|
const struct timespec ts = { seconds, nanoseconds };
|
||||||
|
const int result = pollts(fds, count, &ts, NULL);
|
||||||
|
#else
|
||||||
|
const int milliseconds = (int) (*timeout * 1e3);
|
||||||
|
const int result = poll(fds, count, milliseconds);
|
||||||
|
#endif
|
||||||
|
const int error = errno; // clock_gettime may overwrite our error
|
||||||
|
|
||||||
|
*timeout -= (_glfwPlatformGetTimerValue() - base) /
|
||||||
|
(double) _glfwPlatformGetTimerFrequency();
|
||||||
|
|
||||||
|
if (result > 0)
|
||||||
|
return GLFW_TRUE;
|
||||||
|
else if (result == -1 && error != EINTR && error != EAGAIN)
|
||||||
|
return GLFW_FALSE;
|
||||||
|
else if (*timeout <= 0.0)
|
||||||
|
return GLFW_FALSE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const int result = poll(fds, count, -1);
|
||||||
|
if (result > 0)
|
||||||
|
return GLFW_TRUE;
|
||||||
|
else if (result == -1 && errno != EINTR && errno != EAGAIN)
|
||||||
|
return GLFW_FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
32
src/posix_poll.h
Normal file
32
src/posix_poll.h
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
//========================================================================
|
||||||
|
// GLFW 3.4 POSIX - www.glfw.org
|
||||||
|
//------------------------------------------------------------------------
|
||||||
|
// Copyright (c) 2022 Camilla Löwy <elmindreda@glfw.org>
|
||||||
|
//
|
||||||
|
// This software is provided 'as-is', without any express or implied
|
||||||
|
// warranty. In no event will the authors be held liable for any damages
|
||||||
|
// arising from the use of this software.
|
||||||
|
//
|
||||||
|
// Permission is granted to anyone to use this software for any purpose,
|
||||||
|
// including commercial applications, and to alter it and redistribute it
|
||||||
|
// freely, subject to the following restrictions:
|
||||||
|
//
|
||||||
|
// 1. The origin of this software must not be misrepresented; you must not
|
||||||
|
// claim that you wrote the original software. If you use this software
|
||||||
|
// in a product, an acknowledgment in the product documentation would
|
||||||
|
// be appreciated but is not required.
|
||||||
|
//
|
||||||
|
// 2. Altered source versions must be plainly marked as such, and must not
|
||||||
|
// be misrepresented as being the original software.
|
||||||
|
//
|
||||||
|
// 3. This notice may not be removed or altered from any source
|
||||||
|
// distribution.
|
||||||
|
//
|
||||||
|
//========================================================================
|
||||||
|
// It is fine to use C99 in this file because it will not be built with VS
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
|
#include <poll.h>
|
||||||
|
|
||||||
|
GLFWbool _glfwPollPOSIX(struct pollfd* fds, nfds_t count, double* timeout);
|
||||||
|
|
|
@ -27,8 +27,8 @@
|
||||||
|
|
||||||
#include <pthread.h>
|
#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;
|
||||||
|
|
||||||
|
|
|
@ -34,12 +34,10 @@
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
////// GLFW internal API //////
|
////// GLFW platform API //////
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// Initialise timer
|
void _glfwPlatformInitTimer(void)
|
||||||
//
|
|
||||||
void _glfwInitTimerPOSIX(void)
|
|
||||||
{
|
{
|
||||||
_glfw.timer.posix.clock = CLOCK_REALTIME;
|
_glfw.timer.posix.clock = CLOCK_REALTIME;
|
||||||
_glfw.timer.posix.frequency = 1000000000;
|
_glfw.timer.posix.frequency = 1000000000;
|
||||||
|
@ -51,11 +49,6 @@ void _glfwInitTimerPOSIX(void)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
////// GLFW platform API //////
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
uint64_t _glfwPlatformGetTimerValue(void)
|
uint64_t _glfwPlatformGetTimerValue(void)
|
||||||
{
|
{
|
||||||
struct timespec ts;
|
struct timespec ts;
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
//
|
//
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
#define _GLFW_PLATFORM_LIBRARY_TIMER_STATE _GLFWtimerPOSIX posix
|
#define GLFW_POSIX_LIBRARY_TIMER_STATE _GLFWtimerPOSIX posix;
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
@ -37,9 +37,5 @@ typedef struct _GLFWtimerPOSIX
|
||||||
{
|
{
|
||||||
clockid_t clock;
|
clockid_t clock;
|
||||||
uint64_t frequency;
|
uint64_t frequency;
|
||||||
|
|
||||||
} _GLFWtimerPOSIX;
|
} _GLFWtimerPOSIX;
|
||||||
|
|
||||||
|
|
||||||
void _glfwInitTimerPOSIX(void);
|
|
||||||
|
|
||||||
|
|
96
src/vulkan.c
96
src/vulkan.c
|
@ -45,45 +45,52 @@ 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__) || defined(__NetBSD__)
|
||||||
|
_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)
|
||||||
{
|
{
|
||||||
if (mode == _GLFW_REQUIRE_LOADER)
|
if (mode == _GLFW_REQUIRE_LOADER)
|
||||||
_glfwInputError(GLFW_API_UNAVAILABLE, "Vulkan: Loader not found");
|
_glfwInputError(GLFW_API_UNAVAILABLE, "Vulkan: Loader not found");
|
||||||
|
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
_glfw.vk.GetInstanceProcAddr = (PFN_vkGetInstanceProcAddr)
|
||||||
|
_glfwPlatformGetModuleSymbol(_glfw.vk.handle, "vkGetInstanceProcAddr");
|
||||||
|
if (!_glfw.vk.GetInstanceProcAddr)
|
||||||
|
{
|
||||||
|
_glfwInputError(GLFW_API_UNAVAILABLE,
|
||||||
|
"Vulkan: Loader does not export vkGetInstanceProcAddr");
|
||||||
|
|
||||||
|
_glfwTerminateVulkan();
|
||||||
|
return GLFW_FALSE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_glfw.vk.GetInstanceProcAddr = (PFN_vkGetInstanceProcAddr)
|
vkEnumerateInstanceExtensionProperties = (PFN_vkEnumerateInstanceExtensionProperties)
|
||||||
_glfw_dlsym(_glfw.vk.handle, "vkGetInstanceProcAddr");
|
|
||||||
if (!_glfw.vk.GetInstanceProcAddr)
|
|
||||||
{
|
|
||||||
_glfwInputError(GLFW_API_UNAVAILABLE,
|
|
||||||
"Vulkan: Loader does not export vkGetInstanceProcAddr");
|
|
||||||
|
|
||||||
_glfwTerminateVulkan();
|
|
||||||
return GLFW_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
_glfw.vk.EnumerateInstanceExtensionProperties = (PFN_vkEnumerateInstanceExtensionProperties)
|
|
||||||
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;
|
||||||
|
|
||||||
|
// NOTE: Vulkan 1.0 and 1.1 vkGetInstanceProcAddr cannot return itself
|
||||||
|
if (strcmp(procname, "vkGetInstanceProcAddr") == 0)
|
||||||
|
return (GLFWvkproc) vkGetInstanceProcAddr;
|
||||||
|
|
||||||
proc = (GLFWvkproc) vkGetInstanceProcAddr(instance, procname);
|
proc = (GLFWvkproc) vkGetInstanceProcAddr(instance, procname);
|
||||||
#if defined(_GLFW_VULKAN_STATIC)
|
|
||||||
if (!proc)
|
if (!proc)
|
||||||
{
|
{
|
||||||
if (strcmp(procname, "vkGetInstanceProcAddr") == 0)
|
if (_glfw.vk.handle)
|
||||||
return (GLFWvkproc) vkGetInstanceProcAddr;
|
proc = (GLFWvkproc) _glfwPlatformGetModuleSymbol(_glfw.vk.handle, procname);
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
if (!proc)
|
|
||||||
proc = (GLFWvkproc) _glfw_dlsym(_glfw.vk.handle, procname);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return proc;
|
return proc;
|
||||||
}
|
}
|
||||||
|
@ -291,9 +289,9 @@ GLFWAPI int glfwGetPhysicalDevicePresentationSupport(VkInstance instance,
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return _glfwPlatformGetPhysicalDevicePresentationSupport(instance,
|
return _glfw.platform.getPhysicalDevicePresentationSupport(instance,
|
||||||
device,
|
device,
|
||||||
queuefamily);
|
queuefamily);
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWAPI VkResult glfwCreateWindowSurface(VkInstance instance,
|
GLFWAPI VkResult glfwCreateWindowSurface(VkInstance instance,
|
||||||
|
@ -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,15 +30,14 @@
|
||||||
#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)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -53,19 +52,19 @@ static int findPixelFormatAttribValue(const int* attribs,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define addAttrib(a) \
|
#define ADD_ATTRIB(a) \
|
||||||
{ \
|
{ \
|
||||||
assert((size_t) attribCount < sizeof(attribs) / sizeof(attribs[0])); \
|
assert((size_t) attribCount < sizeof(attribs) / sizeof(attribs[0])); \
|
||||||
attribs[attribCount++] = a; \
|
attribs[attribCount++] = a; \
|
||||||
}
|
}
|
||||||
#define findAttribValue(a) \
|
#define FIND_ATTRIB_VALUE(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)
|
||||||
{
|
{
|
||||||
_GLFWfbconfig* usableConfigs;
|
_GLFWfbconfig* usableConfigs;
|
||||||
const _GLFWfbconfig* closest;
|
const _GLFWfbconfig* closest;
|
||||||
|
@ -85,41 +84,41 @@ static int choosePixelFormat(_GLFWwindow* window,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
addAttrib(WGL_SUPPORT_OPENGL_ARB);
|
ADD_ATTRIB(WGL_SUPPORT_OPENGL_ARB);
|
||||||
addAttrib(WGL_DRAW_TO_WINDOW_ARB);
|
ADD_ATTRIB(WGL_DRAW_TO_WINDOW_ARB);
|
||||||
addAttrib(WGL_PIXEL_TYPE_ARB);
|
ADD_ATTRIB(WGL_PIXEL_TYPE_ARB);
|
||||||
addAttrib(WGL_ACCELERATION_ARB);
|
ADD_ATTRIB(WGL_ACCELERATION_ARB);
|
||||||
addAttrib(WGL_RED_BITS_ARB);
|
ADD_ATTRIB(WGL_RED_BITS_ARB);
|
||||||
addAttrib(WGL_RED_SHIFT_ARB);
|
ADD_ATTRIB(WGL_RED_SHIFT_ARB);
|
||||||
addAttrib(WGL_GREEN_BITS_ARB);
|
ADD_ATTRIB(WGL_GREEN_BITS_ARB);
|
||||||
addAttrib(WGL_GREEN_SHIFT_ARB);
|
ADD_ATTRIB(WGL_GREEN_SHIFT_ARB);
|
||||||
addAttrib(WGL_BLUE_BITS_ARB);
|
ADD_ATTRIB(WGL_BLUE_BITS_ARB);
|
||||||
addAttrib(WGL_BLUE_SHIFT_ARB);
|
ADD_ATTRIB(WGL_BLUE_SHIFT_ARB);
|
||||||
addAttrib(WGL_ALPHA_BITS_ARB);
|
ADD_ATTRIB(WGL_ALPHA_BITS_ARB);
|
||||||
addAttrib(WGL_ALPHA_SHIFT_ARB);
|
ADD_ATTRIB(WGL_ALPHA_SHIFT_ARB);
|
||||||
addAttrib(WGL_DEPTH_BITS_ARB);
|
ADD_ATTRIB(WGL_DEPTH_BITS_ARB);
|
||||||
addAttrib(WGL_STENCIL_BITS_ARB);
|
ADD_ATTRIB(WGL_STENCIL_BITS_ARB);
|
||||||
addAttrib(WGL_ACCUM_BITS_ARB);
|
ADD_ATTRIB(WGL_ACCUM_BITS_ARB);
|
||||||
addAttrib(WGL_ACCUM_RED_BITS_ARB);
|
ADD_ATTRIB(WGL_ACCUM_RED_BITS_ARB);
|
||||||
addAttrib(WGL_ACCUM_GREEN_BITS_ARB);
|
ADD_ATTRIB(WGL_ACCUM_GREEN_BITS_ARB);
|
||||||
addAttrib(WGL_ACCUM_BLUE_BITS_ARB);
|
ADD_ATTRIB(WGL_ACCUM_BLUE_BITS_ARB);
|
||||||
addAttrib(WGL_ACCUM_ALPHA_BITS_ARB);
|
ADD_ATTRIB(WGL_ACCUM_ALPHA_BITS_ARB);
|
||||||
addAttrib(WGL_AUX_BUFFERS_ARB);
|
ADD_ATTRIB(WGL_AUX_BUFFERS_ARB);
|
||||||
addAttrib(WGL_STEREO_ARB);
|
ADD_ATTRIB(WGL_STEREO_ARB);
|
||||||
addAttrib(WGL_DOUBLE_BUFFER_ARB);
|
ADD_ATTRIB(WGL_DOUBLE_BUFFER_ARB);
|
||||||
|
|
||||||
if (_glfw.wgl.ARB_multisample)
|
if (_glfw.wgl.ARB_multisample)
|
||||||
addAttrib(WGL_SAMPLES_ARB);
|
ADD_ATTRIB(WGL_SAMPLES_ARB);
|
||||||
|
|
||||||
if (ctxconfig->client == GLFW_OPENGL_API)
|
if (ctxconfig->client == GLFW_OPENGL_API)
|
||||||
{
|
{
|
||||||
if (_glfw.wgl.ARB_framebuffer_sRGB || _glfw.wgl.EXT_framebuffer_sRGB)
|
if (_glfw.wgl.ARB_framebuffer_sRGB || _glfw.wgl.EXT_framebuffer_sRGB)
|
||||||
addAttrib(WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB);
|
ADD_ATTRIB(WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (_glfw.wgl.EXT_colorspace)
|
if (_glfw.wgl.EXT_colorspace)
|
||||||
addAttrib(WGL_COLORSPACE_EXT);
|
ADD_ATTRIB(WGL_COLORSPACE_EXT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -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,52 +148,52 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!findAttribValue(WGL_SUPPORT_OPENGL_ARB) ||
|
if (!FIND_ATTRIB_VALUE(WGL_SUPPORT_OPENGL_ARB) ||
|
||||||
!findAttribValue(WGL_DRAW_TO_WINDOW_ARB))
|
!FIND_ATTRIB_VALUE(WGL_DRAW_TO_WINDOW_ARB))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (findAttribValue(WGL_PIXEL_TYPE_ARB) != WGL_TYPE_RGBA_ARB)
|
if (FIND_ATTRIB_VALUE(WGL_PIXEL_TYPE_ARB) != WGL_TYPE_RGBA_ARB)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (findAttribValue(WGL_ACCELERATION_ARB) == WGL_NO_ACCELERATION_ARB)
|
if (FIND_ATTRIB_VALUE(WGL_ACCELERATION_ARB) == WGL_NO_ACCELERATION_ARB)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (findAttribValue(WGL_DOUBLE_BUFFER_ARB) != fbconfig->doublebuffer)
|
if (FIND_ATTRIB_VALUE(WGL_DOUBLE_BUFFER_ARB) != fbconfig->doublebuffer)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
u->redBits = findAttribValue(WGL_RED_BITS_ARB);
|
u->redBits = FIND_ATTRIB_VALUE(WGL_RED_BITS_ARB);
|
||||||
u->greenBits = findAttribValue(WGL_GREEN_BITS_ARB);
|
u->greenBits = FIND_ATTRIB_VALUE(WGL_GREEN_BITS_ARB);
|
||||||
u->blueBits = findAttribValue(WGL_BLUE_BITS_ARB);
|
u->blueBits = FIND_ATTRIB_VALUE(WGL_BLUE_BITS_ARB);
|
||||||
u->alphaBits = findAttribValue(WGL_ALPHA_BITS_ARB);
|
u->alphaBits = FIND_ATTRIB_VALUE(WGL_ALPHA_BITS_ARB);
|
||||||
|
|
||||||
u->depthBits = findAttribValue(WGL_DEPTH_BITS_ARB);
|
u->depthBits = FIND_ATTRIB_VALUE(WGL_DEPTH_BITS_ARB);
|
||||||
u->stencilBits = findAttribValue(WGL_STENCIL_BITS_ARB);
|
u->stencilBits = FIND_ATTRIB_VALUE(WGL_STENCIL_BITS_ARB);
|
||||||
|
|
||||||
u->accumRedBits = findAttribValue(WGL_ACCUM_RED_BITS_ARB);
|
u->accumRedBits = FIND_ATTRIB_VALUE(WGL_ACCUM_RED_BITS_ARB);
|
||||||
u->accumGreenBits = findAttribValue(WGL_ACCUM_GREEN_BITS_ARB);
|
u->accumGreenBits = FIND_ATTRIB_VALUE(WGL_ACCUM_GREEN_BITS_ARB);
|
||||||
u->accumBlueBits = findAttribValue(WGL_ACCUM_BLUE_BITS_ARB);
|
u->accumBlueBits = FIND_ATTRIB_VALUE(WGL_ACCUM_BLUE_BITS_ARB);
|
||||||
u->accumAlphaBits = findAttribValue(WGL_ACCUM_ALPHA_BITS_ARB);
|
u->accumAlphaBits = FIND_ATTRIB_VALUE(WGL_ACCUM_ALPHA_BITS_ARB);
|
||||||
|
|
||||||
u->auxBuffers = findAttribValue(WGL_AUX_BUFFERS_ARB);
|
u->auxBuffers = FIND_ATTRIB_VALUE(WGL_AUX_BUFFERS_ARB);
|
||||||
|
|
||||||
if (findAttribValue(WGL_STEREO_ARB))
|
if (FIND_ATTRIB_VALUE(WGL_STEREO_ARB))
|
||||||
u->stereo = GLFW_TRUE;
|
u->stereo = GLFW_TRUE;
|
||||||
|
|
||||||
if (_glfw.wgl.ARB_multisample)
|
if (_glfw.wgl.ARB_multisample)
|
||||||
u->samples = findAttribValue(WGL_SAMPLES_ARB);
|
u->samples = FIND_ATTRIB_VALUE(WGL_SAMPLES_ARB);
|
||||||
|
|
||||||
if (ctxconfig->client == GLFW_OPENGL_API)
|
if (ctxconfig->client == GLFW_OPENGL_API)
|
||||||
{
|
{
|
||||||
if (_glfw.wgl.ARB_framebuffer_sRGB ||
|
if (_glfw.wgl.ARB_framebuffer_sRGB ||
|
||||||
_glfw.wgl.EXT_framebuffer_sRGB)
|
_glfw.wgl.EXT_framebuffer_sRGB)
|
||||||
{
|
{
|
||||||
if (findAttribValue(WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB))
|
if (FIND_ATTRIB_VALUE(WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB))
|
||||||
u->sRGB = GLFW_TRUE;
|
u->sRGB = GLFW_TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -202,7 +201,7 @@ static int choosePixelFormat(_GLFWwindow* window,
|
||||||
{
|
{
|
||||||
if (_glfw.wgl.EXT_colorspace)
|
if (_glfw.wgl.EXT_colorspace)
|
||||||
{
|
{
|
||||||
if (findAttribValue(WGL_COLORSPACE_EXT) == WGL_COLORSPACE_SRGB_EXT)
|
if (FIND_ATTRIB_VALUE(WGL_COLORSPACE_EXT) == WGL_COLORSPACE_SRGB_EXT)
|
||||||
u->sRGB = GLFW_TRUE;
|
u->sRGB = GLFW_TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -221,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -271,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -281,18 +280,18 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef addAttrib
|
#undef ADD_ATTRIB
|
||||||
#undef findAttribValue
|
#undef FIND_ATTRIB_VALUE
|
||||||
|
|
||||||
static void makeContextCurrentWGL(_GLFWwindow* window)
|
static void makeContextCurrentWGL(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
|
@ -323,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--)
|
||||||
|
@ -350,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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -388,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)
|
||||||
|
@ -400,11 +395,6 @@ static void destroyContextWGL(_GLFWwindow* window)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
////// GLFW internal API //////
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
// Initialize WGL
|
// Initialize WGL
|
||||||
//
|
//
|
||||||
GLFWbool _glfwInitWGL(void)
|
GLFWbool _glfwInitWGL(void)
|
||||||
|
@ -416,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,
|
||||||
|
@ -425,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
|
||||||
|
@ -530,10 +520,10 @@ 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 SET_ATTRIB(a, v) \
|
||||||
{ \
|
{ \
|
||||||
assert(((size_t) index + 1) < sizeof(attribs) / sizeof(attribs[0])); \
|
assert(((size_t) index + 1) < sizeof(attribs) / sizeof(attribs[0])); \
|
||||||
attribs[index++] = a; \
|
attribs[index++] = a; \
|
||||||
|
@ -562,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;
|
||||||
|
|
||||||
|
@ -641,13 +631,13 @@ GLFWbool _glfwCreateContextWGL(_GLFWwindow* window,
|
||||||
{
|
{
|
||||||
if (ctxconfig->robustness == GLFW_NO_RESET_NOTIFICATION)
|
if (ctxconfig->robustness == GLFW_NO_RESET_NOTIFICATION)
|
||||||
{
|
{
|
||||||
setAttrib(WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB,
|
SET_ATTRIB(WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB,
|
||||||
WGL_NO_RESET_NOTIFICATION_ARB);
|
WGL_NO_RESET_NOTIFICATION_ARB);
|
||||||
}
|
}
|
||||||
else if (ctxconfig->robustness == GLFW_LOSE_CONTEXT_ON_RESET)
|
else if (ctxconfig->robustness == GLFW_LOSE_CONTEXT_ON_RESET)
|
||||||
{
|
{
|
||||||
setAttrib(WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB,
|
SET_ATTRIB(WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB,
|
||||||
WGL_LOSE_CONTEXT_ON_RESET_ARB);
|
WGL_LOSE_CONTEXT_ON_RESET_ARB);
|
||||||
}
|
}
|
||||||
|
|
||||||
flags |= WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB;
|
flags |= WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB;
|
||||||
|
@ -660,13 +650,13 @@ GLFWbool _glfwCreateContextWGL(_GLFWwindow* window,
|
||||||
{
|
{
|
||||||
if (ctxconfig->release == GLFW_RELEASE_BEHAVIOR_NONE)
|
if (ctxconfig->release == GLFW_RELEASE_BEHAVIOR_NONE)
|
||||||
{
|
{
|
||||||
setAttrib(WGL_CONTEXT_RELEASE_BEHAVIOR_ARB,
|
SET_ATTRIB(WGL_CONTEXT_RELEASE_BEHAVIOR_ARB,
|
||||||
WGL_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB);
|
WGL_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB);
|
||||||
}
|
}
|
||||||
else if (ctxconfig->release == GLFW_RELEASE_BEHAVIOR_FLUSH)
|
else if (ctxconfig->release == GLFW_RELEASE_BEHAVIOR_FLUSH)
|
||||||
{
|
{
|
||||||
setAttrib(WGL_CONTEXT_RELEASE_BEHAVIOR_ARB,
|
SET_ATTRIB(WGL_CONTEXT_RELEASE_BEHAVIOR_ARB,
|
||||||
WGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB);
|
WGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -674,7 +664,7 @@ GLFWbool _glfwCreateContextWGL(_GLFWwindow* window,
|
||||||
if (ctxconfig->noerror)
|
if (ctxconfig->noerror)
|
||||||
{
|
{
|
||||||
if (_glfw.wgl.ARB_create_context_no_error)
|
if (_glfw.wgl.ARB_create_context_no_error)
|
||||||
setAttrib(WGL_CONTEXT_OPENGL_NO_ERROR_ARB, GLFW_TRUE);
|
SET_ATTRIB(WGL_CONTEXT_OPENGL_NO_ERROR_ARB, GLFW_TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: Only request an explicitly versioned context when necessary, as
|
// NOTE: Only request an explicitly versioned context when necessary, as
|
||||||
|
@ -682,17 +672,17 @@ GLFWbool _glfwCreateContextWGL(_GLFWwindow* window,
|
||||||
// highest version supported by the driver
|
// highest version supported by the driver
|
||||||
if (ctxconfig->major != 1 || ctxconfig->minor != 0)
|
if (ctxconfig->major != 1 || ctxconfig->minor != 0)
|
||||||
{
|
{
|
||||||
setAttrib(WGL_CONTEXT_MAJOR_VERSION_ARB, ctxconfig->major);
|
SET_ATTRIB(WGL_CONTEXT_MAJOR_VERSION_ARB, ctxconfig->major);
|
||||||
setAttrib(WGL_CONTEXT_MINOR_VERSION_ARB, ctxconfig->minor);
|
SET_ATTRIB(WGL_CONTEXT_MINOR_VERSION_ARB, ctxconfig->minor);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags)
|
if (flags)
|
||||||
setAttrib(WGL_CONTEXT_FLAGS_ARB, flags);
|
SET_ATTRIB(WGL_CONTEXT_FLAGS_ARB, flags);
|
||||||
|
|
||||||
if (mask)
|
if (mask)
|
||||||
setAttrib(WGL_CONTEXT_PROFILE_MASK_ARB, mask);
|
SET_ATTRIB(WGL_CONTEXT_PROFILE_MASK_ARB, mask);
|
||||||
|
|
||||||
setAttrib(0, 0);
|
SET_ATTRIB(0, 0);
|
||||||
|
|
||||||
window->context.wgl.handle =
|
window->context.wgl.handle =
|
||||||
wglCreateContextAttribsARB(window->context.wgl.dc, share, attribs);
|
wglCreateContextAttribsARB(window->context.wgl.dc, share, attribs);
|
||||||
|
@ -775,19 +765,21 @@ GLFWbool _glfwCreateContextWGL(_GLFWwindow* window,
|
||||||
return GLFW_TRUE;
|
return GLFW_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef setAttrib
|
#undef SET_ATTRIB
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
////// 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);
|
|
||||||
|
|
208
src/win32_init.c
208
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}};
|
||||||
|
@ -40,7 +39,7 @@ 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)
|
#if defined(_GLFW_BUILD_DLL)
|
||||||
#warning "These symbols must be exported by the executable and have no effect in a DLL"
|
#pragma message("These symbols must be exported by the executable and have no effect in a DLL")
|
||||||
#endif
|
#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
|
||||||
|
@ -72,18 +71,17 @@ BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID reserved)
|
||||||
//
|
//
|
||||||
static GLFWbool loadLibraries(void)
|
static GLFWbool loadLibraries(void)
|
||||||
{
|
{
|
||||||
_glfw.win32.winmm.instance = LoadLibraryA("winmm.dll");
|
if (!GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS |
|
||||||
if (!_glfw.win32.winmm.instance)
|
GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
|
||||||
|
(const WCHAR*) &_glfw,
|
||||||
|
(HMODULE*) &_glfw.win32.instance))
|
||||||
{
|
{
|
||||||
_glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
|
_glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
|
||||||
"Win32: Failed to load winmm.dll");
|
"Win32: Failed to retrieve own module handle");
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
_glfw.win32.winmm.GetTime = (PFN_timeGetTime)
|
_glfw.win32.user32.instance = _glfwPlatformLoadModule("user32.dll");
|
||||||
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,
|
||||||
|
@ -92,23 +90,25 @@ 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.user32.GetSystemMetricsForDpi_ = (PFN_GetSystemMetricsForDpi)
|
||||||
|
_glfwPlatformGetModuleSymbol(_glfw.win32.user32.instance, "GetSystemMetricsForDpi");
|
||||||
|
|
||||||
_glfw.win32.dinput8.instance = LoadLibraryA("dinput8.dll");
|
_glfw.win32.dinput8.instance = _glfwPlatformLoadModule("dinput8.dll");
|
||||||
if (_glfw.win32.dinput8.instance)
|
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");
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -125,46 +125,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)
|
_glfw.win32.dwmapi.GetColorizationColor = (PFN_DwmGetColorizationColor)
|
||||||
GetProcAddress(_glfw.win32.dwmapi.instance, "DwmGetColorizationColor");
|
_glfwPlatformGetModuleSymbol(_glfw.win32.dwmapi.instance, "DwmGetColorizationColor");
|
||||||
}
|
}
|
||||||
|
|
||||||
_glfw.win32.shcore.instance = LoadLibraryA("shcore.dll");
|
_glfw.win32.shcore.instance = _glfwPlatformLoadModule("shcore.dll");
|
||||||
if (_glfw.win32.shcore.instance)
|
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;
|
||||||
|
@ -175,25 +175,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
|
||||||
|
@ -266,7 +263,6 @@ static void createKeyTables(void)
|
||||||
_glfw.win32.keycodes[0x151] = GLFW_KEY_PAGE_DOWN;
|
_glfw.win32.keycodes[0x151] = GLFW_KEY_PAGE_DOWN;
|
||||||
_glfw.win32.keycodes[0x149] = GLFW_KEY_PAGE_UP;
|
_glfw.win32.keycodes[0x149] = GLFW_KEY_PAGE_UP;
|
||||||
_glfw.win32.keycodes[0x045] = GLFW_KEY_PAUSE;
|
_glfw.win32.keycodes[0x045] = GLFW_KEY_PAUSE;
|
||||||
_glfw.win32.keycodes[0x146] = GLFW_KEY_PAUSE;
|
|
||||||
_glfw.win32.keycodes[0x039] = GLFW_KEY_SPACE;
|
_glfw.win32.keycodes[0x039] = GLFW_KEY_SPACE;
|
||||||
_glfw.win32.keycodes[0x00F] = GLFW_KEY_TAB;
|
_glfw.win32.keycodes[0x00F] = GLFW_KEY_TAB;
|
||||||
_glfw.win32.keycodes[0x03A] = GLFW_KEY_CAPS_LOCK;
|
_glfw.win32.keycodes[0x03A] = GLFW_KEY_CAPS_LOCK;
|
||||||
|
@ -348,7 +344,7 @@ static GLFWbool createHelperWindow(void)
|
||||||
WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
|
WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
|
||||||
0, 0, 1, 1,
|
0, 0, 1, 1,
|
||||||
NULL, NULL,
|
NULL, NULL,
|
||||||
GetModuleHandleW(NULL),
|
_glfw.win32.instance,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
if (!_glfw.win32.helperWindowHandle)
|
if (!_glfw.win32.helperWindowHandle)
|
||||||
|
@ -405,13 +401,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -433,13 +429,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -498,7 +494,7 @@ void _glfwUpdateKeyNamesWin32(void)
|
||||||
vk = vks[key - GLFW_KEY_KP_0];
|
vk = vks[key - GLFW_KEY_KP_0];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
vk = MapVirtualKey(scancode, MAPVK_VSC_TO_VK);
|
vk = MapVirtualKeyW(scancode, MAPVK_VSC_TO_VK);
|
||||||
|
|
||||||
length = ToUnicode(vk, scancode, state,
|
length = ToUnicode(vk, scancode, state,
|
||||||
chars, sizeof(chars) / sizeof(WCHAR),
|
chars, sizeof(chars) / sizeof(WCHAR),
|
||||||
|
@ -506,6 +502,8 @@ void _glfwUpdateKeyNamesWin32(void)
|
||||||
|
|
||||||
if (length == -1)
|
if (length == -1)
|
||||||
{
|
{
|
||||||
|
// This is a dead key, so we need a second simulated key press
|
||||||
|
// to make it output its own character (usually a diacritic)
|
||||||
length = ToUnicode(vk, scancode, state,
|
length = ToUnicode(vk, scancode, state,
|
||||||
chars, sizeof(chars) / sizeof(WCHAR),
|
chars, sizeof(chars) / sizeof(WCHAR),
|
||||||
0);
|
0);
|
||||||
|
@ -521,7 +519,8 @@ void _glfwUpdateKeyNamesWin32(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Replacement for IsWindowsVersionOrGreater as MinGW lacks versionhelpers.h
|
// Replacement for IsWindowsVersionOrGreater, as we cannot rely on the
|
||||||
|
// application having a correct embedded manifest
|
||||||
//
|
//
|
||||||
BOOL _glfwIsWindowsVersionOrGreaterWin32(WORD major, WORD minor, WORD sp)
|
BOOL _glfwIsWindowsVersionOrGreaterWin32(WORD major, WORD minor, WORD sp)
|
||||||
{
|
{
|
||||||
|
@ -551,12 +550,89 @@ BOOL _glfwIsWindows10BuildOrGreaterWin32(WORD build)
|
||||||
return RtlVerifyVersionInfo(&osvi, mask, cond) == 0;
|
return RtlVerifyVersionInfo(&osvi, mask, cond) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GLFWbool _glfwConnectWin32(int platformID, _GLFWplatform* platform)
|
||||||
|
{
|
||||||
|
const _GLFWplatform win32 =
|
||||||
|
{
|
||||||
|
GLFW_PLATFORM_WIN32,
|
||||||
|
_glfwInitWin32,
|
||||||
|
_glfwTerminateWin32,
|
||||||
|
_glfwGetCursorPosWin32,
|
||||||
|
_glfwSetCursorPosWin32,
|
||||||
|
_glfwSetCursorModeWin32,
|
||||||
|
_glfwSetRawMouseMotionWin32,
|
||||||
|
_glfwRawMouseMotionSupportedWin32,
|
||||||
|
_glfwCreateCursorWin32,
|
||||||
|
_glfwCreateStandardCursorWin32,
|
||||||
|
_glfwDestroyCursorWin32,
|
||||||
|
_glfwSetCursorWin32,
|
||||||
|
_glfwGetScancodeNameWin32,
|
||||||
|
_glfwGetKeyScancodeWin32,
|
||||||
|
_glfwSetClipboardStringWin32,
|
||||||
|
_glfwGetClipboardStringWin32,
|
||||||
|
_glfwInitJoysticksWin32,
|
||||||
|
_glfwTerminateJoysticksWin32,
|
||||||
|
_glfwPollJoystickWin32,
|
||||||
|
_glfwGetMappingNameWin32,
|
||||||
|
_glfwUpdateGamepadGUIDWin32,
|
||||||
|
_glfwFreeMonitorWin32,
|
||||||
|
_glfwGetMonitorPosWin32,
|
||||||
|
_glfwGetMonitorContentScaleWin32,
|
||||||
|
_glfwGetMonitorWorkareaWin32,
|
||||||
|
_glfwGetVideoModesWin32,
|
||||||
|
_glfwGetVideoModeWin32,
|
||||||
|
_glfwGetGammaRampWin32,
|
||||||
|
_glfwSetGammaRampWin32,
|
||||||
|
_glfwCreateWindowWin32,
|
||||||
|
_glfwDestroyWindowWin32,
|
||||||
|
_glfwSetWindowTitleWin32,
|
||||||
|
_glfwSetWindowIconWin32,
|
||||||
|
_glfwGetWindowPosWin32,
|
||||||
|
_glfwSetWindowPosWin32,
|
||||||
|
_glfwGetWindowSizeWin32,
|
||||||
|
_glfwSetWindowSizeWin32,
|
||||||
|
_glfwSetWindowSizeLimitsWin32,
|
||||||
|
_glfwSetWindowAspectRatioWin32,
|
||||||
|
_glfwGetFramebufferSizeWin32,
|
||||||
|
_glfwGetWindowFrameSizeWin32,
|
||||||
|
_glfwGetWindowContentScaleWin32,
|
||||||
|
_glfwIconifyWindowWin32,
|
||||||
|
_glfwRestoreWindowWin32,
|
||||||
|
_glfwMaximizeWindowWin32,
|
||||||
|
_glfwShowWindowWin32,
|
||||||
|
_glfwHideWindowWin32,
|
||||||
|
_glfwRequestWindowAttentionWin32,
|
||||||
|
_glfwFocusWindowWin32,
|
||||||
|
_glfwSetWindowMonitorWin32,
|
||||||
|
_glfwWindowFocusedWin32,
|
||||||
|
_glfwWindowIconifiedWin32,
|
||||||
|
_glfwWindowVisibleWin32,
|
||||||
|
_glfwWindowMaximizedWin32,
|
||||||
|
_glfwWindowHoveredWin32,
|
||||||
|
_glfwFramebufferTransparentWin32,
|
||||||
|
_glfwGetWindowOpacityWin32,
|
||||||
|
_glfwSetWindowResizableWin32,
|
||||||
|
_glfwSetWindowDecoratedWin32,
|
||||||
|
_glfwSetWindowFloatingWin32,
|
||||||
|
_glfwSetWindowOpacityWin32,
|
||||||
|
_glfwSetWindowMousePassthroughWin32,
|
||||||
|
_glfwPollEventsWin32,
|
||||||
|
_glfwWaitEventsWin32,
|
||||||
|
_glfwWaitEventsTimeoutWin32,
|
||||||
|
_glfwPostEmptyEventWin32,
|
||||||
|
_glfwGetEGLPlatformWin32,
|
||||||
|
_glfwGetEGLNativeDisplayWin32,
|
||||||
|
_glfwGetEGLNativeWindowWin32,
|
||||||
|
_glfwGetRequiredInstanceExtensionsWin32,
|
||||||
|
_glfwGetPhysicalDevicePresentationSupportWin32,
|
||||||
|
_glfwCreateWindowSurfaceWin32,
|
||||||
|
};
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
*platform = win32;
|
||||||
////// GLFW platform API //////
|
return GLFW_TRUE;
|
||||||
//////////////////////////////////////////////////////////////////////////
|
}
|
||||||
|
|
||||||
int _glfwPlatformInit(void)
|
int _glfwInitWin32(void)
|
||||||
{
|
{
|
||||||
if (!loadLibraries())
|
if (!loadLibraries())
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
|
@ -564,7 +640,7 @@ int _glfwPlatformInit(void)
|
||||||
createKeyTables();
|
createKeyTables();
|
||||||
_glfwUpdateKeyNamesWin32();
|
_glfwUpdateKeyNamesWin32();
|
||||||
|
|
||||||
if (_glfwIsWindows10CreatorsUpdateOrGreaterWin32())
|
if (_glfwIsWindows10Version1703OrGreaterWin32())
|
||||||
SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2);
|
SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2);
|
||||||
else if (IsWindows8Point1OrGreater())
|
else if (IsWindows8Point1OrGreater())
|
||||||
SetProcessDpiAwareness(PROCESS_PER_MONITOR_DPI_AWARE);
|
SetProcessDpiAwareness(PROCESS_PER_MONITOR_DPI_AWARE);
|
||||||
|
@ -577,13 +653,11 @@ int _glfwPlatformInit(void)
|
||||||
if (!createHelperWindow())
|
if (!createHelperWindow())
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
|
|
||||||
_glfwInitTimerWin32();
|
|
||||||
|
|
||||||
_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);
|
||||||
|
@ -593,31 +667,13 @@ void _glfwPlatformTerminate(void)
|
||||||
|
|
||||||
_glfwUnregisterWindowClassWin32();
|
_glfwUnregisterWindowClassWin32();
|
||||||
|
|
||||||
free(_glfw.win32.clipboardString);
|
_glfw_free(_glfw.win32.clipboardString);
|
||||||
free(_glfw.win32.rawInput);
|
_glfw_free(_glfw.win32.rawInput);
|
||||||
|
|
||||||
_glfwTerminateWGL();
|
_glfwTerminateWGL();
|
||||||
_glfwTerminateEGL();
|
_glfwTerminateEGL();
|
||||||
|
_glfwTerminateOSMesa();
|
||||||
|
|
||||||
freeLibraries();
|
freeLibraries();
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* _glfwPlatformGetVersionString(void)
|
|
||||||
{
|
|
||||||
return _GLFW_VERSION_NUMBER " Win32 WGL EGL OSMesa"
|
|
||||||
#if defined(__MINGW64_VERSION_MAJOR)
|
|
||||||
" MinGW-w64"
|
|
||||||
#elif defined(__MINGW32__)
|
|
||||||
" MinGW"
|
|
||||||
#elif defined(_MSC_VER)
|
|
||||||
" VisualC"
|
|
||||||
#endif
|
|
||||||
#if defined(_GLFW_USE_HYBRID_HPG) || defined(_GLFW_USE_OPTIMUS_HPG)
|
|
||||||
" hybrid-GPU"
|
|
||||||
#endif
|
|
||||||
#if defined(_GLFW_BUILD_DLL)
|
|
||||||
" DLL"
|
|
||||||
#endif
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -199,11 +199,11 @@ static GLFWbool supportsXInput(const GUID* guid)
|
||||||
if (GetRawInputDeviceList(NULL, &count, sizeof(RAWINPUTDEVICELIST)) != 0)
|
if (GetRawInputDeviceList(NULL, &count, sizeof(RAWINPUTDEVICELIST)) != 0)
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
|
|
||||||
ridl = calloc(count, sizeof(RAWINPUTDEVICELIST));
|
ridl = _glfw_calloc(count, sizeof(RAWINPUTDEVICELIST));
|
||||||
|
|
||||||
if (GetRawInputDeviceList(ridl, &count, sizeof(RAWINPUTDEVICELIST)) == (UINT) -1)
|
if (GetRawInputDeviceList(ridl, &count, sizeof(RAWINPUTDEVICELIST)) == (UINT) -1)
|
||||||
{
|
{
|
||||||
free(ridl);
|
_glfw_free(ridl);
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -248,7 +248,7 @@ static GLFWbool supportsXInput(const GUID* guid)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
free(ridl);
|
_glfw_free(ridl);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -262,7 +262,7 @@ static void closeJoystick(_GLFWjoystick* js)
|
||||||
IDirectInputDevice8_Release(js->win32.device);
|
IDirectInputDevice8_Release(js->win32.device);
|
||||||
}
|
}
|
||||||
|
|
||||||
free(js->win32.objects);
|
_glfw_free(js->win32.objects);
|
||||||
|
|
||||||
_glfwFreeJoystick(js);
|
_glfwFreeJoystick(js);
|
||||||
_glfwInputJoystick(js, GLFW_DISCONNECTED);
|
_glfwInputJoystick(js, GLFW_DISCONNECTED);
|
||||||
|
@ -416,8 +416,8 @@ static BOOL CALLBACK deviceCallback(const DIDEVICEINSTANCE* di, void* user)
|
||||||
|
|
||||||
memset(&data, 0, sizeof(data));
|
memset(&data, 0, sizeof(data));
|
||||||
data.device = device;
|
data.device = device;
|
||||||
data.objects = calloc(dc.dwAxes + (size_t) dc.dwButtons + dc.dwPOVs,
|
data.objects = _glfw_calloc(dc.dwAxes + (size_t) dc.dwButtons + dc.dwPOVs,
|
||||||
sizeof(_GLFWjoyobjectWin32));
|
sizeof(_GLFWjoyobjectWin32));
|
||||||
|
|
||||||
if (FAILED(IDirectInputDevice8_EnumObjects(device,
|
if (FAILED(IDirectInputDevice8_EnumObjects(device,
|
||||||
deviceObjectCallback,
|
deviceObjectCallback,
|
||||||
|
@ -428,7 +428,7 @@ static BOOL CALLBACK deviceCallback(const DIDEVICEINSTANCE* di, void* user)
|
||||||
"Win32: Failed to enumerate device objects");
|
"Win32: Failed to enumerate device objects");
|
||||||
|
|
||||||
IDirectInputDevice8_Release(device);
|
IDirectInputDevice8_Release(device);
|
||||||
free(data.objects);
|
_glfw_free(data.objects);
|
||||||
return DIENUM_CONTINUE;
|
return DIENUM_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -445,7 +445,7 @@ static BOOL CALLBACK deviceCallback(const DIDEVICEINSTANCE* di, void* user)
|
||||||
"Win32: Failed to convert joystick name to UTF-8");
|
"Win32: Failed to convert joystick name to UTF-8");
|
||||||
|
|
||||||
IDirectInputDevice8_Release(device);
|
IDirectInputDevice8_Release(device);
|
||||||
free(data.objects);
|
_glfw_free(data.objects);
|
||||||
return DIENUM_STOP;
|
return DIENUM_STOP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -473,7 +473,7 @@ static BOOL CALLBACK deviceCallback(const DIDEVICEINSTANCE* di, void* user)
|
||||||
if (!js)
|
if (!js)
|
||||||
{
|
{
|
||||||
IDirectInputDevice8_Release(device);
|
IDirectInputDevice8_Release(device);
|
||||||
free(data.objects);
|
_glfw_free(data.objects);
|
||||||
return DIENUM_STOP;
|
return DIENUM_STOP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -561,7 +561,7 @@ void _glfwDetectJoystickDisconnectionWin32(void)
|
||||||
{
|
{
|
||||||
_GLFWjoystick* js = _glfw.joysticks + jid;
|
_GLFWjoystick* js = _glfw.joysticks + jid;
|
||||||
if (js->present)
|
if (js->present)
|
||||||
_glfwPlatformPollJoystick(js, _GLFW_POLL_PRESENCE);
|
_glfwPollJoystickWin32(js, _GLFW_POLL_PRESENCE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -570,11 +570,11 @@ void _glfwDetectJoystickDisconnectionWin32(void)
|
||||||
////// GLFW platform API //////
|
////// GLFW platform API //////
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
GLFWbool _glfwPlatformInitJoysticks(void)
|
GLFWbool _glfwInitJoysticksWin32(void)
|
||||||
{
|
{
|
||||||
if (_glfw.win32.dinput8.instance)
|
if (_glfw.win32.dinput8.instance)
|
||||||
{
|
{
|
||||||
if (FAILED(DirectInput8Create(GetModuleHandle(NULL),
|
if (FAILED(DirectInput8Create(_glfw.win32.instance,
|
||||||
DIRECTINPUT_VERSION,
|
DIRECTINPUT_VERSION,
|
||||||
&IID_IDirectInput8W,
|
&IID_IDirectInput8W,
|
||||||
(void**) &_glfw.win32.dinput8.api,
|
(void**) &_glfw.win32.dinput8.api,
|
||||||
|
@ -590,7 +590,7 @@ GLFWbool _glfwPlatformInitJoysticks(void)
|
||||||
return GLFW_TRUE;
|
return GLFW_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformTerminateJoysticks(void)
|
void _glfwTerminateJoysticksWin32(void)
|
||||||
{
|
{
|
||||||
int jid;
|
int jid;
|
||||||
|
|
||||||
|
@ -601,13 +601,13 @@ void _glfwPlatformTerminateJoysticks(void)
|
||||||
IDirectInput8_Release(_glfw.win32.dinput8.api);
|
IDirectInput8_Release(_glfw.win32.dinput8.api);
|
||||||
}
|
}
|
||||||
|
|
||||||
int _glfwPlatformPollJoystick(_GLFWjoystick* js, int mode)
|
int _glfwPollJoystickWin32(_GLFWjoystick* js, int mode)
|
||||||
{
|
{
|
||||||
if (js->win32.device)
|
if (js->win32.device)
|
||||||
{
|
{
|
||||||
int i, ai = 0, bi = 0, pi = 0;
|
int i, ai = 0, bi = 0, pi = 0;
|
||||||
HRESULT result;
|
HRESULT result;
|
||||||
DIJOYSTATE state;
|
DIJOYSTATE state = {0};
|
||||||
|
|
||||||
IDirectInputDevice8_Poll(js->win32.device);
|
IDirectInputDevice8_Poll(js->win32.device);
|
||||||
result = IDirectInputDevice8_GetDeviceState(js->win32.device,
|
result = IDirectInputDevice8_GetDeviceState(js->win32.device,
|
||||||
|
@ -740,7 +740,12 @@ int _glfwPlatformPollJoystick(_GLFWjoystick* js, int mode)
|
||||||
return GLFW_TRUE;
|
return GLFW_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformUpdateGamepadGUID(char* guid)
|
const char* _glfwGetMappingNameWin32(void)
|
||||||
|
{
|
||||||
|
return "Windows";
|
||||||
|
}
|
||||||
|
|
||||||
|
void _glfwUpdateGamepadGUIDWin32(char* guid)
|
||||||
{
|
{
|
||||||
if (strcmp(guid + 20, "504944564944") == 0)
|
if (strcmp(guid + 20, "504944564944") == 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -24,10 +24,9 @@
|
||||||
//
|
//
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
#define _GLFW_PLATFORM_JOYSTICK_STATE _GLFWjoystickWin32 win32
|
#define GLFW_WIN32_JOYSTICK_STATE _GLFWjoystickWin32 win32;
|
||||||
#define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE struct { int dummyLibraryJoystick; }
|
#define GLFW_WIN32_LIBRARY_JOYSTICK_STATE
|
||||||
|
|
||||||
#define _GLFW_PLATFORM_MAPPING_NAME "Windows"
|
|
||||||
#define GLFW_BUILD_WIN32_MAPPINGS
|
#define GLFW_BUILD_WIN32_MAPPINGS
|
||||||
|
|
||||||
// Joystick element (axis, button or slider)
|
// Joystick element (axis, button or slider)
|
||||||
|
|
49
src/win32_module.c
Normal file
49
src/win32_module.c
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
//========================================================================
|
||||||
|
// GLFW 3.4 Win32 - www.glfw.org
|
||||||
|
//------------------------------------------------------------------------
|
||||||
|
// Copyright (c) 2021 Camilla Löwy <elmindreda@glfw.org>
|
||||||
|
//
|
||||||
|
// This software is provided 'as-is', without any express or implied
|
||||||
|
// warranty. In no event will the authors be held liable for any damages
|
||||||
|
// arising from the use of this software.
|
||||||
|
//
|
||||||
|
// Permission is granted to anyone to use this software for any purpose,
|
||||||
|
// including commercial applications, and to alter it and redistribute it
|
||||||
|
// freely, subject to the following restrictions:
|
||||||
|
//
|
||||||
|
// 1. The origin of this software must not be misrepresented; you must not
|
||||||
|
// claim that you wrote the original software. If you use this software
|
||||||
|
// in a product, an acknowledgment in the product documentation would
|
||||||
|
// be appreciated but is not required.
|
||||||
|
//
|
||||||
|
// 2. Altered source versions must be plainly marked as such, and must not
|
||||||
|
// be misrepresented as being the original software.
|
||||||
|
//
|
||||||
|
// 3. This notice may not be removed or altered from any source
|
||||||
|
// distribution.
|
||||||
|
//
|
||||||
|
//========================================================================
|
||||||
|
// Please use C89 style variable declarations in this file because VS 2010
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
|
#include "internal.h"
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
////// GLFW platform API //////
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void* _glfwPlatformLoadModule(const char* path)
|
||||||
|
{
|
||||||
|
return LoadLibraryA(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _glfwPlatformFreeModule(void* module)
|
||||||
|
{
|
||||||
|
FreeLibrary((HMODULE) module);
|
||||||
|
}
|
||||||
|
|
||||||
|
GLFWproc _glfwPlatformGetModuleSymbol(void* module, const char* name)
|
||||||
|
{
|
||||||
|
return (GLFWproc) GetProcAddress((HMODULE) module, name);
|
||||||
|
}
|
||||||
|
|
|
@ -32,7 +32,6 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <malloc.h>
|
|
||||||
#include <wchar.h>
|
#include <wchar.h>
|
||||||
|
|
||||||
|
|
||||||
|
@ -96,7 +95,7 @@ static _GLFWmonitor* createMonitor(DISPLAY_DEVICEW* adapter,
|
||||||
DeleteDC(dc);
|
DeleteDC(dc);
|
||||||
|
|
||||||
monitor = _glfwAllocMonitor(name, widthMM, heightMM);
|
monitor = _glfwAllocMonitor(name, widthMM, heightMM);
|
||||||
free(name);
|
_glfw_free(name);
|
||||||
|
|
||||||
if (adapter->StateFlags & DISPLAY_DEVICE_MODESPRUNED)
|
if (adapter->StateFlags & DISPLAY_DEVICE_MODESPRUNED)
|
||||||
monitor->win32.modesPruned = GLFW_TRUE;
|
monitor->win32.modesPruned = GLFW_TRUE;
|
||||||
|
@ -145,7 +144,7 @@ void _glfwPollMonitorsWin32(void)
|
||||||
disconnectedCount = _glfw.monitorCount;
|
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*));
|
||||||
|
@ -197,7 +196,7 @@ void _glfwPollMonitorsWin32(void)
|
||||||
monitor = createMonitor(&adapter, &display);
|
monitor = createMonitor(&adapter, &display);
|
||||||
if (!monitor)
|
if (!monitor)
|
||||||
{
|
{
|
||||||
free(disconnected);
|
_glfw_free(disconnected);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -227,7 +226,7 @@ void _glfwPollMonitorsWin32(void)
|
||||||
monitor = createMonitor(&adapter, NULL);
|
monitor = createMonitor(&adapter, NULL);
|
||||||
if (!monitor)
|
if (!monitor)
|
||||||
{
|
{
|
||||||
free(disconnected);
|
_glfw_free(disconnected);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -241,7 +240,7 @@ void _glfwPollMonitorsWin32(void)
|
||||||
_glfwInputMonitor(disconnected[i], GLFW_DISCONNECTED, 0);
|
_glfwInputMonitor(disconnected[i], GLFW_DISCONNECTED, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
free(disconnected);
|
_glfw_free(disconnected);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Change the current video mode
|
// Change the current video mode
|
||||||
|
@ -254,7 +253,7 @@ void _glfwSetVideoModeWin32(_GLFWmonitor* monitor, const GLFWvidmode* desired)
|
||||||
LONG result;
|
LONG result;
|
||||||
|
|
||||||
best = _glfwChooseVideoMode(monitor, desired);
|
best = _glfwChooseVideoMode(monitor, desired);
|
||||||
_glfwPlatformGetVideoMode(monitor, ¤t);
|
_glfwGetVideoModeWin32(monitor, ¤t);
|
||||||
if (_glfwCompareVideoModes(¤t, best) == 0)
|
if (_glfwCompareVideoModes(¤t, best) == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -314,12 +313,23 @@ void _glfwRestoreVideoModeWin32(_GLFWmonitor* monitor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwGetMonitorContentScaleWin32(HMONITOR handle, float* xscale, float* yscale)
|
void _glfwGetHMONITORContentScaleWin32(HMONITOR handle, float* xscale, float* yscale)
|
||||||
{
|
{
|
||||||
UINT xdpi, ydpi;
|
UINT xdpi, ydpi;
|
||||||
|
|
||||||
|
if (xscale)
|
||||||
|
*xscale = 0.f;
|
||||||
|
if (yscale)
|
||||||
|
*yscale = 0.f;
|
||||||
|
|
||||||
if (IsWindows8Point1OrGreater())
|
if (IsWindows8Point1OrGreater())
|
||||||
GetDpiForMonitor(handle, MDT_EFFECTIVE_DPI, &xdpi, &ydpi);
|
{
|
||||||
|
if (GetDpiForMonitor(handle, MDT_EFFECTIVE_DPI, &xdpi, &ydpi) != S_OK)
|
||||||
|
{
|
||||||
|
_glfwInputError(GLFW_PLATFORM_ERROR, "Win32: Failed to query monitor DPI");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const HDC dc = GetDC(NULL);
|
const HDC dc = GetDC(NULL);
|
||||||
|
@ -339,11 +349,11 @@ void _glfwGetMonitorContentScaleWin32(HMONITOR handle, float* xscale, float* ysc
|
||||||
////// GLFW platform API //////
|
////// GLFW platform API //////
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void _glfwPlatformFreeMonitor(_GLFWmonitor* monitor)
|
void _glfwFreeMonitorWin32(_GLFWmonitor* monitor)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos)
|
void _glfwGetMonitorPosWin32(_GLFWmonitor* monitor, int* xpos, int* ypos)
|
||||||
{
|
{
|
||||||
DEVMODEW dm;
|
DEVMODEW dm;
|
||||||
ZeroMemory(&dm, sizeof(dm));
|
ZeroMemory(&dm, sizeof(dm));
|
||||||
|
@ -360,18 +370,18 @@ void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos)
|
||||||
*ypos = dm.dmPosition.y;
|
*ypos = dm.dmPosition.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformGetMonitorContentScale(_GLFWmonitor* monitor,
|
void _glfwGetMonitorContentScaleWin32(_GLFWmonitor* monitor,
|
||||||
float* xscale, float* yscale)
|
float* xscale, float* yscale)
|
||||||
{
|
{
|
||||||
_glfwGetMonitorContentScaleWin32(monitor->win32.handle, xscale, yscale);
|
_glfwGetHMONITORContentScaleWin32(monitor->win32.handle, xscale, yscale);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformGetMonitorWorkarea(_GLFWmonitor* monitor,
|
void _glfwGetMonitorWorkareaWin32(_GLFWmonitor* monitor,
|
||||||
int* xpos, int* ypos,
|
int* xpos, int* ypos,
|
||||||
int* width, int* height)
|
int* width, int* height)
|
||||||
{
|
{
|
||||||
MONITORINFO mi = { sizeof(mi) };
|
MONITORINFO mi = { sizeof(mi) };
|
||||||
GetMonitorInfo(monitor->win32.handle, &mi);
|
GetMonitorInfoW(monitor->win32.handle, &mi);
|
||||||
|
|
||||||
if (xpos)
|
if (xpos)
|
||||||
*xpos = mi.rcWork.left;
|
*xpos = mi.rcWork.left;
|
||||||
|
@ -383,7 +393,7 @@ void _glfwPlatformGetMonitorWorkarea(_GLFWmonitor* monitor,
|
||||||
*height = mi.rcWork.bottom - mi.rcWork.top;
|
*height = mi.rcWork.bottom - mi.rcWork.top;
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* count)
|
GLFWvidmode* _glfwGetVideoModesWin32(_GLFWmonitor* monitor, int* count)
|
||||||
{
|
{
|
||||||
int modeIndex = 0, size = 0;
|
int modeIndex = 0, size = 0;
|
||||||
GLFWvidmode* result = NULL;
|
GLFWvidmode* result = NULL;
|
||||||
|
@ -442,7 +452,7 @@ GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* count)
|
||||||
if (*count == size)
|
if (*count == size)
|
||||||
{
|
{
|
||||||
size += 128;
|
size += 128;
|
||||||
result = (GLFWvidmode*) realloc(result, size * sizeof(GLFWvidmode));
|
result = (GLFWvidmode*) _glfw_realloc(result, size * sizeof(GLFWvidmode));
|
||||||
}
|
}
|
||||||
|
|
||||||
(*count)++;
|
(*count)++;
|
||||||
|
@ -452,15 +462,15 @@ GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* count)
|
||||||
if (!*count)
|
if (!*count)
|
||||||
{
|
{
|
||||||
// HACK: Report the current mode if no valid modes were found
|
// HACK: Report the current mode if no valid modes were found
|
||||||
result = calloc(1, sizeof(GLFWvidmode));
|
result = _glfw_calloc(1, sizeof(GLFWvidmode));
|
||||||
_glfwPlatformGetVideoMode(monitor, result);
|
_glfwGetVideoModeWin32(monitor, result);
|
||||||
*count = 1;
|
*count = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode)
|
void _glfwGetVideoModeWin32(_GLFWmonitor* monitor, GLFWvidmode* mode)
|
||||||
{
|
{
|
||||||
DEVMODEW dm;
|
DEVMODEW dm;
|
||||||
ZeroMemory(&dm, sizeof(dm));
|
ZeroMemory(&dm, sizeof(dm));
|
||||||
|
@ -477,7 +487,7 @@ void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode)
|
||||||
&mode->blueBits);
|
&mode->blueBits);
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWbool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
|
GLFWbool _glfwGetGammaRampWin32(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
|
||||||
{
|
{
|
||||||
HDC dc;
|
HDC dc;
|
||||||
WORD values[3][256];
|
WORD values[3][256];
|
||||||
|
@ -495,7 +505,7 @@ GLFWbool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
|
||||||
return GLFW_TRUE;
|
return GLFW_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp)
|
void _glfwSetGammaRampWin32(_GLFWmonitor* monitor, const GLFWgammaramp* ramp)
|
||||||
{
|
{
|
||||||
HDC dc;
|
HDC dc;
|
||||||
WORD values[3][256];
|
WORD values[3][256];
|
||||||
|
|
|
@ -162,7 +162,9 @@ typedef enum
|
||||||
#define DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 ((HANDLE) -4)
|
#define DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 ((HANDLE) -4)
|
||||||
#endif /*DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2*/
|
#endif /*DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2*/
|
||||||
|
|
||||||
// HACK: Define versionhelpers.h functions manually as MinGW lacks the header
|
// Replacement for versionhelpers.h macros, as we cannot rely on the
|
||||||
|
// application having a correct embedded manifest
|
||||||
|
//
|
||||||
#define IsWindowsVistaOrGreater() \
|
#define IsWindowsVistaOrGreater() \
|
||||||
_glfwIsWindowsVersionOrGreaterWin32(HIBYTE(_WIN32_WINNT_VISTA), \
|
_glfwIsWindowsVersionOrGreaterWin32(HIBYTE(_WIN32_WINNT_VISTA), \
|
||||||
LOBYTE(_WIN32_WINNT_VISTA), 0)
|
LOBYTE(_WIN32_WINNT_VISTA), 0)
|
||||||
|
@ -176,9 +178,11 @@ typedef enum
|
||||||
_glfwIsWindowsVersionOrGreaterWin32(HIBYTE(_WIN32_WINNT_WINBLUE), \
|
_glfwIsWindowsVersionOrGreaterWin32(HIBYTE(_WIN32_WINNT_WINBLUE), \
|
||||||
LOBYTE(_WIN32_WINNT_WINBLUE), 0)
|
LOBYTE(_WIN32_WINNT_WINBLUE), 0)
|
||||||
|
|
||||||
#define _glfwIsWindows10AnniversaryUpdateOrGreaterWin32() \
|
// Windows 10 Anniversary Update
|
||||||
|
#define _glfwIsWindows10Version1607OrGreaterWin32() \
|
||||||
_glfwIsWindows10BuildOrGreaterWin32(14393)
|
_glfwIsWindows10BuildOrGreaterWin32(14393)
|
||||||
#define _glfwIsWindows10CreatorsUpdateOrGreaterWin32() \
|
// Windows 10 Creators Update
|
||||||
|
#define _glfwIsWindows10Version1703OrGreaterWin32() \
|
||||||
_glfwIsWindows10BuildOrGreaterWin32(15063)
|
_glfwIsWindows10BuildOrGreaterWin32(15063)
|
||||||
|
|
||||||
// HACK: Define macros that some xinput.h variants don't
|
// HACK: Define macros that some xinput.h variants don't
|
||||||
|
@ -215,9 +219,56 @@ typedef enum
|
||||||
#define DIDFT_OPTIONAL 0x80000000
|
#define DIDFT_OPTIONAL 0x80000000
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// winmm.dll function pointer typedefs
|
#define WGL_NUMBER_PIXEL_FORMATS_ARB 0x2000
|
||||||
typedef DWORD (WINAPI * PFN_timeGetTime)(void);
|
#define WGL_SUPPORT_OPENGL_ARB 0x2010
|
||||||
#define timeGetTime _glfw.win32.winmm.GetTime
|
#define WGL_DRAW_TO_WINDOW_ARB 0x2001
|
||||||
|
#define WGL_PIXEL_TYPE_ARB 0x2013
|
||||||
|
#define WGL_TYPE_RGBA_ARB 0x202b
|
||||||
|
#define WGL_ACCELERATION_ARB 0x2003
|
||||||
|
#define WGL_NO_ACCELERATION_ARB 0x2025
|
||||||
|
#define WGL_RED_BITS_ARB 0x2015
|
||||||
|
#define WGL_RED_SHIFT_ARB 0x2016
|
||||||
|
#define WGL_GREEN_BITS_ARB 0x2017
|
||||||
|
#define WGL_GREEN_SHIFT_ARB 0x2018
|
||||||
|
#define WGL_BLUE_BITS_ARB 0x2019
|
||||||
|
#define WGL_BLUE_SHIFT_ARB 0x201a
|
||||||
|
#define WGL_ALPHA_BITS_ARB 0x201b
|
||||||
|
#define WGL_ALPHA_SHIFT_ARB 0x201c
|
||||||
|
#define WGL_ACCUM_BITS_ARB 0x201d
|
||||||
|
#define WGL_ACCUM_RED_BITS_ARB 0x201e
|
||||||
|
#define WGL_ACCUM_GREEN_BITS_ARB 0x201f
|
||||||
|
#define WGL_ACCUM_BLUE_BITS_ARB 0x2020
|
||||||
|
#define WGL_ACCUM_ALPHA_BITS_ARB 0x2021
|
||||||
|
#define WGL_DEPTH_BITS_ARB 0x2022
|
||||||
|
#define WGL_STENCIL_BITS_ARB 0x2023
|
||||||
|
#define WGL_AUX_BUFFERS_ARB 0x2024
|
||||||
|
#define WGL_STEREO_ARB 0x2012
|
||||||
|
#define WGL_DOUBLE_BUFFER_ARB 0x2011
|
||||||
|
#define WGL_SAMPLES_ARB 0x2042
|
||||||
|
#define WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20a9
|
||||||
|
#define WGL_CONTEXT_DEBUG_BIT_ARB 0x00000001
|
||||||
|
#define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x00000002
|
||||||
|
#define WGL_CONTEXT_PROFILE_MASK_ARB 0x9126
|
||||||
|
#define WGL_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001
|
||||||
|
#define WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002
|
||||||
|
#define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091
|
||||||
|
#define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092
|
||||||
|
#define WGL_CONTEXT_FLAGS_ARB 0x2094
|
||||||
|
#define WGL_CONTEXT_ES2_PROFILE_BIT_EXT 0x00000004
|
||||||
|
#define WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB 0x00000004
|
||||||
|
#define WGL_LOSE_CONTEXT_ON_RESET_ARB 0x8252
|
||||||
|
#define WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB 0x8256
|
||||||
|
#define WGL_NO_RESET_NOTIFICATION_ARB 0x8261
|
||||||
|
#define WGL_CONTEXT_RELEASE_BEHAVIOR_ARB 0x2097
|
||||||
|
#define WGL_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB 0
|
||||||
|
#define WGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB 0x2098
|
||||||
|
#define WGL_CONTEXT_OPENGL_NO_ERROR_ARB 0x31b3
|
||||||
|
#define WGL_COLORSPACE_EXT 0x309d
|
||||||
|
#define WGL_COLORSPACE_SRGB_EXT 0x3089
|
||||||
|
|
||||||
|
#define ERROR_INVALID_VERSION_ARB 0x2095
|
||||||
|
#define ERROR_INVALID_PROFILE_ARB 0x2096
|
||||||
|
#define ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB 0x2054
|
||||||
|
|
||||||
// xinput.dll function pointer typedefs
|
// xinput.dll function pointer typedefs
|
||||||
typedef DWORD (WINAPI * PFN_XInputGetCapabilities)(DWORD,DWORD,XINPUT_CAPABILITIES*);
|
typedef DWORD (WINAPI * PFN_XInputGetCapabilities)(DWORD,DWORD,XINPUT_CAPABILITIES*);
|
||||||
|
@ -236,12 +287,14 @@ typedef BOOL (WINAPI * PFN_EnableNonClientDpiScaling)(HWND);
|
||||||
typedef BOOL (WINAPI * PFN_SetProcessDpiAwarenessContext)(HANDLE);
|
typedef BOOL (WINAPI * PFN_SetProcessDpiAwarenessContext)(HANDLE);
|
||||||
typedef UINT (WINAPI * PFN_GetDpiForWindow)(HWND);
|
typedef UINT (WINAPI * PFN_GetDpiForWindow)(HWND);
|
||||||
typedef BOOL (WINAPI * PFN_AdjustWindowRectExForDpi)(LPRECT,DWORD,BOOL,DWORD,UINT);
|
typedef BOOL (WINAPI * PFN_AdjustWindowRectExForDpi)(LPRECT,DWORD,BOOL,DWORD,UINT);
|
||||||
|
typedef int (WINAPI * PFN_GetSystemMetricsForDpi)(int,UINT);
|
||||||
#define SetProcessDPIAware _glfw.win32.user32.SetProcessDPIAware_
|
#define SetProcessDPIAware _glfw.win32.user32.SetProcessDPIAware_
|
||||||
#define ChangeWindowMessageFilterEx _glfw.win32.user32.ChangeWindowMessageFilterEx_
|
#define ChangeWindowMessageFilterEx _glfw.win32.user32.ChangeWindowMessageFilterEx_
|
||||||
#define EnableNonClientDpiScaling _glfw.win32.user32.EnableNonClientDpiScaling_
|
#define EnableNonClientDpiScaling _glfw.win32.user32.EnableNonClientDpiScaling_
|
||||||
#define SetProcessDpiAwarenessContext _glfw.win32.user32.SetProcessDpiAwarenessContext_
|
#define SetProcessDpiAwarenessContext _glfw.win32.user32.SetProcessDpiAwarenessContext_
|
||||||
#define GetDpiForWindow _glfw.win32.user32.GetDpiForWindow_
|
#define GetDpiForWindow _glfw.win32.user32.GetDpiForWindow_
|
||||||
#define AdjustWindowRectExForDpi _glfw.win32.user32.AdjustWindowRectExForDpi_
|
#define AdjustWindowRectExForDpi _glfw.win32.user32.AdjustWindowRectExForDpi_
|
||||||
|
#define GetSystemMetricsForDpi _glfw.win32.user32.GetSystemMetricsForDpi_
|
||||||
|
|
||||||
// dwmapi.dll function pointer typedefs
|
// dwmapi.dll function pointer typedefs
|
||||||
typedef HRESULT (WINAPI * PFN_DwmIsCompositionEnabled)(BOOL*);
|
typedef HRESULT (WINAPI * PFN_DwmIsCompositionEnabled)(BOOL*);
|
||||||
|
@ -263,6 +316,34 @@ typedef HRESULT (WINAPI * PFN_GetDpiForMonitor)(HMONITOR,MONITOR_DPI_TYPE,UINT*,
|
||||||
typedef LONG (WINAPI * PFN_RtlVerifyVersionInfo)(OSVERSIONINFOEXW*,ULONG,ULONGLONG);
|
typedef LONG (WINAPI * PFN_RtlVerifyVersionInfo)(OSVERSIONINFOEXW*,ULONG,ULONGLONG);
|
||||||
#define RtlVerifyVersionInfo _glfw.win32.ntdll.RtlVerifyVersionInfo_
|
#define RtlVerifyVersionInfo _glfw.win32.ntdll.RtlVerifyVersionInfo_
|
||||||
|
|
||||||
|
// WGL extension pointer typedefs
|
||||||
|
typedef BOOL (WINAPI * PFNWGLSWAPINTERVALEXTPROC)(int);
|
||||||
|
typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVARBPROC)(HDC,int,int,UINT,const int*,int*);
|
||||||
|
typedef const char* (WINAPI * PFNWGLGETEXTENSIONSSTRINGEXTPROC)(void);
|
||||||
|
typedef const char* (WINAPI * PFNWGLGETEXTENSIONSSTRINGARBPROC)(HDC);
|
||||||
|
typedef HGLRC (WINAPI * PFNWGLCREATECONTEXTATTRIBSARBPROC)(HDC,HGLRC,const int*);
|
||||||
|
#define wglSwapIntervalEXT _glfw.wgl.SwapIntervalEXT
|
||||||
|
#define wglGetPixelFormatAttribivARB _glfw.wgl.GetPixelFormatAttribivARB
|
||||||
|
#define wglGetExtensionsStringEXT _glfw.wgl.GetExtensionsStringEXT
|
||||||
|
#define wglGetExtensionsStringARB _glfw.wgl.GetExtensionsStringARB
|
||||||
|
#define wglCreateContextAttribsARB _glfw.wgl.CreateContextAttribsARB
|
||||||
|
|
||||||
|
// opengl32.dll function pointer typedefs
|
||||||
|
typedef HGLRC (WINAPI * PFN_wglCreateContext)(HDC);
|
||||||
|
typedef BOOL (WINAPI * PFN_wglDeleteContext)(HGLRC);
|
||||||
|
typedef PROC (WINAPI * PFN_wglGetProcAddress)(LPCSTR);
|
||||||
|
typedef HDC (WINAPI * PFN_wglGetCurrentDC)(void);
|
||||||
|
typedef HGLRC (WINAPI * PFN_wglGetCurrentContext)(void);
|
||||||
|
typedef BOOL (WINAPI * PFN_wglMakeCurrent)(HDC,HGLRC);
|
||||||
|
typedef BOOL (WINAPI * PFN_wglShareLists)(HGLRC,HGLRC);
|
||||||
|
#define wglCreateContext _glfw.wgl.CreateContext
|
||||||
|
#define wglDeleteContext _glfw.wgl.DeleteContext
|
||||||
|
#define wglGetProcAddress _glfw.wgl.GetProcAddress
|
||||||
|
#define wglGetCurrentDC _glfw.wgl.GetCurrentDC
|
||||||
|
#define wglGetCurrentContext _glfw.wgl.GetCurrentContext
|
||||||
|
#define wglMakeCurrent _glfw.wgl.MakeCurrent
|
||||||
|
#define wglShareLists _glfw.wgl.ShareLists
|
||||||
|
|
||||||
typedef VkFlags VkWin32SurfaceCreateFlagsKHR;
|
typedef VkFlags VkWin32SurfaceCreateFlagsKHR;
|
||||||
|
|
||||||
typedef struct VkWin32SurfaceCreateInfoKHR
|
typedef struct VkWin32SurfaceCreateInfoKHR
|
||||||
|
@ -277,26 +358,60 @@ typedef struct VkWin32SurfaceCreateInfoKHR
|
||||||
typedef VkResult (APIENTRY *PFN_vkCreateWin32SurfaceKHR)(VkInstance,const VkWin32SurfaceCreateInfoKHR*,const VkAllocationCallbacks*,VkSurfaceKHR*);
|
typedef VkResult (APIENTRY *PFN_vkCreateWin32SurfaceKHR)(VkInstance,const VkWin32SurfaceCreateInfoKHR*,const VkAllocationCallbacks*,VkSurfaceKHR*);
|
||||||
typedef VkBool32 (APIENTRY *PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR)(VkPhysicalDevice,uint32_t);
|
typedef VkBool32 (APIENTRY *PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR)(VkPhysicalDevice,uint32_t);
|
||||||
|
|
||||||
#include "win32_joystick.h"
|
|
||||||
#include "wgl_context.h"
|
|
||||||
|
|
||||||
#if !defined(_GLFW_WNDCLASSNAME)
|
#if !defined(_GLFW_WNDCLASSNAME)
|
||||||
#define _GLFW_WNDCLASSNAME L"GLFW30"
|
#define _GLFW_WNDCLASSNAME L"GLFW30"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define _glfw_dlopen(name) LoadLibraryA(name)
|
#define GLFW_WIN32_WINDOW_STATE _GLFWwindowWin32 win32;
|
||||||
#define _glfw_dlclose(handle) FreeLibrary((HMODULE) handle)
|
#define GLFW_WIN32_LIBRARY_WINDOW_STATE _GLFWlibraryWin32 win32;
|
||||||
#define _glfw_dlsym(handle, name) GetProcAddress((HMODULE) handle, name)
|
#define GLFW_WIN32_MONITOR_STATE _GLFWmonitorWin32 win32;
|
||||||
|
#define GLFW_WIN32_CURSOR_STATE _GLFWcursorWin32 win32;
|
||||||
|
|
||||||
#define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowWin32 win32
|
#define GLFW_WGL_CONTEXT_STATE _GLFWcontextWGL wgl;
|
||||||
#define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryWin32 win32
|
#define GLFW_WGL_LIBRARY_CONTEXT_STATE _GLFWlibraryWGL wgl;
|
||||||
#define _GLFW_PLATFORM_LIBRARY_TIMER_STATE _GLFWtimerWin32 win32
|
|
||||||
#define _GLFW_PLATFORM_MONITOR_STATE _GLFWmonitorWin32 win32
|
|
||||||
#define _GLFW_PLATFORM_CURSOR_STATE _GLFWcursorWin32 win32
|
|
||||||
#define _GLFW_PLATFORM_TLS_STATE _GLFWtlsWin32 win32
|
|
||||||
#define _GLFW_PLATFORM_MUTEX_STATE _GLFWmutexWin32 win32
|
|
||||||
|
|
||||||
|
|
||||||
|
// 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;
|
||||||
|
|
||||||
// Win32-specific per-window data
|
// Win32-specific per-window data
|
||||||
//
|
//
|
||||||
typedef struct _GLFWwindowWin32
|
typedef struct _GLFWwindowWin32
|
||||||
|
@ -319,15 +434,15 @@ typedef struct _GLFWwindowWin32
|
||||||
|
|
||||||
// The last received cursor position, regardless of source
|
// The last received cursor position, regardless of source
|
||||||
int lastCursorPosX, lastCursorPosY;
|
int lastCursorPosX, lastCursorPosY;
|
||||||
// The last recevied high surrogate when decoding pairs of UTF-16 messages
|
// The last received high surrogate when decoding pairs of UTF-16 messages
|
||||||
WCHAR highSurrogate;
|
WCHAR highSurrogate;
|
||||||
|
|
||||||
} _GLFWwindowWin32;
|
} _GLFWwindowWin32;
|
||||||
|
|
||||||
// Win32-specific global data
|
// Win32-specific global data
|
||||||
//
|
//
|
||||||
typedef struct _GLFWlibraryWin32
|
typedef struct _GLFWlibraryWin32
|
||||||
{
|
{
|
||||||
|
HINSTANCE instance;
|
||||||
HWND helperWindowHandle;
|
HWND helperWindowHandle;
|
||||||
HDEVNOTIFY deviceNotificationHandle;
|
HDEVNOTIFY deviceNotificationHandle;
|
||||||
int acquiredMonitorCount;
|
int acquiredMonitorCount;
|
||||||
|
@ -343,11 +458,6 @@ typedef struct _GLFWlibraryWin32
|
||||||
int rawInputSize;
|
int rawInputSize;
|
||||||
UINT mouseTrailSize;
|
UINT mouseTrailSize;
|
||||||
|
|
||||||
struct {
|
|
||||||
HINSTANCE instance;
|
|
||||||
PFN_timeGetTime GetTime;
|
|
||||||
} winmm;
|
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
HINSTANCE instance;
|
HINSTANCE instance;
|
||||||
PFN_DirectInput8Create Create;
|
PFN_DirectInput8Create Create;
|
||||||
|
@ -368,6 +478,7 @@ typedef struct _GLFWlibraryWin32
|
||||||
PFN_SetProcessDpiAwarenessContext SetProcessDpiAwarenessContext_;
|
PFN_SetProcessDpiAwarenessContext SetProcessDpiAwarenessContext_;
|
||||||
PFN_GetDpiForWindow GetDpiForWindow_;
|
PFN_GetDpiForWindow GetDpiForWindow_;
|
||||||
PFN_AdjustWindowRectExForDpi AdjustWindowRectExForDpi_;
|
PFN_AdjustWindowRectExForDpi AdjustWindowRectExForDpi_;
|
||||||
|
PFN_GetSystemMetricsForDpi GetSystemMetricsForDpi_;
|
||||||
} user32;
|
} user32;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
|
@ -388,7 +499,6 @@ typedef struct _GLFWlibraryWin32
|
||||||
HINSTANCE instance;
|
HINSTANCE instance;
|
||||||
PFN_RtlVerifyVersionInfo RtlVerifyVersionInfo_;
|
PFN_RtlVerifyVersionInfo RtlVerifyVersionInfo_;
|
||||||
} ntdll;
|
} ntdll;
|
||||||
|
|
||||||
} _GLFWlibraryWin32;
|
} _GLFWlibraryWin32;
|
||||||
|
|
||||||
// Win32-specific per-monitor data
|
// Win32-specific per-monitor data
|
||||||
|
@ -403,7 +513,6 @@ typedef struct _GLFWmonitorWin32
|
||||||
char publicDisplayName[32];
|
char publicDisplayName[32];
|
||||||
GLFWbool modesPruned;
|
GLFWbool modesPruned;
|
||||||
GLFWbool modeChanged;
|
GLFWbool modeChanged;
|
||||||
|
|
||||||
} _GLFWmonitorWin32;
|
} _GLFWmonitorWin32;
|
||||||
|
|
||||||
// Win32-specific per-cursor data
|
// Win32-specific per-cursor data
|
||||||
|
@ -411,36 +520,12 @@ typedef struct _GLFWmonitorWin32
|
||||||
typedef struct _GLFWcursorWin32
|
typedef struct _GLFWcursorWin32
|
||||||
{
|
{
|
||||||
HCURSOR handle;
|
HCURSOR handle;
|
||||||
|
|
||||||
} _GLFWcursorWin32;
|
} _GLFWcursorWin32;
|
||||||
|
|
||||||
// Win32-specific global timer data
|
|
||||||
//
|
|
||||||
typedef struct _GLFWtimerWin32
|
|
||||||
{
|
|
||||||
GLFWbool hasPC;
|
|
||||||
uint64_t frequency;
|
|
||||||
|
|
||||||
} _GLFWtimerWin32;
|
|
||||||
|
|
||||||
// Win32-specific thread local storage data
|
|
||||||
//
|
|
||||||
typedef struct _GLFWtlsWin32
|
|
||||||
{
|
|
||||||
GLFWbool allocated;
|
|
||||||
DWORD index;
|
|
||||||
|
|
||||||
} _GLFWtlsWin32;
|
|
||||||
|
|
||||||
// Win32-specific mutex data
|
|
||||||
//
|
|
||||||
typedef struct _GLFWmutexWin32
|
|
||||||
{
|
|
||||||
GLFWbool allocated;
|
|
||||||
CRITICAL_SECTION section;
|
|
||||||
|
|
||||||
} _GLFWmutexWin32;
|
|
||||||
|
|
||||||
|
GLFWbool _glfwConnectWin32(int platformID, _GLFWplatform* platform);
|
||||||
|
int _glfwInitWin32(void);
|
||||||
|
void _glfwTerminateWin32(void);
|
||||||
|
|
||||||
GLFWbool _glfwRegisterWindowClassWin32(void);
|
GLFWbool _glfwRegisterWindowClassWin32(void);
|
||||||
void _glfwUnregisterWindowClassWin32(void);
|
void _glfwUnregisterWindowClassWin32(void);
|
||||||
|
@ -452,10 +537,91 @@ BOOL _glfwIsWindows10BuildOrGreaterWin32(WORD build);
|
||||||
void _glfwInputErrorWin32(int error, const char* description);
|
void _glfwInputErrorWin32(int error, const char* description);
|
||||||
void _glfwUpdateKeyNamesWin32(void);
|
void _glfwUpdateKeyNamesWin32(void);
|
||||||
|
|
||||||
void _glfwInitTimerWin32(void);
|
|
||||||
|
|
||||||
void _glfwPollMonitorsWin32(void);
|
void _glfwPollMonitorsWin32(void);
|
||||||
void _glfwSetVideoModeWin32(_GLFWmonitor* monitor, const GLFWvidmode* desired);
|
void _glfwSetVideoModeWin32(_GLFWmonitor* monitor, const GLFWvidmode* desired);
|
||||||
void _glfwRestoreVideoModeWin32(_GLFWmonitor* monitor);
|
void _glfwRestoreVideoModeWin32(_GLFWmonitor* monitor);
|
||||||
void _glfwGetMonitorContentScaleWin32(HMONITOR handle, float* xscale, float* yscale);
|
void _glfwGetHMONITORContentScaleWin32(HMONITOR handle, float* xscale, float* yscale);
|
||||||
|
|
||||||
|
int _glfwCreateWindowWin32(_GLFWwindow* window, const _GLFWwndconfig* wndconfig, const _GLFWctxconfig* ctxconfig, const _GLFWfbconfig* fbconfig);
|
||||||
|
void _glfwDestroyWindowWin32(_GLFWwindow* window);
|
||||||
|
void _glfwSetWindowTitleWin32(_GLFWwindow* window, const char* title);
|
||||||
|
void _glfwSetWindowIconWin32(_GLFWwindow* window, int count, const GLFWimage* images);
|
||||||
|
void _glfwGetWindowPosWin32(_GLFWwindow* window, int* xpos, int* ypos);
|
||||||
|
void _glfwSetWindowPosWin32(_GLFWwindow* window, int xpos, int ypos);
|
||||||
|
void _glfwGetWindowSizeWin32(_GLFWwindow* window, int* width, int* height);
|
||||||
|
void _glfwSetWindowSizeWin32(_GLFWwindow* window, int width, int height);
|
||||||
|
void _glfwSetWindowSizeLimitsWin32(_GLFWwindow* window, int minwidth, int minheight, int maxwidth, int maxheight);
|
||||||
|
void _glfwSetWindowAspectRatioWin32(_GLFWwindow* window, int numer, int denom);
|
||||||
|
void _glfwGetFramebufferSizeWin32(_GLFWwindow* window, int* width, int* height);
|
||||||
|
void _glfwGetWindowFrameSizeWin32(_GLFWwindow* window, int* left, int* top, int* right, int* bottom);
|
||||||
|
void _glfwGetWindowContentScaleWin32(_GLFWwindow* window, float* xscale, float* yscale);
|
||||||
|
void _glfwIconifyWindowWin32(_GLFWwindow* window);
|
||||||
|
void _glfwRestoreWindowWin32(_GLFWwindow* window);
|
||||||
|
void _glfwMaximizeWindowWin32(_GLFWwindow* window);
|
||||||
|
void _glfwShowWindowWin32(_GLFWwindow* window);
|
||||||
|
void _glfwHideWindowWin32(_GLFWwindow* window);
|
||||||
|
void _glfwRequestWindowAttentionWin32(_GLFWwindow* window);
|
||||||
|
void _glfwFocusWindowWin32(_GLFWwindow* window);
|
||||||
|
void _glfwSetWindowMonitorWin32(_GLFWwindow* window, _GLFWmonitor* monitor, int xpos, int ypos, int width, int height, int refreshRate);
|
||||||
|
int _glfwWindowFocusedWin32(_GLFWwindow* window);
|
||||||
|
int _glfwWindowIconifiedWin32(_GLFWwindow* window);
|
||||||
|
int _glfwWindowVisibleWin32(_GLFWwindow* window);
|
||||||
|
int _glfwWindowMaximizedWin32(_GLFWwindow* window);
|
||||||
|
int _glfwWindowHoveredWin32(_GLFWwindow* window);
|
||||||
|
int _glfwFramebufferTransparentWin32(_GLFWwindow* window);
|
||||||
|
void _glfwSetWindowResizableWin32(_GLFWwindow* window, GLFWbool enabled);
|
||||||
|
void _glfwSetWindowDecoratedWin32(_GLFWwindow* window, GLFWbool enabled);
|
||||||
|
void _glfwSetWindowFloatingWin32(_GLFWwindow* window, GLFWbool enabled);
|
||||||
|
void _glfwSetWindowMousePassthroughWin32(_GLFWwindow* window, GLFWbool enabled);
|
||||||
|
float _glfwGetWindowOpacityWin32(_GLFWwindow* window);
|
||||||
|
void _glfwSetWindowOpacityWin32(_GLFWwindow* window, float opacity);
|
||||||
|
|
||||||
|
void _glfwSetRawMouseMotionWin32(_GLFWwindow *window, GLFWbool enabled);
|
||||||
|
GLFWbool _glfwRawMouseMotionSupportedWin32(void);
|
||||||
|
|
||||||
|
void _glfwPollEventsWin32(void);
|
||||||
|
void _glfwWaitEventsWin32(void);
|
||||||
|
void _glfwWaitEventsTimeoutWin32(double timeout);
|
||||||
|
void _glfwPostEmptyEventWin32(void);
|
||||||
|
|
||||||
|
void _glfwGetCursorPosWin32(_GLFWwindow* window, double* xpos, double* ypos);
|
||||||
|
void _glfwSetCursorPosWin32(_GLFWwindow* window, double xpos, double ypos);
|
||||||
|
void _glfwSetCursorModeWin32(_GLFWwindow* window, int mode);
|
||||||
|
const char* _glfwGetScancodeNameWin32(int scancode);
|
||||||
|
int _glfwGetKeyScancodeWin32(int key);
|
||||||
|
int _glfwCreateCursorWin32(_GLFWcursor* cursor, const GLFWimage* image, int xhot, int yhot);
|
||||||
|
int _glfwCreateStandardCursorWin32(_GLFWcursor* cursor, int shape);
|
||||||
|
void _glfwDestroyCursorWin32(_GLFWcursor* cursor);
|
||||||
|
void _glfwSetCursorWin32(_GLFWwindow* window, _GLFWcursor* cursor);
|
||||||
|
void _glfwSetClipboardStringWin32(const char* string);
|
||||||
|
const char* _glfwGetClipboardStringWin32(void);
|
||||||
|
|
||||||
|
EGLenum _glfwGetEGLPlatformWin32(EGLint** attribs);
|
||||||
|
EGLNativeDisplayType _glfwGetEGLNativeDisplayWin32(void);
|
||||||
|
EGLNativeWindowType _glfwGetEGLNativeWindowWin32(_GLFWwindow* window);
|
||||||
|
|
||||||
|
void _glfwGetRequiredInstanceExtensionsWin32(char** extensions);
|
||||||
|
int _glfwGetPhysicalDevicePresentationSupportWin32(VkInstance instance, VkPhysicalDevice device, uint32_t queuefamily);
|
||||||
|
VkResult _glfwCreateWindowSurfaceWin32(VkInstance instance, _GLFWwindow* window, const VkAllocationCallbacks* allocator, VkSurfaceKHR* surface);
|
||||||
|
|
||||||
|
void _glfwFreeMonitorWin32(_GLFWmonitor* monitor);
|
||||||
|
void _glfwGetMonitorPosWin32(_GLFWmonitor* monitor, int* xpos, int* ypos);
|
||||||
|
void _glfwGetMonitorContentScaleWin32(_GLFWmonitor* monitor, float* xscale, float* yscale);
|
||||||
|
void _glfwGetMonitorWorkareaWin32(_GLFWmonitor* monitor, int* xpos, int* ypos, int* width, int* height);
|
||||||
|
GLFWvidmode* _glfwGetVideoModesWin32(_GLFWmonitor* monitor, int* count);
|
||||||
|
void _glfwGetVideoModeWin32(_GLFWmonitor* monitor, GLFWvidmode* mode);
|
||||||
|
GLFWbool _glfwGetGammaRampWin32(_GLFWmonitor* monitor, GLFWgammaramp* ramp);
|
||||||
|
void _glfwSetGammaRampWin32(_GLFWmonitor* monitor, const GLFWgammaramp* ramp);
|
||||||
|
|
||||||
|
GLFWbool _glfwInitJoysticksWin32(void);
|
||||||
|
void _glfwTerminateJoysticksWin32(void);
|
||||||
|
int _glfwPollJoystickWin32(_GLFWjoystick* js, int mode);
|
||||||
|
const char* _glfwGetMappingNameWin32(void);
|
||||||
|
void _glfwUpdateGamepadGUIDWin32(char* guid);
|
||||||
|
|
||||||
|
GLFWbool _glfwInitWGL(void);
|
||||||
|
void _glfwTerminateWGL(void);
|
||||||
|
GLFWbool _glfwCreateContextWGL(_GLFWwindow* window,
|
||||||
|
const _GLFWctxconfig* ctxconfig,
|
||||||
|
const _GLFWfbconfig* fbconfig);
|
||||||
|
|
||||||
|
|
|
@ -43,8 +43,7 @@ GLFWbool _glfwPlatformCreateTls(_GLFWtls* tls)
|
||||||
tls->win32.index = TlsAlloc();
|
tls->win32.index = TlsAlloc();
|
||||||
if (tls->win32.index == TLS_OUT_OF_INDEXES)
|
if (tls->win32.index == TLS_OUT_OF_INDEXES)
|
||||||
{
|
{
|
||||||
_glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
|
_glfwInputError(GLFW_PLATFORM_ERROR, "Win32: Failed to allocate TLS index");
|
||||||
"Win32: Failed to allocate TLS index");
|
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
48
src/win32_thread.h
Normal file
48
src/win32_thread.h
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
//========================================================================
|
||||||
|
// GLFW 3.4 Win32 - www.glfw.org
|
||||||
|
//------------------------------------------------------------------------
|
||||||
|
// Copyright (c) 2002-2006 Marcus Geelnard
|
||||||
|
// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>
|
||||||
|
//
|
||||||
|
// This software is provided 'as-is', without any express or implied
|
||||||
|
// warranty. In no event will the authors be held liable for any damages
|
||||||
|
// arising from the use of this software.
|
||||||
|
//
|
||||||
|
// Permission is granted to anyone to use this software for any purpose,
|
||||||
|
// including commercial applications, and to alter it and redistribute it
|
||||||
|
// freely, subject to the following restrictions:
|
||||||
|
//
|
||||||
|
// 1. The origin of this software must not be misrepresented; you must not
|
||||||
|
// claim that you wrote the original software. If you use this software
|
||||||
|
// in a product, an acknowledgment in the product documentation would
|
||||||
|
// be appreciated but is not required.
|
||||||
|
//
|
||||||
|
// 2. Altered source versions must be plainly marked as such, and must not
|
||||||
|
// be misrepresented as being the original software.
|
||||||
|
//
|
||||||
|
// 3. This notice may not be removed or altered from any source
|
||||||
|
// distribution.
|
||||||
|
//
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
|
#define GLFW_WIN32_TLS_STATE _GLFWtlsWin32 win32;
|
||||||
|
#define GLFW_WIN32_MUTEX_STATE _GLFWmutexWin32 win32;
|
||||||
|
|
||||||
|
// Win32-specific thread local storage data
|
||||||
|
//
|
||||||
|
typedef struct _GLFWtlsWin32
|
||||||
|
{
|
||||||
|
GLFWbool allocated;
|
||||||
|
DWORD index;
|
||||||
|
} _GLFWtlsWin32;
|
||||||
|
|
||||||
|
// Win32-specific mutex data
|
||||||
|
//
|
||||||
|
typedef struct _GLFWmutexWin32
|
||||||
|
{
|
||||||
|
GLFWbool allocated;
|
||||||
|
CRITICAL_SECTION section;
|
||||||
|
} _GLFWmutexWin32;
|
||||||
|
|
|
@ -30,43 +30,20 @@
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
////// GLFW internal API //////
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
// Initialise timer
|
|
||||||
//
|
|
||||||
void _glfwInitTimerWin32(void)
|
|
||||||
{
|
|
||||||
uint64_t frequency;
|
|
||||||
|
|
||||||
if (QueryPerformanceFrequency((LARGE_INTEGER*) &frequency))
|
|
||||||
{
|
|
||||||
_glfw.timer.win32.hasPC = GLFW_TRUE;
|
|
||||||
_glfw.timer.win32.frequency = frequency;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_glfw.timer.win32.hasPC = GLFW_FALSE;
|
|
||||||
_glfw.timer.win32.frequency = 1000;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
////// GLFW platform API //////
|
////// GLFW platform API //////
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void _glfwPlatformInitTimer(void)
|
||||||
|
{
|
||||||
|
QueryPerformanceFrequency((LARGE_INTEGER*) &_glfw.timer.win32.frequency);
|
||||||
|
}
|
||||||
|
|
||||||
uint64_t _glfwPlatformGetTimerValue(void)
|
uint64_t _glfwPlatformGetTimerValue(void)
|
||||||
{
|
{
|
||||||
if (_glfw.timer.win32.hasPC)
|
uint64_t value;
|
||||||
{
|
QueryPerformanceCounter((LARGE_INTEGER*) &value);
|
||||||
uint64_t value;
|
return value;
|
||||||
QueryPerformanceCounter((LARGE_INTEGER*) &value);
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return (uint64_t) timeGetTime();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t _glfwPlatformGetTimerFrequency(void)
|
uint64_t _glfwPlatformGetTimerFrequency(void)
|
||||||
|
|
38
src/win32_time.h
Normal file
38
src/win32_time.h
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
//========================================================================
|
||||||
|
// GLFW 3.4 Win32 - www.glfw.org
|
||||||
|
//------------------------------------------------------------------------
|
||||||
|
// Copyright (c) 2002-2006 Marcus Geelnard
|
||||||
|
// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>
|
||||||
|
//
|
||||||
|
// This software is provided 'as-is', without any express or implied
|
||||||
|
// warranty. In no event will the authors be held liable for any damages
|
||||||
|
// arising from the use of this software.
|
||||||
|
//
|
||||||
|
// Permission is granted to anyone to use this software for any purpose,
|
||||||
|
// including commercial applications, and to alter it and redistribute it
|
||||||
|
// freely, subject to the following restrictions:
|
||||||
|
//
|
||||||
|
// 1. The origin of this software must not be misrepresented; you must not
|
||||||
|
// claim that you wrote the original software. If you use this software
|
||||||
|
// in a product, an acknowledgment in the product documentation would
|
||||||
|
// be appreciated but is not required.
|
||||||
|
//
|
||||||
|
// 2. Altered source versions must be plainly marked as such, and must not
|
||||||
|
// be misrepresented as being the original software.
|
||||||
|
//
|
||||||
|
// 3. This notice may not be removed or altered from any source
|
||||||
|
// distribution.
|
||||||
|
//
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
|
#define GLFW_WIN32_LIBRARY_TIMER_STATE _GLFWtimerWin32 win32;
|
||||||
|
|
||||||
|
// Win32-specific global timer data
|
||||||
|
//
|
||||||
|
typedef struct _GLFWtimerWin32
|
||||||
|
{
|
||||||
|
uint64_t frequency;
|
||||||
|
} _GLFWtimerWin32;
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
209
src/window.c
209
src/window.c
|
@ -55,7 +55,7 @@ void _glfwInputWindowFocus(_GLFWwindow* window, GLFWbool focused)
|
||||||
{
|
{
|
||||||
if (window->keys[key] == GLFW_PRESS)
|
if (window->keys[key] == GLFW_PRESS)
|
||||||
{
|
{
|
||||||
const int scancode = _glfwPlatformGetKeyScancode(key);
|
const int scancode = _glfw.platform.getKeyScancode(key);
|
||||||
_glfwInputKey(window, key, scancode, GLFW_RELEASE, 0);
|
_glfwInputKey(window, key, scancode, GLFW_RELEASE, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -186,7 +186,7 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height,
|
||||||
if (!_glfwIsValidContextConfig(&ctxconfig))
|
if (!_glfwIsValidContextConfig(&ctxconfig))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
window = calloc(1, sizeof(_GLFWwindow));
|
window = _glfw_calloc(1, sizeof(_GLFWwindow));
|
||||||
window->next = _glfw.windowListHead;
|
window->next = _glfw.windowListHead;
|
||||||
_glfw.windowListHead = window;
|
_glfw.windowListHead = window;
|
||||||
|
|
||||||
|
@ -215,40 +215,12 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height,
|
||||||
window->numer = GLFW_DONT_CARE;
|
window->numer = GLFW_DONT_CARE;
|
||||||
window->denom = GLFW_DONT_CARE;
|
window->denom = GLFW_DONT_CARE;
|
||||||
|
|
||||||
// Open the actual window and create its context
|
if (!_glfw.platform.createWindow(window, &wndconfig, &ctxconfig, &fbconfig))
|
||||||
if (!_glfwPlatformCreateWindow(window, &wndconfig, &ctxconfig, &fbconfig))
|
|
||||||
{
|
{
|
||||||
glfwDestroyWindow((GLFWwindow*) window);
|
glfwDestroyWindow((GLFWwindow*) window);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctxconfig.client != GLFW_NO_API)
|
|
||||||
{
|
|
||||||
if (!_glfwRefreshContextAttribs(window, &ctxconfig))
|
|
||||||
{
|
|
||||||
glfwDestroyWindow((GLFWwindow*) window);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (wndconfig.mousePassthrough)
|
|
||||||
_glfwPlatformSetWindowMousePassthrough(window, GLFW_TRUE);
|
|
||||||
|
|
||||||
if (window->monitor)
|
|
||||||
{
|
|
||||||
if (wndconfig.centerCursor)
|
|
||||||
_glfwCenterCursorInContentArea(window);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (wndconfig.visible)
|
|
||||||
{
|
|
||||||
_glfwPlatformShowWindow(window);
|
|
||||||
if (wndconfig.focused)
|
|
||||||
_glfwPlatformFocusWindow(window);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return (GLFWwindow*) window;
|
return (GLFWwindow*) window;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -468,7 +440,7 @@ GLFWAPI void glfwDestroyWindow(GLFWwindow* handle)
|
||||||
if (window == _glfwPlatformGetTls(&_glfw.contextSlot))
|
if (window == _glfwPlatformGetTls(&_glfw.contextSlot))
|
||||||
glfwMakeContextCurrent(NULL);
|
glfwMakeContextCurrent(NULL);
|
||||||
|
|
||||||
_glfwPlatformDestroyWindow(window);
|
_glfw.platform.destroyWindow(window);
|
||||||
|
|
||||||
// Unlink window from global linked list
|
// Unlink window from global linked list
|
||||||
{
|
{
|
||||||
|
@ -480,7 +452,7 @@ GLFWAPI void glfwDestroyWindow(GLFWwindow* handle)
|
||||||
*prev = window->next;
|
*prev = window->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
free(window);
|
_glfw_free(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWAPI int glfwWindowShouldClose(GLFWwindow* handle)
|
GLFWAPI int glfwWindowShouldClose(GLFWwindow* handle)
|
||||||
|
@ -508,19 +480,40 @@ GLFWAPI void glfwSetWindowTitle(GLFWwindow* handle, const char* title)
|
||||||
assert(title != NULL);
|
assert(title != NULL);
|
||||||
|
|
||||||
_GLFW_REQUIRE_INIT();
|
_GLFW_REQUIRE_INIT();
|
||||||
_glfwPlatformSetWindowTitle(window, title);
|
_glfw.platform.setWindowTitle(window, title);
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWAPI void glfwSetWindowIcon(GLFWwindow* handle,
|
GLFWAPI void glfwSetWindowIcon(GLFWwindow* handle,
|
||||||
int count, const GLFWimage* images)
|
int count, const GLFWimage* images)
|
||||||
{
|
{
|
||||||
|
int i;
|
||||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||||
|
|
||||||
assert(window != NULL);
|
assert(window != NULL);
|
||||||
assert(count >= 0);
|
assert(count >= 0);
|
||||||
assert(count == 0 || images != NULL);
|
assert(count == 0 || images != NULL);
|
||||||
|
|
||||||
_GLFW_REQUIRE_INIT();
|
_GLFW_REQUIRE_INIT();
|
||||||
_glfwPlatformSetWindowIcon(window, count, images);
|
|
||||||
|
if (count < 0)
|
||||||
|
{
|
||||||
|
_glfwInputError(GLFW_INVALID_VALUE, "Invalid image count for window icon");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
assert(images[i].pixels != NULL);
|
||||||
|
|
||||||
|
if (images[i].width <= 0 || images[i].height <= 0)
|
||||||
|
{
|
||||||
|
_glfwInputError(GLFW_INVALID_VALUE,
|
||||||
|
"Invalid image dimensions for window icon");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_glfw.platform.setWindowIcon(window, count, images);
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWAPI void glfwGetWindowPos(GLFWwindow* handle, int* xpos, int* ypos)
|
GLFWAPI void glfwGetWindowPos(GLFWwindow* handle, int* xpos, int* ypos)
|
||||||
|
@ -534,7 +527,7 @@ GLFWAPI void glfwGetWindowPos(GLFWwindow* handle, int* xpos, int* ypos)
|
||||||
*ypos = 0;
|
*ypos = 0;
|
||||||
|
|
||||||
_GLFW_REQUIRE_INIT();
|
_GLFW_REQUIRE_INIT();
|
||||||
_glfwPlatformGetWindowPos(window, xpos, ypos);
|
_glfw.platform.getWindowPos(window, xpos, ypos);
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWAPI void glfwSetWindowPos(GLFWwindow* handle, int xpos, int ypos)
|
GLFWAPI void glfwSetWindowPos(GLFWwindow* handle, int xpos, int ypos)
|
||||||
|
@ -547,7 +540,7 @@ GLFWAPI void glfwSetWindowPos(GLFWwindow* handle, int xpos, int ypos)
|
||||||
if (window->monitor)
|
if (window->monitor)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_glfwPlatformSetWindowPos(window, xpos, ypos);
|
_glfw.platform.setWindowPos(window, xpos, ypos);
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWAPI void glfwGetWindowSize(GLFWwindow* handle, int* width, int* height)
|
GLFWAPI void glfwGetWindowSize(GLFWwindow* handle, int* width, int* height)
|
||||||
|
@ -561,7 +554,7 @@ GLFWAPI void glfwGetWindowSize(GLFWwindow* handle, int* width, int* height)
|
||||||
*height = 0;
|
*height = 0;
|
||||||
|
|
||||||
_GLFW_REQUIRE_INIT();
|
_GLFW_REQUIRE_INIT();
|
||||||
_glfwPlatformGetWindowSize(window, width, height);
|
_glfw.platform.getWindowSize(window, width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWAPI void glfwSetWindowSize(GLFWwindow* handle, int width, int height)
|
GLFWAPI void glfwSetWindowSize(GLFWwindow* handle, int width, int height)
|
||||||
|
@ -576,7 +569,7 @@ GLFWAPI void glfwSetWindowSize(GLFWwindow* handle, int width, int height)
|
||||||
window->videoMode.width = width;
|
window->videoMode.width = width;
|
||||||
window->videoMode.height = height;
|
window->videoMode.height = height;
|
||||||
|
|
||||||
_glfwPlatformSetWindowSize(window, width, height);
|
_glfw.platform.setWindowSize(window, width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWAPI void glfwSetWindowSizeLimits(GLFWwindow* handle,
|
GLFWAPI void glfwSetWindowSizeLimits(GLFWwindow* handle,
|
||||||
|
@ -619,9 +612,9 @@ GLFWAPI void glfwSetWindowSizeLimits(GLFWwindow* handle,
|
||||||
if (window->monitor || !window->resizable)
|
if (window->monitor || !window->resizable)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_glfwPlatformSetWindowSizeLimits(window,
|
_glfw.platform.setWindowSizeLimits(window,
|
||||||
minwidth, minheight,
|
minwidth, minheight,
|
||||||
maxwidth, maxheight);
|
maxwidth, maxheight);
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWAPI void glfwSetWindowAspectRatio(GLFWwindow* handle, int numer, int denom)
|
GLFWAPI void glfwSetWindowAspectRatio(GLFWwindow* handle, int numer, int denom)
|
||||||
|
@ -650,7 +643,7 @@ GLFWAPI void glfwSetWindowAspectRatio(GLFWwindow* handle, int numer, int denom)
|
||||||
if (window->monitor || !window->resizable)
|
if (window->monitor || !window->resizable)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_glfwPlatformSetWindowAspectRatio(window, numer, denom);
|
_glfw.platform.setWindowAspectRatio(window, numer, denom);
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWAPI void glfwGetFramebufferSize(GLFWwindow* handle, int* width, int* height)
|
GLFWAPI void glfwGetFramebufferSize(GLFWwindow* handle, int* width, int* height)
|
||||||
|
@ -664,7 +657,7 @@ GLFWAPI void glfwGetFramebufferSize(GLFWwindow* handle, int* width, int* height)
|
||||||
*height = 0;
|
*height = 0;
|
||||||
|
|
||||||
_GLFW_REQUIRE_INIT();
|
_GLFW_REQUIRE_INIT();
|
||||||
_glfwPlatformGetFramebufferSize(window, width, height);
|
_glfw.platform.getFramebufferSize(window, width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWAPI void glfwGetWindowFrameSize(GLFWwindow* handle,
|
GLFWAPI void glfwGetWindowFrameSize(GLFWwindow* handle,
|
||||||
|
@ -684,7 +677,7 @@ GLFWAPI void glfwGetWindowFrameSize(GLFWwindow* handle,
|
||||||
*bottom = 0;
|
*bottom = 0;
|
||||||
|
|
||||||
_GLFW_REQUIRE_INIT();
|
_GLFW_REQUIRE_INIT();
|
||||||
_glfwPlatformGetWindowFrameSize(window, left, top, right, bottom);
|
_glfw.platform.getWindowFrameSize(window, left, top, right, bottom);
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWAPI void glfwGetWindowContentScale(GLFWwindow* handle,
|
GLFWAPI void glfwGetWindowContentScale(GLFWwindow* handle,
|
||||||
|
@ -699,7 +692,7 @@ GLFWAPI void glfwGetWindowContentScale(GLFWwindow* handle,
|
||||||
*yscale = 0.f;
|
*yscale = 0.f;
|
||||||
|
|
||||||
_GLFW_REQUIRE_INIT();
|
_GLFW_REQUIRE_INIT();
|
||||||
_glfwPlatformGetWindowContentScale(window, xscale, yscale);
|
_glfw.platform.getWindowContentScale(window, xscale, yscale);
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWAPI float glfwGetWindowOpacity(GLFWwindow* handle)
|
GLFWAPI float glfwGetWindowOpacity(GLFWwindow* handle)
|
||||||
|
@ -708,7 +701,7 @@ GLFWAPI float glfwGetWindowOpacity(GLFWwindow* handle)
|
||||||
assert(window != NULL);
|
assert(window != NULL);
|
||||||
|
|
||||||
_GLFW_REQUIRE_INIT_OR_RETURN(1.f);
|
_GLFW_REQUIRE_INIT_OR_RETURN(1.f);
|
||||||
return _glfwPlatformGetWindowOpacity(window);
|
return _glfw.platform.getWindowOpacity(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWAPI void glfwSetWindowOpacity(GLFWwindow* handle, float opacity)
|
GLFWAPI void glfwSetWindowOpacity(GLFWwindow* handle, float opacity)
|
||||||
|
@ -727,7 +720,7 @@ GLFWAPI void glfwSetWindowOpacity(GLFWwindow* handle, float opacity)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_glfwPlatformSetWindowOpacity(window, opacity);
|
_glfw.platform.setWindowOpacity(window, opacity);
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWAPI void glfwIconifyWindow(GLFWwindow* handle)
|
GLFWAPI void glfwIconifyWindow(GLFWwindow* handle)
|
||||||
|
@ -736,7 +729,7 @@ GLFWAPI void glfwIconifyWindow(GLFWwindow* handle)
|
||||||
assert(window != NULL);
|
assert(window != NULL);
|
||||||
|
|
||||||
_GLFW_REQUIRE_INIT();
|
_GLFW_REQUIRE_INIT();
|
||||||
_glfwPlatformIconifyWindow(window);
|
_glfw.platform.iconifyWindow(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWAPI void glfwRestoreWindow(GLFWwindow* handle)
|
GLFWAPI void glfwRestoreWindow(GLFWwindow* handle)
|
||||||
|
@ -745,7 +738,7 @@ GLFWAPI void glfwRestoreWindow(GLFWwindow* handle)
|
||||||
assert(window != NULL);
|
assert(window != NULL);
|
||||||
|
|
||||||
_GLFW_REQUIRE_INIT();
|
_GLFW_REQUIRE_INIT();
|
||||||
_glfwPlatformRestoreWindow(window);
|
_glfw.platform.restoreWindow(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWAPI void glfwMaximizeWindow(GLFWwindow* handle)
|
GLFWAPI void glfwMaximizeWindow(GLFWwindow* handle)
|
||||||
|
@ -758,7 +751,7 @@ GLFWAPI void glfwMaximizeWindow(GLFWwindow* handle)
|
||||||
if (window->monitor)
|
if (window->monitor)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_glfwPlatformMaximizeWindow(window);
|
_glfw.platform.maximizeWindow(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWAPI void glfwShowWindow(GLFWwindow* handle)
|
GLFWAPI void glfwShowWindow(GLFWwindow* handle)
|
||||||
|
@ -771,10 +764,10 @@ GLFWAPI void glfwShowWindow(GLFWwindow* handle)
|
||||||
if (window->monitor)
|
if (window->monitor)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_glfwPlatformShowWindow(window);
|
_glfw.platform.showWindow(window);
|
||||||
|
|
||||||
if (window->focusOnShow)
|
if (window->focusOnShow)
|
||||||
_glfwPlatformFocusWindow(window);
|
_glfw.platform.focusWindow(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWAPI void glfwRequestWindowAttention(GLFWwindow* handle)
|
GLFWAPI void glfwRequestWindowAttention(GLFWwindow* handle)
|
||||||
|
@ -784,7 +777,7 @@ GLFWAPI void glfwRequestWindowAttention(GLFWwindow* handle)
|
||||||
|
|
||||||
_GLFW_REQUIRE_INIT();
|
_GLFW_REQUIRE_INIT();
|
||||||
|
|
||||||
_glfwPlatformRequestWindowAttention(window);
|
_glfw.platform.requestWindowAttention(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWAPI void glfwHideWindow(GLFWwindow* handle)
|
GLFWAPI void glfwHideWindow(GLFWwindow* handle)
|
||||||
|
@ -797,7 +790,7 @@ GLFWAPI void glfwHideWindow(GLFWwindow* handle)
|
||||||
if (window->monitor)
|
if (window->monitor)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_glfwPlatformHideWindow(window);
|
_glfw.platform.hideWindow(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWAPI void glfwFocusWindow(GLFWwindow* handle)
|
GLFWAPI void glfwFocusWindow(GLFWwindow* handle)
|
||||||
|
@ -807,7 +800,7 @@ GLFWAPI void glfwFocusWindow(GLFWwindow* handle)
|
||||||
|
|
||||||
_GLFW_REQUIRE_INIT();
|
_GLFW_REQUIRE_INIT();
|
||||||
|
|
||||||
_glfwPlatformFocusWindow(window);
|
_glfw.platform.focusWindow(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWAPI int glfwGetWindowAttrib(GLFWwindow* handle, int attrib)
|
GLFWAPI int glfwGetWindowAttrib(GLFWwindow* handle, int attrib)
|
||||||
|
@ -820,21 +813,21 @@ GLFWAPI int glfwGetWindowAttrib(GLFWwindow* handle, int attrib)
|
||||||
switch (attrib)
|
switch (attrib)
|
||||||
{
|
{
|
||||||
case GLFW_FOCUSED:
|
case GLFW_FOCUSED:
|
||||||
return _glfwPlatformWindowFocused(window);
|
return _glfw.platform.windowFocused(window);
|
||||||
case GLFW_ICONIFIED:
|
case GLFW_ICONIFIED:
|
||||||
return _glfwPlatformWindowIconified(window);
|
return _glfw.platform.windowIconified(window);
|
||||||
case GLFW_VISIBLE:
|
case GLFW_VISIBLE:
|
||||||
return _glfwPlatformWindowVisible(window);
|
return _glfw.platform.windowVisible(window);
|
||||||
case GLFW_MAXIMIZED:
|
case GLFW_MAXIMIZED:
|
||||||
return _glfwPlatformWindowMaximized(window);
|
return _glfw.platform.windowMaximized(window);
|
||||||
case GLFW_HOVERED:
|
case GLFW_HOVERED:
|
||||||
return _glfwPlatformWindowHovered(window);
|
return _glfw.platform.windowHovered(window);
|
||||||
case GLFW_FOCUS_ON_SHOW:
|
case GLFW_FOCUS_ON_SHOW:
|
||||||
return window->focusOnShow;
|
return window->focusOnShow;
|
||||||
case GLFW_MOUSE_PASSTHROUGH:
|
case GLFW_MOUSE_PASSTHROUGH:
|
||||||
return window->mousePassthrough;
|
return window->mousePassthrough;
|
||||||
case GLFW_TRANSPARENT_FRAMEBUFFER:
|
case GLFW_TRANSPARENT_FRAMEBUFFER:
|
||||||
return _glfwPlatformFramebufferTransparent(window);
|
return _glfw.platform.framebufferTransparent(window);
|
||||||
case GLFW_RESIZABLE:
|
case GLFW_RESIZABLE:
|
||||||
return window->resizable;
|
return window->resizable;
|
||||||
case GLFW_DECORATED:
|
case GLFW_DECORATED:
|
||||||
|
@ -882,35 +875,41 @@ GLFWAPI void glfwSetWindowAttrib(GLFWwindow* handle, int attrib, int value)
|
||||||
|
|
||||||
value = value ? GLFW_TRUE : GLFW_FALSE;
|
value = value ? GLFW_TRUE : GLFW_FALSE;
|
||||||
|
|
||||||
if (attrib == GLFW_AUTO_ICONIFY)
|
switch (attrib)
|
||||||
window->autoIconify = value;
|
|
||||||
else if (attrib == GLFW_RESIZABLE)
|
|
||||||
{
|
{
|
||||||
window->resizable = value;
|
case GLFW_AUTO_ICONIFY:
|
||||||
if (!window->monitor)
|
window->autoIconify = value;
|
||||||
_glfwPlatformSetWindowResizable(window, value);
|
return;
|
||||||
|
|
||||||
|
case GLFW_RESIZABLE:
|
||||||
|
window->resizable = value;
|
||||||
|
if (!window->monitor)
|
||||||
|
_glfw.platform.setWindowResizable(window, value);
|
||||||
|
return;
|
||||||
|
|
||||||
|
case GLFW_DECORATED:
|
||||||
|
window->decorated = value;
|
||||||
|
if (!window->monitor)
|
||||||
|
_glfw.platform.setWindowDecorated(window, value);
|
||||||
|
return;
|
||||||
|
|
||||||
|
case GLFW_FLOATING:
|
||||||
|
window->floating = value;
|
||||||
|
if (!window->monitor)
|
||||||
|
_glfw.platform.setWindowFloating(window, value);
|
||||||
|
return;
|
||||||
|
|
||||||
|
case GLFW_FOCUS_ON_SHOW:
|
||||||
|
window->focusOnShow = value;
|
||||||
|
return;
|
||||||
|
|
||||||
|
case GLFW_MOUSE_PASSTHROUGH:
|
||||||
|
window->mousePassthrough = value;
|
||||||
|
_glfw.platform.setWindowMousePassthrough(window, value);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else if (attrib == GLFW_DECORATED)
|
|
||||||
{
|
_glfwInputError(GLFW_INVALID_ENUM, "Invalid window attribute 0x%08X", attrib);
|
||||||
window->decorated = value;
|
|
||||||
if (!window->monitor)
|
|
||||||
_glfwPlatformSetWindowDecorated(window, value);
|
|
||||||
}
|
|
||||||
else if (attrib == GLFW_FLOATING)
|
|
||||||
{
|
|
||||||
window->floating = value;
|
|
||||||
if (!window->monitor)
|
|
||||||
_glfwPlatformSetWindowFloating(window, value);
|
|
||||||
}
|
|
||||||
else if (attrib == GLFW_FOCUS_ON_SHOW)
|
|
||||||
window->focusOnShow = value;
|
|
||||||
else if (attrib == GLFW_MOUSE_PASSTHROUGH)
|
|
||||||
{
|
|
||||||
window->mousePassthrough = value;
|
|
||||||
_glfwPlatformSetWindowMousePassthrough(window, value);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
_glfwInputError(GLFW_INVALID_ENUM, "Invalid window attribute 0x%08X", attrib);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWAPI GLFWmonitor* glfwGetWindowMonitor(GLFWwindow* handle)
|
GLFWAPI GLFWmonitor* glfwGetWindowMonitor(GLFWwindow* handle)
|
||||||
|
@ -956,9 +955,9 @@ GLFWAPI void glfwSetWindowMonitor(GLFWwindow* wh,
|
||||||
window->videoMode.height = height;
|
window->videoMode.height = height;
|
||||||
window->videoMode.refreshRate = refreshRate;
|
window->videoMode.refreshRate = refreshRate;
|
||||||
|
|
||||||
_glfwPlatformSetWindowMonitor(window, monitor,
|
_glfw.platform.setWindowMonitor(window, monitor,
|
||||||
xpos, ypos, width, height,
|
xpos, ypos, width, height,
|
||||||
refreshRate);
|
refreshRate);
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWAPI void glfwSetWindowUserPointer(GLFWwindow* handle, void* pointer)
|
GLFWAPI void glfwSetWindowUserPointer(GLFWwindow* handle, void* pointer)
|
||||||
|
@ -986,7 +985,7 @@ GLFWAPI GLFWwindowposfun glfwSetWindowPosCallback(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.pos, cbfun);
|
_GLFW_SWAP(GLFWwindowposfun, window->callbacks.pos, cbfun);
|
||||||
return cbfun;
|
return cbfun;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -997,7 +996,7 @@ GLFWAPI GLFWwindowsizefun glfwSetWindowSizeCallback(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.size, cbfun);
|
_GLFW_SWAP(GLFWwindowsizefun, window->callbacks.size, cbfun);
|
||||||
return cbfun;
|
return cbfun;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1008,7 +1007,7 @@ GLFWAPI GLFWwindowclosefun glfwSetWindowCloseCallback(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.close, cbfun);
|
_GLFW_SWAP(GLFWwindowclosefun, window->callbacks.close, cbfun);
|
||||||
return cbfun;
|
return cbfun;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1019,7 +1018,7 @@ GLFWAPI GLFWwindowrefreshfun glfwSetWindowRefreshCallback(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.refresh, cbfun);
|
_GLFW_SWAP(GLFWwindowrefreshfun, window->callbacks.refresh, cbfun);
|
||||||
return cbfun;
|
return cbfun;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1030,7 +1029,7 @@ GLFWAPI GLFWwindowfocusfun glfwSetWindowFocusCallback(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.focus, cbfun);
|
_GLFW_SWAP(GLFWwindowfocusfun, window->callbacks.focus, cbfun);
|
||||||
return cbfun;
|
return cbfun;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1041,7 +1040,7 @@ GLFWAPI GLFWwindowiconifyfun glfwSetWindowIconifyCallback(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.iconify, cbfun);
|
_GLFW_SWAP(GLFWwindowiconifyfun, window->callbacks.iconify, cbfun);
|
||||||
return cbfun;
|
return cbfun;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1052,7 +1051,7 @@ GLFWAPI GLFWwindowmaximizefun glfwSetWindowMaximizeCallback(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.maximize, cbfun);
|
_GLFW_SWAP(GLFWwindowmaximizefun, window->callbacks.maximize, cbfun);
|
||||||
return cbfun;
|
return cbfun;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1063,7 +1062,7 @@ GLFWAPI GLFWframebuffersizefun glfwSetFramebufferSizeCallback(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.fbsize, cbfun);
|
_GLFW_SWAP(GLFWframebuffersizefun, window->callbacks.fbsize, cbfun);
|
||||||
return cbfun;
|
return cbfun;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1074,20 +1073,20 @@ GLFWAPI GLFWwindowcontentscalefun glfwSetWindowContentScaleCallback(GLFWwindow*
|
||||||
assert(window != NULL);
|
assert(window != NULL);
|
||||||
|
|
||||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||||
_GLFW_SWAP_POINTERS(window->callbacks.scale, cbfun);
|
_GLFW_SWAP(GLFWwindowcontentscalefun, window->callbacks.scale, cbfun);
|
||||||
return cbfun;
|
return cbfun;
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWAPI void glfwPollEvents(void)
|
GLFWAPI void glfwPollEvents(void)
|
||||||
{
|
{
|
||||||
_GLFW_REQUIRE_INIT();
|
_GLFW_REQUIRE_INIT();
|
||||||
_glfwPlatformPollEvents();
|
_glfw.platform.pollEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWAPI void glfwWaitEvents(void)
|
GLFWAPI void glfwWaitEvents(void)
|
||||||
{
|
{
|
||||||
_GLFW_REQUIRE_INIT();
|
_GLFW_REQUIRE_INIT();
|
||||||
_glfwPlatformWaitEvents();
|
_glfw.platform.waitEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWAPI void glfwWaitEventsTimeout(double timeout)
|
GLFWAPI void glfwWaitEventsTimeout(double timeout)
|
||||||
|
@ -1103,12 +1102,12 @@ GLFWAPI void glfwWaitEventsTimeout(double timeout)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_glfwPlatformWaitEventsTimeout(timeout);
|
_glfw.platform.waitEventsTimeout(timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWAPI void glfwPostEmptyEvent(void)
|
GLFWAPI void glfwPostEmptyEvent(void)
|
||||||
{
|
{
|
||||||
_GLFW_REQUIRE_INIT();
|
_GLFW_REQUIRE_INIT();
|
||||||
_glfwPlatformPostEmptyEvent();
|
_glfw.platform.postEmptyEvent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
1117
src/wl_init.c
1117
src/wl_init.c
File diff suppressed because it is too large
Load Diff
|
@ -34,8 +34,10 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
|
#include "wayland-client-protocol.h"
|
||||||
|
|
||||||
static void outputHandleGeometry(void* data,
|
|
||||||
|
static void outputHandleGeometry(void* userData,
|
||||||
struct wl_output* output,
|
struct wl_output* output,
|
||||||
int32_t x,
|
int32_t x,
|
||||||
int32_t y,
|
int32_t y,
|
||||||
|
@ -46,7 +48,7 @@ static void outputHandleGeometry(void* data,
|
||||||
const char* model,
|
const char* model,
|
||||||
int32_t transform)
|
int32_t transform)
|
||||||
{
|
{
|
||||||
struct _GLFWmonitor *monitor = data;
|
struct _GLFWmonitor* monitor = userData;
|
||||||
|
|
||||||
monitor->wl.x = x;
|
monitor->wl.x = x;
|
||||||
monitor->wl.y = y;
|
monitor->wl.y = y;
|
||||||
|
@ -56,14 +58,14 @@ static void outputHandleGeometry(void* data,
|
||||||
snprintf(monitor->name, sizeof(monitor->name), "%s %s", make, model);
|
snprintf(monitor->name, sizeof(monitor->name), "%s %s", make, model);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void outputHandleMode(void* data,
|
static void outputHandleMode(void* userData,
|
||||||
struct wl_output* output,
|
struct wl_output* output,
|
||||||
uint32_t flags,
|
uint32_t flags,
|
||||||
int32_t width,
|
int32_t width,
|
||||||
int32_t height,
|
int32_t height,
|
||||||
int32_t refresh)
|
int32_t refresh)
|
||||||
{
|
{
|
||||||
struct _GLFWmonitor *monitor = data;
|
struct _GLFWmonitor* monitor = userData;
|
||||||
GLFWvidmode mode;
|
GLFWvidmode mode;
|
||||||
|
|
||||||
mode.width = width;
|
mode.width = width;
|
||||||
|
@ -75,16 +77,16 @@ static void outputHandleMode(void* data,
|
||||||
|
|
||||||
monitor->modeCount++;
|
monitor->modeCount++;
|
||||||
monitor->modes =
|
monitor->modes =
|
||||||
realloc(monitor->modes, monitor->modeCount * sizeof(GLFWvidmode));
|
_glfw_realloc(monitor->modes, monitor->modeCount * sizeof(GLFWvidmode));
|
||||||
monitor->modes[monitor->modeCount - 1] = mode;
|
monitor->modes[monitor->modeCount - 1] = mode;
|
||||||
|
|
||||||
if (flags & WL_OUTPUT_MODE_CURRENT)
|
if (flags & WL_OUTPUT_MODE_CURRENT)
|
||||||
monitor->wl.currentMode = monitor->modeCount - 1;
|
monitor->wl.currentMode = monitor->modeCount - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void outputHandleDone(void* data, struct wl_output* output)
|
static void outputHandleDone(void* userData, struct wl_output* output)
|
||||||
{
|
{
|
||||||
struct _GLFWmonitor *monitor = data;
|
struct _GLFWmonitor* monitor = userData;
|
||||||
|
|
||||||
if (monitor->widthMM <= 0 || monitor->heightMM <= 0)
|
if (monitor->widthMM <= 0 || monitor->heightMM <= 0)
|
||||||
{
|
{
|
||||||
|
@ -97,16 +99,17 @@ static void outputHandleDone(void* data, struct wl_output* output)
|
||||||
_glfwInputMonitor(monitor, GLFW_CONNECTED, _GLFW_INSERT_LAST);
|
_glfwInputMonitor(monitor, GLFW_CONNECTED, _GLFW_INSERT_LAST);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void outputHandleScale(void* data,
|
static void outputHandleScale(void* userData,
|
||||||
struct wl_output* output,
|
struct wl_output* output,
|
||||||
int32_t factor)
|
int32_t factor)
|
||||||
{
|
{
|
||||||
struct _GLFWmonitor *monitor = data;
|
struct _GLFWmonitor* monitor = userData;
|
||||||
|
|
||||||
monitor->wl.scale = factor;
|
monitor->wl.scale = factor;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct wl_output_listener outputListener = {
|
static const struct wl_output_listener outputListener =
|
||||||
|
{
|
||||||
outputHandleGeometry,
|
outputHandleGeometry,
|
||||||
outputHandleMode,
|
outputHandleMode,
|
||||||
outputHandleDone,
|
outputHandleDone,
|
||||||
|
@ -120,8 +123,8 @@ static const struct wl_output_listener outputListener = {
|
||||||
|
|
||||||
void _glfwAddOutputWayland(uint32_t name, uint32_t version)
|
void _glfwAddOutputWayland(uint32_t name, uint32_t version)
|
||||||
{
|
{
|
||||||
_GLFWmonitor *monitor;
|
_GLFWmonitor* monitor;
|
||||||
struct wl_output *output;
|
struct wl_output* output;
|
||||||
|
|
||||||
if (version < 2)
|
if (version < 2)
|
||||||
{
|
{
|
||||||
|
@ -155,13 +158,13 @@ void _glfwAddOutputWayland(uint32_t name, uint32_t version)
|
||||||
////// GLFW platform API //////
|
////// GLFW platform API //////
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void _glfwPlatformFreeMonitor(_GLFWmonitor* monitor)
|
void _glfwFreeMonitorWayland(_GLFWmonitor* monitor)
|
||||||
{
|
{
|
||||||
if (monitor->wl.output)
|
if (monitor->wl.output)
|
||||||
wl_output_destroy(monitor->wl.output);
|
wl_output_destroy(monitor->wl.output);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos)
|
void _glfwGetMonitorPosWayland(_GLFWmonitor* monitor, int* xpos, int* ypos)
|
||||||
{
|
{
|
||||||
if (xpos)
|
if (xpos)
|
||||||
*xpos = monitor->wl.x;
|
*xpos = monitor->wl.x;
|
||||||
|
@ -169,8 +172,8 @@ void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos)
|
||||||
*ypos = monitor->wl.y;
|
*ypos = monitor->wl.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformGetMonitorContentScale(_GLFWmonitor* monitor,
|
void _glfwGetMonitorContentScaleWayland(_GLFWmonitor* monitor,
|
||||||
float* xscale, float* yscale)
|
float* xscale, float* yscale)
|
||||||
{
|
{
|
||||||
if (xscale)
|
if (xscale)
|
||||||
*xscale = (float) monitor->wl.scale;
|
*xscale = (float) monitor->wl.scale;
|
||||||
|
@ -178,9 +181,9 @@ void _glfwPlatformGetMonitorContentScale(_GLFWmonitor* monitor,
|
||||||
*yscale = (float) monitor->wl.scale;
|
*yscale = (float) monitor->wl.scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformGetMonitorWorkarea(_GLFWmonitor* monitor,
|
void _glfwGetMonitorWorkareaWayland(_GLFWmonitor* monitor,
|
||||||
int* xpos, int* ypos,
|
int* xpos, int* ypos,
|
||||||
int* width, int* height)
|
int* width, int* height)
|
||||||
{
|
{
|
||||||
if (xpos)
|
if (xpos)
|
||||||
*xpos = monitor->wl.x;
|
*xpos = monitor->wl.x;
|
||||||
|
@ -192,26 +195,25 @@ void _glfwPlatformGetMonitorWorkarea(_GLFWmonitor* monitor,
|
||||||
*height = monitor->modes[monitor->wl.currentMode].height;
|
*height = monitor->modes[monitor->wl.currentMode].height;
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* found)
|
GLFWvidmode* _glfwGetVideoModesWayland(_GLFWmonitor* monitor, int* found)
|
||||||
{
|
{
|
||||||
*found = monitor->modeCount;
|
*found = monitor->modeCount;
|
||||||
return monitor->modes;
|
return monitor->modes;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode)
|
void _glfwGetVideoModeWayland(_GLFWmonitor* monitor, GLFWvidmode* mode)
|
||||||
{
|
{
|
||||||
*mode = monitor->modes[monitor->wl.currentMode];
|
*mode = monitor->modes[monitor->wl.currentMode];
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWbool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
|
GLFWbool _glfwGetGammaRampWayland(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
|
||||||
{
|
{
|
||||||
_glfwInputError(GLFW_FEATURE_UNAVAILABLE,
|
_glfwInputError(GLFW_FEATURE_UNAVAILABLE,
|
||||||
"Wayland: Gamma ramp access is not available");
|
"Wayland: Gamma ramp access is not available");
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor,
|
void _glfwSetGammaRampWayland(_GLFWmonitor* monitor, const GLFWgammaramp* ramp)
|
||||||
const GLFWgammaramp* ramp)
|
|
||||||
{
|
{
|
||||||
_glfwInputError(GLFW_FEATURE_UNAVAILABLE,
|
_glfwInputError(GLFW_FEATURE_UNAVAILABLE,
|
||||||
"Wayland: Gamma ramp access is not available");
|
"Wayland: Gamma ramp access is not available");
|
||||||
|
|
|
@ -24,12 +24,9 @@
|
||||||
//
|
//
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
#include <wayland-client.h>
|
#include <wayland-client-core.h>
|
||||||
#include <xkbcommon/xkbcommon.h>
|
#include <xkbcommon/xkbcommon.h>
|
||||||
#ifdef HAVE_XKBCOMMON_COMPOSE_H
|
|
||||||
#include <xkbcommon/xkbcommon-compose.h>
|
#include <xkbcommon/xkbcommon-compose.h>
|
||||||
#endif
|
|
||||||
#include <dlfcn.h>
|
|
||||||
|
|
||||||
typedef VkFlags VkWaylandSurfaceCreateFlagsKHR;
|
typedef VkFlags VkWaylandSurfaceCreateFlagsKHR;
|
||||||
|
|
||||||
|
@ -45,33 +42,91 @@ typedef struct VkWaylandSurfaceCreateInfoKHR
|
||||||
typedef VkResult (APIENTRY *PFN_vkCreateWaylandSurfaceKHR)(VkInstance,const VkWaylandSurfaceCreateInfoKHR*,const VkAllocationCallbacks*,VkSurfaceKHR*);
|
typedef VkResult (APIENTRY *PFN_vkCreateWaylandSurfaceKHR)(VkInstance,const VkWaylandSurfaceCreateInfoKHR*,const VkAllocationCallbacks*,VkSurfaceKHR*);
|
||||||
typedef VkBool32 (APIENTRY *PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR)(VkPhysicalDevice,uint32_t,struct wl_display*);
|
typedef VkBool32 (APIENTRY *PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR)(VkPhysicalDevice,uint32_t,struct wl_display*);
|
||||||
|
|
||||||
#include "posix_thread.h"
|
|
||||||
#include "posix_time.h"
|
|
||||||
#ifdef __linux__
|
|
||||||
#include "linux_joystick.h"
|
|
||||||
#else
|
|
||||||
#include "null_joystick.h"
|
|
||||||
#endif
|
|
||||||
#include "xkb_unicode.h"
|
#include "xkb_unicode.h"
|
||||||
|
#include "posix_poll.h"
|
||||||
|
|
||||||
#include "wayland-xdg-shell-client-protocol.h"
|
typedef int (* PFN_wl_display_flush)(struct wl_display* display);
|
||||||
#include "wayland-xdg-decoration-client-protocol.h"
|
typedef void (* PFN_wl_display_cancel_read)(struct wl_display* display);
|
||||||
#include "wayland-viewporter-client-protocol.h"
|
typedef int (* PFN_wl_display_dispatch_pending)(struct wl_display* display);
|
||||||
#include "wayland-relative-pointer-unstable-v1-client-protocol.h"
|
typedef int (* PFN_wl_display_read_events)(struct wl_display* display);
|
||||||
#include "wayland-pointer-constraints-unstable-v1-client-protocol.h"
|
typedef struct wl_display* (* PFN_wl_display_connect)(const char*);
|
||||||
#include "wayland-idle-inhibit-unstable-v1-client-protocol.h"
|
typedef void (* PFN_wl_display_disconnect)(struct wl_display*);
|
||||||
|
typedef int (* PFN_wl_display_roundtrip)(struct wl_display*);
|
||||||
|
typedef int (* PFN_wl_display_get_fd)(struct wl_display*);
|
||||||
|
typedef int (* PFN_wl_display_prepare_read)(struct wl_display*);
|
||||||
|
typedef void (* PFN_wl_proxy_marshal)(struct wl_proxy*,uint32_t,...);
|
||||||
|
typedef int (* PFN_wl_proxy_add_listener)(struct wl_proxy*,void(**)(void),void*);
|
||||||
|
typedef void (* PFN_wl_proxy_destroy)(struct wl_proxy*);
|
||||||
|
typedef struct wl_proxy* (* PFN_wl_proxy_marshal_constructor)(struct wl_proxy*,uint32_t,const struct wl_interface*,...);
|
||||||
|
typedef struct wl_proxy* (* PFN_wl_proxy_marshal_constructor_versioned)(struct wl_proxy*,uint32_t,const struct wl_interface*,uint32_t,...);
|
||||||
|
typedef void* (* PFN_wl_proxy_get_user_data)(struct wl_proxy*);
|
||||||
|
typedef void (* PFN_wl_proxy_set_user_data)(struct wl_proxy*,void*);
|
||||||
|
typedef uint32_t (* PFN_wl_proxy_get_version)(struct wl_proxy*);
|
||||||
|
typedef struct wl_proxy* (* PFN_wl_proxy_marshal_flags)(struct wl_proxy*,uint32_t,const struct wl_interface*,uint32_t,uint32_t,...);
|
||||||
|
#define wl_display_flush _glfw.wl.client.display_flush
|
||||||
|
#define wl_display_cancel_read _glfw.wl.client.display_cancel_read
|
||||||
|
#define wl_display_dispatch_pending _glfw.wl.client.display_dispatch_pending
|
||||||
|
#define wl_display_read_events _glfw.wl.client.display_read_events
|
||||||
|
#define wl_display_disconnect _glfw.wl.client.display_disconnect
|
||||||
|
#define wl_display_roundtrip _glfw.wl.client.display_roundtrip
|
||||||
|
#define wl_display_get_fd _glfw.wl.client.display_get_fd
|
||||||
|
#define wl_display_prepare_read _glfw.wl.client.display_prepare_read
|
||||||
|
#define wl_proxy_marshal _glfw.wl.client.proxy_marshal
|
||||||
|
#define wl_proxy_add_listener _glfw.wl.client.proxy_add_listener
|
||||||
|
#define wl_proxy_destroy _glfw.wl.client.proxy_destroy
|
||||||
|
#define wl_proxy_marshal_constructor _glfw.wl.client.proxy_marshal_constructor
|
||||||
|
#define wl_proxy_marshal_constructor_versioned _glfw.wl.client.proxy_marshal_constructor_versioned
|
||||||
|
#define wl_proxy_get_user_data _glfw.wl.client.proxy_get_user_data
|
||||||
|
#define wl_proxy_set_user_data _glfw.wl.client.proxy_set_user_data
|
||||||
|
#define wl_proxy_get_version _glfw.wl.client.proxy_get_version
|
||||||
|
#define wl_proxy_marshal_flags _glfw.wl.client.proxy_marshal_flags
|
||||||
|
|
||||||
#define _glfw_dlopen(name) dlopen(name, RTLD_LAZY | RTLD_LOCAL)
|
struct wl_shm;
|
||||||
#define _glfw_dlclose(handle) dlclose(handle)
|
|
||||||
#define _glfw_dlsym(handle, name) dlsym(handle, name)
|
|
||||||
|
|
||||||
#define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowWayland wl
|
#define wl_display_interface _glfw_wl_display_interface
|
||||||
#define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryWayland wl
|
#define wl_subcompositor_interface _glfw_wl_subcompositor_interface
|
||||||
#define _GLFW_PLATFORM_MONITOR_STATE _GLFWmonitorWayland wl
|
#define wl_compositor_interface _glfw_wl_compositor_interface
|
||||||
#define _GLFW_PLATFORM_CURSOR_STATE _GLFWcursorWayland wl
|
#define wl_shm_interface _glfw_wl_shm_interface
|
||||||
|
#define wl_data_device_manager_interface _glfw_wl_data_device_manager_interface
|
||||||
|
#define wl_shell_interface _glfw_wl_shell_interface
|
||||||
|
#define wl_buffer_interface _glfw_wl_buffer_interface
|
||||||
|
#define wl_callback_interface _glfw_wl_callback_interface
|
||||||
|
#define wl_data_device_interface _glfw_wl_data_device_interface
|
||||||
|
#define wl_data_offer_interface _glfw_wl_data_offer_interface
|
||||||
|
#define wl_data_source_interface _glfw_wl_data_source_interface
|
||||||
|
#define wl_keyboard_interface _glfw_wl_keyboard_interface
|
||||||
|
#define wl_output_interface _glfw_wl_output_interface
|
||||||
|
#define wl_pointer_interface _glfw_wl_pointer_interface
|
||||||
|
#define wl_region_interface _glfw_wl_region_interface
|
||||||
|
#define wl_registry_interface _glfw_wl_registry_interface
|
||||||
|
#define wl_seat_interface _glfw_wl_seat_interface
|
||||||
|
#define wl_shell_surface_interface _glfw_wl_shell_surface_interface
|
||||||
|
#define wl_shm_pool_interface _glfw_wl_shm_pool_interface
|
||||||
|
#define wl_subsurface_interface _glfw_wl_subsurface_interface
|
||||||
|
#define wl_surface_interface _glfw_wl_surface_interface
|
||||||
|
#define wl_touch_interface _glfw_wl_touch_interface
|
||||||
|
#define zwp_idle_inhibitor_v1_interface _glfw_zwp_idle_inhibitor_v1_interface
|
||||||
|
#define zwp_idle_inhibit_manager_v1_interface _glfw_zwp_idle_inhibit_manager_v1_interface
|
||||||
|
#define zwp_confined_pointer_v1_interface _glfw_zwp_confined_pointer_v1_interface
|
||||||
|
#define zwp_locked_pointer_v1_interface _glfw_zwp_locked_pointer_v1_interface
|
||||||
|
#define zwp_pointer_constraints_v1_interface _glfw_zwp_pointer_constraints_v1_interface
|
||||||
|
#define zwp_relative_pointer_v1_interface _glfw_zwp_relative_pointer_v1_interface
|
||||||
|
#define zwp_relative_pointer_manager_v1_interface _glfw_zwp_relative_pointer_manager_v1_interface
|
||||||
|
#define wp_viewport_interface _glfw_wp_viewport_interface
|
||||||
|
#define wp_viewporter_interface _glfw_wp_viewporter_interface
|
||||||
|
#define xdg_toplevel_interface _glfw_xdg_toplevel_interface
|
||||||
|
#define zxdg_toplevel_decoration_v1_interface _glfw_zxdg_toplevel_decoration_v1_interface
|
||||||
|
#define zxdg_decoration_manager_v1_interface _glfw_zxdg_decoration_manager_v1_interface
|
||||||
|
#define xdg_popup_interface _glfw_xdg_popup_interface
|
||||||
|
#define xdg_positioner_interface _glfw_xdg_positioner_interface
|
||||||
|
#define xdg_surface_interface _glfw_xdg_surface_interface
|
||||||
|
#define xdg_toplevel_interface _glfw_xdg_toplevel_interface
|
||||||
|
#define xdg_wm_base_interface _glfw_xdg_wm_base_interface
|
||||||
|
|
||||||
#define _GLFW_PLATFORM_CONTEXT_STATE struct { int dummyContext; }
|
#define GLFW_WAYLAND_WINDOW_STATE _GLFWwindowWayland wl;
|
||||||
#define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE struct { int dummyLibraryContext; }
|
#define GLFW_WAYLAND_LIBRARY_WINDOW_STATE _GLFWlibraryWayland wl;
|
||||||
|
#define GLFW_WAYLAND_MONITOR_STATE _GLFWmonitorWayland wl;
|
||||||
|
#define GLFW_WAYLAND_CURSOR_STATE _GLFWcursorWayland wl;
|
||||||
|
|
||||||
struct wl_cursor_image {
|
struct wl_cursor_image {
|
||||||
uint32_t width;
|
uint32_t width;
|
||||||
|
@ -107,24 +162,27 @@ typedef struct xkb_keymap* (* PFN_xkb_keymap_new_from_string)(struct xkb_context
|
||||||
typedef void (* PFN_xkb_keymap_unref)(struct xkb_keymap*);
|
typedef void (* PFN_xkb_keymap_unref)(struct xkb_keymap*);
|
||||||
typedef xkb_mod_index_t (* PFN_xkb_keymap_mod_get_index)(struct xkb_keymap*, const char*);
|
typedef xkb_mod_index_t (* PFN_xkb_keymap_mod_get_index)(struct xkb_keymap*, const char*);
|
||||||
typedef int (* PFN_xkb_keymap_key_repeats)(struct xkb_keymap*, xkb_keycode_t);
|
typedef int (* PFN_xkb_keymap_key_repeats)(struct xkb_keymap*, xkb_keycode_t);
|
||||||
|
typedef int (* PFN_xkb_keymap_key_get_syms_by_level)(struct xkb_keymap*,xkb_keycode_t,xkb_layout_index_t,xkb_level_index_t,const xkb_keysym_t**);
|
||||||
typedef struct xkb_state* (* PFN_xkb_state_new)(struct xkb_keymap*);
|
typedef struct xkb_state* (* PFN_xkb_state_new)(struct xkb_keymap*);
|
||||||
typedef void (* PFN_xkb_state_unref)(struct xkb_state*);
|
typedef void (* PFN_xkb_state_unref)(struct xkb_state*);
|
||||||
typedef int (* PFN_xkb_state_key_get_syms)(struct xkb_state*, xkb_keycode_t, const xkb_keysym_t**);
|
typedef int (* PFN_xkb_state_key_get_syms)(struct xkb_state*, xkb_keycode_t, const xkb_keysym_t**);
|
||||||
typedef enum xkb_state_component (* PFN_xkb_state_update_mask)(struct xkb_state*, xkb_mod_mask_t, xkb_mod_mask_t, xkb_mod_mask_t, xkb_layout_index_t, xkb_layout_index_t, xkb_layout_index_t);
|
typedef enum xkb_state_component (* PFN_xkb_state_update_mask)(struct xkb_state*, xkb_mod_mask_t, xkb_mod_mask_t, xkb_mod_mask_t, xkb_layout_index_t, xkb_layout_index_t, xkb_layout_index_t);
|
||||||
typedef xkb_mod_mask_t (* PFN_xkb_state_serialize_mods)(struct xkb_state*, enum xkb_state_component);
|
typedef xkb_mod_mask_t (* PFN_xkb_state_serialize_mods)(struct xkb_state*, enum xkb_state_component);
|
||||||
|
typedef xkb_layout_index_t (* PFN_xkb_state_key_get_layout)(struct xkb_state*,xkb_keycode_t);
|
||||||
#define xkb_context_new _glfw.wl.xkb.context_new
|
#define xkb_context_new _glfw.wl.xkb.context_new
|
||||||
#define xkb_context_unref _glfw.wl.xkb.context_unref
|
#define xkb_context_unref _glfw.wl.xkb.context_unref
|
||||||
#define xkb_keymap_new_from_string _glfw.wl.xkb.keymap_new_from_string
|
#define xkb_keymap_new_from_string _glfw.wl.xkb.keymap_new_from_string
|
||||||
#define xkb_keymap_unref _glfw.wl.xkb.keymap_unref
|
#define xkb_keymap_unref _glfw.wl.xkb.keymap_unref
|
||||||
#define xkb_keymap_mod_get_index _glfw.wl.xkb.keymap_mod_get_index
|
#define xkb_keymap_mod_get_index _glfw.wl.xkb.keymap_mod_get_index
|
||||||
#define xkb_keymap_key_repeats _glfw.wl.xkb.keymap_key_repeats
|
#define xkb_keymap_key_repeats _glfw.wl.xkb.keymap_key_repeats
|
||||||
|
#define xkb_keymap_key_get_syms_by_level _glfw.wl.xkb.keymap_key_get_syms_by_level
|
||||||
#define xkb_state_new _glfw.wl.xkb.state_new
|
#define xkb_state_new _glfw.wl.xkb.state_new
|
||||||
#define xkb_state_unref _glfw.wl.xkb.state_unref
|
#define xkb_state_unref _glfw.wl.xkb.state_unref
|
||||||
#define xkb_state_key_get_syms _glfw.wl.xkb.state_key_get_syms
|
#define xkb_state_key_get_syms _glfw.wl.xkb.state_key_get_syms
|
||||||
#define xkb_state_update_mask _glfw.wl.xkb.state_update_mask
|
#define xkb_state_update_mask _glfw.wl.xkb.state_update_mask
|
||||||
#define xkb_state_serialize_mods _glfw.wl.xkb.state_serialize_mods
|
#define xkb_state_serialize_mods _glfw.wl.xkb.state_serialize_mods
|
||||||
|
#define xkb_state_key_get_layout _glfw.wl.xkb.state_key_get_layout
|
||||||
|
|
||||||
#ifdef HAVE_XKBCOMMON_COMPOSE_H
|
|
||||||
typedef struct xkb_compose_table* (* PFN_xkb_compose_table_new_from_locale)(struct xkb_context*, const char*, enum xkb_compose_compile_flags);
|
typedef struct xkb_compose_table* (* PFN_xkb_compose_table_new_from_locale)(struct xkb_context*, const char*, enum xkb_compose_compile_flags);
|
||||||
typedef void (* PFN_xkb_compose_table_unref)(struct xkb_compose_table*);
|
typedef void (* PFN_xkb_compose_table_unref)(struct xkb_compose_table*);
|
||||||
typedef struct xkb_compose_state* (* PFN_xkb_compose_state_new)(struct xkb_compose_table*, enum xkb_compose_state_flags);
|
typedef struct xkb_compose_state* (* PFN_xkb_compose_state_new)(struct xkb_compose_table*, enum xkb_compose_state_flags);
|
||||||
|
@ -139,7 +197,6 @@ typedef xkb_keysym_t (* PFN_xkb_compose_state_get_one_sym)(struct xkb_compose_st
|
||||||
#define xkb_compose_state_feed _glfw.wl.xkb.compose_state_feed
|
#define xkb_compose_state_feed _glfw.wl.xkb.compose_state_feed
|
||||||
#define xkb_compose_state_get_status _glfw.wl.xkb.compose_state_get_status
|
#define xkb_compose_state_get_status _glfw.wl.xkb.compose_state_get_status
|
||||||
#define xkb_compose_state_get_one_sym _glfw.wl.xkb.compose_state_get_one_sym
|
#define xkb_compose_state_get_one_sym _glfw.wl.xkb.compose_state_get_one_sym
|
||||||
#endif
|
|
||||||
|
|
||||||
#define _GLFW_DECORATION_WIDTH 4
|
#define _GLFW_DECORATION_WIDTH 4
|
||||||
#define _GLFW_DECORATION_TOP 24
|
#define _GLFW_DECORATION_TOP 24
|
||||||
|
@ -153,7 +210,6 @@ typedef enum _GLFWdecorationSideWayland
|
||||||
leftDecoration,
|
leftDecoration,
|
||||||
rightDecoration,
|
rightDecoration,
|
||||||
bottomDecoration,
|
bottomDecoration,
|
||||||
|
|
||||||
} _GLFWdecorationSideWayland;
|
} _GLFWdecorationSideWayland;
|
||||||
|
|
||||||
typedef struct _GLFWdecorationWayland
|
typedef struct _GLFWdecorationWayland
|
||||||
|
@ -161,9 +217,15 @@ typedef struct _GLFWdecorationWayland
|
||||||
struct wl_surface* surface;
|
struct wl_surface* surface;
|
||||||
struct wl_subsurface* subsurface;
|
struct wl_subsurface* subsurface;
|
||||||
struct wp_viewport* viewport;
|
struct wp_viewport* viewport;
|
||||||
|
|
||||||
} _GLFWdecorationWayland;
|
} _GLFWdecorationWayland;
|
||||||
|
|
||||||
|
typedef struct _GLFWofferWayland
|
||||||
|
{
|
||||||
|
struct wl_data_offer* offer;
|
||||||
|
GLFWbool text_plain_utf8;
|
||||||
|
GLFWbool text_uri_list;
|
||||||
|
} _GLFWofferWayland;
|
||||||
|
|
||||||
// Wayland-specific per-window data
|
// Wayland-specific per-window data
|
||||||
//
|
//
|
||||||
typedef struct _GLFWwindowWayland
|
typedef struct _GLFWwindowWayland
|
||||||
|
@ -210,7 +272,6 @@ typedef struct _GLFWwindowWayland
|
||||||
_GLFWdecorationWayland top, left, right, bottom;
|
_GLFWdecorationWayland top, left, right, bottom;
|
||||||
int focus;
|
int focus;
|
||||||
} decorations;
|
} decorations;
|
||||||
|
|
||||||
} _GLFWwindowWayland;
|
} _GLFWwindowWayland;
|
||||||
|
|
||||||
// Wayland-specific global data
|
// Wayland-specific global data
|
||||||
|
@ -227,8 +288,6 @@ typedef struct _GLFWlibraryWayland
|
||||||
struct wl_keyboard* keyboard;
|
struct wl_keyboard* keyboard;
|
||||||
struct wl_data_device_manager* dataDeviceManager;
|
struct wl_data_device_manager* dataDeviceManager;
|
||||||
struct wl_data_device* dataDevice;
|
struct wl_data_device* dataDevice;
|
||||||
struct wl_data_offer* dataOffer;
|
|
||||||
struct wl_data_source* dataSource;
|
|
||||||
struct xdg_wm_base* wmBase;
|
struct xdg_wm_base* wmBase;
|
||||||
struct zxdg_decoration_manager_v1* decorationManager;
|
struct zxdg_decoration_manager_v1* decorationManager;
|
||||||
struct wp_viewporter* viewporter;
|
struct wp_viewporter* viewporter;
|
||||||
|
@ -236,6 +295,16 @@ typedef struct _GLFWlibraryWayland
|
||||||
struct zwp_pointer_constraints_v1* pointerConstraints;
|
struct zwp_pointer_constraints_v1* pointerConstraints;
|
||||||
struct zwp_idle_inhibit_manager_v1* idleInhibitManager;
|
struct zwp_idle_inhibit_manager_v1* idleInhibitManager;
|
||||||
|
|
||||||
|
_GLFWofferWayland* offers;
|
||||||
|
unsigned int offerCount;
|
||||||
|
|
||||||
|
struct wl_data_offer* selectionOffer;
|
||||||
|
struct wl_data_source* selectionSource;
|
||||||
|
|
||||||
|
struct wl_data_offer* dragOffer;
|
||||||
|
_GLFWwindow* dragFocus;
|
||||||
|
uint32_t dragSerial;
|
||||||
|
|
||||||
int compositorVersion;
|
int compositorVersion;
|
||||||
int seatVersion;
|
int seatVersion;
|
||||||
|
|
||||||
|
@ -245,18 +314,17 @@ typedef struct _GLFWlibraryWayland
|
||||||
const char* cursorPreviousName;
|
const char* cursorPreviousName;
|
||||||
int cursorTimerfd;
|
int cursorTimerfd;
|
||||||
uint32_t serial;
|
uint32_t serial;
|
||||||
|
uint32_t pointerEnterSerial;
|
||||||
|
|
||||||
int32_t keyboardRepeatRate;
|
int32_t keyboardRepeatRate;
|
||||||
int32_t keyboardRepeatDelay;
|
int32_t keyboardRepeatDelay;
|
||||||
int keyboardLastKey;
|
int keyboardLastKey;
|
||||||
int keyboardLastScancode;
|
int keyboardLastScancode;
|
||||||
char* clipboardString;
|
char* clipboardString;
|
||||||
size_t clipboardSize;
|
|
||||||
char* clipboardSendString;
|
|
||||||
size_t clipboardSendSize;
|
|
||||||
int timerfd;
|
int timerfd;
|
||||||
short int keycodes[256];
|
short int keycodes[256];
|
||||||
short int scancodes[GLFW_KEY_LAST + 1];
|
short int scancodes[GLFW_KEY_LAST + 1];
|
||||||
|
char keynames[GLFW_KEY_LAST + 1][5];
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
void* handle;
|
void* handle;
|
||||||
|
@ -264,9 +332,7 @@ typedef struct _GLFWlibraryWayland
|
||||||
struct xkb_keymap* keymap;
|
struct xkb_keymap* keymap;
|
||||||
struct xkb_state* state;
|
struct xkb_state* state;
|
||||||
|
|
||||||
#ifdef HAVE_XKBCOMMON_COMPOSE_H
|
|
||||||
struct xkb_compose_state* composeState;
|
struct xkb_compose_state* composeState;
|
||||||
#endif
|
|
||||||
|
|
||||||
xkb_mod_mask_t controlMask;
|
xkb_mod_mask_t controlMask;
|
||||||
xkb_mod_mask_t altMask;
|
xkb_mod_mask_t altMask;
|
||||||
|
@ -282,13 +348,14 @@ typedef struct _GLFWlibraryWayland
|
||||||
PFN_xkb_keymap_unref keymap_unref;
|
PFN_xkb_keymap_unref keymap_unref;
|
||||||
PFN_xkb_keymap_mod_get_index keymap_mod_get_index;
|
PFN_xkb_keymap_mod_get_index keymap_mod_get_index;
|
||||||
PFN_xkb_keymap_key_repeats keymap_key_repeats;
|
PFN_xkb_keymap_key_repeats keymap_key_repeats;
|
||||||
|
PFN_xkb_keymap_key_get_syms_by_level keymap_key_get_syms_by_level;
|
||||||
PFN_xkb_state_new state_new;
|
PFN_xkb_state_new state_new;
|
||||||
PFN_xkb_state_unref state_unref;
|
PFN_xkb_state_unref state_unref;
|
||||||
PFN_xkb_state_key_get_syms state_key_get_syms;
|
PFN_xkb_state_key_get_syms state_key_get_syms;
|
||||||
PFN_xkb_state_update_mask state_update_mask;
|
PFN_xkb_state_update_mask state_update_mask;
|
||||||
PFN_xkb_state_serialize_mods state_serialize_mods;
|
PFN_xkb_state_serialize_mods state_serialize_mods;
|
||||||
|
PFN_xkb_state_key_get_layout state_key_get_layout;
|
||||||
|
|
||||||
#ifdef HAVE_XKBCOMMON_COMPOSE_H
|
|
||||||
PFN_xkb_compose_table_new_from_locale compose_table_new_from_locale;
|
PFN_xkb_compose_table_new_from_locale compose_table_new_from_locale;
|
||||||
PFN_xkb_compose_table_unref compose_table_unref;
|
PFN_xkb_compose_table_unref compose_table_unref;
|
||||||
PFN_xkb_compose_state_new compose_state_new;
|
PFN_xkb_compose_state_new compose_state_new;
|
||||||
|
@ -296,12 +363,32 @@ typedef struct _GLFWlibraryWayland
|
||||||
PFN_xkb_compose_state_feed compose_state_feed;
|
PFN_xkb_compose_state_feed compose_state_feed;
|
||||||
PFN_xkb_compose_state_get_status compose_state_get_status;
|
PFN_xkb_compose_state_get_status compose_state_get_status;
|
||||||
PFN_xkb_compose_state_get_one_sym compose_state_get_one_sym;
|
PFN_xkb_compose_state_get_one_sym compose_state_get_one_sym;
|
||||||
#endif
|
|
||||||
} xkb;
|
} xkb;
|
||||||
|
|
||||||
_GLFWwindow* pointerFocus;
|
_GLFWwindow* pointerFocus;
|
||||||
_GLFWwindow* keyboardFocus;
|
_GLFWwindow* keyboardFocus;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
void* handle;
|
||||||
|
PFN_wl_display_flush display_flush;
|
||||||
|
PFN_wl_display_cancel_read display_cancel_read;
|
||||||
|
PFN_wl_display_dispatch_pending display_dispatch_pending;
|
||||||
|
PFN_wl_display_read_events display_read_events;
|
||||||
|
PFN_wl_display_disconnect display_disconnect;
|
||||||
|
PFN_wl_display_roundtrip display_roundtrip;
|
||||||
|
PFN_wl_display_get_fd display_get_fd;
|
||||||
|
PFN_wl_display_prepare_read display_prepare_read;
|
||||||
|
PFN_wl_proxy_marshal proxy_marshal;
|
||||||
|
PFN_wl_proxy_add_listener proxy_add_listener;
|
||||||
|
PFN_wl_proxy_destroy proxy_destroy;
|
||||||
|
PFN_wl_proxy_marshal_constructor proxy_marshal_constructor;
|
||||||
|
PFN_wl_proxy_marshal_constructor_versioned proxy_marshal_constructor_versioned;
|
||||||
|
PFN_wl_proxy_get_user_data proxy_get_user_data;
|
||||||
|
PFN_wl_proxy_set_user_data proxy_set_user_data;
|
||||||
|
PFN_wl_proxy_get_version proxy_get_version;
|
||||||
|
PFN_wl_proxy_marshal_flags proxy_marshal_flags;
|
||||||
|
} client;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
void* handle;
|
void* handle;
|
||||||
|
|
||||||
|
@ -318,7 +405,6 @@ typedef struct _GLFWlibraryWayland
|
||||||
PFN_wl_egl_window_destroy window_destroy;
|
PFN_wl_egl_window_destroy window_destroy;
|
||||||
PFN_wl_egl_window_resize window_resize;
|
PFN_wl_egl_window_resize window_resize;
|
||||||
} egl;
|
} egl;
|
||||||
|
|
||||||
} _GLFWlibraryWayland;
|
} _GLFWlibraryWayland;
|
||||||
|
|
||||||
// Wayland-specific per-monitor data
|
// Wayland-specific per-monitor data
|
||||||
|
@ -332,7 +418,6 @@ typedef struct _GLFWmonitorWayland
|
||||||
int x;
|
int x;
|
||||||
int y;
|
int y;
|
||||||
int scale;
|
int scale;
|
||||||
|
|
||||||
} _GLFWmonitorWayland;
|
} _GLFWmonitorWayland;
|
||||||
|
|
||||||
// Wayland-specific per-cursor data
|
// Wayland-specific per-cursor data
|
||||||
|
@ -347,6 +432,84 @@ typedef struct _GLFWcursorWayland
|
||||||
int currentImage;
|
int currentImage;
|
||||||
} _GLFWcursorWayland;
|
} _GLFWcursorWayland;
|
||||||
|
|
||||||
|
GLFWbool _glfwConnectWayland(int platformID, _GLFWplatform* platform);
|
||||||
|
int _glfwInitWayland(void);
|
||||||
|
void _glfwTerminateWayland(void);
|
||||||
|
|
||||||
|
int _glfwCreateWindowWayland(_GLFWwindow* window, const _GLFWwndconfig* wndconfig, const _GLFWctxconfig* ctxconfig, const _GLFWfbconfig* fbconfig);
|
||||||
|
void _glfwDestroyWindowWayland(_GLFWwindow* window);
|
||||||
|
void _glfwSetWindowTitleWayland(_GLFWwindow* window, const char* title);
|
||||||
|
void _glfwSetWindowIconWayland(_GLFWwindow* window, int count, const GLFWimage* images);
|
||||||
|
void _glfwGetWindowPosWayland(_GLFWwindow* window, int* xpos, int* ypos);
|
||||||
|
void _glfwSetWindowPosWayland(_GLFWwindow* window, int xpos, int ypos);
|
||||||
|
void _glfwGetWindowSizeWayland(_GLFWwindow* window, int* width, int* height);
|
||||||
|
void _glfwSetWindowSizeWayland(_GLFWwindow* window, int width, int height);
|
||||||
|
void _glfwSetWindowSizeLimitsWayland(_GLFWwindow* window, int minwidth, int minheight, int maxwidth, int maxheight);
|
||||||
|
void _glfwSetWindowAspectRatioWayland(_GLFWwindow* window, int numer, int denom);
|
||||||
|
void _glfwGetFramebufferSizeWayland(_GLFWwindow* window, int* width, int* height);
|
||||||
|
void _glfwGetWindowFrameSizeWayland(_GLFWwindow* window, int* left, int* top, int* right, int* bottom);
|
||||||
|
void _glfwGetWindowContentScaleWayland(_GLFWwindow* window, float* xscale, float* yscale);
|
||||||
|
void _glfwIconifyWindowWayland(_GLFWwindow* window);
|
||||||
|
void _glfwRestoreWindowWayland(_GLFWwindow* window);
|
||||||
|
void _glfwMaximizeWindowWayland(_GLFWwindow* window);
|
||||||
|
void _glfwShowWindowWayland(_GLFWwindow* window);
|
||||||
|
void _glfwHideWindowWayland(_GLFWwindow* window);
|
||||||
|
void _glfwRequestWindowAttentionWayland(_GLFWwindow* window);
|
||||||
|
void _glfwFocusWindowWayland(_GLFWwindow* window);
|
||||||
|
void _glfwSetWindowMonitorWayland(_GLFWwindow* window, _GLFWmonitor* monitor, int xpos, int ypos, int width, int height, int refreshRate);
|
||||||
|
int _glfwWindowFocusedWayland(_GLFWwindow* window);
|
||||||
|
int _glfwWindowIconifiedWayland(_GLFWwindow* window);
|
||||||
|
int _glfwWindowVisibleWayland(_GLFWwindow* window);
|
||||||
|
int _glfwWindowMaximizedWayland(_GLFWwindow* window);
|
||||||
|
int _glfwWindowHoveredWayland(_GLFWwindow* window);
|
||||||
|
int _glfwFramebufferTransparentWayland(_GLFWwindow* window);
|
||||||
|
void _glfwSetWindowResizableWayland(_GLFWwindow* window, GLFWbool enabled);
|
||||||
|
void _glfwSetWindowDecoratedWayland(_GLFWwindow* window, GLFWbool enabled);
|
||||||
|
void _glfwSetWindowFloatingWayland(_GLFWwindow* window, GLFWbool enabled);
|
||||||
|
float _glfwGetWindowOpacityWayland(_GLFWwindow* window);
|
||||||
|
void _glfwSetWindowOpacityWayland(_GLFWwindow* window, float opacity);
|
||||||
|
void _glfwSetWindowMousePassthroughWayland(_GLFWwindow* window, GLFWbool enabled);
|
||||||
|
|
||||||
|
void _glfwSetRawMouseMotionWayland(_GLFWwindow* window, GLFWbool enabled);
|
||||||
|
GLFWbool _glfwRawMouseMotionSupportedWayland(void);
|
||||||
|
|
||||||
|
void _glfwPollEventsWayland(void);
|
||||||
|
void _glfwWaitEventsWayland(void);
|
||||||
|
void _glfwWaitEventsTimeoutWayland(double timeout);
|
||||||
|
void _glfwPostEmptyEventWayland(void);
|
||||||
|
|
||||||
|
void _glfwGetCursorPosWayland(_GLFWwindow* window, double* xpos, double* ypos);
|
||||||
|
void _glfwSetCursorPosWayland(_GLFWwindow* window, double xpos, double ypos);
|
||||||
|
void _glfwSetCursorModeWayland(_GLFWwindow* window, int mode);
|
||||||
|
const char* _glfwGetScancodeNameWayland(int scancode);
|
||||||
|
int _glfwGetKeyScancodeWayland(int key);
|
||||||
|
int _glfwCreateCursorWayland(_GLFWcursor* cursor, const GLFWimage* image, int xhot, int yhot);
|
||||||
|
int _glfwCreateStandardCursorWayland(_GLFWcursor* cursor, int shape);
|
||||||
|
void _glfwDestroyCursorWayland(_GLFWcursor* cursor);
|
||||||
|
void _glfwSetCursorWayland(_GLFWwindow* window, _GLFWcursor* cursor);
|
||||||
|
void _glfwSetClipboardStringWayland(const char* string);
|
||||||
|
const char* _glfwGetClipboardStringWayland(void);
|
||||||
|
|
||||||
|
EGLenum _glfwGetEGLPlatformWayland(EGLint** attribs);
|
||||||
|
EGLNativeDisplayType _glfwGetEGLNativeDisplayWayland(void);
|
||||||
|
EGLNativeWindowType _glfwGetEGLNativeWindowWayland(_GLFWwindow* window);
|
||||||
|
|
||||||
|
void _glfwGetRequiredInstanceExtensionsWayland(char** extensions);
|
||||||
|
int _glfwGetPhysicalDevicePresentationSupportWayland(VkInstance instance, VkPhysicalDevice device, uint32_t queuefamily);
|
||||||
|
VkResult _glfwCreateWindowSurfaceWayland(VkInstance instance, _GLFWwindow* window, const VkAllocationCallbacks* allocator, VkSurfaceKHR* surface);
|
||||||
|
|
||||||
|
void _glfwFreeMonitorWayland(_GLFWmonitor* monitor);
|
||||||
|
void _glfwGetMonitorPosWayland(_GLFWmonitor* monitor, int* xpos, int* ypos);
|
||||||
|
void _glfwGetMonitorContentScaleWayland(_GLFWmonitor* monitor, float* xscale, float* yscale);
|
||||||
|
void _glfwGetMonitorWorkareaWayland(_GLFWmonitor* monitor, int* xpos, int* ypos, int* width, int* height);
|
||||||
|
GLFWvidmode* _glfwGetVideoModesWayland(_GLFWmonitor* monitor, int* count);
|
||||||
|
void _glfwGetVideoModeWayland(_GLFWmonitor* monitor, GLFWvidmode* mode);
|
||||||
|
GLFWbool _glfwGetGammaRampWayland(_GLFWmonitor* monitor, GLFWgammaramp* ramp);
|
||||||
|
void _glfwSetGammaRampWayland(_GLFWmonitor* monitor, const GLFWgammaramp* ramp);
|
||||||
|
|
||||||
void _glfwAddOutputWayland(uint32_t name, uint32_t version);
|
void _glfwAddOutputWayland(uint32_t name, uint32_t version);
|
||||||
|
GLFWbool _glfwInputTextWayland(_GLFWwindow* window, uint32_t scancode);
|
||||||
|
|
||||||
|
void _glfwAddSeatListenerWayland(struct wl_seat* seat);
|
||||||
|
void _glfwAddDataDeviceListenerWayland(struct wl_data_device* device);
|
||||||
|
|
||||||
|
|
1665
src/wl_window.c
1665
src/wl_window.c
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user