mirror of
https://github.com/glfw/glfw.git
synced 2024-11-15 02:34:36 +00:00
Merge branch 'master' into multi-context-windows
This commit is contained in:
commit
7a55ca34b9
@ -1,10 +1,10 @@
|
|||||||
image:
|
image:
|
||||||
- Visual Studio 2015
|
- Visual Studio 2015
|
||||||
- Visual Studio 2019
|
|
||||||
branches:
|
branches:
|
||||||
only:
|
only:
|
||||||
- ci
|
- ci
|
||||||
- master
|
- master
|
||||||
|
- latest
|
||||||
- 3.3-stable
|
- 3.3-stable
|
||||||
skip_tags: true
|
skip_tags: true
|
||||||
environment:
|
environment:
|
||||||
@ -21,26 +21,13 @@ environment:
|
|||||||
- GENERATOR: Visual Studio 10 2010
|
- GENERATOR: Visual Studio 10 2010
|
||||||
BUILD_SHARED_LIBS: OFF
|
BUILD_SHARED_LIBS: OFF
|
||||||
CFLAGS: /WX
|
CFLAGS: /WX
|
||||||
- GENERATOR: Visual Studio 16 2019
|
|
||||||
BUILD_SHARED_LIBS: ON
|
|
||||||
CFLAGS: /WX
|
|
||||||
- GENERATOR: Visual Studio 16 2019
|
|
||||||
BUILD_SHARED_LIBS: OFF
|
|
||||||
CFLAGS: /WX
|
|
||||||
matrix:
|
matrix:
|
||||||
fast_finish: true
|
fast_finish: true
|
||||||
exclude:
|
|
||||||
- image: Visual Studio 2015
|
|
||||||
GENERATOR: Visual Studio 16 2019
|
|
||||||
- image: Visual Studio 2019
|
|
||||||
GENERATOR: Visual Studio 10 2010
|
|
||||||
- image: Visual Studio 2019
|
|
||||||
GENERATOR: MinGW Makefiles
|
|
||||||
for:
|
for:
|
||||||
-
|
-
|
||||||
matrix:
|
matrix:
|
||||||
except:
|
only:
|
||||||
- GENERATOR: Visual Studio 10 2010
|
- GENERATOR: MinGW Makefiles
|
||||||
build_script:
|
build_script:
|
||||||
- set PATH=%PATH:C:\Program Files\Git\usr\bin=C:\MinGW\bin%
|
- set PATH=%PATH:C:\Program Files\Git\usr\bin=C:\MinGW\bin%
|
||||||
- cmake -S . -B build -G "%GENERATOR%" -DBUILD_SHARED_LIBS=%BUILD_SHARED_LIBS%
|
- cmake -S . -B build -G "%GENERATOR%" -DBUILD_SHARED_LIBS=%BUILD_SHARED_LIBS%
|
||||||
|
116
.github/workflows/build.yml
vendored
Normal file
116
.github/workflows/build.yml
vendored
Normal file
@ -0,0 +1,116 @@
|
|||||||
|
name: Build
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
push:
|
||||||
|
branches: [ ci, master, latest, 3.3-stable ]
|
||||||
|
permissions:
|
||||||
|
statuses: write
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-linux-x11-clang:
|
||||||
|
name: X11 (Linux, Clang)
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
env:
|
||||||
|
CC: clang
|
||||||
|
CFLAGS: -Werror
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
sudo apt update
|
||||||
|
sudo apt install libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev libxext-dev
|
||||||
|
|
||||||
|
- name: Configure static library
|
||||||
|
run: cmake -S . -B build-static
|
||||||
|
- name: Build static library
|
||||||
|
run: cmake --build build-static --parallel
|
||||||
|
|
||||||
|
- name: Configure shared library
|
||||||
|
run: cmake -S . -B build-shared -D BUILD_SHARED_LIBS=ON
|
||||||
|
- name: Build shared library
|
||||||
|
run: cmake --build build-shared --parallel
|
||||||
|
|
||||||
|
build-linux-wayland-clang:
|
||||||
|
name: Wayland (Linux, Clang)
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
env:
|
||||||
|
CC: clang
|
||||||
|
CFLAGS: -Werror
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
sudo apt update
|
||||||
|
sudo apt install wayland-protocols libwayland-dev libxkbcommon-dev
|
||||||
|
|
||||||
|
- name: Configure static library
|
||||||
|
run: cmake -S . -B build-static -D GLFW_USE_WAYLAND=ON
|
||||||
|
- name: Build static library
|
||||||
|
run: cmake --build build-static --parallel
|
||||||
|
|
||||||
|
- name: Configure shared library
|
||||||
|
run: cmake -S . -B build-shared -D GLFW_USE_WAYLAND=ON -D BUILD_SHARED_LIBS=ON
|
||||||
|
- name: Build shared library
|
||||||
|
run: cmake --build build-shared --parallel
|
||||||
|
|
||||||
|
build-linux-null-clang:
|
||||||
|
name: Null (Linux, Clang)
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
env:
|
||||||
|
CC: clang
|
||||||
|
CFLAGS: -Werror
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
sudo apt update
|
||||||
|
sudo apt install libosmesa6-dev
|
||||||
|
|
||||||
|
- name: Configure static library
|
||||||
|
run: cmake -S . -B build-static -D GLFW_USE_OSMESA=ON
|
||||||
|
- name: Build static library
|
||||||
|
run: cmake --build build-static --parallel
|
||||||
|
|
||||||
|
- name: Configure shared library
|
||||||
|
run: cmake -S . -B build-shared -D GLFW_USE_OSMESA=ON -D BUILD_SHARED_LIBS=ON
|
||||||
|
- name: Build shared library
|
||||||
|
run: cmake --build build-shared --parallel
|
||||||
|
|
||||||
|
build-macos-cocoa-clang:
|
||||||
|
name: Cocoa (macOS, Clang)
|
||||||
|
runs-on: macos-latest
|
||||||
|
env:
|
||||||
|
CFLAGS: -Werror
|
||||||
|
MACOSX_DEPLOYMENT_TARGET: 10.8
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Configure static library
|
||||||
|
run: cmake -S . -B build-static
|
||||||
|
- name: Build static library
|
||||||
|
run: cmake --build build-static --parallel
|
||||||
|
|
||||||
|
- name: Configure shared library
|
||||||
|
run: cmake -S . -B build-shared -D BUILD_SHARED_LIBS=ON
|
||||||
|
- name: Build shared library
|
||||||
|
run: cmake --build build-shared --parallel
|
||||||
|
|
||||||
|
build-windows-win32-vs2019:
|
||||||
|
name: Win32 (Windows, VS2019)
|
||||||
|
runs-on: windows-latest
|
||||||
|
env:
|
||||||
|
CFLAGS: /WX
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Configure static library
|
||||||
|
run: cmake -S . -B build-static -G "Visual Studio 16 2019"
|
||||||
|
- name: Build static library
|
||||||
|
run: cmake --build build-static --parallel
|
||||||
|
|
||||||
|
- name: Configure shared library
|
||||||
|
run: cmake -S . -B build-shared -G "Visual Studio 16 2019" -D BUILD_SHARED_LIBS=ON
|
||||||
|
- name: Build shared library
|
||||||
|
run: cmake --build build-shared --parallel
|
||||||
|
|
114
.travis.yml
114
.travis.yml
@ -1,114 +0,0 @@
|
|||||||
language: c
|
|
||||||
compiler: clang
|
|
||||||
branches:
|
|
||||||
only:
|
|
||||||
- ci
|
|
||||||
- master
|
|
||||||
- 3.3-stable
|
|
||||||
matrix:
|
|
||||||
include:
|
|
||||||
- os: linux
|
|
||||||
dist: xenial
|
|
||||||
name: "X11 shared library"
|
|
||||||
addons:
|
|
||||||
apt:
|
|
||||||
packages:
|
|
||||||
- libxrandr-dev
|
|
||||||
- libxinerama-dev
|
|
||||||
- libxcursor-dev
|
|
||||||
- libxi-dev
|
|
||||||
- libxext-dev
|
|
||||||
env:
|
|
||||||
- BUILD_SHARED_LIBS=ON
|
|
||||||
- CFLAGS=-Werror
|
|
||||||
- os: linux
|
|
||||||
dist: xenial
|
|
||||||
name: "X11 static library"
|
|
||||||
addons:
|
|
||||||
apt:
|
|
||||||
packages:
|
|
||||||
- libxrandr-dev
|
|
||||||
- libxinerama-dev
|
|
||||||
- libxcursor-dev
|
|
||||||
- libxi-dev
|
|
||||||
- libxext-dev
|
|
||||||
env:
|
|
||||||
- BUILD_SHARED_LIBS=OFF
|
|
||||||
- CFLAGS=-Werror
|
|
||||||
- os: linux
|
|
||||||
dist: focal
|
|
||||||
name: "Wayland shared library"
|
|
||||||
addons:
|
|
||||||
apt:
|
|
||||||
packages:
|
|
||||||
- wayland-protocols
|
|
||||||
- libwayland-dev
|
|
||||||
- libxkbcommon-dev
|
|
||||||
- libegl1-mesa-dev
|
|
||||||
env:
|
|
||||||
- USE_WAYLAND=ON
|
|
||||||
- BUILD_SHARED_LIBS=ON
|
|
||||||
- CFLAGS=-Werror
|
|
||||||
- os: linux
|
|
||||||
dist: focal
|
|
||||||
name: "Wayland static library"
|
|
||||||
addons:
|
|
||||||
apt:
|
|
||||||
packages:
|
|
||||||
- wayland-protocols
|
|
||||||
- libwayland-dev
|
|
||||||
- libxkbcommon-dev
|
|
||||||
- libegl1-mesa-dev
|
|
||||||
env:
|
|
||||||
- USE_WAYLAND=ON
|
|
||||||
- BUILD_SHARED_LIBS=OFF
|
|
||||||
- CFLAGS=-Werror
|
|
||||||
- os: linux
|
|
||||||
dist: bionic
|
|
||||||
name: "Null shared library"
|
|
||||||
addons:
|
|
||||||
apt:
|
|
||||||
packages:
|
|
||||||
- libosmesa6-dev
|
|
||||||
env:
|
|
||||||
- BUILD_SHARED_LIBS=ON
|
|
||||||
- USE_OSMESA=ON
|
|
||||||
- CFLAGS=-Werror
|
|
||||||
- os: linux
|
|
||||||
dist: bionic
|
|
||||||
name: "Null static library"
|
|
||||||
addons:
|
|
||||||
apt:
|
|
||||||
packages:
|
|
||||||
- libosmesa6-dev
|
|
||||||
env:
|
|
||||||
- BUILD_SHARED_LIBS=OFF
|
|
||||||
- USE_OSMESA=ON
|
|
||||||
- CFLAGS=-Werror
|
|
||||||
- os: osx
|
|
||||||
name: "Cocoa shared library"
|
|
||||||
env:
|
|
||||||
- BUILD_SHARED_LIBS=ON
|
|
||||||
- CFLAGS=-Werror
|
|
||||||
- MACOSX_DEPLOYMENT_TARGET=10.8
|
|
||||||
- os: osx
|
|
||||||
name: "Cocoa static library"
|
|
||||||
env:
|
|
||||||
- BUILD_SHARED_LIBS=OFF
|
|
||||||
- CFLAGS=-Werror
|
|
||||||
- MACOSX_DEPLOYMENT_TARGET=10.8
|
|
||||||
script:
|
|
||||||
- if grep -Inr '\s$' src include docs tests examples CMake *.md .gitattributes .gitignore; then
|
|
||||||
echo Trailing whitespace found, aborting;
|
|
||||||
exit 1;
|
|
||||||
fi
|
|
||||||
- mkdir build
|
|
||||||
- cd build
|
|
||||||
- cmake -DCMAKE_VERBOSE_MAKEFILE=ON -DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS} -DGLFW_USE_WAYLAND=${USE_WAYLAND} -DGLFW_USE_OSMESA=${USE_OSMESA} ..
|
|
||||||
- cmake --build .
|
|
||||||
notifications:
|
|
||||||
email:
|
|
||||||
recipients:
|
|
||||||
- ci@glfw.org
|
|
||||||
on_success: never
|
|
||||||
on_failure: always
|
|
@ -23,8 +23,23 @@ endif()
|
|||||||
|
|
||||||
file(STRINGS "${source_path}" lines)
|
file(STRINGS "${source_path}" lines)
|
||||||
foreach(line ${lines})
|
foreach(line ${lines})
|
||||||
if ("${line}" MATCHES "^[0-9a-fA-F].*$")
|
if (line MATCHES "^[0-9a-fA-F]")
|
||||||
set(GLFW_GAMEPAD_MAPPINGS "${GLFW_GAMEPAD_MAPPINGS}\"${line}\",\n")
|
if (line MATCHES "platform:Windows")
|
||||||
|
if (GLFW_WIN32_MAPPINGS)
|
||||||
|
string(APPEND GLFW_WIN32_MAPPINGS "\n")
|
||||||
|
endif()
|
||||||
|
string(APPEND GLFW_WIN32_MAPPINGS "\"${line}\",")
|
||||||
|
elseif (line MATCHES "platform:Mac OS X")
|
||||||
|
if (GLFW_COCOA_MAPPINGS)
|
||||||
|
string(APPEND GLFW_COCOA_MAPPINGS "\n")
|
||||||
|
endif()
|
||||||
|
string(APPEND GLFW_COCOA_MAPPINGS "\"${line}\",")
|
||||||
|
elseif (line MATCHES "platform:Linux")
|
||||||
|
if (GLFW_LINUX_MAPPINGS)
|
||||||
|
string(APPEND GLFW_LINUX_MAPPINGS "\n")
|
||||||
|
endif()
|
||||||
|
string(APPEND GLFW_LINUX_MAPPINGS "\"${line}\",")
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ Name: GLFW
|
|||||||
Description: A multi-platform library for OpenGL, window and input
|
Description: A multi-platform library for OpenGL, window and input
|
||||||
Version: @GLFW_VERSION@
|
Version: @GLFW_VERSION@
|
||||||
URL: https://www.glfw.org/
|
URL: https://www.glfw.org/
|
||||||
Requires.private: @GLFW_PKG_DEPS@
|
Requires.private: @GLFW_PKG_CONFIG_REQUIRES_PRIVATE@
|
||||||
Libs: -L${libdir} -l@GLFW_LIB_NAME@
|
Libs: -L${libdir} -l@GLFW_LIB_NAME@
|
||||||
Libs.private: @GLFW_PKG_LIBS@
|
Libs.private: @GLFW_PKG_CONFIG_LIBS_PRIVATE@
|
||||||
Cflags: -I${includedir}
|
Cflags: -I${includedir}
|
||||||
|
@ -13,5 +13,5 @@ if (EPOLLSHIM_INCLUDE_DIRS AND EPOLLSHIM_LIBRARIES)
|
|||||||
endif (EPOLLSHIM_INCLUDE_DIRS AND EPOLLSHIM_LIBRARIES)
|
endif (EPOLLSHIM_INCLUDE_DIRS AND EPOLLSHIM_LIBRARIES)
|
||||||
|
|
||||||
include(FindPackageHandleStandardArgs)
|
include(FindPackageHandleStandardArgs)
|
||||||
find_package_handle_standard_args(EPOLLSHIM DEFAULT_MSG EPOLLSHIM_LIBRARIES EPOLLSHIM_INCLUDE_DIRS)
|
find_package_handle_standard_args(EpollShim DEFAULT_MSG EPOLLSHIM_LIBRARIES EPOLLSHIM_INCLUDE_DIRS)
|
||||||
mark_as_advanced(EPOLLSHIM_INCLUDE_DIRS EPOLLSHIM_LIBRARIES)
|
mark_as_advanced(EPOLLSHIM_INCLUDE_DIRS EPOLLSHIM_LIBRARIES)
|
||||||
|
@ -1,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)
|
||||||
|
|
||||||
@ -18,7 +18,7 @@ endif()
|
|||||||
|
|
||||||
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
||||||
|
|
||||||
if ("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
|
if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
|
||||||
set(GLFW_STANDALONE TRUE)
|
set(GLFW_STANDALONE TRUE)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@ -41,7 +41,20 @@ cmake_dependent_option(GLFW_USE_WAYLAND "Use Wayland for window creation" 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
|
||||||
|
"Library type override for GLFW (SHARED, STATIC, OBJECT, or empty to follow BUILD_SHARED_LIBS)")
|
||||||
|
|
||||||
|
if (GLFW_LIBRARY_TYPE)
|
||||||
|
if (GLFW_LIBRARY_TYPE STREQUAL "SHARED")
|
||||||
|
set(GLFW_BUILD_SHARED_LIBRARY TRUE)
|
||||||
|
else()
|
||||||
|
set(GLFW_BUILD_SHARED_LIBRARY FALSE)
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
set(GLFW_BUILD_SHARED_LIBRARY ${BUILD_SHARED_LIBS})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (UNIX AND GLFW_BUILD_SHARED_LIBRARY)
|
||||||
# On Unix-like systems, shared libraries can use the soname system.
|
# On Unix-like systems, shared libraries can use the soname system.
|
||||||
set(GLFW_LIB_NAME glfw)
|
set(GLFW_LIB_NAME glfw)
|
||||||
else()
|
else()
|
||||||
@ -49,7 +62,7 @@ else()
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (GLFW_VULKAN_STATIC)
|
if (GLFW_VULKAN_STATIC)
|
||||||
if (BUILD_SHARED_LIBS)
|
if (GLFW_BUILD_SHARED_LIBRARY)
|
||||||
# If you absolutely must do this, remove this line and add the Vulkan
|
# If you absolutely must do this, remove this line and add the Vulkan
|
||||||
# loader static library via the CMAKE_SHARED_LINKER_FLAGS
|
# loader static library via the CMAKE_SHARED_LINKER_FLAGS
|
||||||
message(FATAL_ERROR "You are trying to link the Vulkan loader static library into the GLFW shared library")
|
message(FATAL_ERROR "You are trying to link the Vulkan loader static library into the GLFW shared library")
|
||||||
@ -67,24 +80,27 @@ if (GLFW_BUILD_DOCS)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
#--------------------------------------------------------------------
|
#--------------------------------------------------------------------
|
||||||
# Set compiler specific flags
|
# Apply Microsoft C runtime library option
|
||||||
|
# This is here because it also applies to tests and examples
|
||||||
#--------------------------------------------------------------------
|
#--------------------------------------------------------------------
|
||||||
if (MSVC)
|
if (MSVC AND NOT USE_MSVC_RUNTIME_LIBRARY_DLL)
|
||||||
if (NOT USE_MSVC_RUNTIME_LIBRARY_DLL)
|
if (CMAKE_VERSION VERSION_LESS 3.15)
|
||||||
foreach (flag CMAKE_C_FLAGS
|
foreach (flag CMAKE_C_FLAGS
|
||||||
CMAKE_C_FLAGS_DEBUG
|
CMAKE_C_FLAGS_DEBUG
|
||||||
CMAKE_C_FLAGS_RELEASE
|
CMAKE_C_FLAGS_RELEASE
|
||||||
CMAKE_C_FLAGS_MINSIZEREL
|
CMAKE_C_FLAGS_MINSIZEREL
|
||||||
CMAKE_C_FLAGS_RELWITHDEBINFO)
|
CMAKE_C_FLAGS_RELWITHDEBINFO)
|
||||||
|
|
||||||
if (${flag} MATCHES "/MD")
|
if (flag MATCHES "/MD")
|
||||||
string(REGEX REPLACE "/MD" "/MT" ${flag} "${${flag}}")
|
string(REGEX REPLACE "/MD" "/MT" ${flag} "${${flag}}")
|
||||||
endif()
|
endif()
|
||||||
if (${flag} MATCHES "/MDd")
|
if (flag MATCHES "/MDd")
|
||||||
string(REGEX REPLACE "/MDd" "/MTd" ${flag} "${${flag}}")
|
string(REGEX REPLACE "/MDd" "/MTd" ${flag} "${${flag}}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
endforeach()
|
endforeach()
|
||||||
|
else()
|
||||||
|
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@ -199,17 +215,14 @@ if (_GLFW_WAYLAND)
|
|||||||
wayland-egl>=0.2.7
|
wayland-egl>=0.2.7
|
||||||
xkbcommon)
|
xkbcommon)
|
||||||
|
|
||||||
list(APPEND glfw_PKG_DEPS "wayland-client")
|
|
||||||
|
|
||||||
list(APPEND glfw_INCLUDE_DIRS "${Wayland_INCLUDE_DIRS}")
|
list(APPEND glfw_INCLUDE_DIRS "${Wayland_INCLUDE_DIRS}")
|
||||||
list(APPEND glfw_LIBRARIES "${Wayland_LINK_LIBRARIES}")
|
|
||||||
|
|
||||||
include(CheckIncludeFiles)
|
include(CheckIncludeFiles)
|
||||||
include(CheckFunctionExists)
|
include(CheckFunctionExists)
|
||||||
check_include_files(xkbcommon/xkbcommon-compose.h HAVE_XKBCOMMON_COMPOSE_H)
|
check_include_files(xkbcommon/xkbcommon-compose.h HAVE_XKBCOMMON_COMPOSE_H)
|
||||||
check_function_exists(memfd_create HAVE_MEMFD_CREATE)
|
check_function_exists(memfd_create HAVE_MEMFD_CREATE)
|
||||||
|
|
||||||
if (NOT ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux"))
|
if (NOT CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||||
find_package(EpollShim)
|
find_package(EpollShim)
|
||||||
if (EPOLLSHIM_FOUND)
|
if (EPOLLSHIM_FOUND)
|
||||||
list(APPEND glfw_INCLUDE_DIRS "${EPOLLSHIM_INCLUDE_DIRS}")
|
list(APPEND glfw_INCLUDE_DIRS "${EPOLLSHIM_INCLUDE_DIRS}")
|
||||||
@ -243,12 +256,17 @@ endif()
|
|||||||
# Export GLFW library dependencies
|
# Export GLFW library dependencies
|
||||||
#--------------------------------------------------------------------
|
#--------------------------------------------------------------------
|
||||||
foreach(arg ${glfw_PKG_DEPS})
|
foreach(arg ${glfw_PKG_DEPS})
|
||||||
set(GLFW_PKG_DEPS "${GLFW_PKG_DEPS} ${arg}")
|
string(APPEND deps " ${arg}")
|
||||||
endforeach()
|
endforeach()
|
||||||
foreach(arg ${glfw_PKG_LIBS})
|
foreach(arg ${glfw_PKG_LIBS})
|
||||||
set(GLFW_PKG_LIBS "${GLFW_PKG_LIBS} ${arg}")
|
string(APPEND libs " ${arg}")
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
|
set(GLFW_PKG_CONFIG_REQUIRES_PRIVATE "${deps}" CACHE INTERNAL
|
||||||
|
"GLFW pkg-config Requires.private")
|
||||||
|
set(GLFW_PKG_CONFIG_LIBS_PRIVATE "${libs}" CACHE INTERNAL
|
||||||
|
"GLFW pkg-config Libs.private")
|
||||||
|
|
||||||
#--------------------------------------------------------------------
|
#--------------------------------------------------------------------
|
||||||
# Create generated files
|
# Create generated files
|
||||||
#--------------------------------------------------------------------
|
#--------------------------------------------------------------------
|
||||||
|
64
README.md
64
README.md
@ -1,6 +1,6 @@
|
|||||||
# GLFW
|
# GLFW
|
||||||
|
|
||||||
[![Build status](https://travis-ci.org/glfw/glfw.svg?branch=master)](https://travis-ci.org/glfw/glfw)
|
[![Build status](https://github.com/glfw/glfw/actions/workflows/build.yml/badge.svg)](https://github.com/glfw/glfw/actions)
|
||||||
[![Build status](https://ci.appveyor.com/api/projects/status/0kf0ct9831i5l6sp/branch/master?svg=true)](https://ci.appveyor.com/project/elmindreda/glfw)
|
[![Build status](https://ci.appveyor.com/api/projects/status/0kf0ct9831i5l6sp/branch/master?svg=true)](https://ci.appveyor.com/project/elmindreda/glfw)
|
||||||
[![Coverity Scan](https://scan.coverity.com/projects/4884/badge.svg)](https://scan.coverity.com/projects/glfw-glfw)
|
[![Coverity Scan](https://scan.coverity.com/projects/4884/badge.svg)](https://scan.coverity.com/projects/glfw-glfw)
|
||||||
|
|
||||||
@ -14,18 +14,18 @@ GLFW natively supports Windows, macOS and Linux and other Unix-like systems. On
|
|||||||
Linux both X11 and Wayland are supported.
|
Linux both X11 and Wayland are supported.
|
||||||
|
|
||||||
GLFW is licensed under the [zlib/libpng
|
GLFW is licensed under the [zlib/libpng
|
||||||
license](http://www.glfw.org/license.html).
|
license](https://www.glfw.org/license.html).
|
||||||
|
|
||||||
You can [download](http://www.glfw.org/download.html) the latest stable release
|
You can [download](https://www.glfw.org/download.html) the latest stable release
|
||||||
as source or Windows binaries, or fetch the `latest` branch from GitHub. Each
|
as source or Windows binaries, or fetch the `latest` branch from GitHub. Each
|
||||||
release starting with 3.0 also has a corresponding [annotated
|
release starting with 3.0 also has a corresponding [annotated
|
||||||
tag](https://github.com/glfw/glfw/releases) with source and binary archives.
|
tag](https://github.com/glfw/glfw/releases) with source and binary archives.
|
||||||
|
|
||||||
The [documentation](http://www.glfw.org/docs/latest/) is available online and is
|
The [documentation](https://www.glfw.org/docs/latest/) is available online and is
|
||||||
included in all source and binary archives. See the [release
|
included in all source and binary archives. See the [release
|
||||||
notes](https://www.glfw.org/docs/latest/news.html) for new features, caveats and
|
notes](https://www.glfw.org/docs/latest/news.html) for new features, caveats and
|
||||||
deprecations in the latest release. For more details see the [version
|
deprecations in the latest release. For more details see the [version
|
||||||
history](http://www.glfw.org/changelog.html).
|
history](https://www.glfw.org/changelog.html).
|
||||||
|
|
||||||
The `master` branch is the stable integration branch and _should_ always compile
|
The `master` branch is the stable integration branch and _should_ always compile
|
||||||
and run on all supported platforms, although details of newly added features may
|
and run on all supported platforms, although details of newly added features may
|
||||||
@ -34,9 +34,9 @@ fixes live in [other branches](https://github.com/glfw/glfw/branches/all) until
|
|||||||
they are stable enough to merge.
|
they are stable enough to merge.
|
||||||
|
|
||||||
If you are new to GLFW, you may find the
|
If you are new to GLFW, you may find the
|
||||||
[tutorial](http://www.glfw.org/docs/latest/quick.html) for GLFW 3 useful. If
|
[tutorial](https://www.glfw.org/docs/latest/quick.html) for GLFW 3 useful. If
|
||||||
you have used GLFW 2 in the past, there is a [transition
|
you have used GLFW 2 in the past, there is a [transition
|
||||||
guide](http://www.glfw.org/docs/latest/moving.html) for moving to the GLFW
|
guide](https://www.glfw.org/docs/latest/moving.html) for moving to the GLFW
|
||||||
3 API.
|
3 API.
|
||||||
|
|
||||||
|
|
||||||
@ -52,16 +52,16 @@ MinGW-w64, on macOS with Clang and on Linux and other Unix-like systems with GCC
|
|||||||
and Clang. It will likely compile in other environments as well, but this is
|
and Clang. It will likely compile in other environments as well, but this is
|
||||||
not regularly tested.
|
not regularly tested.
|
||||||
|
|
||||||
There are [pre-compiled Windows binaries](http://www.glfw.org/download.html)
|
There are [pre-compiled Windows binaries](https://www.glfw.org/download.html)
|
||||||
available for all supported compilers.
|
available for all supported compilers.
|
||||||
|
|
||||||
See the [compilation guide](http://www.glfw.org/docs/latest/compile.html) for
|
See the [compilation guide](https://www.glfw.org/docs/latest/compile.html) for
|
||||||
more information about how to compile GLFW yourself.
|
more information about how to compile GLFW yourself.
|
||||||
|
|
||||||
|
|
||||||
## Using GLFW
|
## Using GLFW
|
||||||
|
|
||||||
See the [documentation](http://www.glfw.org/docs/latest/) for tutorials, guides
|
See the [documentation](https://www.glfw.org/docs/latest/) for tutorials, guides
|
||||||
and the API reference.
|
and the API reference.
|
||||||
|
|
||||||
|
|
||||||
@ -79,7 +79,7 @@ Unix-like systems running the X Window System are supported even without
|
|||||||
a desktop environment or modern extensions, although some features require
|
a desktop environment or modern extensions, although some features require
|
||||||
a running window or clipboard manager. The OSMesa backend requires Mesa 6.3.
|
a running window or clipboard manager. The OSMesa backend requires Mesa 6.3.
|
||||||
|
|
||||||
See the [compatibility guide](http://www.glfw.org/docs/latest/compat.html)
|
See the [compatibility guide](https://www.glfw.org/docs/latest/compat.html)
|
||||||
in the documentation for more information.
|
in the documentation for more information.
|
||||||
|
|
||||||
|
|
||||||
@ -102,7 +102,7 @@ located in the `deps/` directory.
|
|||||||
- [Nuklear](https://github.com/Immediate-Mode-UI/Nuklear) for test and example UI
|
- [Nuklear](https://github.com/Immediate-Mode-UI/Nuklear) for test and example UI
|
||||||
- [stb\_image\_write](https://github.com/nothings/stb) for writing images to disk
|
- [stb\_image\_write](https://github.com/nothings/stb) for writing images to disk
|
||||||
|
|
||||||
The documentation is generated with [Doxygen](http://doxygen.org/) if CMake can
|
The documentation is generated with [Doxygen](https://doxygen.org/) if CMake can
|
||||||
find that tool.
|
find that tool.
|
||||||
|
|
||||||
|
|
||||||
@ -119,6 +119,9 @@ information on what to include when reporting a bug.
|
|||||||
- Added OpenGL and OpenGL ES user contexts for multiple window contexts via
|
- Added OpenGL and OpenGL ES user contexts for multiple window contexts via
|
||||||
`GLFWusercontext`, `glfwCreateUserContext`, `glfwDestroyUserContext`,
|
`GLFWusercontext`, `glfwCreateUserContext`, `glfwDestroyUserContext`,
|
||||||
`glfwMakeUserContextCurrent`, `glfwGetCurrentUserContext` (#1687)
|
`glfwMakeUserContextCurrent`, `glfwGetCurrentUserContext` (#1687)
|
||||||
|
- Added `glfwInitAllocator` for setting a custom memory allocator (#544,#1628,#1947)
|
||||||
|
- Added `GLFWallocator` struct and `GLFWallocatefun`, `GLFWreallocatefun` and
|
||||||
|
`GLFWdeallocatefun` types (#544,#1628,#1947)
|
||||||
- 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)
|
||||||
@ -130,7 +133,14 @@ information on what to include when reporting a bug.
|
|||||||
- Added `GLFW_FEATURE_UNIMPLEMENTED` error for incomplete backends (#1692)
|
- Added `GLFW_FEATURE_UNIMPLEMENTED` error for incomplete backends (#1692)
|
||||||
- Added `GLFW_ANGLE_PLATFORM_TYPE` init hint and `GLFW_ANGLE_PLATFORM_TYPE_*`
|
- Added `GLFW_ANGLE_PLATFORM_TYPE` init hint and `GLFW_ANGLE_PLATFORM_TYPE_*`
|
||||||
values to select ANGLE backend (#1380)
|
values to select ANGLE backend (#1380)
|
||||||
|
- Added `GLFW_X11_XCB_VULKAN_SURFACE` init hint for selecting X11 Vulkan
|
||||||
|
surface extension (#1793)
|
||||||
|
- 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
|
||||||
- Updated the minimum required CMake version to 3.1
|
- Updated the minimum required CMake version to 3.1
|
||||||
- Disabled tests and examples by default when built as a CMake subdirectory
|
- Disabled tests and examples by default when built as a CMake subdirectory
|
||||||
- Bugfix: The CMake config-file package used an absolute path and was not
|
- Bugfix: The CMake config-file package used an absolute path and was not
|
||||||
@ -140,6 +150,9 @@ information on what to include when reporting a bug.
|
|||||||
- Bugfix: Built-in mappings failed because some OEMs re-used VID/PID (#1583)
|
- Bugfix: Built-in mappings failed because some OEMs re-used VID/PID (#1583)
|
||||||
- Bugfix: Some extension loader headers did not prevent default OpenGL header
|
- Bugfix: Some extension loader headers did not prevent default OpenGL header
|
||||||
inclusion (#1695)
|
inclusion (#1695)
|
||||||
|
- Bugfix: Buffers were swapped at creation on single-buffered windows (#1873)
|
||||||
|
- Bugfix: Gamepad mapping updates could spam `GLFW_INVALID_VALUE` due to
|
||||||
|
incompatible controllers sharing hardware ID (#1763)
|
||||||
- [Win32] Added the `GLFW_WIN32_KEYBOARD_MENU` window hint for enabling access
|
- [Win32] Added the `GLFW_WIN32_KEYBOARD_MENU` window hint for enabling access
|
||||||
to the window menu
|
to the window menu
|
||||||
- [Win32] Added a version info resource to the GLFW DLL
|
- [Win32] Added a version info resource to the GLFW DLL
|
||||||
@ -166,6 +179,10 @@ information on what to include when reporting a bug.
|
|||||||
(#1582)
|
(#1582)
|
||||||
- [Win32] Bugfix: `GLFW_SCALE_TO_MONITOR` had no effect on systems older than
|
- [Win32] Bugfix: `GLFW_SCALE_TO_MONITOR` had no effect on systems older than
|
||||||
Windows 10 version 1703 (#1511)
|
Windows 10 version 1703 (#1511)
|
||||||
|
- [Win32] Bugfix: `USE_MSVC_RUNTIME_LIBRARY_DLL` had no effect on CMake 3.15 or
|
||||||
|
later (#1783,#1796)
|
||||||
|
- [Win32] Bugfix: Compilation with LLVM for Windows failed (#1807,#1824,#1874)
|
||||||
|
- [Win32] Bugfix: The foreground lock timeout was overridden, ignoring the user
|
||||||
- [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)
|
||||||
@ -190,6 +207,8 @@ information on what to include when reporting a bug.
|
|||||||
regained focus (#1648,#1802)
|
regained focus (#1648,#1802)
|
||||||
- [Cocoa] Bugfix: Monitor name query could segfault on macOS 11 (#1809,#1833)
|
- [Cocoa] Bugfix: Monitor name query could segfault on macOS 11 (#1809,#1833)
|
||||||
- [Cocoa] Bugfix: The install name of the installed dylib was relative (#1504)
|
- [Cocoa] Bugfix: The install name of the installed dylib was relative (#1504)
|
||||||
|
- [Cocoa] Bugfix: The MoltenVK layer contents scale was updated only after
|
||||||
|
related events were emitted
|
||||||
- [X11] Bugfix: The CMake files did not check for the XInput headers (#1480)
|
- [X11] Bugfix: The CMake files did not check for the XInput headers (#1480)
|
||||||
- [X11] Bugfix: Key names were not updated when the keyboard layout changed
|
- [X11] Bugfix: Key names were not updated when the keyboard layout changed
|
||||||
(#1462,#1528)
|
(#1462,#1528)
|
||||||
@ -217,6 +236,8 @@ information on what to include when reporting a bug.
|
|||||||
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
|
||||||
|
- [Wayland] Added dynamic loading of all Wayland libraries
|
||||||
- [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
|
||||||
@ -227,25 +248,31 @@ information on what to include when reporting a bug.
|
|||||||
- [Wayland] Bugfix: Client-Side Decorations were destroyed in the wrong worder
|
- [Wayland] Bugfix: Client-Side Decorations were destroyed in the wrong worder
|
||||||
(#1798)
|
(#1798)
|
||||||
- [Wayland] Bugfix: Monitors physical size could report zero (#1784,#1792)
|
- [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)
|
||||||
|
- [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
|
||||||
- [NSGL] Removed enforcement of forward-compatible flag for core contexts
|
- [NSGL] Removed enforcement of forward-compatible flag for core contexts
|
||||||
- [NSGL] Bugfix: `GLFW_COCOA_RETINA_FRAMEBUFFER` had no effect on newer
|
- [NSGL] Bugfix: `GLFW_COCOA_RETINA_FRAMEBUFFER` had no effect on newer
|
||||||
macOS versions (#1442)
|
macOS versions (#1442)
|
||||||
- [NSGL] Bugfix: Workaround for swap interval on 10.14 broke on 10.12 (#1483)
|
- [NSGL] Bugfix: Workaround for swap interval on 10.14 broke on 10.12 (#1483)
|
||||||
|
- [NSGL] Bugfix: Defining `GL_SILENCE_DEPRECATION` externally caused
|
||||||
|
a duplicate definition warning (#1840)
|
||||||
- [EGL] Added platform selection via the `EGL_EXT_platform_base` extension
|
- [EGL] Added platform selection via the `EGL_EXT_platform_base` extension
|
||||||
(#442)
|
(#442)
|
||||||
- [EGL] Added ANGLE backend selection via `EGL_ANGLE_platform_angle` extension
|
- [EGL] Added ANGLE backend selection via `EGL_ANGLE_platform_angle` extension
|
||||||
(#1380)
|
(#1380)
|
||||||
|
- [EGL] Bugfix: The `GLFW_DOUBLEBUFFER` context attribute was ignored (#1843)
|
||||||
|
|
||||||
|
|
||||||
## Contact
|
## Contact
|
||||||
|
|
||||||
On [glfw.org](http://www.glfw.org/) you can find the latest version of GLFW, as
|
On [glfw.org](https://www.glfw.org/) you can find the latest version of GLFW, as
|
||||||
well as news, documentation and other information about the project.
|
well as news, documentation and other information about the project.
|
||||||
|
|
||||||
If you have questions related to the use of GLFW, we have a
|
If you have questions related to the use of GLFW, we have a
|
||||||
[forum](https://discourse.glfw.org/), and the `#glfw` IRC channel on
|
[forum](https://discourse.glfw.org/), and the `#glfw` IRC channel on
|
||||||
[Freenode](http://freenode.net/).
|
[Libera.Chat](https://libera.chat/).
|
||||||
|
|
||||||
If you have a bug to report, a patch to submit or a feature you'd like to
|
If you have a bug to report, a patch to submit or a feature you'd like to
|
||||||
request, please file it in the
|
request, please file it in the
|
||||||
@ -275,6 +302,7 @@ skills.
|
|||||||
- Denis Bernard
|
- Denis Bernard
|
||||||
- Doug Binks
|
- Doug Binks
|
||||||
- blanco
|
- blanco
|
||||||
|
- Waris Boonyasiriwat
|
||||||
- Kyle Brenneman
|
- Kyle Brenneman
|
||||||
- Rok Breulj
|
- Rok Breulj
|
||||||
- Kai Burjack
|
- Kai Burjack
|
||||||
@ -283,6 +311,7 @@ skills.
|
|||||||
- David Carlier
|
- David Carlier
|
||||||
- Arturo Castro
|
- Arturo Castro
|
||||||
- Chi-kwan Chan
|
- Chi-kwan Chan
|
||||||
|
- Joseph Chua
|
||||||
- Ian Clarkson
|
- Ian Clarkson
|
||||||
- Michał Cichoń
|
- Michał Cichoń
|
||||||
- Lambert Clara
|
- Lambert Clara
|
||||||
@ -292,6 +321,7 @@ skills.
|
|||||||
- Andrew Corrigan
|
- Andrew Corrigan
|
||||||
- Bailey Cosier
|
- Bailey Cosier
|
||||||
- Noel Cower
|
- Noel Cower
|
||||||
|
- CuriouserThing
|
||||||
- Jason Daly
|
- Jason Daly
|
||||||
- Jarrod Davis
|
- Jarrod Davis
|
||||||
- Olivier Delannoy
|
- Olivier Delannoy
|
||||||
@ -305,6 +335,7 @@ skills.
|
|||||||
- Fredrik Ehnbom
|
- Fredrik Ehnbom
|
||||||
- Robin Eklind
|
- Robin Eklind
|
||||||
- Siavash Eliasi
|
- Siavash Eliasi
|
||||||
|
- Ahmad Fatoum
|
||||||
- Felipe Ferreira
|
- Felipe Ferreira
|
||||||
- Michael Fogleman
|
- Michael Fogleman
|
||||||
- Gerald Franz
|
- Gerald Franz
|
||||||
@ -333,6 +364,7 @@ skills.
|
|||||||
- Arseny Kapoulkine
|
- Arseny Kapoulkine
|
||||||
- Cem Karan
|
- Cem Karan
|
||||||
- Osman Keskin
|
- Osman Keskin
|
||||||
|
- Koray Kilinc
|
||||||
- Josh Kilmer
|
- Josh Kilmer
|
||||||
- Byunghoon Kim
|
- Byunghoon Kim
|
||||||
- Cameron King
|
- Cameron King
|
||||||
@ -361,6 +393,7 @@ skills.
|
|||||||
- Adam Marcus
|
- Adam Marcus
|
||||||
- Célestin Marot
|
- Célestin Marot
|
||||||
- Kyle McDonald
|
- Kyle McDonald
|
||||||
|
- David V. McKay
|
||||||
- David Medlock
|
- David Medlock
|
||||||
- Bryce Mehring
|
- Bryce Mehring
|
||||||
- Jonathan Mercier
|
- Jonathan Mercier
|
||||||
@ -379,6 +412,7 @@ skills.
|
|||||||
- Martins Mozeiko
|
- Martins Mozeiko
|
||||||
- Julian Møller
|
- Julian Møller
|
||||||
- ndogxj
|
- ndogxj
|
||||||
|
- n3rdopolis
|
||||||
- Kristian Nielsen
|
- Kristian Nielsen
|
||||||
- Kamil Nowakowski
|
- Kamil Nowakowski
|
||||||
- onox
|
- onox
|
||||||
@ -422,6 +456,7 @@ skills.
|
|||||||
- Yoshiki Shibukawa
|
- Yoshiki Shibukawa
|
||||||
- Dmitri Shuralyov
|
- Dmitri Shuralyov
|
||||||
- Daniel Skorupski
|
- Daniel Skorupski
|
||||||
|
- Anthony Smith
|
||||||
- Bradley Smith
|
- Bradley Smith
|
||||||
- Cliff Smolinsky
|
- Cliff Smolinsky
|
||||||
- Patrick Snape
|
- Patrick Snape
|
||||||
@ -452,7 +487,6 @@ skills.
|
|||||||
- Torsten Walluhn
|
- Torsten Walluhn
|
||||||
- Patrick Walton
|
- Patrick Walton
|
||||||
- Xo Wang
|
- Xo Wang
|
||||||
- Waris
|
|
||||||
- Jay Weisskopf
|
- Jay Weisskopf
|
||||||
- Frank Wille
|
- Frank Wille
|
||||||
- Andy Williams
|
- Andy Williams
|
||||||
|
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
16
deps/linmath.h
vendored
16
deps/linmath.h
vendored
@ -5,6 +5,10 @@
|
|||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
/* 2021-03-21 Camilla Löwy <elmindreda@elmindreda.org>
|
||||||
|
* - Replaced double constants with float equivalents
|
||||||
|
*/
|
||||||
|
|
||||||
#ifdef LINMATH_NO_INLINE
|
#ifdef LINMATH_NO_INLINE
|
||||||
#define LINMATH_H_FUNC static
|
#define LINMATH_H_FUNC static
|
||||||
#else
|
#else
|
||||||
@ -575,17 +579,17 @@ LINMATH_H_FUNC void mat4x4_arcball(mat4x4 R, mat4x4 const M, vec2 const _a, vec2
|
|||||||
vec2 a; memcpy(a, _a, sizeof(a));
|
vec2 a; memcpy(a, _a, sizeof(a));
|
||||||
vec2 b; memcpy(b, _b, sizeof(b));
|
vec2 b; memcpy(b, _b, sizeof(b));
|
||||||
|
|
||||||
float z_a = 0.;
|
float z_a = 0.f;
|
||||||
float z_b = 0.;
|
float z_b = 0.f;
|
||||||
|
|
||||||
if(vec2_len(a) < 1.) {
|
if(vec2_len(a) < 1.f) {
|
||||||
z_a = sqrtf(1. - vec2_mul_inner(a, a));
|
z_a = sqrtf(1.f - vec2_mul_inner(a, a));
|
||||||
} else {
|
} else {
|
||||||
vec2_norm(a, a);
|
vec2_norm(a, a);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(vec2_len(b) < 1.) {
|
if(vec2_len(b) < 1.f) {
|
||||||
z_b = sqrtf(1. - vec2_mul_inner(b, b));
|
z_b = sqrtf(1.f - vec2_mul_inner(b, b));
|
||||||
} else {
|
} else {
|
||||||
vec2_norm(b, b);
|
vec2_norm(b, b);
|
||||||
}
|
}
|
||||||
|
@ -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")
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ section](https://discourse.glfw.org/c/support) of the forum, under the [Stack
|
|||||||
Overflow tag](https://stackoverflow.com/questions/tagged/glfw) or [Game
|
Overflow tag](https://stackoverflow.com/questions/tagged/glfw) or [Game
|
||||||
Development tag](https://gamedev.stackexchange.com/questions/tagged/glfw) on
|
Development tag](https://gamedev.stackexchange.com/questions/tagged/glfw) on
|
||||||
Stack Exchange or in the IRC channel `#glfw` on
|
Stack Exchange or in the IRC channel `#glfw` on
|
||||||
[Freenode](http://freenode.net/).
|
[Libera.Chat](https://libera.chat/).
|
||||||
|
|
||||||
Questions about the design or implementation of GLFW or about future plans
|
Questions about the design or implementation of GLFW or about future plans
|
||||||
should be asked in the [dev section](https://discourse.glfw.org/c/dev) of the
|
should be asked in the [dev section](https://discourse.glfw.org/c/dev) of the
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
# Support resources
|
# Support resources
|
||||||
|
|
||||||
See the [latest documentation](http://www.glfw.org/docs/latest/) for tutorials,
|
See the [latest documentation](https://www.glfw.org/docs/latest/) for tutorials,
|
||||||
guides and the API reference.
|
guides and the API reference.
|
||||||
|
|
||||||
If you have questions about using GLFW, we have a
|
If you have questions about using GLFW, we have a
|
||||||
[forum](https://discourse.glfw.org/), and the `#glfw` IRC channel on
|
[forum](https://discourse.glfw.org/), and the `#glfw` IRC channel on
|
||||||
[Freenode](http://freenode.net/).
|
[Libera.Chat](https://libera.chat/).
|
||||||
|
|
||||||
Bugs are reported to our [issue tracker](https://github.com/glfw/glfw/issues).
|
Bugs are reported to our [issue tracker](https://github.com/glfw/glfw/issues).
|
||||||
Please check the [contribution
|
Please check the [contribution
|
||||||
|
351
docs/compile.dox
351
docs/compile.dox
@ -10,164 +10,171 @@ build applications that use GLFW, see @ref build_guide.
|
|||||||
|
|
||||||
@section compile_cmake Using CMake
|
@section compile_cmake Using CMake
|
||||||
|
|
||||||
|
@note GLFW behaves like most other libraries that use CMake so this guide mostly
|
||||||
|
describes the basic configure/generate/compile sequence. If you are already
|
||||||
|
familiar with this from other projects, you may want to focus on the @ref
|
||||||
|
compile_deps and @ref compile_options sections for GLFW-specific information.
|
||||||
|
|
||||||
GLFW uses [CMake](https://cmake.org/) to generate project files or makefiles
|
GLFW uses [CMake](https://cmake.org/) to generate project files or makefiles
|
||||||
for a particular development environment. If you are on a Unix-like system such
|
for your chosen development environment. To compile GLFW, first generate these
|
||||||
as Linux or FreeBSD or have a package system like Fink, MacPorts, Cygwin or
|
files with CMake and then use them to compile the GLFW library.
|
||||||
Homebrew, you can install its CMake package. If not, you can download
|
|
||||||
installers for Windows and macOS from the
|
|
||||||
[CMake website](https://cmake.org/).
|
|
||||||
|
|
||||||
@note CMake only generates project files or makefiles. It does not compile the
|
If you are on Windows and macOS you can
|
||||||
actual GLFW library. To compile GLFW, first generate these files for your
|
[download CMake](https://cmake.org/download/) from their site.
|
||||||
chosen development environment and then use them to compile the actual GLFW
|
|
||||||
library.
|
If you are on a Unix-like system such as Linux, FreeBSD or Cygwin or have
|
||||||
|
a package system like Fink, MacPorts or Homebrew, you can install its CMake
|
||||||
|
package.
|
||||||
|
|
||||||
|
CMake is a complex tool and this guide will only show a few of the possible ways
|
||||||
|
to set up and compile GLFW. The CMake project has their own much more detailed
|
||||||
|
[CMake user guide](https://cmake.org/cmake/help/latest/guide/user-interaction/)
|
||||||
|
that includes everything in this guide not specific to GLFW. It may be a useful
|
||||||
|
companion to this one.
|
||||||
|
|
||||||
|
|
||||||
@subsection compile_deps Dependencies
|
@subsection compile_deps Installing dependencies
|
||||||
|
|
||||||
Once you have installed CMake, make sure that all other dependencies are
|
The C/C++ development environments in Visual Studio, Xcode and MinGW come with
|
||||||
available. On some platforms, GLFW needs a few additional packages to be
|
all necessary dependencies for compiling GLFW, but on Unix-like systems like
|
||||||
installed. See the section for your chosen platform and development environment
|
Linux and FreeBSD you will need a few extra packages.
|
||||||
below.
|
|
||||||
|
|
||||||
|
|
||||||
@subsubsection compile_deps_msvc Dependencies for Visual C++ on Windows
|
@subsubsection compile_deps_x11 Dependencies for X11 on Unix-like systems
|
||||||
|
|
||||||
The Windows SDK bundled with Visual C++ already contains all the necessary
|
To compile GLFW for X11, you need to have the X11 development packages
|
||||||
headers, link libraries and tools except for CMake. Move on to @ref
|
installed. They are not needed to build or run programs that use GLFW.
|
||||||
compile_generate.
|
|
||||||
|
|
||||||
|
On Debian and derivates like Ubuntu and Linux Mint the `xorg-dev` meta-package
|
||||||
@subsubsection compile_deps_mingw Dependencies for MinGW or MinGW-w64 on Windows
|
pulls in the development packages for all of X11.
|
||||||
|
|
||||||
Both the MinGW and the MinGW-w64 packages already contain all the necessary
|
|
||||||
headers, link libraries and tools except for CMake. Move on to @ref
|
|
||||||
compile_generate.
|
|
||||||
|
|
||||||
|
|
||||||
@subsubsection compile_deps_mingw_cross Dependencies for MinGW or MinGW-w64 cross-compilation
|
|
||||||
|
|
||||||
Both Cygwin and many Linux distributions have MinGW or MinGW-w64 packages. For
|
|
||||||
example, Cygwin has the `mingw64-i686-gcc` and `mingw64-x86_64-gcc` packages
|
|
||||||
for 32- and 64-bit version of MinGW-w64, while Debian GNU/Linux and derivatives
|
|
||||||
like Ubuntu have the `mingw-w64` package for both.
|
|
||||||
|
|
||||||
GLFW has CMake toolchain files in the `CMake/` directory that set up
|
|
||||||
cross-compilation of Windows binaries. To use these files you add an option
|
|
||||||
when running `cmake` to generate the project files or makefiles:
|
|
||||||
|
|
||||||
@code{.sh}
|
@code{.sh}
|
||||||
cmake -DCMAKE_TOOLCHAIN_FILE=<toolchain-file> .
|
sudo apt install xorg-dev
|
||||||
@endcode
|
@endcode
|
||||||
|
|
||||||
The exact toolchain file to use depends on the prefix used by the MinGW or
|
On Fedora and derivatives like Red Hat the X11 extension packages
|
||||||
MinGW-w64 binaries on your system. You can usually see this in the /usr
|
`libXcursor-devel`, `libXi-devel`, `libXinerama-devel` and `libXrandr-devel`
|
||||||
directory. For example, both the Debian/Ubuntu and Cygwin MinGW-w64 packages
|
required by GLFW pull in all its other dependencies.
|
||||||
have `/usr/x86_64-w64-mingw32` for the 64-bit compilers, so the correct
|
|
||||||
invocation would be:
|
|
||||||
|
|
||||||
@code{.sh}
|
@code{.sh}
|
||||||
cmake -DCMAKE_TOOLCHAIN_FILE=CMake/x86_64-w64-mingw32.cmake .
|
sudo dnf install libXcursor-devel libXi-devel libXinerama-devel libXrandr-devel
|
||||||
@endcode
|
@endcode
|
||||||
|
|
||||||
For more details see the article
|
On FreeBSD the X11 headers are installed along the end-user X11 packages, so if
|
||||||
[CMake Cross Compiling](https://gitlab.kitware.com/cmake/community/wikis/doc/cmake/CrossCompiling) on
|
you have an X server running you should have the headers as well. If not,
|
||||||
the CMake wiki.
|
install the `xorgproto` package.
|
||||||
|
|
||||||
Once you have this set up, move on to @ref compile_generate.
|
@code{.sh}
|
||||||
|
pkg install xorgproto
|
||||||
|
@endcode
|
||||||
|
|
||||||
|
On Cygwin the `xorgproto` package in the Devel section of the GUI installer will
|
||||||
|
install the headers and other development related files for all of X11.
|
||||||
|
|
||||||
|
Once you have the required depdendencies, move on to @ref compile_generate.
|
||||||
|
|
||||||
|
|
||||||
@subsubsection compile_deps_xcode Dependencies for Xcode on macOS
|
@subsubsection compile_deps_wayland Dependencies for Wayland on Unix-like systems
|
||||||
|
|
||||||
Xcode comes with all necessary tools except for CMake. The required headers
|
To compile GLFW for Wayland, you need to have the Wayland and xkbcommon
|
||||||
and libraries are included in the core macOS frameworks. Xcode can be
|
development packages installed. They are not needed to build or run programs
|
||||||
downloaded from the Mac App Store or from the ADC Member Center.
|
that use GLFW.
|
||||||
|
|
||||||
Once you have Xcode installed, move on to @ref compile_generate.
|
On Debian and derivates like Ubuntu and Linux Mint you will need the
|
||||||
|
`libwayland-dev`, `libxkbcommon-dev` and `wayland-protocols` packages.
|
||||||
|
|
||||||
|
@code{.sh}
|
||||||
|
sudo apt install libwayland-dev libxkbcommon-dev wayland-protocols
|
||||||
|
@endcode
|
||||||
|
|
||||||
@subsubsection compile_deps_x11 Dependencies for Linux and X11
|
On Fedora and derivatives like Red Hat you will need the `wayland-devel`,
|
||||||
|
`libxkbcommon-devel` and `wayland-protocols-devel` packages.
|
||||||
|
|
||||||
To compile GLFW for X11, you need to have the X11 packages installed, as well as
|
@code{.sh}
|
||||||
the basic development tools like GCC and make. For example, on Ubuntu and other
|
sudo dnf install wayland-devel libxkbcommon-devel wayland-protocols-devel
|
||||||
distributions based on Debian GNU/Linux, you need to install the `xorg-dev`
|
@endcode
|
||||||
package, which pulls in all X.org header packages.
|
|
||||||
|
|
||||||
Once you have installed the necessary packages, move on to @ref
|
On FreeBSD you will need the `wayland`, `libxkbcommon` and `wayland-protocols`
|
||||||
compile_generate.
|
packages.
|
||||||
|
|
||||||
|
@code{.sh}
|
||||||
|
pkg install wayland libxkbcommon wayland-protocols
|
||||||
|
@endcode
|
||||||
|
|
||||||
@subsubsection compile_deps_wayland Dependencies for Linux and Wayland
|
Once you have the required depdendencies, move on to @ref compile_generate.
|
||||||
|
|
||||||
To compile GLFW for Wayland, you need to have the Wayland packages installed,
|
|
||||||
as well as the basic development tools like GCC and make. For example, on
|
|
||||||
Ubuntu and other distributions based on Debian GNU/Linux, you need to install
|
|
||||||
the `libwayland-dev` package, which contains all Wayland headers and pulls in
|
|
||||||
wayland-scanner, as well as the `wayland-protocols` package.
|
|
||||||
|
|
||||||
Once you have installed the necessary packages, move on to @ref
|
|
||||||
compile_generate.
|
|
||||||
|
|
||||||
|
|
||||||
@subsection compile_deps_osmesa Dependencies for Linux and OSMesa
|
|
||||||
|
|
||||||
To compile GLFW for OSMesa, you need to install the OSMesa library and header
|
|
||||||
packages. For example, on Ubuntu and other distributions based on Debian
|
|
||||||
GNU/Linux, you need to install the `libosmesa6-dev` package. The OSMesa library
|
|
||||||
is required at runtime for context creation and is loaded on demand.
|
|
||||||
|
|
||||||
Once you have installed the necessary packages, move on to @ref
|
|
||||||
compile_generate.
|
|
||||||
|
|
||||||
|
|
||||||
@subsection compile_generate Generating build files with CMake
|
@subsection compile_generate Generating build files with CMake
|
||||||
|
|
||||||
Once you have all necessary dependencies it is time to generate the project
|
Once you have all necessary dependencies it is time to generate the project
|
||||||
files or makefiles for your development environment. CMake needs to know two
|
files or makefiles for your development environment. CMake needs two paths for
|
||||||
paths for this: the path to the _root_ directory of the GLFW source tree (i.e.
|
this:
|
||||||
_not_ the `src` subdirectory) and the target path for the generated files and
|
|
||||||
compiled binaries. If these are the same, it is called an in-tree build,
|
|
||||||
otherwise it is called an out-of-tree build.
|
|
||||||
|
|
||||||
One of several advantages of out-of-tree builds is that you can generate files
|
- the path to the root directory of the GLFW source tree (not its `src`
|
||||||
and compile for different development environments using a single source tree.
|
subdirectory)
|
||||||
|
- the path to the directory where the generated build files and compiled
|
||||||
|
binaries will be placed
|
||||||
|
|
||||||
@note This section is about generating the project files or makefiles necessary
|
If these are the same, it is called an in-tree build, otherwise it is called an
|
||||||
to compile the GLFW library, not about compiling the actual library.
|
out-of-tree build.
|
||||||
|
|
||||||
|
Out-of-tree builds are recommended as they avoid cluttering up the source tree.
|
||||||
|
They also allow you to have several build directories for different
|
||||||
|
configurations all using the same source tree.
|
||||||
|
|
||||||
|
A common pattern when building a single configuration is to have a build
|
||||||
|
directory named `build` in the root of the source tree.
|
||||||
|
|
||||||
|
|
||||||
@subsubsection compile_generate_cli Generating files with the CMake command-line tool
|
@subsubsection compile_generate_gui Generating files with the CMake GUI
|
||||||
|
|
||||||
To make an in-tree build, enter the _root_ directory of the GLFW source tree
|
Start the CMake GUI and set the paths to the source and build directories
|
||||||
(i.e. _not_ the `src` subdirectory) and run CMake. The current directory is
|
described above. Then press _Configure_ and _Generate_.
|
||||||
used as target path, while the path provided as an argument is used to find the
|
|
||||||
source tree.
|
|
||||||
|
|
||||||
@code{.sh}
|
If you wish change any CMake variables in the list, press _Configure_ and then
|
||||||
cd <glfw-root-dir>
|
_Generate_ to have the new values take effect. The variable list will be
|
||||||
cmake .
|
populated after the first configure step.
|
||||||
@endcode
|
|
||||||
|
|
||||||
To make an out-of-tree build, make a directory outside of the source tree, enter
|
By default GLFW will use X11 on Linux and other Unix-like systems other
|
||||||
it and run CMake with the (relative or absolute) path to the root of the source
|
than macOS. To use Wayland instead, set the `GLFW_USE_WAYLAND` option in the
|
||||||
tree as an argument.
|
GLFW section of the variable list, then apply the new value as described above.
|
||||||
|
|
||||||
@code{.sh}
|
|
||||||
mkdir glfw-build
|
|
||||||
cd glfw-build
|
|
||||||
cmake <glfw-root-dir>
|
|
||||||
@endcode
|
|
||||||
|
|
||||||
Once you have generated the project files or makefiles for your chosen
|
Once you have generated the project files or makefiles for your chosen
|
||||||
development environment, move on to @ref compile_compile.
|
development environment, move on to @ref compile_compile.
|
||||||
|
|
||||||
|
|
||||||
@subsubsection compile_generate_gui Generating files with the CMake GUI
|
@subsubsection compile_generate_cli Generating files with the CMake command-line tool
|
||||||
|
|
||||||
If you are using the GUI version, choose the root of the GLFW source tree as
|
To make a build directory, pass the source and build directories to the `cmake`
|
||||||
source location and the same directory or another, empty directory as the
|
command. These can be relative or absolute paths. The build directory is
|
||||||
destination for binaries. Choose _Configure_, change any options you wish to,
|
created if it doesn't already exist.
|
||||||
_Configure_ again to let the changes take effect and then _Generate_.
|
|
||||||
|
@code{.sh}
|
||||||
|
cmake -S path/to/glfw -B path/to/build
|
||||||
|
@endcode
|
||||||
|
|
||||||
|
It is common to name the build directory `build` and place it in the root of the
|
||||||
|
source tree when only planning to build a single configuration.
|
||||||
|
|
||||||
|
@code{.sh}
|
||||||
|
cd path/to/glfw
|
||||||
|
cmake -S . -B build
|
||||||
|
@endcode
|
||||||
|
|
||||||
|
Without other flags these will generate Visual Studio project files on Windows
|
||||||
|
and makefiles on other platforms. You can choose other targets using the `-G`
|
||||||
|
flag.
|
||||||
|
|
||||||
|
@code{.sh}
|
||||||
|
cmake -S path/to/glfw -B path/to/build -G Xcode
|
||||||
|
@endcode
|
||||||
|
|
||||||
|
By default GLFW will use X11 on Linux and other Unix-like systems other
|
||||||
|
than macOS. To use Wayland instead, set the `GLFW_USE_WAYLAND` CMake option.
|
||||||
|
|
||||||
|
@code{.sh}
|
||||||
|
cmake -S path/to/glfw -B path/to/build -D GLFW_USE_WAYLAND=1
|
||||||
|
@endcode
|
||||||
|
|
||||||
Once you have generated the project files or makefiles for your chosen
|
Once you have generated the project files or makefiles for your chosen
|
||||||
development environment, move on to @ref compile_compile.
|
development environment, move on to @ref compile_compile.
|
||||||
@ -177,13 +184,39 @@ development environment, move on to @ref compile_compile.
|
|||||||
|
|
||||||
You should now have all required dependencies and the project files or makefiles
|
You should now have all required dependencies and the project files or makefiles
|
||||||
necessary to compile GLFW. Go ahead and compile the actual GLFW library with
|
necessary to compile GLFW. Go ahead and compile the actual GLFW library with
|
||||||
these files, as you would with any other project.
|
these files as you would with any other project.
|
||||||
|
|
||||||
Once the GLFW library is compiled, you are ready to build your applications,
|
With Visual Studio open `GLFW.sln` and use the Build menu. With Xcode open
|
||||||
|
`GLFW.xcodeproj` and use the Project menu.
|
||||||
|
|
||||||
|
With Linux, macOS and other forms of Unix, run `make`.
|
||||||
|
|
||||||
|
@code{.sh}
|
||||||
|
cd path/to/build
|
||||||
|
make
|
||||||
|
@endcode
|
||||||
|
|
||||||
|
With MinGW, it is `mingw32-make`.
|
||||||
|
|
||||||
|
@code{.sh}
|
||||||
|
cd path/to/build
|
||||||
|
mingw32-make
|
||||||
|
@endcode
|
||||||
|
|
||||||
|
Any CMake build directory can also be built with the `cmake` command and the
|
||||||
|
`--build` flag.
|
||||||
|
|
||||||
|
@code{.sh}
|
||||||
|
cmake --build path/to/build
|
||||||
|
@endcode
|
||||||
|
|
||||||
|
This will run the platform specific build tool the directory was generated for.
|
||||||
|
|
||||||
|
Once the GLFW library is compiled you are ready to build your application,
|
||||||
linking it to the GLFW library. See @ref build_guide for more information.
|
linking it to the GLFW library. See @ref build_guide for more information.
|
||||||
|
|
||||||
|
|
||||||
@subsection compile_options CMake options
|
@section compile_options CMake options
|
||||||
|
|
||||||
The CMake files for GLFW provide a number of options, although not all are
|
The CMake files for GLFW provide a number of options, although not all are
|
||||||
available on all supported platforms. Some of these are de facto standards
|
available on all supported platforms. Some of these are de facto standards
|
||||||
@ -199,55 +232,112 @@ Finally, if you don't want to use any GUI, you can set options from the `cmake`
|
|||||||
command-line with the `-D` flag.
|
command-line with the `-D` flag.
|
||||||
|
|
||||||
@code{.sh}
|
@code{.sh}
|
||||||
cmake -DBUILD_SHARED_LIBS=ON .
|
cmake -S path/to/glfw -B path/to/build -D BUILD_SHARED_LIBS=ON
|
||||||
@endcode
|
@endcode
|
||||||
|
|
||||||
|
|
||||||
@subsubsection compile_options_shared Shared CMake options
|
@subsection compile_options_shared Shared CMake options
|
||||||
|
|
||||||
@anchor BUILD_SHARED_LIBS
|
@anchor BUILD_SHARED_LIBS
|
||||||
__BUILD_SHARED_LIBS__ determines whether GLFW is built as a static
|
__BUILD_SHARED_LIBS__ determines whether GLFW is built as a static library or as
|
||||||
library or as a DLL / shared library / dynamic library.
|
a DLL / shared library / dynamic library. This is disabled by default,
|
||||||
|
producing a static GLFW library. This variable has no `GLFW_` prefix because it
|
||||||
|
is defined by CMake. If you want to change the library only for GLFW when it is
|
||||||
|
part of a larger project, see @ref GLFW_LIBRARY_TYPE.
|
||||||
|
|
||||||
|
@anchor GLFW_LIBRARY_TYPE
|
||||||
|
__GLFW_LIBRARY_TYPE__ allows you to override @ref BUILD_SHARED_LIBS only for
|
||||||
|
GLFW, without affecting other libraries in a larger project. When set, the
|
||||||
|
value of this option must be a valid CMake library type. Set it to `STATIC` to
|
||||||
|
build GLFW as a static library, `SHARED` to build it as a shared library
|
||||||
|
/ dynamic library / DLL, or `OBJECT` to make GLFW a CMake object library.
|
||||||
|
|
||||||
@anchor GLFW_BUILD_EXAMPLES
|
@anchor GLFW_BUILD_EXAMPLES
|
||||||
__GLFW_BUILD_EXAMPLES__ determines whether the GLFW examples are built
|
__GLFW_BUILD_EXAMPLES__ determines whether the GLFW examples are built
|
||||||
along with the library. This is enabled by default unless GLFW is being built
|
along with the library. This is enabled by default unless GLFW is being built
|
||||||
as a sub-project.
|
as a sub-project of a larger CMake project.
|
||||||
|
|
||||||
@anchor GLFW_BUILD_TESTS
|
@anchor GLFW_BUILD_TESTS
|
||||||
__GLFW_BUILD_TESTS__ determines whether the GLFW test programs are
|
__GLFW_BUILD_TESTS__ determines whether the GLFW test programs are
|
||||||
built along with the library. This is enabled by default unless GLFW is being
|
built along with the library. This is enabled by default unless GLFW is being
|
||||||
built as a sub-project.
|
built as a sub-project of a larger CMake project.
|
||||||
|
|
||||||
@anchor GLFW_BUILD_DOCS
|
@anchor GLFW_BUILD_DOCS
|
||||||
__GLFW_BUILD_DOCS__ determines whether the GLFW documentation is built along
|
__GLFW_BUILD_DOCS__ determines whether the GLFW documentation is built along
|
||||||
with the library.
|
with the library. This is enabled by default if
|
||||||
|
[Doxygen](https://www.doxygen.nl/) is found by CMake during configuration.
|
||||||
|
|
||||||
@anchor GLFW_VULKAN_STATIC
|
@anchor GLFW_VULKAN_STATIC
|
||||||
__GLFW_VULKAN_STATIC__ determines whether to use the Vulkan loader linked
|
__GLFW_VULKAN_STATIC__ determines whether to use the Vulkan loader linked
|
||||||
directly with the application.
|
directly with the application. This is disabled by default.
|
||||||
|
|
||||||
|
|
||||||
@subsubsection compile_options_win32 Windows specific CMake options
|
@subsection compile_options_win32 Windows specific CMake options
|
||||||
|
|
||||||
@anchor USE_MSVC_RUNTIME_LIBRARY_DLL
|
@anchor USE_MSVC_RUNTIME_LIBRARY_DLL
|
||||||
__USE_MSVC_RUNTIME_LIBRARY_DLL__ determines whether to use the DLL version or the
|
__USE_MSVC_RUNTIME_LIBRARY_DLL__ determines whether to use the DLL version or the
|
||||||
static library version of the Visual C++ runtime library. If set to `ON`, the
|
static library version of the Visual C++ runtime library. When enabled, the
|
||||||
DLL version of the Visual C++ library is used.
|
DLL version of the Visual C++ library is used. This is enabled by default.
|
||||||
|
|
||||||
|
On CMake 3.15 and later you can set the standard CMake
|
||||||
|
[CMAKE_MSVC_RUNTIME_LIBRARY](https://cmake.org/cmake/help/latest/variable/CMAKE_MSVC_RUNTIME_LIBRARY.html)
|
||||||
|
variable instead of this GLFW-specific option.
|
||||||
|
|
||||||
@anchor GLFW_USE_HYBRID_HPG
|
@anchor GLFW_USE_HYBRID_HPG
|
||||||
__GLFW_USE_HYBRID_HPG__ determines whether to export the `NvOptimusEnablement` and
|
__GLFW_USE_HYBRID_HPG__ determines whether to export the `NvOptimusEnablement` and
|
||||||
`AmdPowerXpressRequestHighPerformance` symbols, which force the use of the
|
`AmdPowerXpressRequestHighPerformance` symbols, which force the use of the
|
||||||
high-performance GPU on Nvidia Optimus and AMD PowerXpress systems. These symbols
|
high-performance GPU on Nvidia Optimus and AMD PowerXpress systems. These symbols
|
||||||
need to be exported by the EXE to be detected by the driver, so the override
|
need to be exported by the EXE to be detected by the driver, so the override
|
||||||
will not work if GLFW is built as a DLL.
|
will not work if GLFW is built as a DLL. This is disabled by default, letting
|
||||||
|
the operating system and driver decide.
|
||||||
|
|
||||||
|
|
||||||
|
@subsection compile_options_wayland Wayland specific CMake options
|
||||||
|
|
||||||
|
@anchor GLFW_USE_WAYLAND
|
||||||
|
__GLFW_USE_WAYLAND__ determines whether to compile the library for Wayland.
|
||||||
|
This option is only available on Linux and other Unix-like systems other than
|
||||||
|
macOS. This is disabled by default.
|
||||||
|
|
||||||
|
|
||||||
|
@section compile_mingw_cross Cross-compilation with CMake and MinGW
|
||||||
|
|
||||||
|
Both Cygwin and many Linux distributions have MinGW or MinGW-w64 packages. For
|
||||||
|
example, Cygwin has the `mingw64-i686-gcc` and `mingw64-x86_64-gcc` packages
|
||||||
|
for 32- and 64-bit version of MinGW-w64, while Debian GNU/Linux and derivatives
|
||||||
|
like Ubuntu have the `mingw-w64` package for both.
|
||||||
|
|
||||||
|
GLFW has CMake toolchain files in the `CMake` subdirectory that set up
|
||||||
|
cross-compilation of Windows binaries. To use these files you set the
|
||||||
|
`CMAKE_TOOLCHAIN_FILE` CMake variable with the `-D` flag add an option when
|
||||||
|
configuring and generating the build files.
|
||||||
|
|
||||||
|
@code{.sh}
|
||||||
|
cmake -S path/to/glfw -B path/to/build -D CMAKE_TOOLCHAIN_FILE=path/to/file
|
||||||
|
@endcode
|
||||||
|
|
||||||
|
The exact toolchain file to use depends on the prefix used by the MinGW or
|
||||||
|
MinGW-w64 binaries on your system. You can usually see this in the /usr
|
||||||
|
directory. For example, both the Ubuntu and Cygwin MinGW-w64 packages have
|
||||||
|
`/usr/x86_64-w64-mingw32` for the 64-bit compilers, so the correct invocation
|
||||||
|
would be:
|
||||||
|
|
||||||
|
@code{.sh}
|
||||||
|
cmake -S path/to/glfw -B path/to/build -D CMAKE_TOOLCHAIN_FILE=CMake/x86_64-w64-mingw32.cmake
|
||||||
|
@endcode
|
||||||
|
|
||||||
|
The path to the toolchain file is relative to the path to the GLFW source tree
|
||||||
|
passed to the `-S` flag, not to the current directory.
|
||||||
|
|
||||||
|
For more details see the
|
||||||
|
[CMake toolchain guide](https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html).
|
||||||
|
|
||||||
|
|
||||||
@section compile_manual Compiling GLFW manually
|
@section compile_manual Compiling GLFW manually
|
||||||
|
|
||||||
If you wish to compile GLFW without its CMake build environment then you will
|
If you wish to compile GLFW without its CMake build environment then you will
|
||||||
have to do at least some of the platform detection yourself. GLFW needs
|
have to do at least some of the platform detection yourself. GLFW needs
|
||||||
a configuration macro to be defined in order to know what window system it's
|
a configuration macro to be defined in order to know what window system it is
|
||||||
being compiled for and also has optional, platform-specific ones for various
|
being compiled for and also has optional, platform-specific ones for various
|
||||||
features.
|
features.
|
||||||
|
|
||||||
@ -279,11 +369,6 @@ of @b _GLFW_VULKAN_LIBRARY, @b _GLFW_EGL_LIBRARY, @b _GLFW_GLX_LIBRARY, @b
|
|||||||
_GLFW_OSMESA_LIBRARY, @b _GLFW_OPENGL_LIBRARY, @b _GLFW_GLESV1_LIBRARY and @b
|
_GLFW_OSMESA_LIBRARY, @b _GLFW_OPENGL_LIBRARY, @b _GLFW_GLESV1_LIBRARY and @b
|
||||||
_GLFW_GLESV2_LIBRARY. Otherwise, GLFW will use the built-in default names.
|
_GLFW_GLESV2_LIBRARY. Otherwise, GLFW will use the built-in default names.
|
||||||
|
|
||||||
For the EGL context creation API, the following options are available:
|
|
||||||
|
|
||||||
- @b _GLFW_USE_EGLPLATFORM_H to use an existing `EGL/eglplatform.h` header file
|
|
||||||
for native handle types (fallback)
|
|
||||||
|
|
||||||
@note None of the @ref build_macros may be defined during the compilation of
|
@note None of the @ref build_macros may be defined during the compilation of
|
||||||
GLFW. If you define any of these in your build files, make sure they are not
|
GLFW. If you define any of these in your build files, make sure they are not
|
||||||
applied to the GLFW sources.
|
applied to the GLFW sources.
|
||||||
|
@ -180,9 +180,9 @@ as extensions until they become obsolete.
|
|||||||
|
|
||||||
An extension is defined by:
|
An extension is defined by:
|
||||||
|
|
||||||
- An extension name (e.g. `GL_ARB_debug_output`)
|
- An extension name (e.g. `GL_ARB_gl_spirv`)
|
||||||
- New OpenGL tokens (e.g. `GL_DEBUG_SEVERITY_HIGH_ARB`)
|
- New OpenGL tokens (e.g. `GL_SPIR_V_BINARY_ARB`)
|
||||||
- New OpenGL functions (e.g. `glGetDebugMessageLogARB`)
|
- New OpenGL functions (e.g. `glSpecializeShaderARB`)
|
||||||
|
|
||||||
Note the `ARB` affix, which stands for Architecture Review Board and is used
|
Note the `ARB` affix, which stands for Architecture Review Board and is used
|
||||||
for official extensions. The extension above was created by the ARB, but there
|
for official extensions. The extension above was created by the ARB, but there
|
||||||
@ -267,9 +267,9 @@ To check whether a specific extension is supported, use the `GLAD_GL_xxx`
|
|||||||
booleans.
|
booleans.
|
||||||
|
|
||||||
@code
|
@code
|
||||||
if (GLAD_GL_ARB_debug_output)
|
if (GLAD_GL_ARB_gl_spirv)
|
||||||
{
|
{
|
||||||
// Use GL_ARB_debug_output
|
// Use GL_ARB_gl_spirv
|
||||||
}
|
}
|
||||||
@endcode
|
@endcode
|
||||||
|
|
||||||
@ -301,8 +301,8 @@ included in your development environment may be several years out of date and
|
|||||||
may not include the extensions you wish to use.
|
may not include the extensions you wish to use.
|
||||||
|
|
||||||
The header defines function pointer types for all functions of all extensions it
|
The header defines function pointer types for all functions of all extensions it
|
||||||
supports. These have names like `PFNGLGETDEBUGMESSAGELOGARBPROC` (for
|
supports. These have names like `PFNGLSPECIALIZESHADERARBPROC` (for
|
||||||
`glGetDebugMessageLogARB`), i.e. the name is made uppercase and `PFN` (pointer
|
`glSpecializeShaderARB`), i.e. the name is made uppercase and `PFN` (pointer
|
||||||
to function) and `PROC` (procedure) are added to the ends.
|
to function) and `PROC` (procedure) are added to the ends.
|
||||||
|
|
||||||
To include the extension header, define @ref GLFW_INCLUDE_GLEXT before including
|
To include the extension header, define @ref GLFW_INCLUDE_GLEXT before including
|
||||||
@ -322,7 +322,7 @@ is necessary to check at run-time whether the context supports the extension.
|
|||||||
This is done with @ref glfwExtensionSupported.
|
This is done with @ref glfwExtensionSupported.
|
||||||
|
|
||||||
@code
|
@code
|
||||||
if (glfwExtensionSupported("GL_ARB_debug_output"))
|
if (glfwExtensionSupported("GL_ARB_gl_spirv"))
|
||||||
{
|
{
|
||||||
// The extension is supported by the current context
|
// The extension is supported by the current context
|
||||||
}
|
}
|
||||||
@ -341,7 +341,7 @@ your operating system, making it necessary to fetch them at run time. You can
|
|||||||
retrieve pointers to these functions with @ref glfwGetProcAddress.
|
retrieve pointers to these functions with @ref glfwGetProcAddress.
|
||||||
|
|
||||||
@code
|
@code
|
||||||
PFNGLGETDEBUGMESSAGELOGARBPROC pfnGetDebugMessageLog = glfwGetProcAddress("glGetDebugMessageLogARB");
|
PFNGLSPECIALIZESHADERARBPROC pfnSpecializeShaderARB = glfwGetProcAddress("glSpecializeShaderARB");
|
||||||
@endcode
|
@endcode
|
||||||
|
|
||||||
In general, you should avoid giving the function pointer variables the (exact)
|
In general, you should avoid giving the function pointer variables the (exact)
|
||||||
@ -355,28 +355,28 @@ when used together.
|
|||||||
#define GLFW_INCLUDE_GLEXT
|
#define GLFW_INCLUDE_GLEXT
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
|
|
||||||
#define glGetDebugMessageLogARB pfnGetDebugMessageLog
|
#define glSpecializeShaderARB pfnSpecializeShaderARB
|
||||||
PFNGLGETDEBUGMESSAGELOGARBPROC pfnGetDebugMessageLog;
|
PFNGLSPECIALIZESHADERARBPROC pfnSpecializeShaderARB;
|
||||||
|
|
||||||
// Flag indicating whether the extension is supported
|
// Flag indicating whether the extension is supported
|
||||||
int has_ARB_debug_output = 0;
|
int has_ARB_gl_spirv = 0;
|
||||||
|
|
||||||
void load_extensions(void)
|
void load_extensions(void)
|
||||||
{
|
{
|
||||||
if (glfwExtensionSupported("GL_ARB_debug_output"))
|
if (glfwExtensionSupported("GL_ARB_gl_spirv"))
|
||||||
{
|
{
|
||||||
pfnGetDebugMessageLog = (PFNGLGETDEBUGMESSAGELOGARBPROC)
|
pfnSpecializeShaderARB = (PFNGLSPECIALIZESHADERARBPROC)
|
||||||
glfwGetProcAddress("glGetDebugMessageLogARB");
|
glfwGetProcAddress("glSpecializeShaderARB");
|
||||||
has_ARB_debug_output = 1;
|
has_ARB_gl_spirv = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void some_function(void)
|
void some_function(void)
|
||||||
{
|
{
|
||||||
if (has_ARB_debug_output)
|
if (has_ARB_gl_spirv)
|
||||||
{
|
{
|
||||||
// Now the extension function can be called as usual
|
// Now the extension function can be called as usual
|
||||||
glGetDebugMessageLogARB(...);
|
glSpecializeShaderARB(...);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@endcode
|
@endcode
|
||||||
|
@ -797,6 +797,11 @@ glfwUpdateGamepadMappings(mappings);
|
|||||||
This function supports everything from single lines up to and including the
|
This function supports everything from single lines up to and including the
|
||||||
unmodified contents of the whole `gamecontrollerdb.txt` file.
|
unmodified contents of the whole `gamecontrollerdb.txt` file.
|
||||||
|
|
||||||
|
If you are compiling GLFW from source with CMake you can update the built-in mappings by
|
||||||
|
building the _update_mappings_ target. This runs the `GenerateMappings.cmake` CMake
|
||||||
|
script, which downloads `gamecontrollerdb.txt` and regenerates the `mappings.h` header
|
||||||
|
file.
|
||||||
|
|
||||||
Below is a description of the mapping format. Please keep in mind that __this
|
Below is a description of the mapping format. Please keep in mind that __this
|
||||||
description is not authoritative__. The format is defined by the SDL and
|
description is not authoritative__. The format is defined by the SDL and
|
||||||
SDL_GameControllerDB projects and their documentation and code takes precedence.
|
SDL_GameControllerDB projects and their documentation and code takes precedence.
|
||||||
|
@ -33,6 +33,7 @@ successfully initialized, and only from the main thread.
|
|||||||
- @ref glfwGetError
|
- @ref glfwGetError
|
||||||
- @ref glfwSetErrorCallback
|
- @ref glfwSetErrorCallback
|
||||||
- @ref glfwInitHint
|
- @ref glfwInitHint
|
||||||
|
- @ref glfwInitAllocator
|
||||||
- @ref glfwInit
|
- @ref glfwInit
|
||||||
- @ref glfwTerminate
|
- @ref glfwTerminate
|
||||||
|
|
||||||
@ -103,7 +104,6 @@ one of `GLFW_ANGLE_PLATFORM_TYPE_NONE`, `GLFW_ANGLE_PLATFORM_TYPE_OPENGL`,
|
|||||||
`GLFW_ANGLE_PLATFORM_TYPE_D3D11`, `GLFW_ANGLE_PLATFORM_TYPE_VULKAN` and
|
`GLFW_ANGLE_PLATFORM_TYPE_D3D11`, `GLFW_ANGLE_PLATFORM_TYPE_VULKAN` and
|
||||||
`GLFW_ANGLE_PLATFORM_TYPE_METAL`.
|
`GLFW_ANGLE_PLATFORM_TYPE_METAL`.
|
||||||
|
|
||||||
@par
|
|
||||||
The ANGLE platform type is specified via the `EGL_ANGLE_platform_angle`
|
The ANGLE platform type is specified via the `EGL_ANGLE_platform_angle`
|
||||||
extension. This extension is not used if this hint is
|
extension. This extension is not used if this hint is
|
||||||
`GLFW_ANGLE_PLATFORM_TYPE_NONE`, which is the default value.
|
`GLFW_ANGLE_PLATFORM_TYPE_NONE`, which is the default value.
|
||||||
@ -124,14 +124,82 @@ a nib or manually by GLFW. Possible values are `GLFW_TRUE` and `GLFW_FALSE`.
|
|||||||
This is ignored on other platforms.
|
This is ignored on other platforms.
|
||||||
|
|
||||||
|
|
||||||
|
@subsubsection init_hints_x11 X11 specific init hints
|
||||||
|
|
||||||
|
@anchor GLFW_X11_XCB_VULKAN_SURFACE_hint
|
||||||
|
__GLFW_X11_XCB_VULKAN_SURFACE__ specifies whether to prefer the
|
||||||
|
`VK_KHR_xcb_surface` extension for creating Vulkan surfaces, or whether to use
|
||||||
|
the `VK_KHR_xlib_surface` extension. Possible values are `GLFW_TRUE` and
|
||||||
|
`GLFW_FALSE`. This is ignored on other platforms.
|
||||||
|
|
||||||
|
|
||||||
@subsubsection init_hints_values Supported and default values
|
@subsubsection init_hints_values Supported and default values
|
||||||
|
|
||||||
Initialization hint | Default value | Supported values
|
Initialization hint | Default value | Supported values
|
||||||
------------------------------- | ------------------------------- | ----------------
|
-------------------------------- | ------------------------------- | ----------------
|
||||||
@ref GLFW_JOYSTICK_HAT_BUTTONS | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE`
|
@ref GLFW_JOYSTICK_HAT_BUTTONS | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE`
|
||||||
@ref GLFW_ANGLE_PLATFORM_TYPE | `GLFW_ANGLE_PLATFORM_TYPE_NONE` | `GLFW_ANGLE_PLATFORM_TYPE_NONE`, `GLFW_ANGLE_PLATFORM_TYPE_OPENGL`, `GLFW_ANGLE_PLATFORM_TYPE_OPENGLES`, `GLFW_ANGLE_PLATFORM_TYPE_D3D9`, `GLFW_ANGLE_PLATFORM_TYPE_D3D11`, `GLFW_ANGLE_PLATFORM_TYPE_VULKAN` or `GLFW_ANGLE_PLATFORM_TYPE_METAL`
|
@ref GLFW_ANGLE_PLATFORM_TYPE | `GLFW_ANGLE_PLATFORM_TYPE_NONE` | `GLFW_ANGLE_PLATFORM_TYPE_NONE`, `GLFW_ANGLE_PLATFORM_TYPE_OPENGL`, `GLFW_ANGLE_PLATFORM_TYPE_OPENGLES`, `GLFW_ANGLE_PLATFORM_TYPE_D3D9`, `GLFW_ANGLE_PLATFORM_TYPE_D3D11`, `GLFW_ANGLE_PLATFORM_TYPE_VULKAN` or `GLFW_ANGLE_PLATFORM_TYPE_METAL`
|
||||||
@ref GLFW_COCOA_CHDIR_RESOURCES | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE`
|
@ref GLFW_COCOA_CHDIR_RESOURCES | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE`
|
||||||
@ref GLFW_COCOA_MENUBAR | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE`
|
@ref GLFW_COCOA_MENUBAR | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE`
|
||||||
|
@ref GLFW_X11_XCB_VULKAN_SURFACE | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE`
|
||||||
|
|
||||||
|
|
||||||
|
@subsection 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
|
||||||
|
@ -53,6 +53,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
|
||||||
@ -127,7 +137,18 @@ 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
|
||||||
|
|
||||||
|
|
||||||
@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_POINTING_HAND_CURSOR
|
- @ref GLFW_POINTING_HAND_CURSOR
|
||||||
@ -151,6 +172,7 @@ then GLFW will fail to initialize.
|
|||||||
- @ref GLFW_ANGLE_PLATFORM_TYPE_D3D11
|
- @ref GLFW_ANGLE_PLATFORM_TYPE_D3D11
|
||||||
- @ref GLFW_ANGLE_PLATFORM_TYPE_VULKAN
|
- @ref GLFW_ANGLE_PLATFORM_TYPE_VULKAN
|
||||||
- @ref GLFW_ANGLE_PLATFORM_TYPE_METAL
|
- @ref GLFW_ANGLE_PLATFORM_TYPE_METAL
|
||||||
|
- @ref GLFW_X11_XCB_VULKAN_SURFACE
|
||||||
|
|
||||||
|
|
||||||
@section news_archive Release notes for earlier versions
|
@section news_archive Release notes for earlier versions
|
||||||
|
102
docs/window.dox
102
docs/window.dox
@ -236,7 +236,8 @@ does not affect window decorations. Possible values are `GLFW_TRUE` and
|
|||||||
|
|
||||||
@anchor GLFW_FOCUS_ON_SHOW_hint
|
@anchor GLFW_FOCUS_ON_SHOW_hint
|
||||||
__GLFW_FOCUS_ON_SHOW__ specifies whether the window will be given input
|
__GLFW_FOCUS_ON_SHOW__ specifies whether the window will be given input
|
||||||
focus when @ref glfwShowWindow is called. Possible values are `GLFW_TRUE` and `GLFW_FALSE`.
|
focus when @ref glfwShowWindow is called. Possible values are `GLFW_TRUE` and
|
||||||
|
`GLFW_FALSE`.
|
||||||
|
|
||||||
@anchor GLFW_SCALE_TO_MONITOR
|
@anchor GLFW_SCALE_TO_MONITOR
|
||||||
__GLFW_SCALE_TO_MONITOR__ specified whether the window content area should be
|
__GLFW_SCALE_TO_MONITOR__ specified whether the window content area should be
|
||||||
@ -278,7 +279,6 @@ __GLFW_ACCUM_ALPHA_BITS__ specify the desired bit depths of the various
|
|||||||
components of the accumulation buffer. A value of `GLFW_DONT_CARE` means the
|
components of the accumulation buffer. A value of `GLFW_DONT_CARE` means the
|
||||||
application has no preference.
|
application has no preference.
|
||||||
|
|
||||||
@par
|
|
||||||
Accumulation buffers are a legacy OpenGL feature and should not be used in new
|
Accumulation buffers are a legacy OpenGL feature and should not be used in new
|
||||||
code.
|
code.
|
||||||
|
|
||||||
@ -286,7 +286,6 @@ code.
|
|||||||
__GLFW_AUX_BUFFERS__ specifies the desired number of auxiliary buffers. A value
|
__GLFW_AUX_BUFFERS__ specifies the desired number of auxiliary buffers. A value
|
||||||
of `GLFW_DONT_CARE` means the application has no preference.
|
of `GLFW_DONT_CARE` means the application has no preference.
|
||||||
|
|
||||||
@par
|
|
||||||
Auxiliary buffers are a legacy OpenGL feature and should not be used in new
|
Auxiliary buffers are a legacy OpenGL feature and should not be used in new
|
||||||
code.
|
code.
|
||||||
|
|
||||||
@ -303,16 +302,15 @@ the application has no preference.
|
|||||||
__GLFW_SRGB_CAPABLE__ specifies whether the framebuffer should be sRGB capable.
|
__GLFW_SRGB_CAPABLE__ specifies whether the framebuffer should be sRGB capable.
|
||||||
Possible values are `GLFW_TRUE` and `GLFW_FALSE`.
|
Possible values are `GLFW_TRUE` and `GLFW_FALSE`.
|
||||||
|
|
||||||
@par
|
@note __OpenGL:__ If enabled and supported by the system, the
|
||||||
__OpenGL:__ If enabled and supported by the system, the `GL_FRAMEBUFFER_SRGB`
|
`GL_FRAMEBUFFER_SRGB` enable will control sRGB rendering. By default, sRGB
|
||||||
enable will control sRGB rendering. By default, sRGB rendering will be
|
rendering will be disabled.
|
||||||
disabled.
|
|
||||||
|
|
||||||
@par
|
@note __OpenGL ES:__ If enabled and supported by the system, the context will
|
||||||
__OpenGL ES:__ If enabled and supported by the system, the context will always
|
always have sRGB rendering enabled.
|
||||||
have sRGB rendering enabled.
|
|
||||||
|
|
||||||
@anchor GLFW_DOUBLEBUFFER
|
@anchor GLFW_DOUBLEBUFFER
|
||||||
|
@anchor GLFW_DOUBLEBUFFER_hint
|
||||||
__GLFW_DOUBLEBUFFER__ specifies whether the framebuffer should be double
|
__GLFW_DOUBLEBUFFER__ specifies whether the framebuffer should be double
|
||||||
buffered. You nearly always want to use double buffering. This is a hard
|
buffered. You nearly always want to use double buffering. This is a hard
|
||||||
constraint. Possible values are `GLFW_TRUE` and `GLFW_FALSE`.
|
constraint. Possible values are `GLFW_TRUE` and `GLFW_FALSE`.
|
||||||
@ -339,28 +337,22 @@ create the context. Possible values are `GLFW_NATIVE_CONTEXT_API`,
|
|||||||
`GLFW_EGL_CONTEXT_API` and `GLFW_OSMESA_CONTEXT_API`. This is a hard
|
`GLFW_EGL_CONTEXT_API` and `GLFW_OSMESA_CONTEXT_API`. This is a hard
|
||||||
constraint. If no client API is requested, this hint is ignored.
|
constraint. If no client API is requested, this hint is ignored.
|
||||||
|
|
||||||
@par
|
An [extension loader library](@ref context_glext_auto) that assumes it knows
|
||||||
@macos The EGL API is not available on this platform and requests to use it
|
which API was used to create the current context may fail if you change this
|
||||||
will fail.
|
hint. This can be resolved by having it load functions via @ref
|
||||||
|
glfwGetProcAddress.
|
||||||
|
|
||||||
@par
|
@note @wayland The EGL API _is_ the native context creation API, so this hint
|
||||||
__Wayland:__ The EGL API _is_ the native context creation API, so this hint
|
|
||||||
will have no effect.
|
will have no effect.
|
||||||
|
|
||||||
@par
|
@note @x11 On some Linux systems, creating contexts via both the native and EGL
|
||||||
__OSMesa:__ As its name implies, an OpenGL context created with OSMesa does not
|
APIs in a single process will cause the application to segfault. Stick to one
|
||||||
update the window contents when its buffers are swapped. Use OpenGL functions
|
API or the other on Linux for now.
|
||||||
or the OSMesa native access functions @ref glfwGetOSMesaColorBuffer and @ref
|
|
||||||
glfwGetOSMesaDepthBuffer to retrieve the framebuffer contents.
|
|
||||||
|
|
||||||
@note An OpenGL extension loader library that assumes it knows which context
|
@note __OSMesa:__ As its name implies, an OpenGL context created with OSMesa
|
||||||
creation API is used on a given platform may fail if you change this hint. This
|
does not update the window contents when its buffers are swapped. Use OpenGL
|
||||||
can be resolved by having it load via @ref glfwGetProcAddress, which always uses
|
functions or the OSMesa native access functions @ref glfwGetOSMesaColorBuffer
|
||||||
the selected API.
|
and @ref glfwGetOSMesaDepthBuffer to retrieve the framebuffer contents.
|
||||||
|
|
||||||
@bug On some Linux systems, creating contexts via both the native and EGL APIs
|
|
||||||
in a single process will cause the application to segfault. Stick to one API or
|
|
||||||
the other on Linux for now.
|
|
||||||
|
|
||||||
@anchor GLFW_CONTEXT_VERSION_MAJOR_hint
|
@anchor GLFW_CONTEXT_VERSION_MAJOR_hint
|
||||||
@anchor GLFW_CONTEXT_VERSION_MINOR_hint
|
@anchor GLFW_CONTEXT_VERSION_MINOR_hint
|
||||||
@ -368,27 +360,24 @@ __GLFW_CONTEXT_VERSION_MAJOR__ and __GLFW_CONTEXT_VERSION_MINOR__ specify the
|
|||||||
client API version that the created context must be compatible with. The exact
|
client API version that the created context must be compatible with. The exact
|
||||||
behavior of these hints depend on the requested client API.
|
behavior of these hints depend on the requested client API.
|
||||||
|
|
||||||
@note Do not confuse these hints with `GLFW_VERSION_MAJOR` and
|
|
||||||
`GLFW_VERSION_MINOR`, which provide the API version of the GLFW header.
|
|
||||||
|
|
||||||
@par
|
|
||||||
__OpenGL:__ These hints are not hard constraints, but creation will fail if the
|
|
||||||
OpenGL version of the created context is less than the one requested. It is
|
|
||||||
therefore perfectly safe to use the default of version 1.0 for legacy code and
|
|
||||||
you will still get backwards-compatible contexts of version 3.0 and above when
|
|
||||||
available.
|
|
||||||
|
|
||||||
@par
|
|
||||||
While there is no way to ask the driver for a context of the highest supported
|
While there is no way to ask the driver for a context of the highest supported
|
||||||
version, GLFW will attempt to provide this when you ask for a version 1.0
|
version, GLFW will attempt to provide this when you ask for a version 1.0
|
||||||
context, which is the default for these hints.
|
context, which is the default for these hints.
|
||||||
|
|
||||||
@par
|
Do not confuse these hints with @ref GLFW_VERSION_MAJOR and @ref
|
||||||
__OpenGL ES:__ These hints are not hard constraints, but creation will fail if
|
GLFW_VERSION_MINOR, which provide the API version of the GLFW header.
|
||||||
the OpenGL ES version of the created context is less than the one requested.
|
|
||||||
Additionally, OpenGL ES 1.x cannot be returned if 2.0 or later was requested,
|
@note __OpenGL:__ These hints are not hard constraints, but creation will fail
|
||||||
and vice versa. This is because OpenGL ES 3.x is backward compatible with 2.0,
|
if the OpenGL version of the created context is less than the one requested. It
|
||||||
but OpenGL ES 2.0 is not backward compatible with 1.x.
|
is therefore perfectly safe to use the default of version 1.0 for legacy code
|
||||||
|
and you will still get backwards-compatible contexts of version 3.0 and above
|
||||||
|
when available.
|
||||||
|
|
||||||
|
@note __OpenGL ES:__ These hints are not hard constraints, but creation will
|
||||||
|
fail if the OpenGL ES version of the created context is less than the one
|
||||||
|
requested. Additionally, OpenGL ES 1.x cannot be returned if 2.0 or later was
|
||||||
|
requested, and vice versa. This is because OpenGL ES 3.x is backward compatible
|
||||||
|
with 2.0, but OpenGL ES 2.0 is not backward compatible with 1.x.
|
||||||
|
|
||||||
@note @macos The OS only supports core profile contexts for OpenGL versions 3.2
|
@note @macos The OS only supports core profile contexts for OpenGL versions 3.2
|
||||||
and later. Before creating an OpenGL context of version 3.2 or later you must
|
and later. Before creating an OpenGL context of version 3.2 or later you must
|
||||||
@ -401,7 +390,6 @@ forward-compatible, i.e. one where all functionality deprecated in the requested
|
|||||||
version of OpenGL is removed. This must only be used if the requested OpenGL
|
version of OpenGL is removed. This must only be used if the requested OpenGL
|
||||||
version is 3.0 or above. If OpenGL ES is requested, this hint is ignored.
|
version is 3.0 or above. If OpenGL ES is requested, this hint is ignored.
|
||||||
|
|
||||||
@par
|
|
||||||
Forward-compatibility is described in detail in the
|
Forward-compatibility is described in detail in the
|
||||||
[OpenGL Reference Manual](https://www.opengl.org/registry/).
|
[OpenGL Reference Manual](https://www.opengl.org/registry/).
|
||||||
|
|
||||||
@ -411,13 +399,11 @@ __GLFW_CONTEXT_DEBUG__ specifies whether the context should be created in debug
|
|||||||
mode, which may provide additional error and diagnostic reporting functionality.
|
mode, which may provide additional error and diagnostic reporting functionality.
|
||||||
Possible values are `GLFW_TRUE` and `GLFW_FALSE`.
|
Possible values are `GLFW_TRUE` and `GLFW_FALSE`.
|
||||||
|
|
||||||
@par
|
|
||||||
Debug contexts for OpenGL and OpenGL ES are described in detail by the
|
Debug contexts for OpenGL and OpenGL ES are described in detail by the
|
||||||
[GL_KHR_debug](https://www.khronos.org/registry/OpenGL/extensions/KHR/KHR_debug.txt)
|
[GL_KHR_debug](https://www.khronos.org/registry/OpenGL/extensions/KHR/KHR_debug.txt)
|
||||||
extension.
|
extension.
|
||||||
|
|
||||||
@par
|
@note `GLFW_CONTEXT_DEBUG` is the new name introduced in GLFW 3.4. The older
|
||||||
This is the new name, introduced in GLFW 3.4. The older
|
|
||||||
`GLFW_OPENGL_DEBUG_CONTEXT` name is also available for compatibility.
|
`GLFW_OPENGL_DEBUG_CONTEXT` name is also available for compatibility.
|
||||||
|
|
||||||
@anchor GLFW_OPENGL_PROFILE_hint
|
@anchor GLFW_OPENGL_PROFILE_hint
|
||||||
@ -428,7 +414,6 @@ a specific profile. If requesting an OpenGL version below 3.2,
|
|||||||
`GLFW_OPENGL_ANY_PROFILE` must be used. If OpenGL ES is requested, this hint
|
`GLFW_OPENGL_ANY_PROFILE` must be used. If OpenGL ES is requested, this hint
|
||||||
is ignored.
|
is ignored.
|
||||||
|
|
||||||
@par
|
|
||||||
OpenGL profiles are described in detail in the
|
OpenGL profiles are described in detail in the
|
||||||
[OpenGL Reference Manual](https://www.opengl.org/registry/).
|
[OpenGL Reference Manual](https://www.opengl.org/registry/).
|
||||||
|
|
||||||
@ -448,7 +433,6 @@ the pipeline will be flushed whenever the context is released from being the
|
|||||||
current one. If the behavior is `GLFW_RELEASE_BEHAVIOR_NONE`, the pipeline will
|
current one. If the behavior is `GLFW_RELEASE_BEHAVIOR_NONE`, the pipeline will
|
||||||
not be flushed on release.
|
not be flushed on release.
|
||||||
|
|
||||||
@par
|
|
||||||
Context release behaviors are described in detail by the
|
Context release behaviors are described in detail by the
|
||||||
[GL_KHR_context_flush_control](https://www.opengl.org/registry/specs/KHR/context_flush_control.txt)
|
[GL_KHR_context_flush_control](https://www.opengl.org/registry/specs/KHR/context_flush_control.txt)
|
||||||
extension.
|
extension.
|
||||||
@ -458,7 +442,6 @@ __GLFW_CONTEXT_NO_ERROR__ specifies whether errors should be generated by the
|
|||||||
context. Possible values are `GLFW_TRUE` and `GLFW_FALSE`. If enabled,
|
context. Possible values are `GLFW_TRUE` and `GLFW_FALSE`. If enabled,
|
||||||
situations that would have generated errors instead cause undefined behavior.
|
situations that would have generated errors instead cause undefined behavior.
|
||||||
|
|
||||||
@par
|
|
||||||
The no error mode for OpenGL and OpenGL ES is described in detail by the
|
The no error mode for OpenGL and OpenGL ES is described in detail by the
|
||||||
[GL_KHR_no_error](https://www.opengl.org/registry/specs/KHR/no_error.txt)
|
[GL_KHR_no_error](https://www.opengl.org/registry/specs/KHR/no_error.txt)
|
||||||
extension.
|
extension.
|
||||||
@ -492,12 +475,10 @@ run on the discrete GPU. This only affects systems with both integrated and
|
|||||||
discrete GPUs. Possible values are `GLFW_TRUE` and `GLFW_FALSE`. This is
|
discrete GPUs. Possible values are `GLFW_TRUE` and `GLFW_FALSE`. This is
|
||||||
ignored on other platforms.
|
ignored on other platforms.
|
||||||
|
|
||||||
@par
|
|
||||||
Simpler programs and tools may want to enable this to save power, while games
|
Simpler programs and tools may want to enable this to save power, while games
|
||||||
and other applications performing advanced rendering will want to leave it
|
and other applications performing advanced rendering will want to leave it
|
||||||
disabled.
|
disabled.
|
||||||
|
|
||||||
@par
|
|
||||||
A bundled application that wishes to participate in Automatic Graphics Switching
|
A bundled application that wishes to participate in Automatic Graphics Switching
|
||||||
should also declare this in its `Info.plist` by setting the
|
should also declare this in its `Info.plist` by setting the
|
||||||
`NSSupportsAutomaticGraphicsSwitching` key to `true`.
|
`NSSupportsAutomaticGraphicsSwitching` key to `true`.
|
||||||
@ -1397,9 +1378,11 @@ if the window's context supports robustness, or `GLFW_NO_ROBUSTNESS` otherwise.
|
|||||||
|
|
||||||
@subsubsection window_attribs_fb Framebuffer related attributes
|
@subsubsection window_attribs_fb Framebuffer related attributes
|
||||||
|
|
||||||
GLFW does not expose attributes of the default framebuffer (i.e. the framebuffer
|
GLFW does not expose most attributes of the default framebuffer (i.e. the
|
||||||
attached to the window) as these can be queried directly with either OpenGL,
|
framebuffer attached to the window) as these can be queried directly with either
|
||||||
OpenGL ES or Vulkan.
|
OpenGL, OpenGL ES or Vulkan. The one exception is
|
||||||
|
[GLFW_DOUBLEBUFFER](@ref GLFW_DOUBLEBUFFER_attrib), as this is not provided by
|
||||||
|
OpenGL ES.
|
||||||
|
|
||||||
If you are using version 3.0 or later of OpenGL or OpenGL ES, the
|
If you are using version 3.0 or later of OpenGL or OpenGL ES, the
|
||||||
`glGetFramebufferAttachmentParameteriv` function can be used to retrieve the
|
`glGetFramebufferAttachmentParameteriv` function can be used to retrieve the
|
||||||
@ -1425,6 +1408,11 @@ alpha sizes are queried from the `GL_BACK_LEFT`, while the depth and stencil
|
|||||||
sizes are queried from the `GL_DEPTH` and `GL_STENCIL` attachments,
|
sizes are queried from the `GL_DEPTH` and `GL_STENCIL` attachments,
|
||||||
respectively.
|
respectively.
|
||||||
|
|
||||||
|
@anchor GLFW_DOUBLEBUFFER_attrib
|
||||||
|
__GLFW_DOUBLEBUFFER__ indicates whether the specified window is double-buffered
|
||||||
|
when rendering with OpenGL or OpenGL ES. This can be set before creation with
|
||||||
|
the [GLFW_DOUBLEBUFFER](@ref GLFW_DOUBLEBUFFER_hint) window hint.
|
||||||
|
|
||||||
|
|
||||||
@section buffer_swap Buffer swapping
|
@section buffer_swap Buffer swapping
|
||||||
|
|
||||||
|
@ -7,7 +7,8 @@ if (MATH_LIBRARY)
|
|||||||
link_libraries("${MATH_LIBRARY}")
|
link_libraries("${MATH_LIBRARY}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (MSVC)
|
# Workaround for the MS CRT deprecating parts of the standard library
|
||||||
|
if (MSVC OR CMAKE_C_SIMULATE_ID STREQUAL "MSVC")
|
||||||
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
|
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@ -17,8 +18,8 @@ elseif (APPLE)
|
|||||||
set(ICON glfw.icns)
|
set(ICON glfw.icns)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(GLAD_GL "${GLFW_SOURCE_DIR}/deps/glad/gl.h"
|
set(GLAD_GL "${GLFW_SOURCE_DIR}/deps/glad/gl.h")
|
||||||
"${GLFW_SOURCE_DIR}/deps/glad_gl.c")
|
set(GLAD_GLES2 "${GLFW_SOURCE_DIR}/deps/glad/gles2.h")
|
||||||
set(GETOPT "${GLFW_SOURCE_DIR}/deps/getopt.h"
|
set(GETOPT "${GLFW_SOURCE_DIR}/deps/getopt.h"
|
||||||
"${GLFW_SOURCE_DIR}/deps/getopt.c")
|
"${GLFW_SOURCE_DIR}/deps/getopt.c")
|
||||||
set(TINYCTHREAD "${GLFW_SOURCE_DIR}/deps/tinycthread.h"
|
set(TINYCTHREAD "${GLFW_SOURCE_DIR}/deps/tinycthread.h"
|
||||||
@ -32,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})
|
||||||
|
|
||||||
@ -41,7 +43,7 @@ if (RT_LIBRARY)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(GUI_ONLY_BINARIES boing gears heightmap particles sharing splitview
|
set(GUI_ONLY_BINARIES boing gears heightmap particles sharing splitview
|
||||||
triangle-opengl wave 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
|
||||||
@ -54,9 +56,13 @@ if (GLFW_USE_OSMESA)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (MSVC)
|
if (MSVC)
|
||||||
# Tell MSVC to use main instead of WinMain for Windows subsystem executables
|
# Tell MSVC to use main instead of WinMain
|
||||||
set_target_properties(${GUI_ONLY_BINARIES} PROPERTIES
|
set_target_properties(${GUI_ONLY_BINARIES} PROPERTIES
|
||||||
LINK_FLAGS "/ENTRY:mainCRTStartup")
|
LINK_FLAGS "/ENTRY:mainCRTStartup")
|
||||||
|
elseif (CMAKE_C_SIMULATE_ID STREQUAL "MSVC")
|
||||||
|
# Tell Clang using MS CRT to use main instead of WinMain
|
||||||
|
set_target_properties(${GUI_ONLY_BINARIES} PROPERTIES
|
||||||
|
LINK_FLAGS "-Wl,/entry:mainCRTStartup")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (APPLE)
|
if (APPLE)
|
||||||
@ -66,6 +72,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>
|
||||||
@ -292,12 +293,12 @@ static void generate_heightmap__circle(float* center_x, float* center_y,
|
|||||||
{
|
{
|
||||||
float sign;
|
float sign;
|
||||||
/* random value for element in between [0-1.0] */
|
/* random value for element in between [0-1.0] */
|
||||||
*center_x = (MAP_SIZE * rand()) / (1.0f * RAND_MAX);
|
*center_x = (MAP_SIZE * rand()) / (float) RAND_MAX;
|
||||||
*center_y = (MAP_SIZE * rand()) / (1.0f * RAND_MAX);
|
*center_y = (MAP_SIZE * rand()) / (float) RAND_MAX;
|
||||||
*size = (MAX_CIRCLE_SIZE * rand()) / (1.0f * RAND_MAX);
|
*size = (MAX_CIRCLE_SIZE * rand()) / (float) RAND_MAX;
|
||||||
sign = (1.0f * rand()) / (1.0f * RAND_MAX);
|
sign = (1.0f * rand()) / (float) RAND_MAX;
|
||||||
sign = (sign < DISPLACEMENT_SIGN_LIMIT) ? -1.0f : 1.0f;
|
sign = (sign < DISPLACEMENT_SIGN_LIMIT) ? -1.0f : 1.0f;
|
||||||
*displacement = (sign * (MAX_DISPLACEMENT * rand())) / (1.0f * RAND_MAX);
|
*displacement = (sign * (MAX_DISPLACEMENT * rand())) / (float) RAND_MAX;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Run the specified number of iterations of the generation process for the
|
/* Run the specified number of iterations of the generation process for the
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
//
|
//
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
|
#define GLAD_GL_IMPLEMENTATION
|
||||||
#include <glad/gl.h>
|
#include <glad/gl.h>
|
||||||
#define GLFW_INCLUDE_NONE
|
#define GLFW_INCLUDE_NONE
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
|
@ -39,6 +39,7 @@
|
|||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
#include <linmath.h>
|
#include <linmath.h>
|
||||||
|
|
||||||
|
#define GLAD_GL_IMPLEMENTATION
|
||||||
#include <glad/gl.h>
|
#include <glad/gl.h>
|
||||||
#define GLFW_INCLUDE_NONE
|
#define GLFW_INCLUDE_NONE
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
//
|
//
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
|
#define GLAD_GL_IMPLEMENTATION
|
||||||
#include <glad/gl.h>
|
#include <glad/gl.h>
|
||||||
#define GLFW_INCLUDE_NONE
|
#define GLFW_INCLUDE_NONE
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
|
@ -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>
|
||||||
|
@ -276,23 +276,24 @@ extern "C" {
|
|||||||
|
|
||||||
/*! @name GLFW version macros
|
/*! @name GLFW version macros
|
||||||
* @{ */
|
* @{ */
|
||||||
/*! @brief The major version number of the GLFW library.
|
/*! @brief The major version number of the GLFW header.
|
||||||
*
|
*
|
||||||
* This is incremented when the API is changed in non-compatible ways.
|
* The major version number of the GLFW header. This is incremented when the
|
||||||
|
* API is changed in non-compatible ways.
|
||||||
* @ingroup init
|
* @ingroup init
|
||||||
*/
|
*/
|
||||||
#define GLFW_VERSION_MAJOR 3
|
#define GLFW_VERSION_MAJOR 3
|
||||||
/*! @brief The minor version number of the GLFW library.
|
/*! @brief The minor version number of the GLFW header.
|
||||||
*
|
*
|
||||||
* This is incremented when features are added to the API but it remains
|
* The minor version number of the GLFW header. This is incremented when
|
||||||
* backward-compatible.
|
* features are added to the API but it remains backward-compatible.
|
||||||
* @ingroup init
|
* @ingroup init
|
||||||
*/
|
*/
|
||||||
#define GLFW_VERSION_MINOR 4
|
#define GLFW_VERSION_MINOR 4
|
||||||
/*! @brief The revision number of the GLFW library.
|
/*! @brief The revision number of the GLFW header.
|
||||||
*
|
*
|
||||||
* This is incremented when a bug fix release is made that does not contain any
|
* The revision number of the GLFW header. This is incremented when a bug fix
|
||||||
* API changes.
|
* release is made that does not contain any API changes.
|
||||||
* @ingroup init
|
* @ingroup init
|
||||||
*/
|
*/
|
||||||
#define GLFW_VERSION_REVISION 0
|
#define GLFW_VERSION_REVISION 0
|
||||||
@ -977,9 +978,10 @@ extern "C" {
|
|||||||
* Monitor refresh rate [hint](@ref GLFW_REFRESH_RATE).
|
* Monitor refresh rate [hint](@ref GLFW_REFRESH_RATE).
|
||||||
*/
|
*/
|
||||||
#define GLFW_REFRESH_RATE 0x0002100F
|
#define GLFW_REFRESH_RATE 0x0002100F
|
||||||
/*! @brief Framebuffer double buffering hint.
|
/*! @brief Framebuffer double buffering hint and attribute.
|
||||||
*
|
*
|
||||||
* Framebuffer double buffering [hint](@ref GLFW_DOUBLEBUFFER).
|
* Framebuffer double buffering [hint](@ref GLFW_DOUBLEBUFFER_hint) and
|
||||||
|
* [attribute](@ref GLFW_DOUBLEBUFFER_attrib).
|
||||||
*/
|
*/
|
||||||
#define GLFW_DOUBLEBUFFER 0x00021010
|
#define GLFW_DOUBLEBUFFER 0x00021010
|
||||||
|
|
||||||
@ -1250,6 +1252,11 @@ extern "C" {
|
|||||||
* macOS specific [init hint](@ref GLFW_COCOA_MENUBAR_hint).
|
* macOS specific [init hint](@ref GLFW_COCOA_MENUBAR_hint).
|
||||||
*/
|
*/
|
||||||
#define GLFW_COCOA_MENUBAR 0x00051002
|
#define GLFW_COCOA_MENUBAR 0x00051002
|
||||||
|
/*! @brief X11 specific init hint.
|
||||||
|
*
|
||||||
|
* X11 specific [init hint](@ref GLFW_X11_XCB_VULKAN_SURFACE_hint).
|
||||||
|
*/
|
||||||
|
#define GLFW_X11_XCB_VULKAN_SURFACE 0x00052001
|
||||||
/*! @} */
|
/*! @} */
|
||||||
|
|
||||||
#define GLFW_DONT_CARE -1
|
#define GLFW_DONT_CARE -1
|
||||||
@ -1335,6 +1342,131 @@ typedef struct GLFWusercontext GLFWusercontext;
|
|||||||
*/
|
*/
|
||||||
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
|
||||||
@ -1357,7 +1489,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.
|
||||||
*
|
*
|
||||||
@ -1380,7 +1512,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.
|
||||||
*
|
*
|
||||||
@ -1402,7 +1534,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.
|
||||||
*
|
*
|
||||||
@ -1422,7 +1554,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.
|
||||||
*
|
*
|
||||||
@ -1442,7 +1574,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.
|
||||||
*
|
*
|
||||||
@ -1463,7 +1595,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.
|
||||||
*
|
*
|
||||||
@ -1484,7 +1616,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.
|
||||||
*
|
*
|
||||||
@ -1505,7 +1637,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.
|
||||||
*
|
*
|
||||||
@ -1526,7 +1658,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.
|
||||||
*
|
*
|
||||||
@ -1547,7 +1679,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.
|
||||||
*
|
*
|
||||||
@ -1573,7 +1705,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.
|
||||||
*
|
*
|
||||||
@ -1596,7 +1728,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.
|
||||||
*
|
*
|
||||||
@ -1617,7 +1749,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.
|
||||||
*
|
*
|
||||||
@ -1638,7 +1770,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.
|
||||||
*
|
*
|
||||||
@ -1664,7 +1796,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.
|
||||||
*
|
*
|
||||||
@ -1685,7 +1817,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.
|
||||||
@ -1712,7 +1844,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.
|
||||||
*
|
*
|
||||||
@ -1736,7 +1868,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.
|
||||||
*
|
*
|
||||||
@ -1757,7 +1889,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.
|
||||||
*
|
*
|
||||||
@ -1778,7 +1910,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.
|
||||||
*
|
*
|
||||||
@ -1892,6 +2024,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
|
||||||
@ -1935,6 +2084,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.
|
||||||
@ -2009,6 +2160,33 @@ 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);
|
||||||
|
|
||||||
/*! @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
|
||||||
@ -2429,8 +2607,9 @@ GLFWAPI GLFWmonitorfun glfwSetMonitorCallback(GLFWmonitorfun callback);
|
|||||||
*
|
*
|
||||||
* This function returns an array of all video modes supported by the specified
|
* This function returns an array of all video modes supported by the specified
|
||||||
* monitor. The returned array is sorted in ascending order, first by color
|
* monitor. The returned array is sorted in ascending order, first by color
|
||||||
* bit depth (the sum of all channel depths) and then by resolution area (the
|
* bit depth (the sum of all channel depths), then by resolution area (the
|
||||||
* product of width and height).
|
* product of width and height), then resolution width and finally by refresh
|
||||||
|
* rate.
|
||||||
*
|
*
|
||||||
* @param[in] monitor The monitor to query.
|
* @param[in] monitor The monitor to query.
|
||||||
* @param[out] count Where to store the number of video modes in the returned
|
* @param[out] count Where to store the number of video modes in the returned
|
||||||
@ -6024,9 +6203,8 @@ GLFWAPI int glfwVulkanSupported(void);
|
|||||||
* returned array, as it is an error to specify an extension more than once in
|
* returned array, as it is an error to specify an extension more than once in
|
||||||
* the `VkInstanceCreateInfo` struct.
|
* the `VkInstanceCreateInfo` struct.
|
||||||
*
|
*
|
||||||
* @remark @macos This function currently supports either the
|
* @remark @macos GLFW currently supports both the `VK_MVK_macos_surface` and
|
||||||
* `VK_MVK_macos_surface` extension from MoltenVK or `VK_EXT_metal_surface`
|
* the newer `VK_EXT_metal_surface` extensions.
|
||||||
* extension.
|
|
||||||
*
|
*
|
||||||
* @pointer_lifetime The returned array is allocated and freed by GLFW. You
|
* @pointer_lifetime The returned array is allocated and freed by GLFW. You
|
||||||
* should not free it yourself. It is guaranteed to be valid only until the
|
* should not free it yourself. It is guaranteed to be valid only until the
|
||||||
@ -6109,7 +6287,7 @@ GLFWAPI GLFWvkproc glfwGetInstanceProcAddress(VkInstance instance, const char* p
|
|||||||
* GLFW_API_UNAVAILABLE and @ref GLFW_PLATFORM_ERROR.
|
* GLFW_API_UNAVAILABLE and @ref GLFW_PLATFORM_ERROR.
|
||||||
*
|
*
|
||||||
* @remark @macos This function currently always returns `GLFW_TRUE`, as the
|
* @remark @macos This function currently always returns `GLFW_TRUE`, as the
|
||||||
* `VK_MVK_macos_surface` extension does not provide
|
* `VK_MVK_macos_surface` and `VK_EXT_metal_surface` extensions do not provide
|
||||||
* a `vkGetPhysicalDevice*PresentationSupport` type function.
|
* a `vkGetPhysicalDevice*PresentationSupport` type function.
|
||||||
*
|
*
|
||||||
* @thread_safety This function may be called from any thread. For
|
* @thread_safety This function may be called from any thread. For
|
||||||
@ -6172,6 +6350,12 @@ GLFWAPI int glfwGetPhysicalDevicePresentationSupport(VkInstance instance, VkPhys
|
|||||||
* @remark @macos This function creates and sets a `CAMetalLayer` instance for
|
* @remark @macos This function creates and sets a `CAMetalLayer` instance for
|
||||||
* the window content view, which is required for MoltenVK to function.
|
* the window content view, which is required for MoltenVK to function.
|
||||||
*
|
*
|
||||||
|
* @remark @x11 GLFW by default attempts to use the `VK_KHR_xcb_surface`
|
||||||
|
* extension, if available. You can make it prefer the `VK_KHR_xlib_surface`
|
||||||
|
* extension by setting the
|
||||||
|
* [GLFW_X11_XCB_VULKAN_SURFACE](@ref GLFW_X11_XCB_VULKAN_SURFACE_hint) init
|
||||||
|
* hint.
|
||||||
|
*
|
||||||
* @thread_safety This function may be called from any thread. For
|
* @thread_safety This function may be called from any thread. For
|
||||||
* synchronization details of Vulkan objects, see the Vulkan specification.
|
* synchronization details of Vulkan objects, see the Vulkan specification.
|
||||||
*
|
*
|
||||||
|
@ -83,8 +83,8 @@ extern "C" {
|
|||||||
|
|
||||||
#if defined(GLFW_EXPOSE_NATIVE_WIN32) || defined(GLFW_EXPOSE_NATIVE_WGL)
|
#if defined(GLFW_EXPOSE_NATIVE_WIN32) || defined(GLFW_EXPOSE_NATIVE_WGL)
|
||||||
// This is a workaround for the fact that glfw3.h needs to export APIENTRY (for
|
// This is a workaround for the fact that glfw3.h needs to export APIENTRY (for
|
||||||
// example to allow applications to correctly declare a GL_ARB_debug_output
|
// example to allow applications to correctly declare a GL_KHR_debug callback)
|
||||||
// callback) but windows.h assumes no one will define APIENTRY before it does
|
// but windows.h assumes no one will define APIENTRY before it does
|
||||||
#if defined(GLFW_APIENTRY_DEFINED)
|
#if defined(GLFW_APIENTRY_DEFINED)
|
||||||
#undef APIENTRY
|
#undef APIENTRY
|
||||||
#undef GLFW_APIENTRY_DEFINED
|
#undef GLFW_APIENTRY_DEFINED
|
||||||
@ -161,6 +161,14 @@ GLFWAPI const char* glfwGetWin32Monitor(GLFWmonitor* monitor);
|
|||||||
* @return The `HWND` of the specified window, or `NULL` if an
|
* @return The `HWND` of the specified window, or `NULL` if an
|
||||||
* [error](@ref error_handling) occurred.
|
* [error](@ref error_handling) occurred.
|
||||||
*
|
*
|
||||||
|
* @remark The `HDC` associated with the window can be queried with the
|
||||||
|
* [GetDC](https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getdc)
|
||||||
|
* function.
|
||||||
|
* @code
|
||||||
|
* HDC dc = GetDC(glfwGetWin32Window(window));
|
||||||
|
* @endcode
|
||||||
|
* This DC is private and does not need to be released.
|
||||||
|
*
|
||||||
* @thread_safety This function may be called from any thread. Access is not
|
* @thread_safety This function may be called from any thread. Access is not
|
||||||
* synchronized.
|
* synchronized.
|
||||||
*
|
*
|
||||||
@ -177,6 +185,14 @@ GLFWAPI HWND glfwGetWin32Window(GLFWwindow* window);
|
|||||||
* @return The `HGLRC` of the specified window, or `NULL` if an
|
* @return The `HGLRC` of the specified window, or `NULL` if an
|
||||||
* [error](@ref error_handling) occurred.
|
* [error](@ref error_handling) occurred.
|
||||||
*
|
*
|
||||||
|
* @remark The `HDC` associated with the window can be queried with the
|
||||||
|
* [GetDC](https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getdc)
|
||||||
|
* function.
|
||||||
|
* @code
|
||||||
|
* HDC dc = GetDC(glfwGetWin32Window(window));
|
||||||
|
* @endcode
|
||||||
|
* This DC is private and does not need to be released.
|
||||||
|
*
|
||||||
* @thread_safety This function may be called from any thread. Access is not
|
* @thread_safety This function may be called from any thread. Access is not
|
||||||
* synchronized.
|
* synchronized.
|
||||||
*
|
*
|
||||||
|
@ -1,9 +1,19 @@
|
|||||||
|
|
||||||
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 mappings.h context.c init.c input.c monitor.c
|
||||||
vulkan.c window.c)
|
vulkan.c window.c)
|
||||||
|
|
||||||
|
add_custom_target(update_mappings
|
||||||
|
COMMAND "${CMAKE_COMMAND}" -P "${GLFW_SOURCE_DIR}/CMake/GenerateMappings.cmake" mappings.h.in mappings.h
|
||||||
|
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||||
|
COMMENT "Updating gamepad mappings from upstream repository"
|
||||||
|
SOURCES mappings.h.in "${GLFW_SOURCE_DIR}/CMake/GenerateMappings.cmake"
|
||||||
|
VERBATIM)
|
||||||
|
|
||||||
|
set_target_properties(update_mappings PROPERTIES FOLDER "GLFW3")
|
||||||
|
|
||||||
if (_GLFW_COCOA)
|
if (_GLFW_COCOA)
|
||||||
target_sources(glfw PRIVATE cocoa_platform.h cocoa_joystick.h posix_thread.h
|
target_sources(glfw PRIVATE cocoa_platform.h cocoa_joystick.h posix_thread.h
|
||||||
nsgl_context.h egl_context.h osmesa_context.h
|
nsgl_context.h egl_context.h osmesa_context.h
|
||||||
@ -48,6 +58,7 @@ if (_GLFW_WAYLAND)
|
|||||||
find_program(WAYLAND_SCANNER_EXECUTABLE NAMES wayland-scanner)
|
find_program(WAYLAND_SCANNER_EXECUTABLE NAMES wayland-scanner)
|
||||||
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"
|
||||||
@ -55,14 +66,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")
|
||||||
@ -83,7 +97,7 @@ 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()
|
||||||
@ -112,7 +126,7 @@ target_include_directories(glfw PRIVATE
|
|||||||
target_link_libraries(glfw PRIVATE Threads::Threads ${glfw_LIBRARIES})
|
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)
|
||||||
set_source_files_properties(cocoa_init.m cocoa_joystick.m cocoa_monitor.m
|
set_source_files_properties(cocoa_init.m cocoa_joystick.m cocoa_monitor.m
|
||||||
cocoa_window.m nsgl_context.m PROPERTIES
|
cocoa_window.m nsgl_context.m PROPERTIES
|
||||||
LANGUAGE C)
|
LANGUAGE C)
|
||||||
@ -130,22 +144,18 @@ if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Enable a reasonable set of warnings
|
# Enable a reasonable set of warnings
|
||||||
if (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR
|
# NOTE: The order matters here, Clang-CL matches both MSVC and Clang
|
||||||
CMAKE_C_COMPILER_ID STREQUAL "Clang" OR
|
if (MSVC)
|
||||||
CMAKE_C_COMPILER_ID STREQUAL "AppleClang")
|
|
||||||
|
|
||||||
if (CMAKE_C_SIMULATE_ID STREQUAL "MSVC")
|
|
||||||
# Tell Clang-CL that this is a Clang flag
|
|
||||||
target_compile_options(glfw PRIVATE "/clang:-Wall")
|
|
||||||
else()
|
|
||||||
target_compile_options(glfw PRIVATE "-Wall")
|
|
||||||
endif()
|
|
||||||
elseif (MSVC)
|
|
||||||
target_compile_options(glfw PRIVATE "/W3")
|
target_compile_options(glfw PRIVATE "/W3")
|
||||||
|
elseif (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR
|
||||||
|
CMAKE_C_COMPILER_ID STREQUAL "Clang" OR
|
||||||
|
CMAKE_C_COMPILER_ID STREQUAL "AppleClang")
|
||||||
|
|
||||||
|
target_compile_options(glfw PRIVATE "-Wall")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (WIN32)
|
if (_GLFW_WIN32)
|
||||||
target_compile_definitions(glfw PRIVATE _UNICODE)
|
target_compile_definitions(glfw PRIVATE UNICODE _UNICODE)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# HACK: When building on MinGW, WINVER and UNICODE need to be defined before
|
# HACK: When building on MinGW, WINVER and UNICODE need to be defined before
|
||||||
@ -153,7 +163,7 @@ endif()
|
|||||||
# win32_platform.h. We define them here until a saner solution can be found
|
# win32_platform.h. We define them here until a saner solution can be found
|
||||||
# NOTE: MinGW-w64 and Visual C++ do /not/ need this hack.
|
# NOTE: MinGW-w64 and Visual C++ do /not/ need this hack.
|
||||||
if (MINGW)
|
if (MINGW)
|
||||||
target_compile_definitions(glfw PRIVATE UNICODE WINVER=0x0501)
|
target_compile_definitions(glfw PRIVATE WINVER=0x0501)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Workaround for legacy MinGW not providing XInput and DirectInput
|
# Workaround for legacy MinGW not providing XInput and DirectInput
|
||||||
@ -166,8 +176,8 @@ if (MINGW)
|
|||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Workaround for VS deprecating parts of the standard library
|
# Workaround for the MS CRT deprecating parts of the standard library
|
||||||
if (MSVC)
|
if (MSVC OR CMAKE_C_SIMULATE_ID STREQUAL "MSVC")
|
||||||
target_compile_definitions(glfw PRIVATE _CRT_SECURE_NO_WARNINGS)
|
target_compile_definitions(glfw PRIVATE _CRT_SECURE_NO_WARNINGS)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@ -185,7 +195,14 @@ if (MSVC90)
|
|||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (BUILD_SHARED_LIBS)
|
# Workaround for -std=c99 on Linux disabling _DEFAULT_SOURCE (POSIX 2008 and more)
|
||||||
|
if (_GLFW_X11 OR _GLFW_WAYLAND OR _GLFW_OSMESA)
|
||||||
|
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||||
|
target_compile_definitions(glfw PRIVATE _DEFAULT_SOURCE)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (GLFW_BUILD_SHARED_LIBRARY)
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
if (MINGW)
|
if (MINGW)
|
||||||
# Remove the dependency on the shared version of libgcc
|
# Remove the dependency on the shared version of libgcc
|
||||||
@ -243,7 +260,7 @@ endif()
|
|||||||
if (GLFW_INSTALL)
|
if (GLFW_INSTALL)
|
||||||
install(TARGETS glfw
|
install(TARGETS glfw
|
||||||
EXPORT glfwTargets
|
EXPORT glfwTargets
|
||||||
RUNTIME DESTINATION "bin"
|
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
|
||||||
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
||||||
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")
|
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")
|
||||||
endif()
|
endif()
|
||||||
|
@ -602,7 +602,7 @@ 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();
|
||||||
|
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
#define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE struct { int dummyJoystick; }
|
#define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE struct { int dummyJoystick; }
|
||||||
|
|
||||||
#define _GLFW_PLATFORM_MAPPING_NAME "Mac OS X"
|
#define _GLFW_PLATFORM_MAPPING_NAME "Mac OS X"
|
||||||
|
#define GLFW_BUILD_COCOA_MAPPINGS
|
||||||
|
|
||||||
// Cocoa-specific per-joystick data
|
// Cocoa-specific per-joystick data
|
||||||
//
|
//
|
||||||
|
@ -102,15 +102,15 @@ static void closeJoystick(_GLFWjoystick* js)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
for (i = 0; i < CFArrayGetCount(js->ns.axes); i++)
|
for (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 (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 (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);
|
||||||
@ -251,7 +251,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);
|
||||||
|
@ -63,7 +63,7 @@ static char* getMonitorName(CGDirectDisplayID displayID, NSScreen* screen)
|
|||||||
&it) != 0)
|
&it) != 0)
|
||||||
{
|
{
|
||||||
// This may happen if a desktop Mac is running headless
|
// This may happen if a desktop Mac is running headless
|
||||||
return NULL;
|
return _glfw_strdup("Display");
|
||||||
}
|
}
|
||||||
|
|
||||||
while ((service = IOIteratorNext(it)) != 0)
|
while ((service = IOIteratorNext(it)) != 0)
|
||||||
@ -101,7 +101,7 @@ static char* getMonitorName(CGDirectDisplayID displayID, NSScreen* screen)
|
|||||||
{
|
{
|
||||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||||
"Cocoa: Failed to find service port for display");
|
"Cocoa: Failed to find service port for display");
|
||||||
return NULL;
|
return _glfw_strdup("Display");
|
||||||
}
|
}
|
||||||
|
|
||||||
CFDictionaryRef names =
|
CFDictionaryRef names =
|
||||||
@ -114,13 +114,13 @@ static char* getMonitorName(CGDirectDisplayID displayID, NSScreen* screen)
|
|||||||
{
|
{
|
||||||
// This may happen if a desktop Mac is running headless
|
// This may happen if a desktop Mac is running headless
|
||||||
CFRelease(info);
|
CFRelease(info);
|
||||||
return NULL;
|
return _glfw_strdup("Display");
|
||||||
}
|
}
|
||||||
|
|
||||||
const CFIndex size =
|
const CFIndex size =
|
||||||
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);
|
||||||
@ -301,7 +301,7 @@ void _glfwPollMonitorsNS(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 +311,7 @@ void _glfwPollMonitorsNS(void)
|
|||||||
uint32_t disconnectedCount = _glfw.monitorCount;
|
uint32_t disconnectedCount = _glfw.monitorCount;
|
||||||
if (disconnectedCount)
|
if (disconnectedCount)
|
||||||
{
|
{
|
||||||
disconnected = calloc(_glfw.monitorCount, sizeof(_GLFWmonitor*));
|
disconnected = _glfw_calloc(_glfw.monitorCount, sizeof(_GLFWmonitor*));
|
||||||
memcpy(disconnected,
|
memcpy(disconnected,
|
||||||
_glfw.monitors,
|
_glfw.monitors,
|
||||||
_glfw.monitorCount * sizeof(_GLFWmonitor*));
|
_glfw.monitorCount * sizeof(_GLFWmonitor*));
|
||||||
@ -356,14 +356,14 @@ void _glfwPollMonitorsNS(void)
|
|||||||
const CGSize size = CGDisplayScreenSize(displays[i]);
|
const CGSize size = CGDisplayScreenSize(displays[i]);
|
||||||
char* name = getMonitorName(displays[i], screen);
|
char* name = getMonitorName(displays[i], screen);
|
||||||
if (!name)
|
if (!name)
|
||||||
name = _glfw_strdup("Unknown");
|
continue;
|
||||||
|
|
||||||
_GLFWmonitor* monitor = _glfwAllocMonitor(name, size.width, size.height);
|
_GLFWmonitor* monitor = _glfwAllocMonitor(name, size.width, size.height);
|
||||||
monitor->ns.displayID = displays[i];
|
monitor->ns.displayID = displays[i];
|
||||||
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,8 +379,8 @@ 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
|
||||||
@ -521,7 +521,7 @@ GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* count)
|
|||||||
|
|
||||||
CFArrayRef modes = CGDisplayCopyAllDisplayModes(monitor->ns.displayID, NULL);
|
CFArrayRef modes = CGDisplayCopyAllDisplayModes(monitor->ns.displayID, NULL);
|
||||||
const CFIndex found = CFArrayGetCount(modes);
|
const CFIndex found = CFArrayGetCount(modes);
|
||||||
GLFWvidmode* result = calloc(found, sizeof(GLFWvidmode));
|
GLFWvidmode* result = _glfw_calloc(found, sizeof(GLFWvidmode));
|
||||||
|
|
||||||
for (CFIndex i = 0; i < found; i++)
|
for (CFIndex i = 0; i < found; i++)
|
||||||
{
|
{
|
||||||
@ -569,7 +569,7 @@ GLFWbool _glfwPlatformGetGammaRamp(_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,7 +587,7 @@ 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
|
||||||
@ -597,7 +597,7 @@ void _glfwPlatformSetGammaRamp(_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 +612,7 @@ void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp)
|
|||||||
values + ramp->size,
|
values + ramp->size,
|
||||||
values + ramp->size * 2);
|
values + ramp->size * 2);
|
||||||
|
|
||||||
free(values);
|
_glfw_free(values);
|
||||||
|
|
||||||
} // autoreleasepool
|
} // autoreleasepool
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,9 @@
|
|||||||
|
|
||||||
// NOTE: All of NSGL was deprecated in the 10.14 SDK
|
// NOTE: All of NSGL was deprecated in the 10.14 SDK
|
||||||
// This disables the pointless warnings for every symbol we use
|
// This disables the pointless warnings for every symbol we use
|
||||||
|
#ifndef GL_SILENCE_DEPRECATION
|
||||||
#define GL_SILENCE_DEPRECATION
|
#define GL_SILENCE_DEPRECATION
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(__OBJC__)
|
#if defined(__OBJC__)
|
||||||
#import <Cocoa/Cocoa.h>
|
#import <Cocoa/Cocoa.h>
|
||||||
|
@ -243,7 +243,7 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
|
|||||||
|
|
||||||
- (void)windowDidResize:(NSNotification *)notification
|
- (void)windowDidResize:(NSNotification *)notification
|
||||||
{
|
{
|
||||||
if (window->context.client != GLFW_NO_API)
|
if (window->context.source == GLFW_NATIVE_CONTEXT_API)
|
||||||
[window->context.nsgl.object update];
|
[window->context.nsgl.object update];
|
||||||
|
|
||||||
if (_glfw.ns.disabledCursorWindow == window)
|
if (_glfw.ns.disabledCursorWindow == window)
|
||||||
@ -278,7 +278,7 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
|
|||||||
|
|
||||||
- (void)windowDidMove:(NSNotification *)notification
|
- (void)windowDidMove:(NSNotification *)notification
|
||||||
{
|
{
|
||||||
if (window->context.client != GLFW_NO_API)
|
if (window->context.source == GLFW_NATIVE_CONTEXT_API)
|
||||||
[window->context.nsgl.object update];
|
[window->context.nsgl.object update];
|
||||||
|
|
||||||
if (_glfw.ns.disabledCursorWindow == window)
|
if (_glfw.ns.disabledCursorWindow == window)
|
||||||
@ -397,7 +397,7 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
|
|||||||
|
|
||||||
- (void)updateLayer
|
- (void)updateLayer
|
||||||
{
|
{
|
||||||
if (window->context.client != GLFW_NO_API)
|
if (window->context.source == GLFW_NATIVE_CONTEXT_API)
|
||||||
[window->context.nsgl.object update];
|
[window->context.nsgl.object update];
|
||||||
|
|
||||||
_glfwInputWindowDamage(window);
|
_glfwInputWindowDamage(window);
|
||||||
@ -520,6 +520,18 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
|
|||||||
{
|
{
|
||||||
const NSRect contentRect = [window->ns.view frame];
|
const NSRect contentRect = [window->ns.view frame];
|
||||||
const NSRect fbRect = [window->ns.view convertRectToBacking:contentRect];
|
const NSRect fbRect = [window->ns.view convertRectToBacking:contentRect];
|
||||||
|
const float xscale = fbRect.size.width / contentRect.size.width;
|
||||||
|
const float yscale = fbRect.size.height / contentRect.size.height;
|
||||||
|
|
||||||
|
if (xscale != window->ns.xscale || yscale != window->ns.yscale)
|
||||||
|
{
|
||||||
|
if (window->ns.retina && window->ns.layer)
|
||||||
|
[window->ns.layer setContentsScale:[window->ns.object backingScaleFactor]];
|
||||||
|
|
||||||
|
window->ns.xscale = xscale;
|
||||||
|
window->ns.yscale = yscale;
|
||||||
|
_glfwInputWindowContentScale(window, xscale, yscale);
|
||||||
|
}
|
||||||
|
|
||||||
if (fbRect.size.width != window->ns.fbWidth ||
|
if (fbRect.size.width != window->ns.fbWidth ||
|
||||||
fbRect.size.height != window->ns.fbHeight)
|
fbRect.size.height != window->ns.fbHeight)
|
||||||
@ -528,19 +540,6 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
|
|||||||
window->ns.fbHeight = fbRect.size.height;
|
window->ns.fbHeight = fbRect.size.height;
|
||||||
_glfwInputFramebufferSize(window, fbRect.size.width, fbRect.size.height);
|
_glfwInputFramebufferSize(window, fbRect.size.width, fbRect.size.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
const float xscale = fbRect.size.width / contentRect.size.width;
|
|
||||||
const float yscale = fbRect.size.height / contentRect.size.height;
|
|
||||||
|
|
||||||
if (xscale != window->ns.xscale || yscale != window->ns.yscale)
|
|
||||||
{
|
|
||||||
window->ns.xscale = xscale;
|
|
||||||
window->ns.yscale = yscale;
|
|
||||||
_glfwInputWindowContentScale(window, xscale, yscale);
|
|
||||||
|
|
||||||
if (window->ns.retina && window->ns.layer)
|
|
||||||
[window->ns.layer setContentsScale:[window->ns.object backingScaleFactor]];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)drawRect:(NSRect)rect
|
- (void)drawRect:(NSRect)rect
|
||||||
@ -647,7 +646,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]);
|
||||||
@ -655,8 +654,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;
|
||||||
@ -1537,7 +1536,7 @@ const char* _glfwPlatformGetScancodeName(int scancode)
|
|||||||
if (scancode < 0 || scancode > 0xff ||
|
if (scancode < 0 || scancode > 0xff ||
|
||||||
_glfw.ns.keycodes[scancode] == GLFW_KEY_UNKNOWN)
|
_glfw.ns.keycodes[scancode] == GLFW_KEY_UNKNOWN)
|
||||||
{
|
{
|
||||||
_glfwInputError(GLFW_INVALID_VALUE, "Invalid scancode");
|
_glfwInputError(GLFW_INVALID_VALUE, "Invalid scancode %i", scancode);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1748,7 +1747,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;
|
||||||
@ -1776,7 +1775,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;
|
||||||
|
@ -196,12 +196,6 @@ const _GLFWfbconfig* _glfwChooseFBConfig(const _GLFWfbconfig* desired,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (desired->doublebuffer != current->doublebuffer)
|
|
||||||
{
|
|
||||||
// Double buffering is a hard constraint
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Count number of missing buffers
|
// Count number of missing buffers
|
||||||
{
|
{
|
||||||
missing = 0;
|
missing = 0;
|
||||||
@ -570,7 +564,9 @@ GLFWbool _glfwRefreshContextAttribs(_GLFWwindow* window,
|
|||||||
PFNGLCLEARPROC glClear = (PFNGLCLEARPROC)
|
PFNGLCLEARPROC glClear = (PFNGLCLEARPROC)
|
||||||
window->context.getProcAddress("glClear");
|
window->context.getProcAddress("glClear");
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
window->context.swapBuffers(window);
|
|
||||||
|
if (window->doublebuffer)
|
||||||
|
window->context.swapBuffers(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
glfwMakeContextCurrent((GLFWwindow*) previous);
|
glfwMakeContextCurrent((GLFWwindow*) previous);
|
||||||
|
@ -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++)
|
||||||
@ -173,7 +173,7 @@ static GLFWbool chooseEGLConfig(const _GLFWctxconfig* ctxconfig,
|
|||||||
u->stencilBits = getEGLConfigAttrib(n, EGL_STENCIL_SIZE);
|
u->stencilBits = getEGLConfigAttrib(n, EGL_STENCIL_SIZE);
|
||||||
|
|
||||||
u->samples = getEGLConfigAttrib(n, EGL_SAMPLES);
|
u->samples = getEGLConfigAttrib(n, EGL_SAMPLES);
|
||||||
u->doublebuffer = GLFW_TRUE;
|
u->doublebuffer = desired->doublebuffer;
|
||||||
|
|
||||||
u->handle = (uintptr_t) n;
|
u->handle = (uintptr_t) n;
|
||||||
usableCount++;
|
usableCount++;
|
||||||
@ -183,8 +183,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;
|
||||||
}
|
}
|
||||||
@ -446,7 +446,7 @@ GLFWbool _glfwInitEGL(void)
|
|||||||
else
|
else
|
||||||
_glfw.egl.display = eglGetDisplay(_glfwPlatformGetEGLNativeDisplay());
|
_glfw.egl.display = eglGetDisplay(_glfwPlatformGetEGLNativeDisplay());
|
||||||
|
|
||||||
free(attribs);
|
_glfw_free(attribs);
|
||||||
|
|
||||||
if (_glfw.egl.display == EGL_NO_DISPLAY)
|
if (_glfw.egl.display == EGL_NO_DISPLAY)
|
||||||
{
|
{
|
||||||
@ -662,6 +662,9 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window,
|
|||||||
setAttrib(EGL_GL_COLORSPACE_KHR, EGL_GL_COLORSPACE_SRGB_KHR);
|
setAttrib(EGL_GL_COLORSPACE_KHR, EGL_GL_COLORSPACE_SRGB_KHR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!fbconfig->doublebuffer)
|
||||||
|
setAttrib(EGL_RENDER_BUFFER, EGL_SINGLE_BUFFER);
|
||||||
|
|
||||||
setAttrib(EGL_NONE, EGL_NONE);
|
setAttrib(EGL_NONE, EGL_NONE);
|
||||||
|
|
||||||
native = _glfwPlatformGetEGLNativeWindow(window);
|
native = _glfwPlatformGetEGLNativeWindow(window);
|
||||||
|
@ -64,6 +64,8 @@
|
|||||||
#define EGL_OPENGL_ES_API 0x30a0
|
#define EGL_OPENGL_ES_API 0x30a0
|
||||||
#define EGL_OPENGL_API 0x30a2
|
#define EGL_OPENGL_API 0x30a2
|
||||||
#define EGL_NONE 0x3038
|
#define EGL_NONE 0x3038
|
||||||
|
#define EGL_RENDER_BUFFER 0x3086
|
||||||
|
#define EGL_SINGLE_BUFFER 0x3085
|
||||||
#define EGL_EXTENSIONS 0x3055
|
#define EGL_EXTENSIONS 0x3055
|
||||||
#define EGL_CONTEXT_CLIENT_VERSION 0x3098
|
#define EGL_CONTEXT_CLIENT_VERSION 0x3098
|
||||||
#define EGL_NATIVE_VISUAL_ID 0x302e
|
#define EGL_NATIVE_VISUAL_ID 0x302e
|
||||||
|
@ -73,7 +73,7 @@ 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 (i = 0; i < nativeCount; i++)
|
||||||
@ -92,6 +92,9 @@ static GLFWbool chooseGLXFBConfig(const _GLFWfbconfig* desired,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (getGLXFBConfigAttrib(n, GLX_DOUBLEBUFFER) != desired->doublebuffer)
|
||||||
|
continue;
|
||||||
|
|
||||||
if (desired->transparent)
|
if (desired->transparent)
|
||||||
{
|
{
|
||||||
XVisualInfo* vi = glXGetVisualFromFBConfig(_glfw.x11.display, n);
|
XVisualInfo* vi = glXGetVisualFromFBConfig(_glfw.x11.display, n);
|
||||||
@ -119,8 +122,6 @@ static GLFWbool chooseGLXFBConfig(const _GLFWfbconfig* desired,
|
|||||||
|
|
||||||
if (getGLXFBConfigAttrib(n, GLX_STEREO))
|
if (getGLXFBConfigAttrib(n, GLX_STEREO))
|
||||||
u->stereo = GLFW_TRUE;
|
u->stereo = GLFW_TRUE;
|
||||||
if (getGLXFBConfigAttrib(n, GLX_DOUBLEBUFFER))
|
|
||||||
u->doublebuffer = GLFW_TRUE;
|
|
||||||
|
|
||||||
if (_glfw.glx.ARB_multisample)
|
if (_glfw.glx.ARB_multisample)
|
||||||
u->samples = getGLXFBConfigAttrib(n, GLX_SAMPLES);
|
u->samples = getGLXFBConfigAttrib(n, GLX_SAMPLES);
|
||||||
@ -137,7 +138,7 @@ static GLFWbool chooseGLXFBConfig(const _GLFWfbconfig* desired,
|
|||||||
*result = (GLXFBConfig) closest->handle;
|
*result = (GLXFBConfig) closest->handle;
|
||||||
|
|
||||||
XFree(nativeConfigs);
|
XFree(nativeConfigs);
|
||||||
free(usableConfigs);
|
_glfw_free(usableConfigs);
|
||||||
|
|
||||||
return closest != NULL;
|
return closest != NULL;
|
||||||
}
|
}
|
||||||
|
131
src/init.c
131
src/init.c
@ -28,7 +28,6 @@
|
|||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
#include "mappings.h"
|
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -50,6 +49,7 @@ _GLFWlibrary _glfw = { GLFW_FALSE };
|
|||||||
//
|
//
|
||||||
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
|
||||||
@ -57,9 +57,33 @@ static _GLFWinitconfig _glfwInitHints =
|
|||||||
{
|
{
|
||||||
GLFW_TRUE, // macOS menu bar
|
GLFW_TRUE, // macOS menu bar
|
||||||
GLFW_TRUE // macOS bundle chdir
|
GLFW_TRUE // macOS bundle chdir
|
||||||
}
|
},
|
||||||
|
{
|
||||||
|
GLFW_TRUE, // X11 XCB Vulkan surface
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 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)
|
||||||
@ -82,11 +106,11 @@ static void terminate(void)
|
|||||||
_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;
|
||||||
|
|
||||||
@ -100,7 +124,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.usercontextSlot);
|
_glfwPlatformDestroyTls(&_glfw.usercontextSlot);
|
||||||
@ -119,7 +143,7 @@ static void terminate(void)
|
|||||||
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;
|
||||||
}
|
}
|
||||||
@ -148,6 +172,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 //////
|
||||||
@ -207,7 +284,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;
|
||||||
@ -238,6 +315,14 @@ GLFWAPI int glfwInit(void)
|
|||||||
memset(&_glfw, 0, sizeof(_glfw));
|
memset(&_glfw, 0, sizeof(_glfw));
|
||||||
_glfw.hints.init = _glfwInitHints;
|
_glfw.hints.init = _glfwInitHints;
|
||||||
|
|
||||||
|
_glfw.allocator = _glfwInitAllocator;
|
||||||
|
if (!_glfw.allocator.allocate)
|
||||||
|
{
|
||||||
|
_glfw.allocator.allocate = defaultAllocate;
|
||||||
|
_glfw.allocator.reallocate = defaultReallocate;
|
||||||
|
_glfw.allocator.deallocate = defaultDeallocate;
|
||||||
|
}
|
||||||
|
|
||||||
if (!_glfwPlatformInit())
|
if (!_glfwPlatformInit())
|
||||||
{
|
{
|
||||||
terminate();
|
terminate();
|
||||||
@ -255,24 +340,12 @@ GLFWAPI int glfwInit(void)
|
|||||||
|
|
||||||
_glfwPlatformSetTls(&_glfw.errorSlot, &_glfwMainThreadError);
|
_glfwPlatformSetTls(&_glfw.errorSlot, &_glfwMainThreadError);
|
||||||
|
|
||||||
|
_glfwInitGamepadMappings();
|
||||||
|
|
||||||
_glfw.initialized = GLFW_TRUE;
|
_glfw.initialized = GLFW_TRUE;
|
||||||
_glfw.timer.offset = _glfwPlatformGetTimerValue();
|
_glfw.timer.offset = _glfwPlatformGetTimerValue();
|
||||||
|
|
||||||
glfwDefaultWindowHints();
|
glfwDefaultWindowHints();
|
||||||
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; _glfwDefaultMappings[i]; i++)
|
|
||||||
{
|
|
||||||
if (!glfwUpdateGamepadMappings(_glfwDefaultMappings[i]))
|
|
||||||
{
|
|
||||||
terminate();
|
|
||||||
return GLFW_FALSE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return GLFW_TRUE;
|
return GLFW_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -300,12 +373,28 @@ GLFWAPI void glfwInitHint(int hint, int value)
|
|||||||
case GLFW_COCOA_MENUBAR:
|
case GLFW_COCOA_MENUBAR:
|
||||||
_glfwInitHints.ns.menubar = value;
|
_glfwInitHints.ns.menubar = value;
|
||||||
return;
|
return;
|
||||||
|
case GLFW_X11_XCB_VULKAN_SURFACE:
|
||||||
|
_glfwInitHints.x11.xcbVulkanSurface = value;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_glfwInputError(GLFW_INVALID_ENUM,
|
_glfwInputError(GLFW_INVALID_ENUM,
|
||||||
"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 glfwGetVersion(int* major, int* minor, int* rev)
|
GLFWAPI void glfwGetVersion(int* major, int* minor, int* rev)
|
||||||
{
|
{
|
||||||
if (major != NULL)
|
if (major != NULL)
|
||||||
|
53
src/input.c
53
src/input.c
@ -28,6 +28,7 @@
|
|||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
#include "mappings.h"
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <float.h>
|
#include <float.h>
|
||||||
@ -101,25 +102,13 @@ static _GLFWmapping* findValidMapping(const _GLFWjoystick* js)
|
|||||||
for (i = 0; i <= GLFW_GAMEPAD_BUTTON_LAST; i++)
|
for (i = 0; i <= GLFW_GAMEPAD_BUTTON_LAST; i++)
|
||||||
{
|
{
|
||||||
if (!isValidElementForJoystick(mapping->buttons + i, js))
|
if (!isValidElementForJoystick(mapping->buttons + i, js))
|
||||||
{
|
|
||||||
_glfwInputError(GLFW_INVALID_VALUE,
|
|
||||||
"Invalid button in gamepad mapping %s (%s)",
|
|
||||||
mapping->guid,
|
|
||||||
mapping->name);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i <= GLFW_GAMEPAD_AXIS_LAST; i++)
|
for (i = 0; i <= GLFW_GAMEPAD_AXIS_LAST; i++)
|
||||||
{
|
{
|
||||||
if (!isValidElementForJoystick(mapping->axes + i, js))
|
if (!isValidElementForJoystick(mapping->axes + i, js))
|
||||||
{
|
|
||||||
_glfwInputError(GLFW_INVALID_VALUE,
|
|
||||||
"Invalid axis in gamepad mapping %s (%s)",
|
|
||||||
mapping->guid,
|
|
||||||
mapping->name);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -424,6 +413,21 @@ void _glfwInputJoystickHat(_GLFWjoystick* js, int hat, char value)
|
|||||||
////// GLFW internal API //////
|
////// GLFW internal API //////
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// Adds the built-in set of gamepad mappings
|
||||||
|
//
|
||||||
|
void _glfwInitGamepadMappings(void)
|
||||||
|
{
|
||||||
|
size_t i;
|
||||||
|
const size_t count = sizeof(_glfwDefaultMappings) / sizeof(char*);
|
||||||
|
_glfw.mappings = _glfw_calloc(count, sizeof(_GLFWmapping));
|
||||||
|
|
||||||
|
for (i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
if (parseMapping(&_glfw.mappings[_glfw.mappingCount], _glfwDefaultMappings[i]))
|
||||||
|
_glfw.mappingCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Returns an available joystick object with arrays and name allocated
|
// Returns an available joystick object with arrays and name allocated
|
||||||
//
|
//
|
||||||
_GLFWjoystick* _glfwAllocJoystick(const char* name,
|
_GLFWjoystick* _glfwAllocJoystick(const char* name,
|
||||||
@ -446,14 +450,14 @@ _GLFWjoystick* _glfwAllocJoystick(const char* name,
|
|||||||
|
|
||||||
js = _glfw.joysticks + jid;
|
js = _glfw.joysticks + jid;
|
||||||
js->present = GLFW_TRUE;
|
js->present = GLFW_TRUE;
|
||||||
js->name = _glfw_strdup(name);
|
js->axes = _glfw_calloc(axisCount, sizeof(float));
|
||||||
js->axes = calloc(axisCount, sizeof(float));
|
js->buttons = _glfw_calloc(buttonCount + (size_t) hatCount * 4, 1);
|
||||||
js->buttons = calloc(buttonCount + (size_t) hatCount * 4, 1);
|
js->hats = _glfw_calloc(hatCount, 1);
|
||||||
js->hats = calloc(hatCount, 1);
|
|
||||||
js->axisCount = axisCount;
|
js->axisCount = axisCount;
|
||||||
js->buttonCount = buttonCount;
|
js->buttonCount = buttonCount;
|
||||||
js->hatCount = hatCount;
|
js->hatCount = hatCount;
|
||||||
|
|
||||||
|
strncpy(js->name, name, sizeof(js->name) - 1);
|
||||||
strncpy(js->guid, guid, sizeof(js->guid) - 1);
|
strncpy(js->guid, guid, sizeof(js->guid) - 1);
|
||||||
js->mapping = findValidMapping(js);
|
js->mapping = findValidMapping(js);
|
||||||
|
|
||||||
@ -464,10 +468,9 @@ _GLFWjoystick* _glfwAllocJoystick(const char* name,
|
|||||||
//
|
//
|
||||||
void _glfwFreeJoystick(_GLFWjoystick* js)
|
void _glfwFreeJoystick(_GLFWjoystick* js)
|
||||||
{
|
{
|
||||||
free(js->name);
|
_glfw_free(js->axes);
|
||||||
free(js->axes);
|
_glfw_free(js->buttons);
|
||||||
free(js->buttons);
|
_glfw_free(js->hats);
|
||||||
free(js->hats);
|
|
||||||
memset(js, 0, sizeof(_GLFWjoystick));
|
memset(js, 0, sizeof(_GLFWjoystick));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -751,7 +754,7 @@ GLFWAPI GLFWcursor* glfwCreateCursor(const GLFWimage* image, int xhot, int yhot)
|
|||||||
|
|
||||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||||
|
|
||||||
cursor = calloc(1, sizeof(_GLFWcursor));
|
cursor = _glfw_calloc(1, sizeof(_GLFWcursor));
|
||||||
cursor->next = _glfw.cursorListHead;
|
cursor->next = _glfw.cursorListHead;
|
||||||
_glfw.cursorListHead = cursor;
|
_glfw.cursorListHead = cursor;
|
||||||
|
|
||||||
@ -785,7 +788,7 @@ 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;
|
||||||
|
|
||||||
@ -830,7 +833,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)
|
||||||
@ -1188,8 +1191,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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -251,6 +251,9 @@ struct _GLFWinitconfig
|
|||||||
GLFWbool menubar;
|
GLFWbool menubar;
|
||||||
GLFWbool chdir;
|
GLFWbool chdir;
|
||||||
} ns;
|
} ns;
|
||||||
|
struct {
|
||||||
|
GLFWbool xcbVulkanSurface;
|
||||||
|
} x11;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Window configuration
|
// Window configuration
|
||||||
@ -405,6 +408,7 @@ struct _GLFWwindow
|
|||||||
GLFWbool mousePassthrough;
|
GLFWbool mousePassthrough;
|
||||||
GLFWbool shouldClose;
|
GLFWbool shouldClose;
|
||||||
void* userPointer;
|
void* userPointer;
|
||||||
|
GLFWbool doublebuffer;
|
||||||
GLFWvidmode videoMode;
|
GLFWvidmode videoMode;
|
||||||
_GLFWmonitor* monitor;
|
_GLFWmonitor* monitor;
|
||||||
_GLFWcursor* cursor;
|
_GLFWcursor* cursor;
|
||||||
@ -453,7 +457,7 @@ struct _GLFWwindow
|
|||||||
//
|
//
|
||||||
struct _GLFWmonitor
|
struct _GLFWmonitor
|
||||||
{
|
{
|
||||||
char* name;
|
char name[128];
|
||||||
void* userPointer;
|
void* userPointer;
|
||||||
|
|
||||||
// Physical dimensions in millimeters.
|
// Physical dimensions in millimeters.
|
||||||
@ -514,7 +518,7 @@ struct _GLFWjoystick
|
|||||||
int buttonCount;
|
int buttonCount;
|
||||||
unsigned char* hats;
|
unsigned char* hats;
|
||||||
int hatCount;
|
int hatCount;
|
||||||
char* name;
|
char name[128];
|
||||||
void* userPointer;
|
void* userPointer;
|
||||||
char guid[33];
|
char guid[33];
|
||||||
_GLFWmapping* mapping;
|
_GLFWmapping* mapping;
|
||||||
@ -544,6 +548,7 @@ struct _GLFWmutex
|
|||||||
struct _GLFWlibrary
|
struct _GLFWlibrary
|
||||||
{
|
{
|
||||||
GLFWbool initialized;
|
GLFWbool initialized;
|
||||||
|
GLFWallocator allocator;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
_GLFWinitconfig init;
|
_GLFWinitconfig init;
|
||||||
@ -801,6 +806,7 @@ void _glfwAllocGammaArrays(GLFWgammaramp* ramp, unsigned int size);
|
|||||||
void _glfwFreeGammaArrays(GLFWgammaramp* ramp);
|
void _glfwFreeGammaArrays(GLFWgammaramp* ramp);
|
||||||
void _glfwSplitBPP(int bpp, int* red, int* green, int* blue);
|
void _glfwSplitBPP(int bpp, int* red, int* green, int* blue);
|
||||||
|
|
||||||
|
void _glfwInitGamepadMappings(void);
|
||||||
_GLFWjoystick* _glfwAllocJoystick(const char* name,
|
_GLFWjoystick* _glfwAllocJoystick(const char* name,
|
||||||
const char* guid,
|
const char* guid,
|
||||||
int axisCount,
|
int axisCount,
|
||||||
@ -817,3 +823,7 @@ char* _glfw_strdup(const char* source);
|
|||||||
float _glfw_fminf(float a, float b);
|
float _glfw_fminf(float a, float b);
|
||||||
float _glfw_fmaxf(float a, float b);
|
float _glfw_fmaxf(float a, float b);
|
||||||
|
|
||||||
|
void* _glfw_calloc(size_t count, size_t size);
|
||||||
|
void* _glfw_realloc(void* pointer, size_t size);
|
||||||
|
void _glfw_free(void* pointer);
|
||||||
|
|
||||||
|
@ -32,6 +32,7 @@
|
|||||||
#define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE _GLFWlibraryLinux linjs
|
#define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE _GLFWlibraryLinux linjs
|
||||||
|
|
||||||
#define _GLFW_PLATFORM_MAPPING_NAME "Linux"
|
#define _GLFW_PLATFORM_MAPPING_NAME "Linux"
|
||||||
|
#define GLFW_BUILD_LINUX_MAPPINGS
|
||||||
|
|
||||||
// Linux-specific joystick data
|
// Linux-specific joystick data
|
||||||
//
|
//
|
||||||
|
1117
src/mappings.h
1117
src/mappings.h
File diff suppressed because it is too large
Load Diff
@ -31,7 +31,7 @@
|
|||||||
// all available in SDL_GameControllerDB. Do not edit this file. Any gamepad
|
// all available in SDL_GameControllerDB. Do not edit this file. Any gamepad
|
||||||
// mappings not specific to GLFW should be submitted to SDL_GameControllerDB.
|
// mappings not specific to GLFW should be submitted to SDL_GameControllerDB.
|
||||||
// This file can be re-generated from mappings.h.in and the upstream
|
// This file can be re-generated from mappings.h.in and the upstream
|
||||||
// gamecontrollerdb.txt with the GenerateMappings.cmake script.
|
// gamecontrollerdb.txt with the 'update_mappings' CMake target.
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
// All gamepad mappings not labeled GLFW are copied from the
|
// All gamepad mappings not labeled GLFW are copied from the
|
||||||
@ -60,7 +60,8 @@
|
|||||||
|
|
||||||
const char* _glfwDefaultMappings[] =
|
const char* _glfwDefaultMappings[] =
|
||||||
{
|
{
|
||||||
@GLFW_GAMEPAD_MAPPINGS@
|
#if defined(GLFW_BUILD_WIN32_MAPPINGS)
|
||||||
|
@GLFW_WIN32_MAPPINGS@
|
||||||
"78696e70757401000000000000000000,XInput Gamepad (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,",
|
"78696e70757401000000000000000000,XInput Gamepad (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,",
|
||||||
"78696e70757402000000000000000000,XInput Wheel (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,",
|
"78696e70757402000000000000000000,XInput Wheel (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,",
|
||||||
"78696e70757403000000000000000000,XInput Arcade Stick (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,",
|
"78696e70757403000000000000000000,XInput Arcade Stick (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,",
|
||||||
@ -68,6 +69,14 @@ const char* _glfwDefaultMappings[] =
|
|||||||
"78696e70757405000000000000000000,XInput Dance Pad (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,",
|
"78696e70757405000000000000000000,XInput Dance Pad (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,",
|
||||||
"78696e70757406000000000000000000,XInput Guitar (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,",
|
"78696e70757406000000000000000000,XInput Guitar (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,",
|
||||||
"78696e70757408000000000000000000,XInput Drum Kit (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,",
|
"78696e70757408000000000000000000,XInput Drum Kit (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,",
|
||||||
NULL
|
#endif // GLFW_BUILD_WIN32_MAPPINGS
|
||||||
|
|
||||||
|
#if defined(GLFW_BUILD_COCOA_MAPPINGS)
|
||||||
|
@GLFW_COCOA_MAPPINGS@
|
||||||
|
#endif // GLFW_BUILD_COCOA_MAPPINGS
|
||||||
|
|
||||||
|
#if defined(GLFW_BUILD_LINUX_MAPPINGS)
|
||||||
|
@GLFW_LINUX_MAPPINGS@
|
||||||
|
#endif // GLFW_BUILD_LINUX_MAPPINGS
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -80,7 +80,7 @@ static GLFWbool refreshVideoModes(_GLFWmonitor* monitor)
|
|||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
@ -166,12 +167,11 @@ void _glfwInputMonitorWindow(_GLFWmonitor* monitor, _GLFWwindow* window)
|
|||||||
//
|
//
|
||||||
_GLFWmonitor* _glfwAllocMonitor(const char* name, int widthMM, int heightMM)
|
_GLFWmonitor* _glfwAllocMonitor(const char* name, int widthMM, int heightMM)
|
||||||
{
|
{
|
||||||
_GLFWmonitor* monitor = calloc(1, sizeof(_GLFWmonitor));
|
_GLFWmonitor* monitor = _glfw_calloc(1, sizeof(_GLFWmonitor));
|
||||||
monitor->widthMM = widthMM;
|
monitor->widthMM = widthMM;
|
||||||
monitor->heightMM = heightMM;
|
monitor->heightMM = heightMM;
|
||||||
|
|
||||||
if (name)
|
strncpy(monitor->name, name, sizeof(monitor->name) - 1);
|
||||||
monitor->name = _glfw_strdup(name);
|
|
||||||
|
|
||||||
return monitor;
|
return monitor;
|
||||||
}
|
}
|
||||||
@ -188,18 +188,17 @@ void _glfwFreeMonitor(_GLFWmonitor* monitor)
|
|||||||
_glfwFreeGammaArrays(&monitor->originalRamp);
|
_glfwFreeGammaArrays(&monitor->originalRamp);
|
||||||
_glfwFreeGammaArrays(&monitor->currentRamp);
|
_glfwFreeGammaArrays(&monitor->currentRamp);
|
||||||
|
|
||||||
free(monitor->modes);
|
_glfw_free(monitor->modes);
|
||||||
free(monitor->name);
|
_glfw_free(monitor);
|
||||||
free(monitor);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allocates red, green and blue value arrays of the specified size
|
// Allocates red, green and blue value arrays of the specified size
|
||||||
//
|
//
|
||||||
void _glfwAllocGammaArrays(GLFWgammaramp* ramp, unsigned int size)
|
void _glfwAllocGammaArrays(GLFWgammaramp* ramp, unsigned int size)
|
||||||
{
|
{
|
||||||
ramp->red = calloc(size, sizeof(unsigned short));
|
ramp->red = _glfw_calloc(size, sizeof(unsigned short));
|
||||||
ramp->green = calloc(size, sizeof(unsigned short));
|
ramp->green = _glfw_calloc(size, sizeof(unsigned short));
|
||||||
ramp->blue = calloc(size, sizeof(unsigned short));
|
ramp->blue = _glfw_calloc(size, sizeof(unsigned short));
|
||||||
ramp->size = size;
|
ramp->size = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -207,9 +206,9 @@ void _glfwAllocGammaArrays(GLFWgammaramp* ramp, unsigned int size)
|
|||||||
//
|
//
|
||||||
void _glfwFreeGammaArrays(GLFWgammaramp* ramp)
|
void _glfwFreeGammaArrays(GLFWgammaramp* ramp)
|
||||||
{
|
{
|
||||||
free(ramp->red);
|
_glfw_free(ramp->red);
|
||||||
free(ramp->green);
|
_glfw_free(ramp->green);
|
||||||
free(ramp->blue);
|
_glfw_free(ramp->blue);
|
||||||
|
|
||||||
memset(ramp, 0, sizeof(GLFWgammaramp));
|
memset(ramp, 0, sizeof(GLFWgammaramp));
|
||||||
}
|
}
|
||||||
@ -474,7 +473,7 @@ GLFWAPI void glfwSetGamma(GLFWmonitor* handle, float gamma)
|
|||||||
if (!original)
|
if (!original)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
values = calloc(original->size, sizeof(unsigned short));
|
values = _glfw_calloc(original->size, sizeof(unsigned short));
|
||||||
|
|
||||||
for (i = 0; i < original->size; i++)
|
for (i = 0; i < original->size; i++)
|
||||||
{
|
{
|
||||||
@ -496,7 +495,7 @@ GLFWAPI void glfwSetGamma(GLFWmonitor* handle, float gamma)
|
|||||||
ramp.size = original->size;
|
ramp.size = original->size;
|
||||||
|
|
||||||
glfwSetGammaRamp(handle, &ramp);
|
glfwSetGammaRamp(handle, &ramp);
|
||||||
free(values);
|
_glfw_free(values);
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWAPI const GLFWgammaramp* glfwGetGammaRamp(GLFWmonitor* handle)
|
GLFWAPI const GLFWgammaramp* glfwGetGammaRamp(GLFWmonitor* handle)
|
||||||
|
@ -46,7 +46,7 @@ int _glfwPlatformInit(void)
|
|||||||
|
|
||||||
void _glfwPlatformTerminate(void)
|
void _glfwPlatformTerminate(void)
|
||||||
{
|
{
|
||||||
free(_glfw.null.clipboardString);
|
_glfw_free(_glfw.null.clipboardString);
|
||||||
_glfwTerminateOSMesa();
|
_glfwTerminateOSMesa();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,7 +105,7 @@ void _glfwPlatformGetMonitorWorkarea(_GLFWmonitor* monitor,
|
|||||||
|
|
||||||
GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* found)
|
GLFWvidmode* _glfwPlatformGetVideoModes(_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;
|
||||||
|
@ -513,7 +513,7 @@ void _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor)
|
|||||||
void _glfwPlatformSetClipboardString(const char* string)
|
void _glfwPlatformSetClipboardString(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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -524,6 +524,12 @@ const char* _glfwPlatformGetClipboardString(void)
|
|||||||
|
|
||||||
const char* _glfwPlatformGetScancodeName(int scancode)
|
const char* _glfwPlatformGetScancodeName(int scancode)
|
||||||
{
|
{
|
||||||
|
if (scancode < GLFW_KEY_SPACE || scancode > GLFW_KEY_LAST)
|
||||||
|
{
|
||||||
|
_glfwInputError(GLFW_INVALID_VALUE, "Invalid scancode %i", scancode);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
switch (scancode)
|
switch (scancode)
|
||||||
{
|
{
|
||||||
case GLFW_KEY_APOSTROPHE:
|
case GLFW_KEY_APOSTROPHE:
|
||||||
|
@ -46,10 +46,10 @@ static void makeContextCurrentOSMesa(_GLFWwindow* window)
|
|||||||
(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;
|
||||||
}
|
}
|
||||||
|
@ -27,13 +27,10 @@
|
|||||||
// It is fine to use C99 in this file because it will not be built with VS
|
// It is fine to use C99 in this file because it will not be built with VS
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
#define _POSIX_C_SOURCE 199309L
|
|
||||||
|
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <time.h>
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
@ -44,20 +41,14 @@
|
|||||||
//
|
//
|
||||||
void _glfwInitTimerPOSIX(void)
|
void _glfwInitTimerPOSIX(void)
|
||||||
{
|
{
|
||||||
#if defined(_POSIX_TIMERS) && defined(_POSIX_MONOTONIC_CLOCK)
|
_glfw.timer.posix.clock = CLOCK_REALTIME;
|
||||||
struct timespec ts;
|
_glfw.timer.posix.frequency = 1000000000;
|
||||||
|
|
||||||
|
#if defined(_POSIX_MONOTONIC_CLOCK)
|
||||||
|
struct timespec ts;
|
||||||
if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0)
|
if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0)
|
||||||
{
|
_glfw.timer.posix.clock = CLOCK_MONOTONIC;
|
||||||
_glfw.timer.posix.monotonic = GLFW_TRUE;
|
|
||||||
_glfw.timer.posix.frequency = 1000000000;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
#endif
|
#endif
|
||||||
{
|
|
||||||
_glfw.timer.posix.monotonic = GLFW_FALSE;
|
|
||||||
_glfw.timer.posix.frequency = 1000000;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -67,20 +58,9 @@ void _glfwInitTimerPOSIX(void)
|
|||||||
|
|
||||||
uint64_t _glfwPlatformGetTimerValue(void)
|
uint64_t _glfwPlatformGetTimerValue(void)
|
||||||
{
|
{
|
||||||
#if defined(_POSIX_TIMERS) && defined(_POSIX_MONOTONIC_CLOCK)
|
struct timespec ts;
|
||||||
if (_glfw.timer.posix.monotonic)
|
clock_gettime(_glfw.timer.posix.clock, &ts);
|
||||||
{
|
return (uint64_t) ts.tv_sec * _glfw.timer.posix.frequency + (uint64_t) ts.tv_nsec;
|
||||||
struct timespec ts;
|
|
||||||
clock_gettime(CLOCK_MONOTONIC, &ts);
|
|
||||||
return (uint64_t) ts.tv_sec * (uint64_t) 1000000000 + (uint64_t) ts.tv_nsec;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
struct timeval tv;
|
|
||||||
gettimeofday(&tv, NULL);
|
|
||||||
return (uint64_t) tv.tv_sec * (uint64_t) 1000000 + (uint64_t) tv.tv_usec;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t _glfwPlatformGetTimerFrequency(void)
|
uint64_t _glfwPlatformGetTimerFrequency(void)
|
||||||
|
@ -28,13 +28,14 @@
|
|||||||
#define _GLFW_PLATFORM_LIBRARY_TIMER_STATE _GLFWtimerPOSIX posix
|
#define _GLFW_PLATFORM_LIBRARY_TIMER_STATE _GLFWtimerPOSIX posix
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
|
|
||||||
// POSIX-specific global timer data
|
// POSIX-specific global timer data
|
||||||
//
|
//
|
||||||
typedef struct _GLFWtimerPOSIX
|
typedef struct _GLFWtimerPOSIX
|
||||||
{
|
{
|
||||||
GLFWbool monotonic;
|
clockid_t clock;
|
||||||
uint64_t frequency;
|
uint64_t frequency;
|
||||||
|
|
||||||
} _GLFWtimerPOSIX;
|
} _GLFWtimerPOSIX;
|
||||||
|
@ -108,7 +108,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 +117,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;
|
||||||
}
|
}
|
||||||
@ -145,7 +145,7 @@ GLFWbool _glfwInitVulkan(int mode)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
free(ep);
|
_glfw_free(ep);
|
||||||
|
|
||||||
_glfw.vk.available = GLFW_TRUE;
|
_glfw.vk.available = GLFW_TRUE;
|
||||||
|
|
||||||
|
@ -30,7 +30,6 @@
|
|||||||
#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
|
||||||
@ -130,7 +129,7 @@ static int choosePixelFormat(_GLFWwindow* window,
|
|||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
usableConfigs = calloc(nativeCount, sizeof(_GLFWfbconfig));
|
usableConfigs = _glfw_calloc(nativeCount, sizeof(_GLFWfbconfig));
|
||||||
|
|
||||||
for (i = 0; i < nativeCount; i++)
|
for (i = 0; i < nativeCount; i++)
|
||||||
{
|
{
|
||||||
@ -149,7 +148,7 @@ static int choosePixelFormat(_GLFWwindow* window,
|
|||||||
_glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
|
_glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
|
||||||
"WGL: Failed to retrieve pixel format attributes");
|
"WGL: Failed to retrieve pixel format attributes");
|
||||||
|
|
||||||
free(usableConfigs);
|
_glfw_free(usableConfigs);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -165,6 +164,9 @@ static int choosePixelFormat(_GLFWwindow* window,
|
|||||||
if (findAttribValue(WGL_ACCELERATION_ARB) == WGL_NO_ACCELERATION_ARB)
|
if (findAttribValue(WGL_ACCELERATION_ARB) == WGL_NO_ACCELERATION_ARB)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if (findAttribValue(WGL_DOUBLE_BUFFER_ARB) != fbconfig->doublebuffer)
|
||||||
|
continue;
|
||||||
|
|
||||||
u->redBits = findAttribValue(WGL_RED_BITS_ARB);
|
u->redBits = findAttribValue(WGL_RED_BITS_ARB);
|
||||||
u->greenBits = findAttribValue(WGL_GREEN_BITS_ARB);
|
u->greenBits = findAttribValue(WGL_GREEN_BITS_ARB);
|
||||||
u->blueBits = findAttribValue(WGL_BLUE_BITS_ARB);
|
u->blueBits = findAttribValue(WGL_BLUE_BITS_ARB);
|
||||||
@ -182,8 +184,6 @@ static int choosePixelFormat(_GLFWwindow* window,
|
|||||||
|
|
||||||
if (findAttribValue(WGL_STEREO_ARB))
|
if (findAttribValue(WGL_STEREO_ARB))
|
||||||
u->stereo = GLFW_TRUE;
|
u->stereo = GLFW_TRUE;
|
||||||
if (findAttribValue(WGL_DOUBLE_BUFFER_ARB))
|
|
||||||
u->doublebuffer = GLFW_TRUE;
|
|
||||||
|
|
||||||
if (_glfw.wgl.ARB_multisample)
|
if (_glfw.wgl.ARB_multisample)
|
||||||
u->samples = findAttribValue(WGL_SAMPLES_ARB);
|
u->samples = findAttribValue(WGL_SAMPLES_ARB);
|
||||||
@ -220,7 +220,7 @@ static int choosePixelFormat(_GLFWwindow* window,
|
|||||||
_glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
|
_glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
|
||||||
"WGL: Failed to describe pixel format");
|
"WGL: Failed to describe pixel format");
|
||||||
|
|
||||||
free(usableConfigs);
|
_glfw_free(usableConfigs);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -239,6 +239,9 @@ static int choosePixelFormat(_GLFWwindow* window,
|
|||||||
if (pfd.iPixelType != PFD_TYPE_RGBA)
|
if (pfd.iPixelType != PFD_TYPE_RGBA)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if (!!(pfd.dwFlags & PFD_DOUBLEBUFFER) != fbconfig->doublebuffer)
|
||||||
|
continue;
|
||||||
|
|
||||||
u->redBits = pfd.cRedBits;
|
u->redBits = pfd.cRedBits;
|
||||||
u->greenBits = pfd.cGreenBits;
|
u->greenBits = pfd.cGreenBits;
|
||||||
u->blueBits = pfd.cBlueBits;
|
u->blueBits = pfd.cBlueBits;
|
||||||
@ -256,8 +259,6 @@ static int choosePixelFormat(_GLFWwindow* window,
|
|||||||
|
|
||||||
if (pfd.dwFlags & PFD_STEREO)
|
if (pfd.dwFlags & PFD_STEREO)
|
||||||
u->stereo = GLFW_TRUE;
|
u->stereo = GLFW_TRUE;
|
||||||
if (pfd.dwFlags & PFD_DOUBLEBUFFER)
|
|
||||||
u->doublebuffer = GLFW_TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
u->handle = pixelFormat;
|
u->handle = pixelFormat;
|
||||||
@ -269,7 +270,7 @@ static int choosePixelFormat(_GLFWwindow* window,
|
|||||||
_glfwInputError(GLFW_API_UNAVAILABLE,
|
_glfwInputError(GLFW_API_UNAVAILABLE,
|
||||||
"WGL: The driver does not appear to support OpenGL");
|
"WGL: The driver does not appear to support OpenGL");
|
||||||
|
|
||||||
free(usableConfigs);
|
_glfw_free(usableConfigs);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -279,12 +280,12 @@ static int choosePixelFormat(_GLFWwindow* window,
|
|||||||
_glfwInputError(GLFW_FORMAT_UNAVAILABLE,
|
_glfwInputError(GLFW_FORMAT_UNAVAILABLE,
|
||||||
"WGL: Failed to find a suitable pixel format");
|
"WGL: Failed to find a suitable pixel format");
|
||||||
|
|
||||||
free(usableConfigs);
|
_glfw_free(usableConfigs);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
pixelFormat = (int) closest->handle;
|
pixelFormat = (int) closest->handle;
|
||||||
free(usableConfigs);
|
_glfw_free(usableConfigs);
|
||||||
|
|
||||||
return pixelFormat;
|
return pixelFormat;
|
||||||
}
|
}
|
||||||
|
@ -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
|
||||||
@ -405,13 +404,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 +432,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -558,14 +557,6 @@ BOOL _glfwIsWindows10BuildOrGreaterWin32(WORD build)
|
|||||||
|
|
||||||
int _glfwPlatformInit(void)
|
int _glfwPlatformInit(void)
|
||||||
{
|
{
|
||||||
// To make SetForegroundWindow work as we want, we need to fiddle
|
|
||||||
// with the FOREGROUNDLOCKTIMEOUT system setting (we do this as early
|
|
||||||
// as possible in the hope of still being the foreground process)
|
|
||||||
SystemParametersInfoW(SPI_GETFOREGROUNDLOCKTIMEOUT, 0,
|
|
||||||
&_glfw.win32.foregroundLockTimeout, 0);
|
|
||||||
SystemParametersInfoW(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, UIntToPtr(0),
|
|
||||||
SPIF_SENDCHANGE);
|
|
||||||
|
|
||||||
if (!loadLibraries())
|
if (!loadLibraries())
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
|
|
||||||
@ -601,13 +592,8 @@ void _glfwPlatformTerminate(void)
|
|||||||
|
|
||||||
_glfwUnregisterWindowClassWin32();
|
_glfwUnregisterWindowClassWin32();
|
||||||
|
|
||||||
// Restore previous foreground lock timeout system setting
|
_glfw_free(_glfw.win32.clipboardString);
|
||||||
SystemParametersInfoW(SPI_SETFOREGROUNDLOCKTIMEOUT, 0,
|
_glfw_free(_glfw.win32.rawInput);
|
||||||
UIntToPtr(_glfw.win32.foregroundLockTimeout),
|
|
||||||
SPIF_SENDCHANGE);
|
|
||||||
|
|
||||||
free(_glfw.win32.clipboardString);
|
|
||||||
free(_glfw.win32.rawInput);
|
|
||||||
|
|
||||||
_glfwTerminateWGL();
|
_glfwTerminateWGL();
|
||||||
_glfwTerminateEGL();
|
_glfwTerminateEGL();
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
#define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE struct { int dummyLibraryJoystick; }
|
#define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE struct { int dummyLibraryJoystick; }
|
||||||
|
|
||||||
#define _GLFW_PLATFORM_MAPPING_NAME "Windows"
|
#define _GLFW_PLATFORM_MAPPING_NAME "Windows"
|
||||||
|
#define GLFW_BUILD_WIN32_MAPPINGS
|
||||||
|
|
||||||
// Joystick element (axis, button or slider)
|
// Joystick element (axis, button or slider)
|
||||||
//
|
//
|
||||||
|
@ -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
|
||||||
@ -442,7 +441,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,7 +451,7 @@ 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);
|
_glfwPlatformGetVideoMode(monitor, result);
|
||||||
*count = 1;
|
*count = 1;
|
||||||
}
|
}
|
||||||
|
@ -39,8 +39,8 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// This is a workaround for the fact that glfw3.h needs to export APIENTRY (for
|
// This is a workaround for the fact that glfw3.h needs to export APIENTRY (for
|
||||||
// example to allow applications to correctly declare a GL_ARB_debug_output
|
// example to allow applications to correctly declare a GL_KHR_debug callback)
|
||||||
// callback) but windows.h assumes no one will define APIENTRY before it does
|
// but windows.h assumes no one will define APIENTRY before it does
|
||||||
#undef APIENTRY
|
#undef APIENTRY
|
||||||
|
|
||||||
// GLFW on Windows is Unicode only and does not work in MBCS mode
|
// GLFW on Windows is Unicode only and does not work in MBCS mode
|
||||||
@ -330,7 +330,6 @@ typedef struct _GLFWlibraryWin32
|
|||||||
{
|
{
|
||||||
HWND helperWindowHandle;
|
HWND helperWindowHandle;
|
||||||
HDEVNOTIFY deviceNotificationHandle;
|
HDEVNOTIFY deviceNotificationHandle;
|
||||||
DWORD foregroundLockTimeout;
|
|
||||||
int acquiredMonitorCount;
|
int acquiredMonitorCount;
|
||||||
char* clipboardString;
|
char* clipboardString;
|
||||||
short int keycodes[512];
|
short int keycodes[512];
|
||||||
|
@ -31,7 +31,6 @@
|
|||||||
|
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <malloc.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <windowsx.h>
|
#include <windowsx.h>
|
||||||
#include <shellapi.h>
|
#include <shellapi.h>
|
||||||
@ -884,8 +883,8 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
|
|||||||
GetRawInputData(ri, RID_INPUT, NULL, &size, sizeof(RAWINPUTHEADER));
|
GetRawInputData(ri, RID_INPUT, NULL, &size, sizeof(RAWINPUTHEADER));
|
||||||
if (size > (UINT) _glfw.win32.rawInputSize)
|
if (size > (UINT) _glfw.win32.rawInputSize)
|
||||||
{
|
{
|
||||||
free(_glfw.win32.rawInput);
|
_glfw_free(_glfw.win32.rawInput);
|
||||||
_glfw.win32.rawInput = calloc(size, 1);
|
_glfw.win32.rawInput = _glfw_calloc(size, 1);
|
||||||
_glfw.win32.rawInputSize = size;
|
_glfw.win32.rawInputSize = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1185,7 +1184,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
const int count = DragQueryFileW(drop, 0xffffffff, NULL, 0);
|
const int count = DragQueryFileW(drop, 0xffffffff, NULL, 0);
|
||||||
char** paths = calloc(count, sizeof(char*));
|
char** paths = _glfw_calloc(count, sizeof(char*));
|
||||||
|
|
||||||
// Move the mouse to the position of the drop
|
// Move the mouse to the position of the drop
|
||||||
DragQueryPoint(drop, &pt);
|
DragQueryPoint(drop, &pt);
|
||||||
@ -1194,19 +1193,19 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
|
|||||||
for (i = 0; i < count; i++)
|
for (i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
const UINT length = DragQueryFileW(drop, i, NULL, 0);
|
const UINT length = DragQueryFileW(drop, i, NULL, 0);
|
||||||
WCHAR* buffer = calloc((size_t) length + 1, sizeof(WCHAR));
|
WCHAR* buffer = _glfw_calloc((size_t) length + 1, sizeof(WCHAR));
|
||||||
|
|
||||||
DragQueryFileW(drop, i, buffer, length + 1);
|
DragQueryFileW(drop, i, buffer, length + 1);
|
||||||
paths[i] = _glfwCreateUTF8FromWideStringWin32(buffer);
|
paths[i] = _glfwCreateUTF8FromWideStringWin32(buffer);
|
||||||
|
|
||||||
free(buffer);
|
_glfw_free(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
_glfwInputDrop(window, count, (const char**) paths);
|
_glfwInputDrop(window, count, (const char**) paths);
|
||||||
|
|
||||||
for (i = 0; i < count; i++)
|
for (i = 0; i < count; i++)
|
||||||
free(paths[i]);
|
_glfw_free(paths[i]);
|
||||||
free(paths);
|
_glfw_free(paths);
|
||||||
|
|
||||||
DragFinish(drop);
|
DragFinish(drop);
|
||||||
return 0;
|
return 0;
|
||||||
@ -1269,7 +1268,7 @@ static int createNativeWindow(_GLFWwindow* window,
|
|||||||
GetModuleHandleW(NULL),
|
GetModuleHandleW(NULL),
|
||||||
(LPVOID) wndconfig);
|
(LPVOID) wndconfig);
|
||||||
|
|
||||||
free(wideTitle);
|
_glfw_free(wideTitle);
|
||||||
|
|
||||||
if (!window->win32.handle)
|
if (!window->win32.handle)
|
||||||
{
|
{
|
||||||
@ -1469,7 +1468,7 @@ void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
SetWindowTextW(window->win32.handle, wideTitle);
|
SetWindowTextW(window->win32.handle, wideTitle);
|
||||||
free(wideTitle);
|
_glfw_free(wideTitle);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformSetWindowIcon(_GLFWwindow* window,
|
void _glfwPlatformSetWindowIcon(_GLFWwindow* window,
|
||||||
@ -2108,7 +2107,7 @@ const char* _glfwPlatformGetScancodeName(int scancode)
|
|||||||
if (scancode < 0 || scancode > (KF_EXTENDED | 0xff) ||
|
if (scancode < 0 || scancode > (KF_EXTENDED | 0xff) ||
|
||||||
_glfw.win32.keycodes[scancode] == GLFW_KEY_UNKNOWN)
|
_glfw.win32.keycodes[scancode] == GLFW_KEY_UNKNOWN)
|
||||||
{
|
{
|
||||||
_glfwInputError(GLFW_INVALID_VALUE, "Invalid scancode");
|
_glfwInputError(GLFW_INVALID_VALUE, "Invalid scancode %i", scancode);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2270,7 +2269,7 @@ const char* _glfwPlatformGetClipboardString(void)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
free(_glfw.win32.clipboardString);
|
_glfw_free(_glfw.win32.clipboardString);
|
||||||
_glfw.win32.clipboardString = _glfwCreateUTF8FromWideStringWin32(buffer);
|
_glfw.win32.clipboardString = _glfwCreateUTF8FromWideStringWin32(buffer);
|
||||||
|
|
||||||
GlobalUnlock(object);
|
GlobalUnlock(object);
|
||||||
@ -2309,7 +2308,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;
|
||||||
|
@ -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;
|
||||||
|
|
||||||
@ -206,6 +206,8 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height,
|
|||||||
window->mousePassthrough = wndconfig.mousePassthrough;
|
window->mousePassthrough = wndconfig.mousePassthrough;
|
||||||
window->cursorMode = GLFW_CURSOR_NORMAL;
|
window->cursorMode = GLFW_CURSOR_NORMAL;
|
||||||
|
|
||||||
|
window->doublebuffer = fbconfig.doublebuffer;
|
||||||
|
|
||||||
window->minwidth = GLFW_DONT_CARE;
|
window->minwidth = GLFW_DONT_CARE;
|
||||||
window->minheight = GLFW_DONT_CARE;
|
window->minheight = GLFW_DONT_CARE;
|
||||||
window->maxwidth = GLFW_DONT_CARE;
|
window->maxwidth = GLFW_DONT_CARE;
|
||||||
@ -478,7 +480,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)
|
||||||
@ -841,6 +843,8 @@ GLFWAPI int glfwGetWindowAttrib(GLFWwindow* handle, int attrib)
|
|||||||
return window->floating;
|
return window->floating;
|
||||||
case GLFW_AUTO_ICONIFY:
|
case GLFW_AUTO_ICONIFY:
|
||||||
return window->autoIconify;
|
return window->autoIconify;
|
||||||
|
case GLFW_DOUBLEBUFFER:
|
||||||
|
return window->doublebuffer;
|
||||||
case GLFW_CLIENT_API:
|
case GLFW_CLIENT_API:
|
||||||
return window->context.client;
|
return window->context.client;
|
||||||
case GLFW_CONTEXT_CREATION_API:
|
case GLFW_CONTEXT_CREATION_API:
|
||||||
|
103
src/wl_init.c
103
src/wl_init.c
@ -26,8 +26,6 @@
|
|||||||
// It is fine to use C99 in this file because it will not be built with VS
|
// It is fine to use C99 in this file because it will not be built with VS
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
#define _POSIX_C_SOURCE 199309L
|
|
||||||
|
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
@ -41,7 +39,22 @@
|
|||||||
#include <sys/timerfd.h>
|
#include <sys/timerfd.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <wayland-client.h>
|
|
||||||
|
#include "wayland-client-protocol.h"
|
||||||
|
#include "wayland-xdg-shell-client-protocol.h"
|
||||||
|
#include "wayland-xdg-decoration-client-protocol.h"
|
||||||
|
#include "wayland-viewporter-client-protocol.h"
|
||||||
|
#include "wayland-relative-pointer-unstable-v1-client-protocol.h"
|
||||||
|
#include "wayland-pointer-constraints-unstable-v1-client-protocol.h"
|
||||||
|
#include "wayland-idle-inhibit-unstable-v1-client-protocol.h"
|
||||||
|
|
||||||
|
#include "wayland-client-protocol-code.h"
|
||||||
|
#include "wayland-xdg-shell-client-protocol-code.h"
|
||||||
|
#include "wayland-xdg-decoration-client-protocol-code.h"
|
||||||
|
#include "wayland-viewporter-client-protocol-code.h"
|
||||||
|
#include "wayland-relative-pointer-unstable-v1-client-protocol-code.h"
|
||||||
|
#include "wayland-pointer-constraints-unstable-v1-client-protocol-code.h"
|
||||||
|
#include "wayland-idle-inhibit-unstable-v1-client-protocol-code.h"
|
||||||
|
|
||||||
|
|
||||||
static inline int min(int n1, int n2)
|
static inline int min(int n1, int n2)
|
||||||
@ -105,6 +118,7 @@ static void pointerHandleEnter(void* data,
|
|||||||
|
|
||||||
window->wl.decorations.focus = focus;
|
window->wl.decorations.focus = focus;
|
||||||
_glfw.wl.serial = serial;
|
_glfw.wl.serial = serial;
|
||||||
|
_glfw.wl.pointerEnterSerial = serial;
|
||||||
_glfw.wl.pointerFocus = window;
|
_glfw.wl.pointerFocus = window;
|
||||||
|
|
||||||
window->wl.hovered = GLFW_TRUE;
|
window->wl.hovered = GLFW_TRUE;
|
||||||
@ -164,7 +178,7 @@ static void setCursor(_GLFWwindow* window, const char* name)
|
|||||||
buffer = wl_cursor_image_get_buffer(image);
|
buffer = wl_cursor_image_get_buffer(image);
|
||||||
if (!buffer)
|
if (!buffer)
|
||||||
return;
|
return;
|
||||||
wl_pointer_set_cursor(_glfw.wl.pointer, _glfw.wl.serial,
|
wl_pointer_set_cursor(_glfw.wl.pointer, _glfw.wl.pointerEnterSerial,
|
||||||
surface,
|
surface,
|
||||||
image->hotspot_x / scale,
|
image->hotspot_x / scale,
|
||||||
image->hotspot_y / scale);
|
image->hotspot_y / scale);
|
||||||
@ -552,7 +566,7 @@ static GLFWbool inputChar(_GLFWwindow* window, uint32_t key)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return xkb_keymap_key_repeats(_glfw.wl.xkb.keymap, syms[0]);
|
return xkb_keymap_key_repeats(_glfw.wl.xkb.keymap, code);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void keyboardHandleKey(void* data,
|
static void keyboardHandleKey(void* data,
|
||||||
@ -1039,6 +1053,73 @@ int _glfwPlatformInit(void)
|
|||||||
long cursorSizeLong;
|
long cursorSizeLong;
|
||||||
int cursorSize;
|
int cursorSize;
|
||||||
|
|
||||||
|
_glfw.wl.client.handle = _glfw_dlopen("libwayland-client.so.0");
|
||||||
|
if (!_glfw.wl.client.handle)
|
||||||
|
{
|
||||||
|
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||||
|
"Wayland: Failed to open libwayland-client");
|
||||||
|
return GLFW_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
_glfw.wl.client.display_flush = (PFN_wl_display_flush)
|
||||||
|
_glfw_dlsym(_glfw.wl.client.handle, "wl_display_flush");
|
||||||
|
_glfw.wl.client.display_cancel_read = (PFN_wl_display_cancel_read)
|
||||||
|
_glfw_dlsym(_glfw.wl.client.handle, "wl_display_cancel_read");
|
||||||
|
_glfw.wl.client.display_dispatch_pending = (PFN_wl_display_dispatch_pending)
|
||||||
|
_glfw_dlsym(_glfw.wl.client.handle, "wl_display_dispatch_pending");
|
||||||
|
_glfw.wl.client.display_read_events = (PFN_wl_display_read_events)
|
||||||
|
_glfw_dlsym(_glfw.wl.client.handle, "wl_display_read_events");
|
||||||
|
_glfw.wl.client.display_connect = (PFN_wl_display_connect)
|
||||||
|
_glfw_dlsym(_glfw.wl.client.handle, "wl_display_connect");
|
||||||
|
_glfw.wl.client.display_disconnect = (PFN_wl_display_disconnect)
|
||||||
|
_glfw_dlsym(_glfw.wl.client.handle, "wl_display_disconnect");
|
||||||
|
_glfw.wl.client.display_roundtrip = (PFN_wl_display_roundtrip)
|
||||||
|
_glfw_dlsym(_glfw.wl.client.handle, "wl_display_roundtrip");
|
||||||
|
_glfw.wl.client.display_get_fd = (PFN_wl_display_get_fd)
|
||||||
|
_glfw_dlsym(_glfw.wl.client.handle, "wl_display_get_fd");
|
||||||
|
_glfw.wl.client.display_prepare_read = (PFN_wl_display_prepare_read)
|
||||||
|
_glfw_dlsym(_glfw.wl.client.handle, "wl_display_prepare_read");
|
||||||
|
_glfw.wl.client.proxy_marshal = (PFN_wl_proxy_marshal)
|
||||||
|
_glfw_dlsym(_glfw.wl.client.handle, "wl_proxy_marshal");
|
||||||
|
_glfw.wl.client.proxy_add_listener = (PFN_wl_proxy_add_listener)
|
||||||
|
_glfw_dlsym(_glfw.wl.client.handle, "wl_proxy_add_listener");
|
||||||
|
_glfw.wl.client.proxy_destroy = (PFN_wl_proxy_destroy)
|
||||||
|
_glfw_dlsym(_glfw.wl.client.handle, "wl_proxy_destroy");
|
||||||
|
_glfw.wl.client.proxy_marshal_constructor = (PFN_wl_proxy_marshal_constructor)
|
||||||
|
_glfw_dlsym(_glfw.wl.client.handle, "wl_proxy_marshal_constructor");
|
||||||
|
_glfw.wl.client.proxy_marshal_constructor_versioned = (PFN_wl_proxy_marshal_constructor_versioned)
|
||||||
|
_glfw_dlsym(_glfw.wl.client.handle, "wl_proxy_marshal_constructor_versioned");
|
||||||
|
_glfw.wl.client.proxy_get_user_data = (PFN_wl_proxy_get_user_data)
|
||||||
|
_glfw_dlsym(_glfw.wl.client.handle, "wl_proxy_get_user_data");
|
||||||
|
_glfw.wl.client.proxy_set_user_data = (PFN_wl_proxy_set_user_data)
|
||||||
|
_glfw_dlsym(_glfw.wl.client.handle, "wl_proxy_set_user_data");
|
||||||
|
_glfw.wl.client.proxy_get_version = (PFN_wl_proxy_get_version)
|
||||||
|
_glfw_dlsym(_glfw.wl.client.handle, "wl_proxy_get_version");
|
||||||
|
_glfw.wl.client.proxy_marshal_flags = (PFN_wl_proxy_marshal_flags)
|
||||||
|
_glfw_dlsym(_glfw.wl.client.handle, "wl_proxy_marshal_flags");
|
||||||
|
|
||||||
|
if (!_glfw.wl.client.display_flush ||
|
||||||
|
!_glfw.wl.client.display_cancel_read ||
|
||||||
|
!_glfw.wl.client.display_dispatch_pending ||
|
||||||
|
!_glfw.wl.client.display_read_events ||
|
||||||
|
!_glfw.wl.client.display_connect ||
|
||||||
|
!_glfw.wl.client.display_disconnect ||
|
||||||
|
!_glfw.wl.client.display_roundtrip ||
|
||||||
|
!_glfw.wl.client.display_get_fd ||
|
||||||
|
!_glfw.wl.client.display_prepare_read ||
|
||||||
|
!_glfw.wl.client.proxy_marshal ||
|
||||||
|
!_glfw.wl.client.proxy_add_listener ||
|
||||||
|
!_glfw.wl.client.proxy_destroy ||
|
||||||
|
!_glfw.wl.client.proxy_marshal_constructor ||
|
||||||
|
!_glfw.wl.client.proxy_marshal_constructor_versioned ||
|
||||||
|
!_glfw.wl.client.proxy_get_user_data ||
|
||||||
|
!_glfw.wl.client.proxy_set_user_data)
|
||||||
|
{
|
||||||
|
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||||
|
"Wayland: Failed to load libwayland-client entry point");
|
||||||
|
return GLFW_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
_glfw.wl.cursor.handle = _glfw_dlopen("libwayland-cursor.so.0");
|
_glfw.wl.cursor.handle = _glfw_dlopen("libwayland-cursor.so.0");
|
||||||
if (!_glfw.wl.cursor.handle)
|
if (!_glfw.wl.cursor.handle)
|
||||||
{
|
{
|
||||||
@ -1193,7 +1274,7 @@ int _glfwPlatformInit(void)
|
|||||||
wl_data_device_manager_get_data_device(_glfw.wl.dataDeviceManager,
|
wl_data_device_manager_get_data_device(_glfw.wl.dataDeviceManager,
|
||||||
_glfw.wl.seat);
|
_glfw.wl.seat);
|
||||||
wl_data_device_add_listener(_glfw.wl.dataDevice, &dataDeviceListener, NULL);
|
wl_data_device_add_listener(_glfw.wl.dataDevice, &dataDeviceListener, NULL);
|
||||||
_glfw.wl.clipboardString = malloc(4096);
|
_glfw.wl.clipboardString = _glfw_calloc(4096, 1);
|
||||||
if (!_glfw.wl.clipboardString)
|
if (!_glfw.wl.clipboardString)
|
||||||
{
|
{
|
||||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||||
@ -1289,18 +1370,16 @@ void _glfwPlatformTerminate(void)
|
|||||||
close(_glfw.wl.cursorTimerfd);
|
close(_glfw.wl.cursorTimerfd);
|
||||||
|
|
||||||
if (_glfw.wl.clipboardString)
|
if (_glfw.wl.clipboardString)
|
||||||
free(_glfw.wl.clipboardString);
|
_glfw_free(_glfw.wl.clipboardString);
|
||||||
if (_glfw.wl.clipboardSendString)
|
if (_glfw.wl.clipboardSendString)
|
||||||
free(_glfw.wl.clipboardSendString);
|
_glfw_free(_glfw.wl.clipboardSendString);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* _glfwPlatformGetVersionString(void)
|
const char* _glfwPlatformGetVersionString(void)
|
||||||
{
|
{
|
||||||
return _GLFW_VERSION_NUMBER " Wayland EGL OSMesa"
|
return _GLFW_VERSION_NUMBER " Wayland EGL OSMesa"
|
||||||
#if defined(_POSIX_TIMERS) && defined(_POSIX_MONOTONIC_CLOCK)
|
#if defined(_POSIX_MONOTONIC_CLOCK)
|
||||||
" clock_gettime"
|
" monotonic"
|
||||||
#else
|
|
||||||
" gettimeofday"
|
|
||||||
#endif
|
#endif
|
||||||
" evdev"
|
" evdev"
|
||||||
#if defined(_GLFW_BUILD_DLL)
|
#if defined(_GLFW_BUILD_DLL)
|
||||||
|
@ -34,6 +34,8 @@
|
|||||||
#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* data,
|
||||||
struct wl_output* output,
|
struct wl_output* output,
|
||||||
@ -47,15 +49,13 @@ static void outputHandleGeometry(void* data,
|
|||||||
int32_t transform)
|
int32_t transform)
|
||||||
{
|
{
|
||||||
struct _GLFWmonitor *monitor = data;
|
struct _GLFWmonitor *monitor = data;
|
||||||
char name[1024];
|
|
||||||
|
|
||||||
monitor->wl.x = x;
|
monitor->wl.x = x;
|
||||||
monitor->wl.y = y;
|
monitor->wl.y = y;
|
||||||
monitor->widthMM = physicalWidth;
|
monitor->widthMM = physicalWidth;
|
||||||
monitor->heightMM = physicalHeight;
|
monitor->heightMM = physicalHeight;
|
||||||
|
|
||||||
snprintf(name, sizeof(name), "%s %s", make, model);
|
snprintf(monitor->name, sizeof(monitor->name), "%s %s", make, model);
|
||||||
monitor->name = _glfw_strdup(name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void outputHandleMode(void* data,
|
static void outputHandleMode(void* data,
|
||||||
@ -77,7 +77,7 @@ 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)
|
||||||
@ -133,7 +133,7 @@ void _glfwAddOutputWayland(uint32_t name, uint32_t version)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// The actual name of this output will be set in the geometry handler.
|
// The actual name of this output will be set in the geometry handler.
|
||||||
monitor = _glfwAllocMonitor(NULL, 0, 0);
|
monitor = _glfwAllocMonitor("", 0, 0);
|
||||||
|
|
||||||
output = wl_registry_bind(_glfw.wl.registry,
|
output = wl_registry_bind(_glfw.wl.registry,
|
||||||
name,
|
name,
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
//
|
//
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
#include <wayland-client.h>
|
#include <wayland-client-core.h>
|
||||||
#include <xkbcommon/xkbcommon.h>
|
#include <xkbcommon/xkbcommon.h>
|
||||||
#ifdef HAVE_XKBCOMMON_COMPOSE_H
|
#ifdef HAVE_XKBCOMMON_COMPOSE_H
|
||||||
#include <xkbcommon/xkbcommon-compose.h>
|
#include <xkbcommon/xkbcommon-compose.h>
|
||||||
@ -54,12 +54,84 @@ typedef VkBool32 (APIENTRY *PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR
|
|||||||
#endif
|
#endif
|
||||||
#include "xkb_unicode.h"
|
#include "xkb_unicode.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_connect _glfw.wl.client.display_connect
|
||||||
|
#define wl_display_disconnect _glfw.wl.client.display_disconnect
|
||||||
|
#define wl_display_roundtrip _glfw.wl.client.display_roundtrip
|
||||||
|
#define wl_display_get_fd _glfw.wl.client.display_get_fd
|
||||||
|
#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
|
||||||
|
|
||||||
|
struct wl_shm;
|
||||||
|
|
||||||
|
#define wl_display_interface _glfw_wl_display_interface
|
||||||
|
#define wl_subcompositor_interface _glfw_wl_subcompositor_interface
|
||||||
|
#define wl_compositor_interface _glfw_wl_compositor_interface
|
||||||
|
#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_dlopen(name) dlopen(name, RTLD_LAZY | RTLD_LOCAL)
|
#define _glfw_dlopen(name) dlopen(name, RTLD_LAZY | RTLD_LOCAL)
|
||||||
#define _glfw_dlclose(handle) dlclose(handle)
|
#define _glfw_dlclose(handle) dlclose(handle)
|
||||||
@ -246,6 +318,7 @@ 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;
|
||||||
@ -303,6 +376,28 @@ typedef struct _GLFWlibraryWayland
|
|||||||
_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_connect display_connect;
|
||||||
|
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;
|
||||||
|
|
||||||
|
@ -40,6 +40,14 @@
|
|||||||
#include <sys/timerfd.h>
|
#include <sys/timerfd.h>
|
||||||
#include <poll.h>
|
#include <poll.h>
|
||||||
|
|
||||||
|
#include "wayland-client-protocol.h"
|
||||||
|
#include "wayland-xdg-shell-client-protocol.h"
|
||||||
|
#include "wayland-xdg-decoration-client-protocol.h"
|
||||||
|
#include "wayland-viewporter-client-protocol.h"
|
||||||
|
#include "wayland-relative-pointer-unstable-v1-client-protocol.h"
|
||||||
|
#include "wayland-pointer-constraints-unstable-v1-client-protocol.h"
|
||||||
|
#include "wayland-idle-inhibit-unstable-v1-client-protocol.h"
|
||||||
|
|
||||||
|
|
||||||
static int createTmpfileCloexec(char* tmpname)
|
static int createTmpfileCloexec(char* tmpname)
|
||||||
{
|
{
|
||||||
@ -104,12 +112,12 @@ static int createAnonymousFile(off_t size)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
name = calloc(strlen(path) + sizeof(template), 1);
|
name = _glfw_calloc(strlen(path) + sizeof(template), 1);
|
||||||
strcpy(name, path);
|
strcpy(name, path);
|
||||||
strcat(name, template);
|
strcat(name, template);
|
||||||
|
|
||||||
fd = createTmpfileCloexec(name);
|
fd = createTmpfileCloexec(name);
|
||||||
free(name);
|
_glfw_free(name);
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -374,8 +382,8 @@ static void surfaceHandleEnter(void *data,
|
|||||||
{
|
{
|
||||||
++window->wl.monitorsSize;
|
++window->wl.monitorsSize;
|
||||||
window->wl.monitors =
|
window->wl.monitors =
|
||||||
realloc(window->wl.monitors,
|
_glfw_realloc(window->wl.monitors,
|
||||||
window->wl.monitorsSize * sizeof(_GLFWmonitor*));
|
window->wl.monitorsSize * sizeof(_GLFWmonitor*));
|
||||||
}
|
}
|
||||||
|
|
||||||
window->wl.monitors[window->wl.monitorsCount++] = monitor;
|
window->wl.monitors[window->wl.monitorsCount++] = monitor;
|
||||||
@ -675,7 +683,7 @@ static void setCursorImage(_GLFWwindow* window,
|
|||||||
cursorWayland->yhot = image->hotspot_y;
|
cursorWayland->yhot = image->hotspot_y;
|
||||||
}
|
}
|
||||||
|
|
||||||
wl_pointer_set_cursor(_glfw.wl.pointer, _glfw.wl.serial,
|
wl_pointer_set_cursor(_glfw.wl.pointer, _glfw.wl.pointerEnterSerial,
|
||||||
surface,
|
surface,
|
||||||
cursorWayland->xhot / scale,
|
cursorWayland->xhot / scale,
|
||||||
cursorWayland->yhot / scale);
|
cursorWayland->yhot / scale);
|
||||||
@ -829,7 +837,7 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
|
|||||||
|
|
||||||
window->wl.currentCursor = NULL;
|
window->wl.currentCursor = NULL;
|
||||||
|
|
||||||
window->wl.monitors = calloc(1, sizeof(_GLFWmonitor*));
|
window->wl.monitors = _glfw_calloc(1, sizeof(_GLFWmonitor*));
|
||||||
window->wl.monitorsCount = 0;
|
window->wl.monitorsCount = 0;
|
||||||
window->wl.monitorsSize = 1;
|
window->wl.monitorsSize = 1;
|
||||||
|
|
||||||
@ -874,14 +882,14 @@ void _glfwPlatformDestroyWindow(_GLFWwindow* window)
|
|||||||
if (window->wl.surface)
|
if (window->wl.surface)
|
||||||
wl_surface_destroy(window->wl.surface);
|
wl_surface_destroy(window->wl.surface);
|
||||||
|
|
||||||
free(window->wl.title);
|
_glfw_free(window->wl.title);
|
||||||
free(window->wl.monitors);
|
_glfw_free(window->wl.monitors);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title)
|
void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title)
|
||||||
{
|
{
|
||||||
if (window->wl.title)
|
if (window->wl.title)
|
||||||
free(window->wl.title);
|
_glfw_free(window->wl.title);
|
||||||
window->wl.title = _glfw_strdup(title);
|
window->wl.title = _glfw_strdup(title);
|
||||||
if (window->wl.xdg.toplevel)
|
if (window->wl.xdg.toplevel)
|
||||||
xdg_toplevel_set_title(window->wl.xdg.toplevel, title);
|
xdg_toplevel_set_title(window->wl.xdg.toplevel, title);
|
||||||
@ -1291,18 +1299,25 @@ int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape)
|
|||||||
{
|
{
|
||||||
case GLFW_ARROW_CURSOR:
|
case GLFW_ARROW_CURSOR:
|
||||||
name = "left_ptr";
|
name = "left_ptr";
|
||||||
|
break;
|
||||||
case GLFW_IBEAM_CURSOR:
|
case GLFW_IBEAM_CURSOR:
|
||||||
name = "xterm";
|
name = "xterm";
|
||||||
|
break;
|
||||||
case GLFW_CROSSHAIR_CURSOR:
|
case GLFW_CROSSHAIR_CURSOR:
|
||||||
name = "crosshair";
|
name = "crosshair";
|
||||||
|
break;
|
||||||
case GLFW_POINTING_HAND_CURSOR:
|
case GLFW_POINTING_HAND_CURSOR:
|
||||||
name = "hand2";
|
name = "hand2";
|
||||||
|
break;
|
||||||
case GLFW_RESIZE_EW_CURSOR:
|
case GLFW_RESIZE_EW_CURSOR:
|
||||||
name = "sb_h_double_arrow";
|
name = "sb_h_double_arrow";
|
||||||
|
break;
|
||||||
case GLFW_RESIZE_NS_CURSOR:
|
case GLFW_RESIZE_NS_CURSOR:
|
||||||
name = "sb_v_double_arrow";
|
name = "sb_v_double_arrow";
|
||||||
|
break;
|
||||||
case GLFW_RESIZE_ALL_CURSOR:
|
case GLFW_RESIZE_ALL_CURSOR:
|
||||||
name = "fleur";
|
name = "fleur";
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
_glfwInputError(GLFW_CURSOR_UNAVAILABLE,
|
_glfwInputError(GLFW_CURSOR_UNAVAILABLE,
|
||||||
"Wayland: Standard cursor shape unavailable");
|
"Wayland: Standard cursor shape unavailable");
|
||||||
@ -1440,7 +1455,7 @@ static void lockPointer(_GLFWwindow* window)
|
|||||||
window->wl.pointerLock.relativePointer = relativePointer;
|
window->wl.pointerLock.relativePointer = relativePointer;
|
||||||
window->wl.pointerLock.lockedPointer = lockedPointer;
|
window->wl.pointerLock.lockedPointer = lockedPointer;
|
||||||
|
|
||||||
wl_pointer_set_cursor(_glfw.wl.pointer, _glfw.wl.serial,
|
wl_pointer_set_cursor(_glfw.wl.pointer, _glfw.wl.pointerEnterSerial,
|
||||||
NULL, 0, 0);
|
NULL, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1504,7 +1519,7 @@ void _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor)
|
|||||||
}
|
}
|
||||||
else if (window->cursorMode == GLFW_CURSOR_HIDDEN)
|
else if (window->cursorMode == GLFW_CURSOR_HIDDEN)
|
||||||
{
|
{
|
||||||
wl_pointer_set_cursor(_glfw.wl.pointer, _glfw.wl.serial, NULL, 0, 0);
|
wl_pointer_set_cursor(_glfw.wl.pointer, _glfw.wl.pointerEnterSerial, NULL, 0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1600,11 +1615,11 @@ void _glfwPlatformSetClipboardString(const char* string)
|
|||||||
|
|
||||||
if (_glfw.wl.clipboardSendString)
|
if (_glfw.wl.clipboardSendString)
|
||||||
{
|
{
|
||||||
free(_glfw.wl.clipboardSendString);
|
_glfw_free(_glfw.wl.clipboardSendString);
|
||||||
_glfw.wl.clipboardSendString = NULL;
|
_glfw.wl.clipboardSendString = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
_glfw.wl.clipboardSendString = strdup(string);
|
_glfw.wl.clipboardSendString = _glfw_strdup(string);
|
||||||
if (!_glfw.wl.clipboardSendString)
|
if (!_glfw.wl.clipboardSendString)
|
||||||
{
|
{
|
||||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||||
@ -1618,7 +1633,7 @@ void _glfwPlatformSetClipboardString(const char* string)
|
|||||||
{
|
{
|
||||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||||
"Wayland: Impossible to create clipboard source");
|
"Wayland: Impossible to create clipboard source");
|
||||||
free(_glfw.wl.clipboardSendString);
|
_glfw_free(_glfw.wl.clipboardSendString);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
wl_data_source_add_listener(_glfw.wl.dataSource,
|
wl_data_source_add_listener(_glfw.wl.dataSource,
|
||||||
@ -1634,7 +1649,7 @@ static GLFWbool growClipboardString(void)
|
|||||||
{
|
{
|
||||||
char* clipboard = _glfw.wl.clipboardString;
|
char* clipboard = _glfw.wl.clipboardString;
|
||||||
|
|
||||||
clipboard = realloc(clipboard, _glfw.wl.clipboardSize * 2);
|
clipboard = _glfw_realloc(clipboard, _glfw.wl.clipboardSize * 2);
|
||||||
if (!clipboard)
|
if (!clipboard)
|
||||||
{
|
{
|
||||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||||
|
@ -813,11 +813,15 @@ static GLFWbool initExtensions(void)
|
|||||||
XkbGroupStateMask, XkbGroupStateMask);
|
XkbGroupStateMask, XkbGroupStateMask);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_glfw.hints.init.x11.xcbVulkanSurface)
|
||||||
|
{
|
||||||
#if defined(__CYGWIN__)
|
#if defined(__CYGWIN__)
|
||||||
_glfw.x11.x11xcb.handle = _glfw_dlopen("libX11-xcb-1.so");
|
_glfw.x11.x11xcb.handle = _glfw_dlopen("libX11-xcb-1.so");
|
||||||
#else
|
#else
|
||||||
_glfw.x11.x11xcb.handle = _glfw_dlopen("libX11-xcb.so.1");
|
_glfw.x11.x11xcb.handle = _glfw_dlopen("libX11-xcb.so.1");
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
if (_glfw.x11.x11xcb.handle)
|
if (_glfw.x11.x11xcb.handle)
|
||||||
{
|
{
|
||||||
_glfw.x11.x11xcb.GetXCBConnection = (PFN_XGetXCBConnection)
|
_glfw.x11.x11xcb.GetXCBConnection = (PFN_XGetXCBConnection)
|
||||||
@ -1403,8 +1407,8 @@ void _glfwPlatformTerminate(void)
|
|||||||
_glfw.x11.hiddenCursorHandle = (Cursor) 0;
|
_glfw.x11.hiddenCursorHandle = (Cursor) 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
free(_glfw.x11.primarySelectionString);
|
_glfw_free(_glfw.x11.primarySelectionString);
|
||||||
free(_glfw.x11.clipboardString);
|
_glfw_free(_glfw.x11.clipboardString);
|
||||||
|
|
||||||
XUnregisterIMInstantiateCallback(_glfw.x11.display,
|
XUnregisterIMInstantiateCallback(_glfw.x11.display,
|
||||||
NULL, NULL, NULL,
|
NULL, NULL, NULL,
|
||||||
@ -1480,10 +1484,8 @@ void _glfwPlatformTerminate(void)
|
|||||||
const char* _glfwPlatformGetVersionString(void)
|
const char* _glfwPlatformGetVersionString(void)
|
||||||
{
|
{
|
||||||
return _GLFW_VERSION_NUMBER " X11 GLX EGL OSMesa"
|
return _GLFW_VERSION_NUMBER " X11 GLX EGL OSMesa"
|
||||||
#if defined(_POSIX_TIMERS) && defined(_POSIX_MONOTONIC_CLOCK)
|
#if defined(_POSIX_MONOTONIC_CLOCK)
|
||||||
" clock_gettime"
|
" monotonic"
|
||||||
#else
|
|
||||||
" gettimeofday"
|
|
||||||
#endif
|
#endif
|
||||||
#if defined(__linux__)
|
#if defined(__linux__)
|
||||||
" evdev"
|
" evdev"
|
||||||
|
@ -116,7 +116,7 @@ void _glfwPollMonitorsX11(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*));
|
||||||
@ -209,7 +209,7 @@ void _glfwPollMonitorsX11(void)
|
|||||||
_glfwInputMonitor(disconnected[i], GLFW_DISCONNECTED, 0);
|
_glfwInputMonitor(disconnected[i], GLFW_DISCONNECTED, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
free(disconnected);
|
_glfw_free(disconnected);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -450,7 +450,7 @@ GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* count)
|
|||||||
XRRCrtcInfo* ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc);
|
XRRCrtcInfo* ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc);
|
||||||
XRROutputInfo* oi = XRRGetOutputInfo(_glfw.x11.display, sr, monitor->x11.output);
|
XRROutputInfo* oi = XRRGetOutputInfo(_glfw.x11.display, sr, monitor->x11.output);
|
||||||
|
|
||||||
result = calloc(oi->nmode, sizeof(GLFWvidmode));
|
result = _glfw_calloc(oi->nmode, sizeof(GLFWvidmode));
|
||||||
|
|
||||||
for (int i = 0; i < oi->nmode; i++)
|
for (int i = 0; i < oi->nmode; i++)
|
||||||
{
|
{
|
||||||
@ -482,7 +482,7 @@ GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* count)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
*count = 1;
|
*count = 1;
|
||||||
result = calloc(1, sizeof(GLFWvidmode));
|
result = _glfw_calloc(1, sizeof(GLFWvidmode));
|
||||||
_glfwPlatformGetVideoMode(monitor, result);
|
_glfwPlatformGetVideoMode(monitor, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -406,8 +406,8 @@ static char** parseUriList(char* text, int* count)
|
|||||||
|
|
||||||
(*count)++;
|
(*count)++;
|
||||||
|
|
||||||
char* path = calloc(strlen(line) + 1, 1);
|
char* path = _glfw_calloc(strlen(line) + 1, 1);
|
||||||
paths = realloc(paths, *count * sizeof(char*));
|
paths = _glfw_realloc(paths, *count * sizeof(char*));
|
||||||
paths[*count - 1] = path;
|
paths[*count - 1] = path;
|
||||||
|
|
||||||
while (*line)
|
while (*line)
|
||||||
@ -493,7 +493,7 @@ static char* convertLatin1toUTF8(const char* source)
|
|||||||
for (sp = source; *sp; sp++)
|
for (sp = source; *sp; sp++)
|
||||||
size += (*sp & 0x80) ? 2 : 1;
|
size += (*sp & 0x80) ? 2 : 1;
|
||||||
|
|
||||||
char* target = calloc(size, 1);
|
char* target = _glfw_calloc(size, 1);
|
||||||
char* tp = target;
|
char* tp = target;
|
||||||
|
|
||||||
for (sp = source; *sp; sp++)
|
for (sp = source; *sp; sp++)
|
||||||
@ -924,12 +924,12 @@ static void handleSelectionClear(XEvent* event)
|
|||||||
{
|
{
|
||||||
if (event->xselectionclear.selection == _glfw.x11.PRIMARY)
|
if (event->xselectionclear.selection == _glfw.x11.PRIMARY)
|
||||||
{
|
{
|
||||||
free(_glfw.x11.primarySelectionString);
|
_glfw_free(_glfw.x11.primarySelectionString);
|
||||||
_glfw.x11.primarySelectionString = NULL;
|
_glfw.x11.primarySelectionString = NULL;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
free(_glfw.x11.clipboardString);
|
_glfw_free(_glfw.x11.clipboardString);
|
||||||
_glfw.x11.clipboardString = NULL;
|
_glfw.x11.clipboardString = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -968,7 +968,7 @@ static const char* getSelectionString(Atom selection)
|
|||||||
return *selectionString;
|
return *selectionString;
|
||||||
}
|
}
|
||||||
|
|
||||||
free(*selectionString);
|
_glfw_free(*selectionString);
|
||||||
*selectionString = NULL;
|
*selectionString = NULL;
|
||||||
|
|
||||||
for (size_t i = 0; i < targetCount; i++)
|
for (size_t i = 0; i < targetCount; i++)
|
||||||
@ -1047,7 +1047,7 @@ static const char* getSelectionString(Atom selection)
|
|||||||
if (itemCount)
|
if (itemCount)
|
||||||
{
|
{
|
||||||
size += itemCount;
|
size += itemCount;
|
||||||
string = realloc(string, size);
|
string = _glfw_realloc(string, size);
|
||||||
string[size - itemCount - 1] = '\0';
|
string[size - itemCount - 1] = '\0';
|
||||||
strcat(string, data);
|
strcat(string, data);
|
||||||
}
|
}
|
||||||
@ -1057,7 +1057,7 @@ static const char* getSelectionString(Atom selection)
|
|||||||
if (targets[i] == XA_STRING)
|
if (targets[i] == XA_STRING)
|
||||||
{
|
{
|
||||||
*selectionString = convertLatin1toUTF8(string);
|
*selectionString = convertLatin1toUTF8(string);
|
||||||
free(string);
|
_glfw_free(string);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
*selectionString = string;
|
*selectionString = string;
|
||||||
@ -1293,7 +1293,7 @@ static void processEvent(XEvent *event)
|
|||||||
|
|
||||||
if (status == XBufferOverflow)
|
if (status == XBufferOverflow)
|
||||||
{
|
{
|
||||||
chars = calloc(count + 1, 1);
|
chars = _glfw_calloc(count + 1, 1);
|
||||||
count = Xutf8LookupString(window->x11.ic,
|
count = Xutf8LookupString(window->x11.ic,
|
||||||
&event->xkey,
|
&event->xkey,
|
||||||
chars, count,
|
chars, count,
|
||||||
@ -1309,7 +1309,7 @@ static void processEvent(XEvent *event)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (chars != buffer)
|
if (chars != buffer)
|
||||||
free(chars);
|
_glfw_free(chars);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1724,8 +1724,8 @@ static void processEvent(XEvent *event)
|
|||||||
_glfwInputDrop(window, count, (const char**) paths);
|
_glfwInputDrop(window, count, (const char**) paths);
|
||||||
|
|
||||||
for (i = 0; i < count; i++)
|
for (i = 0; i < count; i++)
|
||||||
free(paths[i]);
|
_glfw_free(paths[i]);
|
||||||
free(paths);
|
_glfw_free(paths);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data)
|
if (data)
|
||||||
@ -2108,7 +2108,7 @@ void _glfwPlatformSetWindowIcon(_GLFWwindow* window,
|
|||||||
for (i = 0; i < count; i++)
|
for (i = 0; i < count; i++)
|
||||||
longCount += 2 + images[i].width * images[i].height;
|
longCount += 2 + images[i].width * images[i].height;
|
||||||
|
|
||||||
long* icon = calloc(longCount, sizeof(long));
|
long* icon = _glfw_calloc(longCount, sizeof(long));
|
||||||
long* target = icon;
|
long* target = icon;
|
||||||
|
|
||||||
for (i = 0; i < count; i++)
|
for (i = 0; i < count; i++)
|
||||||
@ -2132,7 +2132,7 @@ void _glfwPlatformSetWindowIcon(_GLFWwindow* window,
|
|||||||
(unsigned char*) icon,
|
(unsigned char*) icon,
|
||||||
longCount);
|
longCount);
|
||||||
|
|
||||||
free(icon);
|
_glfw_free(icon);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -2671,14 +2671,14 @@ void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i < count)
|
if (i == count)
|
||||||
return;
|
{
|
||||||
|
XChangeProperty(_glfw.x11.display, window->x11.handle,
|
||||||
XChangeProperty(_glfw.x11.display, window->x11.handle,
|
_glfw.x11.NET_WM_STATE, XA_ATOM, 32,
|
||||||
_glfw.x11.NET_WM_STATE, XA_ATOM, 32,
|
PropModeAppend,
|
||||||
PropModeAppend,
|
(unsigned char*) &_glfw.x11.NET_WM_STATE_ABOVE,
|
||||||
(unsigned char*) &_glfw.x11.NET_WM_STATE_ABOVE,
|
1);
|
||||||
1);
|
}
|
||||||
}
|
}
|
||||||
else if (states)
|
else if (states)
|
||||||
{
|
{
|
||||||
@ -2688,15 +2688,15 @@ void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i == count)
|
if (i < count)
|
||||||
return;
|
{
|
||||||
|
states[i] = states[count - 1];
|
||||||
|
count--;
|
||||||
|
|
||||||
states[i] = states[count - 1];
|
XChangeProperty(_glfw.x11.display, window->x11.handle,
|
||||||
count--;
|
_glfw.x11.NET_WM_STATE, XA_ATOM, 32,
|
||||||
|
PropModeReplace, (unsigned char*) states, count);
|
||||||
XChangeProperty(_glfw.x11.display, window->x11.handle,
|
}
|
||||||
_glfw.x11.NET_WM_STATE, XA_ATOM, 32,
|
|
||||||
PropModeReplace, (unsigned char*) states, count);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (states)
|
if (states)
|
||||||
@ -2891,7 +2891,7 @@ const char* _glfwPlatformGetScancodeName(int scancode)
|
|||||||
if (scancode < 0 || scancode > 0xff ||
|
if (scancode < 0 || scancode > 0xff ||
|
||||||
_glfw.x11.keycodes[scancode] == GLFW_KEY_UNKNOWN)
|
_glfw.x11.keycodes[scancode] == GLFW_KEY_UNKNOWN)
|
||||||
{
|
{
|
||||||
_glfwInputError(GLFW_INVALID_VALUE, "Invalid scancode");
|
_glfwInputError(GLFW_INVALID_VALUE, "Invalid scancode %i", scancode);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3045,7 +3045,7 @@ void _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor)
|
|||||||
void _glfwPlatformSetClipboardString(const char* string)
|
void _glfwPlatformSetClipboardString(const char* string)
|
||||||
{
|
{
|
||||||
char* copy = _glfw_strdup(string);
|
char* copy = _glfw_strdup(string);
|
||||||
free(_glfw.x11.clipboardString);
|
_glfw_free(_glfw.x11.clipboardString);
|
||||||
_glfw.x11.clipboardString = copy;
|
_glfw.x11.clipboardString = copy;
|
||||||
|
|
||||||
XSetSelectionOwner(_glfw.x11.display,
|
XSetSelectionOwner(_glfw.x11.display,
|
||||||
@ -3086,7 +3086,7 @@ EGLenum _glfwPlatformGetEGLPlatform(EGLint** attribs)
|
|||||||
|
|
||||||
if (type)
|
if (type)
|
||||||
{
|
{
|
||||||
*attribs = calloc(5, sizeof(EGLint));
|
*attribs = _glfw_calloc(5, 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_PLATFORM_ANGLE_NATIVE_PLATFORM_TYPE_ANGLE;
|
(*attribs)[2] = EGL_PLATFORM_ANGLE_NATIVE_PLATFORM_TYPE_ANGLE;
|
||||||
@ -3304,7 +3304,7 @@ GLFWAPI void glfwSetX11SelectionString(const char* string)
|
|||||||
{
|
{
|
||||||
_GLFW_REQUIRE_INIT();
|
_GLFW_REQUIRE_INIT();
|
||||||
|
|
||||||
free(_glfw.x11.primarySelectionString);
|
_glfw_free(_glfw.x11.primarySelectionString);
|
||||||
_glfw.x11.primarySelectionString = _glfw_strdup(string);
|
_glfw.x11.primarySelectionString = _glfw_strdup(string);
|
||||||
|
|
||||||
XSetSelectionOwner(_glfw.x11.display,
|
XSetSelectionOwner(_glfw.x11.display,
|
||||||
|
@ -7,19 +7,19 @@ if (MATH_LIBRARY)
|
|||||||
link_libraries("${MATH_LIBRARY}")
|
link_libraries("${MATH_LIBRARY}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (MSVC)
|
# Workaround for the MS CRT deprecating parts of the standard library
|
||||||
|
if (MSVC OR CMAKE_C_SIMULATE_ID STREQUAL "MSVC")
|
||||||
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
|
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
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_VULKAN "${GLFW_SOURCE_DIR}/deps/glad/vulkan.h")
|
||||||
set(GLAD_VULKAN "${GLFW_SOURCE_DIR}/deps/glad/vulkan.h"
|
|
||||||
"${GLFW_SOURCE_DIR}/deps/glad_vulkan.c")
|
|
||||||
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"
|
||||||
"${GLFW_SOURCE_DIR}/deps/tinycthread.c")
|
"${GLFW_SOURCE_DIR}/deps/tinycthread.c")
|
||||||
|
|
||||||
|
add_executable(allocator allocator.c ${GLAD_GL})
|
||||||
add_executable(clipboard clipboard.c ${GETOPT} ${GLAD_GL})
|
add_executable(clipboard clipboard.c ${GETOPT} ${GLAD_GL})
|
||||||
add_executable(events events.c ${GETOPT} ${GLAD_GL})
|
add_executable(events events.c ${GETOPT} ${GLAD_GL})
|
||||||
add_executable(msaa msaa.c ${GETOPT} ${GLAD_GL})
|
add_executable(msaa msaa.c ${GETOPT} ${GLAD_GL})
|
||||||
@ -51,17 +51,21 @@ endif()
|
|||||||
|
|
||||||
set(GUI_ONLY_BINARIES empty gamma icon inputlag joysticks tearing threads
|
set(GUI_ONLY_BINARIES empty gamma icon inputlag joysticks tearing threads
|
||||||
timeout title triangle-vulkan window)
|
timeout title triangle-vulkan window)
|
||||||
set(CONSOLE_BINARIES clipboard events msaa glfwinfo iconify monitors reopen
|
set(CONSOLE_BINARIES allocator clipboard events msaa glfwinfo iconify monitors
|
||||||
cursor usercontext)
|
reopen cursor usercontext)
|
||||||
|
|
||||||
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/Tests")
|
FOLDER "GLFW3/Tests")
|
||||||
|
|
||||||
if (MSVC)
|
if (MSVC)
|
||||||
# Tell MSVC to use main instead of WinMain for Windows subsystem executables
|
# Tell MSVC to use main instead of WinMain
|
||||||
set_target_properties(${GUI_ONLY_BINARIES} PROPERTIES
|
set_target_properties(${GUI_ONLY_BINARIES} PROPERTIES
|
||||||
LINK_FLAGS "/ENTRY:mainCRTStartup")
|
LINK_FLAGS "/ENTRY:mainCRTStartup")
|
||||||
|
elseif (CMAKE_C_SIMULATE_ID STREQUAL "MSVC")
|
||||||
|
# Tell Clang using MS CRT to use main instead of WinMain
|
||||||
|
set_target_properties(${GUI_ONLY_BINARIES} PROPERTIES
|
||||||
|
LINK_FLAGS "-Wl,/entry:mainCRTStartup")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (APPLE)
|
if (APPLE)
|
||||||
|
142
tests/allocator.c
Normal file
142
tests/allocator.c
Normal file
@ -0,0 +1,142 @@
|
|||||||
|
//========================================================================
|
||||||
|
// Custom heap allocator test
|
||||||
|
// 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_GL_IMPLEMENTATION
|
||||||
|
#include <glad/gl.h>
|
||||||
|
#define GLFW_INCLUDE_NONE
|
||||||
|
#include <GLFW/glfw3.h>
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
#define CALL(x) (function_name = #x, x)
|
||||||
|
static const char* function_name = NULL;
|
||||||
|
|
||||||
|
struct allocator_stats
|
||||||
|
{
|
||||||
|
size_t total;
|
||||||
|
size_t current;
|
||||||
|
size_t maximum;
|
||||||
|
};
|
||||||
|
|
||||||
|
static void error_callback(int error, const char* description)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Error: %s\n", description);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void* allocate(size_t size, void* user)
|
||||||
|
{
|
||||||
|
struct allocator_stats* stats = user;
|
||||||
|
assert(size > 0);
|
||||||
|
|
||||||
|
stats->total += size;
|
||||||
|
stats->current += size;
|
||||||
|
if (stats->current > stats->maximum)
|
||||||
|
stats->maximum = stats->current;
|
||||||
|
|
||||||
|
printf("%s: allocate %zu bytes (current %zu maximum %zu total %zu)\n",
|
||||||
|
function_name, size, stats->current, stats->maximum, stats->total);
|
||||||
|
|
||||||
|
size_t* real_block = malloc(size + sizeof(size_t));
|
||||||
|
assert(real_block != NULL);
|
||||||
|
*real_block = size;
|
||||||
|
return real_block + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void deallocate(void* block, void* user)
|
||||||
|
{
|
||||||
|
struct allocator_stats* stats = user;
|
||||||
|
assert(block != NULL);
|
||||||
|
|
||||||
|
size_t* real_block = (size_t*) block - 1;
|
||||||
|
stats->current -= *real_block;
|
||||||
|
|
||||||
|
printf("%s: deallocate %zu bytes (current %zu maximum %zu total %zu)\n",
|
||||||
|
function_name, *real_block, stats->current, stats->maximum, stats->total);
|
||||||
|
|
||||||
|
free(real_block);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void* reallocate(void* block, size_t size, void* user)
|
||||||
|
{
|
||||||
|
struct allocator_stats* stats = user;
|
||||||
|
assert(block != NULL);
|
||||||
|
assert(size > 0);
|
||||||
|
|
||||||
|
size_t* real_block = (size_t*) block - 1;
|
||||||
|
stats->total += size;
|
||||||
|
stats->current += size - *real_block;
|
||||||
|
if (stats->current > stats->maximum)
|
||||||
|
stats->maximum = stats->current;
|
||||||
|
|
||||||
|
printf("%s: reallocate %zu bytes to %zu bytes (current %zu maximum %zu total %zu)\n",
|
||||||
|
function_name, *real_block, size, stats->current, stats->maximum, stats->total);
|
||||||
|
|
||||||
|
real_block = realloc(real_block, size + sizeof(size_t));
|
||||||
|
assert(real_block != NULL);
|
||||||
|
*real_block = size;
|
||||||
|
return real_block + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
struct allocator_stats stats = {0};
|
||||||
|
const GLFWallocator allocator =
|
||||||
|
{
|
||||||
|
.allocate = allocate,
|
||||||
|
.deallocate = deallocate,
|
||||||
|
.reallocate = reallocate,
|
||||||
|
.user = &stats
|
||||||
|
};
|
||||||
|
|
||||||
|
glfwSetErrorCallback(error_callback);
|
||||||
|
glfwInitAllocator(&allocator);
|
||||||
|
|
||||||
|
if (!CALL(glfwInit)())
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
|
||||||
|
GLFWwindow* window = CALL(glfwCreateWindow)(400, 400, "Custom allocator test", NULL, NULL);
|
||||||
|
if (!window)
|
||||||
|
{
|
||||||
|
glfwTerminate();
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
CALL(glfwMakeContextCurrent)(window);
|
||||||
|
gladLoadGL(glfwGetProcAddress);
|
||||||
|
CALL(glfwSwapInterval)(1);
|
||||||
|
|
||||||
|
while (!CALL(glfwWindowShouldClose)(window))
|
||||||
|
{
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
CALL(glfwSwapBuffers)(window);
|
||||||
|
CALL(glfwWaitEvents)();
|
||||||
|
}
|
||||||
|
|
||||||
|
CALL(glfwTerminate)();
|
||||||
|
exit(EXIT_SUCCESS);
|
||||||
|
}
|
||||||
|
|
@ -27,6 +27,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>
|
||||||
|
@ -30,6 +30,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>
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
|
|
||||||
#include "tinycthread.h"
|
#include "tinycthread.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 @@
|
|||||||
//
|
//
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
|
#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>
|
||||||
|
@ -28,6 +28,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>
|
||||||
|
@ -23,7 +23,9 @@
|
|||||||
//
|
//
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
|
#define GLAD_GL_IMPLEMENTATION
|
||||||
#include <glad/gl.h>
|
#include <glad/gl.h>
|
||||||
|
#define GLAD_VULKAN_IMPLEMENTATION
|
||||||
#include <glad/vulkan.h>
|
#include <glad/vulkan.h>
|
||||||
#define GLFW_INCLUDE_NONE
|
#define GLFW_INCLUDE_NONE
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
@ -116,6 +118,7 @@ static void usage(void)
|
|||||||
ANGLE_TYPE_VULKAN " or "
|
ANGLE_TYPE_VULKAN " or "
|
||||||
ANGLE_TYPE_METAL ")\n");
|
ANGLE_TYPE_METAL ")\n");
|
||||||
printf(" --graphics-switching request macOS graphics switching\n");
|
printf(" --graphics-switching request macOS graphics switching\n");
|
||||||
|
printf(" --disable-xcb-surface disable VK_KHR_xcb_surface extension\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void error_callback(int error, const char* description)
|
static void error_callback(int error, const char* description)
|
||||||
@ -322,11 +325,6 @@ static void print_version(void)
|
|||||||
printf("GLFW library version string: \"%s\"\n", glfwGetVersionString());
|
printf("GLFW library version string: \"%s\"\n", glfwGetVersionString());
|
||||||
}
|
}
|
||||||
|
|
||||||
static GLADapiproc glad_vulkan_callback(const char* name, void* user)
|
|
||||||
{
|
|
||||||
return glfwGetInstanceProcAddress((VkInstance) user, name);
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
int ch;
|
int ch;
|
||||||
@ -360,6 +358,7 @@ int main(int argc, char** argv)
|
|||||||
bool fb_doublebuffer = true;
|
bool fb_doublebuffer = true;
|
||||||
int angle_type = GLFW_ANGLE_PLATFORM_TYPE_NONE;
|
int angle_type = GLFW_ANGLE_PLATFORM_TYPE_NONE;
|
||||||
bool cocoa_graphics_switching = false;
|
bool cocoa_graphics_switching = false;
|
||||||
|
bool disable_xcb_surface = false;
|
||||||
|
|
||||||
enum { CLIENT, CONTEXT, BEHAVIOR, DEBUG_CONTEXT, FORWARD, HELP,
|
enum { CLIENT, CONTEXT, BEHAVIOR, DEBUG_CONTEXT, FORWARD, HELP,
|
||||||
EXTENSIONS, LAYERS,
|
EXTENSIONS, LAYERS,
|
||||||
@ -367,7 +366,7 @@ int main(int argc, char** argv)
|
|||||||
REDBITS, GREENBITS, BLUEBITS, ALPHABITS, DEPTHBITS, STENCILBITS,
|
REDBITS, GREENBITS, BLUEBITS, ALPHABITS, DEPTHBITS, STENCILBITS,
|
||||||
ACCUMREDBITS, ACCUMGREENBITS, ACCUMBLUEBITS, ACCUMALPHABITS,
|
ACCUMREDBITS, ACCUMGREENBITS, ACCUMBLUEBITS, ACCUMALPHABITS,
|
||||||
AUXBUFFERS, SAMPLES, STEREO, SRGB, SINGLEBUFFER, NOERROR_SRSLY,
|
AUXBUFFERS, SAMPLES, STEREO, SRGB, SINGLEBUFFER, NOERROR_SRSLY,
|
||||||
ANGLE_TYPE, GRAPHICS_SWITCHING };
|
ANGLE_TYPE, GRAPHICS_SWITCHING, XCB_SURFACE };
|
||||||
const struct option options[] =
|
const struct option options[] =
|
||||||
{
|
{
|
||||||
{ "behavior", 1, NULL, BEHAVIOR },
|
{ "behavior", 1, NULL, BEHAVIOR },
|
||||||
@ -401,6 +400,7 @@ int main(int argc, char** argv)
|
|||||||
{ "no-error", 0, NULL, NOERROR_SRSLY },
|
{ "no-error", 0, NULL, NOERROR_SRSLY },
|
||||||
{ "angle-type", 1, NULL, ANGLE_TYPE },
|
{ "angle-type", 1, NULL, ANGLE_TYPE },
|
||||||
{ "graphics-switching", 0, NULL, GRAPHICS_SWITCHING },
|
{ "graphics-switching", 0, NULL, GRAPHICS_SWITCHING },
|
||||||
|
{ "vk-xcb-surface", 0, NULL, XCB_SURFACE },
|
||||||
{ NULL, 0, NULL, 0 }
|
{ NULL, 0, NULL, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -607,6 +607,9 @@ int main(int argc, char** argv)
|
|||||||
case GRAPHICS_SWITCHING:
|
case GRAPHICS_SWITCHING:
|
||||||
cocoa_graphics_switching = true;
|
cocoa_graphics_switching = true;
|
||||||
break;
|
break;
|
||||||
|
case XCB_SURFACE:
|
||||||
|
disable_xcb_surface = true;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
usage();
|
usage();
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
@ -623,6 +626,7 @@ int main(int argc, char** argv)
|
|||||||
glfwInitHint(GLFW_COCOA_MENUBAR, false);
|
glfwInitHint(GLFW_COCOA_MENUBAR, false);
|
||||||
|
|
||||||
glfwInitHint(GLFW_ANGLE_PLATFORM_TYPE, angle_type);
|
glfwInitHint(GLFW_ANGLE_PLATFORM_TYPE, angle_type);
|
||||||
|
glfwInitHint(GLFW_X11_XCB_VULKAN_SURFACE, !disable_xcb_surface);
|
||||||
|
|
||||||
if (!glfwInit())
|
if (!glfwInit())
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
@ -843,12 +847,23 @@ int main(int argc, char** argv)
|
|||||||
if (list_extensions)
|
if (list_extensions)
|
||||||
list_context_extensions(client, major, minor);
|
list_context_extensions(client, major, minor);
|
||||||
|
|
||||||
|
glfwDestroyWindow(window);
|
||||||
|
|
||||||
|
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
|
||||||
|
|
||||||
|
window = glfwCreateWindow(200, 200, "Version", NULL, NULL);
|
||||||
|
if (!window)
|
||||||
|
{
|
||||||
|
glfwTerminate();
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
printf("Vulkan loader: %s\n",
|
printf("Vulkan loader: %s\n",
|
||||||
glfwVulkanSupported() ? "available" : "missing");
|
glfwVulkanSupported() ? "available" : "missing");
|
||||||
|
|
||||||
if (glfwVulkanSupported())
|
if (glfwVulkanSupported())
|
||||||
{
|
{
|
||||||
gladLoadVulkanUserPtr(NULL, glad_vulkan_callback, NULL);
|
gladLoadVulkanUserPtr(NULL, (GLADuserptrloadfunc) glfwGetInstanceProcAddress, NULL);
|
||||||
|
|
||||||
uint32_t loader_version = VK_API_VERSION_1_0;
|
uint32_t loader_version = VK_API_VERSION_1_0;
|
||||||
|
|
||||||
@ -866,15 +881,14 @@ int main(int argc, char** argv)
|
|||||||
uint32_t re_count;
|
uint32_t re_count;
|
||||||
const char** re = glfwGetRequiredInstanceExtensions(&re_count);
|
const char** re = glfwGetRequiredInstanceExtensions(&re_count);
|
||||||
|
|
||||||
printf("Vulkan required instance extensions:");
|
|
||||||
if (re)
|
if (re)
|
||||||
{
|
{
|
||||||
|
printf("Vulkan window surface required instance extensions:\n");
|
||||||
for (uint32_t i = 0; i < re_count; i++)
|
for (uint32_t i = 0; i < re_count; i++)
|
||||||
printf(" %s", re[i]);
|
printf(" %s\n", re[i]);
|
||||||
putchar('\n');
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
printf(" missing\n");
|
printf("Vulkan window surface extensions missing\n");
|
||||||
|
|
||||||
if (list_extensions)
|
if (list_extensions)
|
||||||
list_vulkan_instance_extensions();
|
list_vulkan_instance_extensions();
|
||||||
@ -906,7 +920,20 @@ int main(int argc, char** argv)
|
|||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
gladLoadVulkanUserPtr(NULL, glad_vulkan_callback, instance);
|
gladLoadVulkanUserPtr(NULL, (GLADuserptrloadfunc) glfwGetInstanceProcAddress, instance);
|
||||||
|
|
||||||
|
if (re)
|
||||||
|
{
|
||||||
|
VkSurfaceKHR surface = VK_NULL_HANDLE;
|
||||||
|
|
||||||
|
if (glfwCreateWindowSurface(instance, window, NULL, &surface) == VK_SUCCESS)
|
||||||
|
{
|
||||||
|
printf("Vulkan window surface created successfully\n");
|
||||||
|
vkDestroySurfaceKHR(instance, surface, NULL);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
printf("Failed to create Vulkan window surface\n");
|
||||||
|
}
|
||||||
|
|
||||||
uint32_t pd_count;
|
uint32_t pd_count;
|
||||||
vkEnumeratePhysicalDevices(instance, &pd_count, NULL);
|
vkEnumeratePhysicalDevices(instance, &pd_count, NULL);
|
||||||
@ -916,7 +943,6 @@ int main(int argc, char** argv)
|
|||||||
for (uint32_t i = 0; i < pd_count; i++)
|
for (uint32_t i = 0; i < pd_count; i++)
|
||||||
{
|
{
|
||||||
VkPhysicalDeviceProperties pdp;
|
VkPhysicalDeviceProperties pdp;
|
||||||
|
|
||||||
vkGetPhysicalDeviceProperties(pd[i], &pdp);
|
vkGetPhysicalDeviceProperties(pd[i], &pdp);
|
||||||
|
|
||||||
printf("Vulkan %s device: \"%s\" (API version %i.%i)\n",
|
printf("Vulkan %s device: \"%s\" (API version %i.%i)\n",
|
||||||
@ -925,6 +951,19 @@ int main(int argc, char** argv)
|
|||||||
VK_VERSION_MAJOR(pdp.apiVersion),
|
VK_VERSION_MAJOR(pdp.apiVersion),
|
||||||
VK_VERSION_MINOR(pdp.apiVersion));
|
VK_VERSION_MINOR(pdp.apiVersion));
|
||||||
|
|
||||||
|
uint32_t qfp_count;
|
||||||
|
vkGetPhysicalDeviceQueueFamilyProperties(pd[i], &qfp_count, NULL);
|
||||||
|
|
||||||
|
printf("Vulkan device queue family presentation support:\n");
|
||||||
|
for (uint32_t j = 0; j < qfp_count; j++)
|
||||||
|
{
|
||||||
|
printf(" %u: ", j);
|
||||||
|
if (glfwGetPhysicalDevicePresentationSupport(instance, pd[i], j))
|
||||||
|
printf("supported\n");
|
||||||
|
else
|
||||||
|
printf("no\n");
|
||||||
|
}
|
||||||
|
|
||||||
if (list_extensions)
|
if (list_extensions)
|
||||||
list_vulkan_device_extensions(instance, pd[i]);
|
list_vulkan_device_extensions(instance, pd[i]);
|
||||||
|
|
||||||
@ -936,6 +975,8 @@ int main(int argc, char** argv)
|
|||||||
vkDestroyInstance(instance, NULL);
|
vkDestroyInstance(instance, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
glfwDestroyWindow(window);
|
||||||
|
|
||||||
glfwTerminate();
|
glfwTerminate();
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,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>
|
||||||
|
@ -28,6 +28,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>
|
||||||
|
@ -28,6 +28,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>
|
||||||
|
@ -28,6 +28,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>
|
||||||
|
@ -28,6 +28,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>
|
||||||
|
@ -29,6 +29,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>
|
||||||
|
@ -33,6 +33,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>
|
||||||
|
@ -28,6 +28,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>
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
|
|
||||||
#include "tinycthread.h"
|
#include "tinycthread.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>
|
||||||
|
@ -27,6 +27,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>
|
||||||
|
@ -27,6 +27,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>
|
||||||
|
@ -41,6 +41,7 @@
|
|||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define GLAD_VULKAN_IMPLEMENTATION
|
||||||
#include <glad/vulkan.h>
|
#include <glad/vulkan.h>
|
||||||
#define GLFW_INCLUDE_NONE
|
#define GLFW_INCLUDE_NONE
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
@ -65,11 +66,6 @@
|
|||||||
exit(1); \
|
exit(1); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
static GLADapiproc glad_vulkan_callback(const char* name, void* user)
|
|
||||||
{
|
|
||||||
return glfwGetInstanceProcAddress((VkInstance) user, name);
|
|
||||||
}
|
|
||||||
|
|
||||||
static const uint32_t fragShaderCode[] = {
|
static const uint32_t fragShaderCode[] = {
|
||||||
0x07230203,0x00010000,0x00080007,0x00000014,0x00000000,0x00020011,0x00000001,0x0006000b,
|
0x07230203,0x00010000,0x00080007,0x00000014,0x00000000,0x00020011,0x00000001,0x0006000b,
|
||||||
0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001,
|
0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001,
|
||||||
@ -1251,7 +1247,7 @@ static void demo_prepare_pipeline(struct demo *demo) {
|
|||||||
VkPipelineDepthStencilStateCreateInfo ds;
|
VkPipelineDepthStencilStateCreateInfo ds;
|
||||||
VkPipelineViewportStateCreateInfo vp;
|
VkPipelineViewportStateCreateInfo vp;
|
||||||
VkPipelineMultisampleStateCreateInfo ms;
|
VkPipelineMultisampleStateCreateInfo ms;
|
||||||
VkDynamicState dynamicStateEnables[VK_DYNAMIC_STATE_RANGE_SIZE];
|
VkDynamicState dynamicStateEnables[(VK_DYNAMIC_STATE_STENCIL_REFERENCE - VK_DYNAMIC_STATE_VIEWPORT + 1)];
|
||||||
VkPipelineDynamicStateCreateInfo dynamicState;
|
VkPipelineDynamicStateCreateInfo dynamicState;
|
||||||
|
|
||||||
VkResult U_ASSERT_ONLY err;
|
VkResult U_ASSERT_ONLY err;
|
||||||
@ -1715,7 +1711,7 @@ static void demo_init_vk(struct demo *demo) {
|
|||||||
"vkCreateInstance Failure");
|
"vkCreateInstance Failure");
|
||||||
}
|
}
|
||||||
|
|
||||||
gladLoadVulkanUserPtr(NULL, glad_vulkan_callback, demo->inst);
|
gladLoadVulkanUserPtr(NULL, (GLADuserptrloadfunc) glfwGetInstanceProcAddress, demo->inst);
|
||||||
|
|
||||||
/* Make initial call to query gpu_count, then second call for gpu info*/
|
/* Make initial call to query gpu_count, then second call for gpu info*/
|
||||||
err = vkEnumeratePhysicalDevices(demo->inst, &gpu_count, NULL);
|
err = vkEnumeratePhysicalDevices(demo->inst, &gpu_count, NULL);
|
||||||
@ -1738,7 +1734,7 @@ static void demo_init_vk(struct demo *demo) {
|
|||||||
"vkEnumeratePhysicalDevices Failure");
|
"vkEnumeratePhysicalDevices Failure");
|
||||||
}
|
}
|
||||||
|
|
||||||
gladLoadVulkanUserPtr(demo->gpu, glad_vulkan_callback, demo->inst);
|
gladLoadVulkanUserPtr(demo->gpu, (GLADuserptrloadfunc) glfwGetInstanceProcAddress, demo->inst);
|
||||||
|
|
||||||
/* Look for device extensions */
|
/* Look for device extensions */
|
||||||
uint32_t device_extension_count = 0;
|
uint32_t device_extension_count = 0;
|
||||||
@ -1966,7 +1962,7 @@ static void demo_init_connection(struct demo *demo) {
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
gladLoadVulkanUserPtr(NULL, glad_vulkan_callback, NULL);
|
gladLoadVulkanUserPtr(NULL, (GLADuserptrloadfunc) glfwGetInstanceProcAddress, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void demo_init(struct demo *demo, const int argc, const char *argv[])
|
static void demo_init(struct demo *demo, const int argc, const char *argv[])
|
||||||
|
@ -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>
|
||||||
|
Loading…
Reference in New Issue
Block a user