[upstream_utils] Add imgui and friends (#6822)

This commit is contained in:
PJ Reiniger
2024-07-21 01:11:54 -04:00
committed by GitHub
parent 8548d83b03
commit 6922b9dd5e
157 changed files with 149208 additions and 165 deletions

View File

@@ -36,6 +36,10 @@ jobs:
run: ./wpilibj/generate_hids.py && ./wpilibc/generate_hids.py && ./wpilibNewCommands/generate_hids.py
- name: Run PWM Controllers
run: ./wpilibj/generate_pwm_motor_controllers.py && ./wpilibc/generate_pwm_motor_controllers.py
- name: Run imgui gl3w
run: ./thirdparty/imgui_suite/generate_gl3w.py
- name: Run imgui fonts
run: ./thirdparty/imgui_suite/generate_fonts.sh
- name: Add untracked files to index so they count as changes
run: git add -A
- name: Check output

View File

@@ -45,11 +45,31 @@ jobs:
cd upstream_utils
./gcem.py clone
./gcem.py copy-upstream-to-thirdparty
- name: Run gl3w.py
run: |
cd upstream_utils
./gl3w.py clone
./gl3w.py copy-upstream-to-thirdparty
- name: Run glfw.py
run: |
cd upstream_utils
./glfw.py clone
./glfw.py copy-upstream-to-thirdparty
- name: Run googletest.py
run: |
cd upstream_utils
./googletest.py clone
./googletest.py copy-upstream-to-thirdparty
- name: Run imgui.py
run: |
cd upstream_utils
./imgui.py clone
./imgui.py copy-upstream-to-thirdparty
- name: Run implot.py
run: |
cd upstream_utils
./implot.py clone
./implot.py copy-upstream-to-thirdparty
- name: Run json.py
run: |
cd upstream_utils
@@ -90,6 +110,11 @@ jobs:
cd upstream_utils
./sleipnir.py clone
./sleipnir.py copy-upstream-to-thirdparty
- name: Run stb.py
run: |
cd upstream_utils
./stb.py clone
./stb.py copy-upstream-to-thirdparty
- name: Add untracked files to index so they count as changes
run: git add -A
- name: Check output

View File

@@ -287,7 +287,7 @@ endif()
if(WITH_GUI)
add_subdirectory(fieldImages)
add_subdirectory(imgui)
add_subdirectory(thirdparty/imgui_suite)
add_subdirectory(wpigui)
add_subdirectory(glass)
add_subdirectory(outlineviewer)

View File

@@ -186,8 +186,6 @@ nativeUtils.exportsConfigs {
}
}
apply from: "${rootDir}/shared/imgui.gradle"
model {
components {
examplesMap.each { key, value ->
@@ -200,7 +198,7 @@ model {
lib project: ':wpinet', library: 'wpinet', linkage: 'shared'
lib project: ':wpigui', library: 'wpigui', linkage: 'static'
lib library: 'cscore', linkage: 'shared'
nativeUtils.useRequiredLibrary(it, 'imgui')
lib project: ':thirdparty:imgui_suite', library: 'imgui', linkage: 'static'
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio) {
it.buildable = false
return

View File

@@ -25,7 +25,6 @@ def wpilibVersionFileInput = file("src/main/generate/WPILibVersion.cpp.in")
def wpilibVersionFileOutput = file("$buildDir/generated/main/cpp/WPILibVersion.cpp")
apply from: "${rootDir}/shared/libssh.gradle"
apply from: "${rootDir}/shared/imgui.gradle"
task generateCppVersion() {
description = 'Generates the wpilib version class'
@@ -102,7 +101,8 @@ model {
lib project: ':glass', library: 'glass', linkage: 'static'
lib project: ':wpiutil', library: 'wpiutil', linkage: 'static'
lib project: ':wpigui', library: 'wpigui', linkage: 'static'
nativeUtils.useRequiredLibrary(it, 'imgui', 'libssh')
lib project: ':thirdparty:imgui_suite', library: 'imgui', linkage: 'static'
nativeUtils.useRequiredLibrary(it, 'libssh')
if (it.targetPlatform.operatingSystem.isWindows()) {
it.linker.args << 'Gdi32.lib' << 'Shell32.lib' << 'd3d11.lib' << 'd3dcompiler.lib'
it.linker.args << 'ws2_32.lib' << 'advapi32.lib' << 'crypt32.lib' << 'user32.lib'

View File

@@ -24,8 +24,6 @@ apply from: "${rootDir}/shared/config.gradle"
def wpilibVersionFileInput = file("src/app/generate/WPILibVersion.cpp.in")
def wpilibVersionFileOutput = file("$buildDir/generated/app/cpp/WPILibVersion.cpp")
apply from: "${rootDir}/shared/imgui.gradle"
task generateCppVersion() {
description = 'Generates the wpilib version class'
group = 'WPILib'
@@ -112,7 +110,7 @@ model {
lib project: ':wpimath', library: 'wpimath', linkage: 'shared'
lib project: ':wpigui', library: 'wpigui', linkage: 'static'
lib project: ':fieldImages', library: 'fieldImages', linkage: 'shared'
nativeUtils.useRequiredLibrary(it, 'imgui')
lib project: ':thirdparty:imgui_suite', library: 'imgui', linkage: 'static'
}
appendDebugPathToBinaries(binaries)
}
@@ -142,7 +140,7 @@ model {
lib project: ':wpimath', library: 'wpimath', linkage: 'shared'
lib project: ':wpigui', library: 'wpigui', linkage: 'static'
lib project: ':fieldImages', library: 'fieldImages', linkage: 'shared'
nativeUtils.useRequiredLibrary(it, 'imgui')
lib project: ':thirdparty:imgui_suite', library: 'imgui', linkage: 'static'
}
appendDebugPathToBinaries(binaries)
}
@@ -181,7 +179,7 @@ model {
lib project: ':wpigui', library: 'wpigui', linkage: 'static'
lib project: ':fieldImages', library: 'fieldImages', linkage: 'static'
nativeUtils.useRequiredLibrary(it, 'opencv_static')
nativeUtils.useRequiredLibrary(it, 'imgui')
lib project: ':thirdparty:imgui_suite', library: 'imgui', linkage: 'static'
if (it.targetPlatform.operatingSystem.isWindows()) {
it.linker.args << 'Gdi32.lib' << 'Shell32.lib' << 'd3d11.lib' << 'd3dcompiler.lib'
it.linker.args << '/DELAYLOAD:MF.dll' << '/DELAYLOAD:MFReadWrite.dll' << '/DELAYLOAD:MFPlat.dll' << '/delay:nobind'

View File

@@ -1,8 +0,0 @@
cppHeaderFileInclude {
\.h$
\.inc$
}
cppSrcFileInclude {
\.cpp$
}

View File

@@ -1,111 +0,0 @@
include(FetchContent)
include(LinkMacOSGUI)
fetchcontent_declare(
glfw3
GIT_REPOSITORY https://github.com/glfw/glfw.git
GIT_TAG 6b57e08bb0078c9834889eab871bac2368198c15
)
fetchcontent_declare(
gl3w
GIT_REPOSITORY https://github.com/skaslev/gl3w
GIT_TAG 5f8d7fd191ba22ff2b60c1106d7135bb9a335533
)
fetchcontent_declare(
imgui
GIT_REPOSITORY https://github.com/ocornut/imgui.git
# docking branch
GIT_TAG 64b1e448d20c9be9275af731c34b4c7bf14a8e95
)
fetchcontent_declare(
implot
GIT_REPOSITORY https://github.com/epezent/implot.git
# v0.16
GIT_TAG 18c72431f8265e2b0b5378a3a73d8a883b2175ff
)
fetchcontent_declare(
fonts
URL https://github.com/wpilibsuite/thirdparty-fonts/releases/download/v0.2/fonts.zip
URL_HASH SHA256=cedf365657fab0770e11f72d49e4f0f889f564d2e635a4d214029d0ab6bcd324
)
fetchcontent_declare(
stb
GIT_REPOSITORY https://github.com/nothings/stb.git
GIT_TAG c9064e317699d2e495f36ba4f9ac037e88ee371a
)
fetchcontent_makeavailable(imgui implot fonts stb)
# Add glfw directly to our build.
fetchcontent_getproperties(glfw3)
if(NOT glfw3_POPULATED)
fetchcontent_populate(glfw3)
set(SAVE_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS})
set(BUILD_SHARED_LIBS OFF)
set(GLFW_INSTALL OFF)
add_subdirectory(${glfw3_SOURCE_DIR} ${glfw3_BINARY_DIR} EXCLUDE_FROM_ALL)
set_property(TARGET glfw PROPERTY POSITION_INDEPENDENT_CODE ON)
set(BUILD_SHARED_LIBS ${SAVE_BUILD_SHARED_LIBS})
export(TARGETS glfw FILE glfw.cmake NAMESPACE glfw::)
endif()
# Don't use gl3w CMakeLists.txt due to https://github.com/skaslev/gl3w/issues/66
fetchcontent_getproperties(gl3w)
if(NOT gl3w_POPULATED)
fetchcontent_populate(gl3w)
endif()
if(NOT EXISTS "${gl3w_BINARY_DIR}/src/gl3w.c")
find_package(Python COMPONENTS Interpreter Development REQUIRED)
execute_process(
COMMAND "${Python_EXECUTABLE}" ${gl3w_SOURCE_DIR}/gl3w_gen.py "--root=${gl3w_BINARY_DIR}"
WORKING_DIRECTORY ${gl3w_BINARY_DIR}
)
endif()
# Add imgui directly to our build.
file(GLOB imgui_sources ${imgui_SOURCE_DIR}/*.cpp ${imgui_SOURCE_DIR}/misc/cpp/*.cpp)
file(GLOB implot_sources ${implot_SOURCE_DIR}/*.cpp)
file(GLOB fonts_sources ${fonts_SOURCE_DIR}/src/*.cpp)
set(imgui_all_sources
${imgui_sources}
${implot_sources}
${imgui_SOURCE_DIR}/backends/imgui_impl_glfw.cpp
${imgui_SOURCE_DIR}/backends/imgui_impl_opengl3.cpp
${gl3w_BINARY_DIR}/src/gl3w.c
${fonts_sources}
src/stb_image.cpp
)
if(MSVC)
add_library(imgui STATIC ${imgui_all_sources})
else()
add_library(imgui ${imgui_all_sources})
endif()
target_compile_definitions(imgui PUBLIC IMGUI_IMPL_OPENGL_LOADER_GL3W)
if(MSVC)
target_sources(imgui PRIVATE ${imgui_SOURCE_DIR}/backends/imgui_impl_dx11.cpp)
elseif(APPLE)
target_compile_options(imgui PRIVATE -fobjc-arc)
wpilib_link_macos_gui(imgui)
target_sources(imgui PRIVATE ${imgui_SOURCE_DIR}/backends/imgui_impl_metal.mm)
else()
#target_sources(imgui PRIVATE ${imgui_SOURCE_DIR}/backends/imgui_impl_opengl3.cpp)
endif()
target_link_libraries(imgui PUBLIC glfw)
target_include_directories(
imgui
PUBLIC
"$<BUILD_INTERFACE:${imgui_SOURCE_DIR}>"
"$<BUILD_INTERFACE:${imgui_SOURCE_DIR}/misc/cpp>"
"$<BUILD_INTERFACE:${implot_SOURCE_DIR}>"
"$<BUILD_INTERFACE:${imgui_SOURCE_DIR}/backends>"
"$<BUILD_INTERFACE:${gl3w_BINARY_DIR}/include>"
"$<BUILD_INTERFACE:${fonts_SOURCE_DIR}/include>"
"$<BUILD_INTERFACE:${stb_SOURCE_DIR}>"
PRIVATE "$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>"
)
set_property(TARGET imgui PROPERTY POSITION_INDEPENDENT_CODE ON)
target_compile_features(imgui PUBLIC cxx_std_20)
install(TARGETS imgui EXPORT imgui)
export(TARGETS imgui FILE imgui.cmake NAMESPACE imgui::)

View File

@@ -1,7 +0,0 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#define STBI_WINDOWS_UTF8
#define STB_IMAGE_IMPLEMENTATION
#include "stb_image.h"

View File

@@ -24,8 +24,6 @@ apply from: "${rootDir}/shared/config.gradle"
def wpilibVersionFileInput = file("src/main/generate/WPILibVersion.cpp.in")
def wpilibVersionFileOutput = file("$buildDir/generated/main/cpp/WPILibVersion.cpp")
apply from: "${rootDir}/shared/imgui.gradle"
task generateCppVersion() {
description = 'Generates the wpilib version class'
group = 'WPILib'
@@ -104,7 +102,7 @@ model {
lib project: ':wpiutil', library: 'wpiutil', linkage: 'static'
lib project: ':wpigui', library: 'wpigui', linkage: 'static'
lib project: ':fieldImages', library: 'fieldImages', linkage: 'static'
nativeUtils.useRequiredLibrary(it, 'imgui')
lib project: ':thirdparty:imgui_suite', library: 'imgui', linkage: 'static'
if (it.targetPlatform.operatingSystem.isWindows()) {
it.linker.args << 'Gdi32.lib' << 'Shell32.lib' << 'd3d11.lib' << 'd3dcompiler.lib'
} else if (it.targetPlatform.operatingSystem.isMacOsX()) {

View File

@@ -25,7 +25,6 @@ def wpilibVersionFileInput = file("src/main/generate/WPILibVersion.cpp.in")
def wpilibVersionFileOutput = file("$buildDir/generated/main/cpp/WPILibVersion.cpp")
apply from: "${rootDir}/shared/libssh.gradle"
apply from: "${rootDir}/shared/imgui.gradle"
task generateCppVersion() {
description = 'Generates the wpilib version class'
@@ -103,7 +102,8 @@ model {
lib project: ':wpinet', library: 'wpinet', linkage: 'static'
lib project: ':wpiutil', library: 'wpiutil', linkage: 'static'
lib project: ':wpigui', library: 'wpigui', linkage: 'static'
nativeUtils.useRequiredLibrary(it, 'imgui', 'libssh')
nativeUtils.useRequiredLibrary(it, 'libssh')
lib project: ':thirdparty:imgui_suite', library: 'imgui', linkage: 'static'
if (it.targetPlatform.operatingSystem.isWindows()) {
it.linker.args << 'Gdi32.lib' << 'Shell32.lib' << 'd3d11.lib' << 'd3dcompiler.lib'
it.linker.args << 'ws2_32.lib' << 'advapi32.lib' << 'crypt32.lib' << 'user32.lib'

View File

@@ -61,6 +61,7 @@ include 'processstarter'
include 'epilogue-processor'
include 'epilogue-runtime'
include 'thirdparty:googletest'
include 'thirdparty:imgui_suite'
buildCache {
def cred = {

View File

@@ -1,13 +0,0 @@
nativeUtils {
nativeDependencyContainer {
imgui(getNativeDependencyTypeClass('WPIStaticMavenDependency')) {
groupId = "edu.wpi.first.thirdparty.frc2024"
artifactId = "imgui"
headerClassifier = "headers"
sourceClassifier = "sources"
ext = "zip"
version = '1.89.9-1'
targetPlatforms.addAll(nativeUtils.wpi.platforms.allPlatforms)
}
}
}

View File

@@ -20,8 +20,6 @@ apply from: "${rootDir}/shared/googletest.gradle"
apply from: "${rootDir}/shared/plugins/setupBuild.gradle"
apply from: "${rootDir}/shared/imgui.gradle"
model {
binaries {
all {
@@ -33,7 +31,7 @@ model {
lib project: ':wpinet', library: 'wpinet', linkage: 'shared'
lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared'
lib project: ':fieldImages', library: 'fieldImages', linkage: 'static'
nativeUtils.useRequiredLibrary(it, 'imgui')
lib project: ':thirdparty:imgui_suite', library: 'imgui', linkage: 'static'
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio) {
it.buildable = false
return

View File

@@ -25,8 +25,6 @@ apply from: "${rootDir}/shared/config.gradle"
def wpilibVersionFileInput = file("src/main/generate/WPILibVersion.cpp.in")
def wpilibVersionFileOutput = file("$buildDir/generated/main/cpp/WPILibVersion.cpp")
apply from: "${rootDir}/shared/imgui.gradle"
task generateCppVersion() {
description = 'Generates the wpilib version class'
group = 'WPILib'
@@ -105,7 +103,7 @@ model {
lib project: ':wpimath', library: 'wpimath', linkage: 'static'
lib project: ':wpiutil', library: 'wpiutil', linkage: 'static'
lib project: ':wpigui', library: 'wpigui', linkage: 'static'
nativeUtils.useRequiredLibrary(it, 'imgui')
lib project: ':thirdparty:imgui_suite', library: 'imgui', linkage: 'static'
if (it.targetPlatform.operatingSystem.isWindows()) {
it.linker.args << 'Gdi32.lib' << 'Shell32.lib' << 'd3d11.lib' << 'd3dcompiler.lib'
it.linker.args << '/DELAYLOAD:MF.dll' << '/DELAYLOAD:MFReadWrite.dll' << '/DELAYLOAD:MFPlat.dll' << '/delay:nobind'
@@ -147,7 +145,7 @@ model {
lib project: ':wpimath', library: 'wpimath', linkage: 'static'
lib project: ':wpiutil', library: 'wpiutil', linkage: 'static'
lib project: ':wpigui', library: 'wpigui', linkage: 'static'
nativeUtils.useRequiredLibrary(it, 'imgui')
lib project: ':thirdparty:imgui_suite', library: 'imgui', linkage: 'static'
if (it.targetPlatform.operatingSystem.isWindows()) {
it.linker.args << 'Gdi32.lib' << 'Shell32.lib' << 'd3d11.lib' << 'd3dcompiler.lib'
it.linker.args << '/DELAYLOAD:MF.dll' << '/DELAYLOAD:MFReadWrite.dll' << '/DELAYLOAD:MFPlat.dll' << '/delay:nobind'

61
thirdparty/imgui_suite/CMakeLists.txt vendored Normal file
View File

@@ -0,0 +1,61 @@
include(LinkMacOSGUI)
set(SAVE_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS})
set(BUILD_SHARED_LIBS OFF)
set(GLFW_INSTALL OFF)
add_subdirectory("glfw")
set_property(TARGET glfw PROPERTY POSITION_INDEPENDENT_CODE ON)
set(BUILD_SHARED_LIBS ${SAVE_BUILD_SHARED_LIBS})
export(TARGETS glfw FILE glfw.cmake NAMESPACE glfw::)
# Add imgui directly to our build.
file(GLOB imgui_sources imgui/cpp/*.cpp imgui/cpp/misc/cpp/*.cpp)
file(GLOB implot_sources implot/cpp/*.cpp)
file(GLOB fonts_sources generated/fonts/src/*.cpp)
set(imgui_all_sources
${imgui_sources}
${implot_sources}
${fonts_sources}
imgui/cpp/backends/imgui_impl_glfw.cpp
imgui/cpp/backends/imgui_impl_opengl3.cpp
generated/gl3w/src/gl3w.c
stb/cpp/stb_image.cpp
)
if(MSVC)
add_library(imgui STATIC ${imgui_all_sources})
else()
add_library(imgui ${imgui_all_sources})
endif()
target_compile_definitions(imgui PUBLIC IMGUI_IMPL_OPENGL_LOADER_GL3W)
if(MSVC)
target_sources(imgui PRIVATE imgui/cpp/backends/imgui_impl_dx11.cpp)
else()
if(APPLE)
target_compile_options(imgui PRIVATE -fobjc-arc)
wpilib_link_macos_gui(imgui)
target_sources(imgui PRIVATE imgui/cpp/backends/imgui_impl_metal.mm)
else()
#target_sources(imgui PRIVATE imgui/cpp/backends/imgui_impl_opengl3.cpp)
endif()
endif()
target_link_libraries(imgui PUBLIC glfw)
target_include_directories(
imgui
PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/imgui/include>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/imgui/include/misc/cpp>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/imgui/include/backends>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/implot/include>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/generated/gl3w/include>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/generated/fonts/include>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/stb/include>"
PRIVATE "$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>"
)
set_property(TARGET imgui PROPERTY POSITION_INDEPENDENT_CODE ON)
target_compile_features(imgui PUBLIC cxx_std_20)
install(TARGETS imgui EXPORT imgui)
export(TARGETS imgui FILE imgui.cmake NAMESPACE imgui::)

166
thirdparty/imgui_suite/build.gradle vendored Normal file
View File

@@ -0,0 +1,166 @@
import org.gradle.internal.os.OperatingSystem
if (project.hasProperty('onlylinuxathena')) {
return;
}
apply plugin: 'c'
apply plugin: 'cpp'
apply plugin: 'visual-studio'
apply plugin: 'edu.wpi.first.NativeUtils'
if (OperatingSystem.current().isMacOsX()) {
apply plugin: 'objective-c'
apply plugin: 'objective-cpp'
}
apply from: "${rootDir}/shared/config.gradle"
nativeUtils.platformConfigs.named('osxuniversal') {
it.objcCompiler.args.remove('-fobjc-weak')
it.objcCompiler.args.remove('-fobjc-arc')
it.objcppCompiler.args.remove('-fobjc-weak')
it.objcppCompiler.args.remove('-fobjc-arc')
}
model {
components {
imgui(NativeLibrarySpec) {
sources {
cpp {
source {
srcDirs 'imgui/cpp', 'generated/fonts/src', 'stb/cpp', 'implot/cpp', 'imgui/cpp/misc/cpp'
include '*.cpp', 'backends/imgui_impl_glfw.cpp', 'backends/imgui_impl_opengl3.cpp', 'backends/imgui_impl_opengl2.cpp'
}
exportedHeaders {
srcDirs 'imgui/include', 'generated/fonts/include', 'stb/include', 'implot/include', 'generated/gl3w/include', 'glfw/include', 'imgui/include/misc/cpp', 'imgui/include/backends'
include '*.h', 'backends/imgui_impl_glfw.h', 'backends/imgui_impl_opengl3.h', 'backends/imgui_impl_opengl2.h'
}
}
c {
source {
srcDirs 'generated/gl3w/src', 'glfw/src'
include 'gl3w.c', 'context.c', 'init.c', 'input.c', 'monitor.c', 'platform.c', 'vulkan.c', 'window.c', 'egl_context.c', 'osmesa_context.c', 'null_init.c', 'null_monitor.c', 'null_window.c', 'null_joystick.c'
}
exportedHeaders {
srcDirs 'generated/gl3w/include', 'glfw/include'
include '*.h'
}
}
}
binaries.all {
if (toolChain in VisualCpp) {
cppCompiler.args '-D_UNICODE', '-DUNICODE', '-DWIN32', '-D_WIN32', '-DSTRICT', '-DWIN32_LEAN_AND_MEAN', '-D_HAS_EXCEPTIONS=1'
} else {
cppCompiler.args '-Wshadow', '-fexceptions', '-Wno-missing-field-initializers'
}
if (it in SharedLibraryBinarySpec) {
it.cCompiler.define '_GLFW_BUILD_DLL'
if (!it.targetPlatform.operatingSystem.isWindows()) {
it.linker.args << '-fvisibility=hidden'
}
}
if (it.targetPlatform.operatingSystem.isWindows()) {
it.cCompiler.define '_GLFW_WIN32'
linker.args << 'kernel32.lib' << 'Gdi32.lib' << 'User32.lib' << 'Shell32.lib' << 'd3d11.lib' << 'd3dcompiler.lib'
it.sources {
imguiWindowsCpp(CppSourceSet) {
source {
srcDirs 'imgui'
include 'cpp/backends/imgui_impl_dx11.cpp'
}
exportedHeaders {
srcDirs 'imgui/include', 'imgui/include/backends'
include '*.h', 'backends/imgui_impl_dx11.h'
}
}
glfw3WindowsC(CSourceSet) {
source {
srcDirs 'glfw/src'
includes = [
'win32_init.c',
'win32_joystick.c',
'win32_module.c',
'win32_monitor.c',
'win32_time.c',
'win32_thread.c',
'win32_window.c',
'wgl_context.c',
]
}
}
}
} else if (it.targetPlatform.operatingSystem.isMacOsX()) {
it.cCompiler.args << '-fno-common'
it.cCompiler.define '_GLFW_COCOA'
it.objcCompiler.define '_GLFW_COCOA'
it.objcppCompiler.args << '-fobjc-arc'
it.linker.args << '-framework' << 'Metal' << '-framework' << 'MetalKit' << '-framework' << 'Cocoa' << '-framework' << 'IOKit' << '-framework' << 'CoreFoundation' << '-framework' << 'CoreVideo' << '-framework' << 'QuartzCore'
it.sources {
imguiMacObjectiveCpp(ObjectiveCppSourceSet) {
source {
srcDirs 'imgui'
include 'cpp/backends/imgui_impl_metal.mm'
}
exportedHeaders {
srcDirs 'imgui/include', 'imgui/include/backends'
include '*.h', 'backends/imgui_impl_metal.h'
}
}
glfw3MacC(CSourceSet) {
source {
srcDirs 'glfw/src'
includes = [
'cocoa_time.c',
'posix_module.c',
'posix_thread.c',
]
}
}
glfw3MacObjC(ObjectiveCSourceSet) {
source {
srcDirs 'glfw/src'
includes = [
'cocoa_init.m',
'cocoa_joystick.m',
'cocoa_monitor.m',
'cocoa_window.m',
'nsgl_context.m',
]
}
}
}
} else {
it.cCompiler.define '_GLFW_X11'
it.linker.args << '-lrt'
it.sources {
glfw3LinuxC(CSourceSet) {
source {
srcDirs 'glfw/src'
includes = [
'x11_init.c',
'x11_monitor.c',
'x11_window.c',
'xkb_unicode.c',
'posix_module.c',
'posix_poll.c',
'posix_time.c',
'posix_thread.c',
'glx_context.c',
'linux_joystick.c',
]
}
}
}
}
}
binaries.withType(SharedLibraryBinarySpec) {
buildable = false
}
appendDebugPathToBinaries(binaries)
}
}
}
apply from: 'publish.gradle'

84
thirdparty/imgui_suite/generate_fonts.sh vendored Executable file
View File

@@ -0,0 +1,84 @@
#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
mkdir -p $DIR/generated
cd $DIR/generated
# Versions
IMGUI_COMMIT=74f7ac04a166c77ef1cbbbebff51e5bfc4fcfa5d
ICONFONTCPPHEADERS_COMMIT=acd3728de3ee4e2461f8958154bb2dc46f958723
DROID_COMMIT=d3817c246c6e3da7531fa1fbb0b0fca271aae7fb
PROGGYFONTS_VERSION=1.1.5
FONTAWESOME_VERSION=6.2.0
FIRACODE_VERSION=6.2
mkdir download
pushd download
# Download compressor
wget https://github.com/ocornut/imgui/raw/${IMGUI_COMMIT}/misc/fonts/binary_to_compressed_c.cpp
# Download fonts
wget -O proggyfonts.zip https://github.com/bluescan/proggyfonts/archive/refs/tags/v${PROGGYFONTS_VERSION}.zip
wget https://github.com/FortAwesome/Font-Awesome/releases/download/${FONTAWESOME_VERSION}/fontawesome-free-${FONTAWESOME_VERSION}-web.zip
wget -O droid-fonts.zip https://github.com/grays/droid-fonts/archive/${DROID_COMMIT}.zip
wget -O fira-code.zip https://github.com/tonsky/FiraCode/releases/download/${FIRACODE_VERSION}/Fira_Code_v${FIRACODE_VERSION}.zip
# Download C++ icon font header
wget https://github.com/juliettef/IconFontCppHeaders/raw/${ICONFONTCPPHEADERS_COMMIT}/IconsFontAwesome6.h
popd
# Extract fonts
rm -rf extract
mkdir extract
pushd extract
unzip ../download/proggyfonts.zip
unzip ../download/fontawesome-free-${FONTAWESOME_VERSION}-web.zip
unzip ../download/droid-fonts.zip
mkdir fira-code
pushd fira-code
unzip ../../download/fira-code.zip
popd
popd
rm -rf fonts
mkdir -p fonts/src
mkdir -p fonts/include
# Copy C++ icon font header
cp -p download/IconsFontAwesome6.h fonts/include/
# Copy license files
cp -p extract/proggyfonts-${PROGGYFONTS_VERSION}/LICENSE fonts/LICENSE-proggyfonts.txt
cp -p extract/fontawesome-free-${FONTAWESOME_VERSION}-web/LICENSE.txt fonts/LICENSE-fontawesome.txt
cp -p extract/droid-fonts-${DROID_COMMIT}/droid/NOTICE fonts/LICENSE-droid.txt
# Build C versions
g++ -o imgui_font_bin2c download/binary_to_compressed_c.cpp
./imgui_font_bin2c "extract/proggyfonts-${PROGGYFONTS_VERSION}/ProggyDotted/ProggyDotted Regular.ttf" ProggyDotted > fonts/src/ProggyDotted.inc
./imgui_font_bin2c "extract/fontawesome-free-${FONTAWESOME_VERSION}-web/webfonts/fa-regular-400.ttf" FontAwesomeRegular > fonts/src/FontAwesomeRegular.inc
./imgui_font_bin2c "extract/fontawesome-free-${FONTAWESOME_VERSION}-web/webfonts/fa-solid-900.ttf" FontAwesomeSolid > fonts/src/FontAwesomeSolid.inc
./imgui_font_bin2c "extract/droid-fonts-${DROID_COMMIT}/droid/DroidSans.ttf" DroidSans > fonts/src/DroidSans.inc
./imgui_font_bin2c "extract/fira-code/ttf/FiraCode-Retina.ttf" FiraCodeRetina > fonts/src/FiraCodeRetina.inc
# Generate C wrapper source/headers
for font in ProggyDotted FontAwesomeRegular FontAwesomeSolid DroidSans FiraCodeRetina
do
cat >fonts/src/imgui_${font}.cpp <<END
#include "imgui_${font}.h"
#include "${font}.inc"
ImFont* ImGui::AddFont${font}(ImGuiIO& io, float size_pixels, const ImFontConfig* font_cfg, const ImWchar* glyph_ranges) {
return io.Fonts->AddFontFromMemoryCompressedTTF(${font}_compressed_data, ${font}_compressed_size, size_pixels, font_cfg, glyph_ranges);
}
END
cat >fonts/include/imgui_${font}.h <<END
#pragma once
#include "imgui.h"
namespace ImGui {
ImFont* AddFont${font}(ImGuiIO& io, float size_pixels, const ImFontConfig* font_cfg = nullptr, const ImWchar* glyph_ranges = nullptr);
}
END
done
rm -r download extract imgui_font_bin2c

30
thirdparty/imgui_suite/generate_gl3w.py vendored Executable file
View File

@@ -0,0 +1,30 @@
#!/usr/bin/env python3
import os
import sys
import argparse
from pathlib import Path
def main(argv):
script_path = Path(__file__).resolve()
dirname = script_path.parent
parser = argparse.ArgumentParser()
parser.add_argument(
"--output_directory",
help="Optional. If set, will output the generated files to this directory, otherwise it will use a path relative to the script",
default=dirname / "generated/gl3w",
type=Path,
)
args = parser.parse_args(argv)
sys.path.append(str(dirname / "gl3w"))
args.output_directory.mkdir(parents=True, exist_ok=True)
os.chdir(args.output_directory)
import gl3w_gen
if __name__ == "__main__":
main(sys.argv[1:])

View File

@@ -0,0 +1,190 @@
Copyright (c) 2005-2008, The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
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.
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS

View File

@@ -0,0 +1,165 @@
Fonticons, Inc. (https://fontawesome.com)
--------------------------------------------------------------------------------
Font Awesome Free License
Font Awesome Free is free, open source, and GPL friendly. You can use it for
commercial projects, open source projects, or really almost whatever you want.
Full Font Awesome Free license: https://fontawesome.com/license/free.
--------------------------------------------------------------------------------
# Icons: CC BY 4.0 License (https://creativecommons.org/licenses/by/4.0/)
The Font Awesome Free download is licensed under a Creative Commons
Attribution 4.0 International License and applies to all icons packaged
as SVG and JS file types.
--------------------------------------------------------------------------------
# Fonts: SIL OFL 1.1 License
In the Font Awesome Free download, the SIL OFL license applies to all icons
packaged as web and desktop font files.
Copyright (c) 2022 Fonticons, Inc. (https://fontawesome.com)
with Reserved Font Name: "Font Awesome".
This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL
SIL OPEN FONT LICENSE
Version 1.1 - 26 February 2007
PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.
The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.
DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.
"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).
"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).
"Modified Version" refers to any derivative made by adding to, deleting,
or substituting — in part or in whole — any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.
"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.
PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:
1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.
2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.
3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.
5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.
TERMINATION
This license becomes null and void if any of the above conditions are
not met.
DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.
--------------------------------------------------------------------------------
# Code: MIT License (https://opensource.org/licenses/MIT)
In the Font Awesome Free download, the MIT license applies to all non-font and
non-icon files.
Copyright 2022 Fonticons, Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in the
Software without restriction, including without limitation the rights to use, copy,
modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
and to permit persons to whom the Software is 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 Software.
THE SOFTWARE IS 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
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--------------------------------------------------------------------------------
# Attribution
Attribution is required by MIT, SIL OFL, and CC BY licenses. Downloaded Font
Awesome Free files already contain embedded comments with sufficient
attribution, so you shouldn't need to do anything additional when using these
files normally.
We've kept attribution comments terse, so we ask that you do not actively work
to remove them from files, especially code. They're a great way for folks to
learn about Font Awesome.
--------------------------------------------------------------------------------
# Brand Icons
All brand icons are trademarks of their respective owners. The use of these
trademarks does not indicate endorsement of the trademark holder by Font
Awesome, nor vice versa. **Please do not use brand logos for any purpose except
to represent the company, product, or service to which they refer.**

View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2004, 2005 Tristan Grimmer
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
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 Software.
THE SOFTWARE IS 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 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,5 @@
#pragma once
#include "imgui.h"
namespace ImGui {
ImFont* AddFontDroidSans(ImGuiIO& io, float size_pixels, const ImFontConfig* font_cfg = nullptr, const ImWchar* glyph_ranges = nullptr);
}

View File

@@ -0,0 +1,5 @@
#pragma once
#include "imgui.h"
namespace ImGui {
ImFont* AddFontFiraCodeRetina(ImGuiIO& io, float size_pixels, const ImFontConfig* font_cfg = nullptr, const ImWchar* glyph_ranges = nullptr);
}

View File

@@ -0,0 +1,5 @@
#pragma once
#include "imgui.h"
namespace ImGui {
ImFont* AddFontFontAwesomeRegular(ImGuiIO& io, float size_pixels, const ImFontConfig* font_cfg = nullptr, const ImWchar* glyph_ranges = nullptr);
}

View File

@@ -0,0 +1,5 @@
#pragma once
#include "imgui.h"
namespace ImGui {
ImFont* AddFontFontAwesomeSolid(ImGuiIO& io, float size_pixels, const ImFontConfig* font_cfg = nullptr, const ImWchar* glyph_ranges = nullptr);
}

View File

@@ -0,0 +1,5 @@
#pragma once
#include "imgui.h"
namespace ImGui {
ImFont* AddFontProggyDotted(ImGuiIO& io, float size_pixels, const ImFontConfig* font_cfg = nullptr, const ImWchar* glyph_ranges = nullptr);
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,774 @@
// File: 'extract/fontawesome-free-6.2.0-web/webfonts/fa-regular-400.ttf' (62048 bytes)
// Exported using binary_to_compressed_c.cpp
static const unsigned int FontAwesomeRegular_compressed_size = 36785;
static const unsigned int FontAwesomeRegular_compressed_data[36788/4] =
{
0x0000bc57, 0x00000000, 0x60f20000, 0x00000400, 0x00010037, 0x000a0000, 0x00030080, 0x2f534f20, 0x5e575f32, 0x0100005a, 0x08158228, 0x6d636028,
0x191a7061, 0x0000a125, 0x0000d404, 0x6c676c17, 0xa1a06679, 0x000017a7, 0x0000e81d, 0x656878c6, 0x08236461, 0x2b827104, 0x0382ac20, 0x82683621,
0x41042310, 0x0b821403, 0x0382e420, 0x6d682428, 0xc4807874, 0x4f822502, 0x00008830, 0x6f6c4c03, 0xbdfd6163, 0x0000f430, 0x1382401c, 0x616da828,
0xe2007078, 0x0b82f800, 0x2f820820, 0x616e202c, 0x1a85656d, 0x00003d49, 0x738260e4, 0x6f700530, 0xd5417473, 0x00002af1, 0x000068e8, 0xab83f509,
0x0102032f, 0x68389600, 0x3c0f5f55, 0x020b00f5, 0x23008300, 0x7ae133df, 0xff250789, 0x018002c0, 0x220f82c0, 0x82020008, 0x25028305, 0x01000001,
0x1382ffc0, 0xff800229, 0x020000ff, 0x83010080, 0x20038a16, 0x241184d3, 0x00f600d3, 0x8315840d, 0x8c01201f, 0x01042625, 0x009001d2, 0x22498205,
0x8266014c, 0x01472123, 0xf52a0785, 0x84001900, 0x00020000, 0x15820305, 0x01210285, 0x84078510, 0x57412905, 0xc0004d53, 0xffff2100, 0x01238385,
0x824000c0, 0x82012018, 0x01002403, 0x82a50139, 0x00202c07, 0x00800100, 0x00800000, 0x82c00120, 0x0040230b, 0xa9820110, 0x1a200b82, 0x10210382,
0x202f8201, 0x841e8201, 0x200b8307, 0x20238480, 0x830f8800, 0x83178413, 0x853b8363, 0x0002211f, 0x5f830b89, 0x2b870384, 0x2382c020, 0x7f854791,
0x1f831783, 0x07872b83, 0x1f008022, 0x1f824388, 0x1b830220, 0x13870782, 0x00000223, 0x23038400, 0x01170040, 0x0b863382, 0x23831384, 0x86000221,
0x82078b1f, 0x83022043, 0x232f8743, 0x02ffff00, 0x23831383, 0x0b821782, 0x13874b85, 0x01233b86, 0x832000c0, 0x00022103, 0x3b82c382, 0x3f880120,
0x80200f82, 0x7f83f382, 0x7b8a578c, 0x3b8cd386, 0x47835f86, 0xdb860388, 0x2020b78e, 0x0b416b87, 0x8e0b9b0b, 0x8300203f, 0x081b41ef, 0x20004022,
0x4788ff8b, 0x378cdf82, 0x77862782, 0xb78b2020, 0x0220ab87, 0xff21bf84, 0x843387ff, 0x86bf822b, 0x0220210f, 0x00221f84, 0x13830100, 0x230e4b41,
0x1b000002, 0x2383f383, 0xa7411f84, 0x20178217, 0x063b4101, 0x37420120, 0x82022006, 0x8233982b, 0xa702201b, 0x20ab8903, 0x8f33a800, 0x0040225b,
0x233b8717, 0x04000000, 0x03200382, 0x24200382, 0x0b820382, 0x002c0825, 0x84010003, 0x00032e0f, 0x0800000a, 0x0804002c, 0x01000008, 0x091482ca,
0xca0007d8, 0x25002100, 0x39002b00, 0x61005a00, 0x63006200, 0x65006400, 0x67006600, 0x69006800, 0x6b006a00, 0x6d006c00, 0x6f006e00, 0x71007000,
0x73007200, 0x75007400, 0x77007600, 0x79007800, 0xa9007a00, 0x2823ae00, 0xfe23f323, 0xcf25a025, 0xfc25fb25, 0x11260026, 0x39261d26, 0x5b265a26,
0x5d265c26, 0x5f265e26, 0xaa266526, 0xbd26ab26, 0x09270527, 0x0c270b27, 0x44273127, 0x53274627, 0x55275427, 0x64275727, 0x1b2b9527, 0x242b1c2b,
0x85e1502b, 0x05f003f0, 0x07f006f0, 0x16f014f0, 0x1af017f0, 0x1df01bf0, 0x24f022f0, 0x3ef02ef0, 0x45f044f0, 0x59f046f0, 0x5df05cf0, 0x69f067f0,
0x70f06ef0, 0x75f073f0, 0x80f07cf0, 0x87f086f0, 0x89f088f0, 0x94f08af0, 0x97f096f0, 0xa0f09df0, 0xa7f0a2f0, 0xc8f0c5f0, 0xe5f0e0f0, 0xebf0e6f0,
0xf6f0f3f0, 0xf8f0f7f0, 0x0cf1fef0, 0x14f111f1, 0x1af115f1, 0x1df11cf1, 0x28f123f1, 0x33f12af1, 0x46f144f1, 0x4af147f1, 0x52f14ef1, 0x5cf155f1,
0x86f165f1, 0x90f18ef1, 0x96f192f1, 0xc9f1adf1, 0xd8f1cdf1, 0xdbf1d9f1, 0xeaf1e3f1, 0xf7f1f6f1, 0xfaf1f9f1, 0x49f20af2, 0x4df24af2, 0x52f250f2,
0x5df25bf2, 0x78f274f2, 0x7bf27af2, 0x8bf283f2, 0x8df28cf2, 0x92f28ef2, 0x9cf295f2, 0xb7f2b6f2, 0xbaf2b9f2, 0xbcf2bbf2, 0xbef2bdf2, 0xc2f2c0f2,
0xd2f2c3f2, 0xdcf2d4f2, 0x02f3edf2, 0x5bf328f3, 0xd1f3a5f3, 0x25f410f4, 0x3ff43af4, 0x43f441f4, 0x47f445f4, 0x7df45cf4, 0xdaf4adf4, 0x2cf5e6f4,
0x36f531f5, 0x56f541f5, 0x7af567f5, 0x9cf58cf5, 0xb4f5a5f5, 0xc0f5b8f5, 0xc8f5c2f5, 0x0000ffff, 0x23002100, 0x30002a00, 0xcb413c00, 0x41042088,
0x57201ecb, 0x2010cb41, 0x18cb417b, 0xc5f0a424, 0xcb41c7f0, 0x41ea2006, 0x182012cb, 0x3614cb41, 0xf150f14d, 0xf15bf155, 0xf185f164, 0xf190f18e,
0xf196f191, 0x41c1f1ad, 0x472016cb, 0x2808cb41, 0xf25df254, 0xf278f271, 0x12cb4179, 0xcb41b420, 0xf2c12410, 0x41d0f2c3, 0x58200acb, 0x282acb41,
0xf57ff579, 0xf5a4f596, 0x09cb41b3, 0xffe0ff2a, 0xffdbffdf, 0x00d5ffd7, 0x25820040, 0x0000ab1e, 0x03822d10, 0x8c832c20, 0x831d1021, 0x00002b05,
0x12101310, 0xfa0f0910, 0x0f83f50f, 0x83e30f21, 0x2d038305, 0xce0fcf0f, 0xcb0fcc0f, 0xc30fc60f, 0x1184be0f, 0x0000bc24, 0x0984b20f, 0xa80faa2c,
0xa50f0000, 0x870f880f, 0x1184700f, 0x600f6722, 0x5c260784, 0x0000570f, 0x0b84450f, 0x3e0f3f22, 0x03830783, 0x0f280f2d, 0x00170f18, 0x0f140f00,
0x82110f12, 0x0f092307, 0x6b840e02, 0x00d90e2b, 0x0ebf0e00, 0x0ea90eac, 0x2929839f, 0x8f0e950e, 0x0000840e, 0x0382820e, 0x360e7222, 0x33200582,
0x2f260382, 0x2d0e2e0e, 0x09821a0e, 0x25841620, 0x00000624, 0x0983050e, 0x0d250383, 0x0d0000df, 0x200382dd, 0x200382dc, 0x241184db, 0x0d0000d8,
0x3e0382cb, 0x0db20dc2, 0x0d790d9e, 0x0c010d4a, 0x00980cd6, 0x0c6f0c00, 0x0c6a0c6b, 0x0c680c69, 0x82530c67, 0x0b03220f, 0x853183d7, 0x5c0b3703,
0x3b0b4c0b, 0x2e0b370b, 0x1a0b270b, 0x100b170b, 0x0a0b0f0b, 0x1d850100, 0x01210583, 0x3d01b1d6, 0x28022002, 0x1e02fe01, 0xea010e02, 0xe601f201,
0x0202e401, 0xdc01f401, 0x3402e801, 0x01823802, 0x2e022c26, 0xb0012e02, 0xd4265982, 0xda01f001, 0x1d82c601, 0x5e01f434, 0x04020602, 0x60016201,
0x4a014c01, 0x50019201, 0x41821002, 0x8a01b226, 0xa4010000, 0x82200382, 0xe6220382, 0x0582b001, 0xe601e224, 0x9d83a001, 0x01230385, 0x8296019a,
0x016a2615, 0x011c016a, 0x87138518, 0x84012705, 0x00008401, 0x03824401, 0x46015e22, 0x01211583, 0x8305835a, 0x3e012303, 0x07844201, 0x66015e22,
0x1f820784, 0x012c0123, 0x270b842c, 0x00280118, 0x00c200d6, 0x01210084, 0x22068434, 0x85b60000, 0x64012707, 0x00006001, 0x0d851401, 0x01000025,
0x850a0128, 0x2201210b, 0x9b840782, 0x821c0121, 0x821a2017, 0x8302840d, 0x42012197, 0x002c5182, 0x00001001, 0x6a000e01, 0xbc006c00, 0x08200982,
0x06290382, 0x04010000, 0x02010000, 0x20398300, 0x841585fe, 0x20048936, 0x840a89de, 0x84962009, 0x00c82205, 0x2201822e, 0x84200028, 0x0804930d,
0x02000128, 0x04000300, 0x06000500, 0x12001100, 0x14001300, 0x16001500, 0x18001700, 0x1a001900, 0x1c001b00, 0x1e001d00, 0x43821f00, 0x00215208,
0x00230022, 0x00250024, 0x00270026, 0x00290028, 0x002b002a, 0x002d002c, 0x002f002e, 0x00320031, 0x00360033, 0x003a0037, 0x003c003b, 0x00410040,
0x00440042, 0x00470045, 0x004f004b, 0x00530050, 0x00550054, 0x00580056, 0x005c005a, 0x005e005d, 0x0c99475f, 0x006c4408, 0x00780077, 0x007b007a,
0x0082007f, 0x00890084, 0x008f008a, 0x00920091, 0x00950093, 0x00970096, 0x009a0098, 0x009f009e, 0x00a300a2, 0x00a500a4, 0x00a900a8, 0x00ab00aa,
0x00ad00ac, 0x00af00ae, 0x830c00b0, 0x400f21e4, 0x00230583, 0x82440100, 0x86212007, 0x82012003, 0x82232007, 0x82252003, 0x00022403, 0x822a0000,
0x822b2003, 0x82052003, 0x82302003, 0x82392003, 0x82072003, 0x823c2003, 0x825a2003, 0x82112003, 0x86612003, 0x82162003, 0x86622007, 0x82172003,
0x86632007, 0x82182003, 0x86642007, 0x82192003, 0x86652007, 0x821a2003, 0x86662007, 0x821b2003, 0x86672007, 0x821c2003, 0x86682007, 0x821d2003,
0x86692007, 0x821e2003, 0x866a2007, 0x821f2003, 0x866b2007, 0x82202003, 0x866c2007, 0x82212003, 0x866d2007, 0x82222003, 0x866e2007, 0x82232003,
0x866f2007, 0x82242003, 0x86702007, 0x20e78303, 0x830b8271, 0x82262003, 0x86722007, 0x82272003, 0x86732007, 0x82282003, 0x86742007, 0x82292003,
0x86752007, 0x822a2003, 0x86762007, 0x822b2003, 0x86772007, 0x822c2003, 0x86782007, 0x822d2003, 0x86792007, 0x822e2003, 0x867a2007, 0x822f2003,
0x86a92007, 0x827b2003, 0x86ae2007, 0x008a2403, 0x85282300, 0x5a002103, 0xf3200782, 0x00210385, 0x20078282, 0x250385fe, 0x00006900, 0x0385a025,
0x824f0021, 0x85cf2007, 0x56002103, 0xfb200782, 0x17840385, 0x0b82fc20, 0x0b830382, 0x0383da83, 0x00680025, 0x85112600, 0x5e002103, 0x1d200782,
0x00210385, 0x2007824b, 0x21038539, 0x07825800, 0x03855a20, 0x82aa0021, 0x855b2007, 0xad002103, 0x5c200782, 0x00200385, 0x2621af82, 0x820b825d,
0x82002003, 0x5e2621c7, 0x03820b82, 0x82ab0021, 0x855f2007, 0xac002103, 0x65200782, 0x00210385, 0x83078231, 0x8303824b, 0x832620a7, 0x84038227,
0x82bd200b, 0x2503821b, 0x00007800, 0x03850527, 0x27219b83, 0x820b8209, 0x50002103, 0x0b200782, 0x00210385, 0x20078284, 0x2103850c, 0x07828900,
0x27205782, 0x00200382, 0x44203783, 0x03820f82, 0x009e0025, 0x85462700, 0x200b8403, 0x820b8253, 0x14002103, 0x54200782, 0x0b840385, 0x0b825520,
0x00210382, 0x20078201, 0x84038557, 0x8264200b, 0x8303820b, 0x952721b3, 0x03820b82, 0x00060025, 0x851b2b00, 0xaf002103, 0x1c200782, 0x0b840385,
0x0b822420, 0xcb830382, 0xab822b20, 0x00250383, 0xe1000032, 0x25038585, 0x00003000, 0x038503f0, 0xf021cb83, 0x820b8204, 0x215f83af, 0x0b8206f0,
0x2f830382, 0x8207f021, 0x2103820b, 0x07823300, 0xf020ab82, 0x00210382, 0x200b829f, 0x20038516, 0x21938200, 0x0b8217f0, 0x00210382, 0x20078234,
0x2103851a, 0x0782a200, 0xf0209b82, 0x00210382, 0x200b82a5, 0x2103851d, 0x07825c00, 0x03852220, 0x82350021, 0x20a38207, 0x210382f0, 0x0b823600,
0x03852e20, 0x82370021, 0x853e2007, 0x38002103, 0x44200782, 0x00210385, 0x20078239, 0x21038545, 0x07825f00, 0x03854620, 0x825e0021, 0x82572007,
0x00592403, 0x823a0000, 0x855c2007, 0x200b8403, 0x820b825d, 0x3b002103, 0x67200782, 0x00200385, 0xf021db82, 0x820b8269, 0x05002103, 0x6e200782,
0x00210385, 0x2007823d, 0x20038570, 0x207f8300, 0x820b8273, 0x3f002103, 0x75200782, 0x00210385, 0x20078240, 0x2003827b, 0x206b827c, 0x20078241,
0x21038580, 0x07824300, 0x03858620, 0x82440021, 0x85872007, 0x66002103, 0x88200782, 0x00200385, 0x89207f83, 0x03820b82, 0xc7830020, 0x0b828a20,
0x00210382, 0x20078231, 0x21038594, 0x07824600, 0x03859620, 0x824f0021, 0x85972007, 0x37002103, 0x9d200782, 0x00210385, 0x20078247, 0x210385a0,
0x07824800, 0x0385a220, 0x82530021, 0x82a42007, 0x82a72003, 0x8249209b, 0x85c52007, 0x4d002103, 0xc7200782, 0xc8200382, 0x4e201782, 0xe0200782,
0x00210385, 0x20078250, 0x840385e5, 0x82e620d7, 0x8403820b, 0x82ea20bf, 0x82eb200b, 0x8251202f, 0x85f32007, 0x205f8403, 0x820b82f6, 0x65002103,
0xf7200782, 0x00210385, 0x2007826c, 0x210385f8, 0x07825400, 0x0385fe20, 0x00550025, 0x850cf100, 0x56002103, 0x11200782, 0x0b840385, 0x0b821420,
0x00210382, 0x20078241, 0x21038515, 0x07824200, 0x03821820, 0x77821a20, 0x07825720, 0x03851c20, 0x825a0021, 0x851d2007, 0x36002103, 0x23200782,
0x00210385, 0x20078245, 0x20038528, 0x214b8200, 0x0b822af1, 0x00210382, 0x20078201, 0x21038533, 0x07825b00, 0x03854420, 0x825c0021, 0x85462007,
0x5d002103, 0x47200782, 0x0b840385, 0x0b824a20, 0x00210382, 0x2007825e, 0x2003824d, 0x2083824e, 0x2007825f, 0x20038250, 0x054b4652, 0x8255f121,
0x2103820b, 0x07820300, 0x5c205783, 0x64201782, 0x03830b82, 0x0b826520, 0x0b826620, 0x03828520, 0x0b828620, 0x07826820, 0x03858e20, 0x82a40021,
0x85902007, 0xa3002103, 0x91200782, 0x92200382, 0x21053346, 0x0b8296f1, 0x00200382, 0xf1215782, 0x820b82ad, 0x6c002103, 0xc1200782, 0xc9200382,
0x21053346, 0x0b82cdf1, 0x00210382, 0x20078276, 0x210385d8, 0x07827700, 0x0385d920, 0xdb200b84, 0x03820b82, 0x82560021, 0x85e32007, 0x78002103,
0xea200782, 0x00210385, 0x20078279, 0x210385f6, 0x07827a00, 0x0385f720, 0xf9200b84, 0x03820b82, 0x827b0021, 0x85fa2007, 0x15002503, 0x0af20000,
0x00210385, 0x2007827c, 0x20038247, 0x208f8249, 0x2007827d, 0x2103854a, 0x07827f00, 0x03854d20, 0x82800021, 0x85502007, 0x82002103, 0x52200782,
0x00210385, 0x20078281, 0x20038254, 0x833b825b, 0x825d2017, 0x2103820b, 0x07828a00, 0x03827120, 0x17827420, 0x07828b20, 0x03857820, 0x828f0021,
0x82792007, 0x827a2003, 0x200b8317, 0x820b827b, 0xb0002103, 0x83200782, 0x00200385, 0x33838b83, 0x00210382, 0x20138291, 0x8403858c, 0x828d200b,
0x2103820b, 0x07829200, 0x03858e20, 0x0f830b84, 0x00210382, 0x20138202, 0x21038595, 0x07820400, 0x03859c20, 0x823c0021, 0x82b42007, 0x00b62403,
0x82930000, 0x85b72007, 0x83002003, 0x82b9202b, 0x2103820b, 0x07829600, 0x0385ba20, 0xbb200b84, 0x03820b82, 0x82970021, 0x85bc2007, 0x200b8403,
0x820b82bd, 0x98002103, 0xbe200782, 0x0b840385, 0x0b82c020, 0x00210382, 0x20078233, 0x200382c1, 0x206b82c2, 0x20078299, 0x210385c3, 0x07829a00,
0x0382d020, 0x1782d220, 0x07829b20, 0x0385d420, 0x82a80021, 0x85dc2007, 0x9e002103, 0xed200782, 0x00250385, 0xf300009f, 0x21038502, 0x0782a000,
0x03852820, 0x82a10021, 0x82582007, 0x005b2403, 0x82a20000, 0x85a52007, 0xa6002103, 0xd1200782, 0x00250385, 0xf40000a7, 0x83038510, 0x25f4215f,
0x03820b82, 0xf421fb83, 0x820b823a, 0xa9002103, 0x3f200782, 0x00210385, 0x200782aa, 0x21038541, 0x0782ab00, 0x03854320, 0x82ac0021, 0x85452007,
0xad002103, 0x47200782, 0x00210385, 0x200782ae, 0x2103855c, 0x0782af00, 0x03857d20, 0x82540021, 0x85ad2007, 0xb0002103, 0xda200782, 0x00210385,
0x200782b1, 0x830385e6, 0x2cf52483, 0x82f50000, 0x12002103, 0x31200782, 0x00210385, 0x20078213, 0x21038536, 0x07821100, 0x03854120, 0x82040021,
0x85562007, 0xb2002103, 0x67200782, 0x00210385, 0x200782b3, 0x24038279, 0x0000007a, 0x200782b4, 0x2003827f, 0x200b828c, 0x200782b6, 0x20038296,
0x200b829c, 0x200782c4, 0x200382a4, 0x200b82a5, 0x830782cb, 0x82b42033, 0x82cd200b, 0x85b8200b, 0xcf002103, 0xc0200782, 0x00210385, 0x200782d0,
0x210385c2, 0x0782d100, 0x0385c820, 0x00d20025, 0x8419f301, 0x00002203, 0x20078269, 0x2203844b, 0x82460000, 0x84e22007, 0x00002203, 0x2007826c,
0x220384e5, 0x82540000, 0x84f42007, 0x00002603, 0xf4010036, 0x22038441, 0x823d0000, 0x844d2007, 0x00002203, 0x20078266, 0x2203844e, 0x82670000,
0x84642007, 0x00002203, 0x20078233, 0x2203848e, 0x82a60000, 0x84992007, 0x00002203, 0x20078231, 0x8503849a, 0x829b200b, 0x829b200b, 0x823120cb,
0x849c2007, 0x20178503, 0x200b82a1, 0x201782a1, 0x20078252, 0x220384ac, 0x82b00000, 0x84b22007, 0x00002203, 0x20078203, 0x220384b3, 0x82470000,
0x84be2007, 0x00002203, 0x2007824e, 0x220384c1, 0x82410000, 0x84c22007, 0x00002203, 0x20078242, 0x220384c4, 0x82640000, 0x84c52007, 0x00002203,
0x2007825b, 0x850384c6, 0x82cb200b, 0x82cb200b, 0x207f8377, 0x200b82f0, 0x240b82f0, 0xf5010079, 0x22038414, 0x82530000, 0x84152007, 0x00002203,
0x2007827a, 0x22038416, 0x82370000, 0x84182007, 0x00002203, 0x2007826b, 0x22038434, 0x82560000, 0x84352007, 0x830b8503, 0x8253203f, 0x201f8353,
0x20178282, 0x200b8282, 0x20078250, 0x22038496, 0x82870000, 0x84a42007, 0x00002203, 0x20078231, 0x840384aa, 0xb4f521d7, 0xb4200b82, 0x48202f82,
0xb9200782, 0x00220384, 0x07826500, 0x0384bb20, 0x71000022, 0xbf200782, 0xfb840384, 0x82c1f521, 0x82c1200b, 0x20fb822f, 0x82d782f5, 0x21fb8403,
0x1782cef5, 0x1782ce20, 0xd5203b83, 0xd5200b82, 0x9c200b82, 0xd6200782, 0x00220384, 0x07829b00, 0x0384e920, 0x40000022, 0xea200782, 0x00220384,
0x07824400, 0x0384fa20, 0x8f000026, 0x00f60100, 0x00220384, 0x0782b700, 0x03840120, 0xc8000022, 0x02200782, 0x00220384, 0x0782bf00, 0x03840320,
0xb8000022, 0x04200782, 0x00220384, 0x0782b900, 0x03840520, 0xba000022, 0x06200782, 0x00220384, 0x0782bc00, 0x03840920, 0xb1000022, 0x0a200782,
0x00220384, 0x0782cf00, 0x03840d20, 0xbb000022, 0x10200782, 0x00220384, 0x07825900, 0x03841720, 0xc4000022, 0x18200782, 0x00220384, 0x0782c600,
0x03841920, 0xc5000022, 0x1b200782, 0x00220384, 0x0782c000, 0x03841c20, 0xc2000022, 0x1d200782, 0x00220384, 0x0782c100, 0x03842020, 0xb2000022,
0x22200782, 0x00220384, 0x0782ce00, 0x03842620, 0xb5000022, 0x2b200782, 0x00220384, 0x0782d200, 0x03842c20, 0xb6000022, 0x2d200782, 0x00220384,
0x0782cd00, 0x03842e20, 0xd1000022, 0x33200782, 0x00220384, 0x0782b400, 0x03843620, 0xcb000022, 0x42200782, 0x00220384, 0x07825700, 0x03844420,
0xcc000026, 0xe0f70100, 0x00220384, 0x07825600, 0x0384e120, 0xe2200b85, 0xe2210b82, 0x200b8500, 0x200b82e3, 0x200b86e3, 0x200b82e4, 0x200b86e4,
0x200b82e5, 0x200b82e5, 0x200782af, 0x220384e6, 0x82af0000, 0x84e72007, 0x200b8503, 0x200b82e8, 0x202386e8, 0x200b82e9, 0x200b86e9, 0x200b82ea,
0x200b86ea, 0x200b82eb, 0x230b85eb, 0x01000df9, 0x00220382, 0x07823100, 0x03840e20, 0x1a200b85, 0x1a200b82, 0x84202382, 0x23200782, 0x00220384,
0x0782bd00, 0x03842920, 0xbe000022, 0xe1200782, 0x2f850384, 0x0b82ed20, 0x2f82ed20, 0x03826020, 0x0042eb09, 0x01d00070, 0x01aa0156, 0x021a02f0,
0x0284025a, 0x030e03c0, 0x038c0342, 0x040004dc, 0x04c0046e, 0x051005e6, 0x06920536, 0x06400614, 0x07e4068c, 0x0746071a, 0x07cc076e, 0x082408f8,
0x08880856, 0x09da08a6, 0x09520908, 0x0ae60986, 0x0a7e0a26, 0x0ad20aa0, 0x0b300bf6, 0x0b860b62, 0x0c000cb2, 0x0db00c5a, 0x0e7a0d1a, 0x0e8a0e2c,
0x0f240fc2, 0x101610a4, 0x11101182, 0x127812c6, 0x135413ee, 0x14e0139a, 0x15ea1438, 0x16d01524, 0x17a01634, 0x18221860, 0x1aa419e2, 0x1a741a0c,
0x1b001bb0, 0x1c081c88, 0x1d241d6a, 0x1ecc1d82, 0x1f0c1f6c, 0x209e2096, 0x214821e6, 0x22f42196, 0x23de2260, 0x23862332, 0x241c24da, 0x2536257e,
0x268c26ea, 0x273e27e8, 0x283828a2, 0x295829ea, 0x2a302ac4, 0x2b1a2ba6, 0x2c0e2ca2, 0x2d242d80, 0x2ec42d6a, 0x2fde2e6e, 0x30f62f5e, 0x32be3184,
0x32723212, 0x332a33ce, 0x355834c0, 0x36763502, 0x37f83636, 0x384c38ce, 0x390e39b6, 0x3ade397e, 0x3a703a28, 0x3b363bda, 0x3c723ca6, 0x3e8e3dfa,
0x3fb43e1e, 0x3fb23f30, 0x400840f0, 0x412c416c, 0x423442b0, 0x4308439a, 0x44e04374, 0x4588444c, 0x456c4508, 0x465046f2, 0x474c47d2, 0x486648ec,
0x492a497e, 0x4b7e4acc, 0x4c124c30, 0x4e684dac, 0x4f9a4e00, 0x51965082, 0x52ec5146, 0x54a853e4, 0x56b055f4, 0x5764577c, 0x5afa58fe, 0x5b665b44,
0x5dde5cfa, 0x5e165e80, 0x606a5f90, 0x61c66016, 0x620062b6, 0x003c6394, 0xff000005, 0x018001c0, 0x001400c0, 0x001c0018, 0x00240020, 0x06210100,
0x11070607, 0x17161716, 0x36373621, 0x27261137, 0x11152726, 0x27073727, 0x11020f33, 0x3723021f, 0xe0fe5001, 0x010d0e14, 0x140e0d01, 0x09872001,
0x90737327, 0x1d73e673, 0x23028273, 0xc00173e6, 0xfe211c83, 0x20268860, 0x2b0983a0, 0xa6b4fe5a, 0xa6a67ca6, 0x4c01a62a, 0xa62e0482, 0x02000000,
0xe0ff2000, 0xa0016000, 0x81820a00, 0x70850020, 0x15367f84, 0x06310722, 0x16171415, 0x36373233, 0x26273435, 0x02164023, 0x03831602, 0x82090e21,
0x850e2000, 0x02502405, 0x83200116, 0xe0fe2614, 0x09300216, 0x82168609, 0x225b821c, 0x82e0ff00, 0x00a02489, 0x823d0038, 0x372326d9, 0x0f262736,
0x26068701, 0x17160706, 0x85230733, 0x17062806, 0x3f363332, 0x87073301, 0x37362608, 0x3f232726, 0x2e068301, 0x33372307, 0x4aa80107, 0x1615010e,
0x856f0f06, 0x83552006, 0x1a4d2273, 0x83068353, 0x02022319, 0x1b820513, 0x0f820220, 0x1d8b0882, 0x196f9d2c, 0x38011a70, 0x0106164c, 0x05855415,
0x9020c683, 0x0e830483, 0x14841320, 0x0254132f, 0x90021615, 0x17150201, 0x9090bf02, 0x38008200, 0xff100001, 0x012f01c0, 0x005700c0, 0x17161300,
0x27060716, 0x07262726, 0x20018306, 0x210f8217, 0x04833317, 0x12821884, 0x07061528, 0x22352726, 0x23822327, 0x37262723, 0x22218436, 0x83363716,
0x223782f5, 0x84313023, 0x821a8318, 0x32290814, 0x37363533, 0xb8151716, 0x03141e2a, 0x1f181507, 0x111d1d1e, 0x0503050f, 0x351d0d04, 0x19181802,
0x0b0d1614, 0x19330d05, 0x32a7831d, 0x13010505, 0x13151c1b, 0x11150b07, 0x36121818, 0x83041f21, 0x341e2129, 0x0c272986, 0x1f210906, 0x83050424,
0x7701212b, 0x1723a082, 0x82060315, 0x022e080e, 0x1115090b, 0x10090808, 0x0808060c, 0x18180c0c, 0x0a11351f, 0x02163101, 0x01321602, 0x09070703,
0x0714140b, 0x03060608, 0x160d0c06, 0x28860712, 0x820d0b21, 0x132b2428, 0x83300212, 0x00312128, 0x032e0082, 0x0000ffff, 0x80017f01, 0x1e000c00,
0x0b823000, 0x01072631, 0x33161706, 0x36013732, 0x37360527, 0x83373631, 0x217a82de, 0xf9821607, 0x07060524, 0x09840631, 0x1984ff82, 0x11780131,
0x0eb0fe11, 0x0a09090e, 0x0e500107, 0x42c8fe0f, 0xa442079c, 0x90002008, 0x0e792711, 0x11b0fe0e, 0x31820711, 0x69111126, 0x140e0d01, 0xa020228b,
0x9682108f, 0xff1a003c, 0x01a401e0, 0x002c00a0, 0x23062500, 0x15012f22, 0x27220706, 0x07013d26, 0x0f820722, 0x3f262729, 0x37262701, 0x41011f36,
0x2b08057f, 0x16173637, 0x1617010f, 0x07a10107, 0x8806060e, 0x070a1502, 0x02018908, 0x080d0504, 0x89891209, 0x140e0812, 0x16160289, 0x0b158902,
0x14380f83, 0x030c500b, 0x02169e4f, 0x9e0a0707, 0x0c02014f, 0x4f4f0d14, 0x0912140d, 0x02251383, 0x094f9e16, 0x83118512, 0xff10288b, 0x01b001f0,
0x83180090, 0x2307218b, 0x24052142, 0x36272623, 0x06fd4137, 0x17163327, 0x1602b001, 0x226083a0, 0x890216a0, 0x16c02209, 0x840f8c02, 0x00002919,
0x00000200, 0x4001e1ff, 0x132adf82, 0x00002700, 0x31171613, 0x57821716, 0x26070625, 0x82272627, 0x37362ed2, 0x31070635, 0x16150706, 0x36171617,
0x830e8237, 0x30a02818, 0x0101201f, 0x87301f20, 0x2d442707, 0x2d02022d, 0x0787442d, 0x83700121, 0x8780201d, 0x2008841e, 0x20208330, 0x8421877f,
0x01002108, 0xe02b7f82, 0x9f010001, 0x00001700, 0x85070605, 0x07112ccc, 0x3f262706, 0x16173601, 0x82331115, 0x020023d2, 0xcd83d016, 0x1443502d,
0x68110a0d, 0x500c0d0c, 0x44080216, 0x0130053e, 0x110a294d, 0x07400d14, 0xfe0e0706, 0x00160288, 0xd3835386, 0x00002224, 0xaf822105, 0x35434a82,
0x010f2105, 0x17255887, 0x0f060716, 0x085c8201, 0x01070622, 0x10f0fe28, 0xce0b0506, 0x1a03031f, 0x202a2a1b, 0x0d111127, 0x3e2f280f, 0x0526293d,
0xd29f2e04, 0x20086883, 0x100e0120, 0x261dba0b, 0x041f2026, 0x0d231b03, 0x2310120f, 0x2e060428, 0x29393930, 0x16160291, 0x26778b02, 0x17000030,
0x82272223, 0x05b64379, 0x42013b21, 0x232007b5, 0xe5848d84, 0x17162123, 0x22818416, 0x82061716, 0x5abc37bc, 0x0b1a1a22, 0x09161405, 0x120e0d06,
0x1817245a, 0x17180101, 0x99826424, 0xc4950a22, 0x01218283, 0x330b8400, 0x26253828, 0x25260101, 0x13132038, 0x05091520, 0x0a0a1114, 0x23282983,
0x01011718, 0x8f0c0f0e, 0x08828d83, 0x01900b25, 0x83382525, 0x8700202c, 0x0180249b, 0x421e009f, 0x7182053b, 0x35272622, 0x3722a483, 0x88843613,
0x3736352e, 0x33151716, 0x80011716, 0x01271602, 0xf82b4583, 0x0606080d, 0x13140c90, 0x83d07d09, 0x1628260f, 0x02167802, 0x2b8c8368, 0x0c0b0c68,
0x09131001, 0x98ed140c, 0x98220f83, 0x66821602, 0x200a7b41, 0x1903412e, 0x26272226, 0x3736013f, 0x06236a82, 0x82072307, 0x06014106, 0x1c25523e,
0x14050c1c, 0x10060916, 0x23521510, 0x01011818, 0xa4231818, 0x0107070b, 0xd0130520, 0xbc226683, 0xfe888717, 0x22141527, 0x15050916, 0x82888213,
0x82242026, 0x0908242e, 0x8413b70b, 0x028723b9, 0xfb872625, 0x00000232, 0x4001e0ff, 0x2000a001, 0x00003200, 0x31171637, 0x2d05ca42, 0x27262726,
0x07220722, 0x26273637, 0x87452223, 0x06072605, 0x07062115, 0x05ff4231, 0x36373622, 0x16222d82, 0xda420017, 0x0605330b, 0x0c4b0302, 0x0b080710,
0x2e1b2507, 0x0a0b1a19, 0x0a431001, 0x1f30240b, 0x43800120, 0x012e0b0f, 0x10125b01, 0x212b0905, 0x1a222136, 0x3a431e1a, 0x2f20210d, 0x280a3341,
0x17000012, 0x37262722, 0x05204213, 0x1617322d, 0x23060307, 0x12060638, 0x83e6db09, 0x100139fe, 0x0606070e, 0x200d08f0, 0x01140d03, 0x1616026c,
0x0c0c0c02, 0x000c70fe, 0x03200082, 0x1e27e788, 0x44003100, 0x45250000, 0x23200543, 0x82054445, 0x16152505, 0x33171617, 0x3424d583, 0x012f2627,
0x82087941, 0x2726216e, 0x78831683, 0x1b880985, 0x2a040131, 0x23230102, 0x23352835, 0x2a020123, 0x8311101b, 0x8348200d, 0x10112c0d, 0x2028781b,
0x01011516, 0x88201615, 0x48382108, 0x08881287, 0x3a24c622, 0x38832f83, 0x11243a25, 0x87221c1b, 0x1c22240d, 0x83aa111b, 0x8332873d, 0xa0fe2107,
0x0021118f, 0x0ec34100, 0x27260125, 0x85272631, 0x171626d7, 0x37323732, 0x053c4607, 0x0382c483, 0x36213524, 0xbb413137, 0x25248305, 0x27262726,
0xc4414001, 0x05062b0b, 0x0d4a0302, 0x0b080710, 0xc4412408, 0xf0fe2105, 0x210fc441, 0xc5410001, 0x060f260f, 0x35212b09, 0x11c54122, 0x00301f2f,
0xff010000, 0x010800ff, 0x0077017f, 0x080c8212, 0x16010d3c, 0x22070607, 0x27262527, 0x36253736, 0x01071617, 0x01defe72, 0x07071322, 0xfe050510,
0x01010db0, 0x1650010d, 0x0113070b, 0x0c8a8a4a, 0x02010d14, 0x0f0f07a0, 0x1307a007, 0xef820c14, 0x48001038, 0x3801b001, 0x15000a00, 0x21250000,
0x17160706, 0x26373621, 0x05842527, 0x01290f84, 0x1690fe98, 0x01160202, 0x21058370, 0x078790fe, 0x78220d83, 0x1f451602, 0x87902005, 0x01002108,
0x0822a382, 0x9f858001, 0x07062532, 0x22230605, 0x2d372627, 0x36372601, 0x17160517, 0x0d261a82, 0x0505b0fe, 0x9382080e, 0xdefe222b, 0x140c0713,
0x010d5001, 0x239482c0, 0x0c140e02, 0x1320a583, 0x0f209f82, 0x8f414782, 0x00112509, 0x3700003c, 0x2210dc49, 0x82062313, 0x161529fe, 0x35373617,
0x37363736, 0x23054f42, 0x0706010f, 0x3f211386, 0x25168201, 0x26272635, 0xff499027, 0x6b43250b, 0x011d1e2c, 0x012cb383, 0x6b18100f, 0x0111111a,
0x2e491f01, 0x14291185, 0x100f1b49, 0x2e1f1f01, 0x0b184a20, 0x1d23b782, 0x83102c1e, 0x18102eee, 0x01010f10, 0x241a1111, 0x341a2612, 0x3e128311,
0x260c1811, 0x1f19190f, 0x011f1f2e, 0x00020000, 0x01d0ff10, 0x00b001f0, 0x00530041, 0x82260100, 0x171625a4, 0x33321716, 0x82075749, 0x230f8207,
0x14151716, 0x9e821a82, 0x26013d26, 0x26070627, 0x0347ce84, 0x0a074705, 0x03272627, 0x26312726, 0x43348227, 0x26080930, 0x484a6407, 0x38390201,
0x1302015a, 0x48150105, 0x01012e2d, 0x4f513a3a, 0x0d023534, 0x0c13130c, 0x1316020d, 0x44251c04, 0x2f260707, 0x27331a20, 0xe6821a1a, 0x35341f2c,
0x121b0f41, 0x12010112, 0x07871b12, 0xb0012508, 0x66474602, 0x1042425b, 0x06161301, 0x4935350c, 0x02383a51, 0x53393905, 0x0c0d1313, 0x0d0c0101,
0x01167413, 0x01261b82, 0x2f2f1f20, 0x4782201f, 0x0102282e, 0x12271a1a, 0x22383744, 0xd0fe0223, 0x1a204d82, 0x11234d83, 0x821a1b12, 0x064b435c,
0x017f4e08, 0x0013009f, 0x25000017, 0x22232603, 0x17060307, 0x33013f16, 0x32331617, 0x25273637, 0x01231737, 0x0f07a87e, 0x07a8070f, 0x220a1514,
0x0f0722e0, 0x07140405, 0x5c5ce6fe, 0x900101b8, 0x70fe0e0e, 0x14070a15, 0x020f5050, 0xdc6e150a, 0x0c7f44db, 0x21001527, 0x00002d00, 0x087f4437,
0x76441120, 0x44262006, 0x35230d76, 0x41352313, 0xfa360837, 0x23010125, 0x168c3523, 0xac160202, 0x01232335, 0x20131201, 0x194474ca, 0x94742307,
0x0b879494, 0x3623cb22, 0x02252083, 0x1670fe16, 0x24348302, 0x101d1d25, 0x073544a5, 0xa0fe9823, 0x460b8798, 0x802a0993, 0x3a00a001, 0x26170000,
0x02833127, 0x82343521, 0x3736279d, 0x31303130, 0x01821716, 0x2007ee41, 0x09564427, 0x20054b44, 0x221d8232, 0x82060714, 0xdd480801, 0x1a313146,
0x311a1b1b, 0x24304532, 0x06151525, 0x0f0c0d05, 0x2c1b1a0f, 0x012d2d52, 0x522d2d01, 0x0f1a1b2c, 0x07080c0f, 0x15150108, 0x20302524, 0x33212101,
0x33373732, 0x01212233, 0x13101001, 0x08070b14, 0x0e020108, 0x01290082, 0x43353503, 0x03363542, 0x2a0c8201, 0x0606020e, 0x13140b0c, 0x83011010,
0x000225af, 0x01e0ff00, 0x1322af83, 0xb1821f00, 0x27262323, 0x06404311, 0x23052847, 0x33270706, 0x08085048, 0x839b113c, 0x16020216, 0x34334083,
0x01011e1f, 0x33341f1e, 0x4d6b6b40, 0x02023333, 0x6b4d3333, 0x01160220, 0x01021690, 0x33321e1e, 0x32333e3e, 0x30011e1e, 0x4b313202, 0x0232314b,
0x7b46a0fe, 0x0019260a, 0x07060500, 0x206b8421, 0x21678321, 0xa0471523, 0x25068305, 0x16024001, 0x6783f0fe, 0x83100121, 0xb8f82105, 0xb8210583,
0x068549f8, 0x02246183, 0x98021616, 0x0b490486, 0x8215200b, 0x0706210c, 0x06214c88, 0x83618707, 0x44478653, 0x5a8305a2, 0x86880121, 0x84b02045,
0x48b9826c, 0xbd240b57, 0x3c00a001, 0x410ac341, 0x162105a1, 0x23018317, 0x23060706, 0x4d05104d, 0x1621094f, 0x82218337, 0x37362116, 0xc541cb82,
0xde2c0805, 0x1c323242, 0x1d1e011c, 0x313e3233, 0x15152525, 0x09090101, 0x0f100b06, 0x4a2e1a1b, 0x01023132, 0x26260e0e, 0x26261c48, 0x96081f20,
0x15348482, 0x210116af, 0x37333321, 0x1f1f0120, 0x3f3b3233, 0x1e1e3233, 0x3106ce41, 0x0105050e, 0x0e0e0e0f, 0x32310201, 0x2929154c, 0x3e832323,
0x3a212122, 0x4725d085, 0x1a1a3132, 0x06634101, 0xbb828020, 0x0000182b, 0x07061101, 0x21352726, 0x06084115, 0x15171626, 0x37363521, 0x23057549,
0xe0fe0216, 0x16233a85, 0x83200102, 0x88012309, 0x848270fe, 0xc8c81622, 0x21090f41, 0x0b839898, 0x820b6341, 0x05bb4157, 0x1120e782, 0xc141ee84,
0x82112005, 0x09ba41f5, 0x49847020, 0x8305c041, 0x07404b0b, 0x72876020, 0x02a0fe23, 0x082b4a16, 0xaf824020, 0x6b411d20, 0x20a18407, 0x05fe4415,
0x11373622, 0xc782af83, 0xa0070626, 0x022d2d44, 0x0b4ca784, 0x284a8406, 0x20442d2d, 0x412c2b02, 0x2aa7832e, 0x1e1e2d2e, 0x1e1e0101, 0x830e012d,
0xf2fe250e, 0x022b2c41, 0x2b0a7742, 0x2500001e, 0x23060716, 0x07012f22, 0x4d0a1441, 0x302e0547, 0x011f3031, 0x110b3c01, 0x080c0707, 0x5d845094,
0x02161632, 0x0e1111e7, 0x9901970e, 0x040f1306, 0x7551d40a, 0x28091b41, 0x0e0ee8d7, 0x01981111, 0x20c784d8, 0x06f74920, 0x00000e23, 0x05454305,
0x1117162a, 0x06171633, 0xf0280107, 0x20051e47, 0x430683d8, 0x02230624, 0x4b88fe16, 0x9f8605ca, 0x9f01c024, 0x3b821c00, 0x11272622, 0xf482a185,
0x36200b82, 0x1b239c82, 0x82173601, 0x2849824c, 0x9c0216a8, 0x070d0d07, 0x2b3a839c, 0x0a111001, 0x110ab4b4, 0x16020110, 0x40265583, 0xed0a0aed,
0xa085c0fe, 0x0406112f, 0x01effe0e, 0x06040e11, 0x1670fe11, 0x086b4102, 0x22061b42, 0x42272205, 0x1120051e, 0x01206183, 0x26086641, 0x0b680123,
0x84dafe07, 0x0f0f245f, 0x8526010b, 0x04042709, 0x5d010920, 0x5c85b2fe, 0x04071027, 0x01a3fe0c, 0x240d834e, 0x071070fe, 0x0a2f5101, 0x2c001a22,
0x20093543, 0x0e354327, 0x07060722, 0x5d4fd682, 0x44e0200e, 0x3644052a, 0x230b850b, 0x0231324b, 0x83073f44, 0x91202007, 0x243a8622, 0x32310290,
0x442e8b4b, 0x402609db, 0x1200a001, 0x93841e00, 0x2007da44, 0x24878206, 0x07061523, 0x09da4437, 0x83181521, 0x409036cc, 0x02022b2b, 0x78412a2b,
0x78181602, 0x011d1e2c, 0x2c1d1e01, 0x07b34178, 0x402b2b22, 0x78272083, 0x01c00216, 0x832c1e1d, 0x00d0211f, 0xc022fb84, 0x6782c001, 0x3c002022,
0x4508094b, 0x062105db, 0x05314407, 0x17373623, 0x256c8316, 0x012f3435, 0xc6472607, 0x44372006, 0x2722054b, 0x90822326, 0x1f141529, 0x01070601,
0x44023a84, 0x3e24052f, 0x1e1e3333, 0x33317e83, 0x38483e32, 0x0c0a0936, 0x36060606, 0x32314ba4, 0x2eec8702, 0x075b2a01, 0x05060c0b, 0x362b5a06,
0x415a3e28, 0x272a1246, 0x0701093f, 0x07080808, 0x48411841, 0x2f44220b, 0x2117866a, 0xbb411c6c, 0x01402907, 0x001b00a0, 0x37000027, 0x82081051,
0x16112596, 0x35373617, 0x2106aa47, 0x4047022f, 0x35232b08, 0x212132cb, 0x24240201, 0xdc42a836, 0x85603c05, 0x06080c07, 0x9b700c11, 0x16172290,
0x17160101, 0x05a19022, 0x36332423, 0x47012524, 0x0229053d, 0x0ab6a816, 0x9b130e05, 0x831d83cf, 0x00a02125, 0x012e0082, 0xe0ff1f00, 0x9f016001,
0x00003400, 0xa9520625, 0x07855205, 0x20088352, 0x21118326, 0xc9523637, 0x0ac75205, 0x11821620, 0x5e012b08, 0x2e272c0a, 0x152e2d34, 0x150a0714,
0x1f373742, 0x1d070619, 0x2626431d, 0x08171626, 0x8d462809, 0x16070416, 0x1129294b, 0x1782011b, 0x84274221, 0x35412917, 0x01011419, 0x0a090d0d,
0x27083682, 0x1105051a, 0x14261f0e, 0x0f0a1213, 0x321d1d10, 0x252c1b2f, 0x04151607, 0x0d040312, 0x13271514, 0x100a1114, 0x331d1d0f, 0x260c4743,
0x01000011, 0x43230706, 0x0b4505a9, 0x80013607, 0x02901602, 0x90021616, 0x16020216, 0x02165001, 0x02168801, 0x820382fe, 0x062a4b0d, 0x440aa745,
0x054516f7, 0x82062005, 0x51c023e8, 0x48823637, 0x28254c82, 0x293d3d29, 0x280b8528, 0x20513736, 0x50363502, 0x291782eb, 0x283ceb16, 0x27020227,
0x0d853c28, 0x35365022, 0x2b09ef43, 0x009f017f, 0x17000010, 0x26032726, 0x2d074b44, 0x07060307, 0xa80610c0, 0x0a151407, 0xfe839292, 0x1006a837,
0x010e0120, 0x070a1590, 0x01a5fe14, 0x0a07145b, 0x0e70fe15, 0x08d34801, 0x01400229, 0x001e00a0, 0x82300500, 0x010b23e7, 0x4f890706, 0x17163727,
0x1736011b, 0x37558316, 0x10019801, 0x06626106, 0x90061110, 0x0a161406, 0x11066377, 0x77630611, 0x05226382, 0x63820790, 0x43011028, 0x0110bdfe,
0x6b830f01, 0xfe140525, 0x824a01b5, 0xfe10260d, 0x144b01b6, 0x20738305, 0x2073890f, 0x20bb8301, 0x0ab3451c, 0x22230622, 0x45090353, 0x173a05b5,
0x100d7a01, 0x070b0807, 0x0b079696, 0x0d100708, 0x100d9b9b, 0x96960f12, 0x0b83120f, 0x0f120734, 0xb2b20906, 0x120f0609, 0x0f12b9b9, 0xb2b2100d,
0x0b830d10, 0x8308c741, 0x00122263, 0x06104600, 0x26273526, 0x011f3637, 0x07355b83, 0x02a37b01, 0xa3021616, 0x0e13110c, 0x130e9595, 0x7a010c11,
0x05d952e2, 0x0e13e22a, 0xcdcd110c, 0x130e0c11, 0x2309ef50, 0x001600a0, 0x2c050352, 0x26210137, 0x21373627, 0x07161716, 0x2d058201, 0x68010706,
0x070fb0fe, 0x2f010a06, 0x1642e3fe, 0x230d8305, 0x1c01d2fe, 0x20260d83, 0x0b0e0d01, 0x6d836901, 0xfe210983, 0x37098397, 0x00000300, 0x0002e0ff,
0x1800a001, 0x2e002500, 0x23010000, 0x012b2627, 0x26126357, 0x1f323325, 0x47163301, 0x7b8305de, 0x15213522, 0xc0257382, 0x1a1331ac, 0x08dc4b76,
0x09878020, 0x7680fe34, 0xc03f0506, 0x60fe010f, 0x80010f01, 0x010f80fe, 0x0982a001, 0x132d6028, 0x1b121201, 0x3288c0fe, 0x09830020, 0x3b051026,
0x60200f01, 0x24822e82, 0x0fb0b027, 0x00000001, 0x299b8602, 0x00210095, 0x13000038, 0xcb4c3717, 0x0f062808, 0x22230601, 0x5326012f, 0x362705d2,
0x22171617, 0x56173133, 0x1523067c, 0x53011f16, 0x320807d9, 0xf4010f26, 0x201a0c0b, 0x21342321, 0x2f010121, 0x10100cb4, 0x012fb40c, 0x34212101,
0x19212122, 0x2d0b0101, 0x16233023, 0x1f010115, 0x011fb0b0, 0x82151601, 0x012f390e, 0x190c0c6c, 0x0a050a0a, 0x06362627, 0x0ba92c41, 0x412ca90b,
0x27263606, 0x0a391282, 0x202f5019, 0x1a1a0706, 0x1e2c0623, 0x2c1ea4a4, 0x1a1a2306, 0x2f200607, 0x31b38300, 0x02c1ff17, 0x00c00128, 0x0034001f,
0x1f160100, 0x40551602, 0x2f062206, 0x05065401, 0x3726272a, 0x36023f36, 0x07153137, 0x1d83c782, 0x1f363723, 0x05744201, 0x6d089882, 0x44070f20,
0x04050f99, 0x021a6f0a, 0x890c0d0c, 0x0c0c0c8a, 0x0a6f1b01, 0x9a0e0504, 0x350f0744, 0x56760d05, 0x6a150108, 0x14690b0b, 0x76560902, 0x0135050d,
0x8d0d01c0, 0x0e0e0217, 0x0e9c6e0a, 0x49060809, 0x09080649, 0x0a6e9c0e, 0x17020e0e, 0x4f010d8d, 0x11030b6c, 0x780c0955, 0x38060638, 0x55090c78,
0x6c0b0311, 0x00000400, 0x3a82c0ff, 0x1200c03e, 0x30001e00, 0x00004200, 0x07062325, 0x17140706, 0x32213316, 0x26353637, 0x07272627, 0x3620a882,
0x2005ee4e, 0x09b64521, 0x2507aa50, 0x31171635, 0x93501716, 0x82362007, 0x01270820, 0x314b6010, 0x09090232, 0x0e80010e, 0x32020909, 0x07df4b31,
0x60322323, 0x07232332, 0x36afa2fe, 0x01012425, 0x87362524, 0x07c84507, 0x8308d045, 0x05414f31, 0xa0294783, 0x011f2030, 0x30201f01, 0x83348bd0,
0x45d0203c, 0x078707e0, 0x00820020, 0xd3830320, 0x0100023a, 0x000e00c0, 0x003b0029, 0x37361300, 0x17151716, 0x2f060716, 0x013d2601, 0x86052c53,
0x070621b2, 0x8305604b, 0x373622b6, 0x0c475303, 0xe838d283, 0x02161602, 0x0d0c1255, 0x180b6013, 0x223a3948, 0x22010122, 0x48393a22, 0xd0280b8b,
0x583b3b02, 0x023b3b58, 0x01300787, 0x02021648, 0x0e397b16, 0x400c1213, 0x78870e06, 0x3f853391, 0x8b00ff21, 0x223e8336, 0x82080000, 0x02e034bf,
0x00a00140, 0x001c0011, 0x00320027, 0x00560044, 0x8279006c, 0x272232c9, 0x34352631, 0x32333637, 0x14151617, 0x37230607, 0x06735436, 0x15272622,
0x2f240a93, 0x31173201, 0x22212a85, 0x203a8527, 0x23449015, 0x31373603, 0x21054644, 0xf4831117, 0x27262133, 0x33112726, 0x21171611, 0x26113736,
0x07062127, 0x0bd05080, 0x16024823, 0x96e083e0, 0x8b482004, 0x250b8b2b, 0x12120180, 0xf643011b, 0x40fe3008, 0x0112121b, 0x010f0130, 0x01010fc0,
0x8240fe0f, 0x51002005, 0x20200b05, 0x2205f247, 0x90601602, 0x8b802008, 0x51a02027, 0x20200c3a, 0x88087f44, 0x40012269, 0x206284fe, 0x51628301,
0xc02c07eb, 0xc0010002, 0x40002400, 0x22010000, 0x25070d48, 0x27263507, 0x8e480706, 0x099e5a05, 0x27341137, 0x06032326, 0x30272623, 0x26313031,
0x35072227, 0x16333637, 0x056a4f17, 0x1137322e, 0x0a09dc01, 0x222a2943, 0x57323424, 0x0807d14b, 0x36364f2a, 0x30352e2d, 0x0b011440, 0x2d0c0f0a,
0x302a2d28, 0x12463f3f, 0x22283047, 0x3f343525, 0x1e04c001, 0x0e0d0202, 0x08220203, 0xfe21de83, 0x32058330, 0x02022268, 0x01020e0e, 0x01140918,
0x08080f2d, 0x8310c0fe, 0xf81c3823, 0x0d021d07, 0xfe1a020f, 0x000200f6, 0x01c0ff00, 0x00c00180, 0x5d1f0015, 0x3f230b0d, 0x5c161701, 0x262b059d,
0x07271127, 0x21333611, 0x5d111532, 0x0f33080a, 0x9090110f, 0x010f0f11, 0x140e0d01, 0x04019090, 0x5d071401, 0x503b0604, 0x08080913, 0x09085454,
0xb0011308, 0x010d0e14, 0x54543cfe, 0x06068e01, 0x460072fe, 0x012d051f, 0x00a001ff, 0x00260011, 0x1300003e, 0x0fb85a06, 0x915d2520, 0x27132613,
0x0f222326, 0x2b058501, 0x31303130, 0x21373611, 0x98111716, 0x830b9f5a, 0x2701248b, 0x521a80fe, 0x1a210522, 0x053d4601, 0x1c121133, 0x0a048910,
0x256b050a, 0x05090a05, 0x010f014c, 0x20b88280, 0x0fcd5a48, 0x48465820, 0x1b40210e, 0xfe2b4782, 0x0707ba87, 0x06062e90, 0x823f015e, 0xfe0f2234,
0x06e744c7, 0xbc01fc39, 0x1f001600, 0x52002900, 0x36010000, 0x1f323133, 0x14151601, 0x5906010f, 0x3f290744, 0x0f261701, 0x36371701, 0x3271822f,
0x013f3637, 0x07060727, 0x06171627, 0x07222307, 0x45111506, 0x3d230716, 0x5a373601, 0x2c430654, 0x363a0805, 0x33373637, 0x1d167501, 0x150c161d,
0x120dc515, 0x090a0e64, 0x0d051d03, 0x111043c5, 0x0e1d2e1d, 0x11ec0d0e, 0x8605063a, 0x0105862e, 0x02021604, 0x0b117016, 0x110b0c0c, 0x07821001,
0x1616022d, 0x19190102, 0x25f0fe25, 0x83011919, 0x01702509, 0x0c1515a7, 0xc5384e83, 0x041c060d, 0x640e090b, 0x22c50d12, 0x2e1d0e0e, 0x0c11101e,
0x01113ad0, 0x06214b84, 0x823b83cb, 0xf0fe2147, 0x70204f85, 0x46875b84, 0x83100121, 0x05c34109, 0x0002c02e, 0x1900c001, 0x46003400, 0x36130000,
0x21057d48, 0x1745010f, 0x08964605, 0x965c3120, 0x062d5805, 0x594d2620, 0x4125200c, 0xaf3a10f8, 0x302f1011, 0x0f0f1011, 0x0f0f2e2e, 0x2f301110,
0x0e0e1110, 0x0e0e2f2f, 0xf2445101, 0x86012029, 0x204b9133, 0x28714551, 0x860cf745, 0x063726e3, 0x2f223123, 0x05f54401, 0xef833220, 0x21053645,
0xc885010f, 0xf427e3a6, 0x090b0b09, 0x83080840, 0x6c2c2106, 0x08240583, 0x0c018008, 0x6c23dfa9, 0x85400808, 0x822c2036, 0x2109830a, 0xd8aa5480,
0xcf460420, 0x001a2b08, 0x003c002c, 0x0100005d, 0xbc820706, 0x5506df4e, 0x975405bb, 0x27262205, 0x0ef54d11, 0x35070623, 0x222c8222, 0x60171615,
0x372107a3, 0x05b94723, 0x3637362c, 0x17163337, 0x06010f14, 0x4483011d, 0x10823520, 0x26273425, 0x97000127, 0x0fac469d, 0x09090e2e, 0x090d1e02,
0x0d090a0a, 0x141e3321, 0x3305a75a, 0x16331302, 0x0c390b02, 0x02161602, 0x1401212d, 0xc0011f13, 0x21172c41, 0x3a4730fe, 0x0980250f, 0x021e0e09,
0x3305d045, 0x141301d0, 0x0202161e, 0x02021416, 0x23060c14, 0x16100d08, 0x02230d82, 0x8326161c, 0x0000236c, 0x2b470400, 0x0030250a, 0x007a0057,
0x4e06574e, 0xdd4705f2, 0x36172105, 0x25077a5f, 0x23222330, 0xfe831516, 0x14272223, 0x05265515, 0x59273121, 0x34830857, 0xf34d1620, 0x48058205,
0x05820518, 0x82363721, 0x37312401, 0x83310706, 0x4f062039, 0x7641066a, 0x07784107, 0x31272623, 0x0f9f48a0, 0xd1488020, 0x01200807, 0x01030101,
0x081b1212, 0x17160108, 0x3024c122, 0x303d3d30, 0x17232430, 0x04040c17, 0x2317170c, 0xc1301191, 0x1f282831, 0x0b13141d, 0x1d14130b, 0x3128281f,
0x13250f84, 0x140b0b14, 0x200f8413, 0x0f4649c0, 0x5b835020, 0x08247183, 0x12121b08, 0x01377082, 0x01171623, 0x171722df, 0x17170101, 0x23232122,
0x1c0c0c1c, 0x87222223, 0x22222111, 0x23321185, 0x13012121, 0x1d1b1e12, 0x1d17181c, 0x121e1b1d, 0x0f850113, 0x18171d23, 0x210f851c, 0x8b630000,
0x80023005, 0x1e00c001, 0x48003800, 0x74006600, 0x41130000, 0x172a123c, 0x27060716, 0x36372601, 0xaf5a031f, 0x07142205, 0x07db5517, 0x26272627,
0x31070627, 0x05584a17, 0x06233029, 0x14151623, 0x41021f07, 0x1d8305a9, 0x37213782, 0x0b644117, 0x34273127, 0x1f161735, 0x25228501, 0x2a219733,
0x3c41332b, 0x140b2a09, 0x10691d14, 0xfd130f0c, 0x2e0583b0, 0x232e2770, 0x24253631, 0x19360e01, 0x410a1212, 0x4c31072b, 0x0105cd36, 0x01221716,
0x07030101, 0x362a0952, 0x24418948, 0x1c26220f, 0x0764410c, 0xd4262e32, 0x38251138, 0x24361512, 0x01010224, 0x10111b63, 0x2a0a3c41, 0x1f201f19,
0x10130f52, 0x83d0010c, 0x582e0805, 0x011f241f, 0x36252401, 0x1a2a1b20, 0x18151b1b, 0x1e1b1d1c, 0x03011313, 0x100da02a, 0x01171721, 0x11070801,
0x2183400c, 0x1701021e, 0x6e412217, 0x2e242505, 0x181c241d, 0x30076641, 0x0403a010, 0x2d08212c, 0x25010105, 0x0a003724, 0x078f4b00, 0x27002235,
0x31002c00, 0x3b003600, 0x47004200, 0x53004e00, 0x61130000, 0x16200913, 0x210baa49, 0x2e613736, 0x33072508, 0x021d2335, 0x33210482, 0x21048715,
0x0a822337, 0x04821520, 0x35373624, 0x0b82012b, 0x16230482, 0x84353317, 0x90982617, 0x02161602, 0x11334928, 0x17832820, 0x82506821, 0x60802300,
0x06829060, 0x40220282, 0x0c84010f, 0x400f012d, 0x01606090, 0x02162880, 0x47281602, 0x19851383, 0x3838b824, 0x00844030, 0x3838682c, 0x0f0138d8,
0x28383828, 0x0a82010f, 0x00003823, 0x28eb8202, 0x01ff01e0, 0x002400a0, 0x0cd3443f, 0x3d640620, 0x21d68306, 0x9a4b3316, 0x27262105, 0x11230183,
0x82012f22, 0x3f36221c, 0x840e8401, 0x4c172020, 0xb544057c, 0x33023207, 0x0110100d, 0x0f07060b, 0x1723232e, 0x3a47322b, 0x05b44b39, 0x473a3930,
0x14172628, 0x090b2415, 0x0d0e140a, 0x7a44010c, 0xa001360b, 0x2f1c1b01, 0x35493a2f, 0x0115141f, 0x010e0e0c, 0x100f0e01, 0x3514850e, 0x1c2f2f3a,
0x90fe011b, 0x100e070c, 0x1c16130d, 0x17180e16, 0x1e624420, 0x0200240a, 0x85ffffff, 0x001822cb, 0x1a414f29, 0x8e581320, 0x06494f07, 0xbf011127,
0x1a1330ac, 0x0e3c4f77, 0x1c12112b, 0xfe0f0110, 0x01010f80, 0x06434f0f, 0x354f0120, 0x09d84a16, 0x013b0525, 0x8200ff0f, 0x0813457c, 0x00002b24,
0x71840725, 0x11272626, 0x37363736, 0x16267586, 0x35231517, 0xe64f2726, 0x82112006, 0x16212b18, 0x02071617, 0x1509603d, 0x8b8781fe, 0x131a7624,
0xa14b8c31, 0x3fa03906, 0x0f760605, 0x14094701, 0x09128c01, 0xc0b20709, 0x12010111, 0x40011b12, 0x13212083, 0x250b832d, 0x010f2020, 0xb682053b,
0x828ee021, 0x0e0e221c, 0x089f4511, 0xa0010032, 0x1d001200, 0x33002800, 0x16130000, 0x17161117, 0x98897082, 0xb94c1720, 0x16172709, 0x23070617,
0x11822726, 0x21200a84, 0x21270a83, 0x02021618, 0x83a00116, 0x60fe2805, 0x0114141f, 0x63681602, 0xd023063f, 0x83a80216, 0x84902017, 0x84802004,
0x84f02022, 0x0110252e, 0xfe1602a0, 0x16273484, 0x14140102, 0x6160011f, 0x1e8306e8, 0x16024822, 0x5805544c, 0xae82082a, 0x00030029, 0x02c0ff00,
0x82c00180, 0x003a22ad, 0x4ead8472, 0x22210629, 0x06e24e27, 0xcb443720, 0x20058305, 0x059d4203, 0x2705d444, 0x17160706, 0x07011f16, 0x36262683,
0x2517013f, 0x3a841716, 0x84075546, 0x83232025, 0x37362105, 0x33211382, 0x21238232, 0x0f821716, 0x86012f21, 0x27262652, 0x31273437, 0x076547d0,
0x171a1c36, 0x10292021, 0x010b0607, 0x2d0d0d0c, 0x3b3b0201, 0x15162b58, 0x080cc15f, 0x0c0a0a45, 0x02021017, 0x1a1a0304, 0x15011410, 0x02383854,
0x0d0d2d01, 0x070b010c, 0x20291006, 0x1c1a1721, 0x1a32313e, 0x2415181a, 0x16152c24, 0x1b1a1014, 0x02020404, 0x0a0c1710, 0x2901010a, 0x06013f28,
0x5b02c001, 0x063d063c, 0x010b0b0f, 0x0c0f0e01, 0x18100f01, 0x314b402e, 0xd6fe0232, 0x24250106, 0x25243636, 0x08078301, 0x13141a41, 0x041e190c,
0x08070604, 0xaa030911, 0x49313105, 0x10182e40, 0x0f0c010f, 0x0b01010e, 0x01060f0b, 0x042c1b1a, 0x11111c08, 0x11090306, 0x04070608, 0x0c191e04,
0x331a1413, 0x01062323, 0x51001719, 0x012d061f, 0x00bf0138, 0x00200015, 0x17160100, 0x077f4b11, 0x23061651, 0x010f3117, 0x27071651, 0x12250111,
0x950c0101, 0x230b0151, 0x1d1d1209, 0x29060251, 0x05bf015d, 0x0e7ffe12, 0xee504f07, 0x0310230b, 0xee503b7f, 0x01322206, 0x08c75d0a, 0xa001c028,
0x69003700, 0x75827c00, 0x68273621, 0x0726056b, 0x31302706, 0x72440726, 0x31302e05, 0x07161530, 0x17161706, 0x37323316, 0x05df4d36, 0x83363721,
0x27258201, 0x37263530, 0x31150627, 0x2f851f82, 0x21050d4e, 0x43822207, 0x36372624, 0x0f823635, 0x2d830782, 0x17321724, 0x41833716, 0x010f1622,
0x22065148, 0x87232223, 0xb801351c, 0x1305040b, 0x15181714, 0x3627210f, 0x093a3c36, 0x06040609, 0x1a231383, 0x8b0f101f, 0x092a3413, 0x07050201,
0x2a302f07, 0x1415252a, 0x120b1113, 0x850a050f, 0x20242512, 0x12141e21, 0x21081482, 0x0f120c10, 0x0e029e06, 0x0a232423, 0x02020c04, 0x2a0c030e,
0x050f2c29, 0x18152f01, 0x05131417, 0x5c820b04, 0x3a090929, 0x2736363c, 0x830f2001, 0x08192114, 0x1834128c, 0x15141310, 0x302a2a25, 0x0507072f,
0x06090102, 0x110b120f, 0x26281282, 0x24302a29, 0x02010b0c, 0x0c211385, 0x827c8203, 0x040b2865, 0x2a292c0f, 0x480e030c, 0xab500513, 0x000a2b05,
0x002b0015, 0x003d0034, 0xc3433700, 0x013b2108, 0x33200a88, 0x50058767, 0x363c0a5f, 0x21373637, 0x07062115, 0x26352115, 0x15211727, 0x36211716,
0x16a83537, 0x30160202, 0xc0200484, 0xd04c0583, 0x46982005, 0x402008a0, 0x32082b45, 0x0f40fec0, 0x01e00101, 0x20fe100f, 0xc0010f01, 0x4370010f,
0x078707d4, 0x46300121, 0x3027139c, 0x20200f01, 0x8290010f, 0x0f012331, 0x008200c0, 0x55000521, 0x08340703, 0x2a001d00, 0x40003700, 0x06250000,
0x36171607, 0x13272637, 0x2514de4e, 0x26210706, 0xc3823527, 0x15171628, 0x21232635, 0x0c860722, 0x37870720, 0xc6840120, 0x9021c483, 0x05d74efe,
0x1b121222, 0x8206e14e, 0x08e24509, 0x0f800129, 0xfe080801, 0x4e080880, 0x402005e7, 0x22059944, 0x88681602, 0x933820c7, 0x052046c7, 0x010f6029,
0x9e600f01, 0x83a20202, 0x56a22108, 0x82081c63, 0x860620d7, 0x00802cd7, 0x00330028, 0x004f003f, 0x8287007c, 0x273423d9, 0x03843736, 0x5f333521,
0x26250875, 0x07222327, 0x060d4c06, 0x4e06dc60, 0x262005fa, 0x33202d82, 0x2405d541, 0x3d362722, 0x370b8601, 0x26353435, 0x30333035, 0x35053331,
0x36013f34, 0x17323337, 0x14011d16, 0x2b05436a, 0x2726013d, 0x14150706, 0x06171617, 0x14290582, 0x14070615, 0x26272617, 0x45048227, 0x012407ef,
0x02200240, 0x38370282, 0x0114141f, 0x1f141401, 0x322a1ac4, 0x0c141518, 0x2802121f, 0x83683d29, 0x42282016, 0x2020090f, 0x05240a84, 0x80300904,
0xb0300983, 0xfeb00101, 0x0c1f0c78, 0x0b113217, 0x0c08080c, 0xfc830382, 0x160e0f2c, 0x03270203, 0x15152104, 0x28839001, 0x04843820, 0x090a2824,
0x03832914, 0x83040421, 0x2c5b836a, 0x0c0c011f, 0x241f3815, 0x27283b6c, 0x41148302, 0x975d0870, 0x130f2205, 0x2f08840c, 0x01020328, 0x176cc402,
0x01133815, 0x54110b0c, 0x6e826882, 0x56833420, 0x13193433, 0x0b090913, 0x01010607, 0x0a0c2f12, 0x22181808, 0x0981415c, 0x310f7f41, 0x007f0050,
0x0500008a, 0x36373633, 0x2f343537, 0x6a572601, 0x088a6305, 0x15143325, 0x86061716, 0x17162103, 0x26094a43, 0x14152733, 0x822b0617, 0x37363030,
0x39303533, 0x14313201, 0x011d1407, 0x82272623, 0x36132810, 0x26273435, 0x83353427, 0x415b8207, 0x8a41077c, 0x37342e07, 0x16013b36, 0x1d16011f,
0x06070601, 0x3545850f, 0x07061716, 0x68080123, 0x0228293d, 0x150b2012, 0x2a321814, 0x8a41c41a, 0x41382007, 0x0124059a, 0x101f1414, 0x3020e883,
0x20230484, 0x85050409, 0x01012209, 0x2a1183b0, 0x0c048cb0, 0x0302130b, 0x830f0e16, 0x058541f6, 0x110b0c2c, 0x1f0c1732, 0x1515010c, 0x25837c21,
0x2d058141, 0x28270220, 0x20246c3b, 0x0c0c1537, 0x84411f01, 0x04042507, 0x0a091429, 0x7a830383, 0x3c41b020, 0x0c502407, 0x83020f13, 0x0250250c,
0x28020301, 0xfe310983, 0x160b0be2, 0x01081211, 0x0b060602, 0x13130909, 0x05824119, 0x2d058e41, 0x0c0b1154, 0x15381301, 0x19216c17, 0x3a840818,
0x00233483, 0x56200006, 0x034306e3, 0x2201240c, 0x84272607, 0x35232303, 0x465d2726, 0x42152005, 0x1f2205b0, 0xde6a1601, 0x24188405, 0x16373607,
0x23198217, 0x27352726, 0x14240a84, 0x012b2607, 0x232a0b86, 0x23062322, 0x31303530, 0x8c581335, 0x37342406, 0x55013b36, 0x2b28069e, 0x16070601,
0x37323317, 0x05823782, 0x16333229, 0x06373217, 0x82070607, 0x844e8204, 0x7801214d, 0x21169742, 0x97422037, 0x00012157, 0x416a7643, 0x0343107f,
0x35253006, 0x27262726, 0x010f2223, 0x1d060706, 0x61171601, 0x3525088b, 0x37363332, 0x21038616, 0x74413736, 0x07062a05, 0x07352726, 0x16373233,
0x8230821d, 0x30232a0b, 0x31340139, 0x3b321732, 0x059c4101, 0x23262528, 0x07060722, 0x07832322, 0x21065743, 0xf2511716, 0x06072d05, 0x2722012b,
0x36013d26, 0x3b36013f, 0x4f4e6c82, 0x05fe5c06, 0x42c00121, 0x1f210598, 0x36984238, 0x421e0121, 0xc8203298, 0x23057843, 0x15140c1f, 0x214e7843,
0x78430b20, 0x06d74a0e, 0xc001002b, 0x26001500, 0x00004300, 0x0ce25b01, 0x23068e44, 0x07060727, 0x27055362, 0x17141733, 0x15013b16, 0x13251085,
0x35333736, 0x08105c23, 0x23302d85, 0x3ef70107, 0x1ba40d09, 0x01011212, 0xc01b1213, 0x092f0883, 0xc10f0127, 0x0f01010f, 0x09090180, 0x85bf2f0e,
0x0f01230d, 0x26846060, 0x26861220, 0x01012f26, 0x01093e79, 0xff210e82, 0x23188700, 0xf9090de3, 0x01293983, 0x30020e00, 0xc009090e, 0x200d8580,
0x05c3470f, 0x20212889, 0x06f75120, 0x01c0012d, 0x001100a0, 0x002c0027, 0x51000041, 0x1621059f, 0x09076d17, 0xe38c3720, 0x72452120, 0x25272605,
0x35231533, 0x08874d01, 0x17161522, 0x3525cf82, 0x011d1617, 0x878a87e0, 0x54d12407, 0x48fc140d, 0x4020086e, 0x0f280983, 0x9090cffe, 0x0f011001,
0x2805774d, 0xc0160210, 0x024e0216, 0x0bde68c0, 0x7f222783, 0xb1470d54, 0x14fc270d, 0x5050310f, 0xd484b0fe, 0x010f402d, 0x02021668, 0x024e6416,
0x6a00fa02, 0xcf83087b, 0x22001528, 0x16010000, 0xe04f3117, 0x15212410, 0x59070621, 0x46480893, 0x0a475d09, 0x210ce658, 0x818da001, 0x2005ab4d,
0x20ba8730, 0x21848201, 0x7c850300, 0x00800128, 0x00240015, 0xcf510032, 0x16212106, 0x21050864, 0xdd560706, 0x15332a05, 0x32331617, 0x2635013f,
0x21838227, 0xa949021d, 0x06072605, 0x012f2223, 0x8a658300, 0x8380208d, 0xad3026fe, 0x11131310, 0x416b82ac, 0x058205c5, 0x241e8e25, 0x858d1f24,
0x0df94184, 0x16000137, 0x8e0c0c8e, 0x02020e17, 0xac54010e, 0x0f01010f, 0x171775ac, 0x063f4e75, 0x4202c021, 0x532507b7, 0x00005c00, 0x06d54125,
0x6d011d21, 0x352108f9, 0x0ab94234, 0xb9421520, 0x26032805, 0x2b263127, 0x44272601, 0xbd420515, 0x4235200a, 0x288506e2, 0x3637362c, 0x2627013b,
0x16373627, 0xd2420617, 0x1ba32305, 0xa1831213, 0x2008d142, 0x339283c0, 0x0e090980, 0x11069230, 0x03291710, 0x16160f0f, 0x29030f0f, 0x21071b42,
0x21836060, 0x21821020, 0x160d3d26, 0x9e3e1b15, 0x03830e83, 0xe542f920, 0x581c2006, 0x1b2005de, 0x2b09e442, 0x0e30010f, 0x01c00909, 0x0e0d1560,
0x0e280282, 0x1201150d, 0xf0fe1b12, 0x30245283, 0x10010f01, 0x20820282, 0x0d0d1625, 0x850f0118, 0x0024084e, 0x00040000, 0x01c0ff10, 0x00c00170,
0x002d000e, 0x00560044, 0x1f141700, 0x33171601, 0x36013f36, 0x15233537, 0x2a099c59, 0x31141716, 0x30333130, 0x82353031, 0x543720e4, 0x1e8505a7,
0x4d512320, 0x093e5105, 0x59062721, 0x288505d2, 0x3c082a83, 0x0a120570, 0x0a103e10, 0xa0010412, 0x31304e50, 0x0d2b0101, 0xa008100f, 0x0d0f1008,
0x3202012b, 0x0c604b31, 0x5e0b0d0d, 0x0c0d0d0b, 0x2101011f, 0x24373c21, 0x1f010125, 0x16172270, 0x22b18401, 0x83140e0d, 0x0a063ab7, 0x010d1a08,
0x081a0d01, 0x0127270a, 0x333203c6, 0x0f304447, 0x01191a19, 0x3d048201, 0x4a452f0f, 0xfe023132, 0x14140efc, 0x14141616, 0x3030250e, 0x01022627,
0x30362424, 0xd882b425, 0x820f2221, 0x0e14224d, 0x4453840d, 0x012105c7, 0x32ff82c0, 0x00360024, 0x01000040, 0x16171615, 0x1f161517, 0x42071601,
0x3f2105ad, 0x069e6d01, 0x2008275d, 0x29198231, 0x15070631, 0x26210714, 0xfa83013d, 0x4a132321, 0x352606a4, 0x38000133, 0xdc822423, 0x06090f31,
0x70fe0f07, 0x0906070f, 0x01012b0f, 0x56382324, 0x22080583, 0x1d1e2c28, 0x30012801, 0x1e1d0128, 0x1348102c, 0x131a1a13, 0xa0018013, 0x29290a12,
0x3746213a, 0x820d0c13, 0x0d0d2d9b, 0x4637130c, 0x29293a21, 0x090e120a, 0x0e210082, 0x252f8340, 0x3d3d4a21, 0x4183214a, 0x82a0fe21, 0x553c8236,
0x1c280c47, 0x55003e00, 0x81006d00, 0x3622c782, 0xc7823337, 0x06230383, 0x82152307, 0x27262303, 0x03822335, 0x35201782, 0x2005b15e, 0x441c8215,
0x33231014, 0x82373635, 0x11172222, 0x82f58233, 0x830b822f, 0x23068336, 0x05232726, 0x820aef6a, 0x16152952, 0x23113317, 0x13310706, 0x16213685,
0x20728317, 0x22288211, 0x82110706, 0x100f2ae4, 0x0f18010f, 0x180f0101, 0x250a8901, 0x14141f70, 0x154a5801, 0x10fe2107, 0x58290987, 0x1f141401,
0x165848b0, 0x05dc4902, 0x02240585, 0x50fe5816, 0x2282108e, 0x0140a022, 0x27069876, 0xb0160240, 0x60010216, 0x7185668f, 0x54836020, 0x04830820,
0x87e0fe21, 0x20012168, 0x08200983, 0x80220483, 0x144db0fe, 0x02302906, 0x28021616, 0x28180216, 0x0d840883, 0x56826820, 0x16025029, 0x1440c8fe,
0x83010d0e, 0x0140246f, 0x82021688, 0x00782311, 0x67790003, 0x00182707, 0x003b002e, 0x25413700, 0x37362107, 0x41057641, 0x26220575, 0x0b5f012f,
0x40c82121, 0xc8825583, 0x89021621, 0x53c82009, 0x0983090e, 0x26059445, 0x010f0130, 0x45010f40, 0x68200572, 0x3b84318e, 0x7855f820, 0x0fac5e11,
0xff590220, 0x5a00200c, 0x02212cbb, 0x17795900, 0x20117960, 0x17f559c0, 0x2010de60, 0x060b5800, 0xc0010036, 0x2b001900, 0x58003d00, 0x00006a00,
0x31373625, 0x17363736, 0x7905f050, 0x27290be2, 0x06310714, 0x26272223, 0x251f8227, 0x16173233, 0x2b833315, 0x8308c560, 0x06172119, 0x4406d35a,
0x3623099b, 0x83171637, 0x11775c01, 0x00012908, 0x0b14131c, 0x0d0f1111, 0x281d1c11, 0x111c1d28, 0x1111100e, 0x1c13140b, 0x0e090930, 0x0109090d,
0x0d090901, 0x6009090e, 0x15860786, 0x0e41d020, 0x01602929, 0x0f0d0a0a, 0x1212100e, 0x28057e45, 0x0e101212, 0x0a0a0d0f, 0x0cdb7101, 0x200bde60,
0x29404130, 0xd3410520, 0x0a3f4108, 0x37263722, 0x20061e41, 0x06477b17, 0x07062722, 0x27220182, 0x3f413731, 0x1490394f, 0x22230e05, 0x23222c2c,
0x1514050e, 0x1615070a, 0x15161f1f, 0x40150a07, 0x26473e41, 0x25150a31, 0x82161615, 0x050a2204, 0x08f15f14, 0x62bf0521, 0x3c41171b, 0x0843452a,
0xc001002d, 0x23001100, 0x49002e00, 0x5b005b00, 0x534205f9, 0x4133200c, 0x07201037, 0x4a099052, 0x045e0530, 0x11ac7b14, 0x47429020, 0x41e0200d,
0x28200d26, 0x20098156, 0x296142b8, 0x0b41f020, 0x08e87417, 0x640c6564, 0x00231c71, 0x820d0000, 0x02003e03, 0x00800140, 0x00210014, 0x003b002e,
0x00550048, 0x006f0062, 0x0089007c, 0x00a30096, 0x163b7fb0, 0x27089558, 0x11171621, 0x07062325, 0x2806144b, 0x33172726, 0x26353736, 0x21128527,
0x0c97013b, 0x338b3720, 0x40bf0520, 0x408b0720, 0x64000221, 0x3a640526, 0x6410200d, 0x0f2b062e, 0x010fc001, 0x0b187cfe, 0x840b0101, 0x89382004,
0x9450200a, 0x8968200a, 0xc0fe2115, 0x3c2537b5, 0x01010fe0, 0x2104840f, 0xca4a8001, 0x121b230f, 0x1b4c0112, 0x00012105, 0xff222683, 0x9a86e800,
0x30206c82, 0x09930a89, 0x50201e8a, 0x582334b3, 0x83100f01, 0x4c048273, 0xdb670653, 0x00222205, 0x243b5c2b, 0x17160328, 0x11373621, 0x145c1121,
0x05d5461e, 0x5ca0fe21, 0xa1542100, 0x00012205, 0x208f82ff, 0x08f34403, 0x8f821020, 0x91823d20, 0x631f3621, 0x2725067e, 0x34013d26, 0x2d7a6237,
0x0d0cbc2c, 0x900b0b90, 0x0c0c0c0d, 0x74434401, 0x2d013129, 0x07580807, 0x58080d0d, 0x0e070606, 0x6d070db1, 0x2029b545, 0x0a474800, 0x20000a27,
0x00002d00, 0x094f4425, 0x4d05fe46, 0xb14d103a, 0x06212808, 0x16380107, 0x53160202, 0xfe200537, 0x21213148, 0xa35a02d8, 0x48882006, 0x9b8b2125,
0x2f001926, 0x00003c00, 0x6019ff62, 0xaa9c05f2, 0xf562d420, 0x48d42013, 0xeb6220e4, 0xa2f42012, 0x05e348bc, 0xbf014030, 0x45002200, 0x27010000,
0x1f060726, 0x05822301, 0x2c075b79, 0x013b3637, 0x16170607, 0x013f3217, 0x05f04d36, 0x23061526, 0x11272621, 0x36251882, 0x23272637, 0x14441822,
0x3523080c, 0x39022726, 0x0e101290, 0x3ea4640f, 0x02012c2d, 0x01021616, 0xa42c1d1e, 0x070e0f64, 0x9007090a, 0x82d10708, 0xfe072d11, 0x010107f0,
0x02163807, 0x18381602, 0x22053d43, 0x83100118, 0x02350809, 0x87310116, 0x10120e0e, 0x2d2c025f, 0x01165740, 0x2c581501, 0x105f1e1e, 0x07010711,
0x0a0a0887, 0x1502f107, 0x0601072f, 0x02070e01, 0x10021515, 0xf1fe1710, 0x22428517, 0x82182f17, 0x000021d2, 0x2a09bb63, 0x00240011, 0x0051003f,
0x7f072500, 0xc68205af, 0x0f161728, 0x31070601, 0x7c4d2227, 0x46441805, 0x2d094309, 0x9133012d, 0x04090a10, 0x910d0538, 0x830a0a0f, 0x49342007,
0x0a250801, 0x0e0a0909, 0x12b36a01, 0x2d177f6a, 0x0a04387b, 0x0d910f0a, 0x09043805, 0x0782100a, 0x91696520, 0x2a2c430c, 0x2009734b, 0x29fb820f,
0x01000031, 0x06070623, 0xe682011f, 0x2723fb82, 0x59372726, 0x11381956, 0x16213736, 0x40011117, 0x04080fc0, 0x0a086009, 0x0a60080a, 0x400f0706,
0x420bec50, 0x8d510757, 0x40013008, 0x0001010f, 0x0b0f0d01, 0x68080868, 0x510d0f0b, 0x94441502, 0x06984b06, 0x860ad343, 0x26132fa7, 0x010f2223,
0x17161706, 0x36373633, 0xa7a1012f, 0xa084f220, 0x0705092a, 0x070fc00e, 0x8e5f0a06, 0x1020a6a1, 0xad84a186, 0xa9519020, 0x93a68e13, 0x06072ba7,
0x17161507, 0x36013f16, 0xa7a33435, 0x0f0bc824, 0x7184010d, 0xb8207d82, 0x3222a4a1, 0xd282060a, 0x06061123, 0x0582410a, 0xa7a36e20, 0x6a000221,
0x1623079f, 0x52002700, 0x33250651, 0x16011f32, 0x0afd5b15, 0x23110128, 0x3d262722, 0xd3522301, 0x83002007, 0x1aa6245b, 0x47135a13, 0x502b0a52,
0x09090e50, 0x01010fa0, 0x8200010f, 0x1b802405, 0x82011212, 0xfe1b2221, 0x089653db, 0x80fe8028, 0x09092001, 0x6c52500e, 0x82002007, 0x88042000,
0x00152683, 0x00310026, 0x0ff1543c, 0x37362128, 0x34113736, 0x08540327, 0x17142d09, 0x11013b16, 0x33171627, 0x27263736, 0x17209782, 0x0d860382,
0x4a6d0125, 0x88b51b13, 0x84002073, 0x011d2487, 0x8200ff0f, 0xa00f2195, 0x4f247e82, 0x901602ef, 0x2006064a, 0x240887a8, 0x63011602, 0x20cf844a,
0x83ba84fe, 0x350125d9, 0x9dfe131b, 0x8022d284, 0xdf83020e, 0xa8e0fe22, 0x6007f05b, 0xfb700895, 0x00a02d0a, 0x00800014, 0x22231300, 0x011d0607,
0x322ca584, 0x013d3637, 0x27262734, 0x31272605, 0xfd59ab82, 0x07062405, 0x66300706, 0xee6705a3, 0x05b95e05, 0x6e163321, 0x0721052b, 0x82158206,
0x05fd670c, 0x21050667, 0x1c820706, 0xf06f1720, 0x15142805, 0x22230706, 0x8226012f, 0x065352f6, 0x34204084, 0x21062b5c, 0xaf4a4060, 0x08068605,
0x01a0013f, 0x641c1313, 0x2112130f, 0x070f0e22, 0x090c0c0e, 0x0816020d, 0x0e0e1f07, 0x05050506, 0x05050c0b, 0x030e0606, 0x118a1503, 0x14110102,
0x05050102, 0x06070e02, 0x03010105, 0x0c020102, 0x3404820e, 0x20283411, 0x16080625, 0x2d240a02, 0x131b3438, 0x011c0312, 0x2a028201, 0x0101011d,
0xdf0d0909, 0x8209080e, 0xde320806, 0x0109090d, 0x13131c24, 0x1b142701, 0x01011514, 0x22151312, 0x0806100f, 0x0502160e, 0x1219181a, 0x0108080e,
0x06070706, 0x06181514, 0x03011606, 0x75821011, 0x050b2f08, 0x03100904, 0x0c040502, 0x06040408, 0x1304040e, 0x02020203, 0x1b180211, 0x0b160205,
0x01201c08, 0x1a121101, 0x04052314, 0x08082314, 0x6b722414, 0x00a02d09, 0x007b0014, 0x34353700, 0x012b2627, 0x28097441, 0x35363716, 0x26353625,
0x05bb6627, 0x23272627, 0x06010f06, 0x05914615, 0x16013b25, 0x83151417, 0x1716230d, 0x56410706, 0x86118205, 0x07062609, 0x14070623, 0x08884117,
0x83262721, 0x83138701, 0x36172117, 0x34225d82, 0x06823327, 0x27263726, 0x0e090980, 0x240a6d41, 0x01016201, 0x3602821c, 0x1b131203, 0x242d3834,
0x0816020a, 0x28202506, 0x01021134, 0x820c0e02, 0x033a0804, 0x06060101, 0x05010e07, 0x14020105, 0x11020111, 0x0303158a, 0x0506060e, 0x04090c05,
0x18130705, 0x02160f17, 0x0c0b1609, 0x0e0e0907, 0x13122120, 0x131c640f, 0x1d010113, 0x6441e0a0, 0x82df2005, 0x012e0806, 0x3b0e0809, 0x14230808,
0x14230504, 0x0111121a, 0x081c2001, 0x0502160b, 0x1102181b, 0x03020202, 0x0e040413, 0x08040406, 0x0106060b, 0x58820e04, 0x03150b24, 0x1a821002,
0x06061523, 0x08fd821a, 0x06070722, 0x04050101, 0x1a1a3014, 0x080b1602, 0x12141412, 0x01100f19, 0x1b141501, 0x13012615, 0x14231d13, 0x08089b43,
0xbf01ff33, 0x43003200, 0x67005500, 0x27250000, 0x26273637, 0x2726022f, 0x27010f26, 0x0f060726, 0x06070602, 0x0607011f, 0x021f1617, 0x3f161716,
0x33161701, 0x05337332, 0x0f273629, 0x2f072702, 0x82273701, 0x82372015, 0x54172024, 0xfa5707bd, 0x6b152009, 0x01391005, 0x0b3030f9, 0x53140807,
0x1312050e, 0x11454511, 0x0e051213, 0x07081453, 0x23178d0b, 0x07080b0a, 0x64271988, 0x12535312, 0x873a3a64, 0x30c92407, 0x18011f1f, 0x21099440,
0x3158301f, 0x8b7b200f, 0x2f2f2158, 0x2f237095, 0x8703072f, 0x850e2088, 0x5254215e, 0x52220785, 0x5e83c454, 0x1f276684, 0x202e2f20, 0x58b00120,
0x1121055a, 0x20078201, 0x206f831a, 0x24008200, 0xff200002, 0x2b1a82e0, 0x002800a0, 0x2500003a, 0x23062322, 0x22055964, 0x42363736, 0x2221065d,
0x09884207, 0x84373221, 0x7a232017, 0xa2420913, 0x23063805, 0x0101a601, 0x31491111, 0x17010232, 0x01062a17, 0x0c090701, 0x7e3f090b, 0x1e2e0511,
0x3f32331d, 0x202d2d34, 0x06030304, 0x24834ba6, 0x3420203d, 0x2b010121, 0x201e442b, 0x32010344, 0x28304b31, 0x07041829, 0x01020206, 0x821e1e01,
0x323f2d2e, 0x011e1d33, 0x06271616, 0x02340506, 0x3a2a2082, 0x35132d2c, 0x39394c41, 0xc3460b17, 0x0014240a, 0x4e310021, 0x0329238f, 0x06010f26,
0x011f1415, 0x24c38216, 0x01272635, 0x20b74680, 0x00487e20, 0x48012009, 0x01212403, 0x07e14616, 0x07060a27, 0x070fc00f, 0x20008200, 0x08af4c03,
0x2c001124, 0x596c3e00, 0x52212013, 0xa0282bb3, 0x291b1b01, 0x011b1b29, 0x60200788, 0x2029b64c, 0x82388cc0, 0x29884948, 0x0b470620, 0x000c2d08,
0x00260019, 0x00490033, 0x13000061, 0x25057156, 0x26230706, 0xe15e3527, 0x066f5605, 0x19980720, 0x5619e24c, 0x33740b50, 0x01582507, 0x010f300f,
0xc0200484, 0x0c820786, 0x1594c020, 0x01e8fe27, 0x011b1212, 0x07504300, 0x0984ff20, 0x0f013023, 0x07385650, 0x4d4f5020, 0x20058205, 0x204c8958,
0x204c8910, 0x64159490, 0x80470937, 0xfe802409, 0x56010f80, 0x5b720a24, 0x000f2105, 0x07200082, 0x34082b41, 0x002f0014, 0x004b0043, 0x0065005c,
0x0500007b, 0x33353736, 0x081c7515, 0x16260b82, 0x22032117, 0xc2483127, 0x23152105, 0x29058757, 0x16011f32, 0x3523011d, 0x14770723, 0x5e232008,
0x362b059d, 0x26173337, 0x33152327, 0x82013f36, 0x1716230b, 0x4e841716, 0x27262323, 0x07655135, 0x18371521, 0x210ca442, 0xff570706, 0x40012105,
0x290c035d, 0x010f0130, 0x090e4000, 0x1686a009, 0x131aa628, 0x5030135a, 0x7b4c18a8, 0x08182f05, 0x010f0f01, 0x18180f01, 0x08081602, 0x2f820216,
0x80531820, 0x0f182407, 0x83082001, 0x9008211c, 0x20210583, 0x85058420, 0x1030252f, 0x20200f01, 0x84078041, 0x4930201a, 0x80200557, 0x26087749,
0x01402025, 0x8318100f, 0x233a8469, 0x38010f80, 0x02226182, 0x48822816, 0x140e0d22, 0x24055541, 0x0170800f, 0x21b4820f, 0x59838060, 0x04832020,
0x1f823020, 0x2d820f20, 0x20075743, 0x05bf7401, 0x49128b5e, 0x26221999, 0x1d460627, 0x011f2705, 0x3f361716, 0x05841701, 0x26273622, 0xa0491582,
0x07783c22, 0x18071010, 0x1416091a, 0x11063005, 0x19190710, 0x06111007, 0x16140530, 0x49181a09, 0xc82b25a7, 0x0f01010f, 0x05144e46, 0x83901609,
0x4848210a, 0x90260583, 0x14050916, 0x3344464e, 0x20dbb308, 0x05f14e07, 0x5d060721, 0x05830568, 0x2f363724, 0xdd823701, 0xdba20720, 0x25256a34,
0x0c10130f, 0x100c2d2d, 0x080b0707, 0x0b082526, 0x0f850708, 0xa50f1321, 0x30d730db, 0x0f0c1030, 0x13393913, 0x3009050f, 0x85050930, 0x100c210b,
0x0420d783, 0x200c4f4b, 0x06a34f39, 0x4b10247c, 0xcc53134f, 0x37362205, 0x8e481835, 0x23172208, 0x08a55535, 0x8729dba2, 0x02010f48, 0x2c021616,
0x28048222, 0x1f161704, 0x0c2c2c04, 0x20008208, 0x23d8a50c, 0xa80f01e0, 0x2805fd7c, 0x1e231718, 0x68011313, 0x05a56438, 0x2210274c, 0x4c4e003c,
0xda762927, 0x17063208, 0x32013b16, 0x012f3637, 0x32272326, 0x35363137, 0x05745e34, 0x17141524, 0xe0a23316, 0x0407782f, 0x07040c28, 0x042f0408,
0xc4070404, 0x23058208, 0x5708034b, 0xa50b1d56, 0x069c29e9, 0x0606123c, 0x07080746, 0x70220282, 0x54180406, 0x00200c6a, 0x2a090746, 0x002a0015,
0x0034002f, 0xa24b0040, 0x353322ef, 0x052a5f33, 0x70031121, 0x35230748, 0x82072315, 0x361722f6, 0x20f58237, 0x05765c07, 0x06171622, 0x221ea942,
0x82304030, 0x9f4f2291, 0x2f008340, 0x1213051f, 0x12131f1f, 0x20101f05, 0x0f01010f, 0xe69f0484, 0x4d101021, 0x0124052f, 0x40202060, 0x752a0282,
0x0116161e, 0x1e161601, 0xc3449075, 0x010f2105, 0x43067351, 0x39220883, 0xe3a25800, 0xfb4d1420, 0x07795605, 0x6b481720, 0x07262206, 0x4be68317,
0x302105d2, 0x240b8231, 0x30373233, 0x08cc7237, 0xa020f09e, 0xa32dee83, 0x010b2c24, 0x242c0b01, 0x01060706, 0x23048201, 0x0209093f, 0x8205a05a,
0x06052c06, 0x05010507, 0x02010b0c, 0x82020d0d, 0x242e4e06, 0x0124bc3a, 0x010b380b, 0x03030525, 0x03088808, 0x0b010603, 0x0e0e010b, 0x0f0e1718,
0x052c0982, 0x13060105, 0x14221e13, 0x0a0a0114, 0x20106f45, 0x290d4148, 0x31273422, 0x260c004d, 0x3d363732, 0x4e161701, 0x0f22067b, 0xdb423501,
0x095f2422, 0x42600e09, 0x068305c9, 0x06072c23, 0x20028207, 0x1fe8412c, 0x2005e641, 0x823889a0, 0x1f112746, 0x08040304, 0x05820866, 0x5b701f20,
0x01c02b07, 0x00c00180, 0x00260010, 0xd9820037, 0x0f263723, 0x05615201, 0x64063c45, 0xf44f1202, 0x066b4c14, 0x3f32333a, 0x012f3601, 0x0ea20726,
0x0c0c300e, 0x08080630, 0x220c0c06, 0xcb0b0b22, 0x2020ff4f, 0x21288371, 0x32830c0c, 0x0e223a83, 0x4082be0e, 0x06284682, 0x220e0e06, 0xa50e0e22,
0x20230850, 0x222b85be, 0x84300606, 0x05b34380, 0x82000221, 0x05bb68e3, 0x56004b30, 0x00006800, 0x06071625, 0x0706012f, 0x4c542726, 0x27262205,
0x3ae98236, 0x011f3637, 0x17163736, 0x16173637, 0x1716010f, 0x27170706, 0x27222306, 0x82171607, 0x8237201e, 0x1516232c, 0x0b820714, 0x82273121,
0x3336231a, 0x13821732, 0x26033125, 0x82373435, 0x17162210, 0x1851823f, 0x380e3347, 0x0f0fd001, 0x440c1110, 0x0c445f5f, 0x0e0e1111, 0x0202390c,
0x0e0e0c39, 0x23138711, 0x0b0f0f10, 0x0b351383, 0x1b1b169f, 0x4b365016, 0x9f50364b, 0x0d502c01, 0x012c500d, 0x860c82d0, 0x84532016, 0x20188210,
0x080b5c53, 0x2106a45f, 0x43881111, 0x5c206b9d, 0x56894288, 0x6a87d020, 0x89fffe21, 0x7c61207f, 0x13440f25, 0x01ff3707, 0x001a00c0, 0x0022001e,
0x01000026, 0x06010726, 0x011f1615, 0x73471415, 0x375d080b, 0x0f273613, 0x03252701, 0x37071735, 0x01033727, 0xfe0d0df6, 0x0e010c30, 0x05050d99,
0x636f0607, 0x06060504, 0x0340020a, 0x68bb850c, 0x2f9a2301, 0xe1b1be2f, 0x08bc0130, 0x08f8fe07, 0x40060f0e, 0x03070e72, 0x02294704, 0x010b0603,
0x73090fb0, 0xfea62bd1, 0x1e1331bb, 0xfefa4a16, 0x092348bc, 0x052c8b83, 0x37002000, 0x17370000, 0x07273733, 0x5e088e5c, 0xb26305f3, 0x27262309,
0x6a652713, 0x26073705, 0x36273727, 0x16371737, 0x06170717, 0x601fb107, 0x4e4f4e1e, 0x40183947, 0xec740995, 0xb4483d0a, 0x17161e68, 0x681e1617,
0x21550517, 0x53532a1e, 0x55211e2a, 0x5bdb1606, 0xe539395b, 0x3e10794c, 0x3a3a4747, 0xfe012223, 0x05630197, 0x26016305, 0x22623c2f, 0x123e3f13,
0x2f3c6222, 0x6e070026, 0xa02e0647, 0x2e001e00, 0x44003900, 0x5a004f00, 0xbf4d6f00, 0x82062008, 0x7f11209a, 0x5b180639, 0x13280b95, 0x06310714,
0x35362123, 0x2006d055, 0x09525327, 0x0a893320, 0x15930720, 0x52012f21, 0x232612f0, 0xd0fec801, 0x10481018, 0x02240805, 0x01021616, 0x011f1414,
0x19192560, 0x100f0101, 0x0b0c0818, 0x04e4fe11, 0x30010701, 0x40c80107, 0x16020216, 0x90200484, 0x08210a9f, 0x056a44c0, 0x01210686, 0x214d83a0,
0x4083c0fe, 0x83280121, 0xd8fe2b05, 0x0114141f, 0x25191901, 0x7f833001, 0x1198fe2e, 0x0d0b0c0b, 0x01074001, 0xd0fe0701, 0x6c08b15d, 0x897008bd,
0x51f0200f, 0xdb660dd2, 0x01802f08, 0x002100c0, 0x00400030, 0x1300004a, 0xb5643736, 0x011d2207, 0x08d86416, 0x50791720, 0x07c06409, 0x0607222b,
0x35073107, 0x33070617, 0x0e581817, 0x17312107, 0x2208d564, 0x474424b8, 0xdc6405fc, 0x03072206, 0x09237958, 0xe526913c, 0x1e1d0113, 0x181d102c,
0x2f3e0d18, 0x3db12007, 0x070fe2fe, 0x2b0f0906, 0xe064e001, 0x39492207, 0x06c9640c, 0x2308e964, 0x0f450c0b, 0x3308fb78, 0x2cb31d72, 0x1e2c2132,
0x0f0e011d, 0x250b5517, 0x0130323b, 0x20050565, 0x06e964d7, 0xb7620320, 0x775a200c, 0xa6690ce1, 0x19b57c07, 0x3930033c, 0x32313001, 0x36371617,
0x30272627, 0x06070631, 0x16171415, 0x30313017, 0x13833631, 0x23060724, 0x42183130, 0xb27c07d3, 0x21013c29, 0x0e111117, 0x3435250e, 0x26252526,
0x0e253534, 0x1711110e, 0x17182021, 0x7c201817, 0x012e2ba8, 0x0d0e1720, 0x01251111, 0x33272501, 0x07832733, 0x0d11112a, 0x1917170e, 0x17192020,
0x260c9b7c, 0x00210014, 0x50630042, 0x252023ed, 0x2321ef84, 0x48ed8222, 0xfd82056d, 0xe787e982, 0x33173222, 0x305f209f, 0x10dd2b23, 0x1d0f0f11,
0x1c1d2726, 0x06831d01, 0x110e0e27, 0x13140e11, 0x2300820e, 0xc00f1314, 0x53591d9c, 0x83c22023, 0x1c1c2450, 0x8228281c, 0x845a8204, 0x83142058,
0x93688205, 0x82002017, 0x00043600, 0x02e0ff20, 0x00a00120, 0x002d0015, 0x005f0052, 0x37341300, 0x054d6f31, 0x14011d22, 0x7d08c36d, 0x352005cf,
0x6d086d72, 0x332a06da, 0x36272627, 0x16373637, 0x38642117, 0x07062205, 0x05b94911, 0x21272624, 0x1e530706, 0x17112105, 0x0cd54418, 0x0e090923,
0x05f94380, 0xa0240683, 0x0112121b, 0x83067755, 0xf020210f, 0x2605d54e, 0x58010f15, 0x6814160e, 0x01290684, 0x16140e0d, 0x0fa8fe0e, 0x2e118515,
0x01081530, 0x15150846, 0x08bafe08, 0x48200115, 0x60260cb3, 0x121201a0, 0x0449201b, 0xcc202109, 0x5a873687, 0x8fe8fe21, 0x1801245a, 0x83fafe09,
0x06012150, 0x00200583, 0x0a200082, 0x22089778, 0x61470036, 0x7f3106d5, 0xc300b600, 0xdf00d000, 0x32130000, 0x17163117, 0x22fd8233, 0x56171633,
0x15200576, 0x15290882, 0x07060706, 0x27262722, 0x21088223, 0x08822623, 0x43533420, 0x35262c05, 0x37363736, 0x37361531, 0x82222726, 0x3130241c,
0x82143130, 0x83252031, 0x1716280c, 0x35343736, 0x61312726, 0x17200c87, 0x06241283, 0x32171607, 0x25226682, 0x2e830706, 0x31323523, 0x250d8216,
0x26252726, 0x7da73527, 0x5c623320, 0x86232008, 0x2070857d, 0x215a8505, 0x5b832726, 0x65830520, 0x31353422, 0x163a0d83, 0x14403117, 0xca071010,
0x14101007, 0x0112121b, 0x12120b0b, 0x12010b0b, 0x16961b12, 0x010f2308, 0x01020c01, 0x0d03010f, 0x02014001, 0x0f01010c, 0x0f01030d, 0x190aca3b,
0x09ca0a19, 0x4b091a1a, 0x23870d03, 0x83b0fe21, 0x8201201b, 0x82012031, 0x08972331, 0x66a1450f, 0x46863020, 0x82792e21, 0x215f8632, 0x0b89a0fe,
0x854d0121, 0x2163837d, 0xae8dc001, 0x5e956a20, 0x50201688, 0x0224ac85, 0x20010c01, 0x2823a589, 0x836a0a19, 0x0a6a23b8, 0xd189c819, 0xe6851020,
0xe8820120, 0x18010f25, 0x41100e12, 0x67960a16, 0x86252521, 0x0f182146, 0x41833584, 0x0a89e020, 0xc4891020, 0x240aab55, 0x00280015, 0x0cbd4432,
0x2705c552, 0x26272635, 0x27260127, 0x3105dc47, 0x07062315, 0x23150706, 0x06252726, 0x37363507, 0xff820633, 0x2d0aac55, 0x381c28e8, 0x1201011b,
0xb5fe1b12, 0x43620104, 0x18583105, 0xc0010f10, 0x15010209, 0x07010f0b, 0x380b0257, 0x2b065e44, 0x12121cc1, 0x381b0101, 0x1be8271d, 0xfe260982,
0x01090275, 0x3582103f, 0x0f01c030, 0x01581810, 0x020b0904, 0x0f010757, 0xdb70380b, 0x821c200a, 0x003f25a5, 0x36331700, 0x8207ac53, 0x2726218c,
0x8d828b82, 0x15239e83, 0x18131716, 0x2009cb4a, 0x85af8315, 0x0ce76421, 0x53e04021, 0x10700658, 0x40402108, 0x0f21ca82, 0x88bb8360, 0x83088413,
0x060a642a, 0x0f011023, 0x089b7840, 0x30201c84, 0x90201985, 0x3a8dc083, 0x1985f020, 0x68820f20, 0xbf850020, 0x01800125, 0x822700c0, 0x003b26bf,
0x37361300, 0x05085421, 0x010f0623, 0x079e6a17, 0x27262122, 0x3524c582, 0x27013f36, 0x232ed282, 0x13312726, 0x012f2633, 0x06072207, 0x32823107,
0x15233536, 0x00331714, 0x50011602, 0x16020216, 0x522a0208, 0x08022a52, 0xfe210b83, 0x251184b0, 0x51512c01, 0x1182012c, 0x05b86431, 0x01515205,
0xb8030601, 0x14e00113, 0x5ca801b8, 0x1327057f, 0x52512e3e, 0x48133f2c, 0x132607bb, 0x51522c3f, 0x0f823e2e, 0x0798fe31, 0x01525205, 0x00010605,
0x1313221b, 0x8b001b22, 0x002627b7, 0x003a0030, 0xb4a20100, 0x0320da82, 0x1522b082, 0xbb823533, 0x36373523, 0x22b68237, 0x71011f16, 0xb39b050e,
0xa829d783, 0xe0011e51, 0x52521d01, 0x2306821d, 0xc001511e, 0xb499a883, 0xfe021634, 0x2b1e52de, 0x1e2b1313, 0x1f514452, 0x2b14142b, 0xa682511f,
0x20080f76, 0x270c826b, 0x22232726, 0x012b2607, 0x27200482, 0x8305c042, 0x1714219e, 0x445d9482, 0x013d2c05, 0x2f222722, 0x35272601, 0x82013f34,
0x24b28212, 0x16333736, 0x201d8417, 0x82c18234, 0x1716230b, 0x56743736, 0x30172205, 0x08974631, 0x22840720, 0x673d3621, 0x21080536, 0x79012726,
0x060d2315, 0x0e181305, 0x22120606, 0x12121b10, 0x011e2101, 0x23150c0c, 0x070a1502, 0x00820108, 0x01133824, 0xca50110f, 0x0f103805, 0x0b0e0201,
0x09040404, 0x04040f0e, 0x0304050b, 0x04120d08, 0x820f0d04, 0x0d0d222a, 0x08328416, 0x01012f2e, 0x011f1314, 0x01011b7c, 0x011a010f, 0x1b121201,
0x291b1d32, 0x1415184f, 0x1665140c, 0x0a070702, 0x1f010182, 0x134f170c, 0x0f2c100c, 0x90202582, 0x5a820483, 0x04020a26, 0x0a010105, 0x022e7482,
0x0c0d0203, 0x0b070801, 0x16161b82, 0x3484840d, 0x412b6c3a, 0x15141f82, 0x00020002, 0x01c0ff00, 0x00c001e0, 0x0069002e, 0x07220100, 0x24055071,
0x07062726, 0x052e4126, 0x3023262e, 0x06313031, 0x14070607, 0x1716011f, 0x220b3977, 0x82070617, 0x26232418, 0x4a26012f, 0x208205d6, 0x37323322,
0x55057475, 0x372305bc, 0x82151716, 0x86138909, 0x01440809, 0x07060698, 0x0a181213, 0x29291409, 0x1e0a0914, 0x08011415, 0x17162208, 0x1e521501,
0x212c2727, 0x02363751, 0x1f141401, 0x29280218, 0x3045223c, 0x0a0b0950, 0x1b0a0d0a, 0x01070303, 0x01161502, 0x010e0e04, 0x0f200886, 0x18831088,
0x01700125, 0x780e0d16, 0x7a2109dc, 0x08b58202, 0x181f2226, 0x11112057, 0x51373602, 0x14141fa8, 0x293df001, 0x32010228, 0x100d0a56, 0x1d0a0708,
0x16c90801, 0x98160202, 0x0d214982, 0x200983b9, 0x200983b8, 0x24138498, 0x0d02020d, 0x20098369, 0x0ab35fa8, 0x30008024, 0xe7797500, 0x010f2111,
0x27051954, 0x16170607, 0x0623011f, 0x24051e5e, 0x37333233, 0x05f54d15, 0x27262724, 0x01823534, 0x35200782, 0x22056552, 0x82223122, 0x23062d25,
0x3f362726, 0x36373201, 0x012f3435, 0x372c2482, 0x1f323736, 0x36331601, 0x012f2637, 0x240cdc79, 0x0e012307, 0x08be8362, 0x0c1f123b, 0x2f181415,
0x80101a2a, 0x13170d0c, 0x100c0813, 0x0a02190f, 0x0113131e, 0x1f151501, 0x01590203, 0x1415021b, 0x0218011f, 0x0101100b, 0x02010507, 0x2103010e,
0x03212221, 0x08ec8218, 0x0603a321, 0x0e920a06, 0x0d060703, 0x03ea0405, 0x01020e03, 0x0d10410a, 0x0c172f13, 0x1b010b20, 0x7963291b, 0x2e080dce,
0x0d042f13, 0x1923160c, 0x03010919, 0x1f1d1415, 0x08061514, 0x141e1623, 0x02300113, 0x06060117, 0x06050c01, 0x040d0d11, 0x010f0904, 0x82020302,
0x03163861, 0x0904030b, 0x0534040b, 0x07080912, 0x01550201, 0x050b0d02, 0x790f1317, 0x272405c5, 0x00011a1a, 0x04840082, 0x01000228, 0x00500080,
0x4d592500, 0x2f342d05, 0x012b2601, 0x17140706, 0x16013b16, 0x28054765, 0x22012b06, 0x16150607, 0x056b6217, 0x07060729, 0x27352726, 0x82272623,
0x36372601, 0x3f32013b, 0x05d15f01, 0x37262723, 0x08018236, 0x1f16332b, 0x02151601, 0x16160200, 0x0f760902, 0x0104f21b, 0xa10f0a0a, 0x080f111b,
0x0e0e050a, 0x0a0f6011, 0x9d04010a, 0x0a4e0608, 0x2a238301, 0x0f16953d, 0x1801010f, 0x82602418, 0x01320829, 0x23a20301, 0x01011819, 0xf3160f0f,
0x11771e32, 0x02165c74, 0x105c1602, 0x0115ab0c, 0x0b0a0f03, 0x1a161501, 0x0a0a101e, 0x030f0a0b, 0x083a0501, 0x1f830d0c, 0x2f012c08, 0x160e0e01,
0x04191923, 0x0202031d, 0x16231919, 0x01010e0e, 0x1f19aa29, 0x20000200, 0x2002c0ff, 0x5300c001, 0x00008900, 0x651f3213, 0x3328062a, 0x17161732,
0x14010f14, 0x22056b60, 0x82343130, 0x201382bd, 0x46138215, 0x604305c2, 0x3736220c, 0x200f8734, 0x05224236, 0x27353430, 0x37363526, 0x22353336,
0x07063107, 0xad431714, 0x05c14306, 0x2908eb61, 0x3536013f, 0x07262726, 0xe4432322, 0x0f062305, 0x09832701, 0x11eb3f08, 0x0c052f07, 0x0620040c,
0x08070b12, 0x021d0101, 0x19030a0d, 0x0b0e0505, 0x30010808, 0x2d22220b, 0x4c2f3f31, 0x0a080808, 0x02330909, 0x0a010703, 0x08080124, 0x2007100b,
0x020d0a04, 0x0c82012b, 0x171b0a2e, 0x19010217, 0x03011515, 0x1f070718, 0x33080782, 0x523d4b18, 0x2f2f3e31, 0x0202300f, 0x0116191a, 0x16150901,
0x14131a14, 0x070d0506, 0x011a1313, 0x0db81390, 0x07149c0d, 0x03040c06, 0x0d02018c, 0x03680b01, 0x0f826e82, 0xcc04032b, 0x011b1b2c, 0x08472b01,
0x3781820a, 0x01023107, 0x7b222407, 0x060c0403, 0x6a130107, 0x020e010b, 0x0304a502, 0x2c080d82, 0x24121330, 0x13020404, 0x0a0b2212, 0x15010152,
0x171e1f16, 0x01013847, 0xcc3d2525, 0x11280909, 0x0d1d0111, 0x1b10100c, 0x0f193617, 0x05d3700f, 0x01c00131, 0x000a00c0, 0x00430015, 0x0086007b,
0x68063700, 0x26220680, 0x0a893327, 0x35463720, 0x09397c07, 0x22072622, 0x4505a34e, 0x32220604, 0x6b4b3637, 0x17272106, 0x0726c582, 0x26012b06,
0x8641012f, 0x82362005, 0x82332023, 0x013d2820, 0x17163736, 0x18171415, 0x82084d62, 0x013b2614, 0x17161716, 0x20178233, 0x20708927, 0x050176d0,
0x0f012e08, 0x02010f40, 0x02020f0d, 0x2316690e, 0x1306050e, 0x14010b19, 0x141f1f14, 0x08110114, 0x12122201, 0x20164e0e, 0x0a6d2420, 0x201e2b09,
0x081a8201, 0x14171e31, 0x03041f13, 0x4f1f346d, 0x08070104, 0x1c090806, 0x03090805, 0x16150204, 0x04081002, 0x100d0e05, 0x050a0405, 0x0e070404,
0x0f040313, 0x8202170e, 0x05804661, 0x0f01a023, 0x8c768360, 0x1a572404, 0x740f0101, 0x3908080d, 0x020107a9, 0x171a1515, 0x101d6813, 0x20080310,
0x1e6e3223, 0xb7021415, 0x0615161e, 0x68290101, 0x050c0706, 0x260a0105, 0x05050606, 0x020216f8, 0x030d8316, 0x01050401, 0x38820a01, 0x0c020328,
0x1702010c, 0x6789606e, 0x00060036, 0x01c1ff20, 0x00c001e0, 0x003b0030, 0x0057004d, 0x00920087, 0x2a057746, 0x36370722, 0x26273435, 0x42072227,
0xc5420599, 0x22068206, 0x7d16011d, 0x163719b3, 0x07151417, 0x31302726, 0x0f223130, 0x37363701, 0x32373607, 0x8207011f, 0x23132449, 0x7c012f22,
0x32250515, 0x32333237, 0x28b78217, 0x0706010f, 0x33161716, 0x26298232, 0x37363336, 0x84321716, 0x7d668203, 0x26080cb6, 0x140b0d9c, 0x0b0e121c,
0x21131401, 0x0514131b, 0x2b160404, 0x0114141f, 0x0b133207, 0x2e1b010b, 0x4b4f3a2d, 0x82023231, 0x1c33081e, 0x1213015c, 0x13120202, 0x03154801,
0x070d0b18, 0x05180b06, 0x1602a913, 0x313d070f, 0xe1010237, 0x2e21294f, 0x69100209, 0x01010201, 0x01080709, 0x82143a10, 0x05093a08, 0x0f0f1002,
0x0d250110, 0x0b0d1e13, 0x10031d13, 0x32232307, 0x12120280, 0x084f8302, 0x0420012d, 0x45080113, 0x161c0605, 0x11110115, 0x2809151b, 0x15140101,
0x680f101e, 0x15111109, 0x24162350, 0x32320123, 0x131d6c4a, 0x83340113, 0x8438207f, 0xa4200804, 0x02021701, 0x01010591, 0x01129702, 0x0e021638,
0x0573087f, 0x1998fe05, 0x500d0724, 0x01100512, 0x122f9e82, 0x14040905, 0x0205040f, 0x0a020302, 0x82011522, 0x32032569, 0xb4012020, 0x67594689,
0x00022b06, 0x1a00c001, 0x46002c00, 0xe1515200, 0x2613252e, 0x27263127, 0x41091e5c, 0x2f240573, 0x07373601, 0x180b205c, 0x3b288c4e, 0x17160160,
0x02165822, 0x02161602, 0x0f07263c, 0x07130505, 0x50022323, 0x090e4040, 0x0e200082, 0x272cdc51, 0x16172200, 0xd0160201, 0x482a4e83, 0x0b020e52,
0x2c174b15, 0x54534020, 0x07fb4a05, 0xfb82c020, 0x3b001826, 0x00004400, 0x200d4576, 0x095d7627, 0x35332723, 0x771c8636, 0x162514bc, 0x16031517,
0x05766f17, 0x0216e023, 0x20708330, 0x87c28330, 0x18482009, 0x4d1da04b, 0xfe240547, 0x1602d8a0, 0x4a84368c, 0x4b18a820, 0x9f6f1fa0, 0x06ff4410,
0x36002d22, 0x2629d382, 0x33373627, 0x07061716, 0x20a28223, 0x21c89e15, 0x59512105, 0x83982006, 0x849020c2, 0x16182204, 0x23bd9a02, 0xa0fe1001,
0x4918be85, 0x01200883, 0x28200982, 0xc024b49c, 0x010f00ff, 0x83413582, 0x18252012, 0x220eca52, 0x59011f36, 0xbdab050a, 0x2e02013a, 0x11100f0f,
0x1110302f, 0x2f2f0e0e, 0x10110e0e, 0x10112f30, 0x822e0f0f, 0x7820cca6, 0x46912e85, 0x02480123, 0x4ddca716, 0xc02f085f, 0x0e00c001, 0x3a003100,
0x06370000, 0x1826012f, 0x2107365c, 0xd5ab010f, 0x1110d823, 0x20ca8440, 0x21ca835f, 0xcaa65870, 0x0f0f2829, 0x0e111040, 0x835f2f0e, 0x0170223c,
0x18c0ab98, 0x2f099b51, 0x001e0019, 0x00280023, 0x15160100, 0x010f0611, 0x0728c782, 0x35262706, 0x013f3611, 0x2b05a441, 0x11370131, 0x27011107,
0x13111711, 0x022b0983, 0x0e010a36, 0xb70908a8, 0x820b0ca0, 0x07a92f09, 0x0ba0b809, 0x78fafd0b, 0x90380178, 0x06823090, 0x0c089c33, 0x070fb0fe,
0x3d020340, 0x0807053c, 0x1050010c, 0x350c8206, 0x07053d3e, 0x012d7ffe, 0xe4fe2e1d, 0xfe301c01, 0x1e0130e2, 0x0f85e4fe, 0x0000002f, 0xffffff02,
0x01ff01c3, 0x001b00c0, 0x0bd1502b, 0x6d013b21, 0x33210548, 0x41571832, 0x06132407, 0x7e072307, 0x2125062b, 0x01111716, 0x09c36bbf, 0x06016025,
0x4f7d0606, 0x112e05d8, 0x01111c12, 0x9050a00f, 0x0f01010f, 0x05828001, 0x1201c03e, 0xe1fe1a12, 0x5412121b, 0x04030308, 0x1b12125e, 0x121a1f01,
0xa0fe0112, 0x3c3c010f, 0x20202582, 0x0f222582, 0x4345e0fe, 0x000a290b, 0x00300015, 0x13000042, 0x20137148, 0x059a5b2f, 0x26f15318, 0x0445c820,
0x16022205, 0x20088770, 0x172e6638, 0x0fd15318, 0x6c200121, 0x098909c6, 0x2e5aa020, 0x06997610, 0x11bf5318, 0x2c069743, 0xc0010002, 0x27000c00,
0x00003900, 0x0acf7501, 0x0121c8ad, 0x09496d48, 0x9b180b77, 0x21b8abc2, 0x237c0001, 0x82482007, 0x061121b3, 0x2106764d, 0x09822726, 0x3d262725,
0x56373601, 0x32200556, 0x35260782, 0x33220706, 0x46183130, 0x2c820737, 0x11272622, 0x15201e83, 0x36252583, 0x16171633, 0x36278317, 0xc0013736,
0x141f0c0e, 0x1e2d1614, 0x171f2d1e, 0x0109090b, 0x832a1b0d, 0x1012270c, 0x2a1d1510, 0x0b830101, 0x191d2c23, 0x07745121, 0x10182125, 0x83171211,
0x14163d15, 0x0f0b1f14, 0xb0fe9001, 0x060c0405, 0x0e0e0205, 0x03080102, 0x010b0607, 0x020c060f, 0x04240e83, 0x0df00803, 0x022b0984, 0xfe040b0d,
0x020216b6, 0x83900116, 0x04172405, 0x8405060b, 0x05062532, 0x0005050b, 0x2a064f44, 0x018002f8, 0x00750088, 0x8287007e, 0x272621e3, 0x0721c183,
0x83e98326, 0x05814703, 0x3621de82, 0x5d0e8217, 0xb0430816, 0x06232306, 0x0a82012f, 0x06820720, 0x23352327, 0x37363311, 0x82308333, 0x16172107,
0x03823382, 0x36013f27, 0x012f2627, 0x82058237, 0x26272328, 0x11823435, 0x84161721, 0x15332201, 0x2c2d8214, 0x05271117, 0x37362726, 0x07061716,
0x74411821, 0xfa700808, 0x2f1f1f0e, 0x231c1c23, 0x101d1d29, 0x110c0110, 0x070c0806, 0x2e1b1b01, 0x133a0a0b, 0x1a151301, 0x7c0b141b, 0x031c0304,
0x051a1604, 0x21040302, 0x0e09030f, 0x4a5a0a0f, 0x09124060, 0x1d174d3d, 0x11150404, 0x14181301, 0x1110110d, 0x020e1b0c, 0x09791102, 0x11110e0e,
0x050c0d36, 0x100d5605, 0x011b1b2e, 0x09370705, 0x86410d09, 0x010f36fe, 0x2105e04a, 0x09872002, 0x41016a08, 0x09171611, 0x04151604, 0x11131307,
0x0f130212, 0x19040904, 0x06010a19, 0x1b1c133b, 0x0b131213, 0x24040464, 0x1b120304, 0x1b030104, 0x020b030e, 0xc0510801, 0x0f0100ff, 0x0b031345,
0x03020f01, 0x0404060d, 0x1512240e, 0x08620f15, 0x0e0e1111, 0x050a0a36, 0x58050708, 0x190a020c, 0x02060419, 0x09090eaf, 0x01000101, 0x877a85e1,
0x010f2178, 0x240b2f43, 0x0038002a, 0x07974159, 0x6b263121, 0x272205c7, 0x9f410631, 0x5c078307, 0x21250517, 0x37363736, 0x076e6535, 0x16173528,
0x013f3233, 0x265e3515, 0x83352005, 0x4103871c, 0x0585057d, 0xee01153d, 0x200f100c, 0x05043b1f, 0x0f12110e, 0x0e11120f, 0x1f3b0405, 0x0c100f20,
0x18120112, 0x21079a4c, 0x49711e12, 0x88320805, 0x20282820, 0x1712a788, 0x0ba71217, 0x201f0f0f, 0x0606053b, 0x08080a0a, 0x06060a0a, 0x1f203b05,
0x010b0f0f, 0x0c0c091d, 0x032b1717, 0x0b0b0b04, 0x04820101, 0x2b03042a, 0x0c0c1717, 0xf7170f09, 0x2407f754, 0xfe0f17f7, 0x2df183e3, 0x1a1a71ab,
0x8aeaab71, 0x0d8a0f0f, 0x37840b09, 0x07050529, 0x08030308, 0x84050507, 0x090b3d37, 0x0007000d, 0x02c0ff20, 0x00c00100, 0x0020000e, 0x00320029,
0x0050003b, 0x2500005d, 0x25063051, 0x26373633, 0xa97f2627, 0x07824306, 0x16171626, 0x15230517, 0x35231b82, 0x87112726, 0x86152008, 0x182f2008,
0x7a14337a, 0x01290cf7, 0x17224010, 0x0f010116, 0x22aa82c0, 0x69221716, 0xf5710809, 0x10102109, 0x0f201a82, 0x7022058b, 0x1e88e0fe, 0x10243088,
0xe0fe0f01, 0x01252983, 0xa0010f20, 0x834b8201, 0x205c830c, 0x26461820, 0x6040240f, 0x82400f01, 0x8500201d, 0x85802007, 0x83c02006, 0x314e1826,
0x83fe200f, 0x05604627, 0x80fe0f3b, 0x06000000, 0xe0ff0000, 0xa0014002, 0x1c001100, 0x36002b00, 0x58004b00, 0x05057d00, 0x16413720, 0x5f25200b,
0x06230d69, 0x41171607, 0x27210542, 0x74198937, 0xd02021e4, 0xf188e987, 0x16600025, 0x84160202, 0x41e02004, 0xe0200d3c, 0x30201989, 0x1820bf7b,
0x20103c47, 0x070b4518, 0x3c413820, 0x8788200b, 0x74782015, 0x40182385, 0x112a0ba3, 0x3e002300, 0x63004c00, 0xe2620000, 0x18152011, 0x23100e61,
0x31070635, 0x89610284, 0x26112411, 0x5c373627, 0x17240591, 0x26370706, 0x20072165, 0x20178407, 0x2b308337, 0x00010706, 0x01191925, 0x25191901,
0x11250787, 0x0b0c0c0b, 0x47058511, 0x47381789, 0x17170d35, 0x171d481d, 0x47360e17, 0x202114a0, 0x20274827, 0x022e1520, 0x08a65618, 0x50012e22,
0x5c83548b, 0x56888020, 0xf0205c82, 0x3219a547, 0x0e192901, 0x190e0f0f, 0x204b0129, 0x12121213, 0x474d3720, 0x4d210736, 0x0c076938, 0x2d001426,
0x4e003f00, 0x180ced59, 0x4309657d, 0x33210831, 0x09887415, 0x17163325, 0x18362711, 0x5407635b, 0xde5406d4, 0x066a4208, 0xff400123, 0x09384200,
0x10220987, 0xcf4b0f01, 0x09402105, 0x2205f172, 0x59010f40, 0x2487082f, 0x5b422020, 0x4301200d, 0x10201e1e, 0x8205ee4d, 0x80fe225a, 0x0f7043a0,
0x51422020, 0xbf52180b, 0x001c290d, 0x00440031, 0x2500004f, 0x2324b284, 0x17160706, 0x1720d690, 0x21174844, 0x675d2623, 0x82072006, 0x21112309,
0x44892711, 0x43700121, 0xa020090d, 0x43104443, 0xc020171f, 0xf984a983, 0x010f2025, 0x89a0e001, 0x43682043, 0x18200708, 0x0121dd8f, 0x171a4320,
0x16172223, 0x26508301, 0x00010f01, 0x189800ff, 0x7409a150, 0x1b2b0bf7, 0x00002400, 0x36373613, 0x7c333237, 0x34340f1c, 0x31373635, 0x21171613,
0x21353736, 0x10080815, 0x03040d0c, 0x0ff64918, 0x28060222, 0x2705034b, 0x7f0160fe, 0x0207090f, 0x03258e8f, 0xfe0b0d04, 0x23cf82a1, 0x00c0c00f,
0x012d0082, 0xe0ff0000, 0x10000002, 0x00000a00, 0x06f75a17, 0x2726212e, 0x01160200, 0x020216d0, 0x1630fe16, 0x8305c35a, 0x0b2b470c, 0x3800222d,
0x00004100, 0x07222301, 0x6f011d06, 0x1620067e, 0x2008556f, 0x055f5335, 0x26273422, 0x20068a6f, 0x08bb6f11, 0xe0831120, 0x85012121, 0x17162dc8,
0x0ee0b001, 0x01300909, 0xe0221716, 0x20072541, 0x06434210, 0x8e707020, 0x29cd830d, 0x00ff0001, 0x010f0001, 0xe982e0fe, 0x09099025, 0x8710100e,
0x203e8435, 0x83128230, 0x83502050, 0x0ff2422c, 0x01b0fe22, 0x0f21f882, 0x2e418201, 0x01c0ff1b, 0x00c001e5, 0x2500007e, 0x18060716, 0x20078761,
0x220b8217, 0x8315022f, 0x22232306, 0xed56012f, 0x06072805, 0x013f2627, 0x84010f35, 0x200d8507, 0x05094e27, 0x85060068, 0x2105840d, 0x06843502,
0x0cbb7d18, 0x87491520, 0x4f0f2006, 0x65840610, 0x07012c08, 0x17363717, 0x0503e401, 0x211f0a05, 0x140d0912, 0x15040821, 0x49150815, 0x070e0e39,
0x17070a0a, 0x02161602, 0x0e111117, 0x8249390e, 0x04153516, 0x0d142108, 0x1f211209, 0x16070415, 0x4e49494e, 0x15040716, 0x11213990, 0x23378e11,
0x0305050a, 0x4208398f, 0x0a9a0815, 0x08030809, 0x12140d13, 0x161f1309, 0x4e140308, 0x1139542a, 0x17070711, 0x02021626, 0x0e172616, 0x3911110e,
0x144e2a54, 0x1f160803, 0x14120913, 0x0808130d, 0x15031416, 0x0315292b, 0x91081614, 0x0e0e213b, 0x03233b91, 0x8c0a0809, 0x2a29253d, 0x00150414,
0x55050b6d, 0x202807eb, 0x49004000, 0x00005700, 0x0a965118, 0x07063324, 0xba512726, 0x210a8906, 0x0f511703, 0x5e112005, 0x1127083a, 0x36272623,
0x82373337, 0x17163a03, 0x27330731, 0x22012b26, 0x1403010f, 0x3b163117, 0x36373201, 0x11211135, 0x07f549a0, 0x08905020, 0x46240222, 0x42059c5d,
0x0820077f, 0x46300e83, 0x5e1d1125, 0x91a6121d, 0x5e040313, 0x48130105, 0x27065542, 0x0f30e0fe, 0xd00f0101, 0x01280498, 0x16023777, 0xd0fe0216,
0x2008f043, 0x2a0f8330, 0x01011837, 0x041c3718, 0x6bfe1c04, 0x01250654, 0x00d0fe30, 0x09a34f00, 0x2e001428, 0x55004000, 0xe0440000, 0x18152005,
0x2a085d83, 0x26272635, 0x07061327, 0x18262723, 0x7409ce65, 0x21240529, 0x25151716, 0x11267918, 0x31832120, 0x84053a41, 0x17162645, 0x00020706,
0x08fa44fe, 0x50180120, 0x1030080c, 0x6d100f01, 0x05080905, 0x0805163f, 0x10490508, 0x0125d783, 0xfe010f60, 0x05c445d0, 0xe8260585, 0x2233b0fe,
0xef670122, 0x16502408, 0x60160202, 0x7e490528, 0x2b088408, 0x010fe0fe, 0x5e0707a1, 0x6107071e, 0x2007625f, 0x0b056fd0, 0x0190fe26, 0xf0332222,
0xf0233f83, 0x8414141f, 0x51002052, 0x802c086b, 0x1d00c001, 0x3f002600, 0x23010000, 0x18074149, 0x4709394e, 0x2f210806, 0x23d28301, 0x37362726,
0x21090f47, 0x14821d06, 0x37363335, 0x33273435, 0x01111716, 0x15063240, 0x151e1e15, 0x46320615, 0x802011f6, 0x03838083, 0xff469020, 0x02123407,
0x0fc00f01, 0x0f120201, 0x1c800101, 0x01011112, 0x451c1211, 0x48830f3d, 0xba451020, 0x70fe2107, 0x0f272a82, 0x010f4001, 0x83100808, 0x08102b0a,
0xfe0f0108, 0x000300c0, 0x3f4bff00, 0x00193105, 0x00460034, 0x27232500, 0x22232726, 0x17150607, 0x1f20cc83, 0x2106565a, 0x8c4f2627, 0x3858392e,
0x10160201, 0x0107070a, 0x06070f38, 0x0b07590a, 0x0a57070b, 0x580f0706, 0x4f17d348, 0xd0330f9a, 0x07021658, 0x01580a07, 0x600b0f0d, 0x0c600808,
0x48010d0e, 0xf9481ab5, 0x3b3b2208, 0x454a8358, 0x17240bff, 0x44003200, 0x3522db83, 0x21782726, 0x3633230c, 0xd9af3537, 0x918c6820, 0x0222a482,
0xd3a76816, 0x0c41e020, 0x0238260e, 0x02161016, 0x198b49e0, 0xd792d591, 0x07260125, 0x7f150706, 0x372005df, 0x2009e37f, 0x1c9a4a02, 0x854a3120,
0x07062c0b, 0x0e0c1801, 0x1657020d, 0x88160202, 0xa71820df, 0x2a0127d6, 0x0e07060a, 0xcd840138, 0x2506f041, 0x070b0b06, 0xd9ab9657, 0x41098b42,
0x012106af, 0x5b411826, 0x16172408, 0x74363317, 0x2f200516, 0x1125d7ad, 0x050c0b07, 0x289f8858, 0x0f380215, 0x580a0607, 0x20dba811, 0x067b4238,
0x1b415820, 0xab882009, 0x05003cd6, 0xe0ff0000, 0xa001ff01, 0x15001100, 0x1d001900, 0x00002100, 0x23262725, 0x700f2221, 0x3f2c0681, 0x012f3601,
0x07372317, 0x27073327, 0x46080782, 0x07212713, 0x0868fc01, 0x0bfffe0c, 0x0b096708, 0x0a0a07e8, 0x090ce807, 0x4d8c3f7d, 0x4e9c4e7f, 0x418c4b7e,
0x5601ab7e, 0x0b99fcab, 0x0e10990b, 0xf60808f6, 0x5f63100e, 0x6363525f, 0xfe5f5f52, 0x00b5b5bc, 0x82000400, 0x40022300, 0x77828001, 0x3c002624,
0x75825100, 0x81180620, 0x27210fda, 0x09d64d15, 0x26352323, 0x790d8427, 0x172015ba, 0x270ee745, 0x06070621, 0x01900107, 0x0a068518, 0x201f3025,
0x79088001, 0x0823085c, 0x83100f01, 0xf0fe220c, 0xcc6d1801, 0x121b2513, 0x60010112, 0x2107974a, 0x0983a0fe, 0x8218c020, 0x1f230d1e, 0x47402030,
0x08510806, 0x08104605, 0x200b3049, 0x08bc4b30, 0x002d0888, 0xff000003, 0x010002e0, 0x001900a0, 0x18ff822f, 0x181ac76a, 0x1822e346, 0x2018bd6a,
0x090d51af, 0xfe210983, 0x20d68380, 0x05da4a30, 0xfe0f0123, 0x58b58280, 0x6a18081d, 0x4f200fff, 0xb9452b83, 0x7e6e180f, 0x0657630e, 0xc001403e,
0x58000c00, 0x21050000, 0x17140706, 0x36213316, 0x25272637, 0x16311716, 0x35331517, 0x08e26418, 0x25057754, 0x06071716, 0xbd451415, 0x17162606,
0x0f060706, 0x74258201, 0xf082088c, 0x26273422, 0x52070461, 0x39080534, 0xeffe2801, 0x07070215, 0x17100109, 0xfe160202, 0x131201d8, 0x0c21301a,
0x02010909, 0x1a1b1717, 0x0f0e0a0c, 0x42060d0c, 0x050b0505, 0x36050706, 0x09010112, 0x30220b09, 0x0982131a, 0x1c121326, 0x02171c1b, 0x2106994d,
0x0d821702, 0x13122808, 0x15021001, 0x0208070a, 0xa0021616, 0x08191827, 0x030b4320, 0x2c160d0c, 0x21222f2f, 0x11110101, 0x420a1414, 0x82060705,
0x3605384f, 0x0d16202b, 0x430b030c, 0x18190820, 0x302f2627, 0x07172a2b, 0x82090e18, 0x180e2a00, 0x2b2a1707, 0x00262f30, 0x060b4100, 0x2005e758,
0x0c0b4140, 0x2321ce82, 0x22048237, 0x4d352327, 0x3524054d, 0x07062726, 0x6806dd42, 0x143d056e, 0x2733011f, 0x37343534, 0x14151621, 0x37330715,
0x88013536, 0x0116b0fe, 0x010a0706, 0x3106824f, 0x0b380a06, 0x1f901c11, 0x15020216, 0x1617031f, 0x09822001, 0x8f1f1632, 0x010f1018, 0x47334103,
0x08500108, 0x03423247, 0xdb83d686, 0x0f12f825, 0x83380116, 0x152121e1, 0x21203582, 0x38340983, 0x18100f01, 0xd6c70809, 0x01070101, 0x01010602,
0x0908c7d6, 0x2506b745, 0xa0018001, 0x7d514200, 0x06172306, 0x89821407, 0x3331302d, 0x013f3635, 0x07353736, 0x83010f06, 0x66232002, 0x272b0844,
0x37363526, 0x16171633, 0x82331517, 0x662620d1, 0x14250577, 0x011d0617, 0x24148214, 0x36171637, 0x20e88337, 0x0b154201, 0x1a0f2c31, 0x22023001,
0x0f011526, 0x04080208, 0x82050b0b, 0x82212000, 0x0b073d5a, 0x69090102, 0x022c2b43, 0x3a390230, 0x10196957, 0x05050110, 0x24140c0c, 0x02121202,
0x01230383, 0x42affe18, 0x51200504, 0x3b08fb83, 0x2820067f, 0x040d0e02, 0x17132820, 0x093b180b, 0x0c190904, 0x02020405, 0x7010080f, 0x17080608,
0x01090303, 0x432c2c02, 0x3a57c3c3, 0x1001023a, 0x0c0d1910, 0x16700e0c, 0x9d0a1212, 0x02235085, 0x42d4fe12, 0x002f0805, 0xff000003, 0x013e01c1,
0x000c00a0, 0x4150003e, 0x163d05c1, 0x37362117, 0x23262734, 0x14153327, 0x33070607, 0x33352736, 0x33170615, 0x3d262726, 0x05cd4101, 0x27202084,
0x2009a952, 0x05be6323, 0x3121ff82, 0x4f741816, 0xfe283d0d, 0x020215ef, 0x16100115, 0x0a060601, 0x050419f1, 0x0214350e, 0x35140240, 0x1804050e,
0x153bd482, 0x03012518, 0x190b0b02, 0x22322b19, 0x25020122, 0x07070918, 0x1f691502, 0x61011414, 0x07830720, 0x16020f22, 0x0a2f2d83, 0x1eb00807,
0x191e1d1e, 0x1e1e3839, 0x82193939, 0x011f3e0a, 0x22021617, 0x0a0f0e35, 0x13121615, 0x22220101, 0x07223632, 0x01170a07, 0x151401d0, 0x4a488b1e,
0xff2b082f, 0x1100c001, 0x6d005e00, 0x50010000, 0x342311ff, 0x8326012f, 0x220721d2, 0x8745e383, 0x6f062005, 0x2a5005cb, 0x07142205, 0x054e6706,
0x06010f32, 0x011f1415, 0x33162733, 0x37163130, 0x17163736, 0x2905f243, 0x33073732, 0x34353637, 0x0a420335, 0x345d0809, 0x01232627, 0x0f101800,
0x100f0101, 0x10101818, 0x10100101, 0x1c07ff18, 0x05090503, 0x0405180e, 0x030b0a12, 0x030a270a, 0x120d0d04, 0x040d0d11, 0x0d270a02, 0x1a0b0b01,
0x09040e18, 0x071d0404, 0x5d356c02, 0x1c060d0d, 0x2f1c171c, 0x14041d2e, 0x0d0d2914, 0x016c355d, 0x16b0fe57, 0x21f18202, 0x06865001, 0x67875f85,
0x010f2f08, 0x10050855, 0x01120702, 0x0e0e0401, 0x01010c12, 0x0b0a1109, 0x09110a0b, 0x100c0101, 0x01011111, 0x10020712, 0x04040805, 0x0204c4e3,
0xa5820808, 0x0923012e, 0x03021415, 0x0303e3c3, 0xf5fe0101, 0x23053242, 0x08070a15, 0x2905a34a, 0xa0018001, 0x4d000c00, 0xf5435a00, 0x27262d0c,
0x07222103, 0x14011d06, 0x1514011f, 0x07280182, 0x36330706, 0x34353637, 0x27240182, 0x33153335, 0x07200386, 0x17261d84, 0x26331716, 0x1d842627,
0x24069a78, 0x07220723, 0x23408231, 0x27343533, 0x68208682, 0x300cfe42, 0x0fccfe0f, 0x250b0b0b, 0x31080202, 0x30020207, 0x27018440, 0x31070202,
0x25020208, 0x11281982, 0x09090e99, 0x0e090940, 0x2a09e944, 0x0b0bb001, 0x0a0f8b10, 0x82070620, 0x22212d98, 0x22222b2c, 0x0c0c0b23, 0x3075290d,
0x75390082, 0x0c0c0d29, 0x2323230a, 0x21222c2a, 0x0508081d, 0x0f0a2005, 0x0b0b108b, 0x214582c0, 0x4e824040, 0x00820020, 0x974b0220, 0x00042a08,
0x01000009, 0x21112111, 0x2d038207, 0xfe000211, 0x30000200, 0xa00160fe, 0x0a88c001, 0x2a086348, 0x001100a1, 0x00350023, 0x1875005a, 0x20139586,
0x0f804d37, 0x8f172721, 0x27232111, 0x1809364a, 0x18345b6b, 0x2607f254, 0x08090908, 0x820e700e, 0x0d092306, 0x0c8a090d, 0x3605d445, 0x393a4770,
0x02012222, 0x10100d33, 0x05060a02, 0x23232e10, 0x85312c17, 0x22012215, 0x816b1822, 0x583a2f12, 0x023b3a58, 0x583a3a02, 0x0d0909f0, 0x54820a0e,
0x4c820e20, 0x09090123, 0x2066880e, 0x820d8401, 0x23138219, 0x01b10909, 0x07a86b18, 0x01151525, 0x180e0f0b, 0x2909a86b, 0x2f3a3a2e, 0x011c1d2f,
0x6b188ffe, 0x002019a8, 0x0fbb5618, 0x57003c24, 0x56186900, 0x17292dbb, 0x33363726, 0x07161732, 0x05cd6906, 0x41172721, 0xb259075e, 0x37362105,
0x56180183, 0x4a3140ba, 0x1f180b0c, 0x0d0c181e, 0x10090e0e, 0x0e0e0812, 0x17a24ae6, 0x7818ff20, 0x56181045, 0x172d25bc, 0x16160f0e, 0x0c0b0e0f,
0x0b0c0a0a, 0x173d4b19, 0x12fe5718, 0x42050021, 0x142e08cb, 0x47002d00, 0x74006200, 0x06250000, 0x2c5d2627, 0x09004105, 0x7a270721, 0x16270799,
0x012f0607, 0x45141514, 0x31200601, 0x099b5518, 0x07373422, 0x3f2d3982, 0x16173601, 0x1516010f, 0x37360531, 0x41028431, 0x06210542, 0x41018307,
0x5518055a, 0x013e1198, 0x0b101148, 0x110b1b1c, 0x0a0e0f11, 0x1a1a1213, 0x0d0b1312, 0x0901b80f, 0x06030d1f, 0x0483600e, 0x09090b27, 0x09090d0e,
0xb4551801, 0x0e0c2508, 0x600d0306, 0x1e230483, 0x4190fe09, 0x01201755, 0x3d105541, 0x0e0f0d36, 0x0f0e0202, 0x0c11110d, 0x0101090a, 0x110c0a09,
0x090e9a11, 0x0d0e060a, 0x04832003, 0x1e820320, 0x8207a842, 0x03022775, 0x0e0d0304, 0x04832006, 0x0e090a23, 0x2b624110, 0x290a6341, 0x002b0011,
0x00600045, 0x72180072, 0x2f2011dd, 0x20064161, 0xc9751816, 0x61332011, 0x1992055b, 0x592cb042, 0x5939109e, 0x17181011, 0x0f0f1011, 0x0f0f1616,
0x18171110, 0x0e0e1110, 0x0e0e1717, 0x201897c0, 0x176341d9, 0x5712b942, 0xd9200f20, 0x5a975b85, 0x79201791, 0x202a6541, 0x08c74209, 0x13000a30,
0x37002500, 0x52004000, 0x7f006400, 0x53189100, 0xb25e0cdb, 0x27262206, 0x08984223, 0x76079442, 0xc548058d, 0x17162509, 0x26070637, 0x33203084,
0x84119a4d, 0x17162211, 0x21358216, 0x34833736, 0x421a8a41, 0x402512ec, 0x16020216, 0x20048480, 0x0c245bb8, 0x8307ee53, 0x14502507, 0x01010d0e,
0x0a089418, 0x2aa9d820, 0x41183061, 0x6b1811a9, 0x6562086c, 0x24848b08, 0x22171601, 0x83848b30, 0x0f6b1894, 0x2029a008, 0x29c44150, 0x2e098b44,
0x00280016, 0x0055003a, 0x37000067, 0x18312706, 0x210f4e5b, 0x5b180722, 0xb3355148, 0x0307070a, 0x231b1b0d, 0x0d1a1b23, 0x09080704, 0x252c2c25,
0x0670441d, 0x40835c18, 0x05044f26, 0x121d0906, 0x1c280082, 0x0405060a, 0xa110010f, 0x91056947, 0x41302005, 0x00222930, 0xf7420000, 0x00132e09,
0x0020001b, 0x002d0025, 0x0051003f, 0x058f586c, 0x804b1720, 0x534c1806, 0x07332808, 0x17160706, 0x83233533, 0x37152503, 0x35331523, 0x2105435e,
0x5d181523, 0xd14523db, 0xdb5d181a, 0x4a582012, 0xb02007dc, 0xc0740888, 0x28082e05, 0x20602020, 0x16082020, 0x08160202, 0x1c654180, 0x5d18fe20,
0xd74518ea, 0x4aa02011, 0x20250fe9, 0x02161602, 0x84008630, 0x0635570b, 0x423f7741, 0x153009ab, 0x39002700, 0x66005400, 0x36250000, 0x07163117,
0x26081a4c, 0x16173637, 0x41373233, 0x3c442357, 0x1257411a, 0xbd825e20, 0x1f120831, 0x1f26261f, 0x0907131f, 0x322c0e09, 0x418e2c32, 0x44411c45,
0x110e4418, 0x09038c26, 0x111c0d0a, 0x1c270082, 0x03090a0d, 0x41640b0b, 0x1185112c, 0x412aaa42, 0x07302f2f, 0x35262726, 0x37363734, 0x15161716,
0x31373433, 0x694d0985, 0x41352006, 0x7e20422f, 0x200b4e58, 0x550c8b40, 0x2b4118f2, 0x46742022, 0x0f8f0ff5, 0xde434020, 0x0b334129, 0x78004726,
0xa5009300, 0x29186342, 0x31342331, 0x27263130, 0x5f492734, 0x056b4905, 0x0615062d, 0x30332215, 0x06312315, 0x4a352627, 0x142507cc, 0x31270607,
0x4130af33, 0x84214272, 0x24008201, 0x02020303, 0x2500820e, 0x03030202, 0x10830201, 0x0106052d, 0x18180f10, 0x0501100f, 0xa2a00306, 0x48862023,
0xcc422985, 0x834f2010, 0x03012c5f, 0x0c020204, 0x020c0101, 0x84030402, 0x01042f10, 0x151c0602, 0x15020215, 0x02061c15, 0x25a50401, 0xcc411b20,
0x0caf4c29, 0x4e001c28, 0x95006400, 0x2366c700, 0x37342107, 0x23050c74, 0x17363736, 0x2707f87d, 0x27312306, 0x17140706, 0x0df49118, 0x16272625,
0x18373233, 0x4c07f455, 0x06260da7, 0x22033107, 0x14823127, 0x82067a44, 0x0607254c, 0x27230607, 0x7f21ec41, 0x16210671, 0x051d4215, 0x3c304f42,
0x0e14d001, 0x0105010d, 0x080b0a07, 0x0e0c0606, 0x0a0a010f, 0x4907060f, 0x37010106, 0x0b3e5a4a, 0x0d190126, 0x150d0e0d, 0x2411c241, 0x02023d4e,
0x0bd14487, 0x4208e544, 0x01271812, 0x19170f11, 0x4204100f, 0x013e2536, 0x0d0d0140, 0x010a0814, 0x10101001, 0x0f06060a, 0x11101817, 0x02040c0c,
0x05120c4d, 0x7a182c07, 0x37250c46, 0x2f05042d, 0x12de4136, 0x05052826, 0x1111a4fe, 0x45061a45, 0xaa20062a, 0xa5252e42, 0x43002025, 0x2d260bf7,
0x5f004400, 0xf7437100, 0x06072c18, 0x2726012f, 0x37363726, 0x83011f36, 0x16172605, 0x31071617, 0x05474233, 0xa36d0720, 0x221e8405, 0x591f1617,
0x3642089c, 0x2031820d, 0x27654617, 0x05126f32, 0x070e410e, 0x0c040306, 0x04110d0b, 0x0d0c0c04, 0x67280d83, 0x0c0b0e10, 0x07060304, 0x05211c82,
0x25078312, 0x040c0c0d, 0xe541aa04, 0xae5c1811, 0x10a84317, 0x0e428324, 0x65821103, 0x060e0e26, 0x10040407, 0x04247387, 0x0e060704, 0x11246c83,
0x0d420e03, 0x10217486, 0x12a9414f, 0x3a222224, 0xf34e4839, 0x0015281d, 0x0040002b, 0x416d005b, 0x163e185f, 0x0f143115, 0x26270601, 0x013f2635,
0x34372627, 0x011f3637, 0x16170737, 0x06071415, 0x196b012f, 0x450d8207, 0x7f3b421f, 0x07590808, 0x04010605, 0x01042424, 0x59070506, 0x032424aa,
0x5a060506, 0x825a0808, 0x77032106, 0x303a4e41, 0x09090471, 0x03033004, 0x04040703, 0x04042b2b, 0x210a8207, 0x09881e30, 0x5b201d8a, 0x202b4b41,
0x08774d07, 0x31001433, 0x67005000, 0x93007d00, 0x0000a800, 0x31333601, 0x05264132, 0x07060725, 0x82363722, 0x05105001, 0x82061721, 0x06aa6c10,
0x50221721, 0x1c840513, 0x31071622, 0x06211a83, 0x06775127, 0x36233384, 0x84333227, 0x8507203b, 0x242f8450, 0x35262706, 0x271e8426, 0x17360731,
0x010f1631, 0x13823882, 0x23060b43, 0x011f023f, 0x07207b82, 0x080d8618, 0x17363725, 0x55311716, 0x362105da, 0x21648415, 0x2f822223, 0x37343208,
0x0fab0131, 0x0f0f1414, 0x1c1c0d0e, 0x02010b13, 0xfe0b0707, 0x545341a0, 0x0502024b, 0x48483f02, 0x07073537, 0x0e030328, 0x2907070f, 0x013e0b0a,
0x85058394, 0x0202231f, 0x21830102, 0x06363408, 0x01012807, 0x0707120f, 0x0d0c0978, 0x090a0704, 0x23221b1b, 0x0d010e21, 0x17242425, 0x060509a9,
0x06031e01, 0x05030506, 0x05030439, 0x62060202, 0x83380563, 0x07012709, 0x06060a61, 0x1c841d03, 0xedfe0122, 0x0a208283, 0x91858183, 0x0eb20123,
0x0809830f, 0x07070b23, 0x1d120a02, 0x3e3d0d1c, 0x07290a0b, 0x29111208, 0x37350707, 0x013f4848, 0x02020402, 0x4153544b, 0x84048337, 0x0a072d1d,
0x28070909, 0x38360607, 0x033e4848, 0x61331e82, 0x22220e0c, 0x091b1b22, 0x0d04070a, 0x2317090c, 0x82092624, 0x610a2c70, 0x05020107, 0x05380403,
0x83050301, 0x398e2184, 0x0882a082, 0x06011e26, 0x06620905, 0x0323fe82, 0x83b3fe04, 0x0b01217b, 0x8b857c83, 0x370a9b44, 0x003d001e, 0x006e0053,
0x13000080, 0x16171617, 0x1417010f, 0x012f0607, 0x2709d564, 0x3336023f, 0x33011f32, 0x07201d9c, 0x2014334b, 0x2b395225, 0x0426c83e, 0x1b040103,
0x04040407, 0x04042123, 0x1c070205, 0x05010204, 0x04021126, 0xa0110206, 0x22211d89, 0x241d8c22, 0x11020505, 0x134a4b0a, 0x43a2fe21, 0x724c1768,
0x19013611, 0x04050105, 0x05251b04, 0x12020303, 0x03030212, 0x031b2505, 0x23148205, 0x22050522, 0x8d201b9b, 0x200f674b, 0x2a784334, 0x62057743,
0x382d05e7, 0x76005300, 0xbd008c00, 0x0000ef00, 0x05ba6a25, 0x26070624, 0x48432627, 0x06a55007, 0x31171626, 0x31070603, 0x07231a82, 0x4b360706,
0x1720055b, 0x2a842682, 0x06033524, 0x0c823127, 0x82343521, 0x05804318, 0x6b433220, 0x31072905, 0x01392221, 0x35303526, 0x27261e82, 0x33323334,
0x8c6e1532, 0x14152108, 0x27222483, 0x77480731, 0x022f0877, 0x060c0507, 0x3c3c2107, 0x3c3c4b4d, 0x0c060721, 0x16020105, 0x46443435, 0x02163534,
0x374dc801, 0x0d0a0f38, 0x4510100a, 0x46636245, 0x82101045, 0x0f23080c, 0xf04e3838, 0x0e12120f, 0x0e060e0e, 0x090a100e, 0x01090708, 0x0b060602,
0xe3010101, 0x060b0201, 0x82090207, 0x0808260a, 0x0e100707, 0x2422820f, 0x0e12110f, 0x1d9948f2, 0x0e0d0f22, 0x480cd04a, 0x72332d99, 0x04060e0d,
0x01262640, 0x40262601, 0x0d0e0604, 0x853d0404, 0x3d34080d, 0x1f010404, 0x4a2f2f02, 0x03020105, 0x023d3c5f, 0x5f3c3d02, 0x05010203, 0x022e2f4a,
0x0cdafe01, 0x0f0d0101, 0x070e1313, 0x01040505, 0x09010102, 0x0c1b1b12, 0x01260782, 0x1b1b0c01, 0xc6820912, 0x0401012a, 0x0e070505, 0x0d0f1313,
0x3a201482, 0x2c4fba48, 0x16151b07, 0x15160202, 0x0102071b, 0x0b935704, 0x2305ab6d, 0x00800067, 0x24cf6b18, 0x21243e47, 0xec483d26, 0x16172405,
0x4a373233, 0x152205dc, 0x385f0714, 0x13332107, 0x21069b5b, 0x975b2223, 0x53152005, 0x6b18079f, 0x38561df4, 0x05ef4d18, 0x1f1f0126, 0x0a0d0435,
0x3b07674f, 0x0809090e, 0x35040e08, 0x02011f1f, 0x01593b3b, 0x02190240, 0x08040512, 0x12050309, 0x31610a82, 0x136c1807, 0x1d344f18, 0x31313e28,
0x340e0c1a, 0x7a4f0f0c, 0x09033e05, 0x0d0e0d0a, 0x1a0c0e34, 0x583e3131, 0xfe023b3b, 0x02192590, 0x09091201, 0x19020112, 0x075c4e25, 0x300b7741,
0x002c0016, 0x00700047, 0x13000089, 0x36313734, 0x9a69181f, 0x06c24808, 0x36253129, 0x15163117, 0x48010f14, 0x80410cc5, 0x3617212e, 0x20118041,
0x18804115, 0x05067424, 0xdd485907, 0x0701250b, 0x03060506, 0x2009de48, 0x17714585, 0x2f0a8341, 0x06031225, 0x473c0a07, 0x060a3c48, 0x25120407,
0x20078341, 0x16824158, 0x07230126, 0x30030303, 0x200ef848, 0x0e03490a, 0x6a181e84, 0x94411d3b, 0x1b172905, 0x06060a2a, 0x01011203, 0x062f8782,
0x171b2a0a, 0x311a0c0e, 0x3b583f31, 0x4101023b, 0x1f491797, 0x00103309, 0x002b0019, 0x0058003d, 0x009a0081, 0x07223700, 0x7f5a2706, 0x7537200b,
0x9956054c, 0x47212025, 0x35432b1f, 0x27312115, 0x24172d43, 0x0d0812a0, 0x0bb35a0f, 0x2408656e, 0x17160138, 0x1ca15622, 0x41b0fe21, 0x012117c8,
0x0632435c, 0x3b585824, 0x5443023b, 0x431c2015, 0xe423154b, 0x5a0b0c0a, 0x0c2008e1, 0x56077269, 0x4e47207a, 0x43ba2017, 0x0223074c, 0x43583b3b,
0x67431870, 0x0015281f, 0x00380027, 0x4c650053, 0x7018183b, 0x6f5c10b3, 0x23f6533e, 0x4d3b6b5c, 0xf8531082, 0x43635c0c, 0x7700652b, 0xa4008900,
0x0000b600, 0x05196225, 0x5c070621, 0x22380b1b, 0x39372627, 0x32353201, 0x36333437, 0x34373637, 0x26353637, 0x22272627, 0x03820582, 0x23352327,
0x35263135, 0x20239c34, 0x82238334, 0x2057833b, 0x517b5531, 0x0106312c, 0x0a070601, 0x04050504, 0x0b85070a, 0x061b152d, 0x01050102, 0x04010201,
0x82040606, 0x04022306, 0x08840105, 0x04040122, 0x05281694, 0x1b060201, 0x61070a15, 0x2747b355, 0x0b0b07a6, 0x02060807, 0x05210082, 0x280b8509,
0x0606010b, 0x01010103, 0x82aa8203, 0x22938299, 0x52010405, 0x052206ed, 0x19950205, 0x82070221, 0x050b23b0, 0xf2554a09, 0x0a2b4c42, 0x97006528,
0xe300c800, 0xf741f500, 0x41342036, 0xbf5230f7, 0x5e0f5530, 0x204c3642, 0x18105357, 0x20584755, 0x4e604296, 0x0b534520, 0x5525a525, 0x5b532a86,
0x002d2f09, 0x00a50093, 0x00cd00b6, 0x17160500, 0x13532306, 0x07142511, 0x27260726, 0x21058144, 0xa9440706, 0x37322305, 0x67182717, 0x0983098d,
0x44070621, 0xbd421fb5, 0x228d822f, 0x18273107, 0x48115779, 0x17200f31, 0x2614e453, 0x03590101, 0x46352f08, 0x0e2511fc, 0x05031311, 0x0bb46e0a,
0x06272c23, 0x47ca4438, 0x01010624, 0x77189106, 0xc0240d5b, 0x0e0e0812, 0x2d0b4748, 0x0e111567, 0x0904050f, 0x0f551108, 0x07831705, 0x04250f82,
0x080c1806, 0x11354814, 0x08282c27, 0x1e070803, 0x0b3b5622, 0x8a191122, 0x244ae444, 0x070b0b07, 0x0be8447e, 0x67480c20, 0x0599300b, 0x11090905,
0x050f1012, 0x590e0218, 0x840f0f12, 0x5715200f, 0x69600cc7, 0x00522805, 0x37000064, 0x7a313726, 0x0721054f, 0x050e6806, 0x52ed7918, 0x06038332,
0x0bd60a07, 0x0e020606, 0x2e2e2222, 0x4d0d2222, 0x2f474146, 0x08070b86, 0x2a0b0708, 0x01011a19, 0x7a2a191a, 0x5a170046, 0x132834bf, 0x76004500,
0xa3009100, 0x45162741, 0x66418ead, 0x72714511, 0x200e9041, 0x250a4555, 0x304525a5, 0x0eef422a, 0x3f002926, 0x6c005a00, 0x5716c741, 0x3120292d,
0x21246e4e, 0x5b633736, 0x11904105, 0x2a575c20, 0x0e684149, 0x2f4e8720, 0x1928570e, 0x63456b20, 0x05c64411, 0x46127458, 0x13280977, 0x36002500,
0x63005100, 0x4c164341, 0x3a414e35, 0x0e324411, 0x413b314c, 0x34440e3a, 0x0c2f4c0c, 0x2a412920, 0x6b77182a, 0x6e23200c, 0x7f180589, 0x9b622337,
0x45d0202c, 0x73621c37, 0x36e8512b, 0x220bd646, 0x50000000, 0x0a2e0927, 0x39001c00, 0x67004b00, 0x94008200, 0xa2180000, 0x2f200917, 0x5505bf58,
0x17210bdf, 0x05ac7f36, 0x24088d69, 0x30353435, 0x05a94831, 0x39823120, 0x37363122, 0x71572ea7, 0x66a8202c, 0x162207bb, 0x12505802, 0x610f2015,
0x0f260550, 0x0e0d0101, 0x23a27014, 0xb066fe20, 0x11735718, 0x02504820, 0x50982007, 0x16211403, 0x07bc690e, 0x16250782, 0x010d0e14, 0x6927a630,
0x102837d7, 0x35002100, 0x72005000, 0x4f12d751, 0x072010f4, 0x20087968, 0x07294815, 0x51273521, 0x52181ecf, 0x1423089e, 0x7b171617, 0x36210791,
0x26098537, 0x0d0812a0, 0x6c0b0b10, 0x8a200963, 0x200f706c, 0x0fbf675a, 0x24180e64, 0x111e9001, 0x07234a11, 0x1e11112a, 0x02161602, 0x2c34342c,
0x86510783, 0x0990510c, 0x0b0c0a23, 0x07a86859, 0x08882020, 0x24182748, 0x27261d96, 0x07fd422c, 0x26272c2c, 0x0216761d, 0x16991602, 0x04820101,
0x76200982, 0x3105d37d, 0xc0010002, 0x21001300, 0x45003300, 0x76006000, 0x1a610000, 0x22232909, 0x36272627, 0x31373637, 0x085f8318, 0x16373627,
0x32273117, 0x05ef6617, 0x2206dc5b, 0x18073336, 0x240b1344, 0x06070617, 0x34a61823, 0x4633201c, 0xe24b0770, 0x31333a08, 0x0c0606aa, 0x0e010e0e,
0x0d14150d, 0x0e02010e, 0x0fc60c0f, 0x2013100d, 0x31b6832f, 0x0d202e42, 0x01010909, 0x0f0d0909, 0x08090908, 0x0685a00f, 0xfd681487, 0x25502218,
0x0b01442b, 0x08320226, 0x9d1b1415, 0x82059360, 0x0d0e3467, 0x17181014, 0x1210380f, 0x011e0d0f, 0x02161602, 0x64ab2a01, 0x797b18b0, 0x10402119,
0x240bef4b, 0x0f193851, 0x0d376f0f, 0x7c004b26, 0xa9009700, 0x491c376f, 0x86188e9d, 0x26201932, 0x6f71174f, 0x7b20189f, 0xa5258949, 0x2daf4925,
0x18000221, 0x2507b7aa, 0x002b001e, 0x7f5d0100, 0x5d162006, 0x3725109d, 0x07011f16, 0xaeaa1832, 0x01112309, 0xaa18997a, 0x0f3519ac, 0x075b4407,
0x02146905, 0x0d765609, 0x25013605, 0x0e0e0217, 0xa4aa180a, 0x0d012f15, 0x3803e68d, 0x55090c78, 0x6c0b0311, 0x036fcefe, 0x0023260c, 0x00500035,
0x25175a62, 0x45092d45, 0x8918072c, 0xf9592c37, 0x59b0201d, 0x078807ad, 0x884e4020, 0x17b16211, 0x1818f847, 0x2010f746, 0x29fd4860, 0x2a09274a,
0x002c0016, 0x005c0041, 0x5400006e, 0x142306cd, 0x7d2f0607, 0x27250676, 0x3f363526, 0x296e4b01, 0x2f2c6d4b, 0x31311eb1, 0x07021e1f, 0x22120708,
0x12222626, 0x02220882, 0x704b2e1f, 0x1d803549, 0x1d1d0303, 0x05050823, 0x0f0f0803, 0x05050308, 0x7d1d2308, 0x6228764b, 0x00272c9f, 0x0e011600,
0x85000100, 0x001a2200, 0x240b866c, 0x001b0001, 0x240b86cb, 0x00070002, 0x240b8665, 0x00210003, 0x200b8644, 0x24238a04, 0x00320005, 0x24178686,
0x00180006, 0x200b862c, 0x2009820a, 0x240b8600, 0x0017000b, 0x240b86e6, 0x00130010, 0x200b86b8, 0x245f8411, 0x04010003, 0x23868209, 0x00d50134,
0x01240b85, 0x93023600, 0x02240b86, 0xc7010e00, 0x03240b86, 0x85014200, 0x04200b86, 0x0524238a, 0x09026400, 0x06241786, 0x55013000, 0x0a240b86,
0xfd005800, 0x0b240b86, 0xc9022e00, 0x10240b86, 0x6d022600, 0x11200b86, 0x3f085f83, 0x20656854, 0x27626577, 0x6f6d2073, 0x70207473, 0x6c75706f,
0x69207261, 0x206e6f63, 0x20746573, 0x20646e61, 0x6c6f6f74, 0x2e74696b, 0x746e6f46, 0x73657741, 0x36656d6f, 0x65657246, 0x6765522d, 0x17832d83,
0x18862020, 0x20362022, 0x20201a83, 0x2d251a86, 0x2e322e36, 0x2d0c8630, 0x79706f43, 0x68676972, 0x63282074, 0x358b2029, 0x72655624, 0x71826973,
0x3037372d, 0x3330302e, 0x32363039, 0x8c282035, 0x85762057, 0x203a2122, 0x29205184, 0x73851b8c, 0x86871292, 0x74746828, 0x2f3a7370, 0xc182662f,
0xc1856120, 0x6f632e2d, 0x0054006d, 0x00650068, 0x82770020, 0x00622405, 0x82730027, 0x006d220b, 0x2007826f, 0x20098274, 0x28098270, 0x00750070,
0x0061006c, 0x220f8272, 0x82630069, 0x826e2011, 0x82732009, 0x2421832f, 0x006e0061, 0x200f8264, 0x20178274, 0x2827826f, 0x0069006b, 0x002e0074,
0x22278446, 0x84410074, 0x82732059, 0x826d200d, 0x82362031, 0x82722017, 0x00652407, 0x8252002d, 0x88672007, 0x202f875b, 0x22318e20, 0x82360020,
0x8246205d, 0x8465207d, 0x20358da7, 0x221d822d, 0x8232002e, 0x8e30206f, 0x8443204f, 0x827920b9, 0x00692237, 0x20e38267, 0x20458274, 0x20bd8228,
0x204d8429, 0x83b5826f, 0x209d8d11, 0x20618256, 0x20f98272, 0x22bb8469, 0x82370020, 0x84302001, 0x0030265b, 0x00390033, 0x226d8230, 0x82350032,
0x88282041, 0x20af91df, 0x20458c76, 0x202d823a, 0x85438236, 0x9a2920a3, 0x41e78b37, 0x6822350d, 0x01827400, 0xc1827020, 0x2f003a22, 0x66200182,
0x7422c784, 0x83416100, 0x002e220c, 0x21178263, 0x0082006d, 0x84000221, 0xdbff2300, 0x08841900, 0xc609048f, 0x010000d3, 0x01030102, 0x00080004,
0x010e000d, 0x01060105, 0x01080107, 0x010a0109, 0x010c010b, 0x010e010d, 0x0110010f, 0x00220011, 0x01120123, 0x01140113, 0x01160115, 0x01180117,
0x011a0119, 0x011c011b, 0x011e011d, 0x0120011f, 0x01220121, 0x01240123, 0x01260125, 0x01280127, 0x012a0129, 0x012c012b, 0x012e012d, 0x0130012f,
0x01320131, 0x01340133, 0x01360135, 0x01380137, 0x013a0139, 0x013c013b, 0x013e013d, 0x0140013f, 0x01420141, 0x01440143, 0x01460145, 0x01480147,
0x014a0149, 0x014c014b, 0x014e014d, 0x0150014f, 0x01520151, 0x01540153, 0x01560155, 0x01580157, 0x015a0159, 0x015c015b, 0x015e015d, 0x0160015f,
0x01620161, 0x01640163, 0x01660165, 0x01680167, 0x016a0169, 0x016c016b, 0x016e016d, 0x0170016f, 0x01720171, 0x01740173, 0x01760175, 0x01780177,
0x017a0179, 0x017c017b, 0x017e017d, 0x0180017f, 0x01820181, 0x01840183, 0x01860185, 0x01880187, 0x018a0189, 0x018c018b, 0x018e018d, 0x0190018f,
0x01920191, 0x01940193, 0x01960195, 0x01980197, 0x019a0199, 0x019c019b, 0x019e019d, 0x01a0019f, 0x01a201a1, 0x01a401a3, 0x01a601a5, 0x01a801a7,
0x01aa01a9, 0x01ac01ab, 0x01ae01ad, 0x01b001af, 0x01b201b1, 0x01b401b3, 0x01b601b5, 0x01b801b7, 0x01ba01b9, 0x01bc01bb, 0x01be01bd, 0x01c001bf,
0x01c201c1, 0x01c401c3, 0x01c601c5, 0x01c801c7, 0x01ca01c9, 0x01cc01cb, 0x0bce01cd, 0x6c637865, 0x74616d61, 0x076e6f69, 0x68736168, 0x0b676174,
0x6c6c6f64, 0x732d7261, 0x416e6769, 0x0938135d, 0x7373656c, 0x6168742d, 0x7165066e, 0x736c6175, 0x6572670c, 0x72657461, 0x2d411384, 0x660d2433,
0x82646c6f, 0x6c63363f, 0x6465736f, 0x61656805, 0x73047472, 0x04726174, 0x72657375, 0x08168205, 0x0e6b632d, 0x74636572, 0x6c676e61, 0x696c2d65,
0x66047473, 0x0867616c, 0x6b6f6f62, 0x6b72616d, 0x616d6905, 0x700d6567, 0x742d6e65, 0x82732d6f, 0x65722695, 0x7269630c, 0x202d8263, 0x87208378,
0x6863250c, 0x0f6b6365, 0x71231986, 0x83736575, 0x650324f8, 0x82096579, 0x732d3c03, 0x6873616c, 0x6c61630d, 0x61646e65, 0x61642d72, 0x63077379,
0x656d6d6f, 0x8506746e, 0x850b20a2, 0x6f2d2106, 0x09226a82, 0xa7826863, 0x61622d24, 0x24860872, 0x83097321, 0x682d37b4, 0x05666c61, 0x6f6d656c,
0x72630b6e, 0x74696465, 0x7261632d, 0x2d820a64, 0x642d6438, 0x65766972, 0x6e616810, 0x6f702d64, 0x2d746e69, 0x68676972, 0x108a0f74, 0x66656c24,
0x0f8a0d74, 0x8b707521, 0x6f64351d, 0x63046e77, 0x0b79706f, 0x706f6c66, 0x642d7970, 0x066b7369, 0x0824f185, 0x65766e65, 0x65281582, 0x73617005,
0x6c096574, 0x62325a83, 0x04626c75, 0x6c6c6562, 0x736f6808, 0x61746970, 0x2d850b6c, 0x6c702d25, 0x41067375, 0x0a2a050a, 0x65636166, 0x696d732d,
0x0a85656c, 0x82726621, 0x84082067, 0x656d2815, 0x656b0868, 0x826f6279, 0x410820c3, 0x0b20071b, 0x43823785, 0x0c796122, 0x6d244f86, 0x73756e69,
0x63260c87, 0x6b636568, 0xf3827311, 0x822d6521, 0x416d204c, 0x07230694, 0x826d6f63, 0x1173219c, 0x63253386, 0x74657261, 0x20d4832d, 0x22118c0f,
0x8c127075, 0x8372200f, 0x660421ca, 0x04829f84, 0x696c2d30, 0x0973656e, 0x6d756874, 0x752d7362, 0x09860b70, 0x03284883, 0x046e7573, 0x6e6f6f6d,
0x6c24638d, 0x0a746665, 0x642cb586, 0x6208746f, 0x646c6975, 0x08676e69, 0x2d245483, 0x09666470, 0x77240884, 0x0a64726f, 0x65250984, 0x6c656378,
0x290a840f, 0x65776f70, 0x696f7072, 0x1a85746e, 0x616d6925, 0x840b6567, 0x697a251a, 0x72657070, 0x61241685, 0x6f696475, 0x76240a85, 0x6f656469,
0x632a5185, 0x0965646f, 0x6566696c, 0x6e82722d, 0x61700b22, 0x2d312f82, 0x6e616c70, 0x75660665, 0x6c6f6274, 0x77656e09, 0x24168473, 0x6c65620a,
0x0585426c, 0x6f630922, 0x2006ef47, 0x05154311, 0x61632d27, 0x6f697470, 0x2d43826e, 0x6a626f0c, 0x2d746365, 0x756f7267, 0x0c860e70, 0x846e7521,
0x6e0b2c0e, 0x2d65746f, 0x63697473, 0x8205796b, 0x656e3139, 0x756f680e, 0x616c6772, 0x682d7373, 0x09666c61, 0x0e2f0e88, 0x646e6168, 0x6361622d,
0x69662d6b, 0x83047473, 0x0578420e, 0x69637328, 0x726f7373, 0x21840b73, 0x7a696c22, 0x8205be42, 0x7073252d, 0x0c6b636f, 0x82099d42, 0x270c85fa,
0x65636165, 0x6765720a, 0x65234882, 0x43646572, 0x70240944, 0x0e73756c, 0x22085243, 0x8b6e696d, 0x6d78240e, 0x896b7261, 0x68632f1d, 0x036b6365,
0x0770616d, 0x7373656d, 0xc3436761, 0x61702408, 0x42657375, 0x73290773, 0x0c706f74, 0x746e6f66, 0x068d482d, 0x82830920, 0x61687325, 0x430d656b,
0x2d290701, 0x6e65706f, 0x6464610c, 0x24488272, 0x6f6f622d, 0x200c886b, 0x87cc8263, 0x2a55824a, 0x64690872, 0x6461622d, 0x82076567, 0x2f1c8308,
0x6e69770f, 0x2d776f64, 0x6978616d, 0x657a696d, 0x69210f88, 0x200f846e, 0x821f860e, 0x6f742a5a, 0x73096572, 0x66776f6e, 0x2c7d826c, 0x61727409,
0x632d6873, 0x69066e61, 0x27bd826d, 0x6c630973, 0x6f627069, 0x5782708a, 0x7c876e20, 0x66656c23, 0x07974474, 0x67697225, 0x42097468, 0x7533069e,
0x65670370, 0x6f6d0c6d, 0x2d79656e, 0x6c6c6962, 0x440f312d, 0x782009fd, 0x2005cf44, 0x26d88468, 0x6f687369, 0x84630a70, 0x696b240c, 0x860c676e,
0x836e200a, 0x2217864f, 0x82776170, 0x24228473, 0x65657571, 0x2316866e, 0x6b6f6f72, 0x25070a44, 0x6c6c7566, 0xe944630c, 0x642d2505, 0x0f73746f,
0x20091044, 0x20ee822d, 0x0515446b, 0x676e6124, 0x0a857972, 0x7a696425, 0x840c797a, 0x6c662625, 0x65687375, 0x24328564, 0x776f7266, 0x057d416e,
0x67271c84, 0x616d6972, 0x87096563, 0x0e6e210c, 0x58820988, 0x8a656421, 0x6562240e, 0x89146d61, 0x260e831d, 0x6577732d, 0x89107461, 0x65682514,
0x73747261, 0x7326108a, 0x6e697571, 0x21891674, 0x2d211085, 0x86288274, 0x258282c5, 0x74732d6e, 0x0f8b7261, 0x478a1f84, 0x6e6f7426, 0x17657567,
0x10854789, 0x4e852d20, 0x17901520, 0x6e697723, 0x21ca8c6b, 0xe3856b6e, 0x73696b23, 0x83188573, 0x892d2009, 0x830e84d4, 0x842d2036, 0x054641c4,
0x75616c24, 0x39416867, 0x840a8405, 0x8411202f, 0x850f856d, 0x89218b7f, 0x656d2879, 0x6c622d68, 0x856b6e61, 0x6f722b30, 0x6e696c6c, 0x79652d67,
0x99417365, 0x61732705, 0x72632d64, 0x4f840d79, 0xf5830c83, 0x830bda41, 0x4610209d, 0x2d2608b3, 0x6f727473, 0x2e86656b, 0x70727525, 0x46736972,
0x7427060f, 0x64657269, 0x05000000, 0xe830d0fa, 0x0000004a,
};

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,5 @@
#include "imgui_DroidSans.h"
#include "DroidSans.inc"
ImFont* ImGui::AddFontDroidSans(ImGuiIO& io, float size_pixels, const ImFontConfig* font_cfg, const ImWchar* glyph_ranges) {
return io.Fonts->AddFontFromMemoryCompressedTTF(DroidSans_compressed_data, DroidSans_compressed_size, size_pixels, font_cfg, glyph_ranges);
}

View File

@@ -0,0 +1,5 @@
#include "imgui_FiraCodeRetina.h"
#include "FiraCodeRetina.inc"
ImFont* ImGui::AddFontFiraCodeRetina(ImGuiIO& io, float size_pixels, const ImFontConfig* font_cfg, const ImWchar* glyph_ranges) {
return io.Fonts->AddFontFromMemoryCompressedTTF(FiraCodeRetina_compressed_data, FiraCodeRetina_compressed_size, size_pixels, font_cfg, glyph_ranges);
}

View File

@@ -0,0 +1,5 @@
#include "imgui_FontAwesomeRegular.h"
#include "FontAwesomeRegular.inc"
ImFont* ImGui::AddFontFontAwesomeRegular(ImGuiIO& io, float size_pixels, const ImFontConfig* font_cfg, const ImWchar* glyph_ranges) {
return io.Fonts->AddFontFromMemoryCompressedTTF(FontAwesomeRegular_compressed_data, FontAwesomeRegular_compressed_size, size_pixels, font_cfg, glyph_ranges);
}

View File

@@ -0,0 +1,5 @@
#include "imgui_FontAwesomeSolid.h"
#include "FontAwesomeSolid.inc"
ImFont* ImGui::AddFontFontAwesomeSolid(ImGuiIO& io, float size_pixels, const ImFontConfig* font_cfg, const ImWchar* glyph_ranges) {
return io.Fonts->AddFontFromMemoryCompressedTTF(FontAwesomeSolid_compressed_data, FontAwesomeSolid_compressed_size, size_pixels, font_cfg, glyph_ranges);
}

View File

@@ -0,0 +1,5 @@
#include "imgui_ProggyDotted.h"
#include "ProggyDotted.inc"
ImFont* ImGui::AddFontProggyDotted(ImGuiIO& io, float size_pixels, const ImFontConfig* font_cfg, const ImWchar* glyph_ranges) {
return io.Fonts->AddFontFromMemoryCompressedTTF(ProggyDotted_compressed_data, ProggyDotted_compressed_size, size_pixels, font_cfg, glyph_ranges);
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,311 @@
#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;
*/
#if defined(__SCITECH_SNAP__) && !defined(KHRONOS_STATIC)
# define KHRONOS_STATIC 1
#endif
/*-------------------------------------------------------------------------
* Definition of KHRONOS_APICALL
*-------------------------------------------------------------------------
* This precedes the return type of the function in the function prototype.
*/
#if defined(KHRONOS_STATIC)
/* If the preprocessor constant KHRONOS_STATIC is defined, make the
* header compatible with static linking. */
# define KHRONOS_APICALL
#elif defined(_WIN32)
# 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
/*
* To support platform where unsigned long cannot be used interchangeably with
* inptr_t (e.g. CHERI-extended ISAs), we can use the stdint.h intptr_t.
* Ideally, we could just use (u)intptr_t everywhere, but this could result in
* ABI breakage if khronos_uintptr_t is changed from unsigned long to
* unsigned long long or similar (this results in different C++ name mangling).
* To avoid changes for existing platforms, we restrict usage of intptr_t to
* platforms where the size of a pointer is larger than the size of long.
*/
#if defined(__SIZEOF_LONG__) && defined(__SIZEOF_POINTER__)
#if __SIZEOF_POINTER__ > __SIZEOF_LONG__
#define KHRONOS_USE_INTPTR_T
#endif
#endif
#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 KHRONOS_USE_INTPTR_T
typedef intptr_t khronos_intptr_t;
typedef uintptr_t khronos_uintptr_t;
#elif defined(_WIN64)
typedef signed long long int khronos_intptr_t;
typedef unsigned long long int khronos_uintptr_t;
#else
typedef signed long int khronos_intptr_t;
typedef unsigned long int khronos_uintptr_t;
#endif
#if defined(_WIN64)
typedef signed long long int khronos_ssize_t;
typedef unsigned long long int khronos_usize_t;
#else
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_ */

View File

@@ -0,0 +1,926 @@
/*
* This file was generated with gl3w_gen.py, part of gl3w
* (hosted at https://github.com/skaslev/gl3w)
*
* This is free and unencumbered software released into the public domain.
*
* Anyone is free to copy, modify, publish, use, compile, sell, or
* distribute this software, either in source code form or as a compiled
* binary, for any purpose, commercial or non-commercial, and by any
* means.
*
* In jurisdictions that recognize copyright laws, the author or authors
* of this software dedicate any and all copyright interest in the
* software to the public domain. We make this dedication for the benefit
* of the public at large and to the detriment of our heirs and
* successors. We intend this dedication to be an overt act of
* relinquishment in perpetuity of all present and future rights to this
* software under copyright law.
*
* THE SOFTWARE IS 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 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 SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
#include <GL/gl3w.h>
#include <stdlib.h>
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
#if defined(_WIN32)
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN 1
#endif
#include <windows.h>
static HMODULE libgl;
typedef PROC(__stdcall* GL3WglGetProcAddr)(LPCSTR);
static GL3WglGetProcAddr wgl_get_proc_address;
static int open_libgl(void)
{
libgl = LoadLibraryA("opengl32.dll");
if (!libgl)
return GL3W_ERROR_LIBRARY_OPEN;
wgl_get_proc_address = (GL3WglGetProcAddr)GetProcAddress(libgl, "wglGetProcAddress");
return GL3W_OK;
}
static void close_libgl(void)
{
FreeLibrary(libgl);
}
static GL3WglProc get_proc(const char *proc)
{
GL3WglProc res;
res = (GL3WglProc)wgl_get_proc_address(proc);
if (!res)
res = (GL3WglProc)GetProcAddress(libgl, proc);
return res;
}
#elif defined(__APPLE__)
#include <dlfcn.h>
static void *libgl;
static int open_libgl(void)
{
libgl = dlopen("/System/Library/Frameworks/OpenGL.framework/OpenGL", RTLD_LAZY | RTLD_LOCAL);
if (!libgl)
return GL3W_ERROR_LIBRARY_OPEN;
return GL3W_OK;
}
static void close_libgl(void)
{
dlclose(libgl);
}
static GL3WglProc get_proc(const char *proc)
{
GL3WglProc res;
*(void **)(&res) = dlsym(libgl, proc);
return res;
}
#else
#include <dlfcn.h>
static void *libgl; /* OpenGL library */
static void *libglx; /* GLX library */
static void *libegl; /* EGL library */
static GL3WGetProcAddressProc gl_get_proc_address;
static void close_libgl(void)
{
if (libgl) {
dlclose(libgl);
libgl = NULL;
}
if (libegl) {
dlclose(libegl);
libegl = NULL;
}
if (libglx) {
dlclose(libglx);
libglx = NULL;
}
}
static int is_library_loaded(const char *name, void **lib)
{
*lib = dlopen(name, RTLD_LAZY | RTLD_LOCAL | RTLD_NOLOAD);
return *lib != NULL;
}
static int open_libs(void)
{
/* On Linux we have two APIs to get process addresses: EGL and GLX.
* EGL is supported under both X11 and Wayland, whereas GLX is X11-specific.
* First check what's already loaded, the windowing library might have
* already loaded either EGL or GLX and we want to use the same one.
*/
if (is_library_loaded("libEGL.so.1", &libegl) ||
is_library_loaded("libGLX.so.0", &libglx)) {
libgl = dlopen("libOpenGL.so.0", RTLD_LAZY | RTLD_LOCAL);
if (libgl)
return GL3W_OK;
else
close_libgl();
}
if (is_library_loaded("libGL.so.1", &libgl))
return GL3W_OK;
/* Neither is already loaded, so we have to load one. Try EGL first
* because it is supported under both X11 and Wayland.
*/
/* Load OpenGL + EGL */
libgl = dlopen("libOpenGL.so.0", RTLD_LAZY | RTLD_LOCAL);
libegl = dlopen("libEGL.so.1", RTLD_LAZY | RTLD_LOCAL);
if (libgl && libegl)
return GL3W_OK;
/* Fall back to legacy libGL, which includes GLX */
close_libgl();
libgl = dlopen("libGL.so.1", RTLD_LAZY | RTLD_LOCAL);
if (libgl)
return GL3W_OK;
return GL3W_ERROR_LIBRARY_OPEN;
}
static int open_libgl(void)
{
int res = open_libs();
if (res)
return res;
if (libegl)
*(void **)(&gl_get_proc_address) = dlsym(libegl, "eglGetProcAddress");
else if (libglx)
*(void **)(&gl_get_proc_address) = dlsym(libglx, "glXGetProcAddressARB");
else
*(void **)(&gl_get_proc_address) = dlsym(libgl, "glXGetProcAddressARB");
if (!gl_get_proc_address) {
close_libgl();
return GL3W_ERROR_LIBRARY_OPEN;
}
return GL3W_OK;
}
static GL3WglProc get_proc(const char *proc)
{
GL3WglProc res = NULL;
/* Before EGL version 1.5, eglGetProcAddress doesn't support querying core
* functions and may return a dummy function if we try, so try to load the
* function from the GL library directly first.
*/
if (libegl)
*(void **)(&res) = dlsym(libgl, proc);
if (!res)
res = gl_get_proc_address(proc);
if (!libegl && !res)
*(void **)(&res) = dlsym(libgl, proc);
return res;
}
#endif
static struct {
int major, minor;
} version;
static int parse_version(void)
{
if (!glGetIntegerv)
return GL3W_ERROR_INIT;
glGetIntegerv(GL_MAJOR_VERSION, &version.major);
glGetIntegerv(GL_MINOR_VERSION, &version.minor);
if (version.major < 3)
return GL3W_ERROR_OPENGL_VERSION;
return GL3W_OK;
}
static void load_procs(GL3WGetProcAddressProc proc);
int gl3wInit(void)
{
int res;
res = open_libgl();
if (res)
return res;
atexit(close_libgl);
return gl3wInit2(get_proc);
}
int gl3wInit2(GL3WGetProcAddressProc proc)
{
load_procs(proc);
return parse_version();
}
int gl3wIsSupported(int major, int minor)
{
if (major < 3)
return 0;
if (version.major == major)
return version.minor >= minor;
return version.major >= major;
}
GL3WglProc gl3wGetProcAddress(const char *proc)
{
return get_proc(proc);
}
static const char *proc_names[] = {
"glActiveShaderProgram",
"glActiveTexture",
"glAttachShader",
"glBeginConditionalRender",
"glBeginQuery",
"glBeginQueryIndexed",
"glBeginTransformFeedback",
"glBindAttribLocation",
"glBindBuffer",
"glBindBufferBase",
"glBindBufferRange",
"glBindBuffersBase",
"glBindBuffersRange",
"glBindFragDataLocation",
"glBindFragDataLocationIndexed",
"glBindFramebuffer",
"glBindImageTexture",
"glBindImageTextures",
"glBindProgramPipeline",
"glBindRenderbuffer",
"glBindSampler",
"glBindSamplers",
"glBindTexture",
"glBindTextureUnit",
"glBindTextures",
"glBindTransformFeedback",
"glBindVertexArray",
"glBindVertexBuffer",
"glBindVertexBuffers",
"glBlendColor",
"glBlendEquation",
"glBlendEquationSeparate",
"glBlendEquationSeparatei",
"glBlendEquationi",
"glBlendFunc",
"glBlendFuncSeparate",
"glBlendFuncSeparatei",
"glBlendFunci",
"glBlitFramebuffer",
"glBlitNamedFramebuffer",
"glBufferData",
"glBufferStorage",
"glBufferSubData",
"glCheckFramebufferStatus",
"glCheckNamedFramebufferStatus",
"glClampColor",
"glClear",
"glClearBufferData",
"glClearBufferSubData",
"glClearBufferfi",
"glClearBufferfv",
"glClearBufferiv",
"glClearBufferuiv",
"glClearColor",
"glClearDepth",
"glClearDepthf",
"glClearNamedBufferData",
"glClearNamedBufferSubData",
"glClearNamedFramebufferfi",
"glClearNamedFramebufferfv",
"glClearNamedFramebufferiv",
"glClearNamedFramebufferuiv",
"glClearStencil",
"glClearTexImage",
"glClearTexSubImage",
"glClientWaitSync",
"glClipControl",
"glColorMask",
"glColorMaski",
"glCompileShader",
"glCompressedTexImage1D",
"glCompressedTexImage2D",
"glCompressedTexImage3D",
"glCompressedTexSubImage1D",
"glCompressedTexSubImage2D",
"glCompressedTexSubImage3D",
"glCompressedTextureSubImage1D",
"glCompressedTextureSubImage2D",
"glCompressedTextureSubImage3D",
"glCopyBufferSubData",
"glCopyImageSubData",
"glCopyNamedBufferSubData",
"glCopyTexImage1D",
"glCopyTexImage2D",
"glCopyTexSubImage1D",
"glCopyTexSubImage2D",
"glCopyTexSubImage3D",
"glCopyTextureSubImage1D",
"glCopyTextureSubImage2D",
"glCopyTextureSubImage3D",
"glCreateBuffers",
"glCreateFramebuffers",
"glCreateProgram",
"glCreateProgramPipelines",
"glCreateQueries",
"glCreateRenderbuffers",
"glCreateSamplers",
"glCreateShader",
"glCreateShaderProgramv",
"glCreateTextures",
"glCreateTransformFeedbacks",
"glCreateVertexArrays",
"glCullFace",
"glDebugMessageCallback",
"glDebugMessageControl",
"glDebugMessageInsert",
"glDeleteBuffers",
"glDeleteFramebuffers",
"glDeleteProgram",
"glDeleteProgramPipelines",
"glDeleteQueries",
"glDeleteRenderbuffers",
"glDeleteSamplers",
"glDeleteShader",
"glDeleteSync",
"glDeleteTextures",
"glDeleteTransformFeedbacks",
"glDeleteVertexArrays",
"glDepthFunc",
"glDepthMask",
"glDepthRange",
"glDepthRangeArrayv",
"glDepthRangeIndexed",
"glDepthRangef",
"glDetachShader",
"glDisable",
"glDisableVertexArrayAttrib",
"glDisableVertexAttribArray",
"glDisablei",
"glDispatchCompute",
"glDispatchComputeIndirect",
"glDrawArrays",
"glDrawArraysIndirect",
"glDrawArraysInstanced",
"glDrawArraysInstancedBaseInstance",
"glDrawBuffer",
"glDrawBuffers",
"glDrawElements",
"glDrawElementsBaseVertex",
"glDrawElementsIndirect",
"glDrawElementsInstanced",
"glDrawElementsInstancedBaseInstance",
"glDrawElementsInstancedBaseVertex",
"glDrawElementsInstancedBaseVertexBaseInstance",
"glDrawRangeElements",
"glDrawRangeElementsBaseVertex",
"glDrawTransformFeedback",
"glDrawTransformFeedbackInstanced",
"glDrawTransformFeedbackStream",
"glDrawTransformFeedbackStreamInstanced",
"glEnable",
"glEnableVertexArrayAttrib",
"glEnableVertexAttribArray",
"glEnablei",
"glEndConditionalRender",
"glEndQuery",
"glEndQueryIndexed",
"glEndTransformFeedback",
"glFenceSync",
"glFinish",
"glFlush",
"glFlushMappedBufferRange",
"glFlushMappedNamedBufferRange",
"glFramebufferParameteri",
"glFramebufferParameteriMESA",
"glFramebufferRenderbuffer",
"glFramebufferTexture",
"glFramebufferTexture1D",
"glFramebufferTexture2D",
"glFramebufferTexture3D",
"glFramebufferTextureLayer",
"glFrontFace",
"glGenBuffers",
"glGenFramebuffers",
"glGenProgramPipelines",
"glGenQueries",
"glGenRenderbuffers",
"glGenSamplers",
"glGenTextures",
"glGenTransformFeedbacks",
"glGenVertexArrays",
"glGenerateMipmap",
"glGenerateTextureMipmap",
"glGetActiveAtomicCounterBufferiv",
"glGetActiveAttrib",
"glGetActiveSubroutineName",
"glGetActiveSubroutineUniformName",
"glGetActiveSubroutineUniformiv",
"glGetActiveUniform",
"glGetActiveUniformBlockName",
"glGetActiveUniformBlockiv",
"glGetActiveUniformName",
"glGetActiveUniformsiv",
"glGetAttachedShaders",
"glGetAttribLocation",
"glGetBooleani_v",
"glGetBooleanv",
"glGetBufferParameteri64v",
"glGetBufferParameteriv",
"glGetBufferPointerv",
"glGetBufferSubData",
"glGetCompressedTexImage",
"glGetCompressedTextureImage",
"glGetCompressedTextureSubImage",
"glGetDebugMessageLog",
"glGetDoublei_v",
"glGetDoublev",
"glGetError",
"glGetFloati_v",
"glGetFloatv",
"glGetFragDataIndex",
"glGetFragDataLocation",
"glGetFramebufferAttachmentParameteriv",
"glGetFramebufferParameteriv",
"glGetFramebufferParameterivMESA",
"glGetGraphicsResetStatus",
"glGetInteger64i_v",
"glGetInteger64v",
"glGetIntegeri_v",
"glGetIntegerv",
"glGetInternalformati64v",
"glGetInternalformativ",
"glGetMultisamplefv",
"glGetNamedBufferParameteri64v",
"glGetNamedBufferParameteriv",
"glGetNamedBufferPointerv",
"glGetNamedBufferSubData",
"glGetNamedFramebufferAttachmentParameteriv",
"glGetNamedFramebufferParameteriv",
"glGetNamedRenderbufferParameteriv",
"glGetObjectLabel",
"glGetObjectPtrLabel",
"glGetPointerv",
"glGetProgramBinary",
"glGetProgramInfoLog",
"glGetProgramInterfaceiv",
"glGetProgramPipelineInfoLog",
"glGetProgramPipelineiv",
"glGetProgramResourceIndex",
"glGetProgramResourceLocation",
"glGetProgramResourceLocationIndex",
"glGetProgramResourceName",
"glGetProgramResourceiv",
"glGetProgramStageiv",
"glGetProgramiv",
"glGetQueryBufferObjecti64v",
"glGetQueryBufferObjectiv",
"glGetQueryBufferObjectui64v",
"glGetQueryBufferObjectuiv",
"glGetQueryIndexediv",
"glGetQueryObjecti64v",
"glGetQueryObjectiv",
"glGetQueryObjectui64v",
"glGetQueryObjectuiv",
"glGetQueryiv",
"glGetRenderbufferParameteriv",
"glGetSamplerParameterIiv",
"glGetSamplerParameterIuiv",
"glGetSamplerParameterfv",
"glGetSamplerParameteriv",
"glGetShaderInfoLog",
"glGetShaderPrecisionFormat",
"glGetShaderSource",
"glGetShaderiv",
"glGetString",
"glGetStringi",
"glGetSubroutineIndex",
"glGetSubroutineUniformLocation",
"glGetSynciv",
"glGetTexImage",
"glGetTexLevelParameterfv",
"glGetTexLevelParameteriv",
"glGetTexParameterIiv",
"glGetTexParameterIuiv",
"glGetTexParameterfv",
"glGetTexParameteriv",
"glGetTextureImage",
"glGetTextureLevelParameterfv",
"glGetTextureLevelParameteriv",
"glGetTextureParameterIiv",
"glGetTextureParameterIuiv",
"glGetTextureParameterfv",
"glGetTextureParameteriv",
"glGetTextureSubImage",
"glGetTransformFeedbackVarying",
"glGetTransformFeedbacki64_v",
"glGetTransformFeedbacki_v",
"glGetTransformFeedbackiv",
"glGetUniformBlockIndex",
"glGetUniformIndices",
"glGetUniformLocation",
"glGetUniformSubroutineuiv",
"glGetUniformdv",
"glGetUniformfv",
"glGetUniformiv",
"glGetUniformuiv",
"glGetVertexArrayIndexed64iv",
"glGetVertexArrayIndexediv",
"glGetVertexArrayiv",
"glGetVertexAttribIiv",
"glGetVertexAttribIuiv",
"glGetVertexAttribLdv",
"glGetVertexAttribPointerv",
"glGetVertexAttribdv",
"glGetVertexAttribfv",
"glGetVertexAttribiv",
"glGetnCompressedTexImage",
"glGetnTexImage",
"glGetnUniformdv",
"glGetnUniformfv",
"glGetnUniformiv",
"glGetnUniformuiv",
"glHint",
"glInvalidateBufferData",
"glInvalidateBufferSubData",
"glInvalidateFramebuffer",
"glInvalidateNamedFramebufferData",
"glInvalidateNamedFramebufferSubData",
"glInvalidateSubFramebuffer",
"glInvalidateTexImage",
"glInvalidateTexSubImage",
"glIsBuffer",
"glIsEnabled",
"glIsEnabledi",
"glIsFramebuffer",
"glIsProgram",
"glIsProgramPipeline",
"glIsQuery",
"glIsRenderbuffer",
"glIsSampler",
"glIsShader",
"glIsSync",
"glIsTexture",
"glIsTransformFeedback",
"glIsVertexArray",
"glLineWidth",
"glLinkProgram",
"glLogicOp",
"glMapBuffer",
"glMapBufferRange",
"glMapNamedBuffer",
"glMapNamedBufferRange",
"glMemoryBarrier",
"glMemoryBarrierByRegion",
"glMinSampleShading",
"glMultiDrawArrays",
"glMultiDrawArraysIndirect",
"glMultiDrawArraysIndirectCount",
"glMultiDrawElements",
"glMultiDrawElementsBaseVertex",
"glMultiDrawElementsIndirect",
"glMultiDrawElementsIndirectCount",
"glNamedBufferData",
"glNamedBufferStorage",
"glNamedBufferSubData",
"glNamedFramebufferDrawBuffer",
"glNamedFramebufferDrawBuffers",
"glNamedFramebufferParameteri",
"glNamedFramebufferReadBuffer",
"glNamedFramebufferRenderbuffer",
"glNamedFramebufferTexture",
"glNamedFramebufferTextureLayer",
"glNamedRenderbufferStorage",
"glNamedRenderbufferStorageMultisample",
"glObjectLabel",
"glObjectPtrLabel",
"glPatchParameterfv",
"glPatchParameteri",
"glPauseTransformFeedback",
"glPixelStoref",
"glPixelStorei",
"glPointParameterf",
"glPointParameterfv",
"glPointParameteri",
"glPointParameteriv",
"glPointSize",
"glPolygonMode",
"glPolygonOffset",
"glPolygonOffsetClamp",
"glPopDebugGroup",
"glPrimitiveRestartIndex",
"glProgramBinary",
"glProgramParameteri",
"glProgramUniform1d",
"glProgramUniform1dv",
"glProgramUniform1f",
"glProgramUniform1fv",
"glProgramUniform1i",
"glProgramUniform1iv",
"glProgramUniform1ui",
"glProgramUniform1uiv",
"glProgramUniform2d",
"glProgramUniform2dv",
"glProgramUniform2f",
"glProgramUniform2fv",
"glProgramUniform2i",
"glProgramUniform2iv",
"glProgramUniform2ui",
"glProgramUniform2uiv",
"glProgramUniform3d",
"glProgramUniform3dv",
"glProgramUniform3f",
"glProgramUniform3fv",
"glProgramUniform3i",
"glProgramUniform3iv",
"glProgramUniform3ui",
"glProgramUniform3uiv",
"glProgramUniform4d",
"glProgramUniform4dv",
"glProgramUniform4f",
"glProgramUniform4fv",
"glProgramUniform4i",
"glProgramUniform4iv",
"glProgramUniform4ui",
"glProgramUniform4uiv",
"glProgramUniformMatrix2dv",
"glProgramUniformMatrix2fv",
"glProgramUniformMatrix2x3dv",
"glProgramUniformMatrix2x3fv",
"glProgramUniformMatrix2x4dv",
"glProgramUniformMatrix2x4fv",
"glProgramUniformMatrix3dv",
"glProgramUniformMatrix3fv",
"glProgramUniformMatrix3x2dv",
"glProgramUniformMatrix3x2fv",
"glProgramUniformMatrix3x4dv",
"glProgramUniformMatrix3x4fv",
"glProgramUniformMatrix4dv",
"glProgramUniformMatrix4fv",
"glProgramUniformMatrix4x2dv",
"glProgramUniformMatrix4x2fv",
"glProgramUniformMatrix4x3dv",
"glProgramUniformMatrix4x3fv",
"glProvokingVertex",
"glPushDebugGroup",
"glQueryCounter",
"glReadBuffer",
"glReadPixels",
"glReadnPixels",
"glReleaseShaderCompiler",
"glRenderbufferStorage",
"glRenderbufferStorageMultisample",
"glResumeTransformFeedback",
"glSampleCoverage",
"glSampleMaski",
"glSamplerParameterIiv",
"glSamplerParameterIuiv",
"glSamplerParameterf",
"glSamplerParameterfv",
"glSamplerParameteri",
"glSamplerParameteriv",
"glScissor",
"glScissorArrayv",
"glScissorIndexed",
"glScissorIndexedv",
"glShaderBinary",
"glShaderSource",
"glShaderStorageBlockBinding",
"glSpecializeShader",
"glStencilFunc",
"glStencilFuncSeparate",
"glStencilMask",
"glStencilMaskSeparate",
"glStencilOp",
"glStencilOpSeparate",
"glTexBuffer",
"glTexBufferRange",
"glTexImage1D",
"glTexImage2D",
"glTexImage2DMultisample",
"glTexImage3D",
"glTexImage3DMultisample",
"glTexParameterIiv",
"glTexParameterIuiv",
"glTexParameterf",
"glTexParameterfv",
"glTexParameteri",
"glTexParameteriv",
"glTexStorage1D",
"glTexStorage2D",
"glTexStorage2DMultisample",
"glTexStorage3D",
"glTexStorage3DMultisample",
"glTexSubImage1D",
"glTexSubImage2D",
"glTexSubImage3D",
"glTextureBarrier",
"glTextureBuffer",
"glTextureBufferRange",
"glTextureParameterIiv",
"glTextureParameterIuiv",
"glTextureParameterf",
"glTextureParameterfv",
"glTextureParameteri",
"glTextureParameteriv",
"glTextureStorage1D",
"glTextureStorage2D",
"glTextureStorage2DMultisample",
"glTextureStorage3D",
"glTextureStorage3DMultisample",
"glTextureSubImage1D",
"glTextureSubImage2D",
"glTextureSubImage3D",
"glTextureView",
"glTransformFeedbackBufferBase",
"glTransformFeedbackBufferRange",
"glTransformFeedbackVaryings",
"glUniform1d",
"glUniform1dv",
"glUniform1f",
"glUniform1fv",
"glUniform1i",
"glUniform1iv",
"glUniform1ui",
"glUniform1uiv",
"glUniform2d",
"glUniform2dv",
"glUniform2f",
"glUniform2fv",
"glUniform2i",
"glUniform2iv",
"glUniform2ui",
"glUniform2uiv",
"glUniform3d",
"glUniform3dv",
"glUniform3f",
"glUniform3fv",
"glUniform3i",
"glUniform3iv",
"glUniform3ui",
"glUniform3uiv",
"glUniform4d",
"glUniform4dv",
"glUniform4f",
"glUniform4fv",
"glUniform4i",
"glUniform4iv",
"glUniform4ui",
"glUniform4uiv",
"glUniformBlockBinding",
"glUniformMatrix2dv",
"glUniformMatrix2fv",
"glUniformMatrix2x3dv",
"glUniformMatrix2x3fv",
"glUniformMatrix2x4dv",
"glUniformMatrix2x4fv",
"glUniformMatrix3dv",
"glUniformMatrix3fv",
"glUniformMatrix3x2dv",
"glUniformMatrix3x2fv",
"glUniformMatrix3x4dv",
"glUniformMatrix3x4fv",
"glUniformMatrix4dv",
"glUniformMatrix4fv",
"glUniformMatrix4x2dv",
"glUniformMatrix4x2fv",
"glUniformMatrix4x3dv",
"glUniformMatrix4x3fv",
"glUniformSubroutinesuiv",
"glUnmapBuffer",
"glUnmapNamedBuffer",
"glUseProgram",
"glUseProgramStages",
"glValidateProgram",
"glValidateProgramPipeline",
"glVertexArrayAttribBinding",
"glVertexArrayAttribFormat",
"glVertexArrayAttribIFormat",
"glVertexArrayAttribLFormat",
"glVertexArrayBindingDivisor",
"glVertexArrayElementBuffer",
"glVertexArrayVertexBuffer",
"glVertexArrayVertexBuffers",
"glVertexAttrib1d",
"glVertexAttrib1dv",
"glVertexAttrib1f",
"glVertexAttrib1fv",
"glVertexAttrib1s",
"glVertexAttrib1sv",
"glVertexAttrib2d",
"glVertexAttrib2dv",
"glVertexAttrib2f",
"glVertexAttrib2fv",
"glVertexAttrib2s",
"glVertexAttrib2sv",
"glVertexAttrib3d",
"glVertexAttrib3dv",
"glVertexAttrib3f",
"glVertexAttrib3fv",
"glVertexAttrib3s",
"glVertexAttrib3sv",
"glVertexAttrib4Nbv",
"glVertexAttrib4Niv",
"glVertexAttrib4Nsv",
"glVertexAttrib4Nub",
"glVertexAttrib4Nubv",
"glVertexAttrib4Nuiv",
"glVertexAttrib4Nusv",
"glVertexAttrib4bv",
"glVertexAttrib4d",
"glVertexAttrib4dv",
"glVertexAttrib4f",
"glVertexAttrib4fv",
"glVertexAttrib4iv",
"glVertexAttrib4s",
"glVertexAttrib4sv",
"glVertexAttrib4ubv",
"glVertexAttrib4uiv",
"glVertexAttrib4usv",
"glVertexAttribBinding",
"glVertexAttribDivisor",
"glVertexAttribFormat",
"glVertexAttribI1i",
"glVertexAttribI1iv",
"glVertexAttribI1ui",
"glVertexAttribI1uiv",
"glVertexAttribI2i",
"glVertexAttribI2iv",
"glVertexAttribI2ui",
"glVertexAttribI2uiv",
"glVertexAttribI3i",
"glVertexAttribI3iv",
"glVertexAttribI3ui",
"glVertexAttribI3uiv",
"glVertexAttribI4bv",
"glVertexAttribI4i",
"glVertexAttribI4iv",
"glVertexAttribI4sv",
"glVertexAttribI4ubv",
"glVertexAttribI4ui",
"glVertexAttribI4uiv",
"glVertexAttribI4usv",
"glVertexAttribIFormat",
"glVertexAttribIPointer",
"glVertexAttribL1d",
"glVertexAttribL1dv",
"glVertexAttribL2d",
"glVertexAttribL2dv",
"glVertexAttribL3d",
"glVertexAttribL3dv",
"glVertexAttribL4d",
"glVertexAttribL4dv",
"glVertexAttribLFormat",
"glVertexAttribLPointer",
"glVertexAttribP1ui",
"glVertexAttribP1uiv",
"glVertexAttribP2ui",
"glVertexAttribP2uiv",
"glVertexAttribP3ui",
"glVertexAttribP3uiv",
"glVertexAttribP4ui",
"glVertexAttribP4uiv",
"glVertexAttribPointer",
"glVertexBindingDivisor",
"glViewport",
"glViewportArrayv",
"glViewportIndexedf",
"glViewportIndexedfv",
"glWaitSync",
};
GL3W_API union GL3WProcs gl3wProcs;
static void load_procs(GL3WGetProcAddressProc proc)
{
size_t i;
for (i = 0; i < ARRAY_SIZE(proc_names); i++)
gl3wProcs.ptr[i] = proc(proc_names[i]);
}

430
thirdparty/imgui_suite/gl3w/gl3w_gen.py vendored Normal file
View File

@@ -0,0 +1,430 @@
#!/usr/bin/env python
# This file is part of gl3w, hosted at https://github.com/skaslev/gl3w
#
# This is free and unencumbered software released into the public domain.
#
# Anyone is free to copy, modify, publish, use, compile, sell, or
# distribute this software, either in source code form or as a compiled
# binary, for any purpose, commercial or non-commercial, and by any
# means.
#
# In jurisdictions that recognize copyright laws, the author or authors
# of this software dedicate any and all copyright interest in the
# software to the public domain. We make this dedication for the benefit
# of the public at large and to the detriment of our heirs and
# successors. We intend this dedication to be an overt act of
# relinquishment in perpetuity of all present and future rights to this
# software under copyright law.
#
# THE SOFTWARE IS 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 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 SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
# Allow Python 2.6+ to use the print() function
from __future__ import print_function
import argparse
import os
import re
# Try to import Python 3 library urllib.request
# and if it fails, fall back to Python 2 urllib2
try:
import urllib.request as urllib2
except ImportError:
import urllib2
# UNLICENSE copyright header
UNLICENSE = r'''/*
* This file was generated with gl3w_gen.py, part of gl3w
* (hosted at https://github.com/skaslev/gl3w)
*
* This is free and unencumbered software released into the public domain.
*
* Anyone is free to copy, modify, publish, use, compile, sell, or
* distribute this software, either in source code form or as a compiled
* binary, for any purpose, commercial or non-commercial, and by any
* means.
*
* In jurisdictions that recognize copyright laws, the author or authors
* of this software dedicate any and all copyright interest in the
* software to the public domain. We make this dedication for the benefit
* of the public at large and to the detriment of our heirs and
* successors. We intend this dedication to be an overt act of
* relinquishment in perpetuity of all present and future rights to this
* software under copyright law.
*
* THE SOFTWARE IS 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 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 SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
'''
EXT_SUFFIX = ['ARB', 'EXT', 'KHR', 'OVR', 'NV', 'AMD', 'INTEL']
def is_ext(proc):
return any(proc.endswith(suffix) for suffix in EXT_SUFFIX)
def write(f, s):
f.write(s.encode('utf-8'))
def touch_dir(path):
if not os.path.exists(path):
os.makedirs(path)
def download(url, dst):
if os.path.exists(dst):
print('Reusing {0}...'.format(dst))
return
print('Downloading {0}...'.format(dst))
web = urllib2.urlopen(urllib2.Request(url, headers={'User-Agent': 'Mozilla/5.0'}))
with open(dst, 'wb') as f:
f.writelines(web.readlines())
parser = argparse.ArgumentParser(description='gl3w generator script')
parser.add_argument('--ext', action='store_true', help='Load extensions')
parser.add_argument('--root', type=str, default='', help='Root directory')
args = parser.parse_args()
# Create directories
touch_dir(os.path.join(args.root, 'include/GL'))
touch_dir(os.path.join(args.root, 'include/KHR'))
touch_dir(os.path.join(args.root, 'src'))
# Download glcorearb.h and khrplatform.h
download('https://www.khronos.org/registry/OpenGL/api/GL/glcorearb.h',
os.path.join(args.root, 'include/GL/glcorearb.h'))
download('https://www.khronos.org/registry/EGL/api/KHR/khrplatform.h',
os.path.join(args.root, 'include/KHR/khrplatform.h'))
# Parse function names from glcorearb.h
print('Parsing glcorearb.h header...')
procs = []
p = re.compile(r'GLAPI.*APIENTRY\s+(\w+)')
with open(os.path.join(args.root, 'include/GL/glcorearb.h'), 'r') as f:
for line in f:
m = p.match(line)
if not m:
continue
proc = m.group(1)
if args.ext or not is_ext(proc):
procs.append(proc)
procs.sort()
# Generate gl3w.h
print('Generating {0}...'.format(os.path.join(args.root, 'include/GL/gl3w.h')))
with open(os.path.join(args.root, 'include/GL/gl3w.h'), 'wb') as f:
write(f, UNLICENSE)
write(f, r'''#ifndef __gl3w_h_
#define __gl3w_h_
#include <GL/glcorearb.h>
#ifndef GL3W_API
#define GL3W_API
#endif
#ifndef __gl_h_
#define __gl_h_
#endif
#ifdef __cplusplus
extern "C" {
#endif
#define GL3W_OK 0
#define GL3W_ERROR_INIT -1
#define GL3W_ERROR_LIBRARY_OPEN -2
#define GL3W_ERROR_OPENGL_VERSION -3
typedef void (*GL3WglProc)(void);
typedef GL3WglProc (*GL3WGetProcAddressProc)(const char *proc);
/* gl3w api */
GL3W_API int gl3wInit(void);
GL3W_API int gl3wInit2(GL3WGetProcAddressProc proc);
GL3W_API int gl3wIsSupported(int major, int minor);
GL3W_API GL3WglProc gl3wGetProcAddress(const char *proc);
/* gl3w internal state */
''')
write(f, 'union GL3WProcs {\n')
write(f, '\tGL3WglProc ptr[{0}];\n'.format(len(procs)))
write(f, '\tstruct {\n')
for proc in procs:
write(f, '\t\t{0: <55} {1};\n'.format('PFN{0}PROC'.format(proc.upper()), proc[2:]))
write(f, r''' } gl;
};
GL3W_API extern union GL3WProcs gl3wProcs;
/* OpenGL functions */
''')
for proc in procs:
write(f, '#define {0: <48} gl3wProcs.gl.{1}\n'.format(proc, proc[2:]))
write(f, r'''
#ifdef __cplusplus
}
#endif
#endif
''')
# Generate gl3w.c
print('Generating {0}...'.format(os.path.join(args.root, 'src/gl3w.c')))
with open(os.path.join(args.root, 'src/gl3w.c'), 'wb') as f:
write(f, UNLICENSE)
write(f, r'''#include <GL/gl3w.h>
#include <stdlib.h>
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
#if defined(_WIN32)
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN 1
#endif
#include <windows.h>
static HMODULE libgl;
typedef PROC(__stdcall* GL3WglGetProcAddr)(LPCSTR);
static GL3WglGetProcAddr wgl_get_proc_address;
static int open_libgl(void)
{
libgl = LoadLibraryA("opengl32.dll");
if (!libgl)
return GL3W_ERROR_LIBRARY_OPEN;
wgl_get_proc_address = (GL3WglGetProcAddr)GetProcAddress(libgl, "wglGetProcAddress");
return GL3W_OK;
}
static void close_libgl(void)
{
FreeLibrary(libgl);
}
static GL3WglProc get_proc(const char *proc)
{
GL3WglProc res;
res = (GL3WglProc)wgl_get_proc_address(proc);
if (!res)
res = (GL3WglProc)GetProcAddress(libgl, proc);
return res;
}
#elif defined(__APPLE__)
#include <dlfcn.h>
static void *libgl;
static int open_libgl(void)
{
libgl = dlopen("/System/Library/Frameworks/OpenGL.framework/OpenGL", RTLD_LAZY | RTLD_LOCAL);
if (!libgl)
return GL3W_ERROR_LIBRARY_OPEN;
return GL3W_OK;
}
static void close_libgl(void)
{
dlclose(libgl);
}
static GL3WglProc get_proc(const char *proc)
{
GL3WglProc res;
*(void **)(&res) = dlsym(libgl, proc);
return res;
}
#else
#include <dlfcn.h>
static void *libgl; /* OpenGL library */
static void *libglx; /* GLX library */
static void *libegl; /* EGL library */
static GL3WGetProcAddressProc gl_get_proc_address;
static void close_libgl(void)
{
if (libgl) {
dlclose(libgl);
libgl = NULL;
}
if (libegl) {
dlclose(libegl);
libegl = NULL;
}
if (libglx) {
dlclose(libglx);
libglx = NULL;
}
}
static int is_library_loaded(const char *name, void **lib)
{
*lib = dlopen(name, RTLD_LAZY | RTLD_LOCAL | RTLD_NOLOAD);
return *lib != NULL;
}
static int open_libs(void)
{
/* On Linux we have two APIs to get process addresses: EGL and GLX.
* EGL is supported under both X11 and Wayland, whereas GLX is X11-specific.
* First check what's already loaded, the windowing library might have
* already loaded either EGL or GLX and we want to use the same one.
*/
if (is_library_loaded("libEGL.so.1", &libegl) ||
is_library_loaded("libGLX.so.0", &libglx)) {
libgl = dlopen("libOpenGL.so.0", RTLD_LAZY | RTLD_LOCAL);
if (libgl)
return GL3W_OK;
else
close_libgl();
}
if (is_library_loaded("libGL.so.1", &libgl))
return GL3W_OK;
/* Neither is already loaded, so we have to load one. Try EGL first
* because it is supported under both X11 and Wayland.
*/
/* Load OpenGL + EGL */
libgl = dlopen("libOpenGL.so.0", RTLD_LAZY | RTLD_LOCAL);
libegl = dlopen("libEGL.so.1", RTLD_LAZY | RTLD_LOCAL);
if (libgl && libegl)
return GL3W_OK;
/* Fall back to legacy libGL, which includes GLX */
close_libgl();
libgl = dlopen("libGL.so.1", RTLD_LAZY | RTLD_LOCAL);
if (libgl)
return GL3W_OK;
return GL3W_ERROR_LIBRARY_OPEN;
}
static int open_libgl(void)
{
int res = open_libs();
if (res)
return res;
if (libegl)
*(void **)(&gl_get_proc_address) = dlsym(libegl, "eglGetProcAddress");
else if (libglx)
*(void **)(&gl_get_proc_address) = dlsym(libglx, "glXGetProcAddressARB");
else
*(void **)(&gl_get_proc_address) = dlsym(libgl, "glXGetProcAddressARB");
if (!gl_get_proc_address) {
close_libgl();
return GL3W_ERROR_LIBRARY_OPEN;
}
return GL3W_OK;
}
static GL3WglProc get_proc(const char *proc)
{
GL3WglProc res = NULL;
/* Before EGL version 1.5, eglGetProcAddress doesn't support querying core
* functions and may return a dummy function if we try, so try to load the
* function from the GL library directly first.
*/
if (libegl)
*(void **)(&res) = dlsym(libgl, proc);
if (!res)
res = gl_get_proc_address(proc);
if (!libegl && !res)
*(void **)(&res) = dlsym(libgl, proc);
return res;
}
#endif
static struct {
int major, minor;
} version;
static int parse_version(void)
{
if (!glGetIntegerv)
return GL3W_ERROR_INIT;
glGetIntegerv(GL_MAJOR_VERSION, &version.major);
glGetIntegerv(GL_MINOR_VERSION, &version.minor);
if (version.major < 3)
return GL3W_ERROR_OPENGL_VERSION;
return GL3W_OK;
}
static void load_procs(GL3WGetProcAddressProc proc);
int gl3wInit(void)
{
int res;
res = open_libgl();
if (res)
return res;
atexit(close_libgl);
return gl3wInit2(get_proc);
}
int gl3wInit2(GL3WGetProcAddressProc proc)
{
load_procs(proc);
return parse_version();
}
int gl3wIsSupported(int major, int minor)
{
if (major < 3)
return 0;
if (version.major == major)
return version.minor >= minor;
return version.major >= major;
}
GL3WglProc gl3wGetProcAddress(const char *proc)
{
return get_proc(proc);
}
static const char *proc_names[] = {
''')
for proc in procs:
write(f, '\t"{0}",\n'.format(proc))
write(f, r'''};
GL3W_API union GL3WProcs gl3wProcs;
static void load_procs(GL3WGetProcAddressProc proc)
{
size_t i;
for (i = 0; i < ARRAY_SIZE(proc_names); i++)
gl3wProcs.ptr[i] = proc(proc_names[i]);
}
''')

View File

@@ -0,0 +1,48 @@
# Usage:
# cmake -P GenerateMappings.cmake <path/to/mappings.h.in> <path/to/mappings.h>
set(source_url "https://raw.githubusercontent.com/gabomdq/SDL_GameControllerDB/master/gamecontrollerdb.txt")
set(source_path "${CMAKE_CURRENT_BINARY_DIR}/gamecontrollerdb.txt")
set(template_path "${CMAKE_ARGV3}")
set(target_path "${CMAKE_ARGV4}")
if (NOT EXISTS "${template_path}")
message(FATAL_ERROR "Failed to find template file ${template_path}")
endif()
file(DOWNLOAD "${source_url}" "${source_path}"
STATUS download_status
TLS_VERIFY on)
list(GET download_status 0 status_code)
list(GET download_status 1 status_message)
if (status_code)
message(FATAL_ERROR "Failed to download ${source_url}: ${status_message}")
endif()
file(STRINGS "${source_path}" lines)
foreach(line ${lines})
if (line MATCHES "^[0-9a-fA-F]")
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()
endforeach()
configure_file("${template_path}" "${target_path}" @ONLY NEWLINE_STYLE UNIX)
file(REMOVE "${source_path}")

View File

@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>${MACOSX_BUNDLE_EXECUTABLE_NAME}</string>
<key>CFBundleGetInfoString</key>
<string>${MACOSX_BUNDLE_INFO_STRING}</string>
<key>CFBundleIconFile</key>
<string>${MACOSX_BUNDLE_ICON_FILE}</string>
<key>CFBundleIdentifier</key>
<string>${MACOSX_BUNDLE_GUI_IDENTIFIER}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleLongVersionString</key>
<string>${MACOSX_BUNDLE_LONG_VERSION_STRING}</string>
<key>CFBundleName</key>
<string>${MACOSX_BUNDLE_BUNDLE_NAME}</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>${MACOSX_BUNDLE_SHORT_VERSION_STRING}</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>${MACOSX_BUNDLE_BUNDLE_VERSION}</string>
<key>CSResourcesFileMapped</key>
<true/>
<key>LSRequiresCarbon</key>
<true/>
<key>NSHumanReadableCopyright</key>
<string>${MACOSX_BUNDLE_COPYRIGHT}</string>
<key>NSHighResolutionCapable</key>
<true/>
</dict>
</plist>

View File

@@ -0,0 +1,29 @@
if (NOT EXISTS "@GLFW_BINARY_DIR@/install_manifest.txt")
message(FATAL_ERROR "Cannot find install manifest: \"@GLFW_BINARY_DIR@/install_manifest.txt\"")
endif()
file(READ "@GLFW_BINARY_DIR@/install_manifest.txt" files)
string(REGEX REPLACE "\n" ";" files "${files}")
foreach (file ${files})
message(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"")
if (EXISTS "$ENV{DESTDIR}${file}")
exec_program("@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
OUTPUT_VARIABLE rm_out
RETURN_VALUE rm_retval)
if (NOT "${rm_retval}" STREQUAL 0)
MESSAGE(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"")
endif()
elseif (IS_SYMLINK "$ENV{DESTDIR}${file}")
EXEC_PROGRAM("@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
OUTPUT_VARIABLE rm_out
RETURN_VALUE rm_retval)
if (NOT "${rm_retval}" STREQUAL 0)
message(FATAL_ERROR "Problem when removing symlink \"$ENV{DESTDIR}${file}\"")
endif()
else()
message(STATUS "File \"$ENV{DESTDIR}${file}\" does not exist.")
endif()
endforeach()

View File

@@ -0,0 +1,13 @@
prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=${prefix}
includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@
libdir=@CMAKE_INSTALL_FULL_LIBDIR@
Name: GLFW
Description: A multi-platform library for OpenGL, window and input
Version: @GLFW_VERSION@
URL: https://www.glfw.org/
Requires.private: @GLFW_PKG_CONFIG_REQUIRES_PRIVATE@
Libs: -L${libdir} -l@GLFW_LIB_NAME@
Libs.private: @GLFW_PKG_CONFIG_LIBS_PRIVATE@
Cflags: -I${includedir}

View File

@@ -0,0 +1,3 @@
include(CMakeFindDependencyMacro)
find_dependency(Threads)
include("${CMAKE_CURRENT_LIST_DIR}/glfw3Targets.cmake")

View File

@@ -0,0 +1,13 @@
# Define the environment for cross-compiling with 32-bit MinGW-w64 Clang
SET(CMAKE_SYSTEM_NAME Windows) # Target system name
SET(CMAKE_SYSTEM_VERSION 1)
SET(CMAKE_C_COMPILER "i686-w64-mingw32-clang")
SET(CMAKE_CXX_COMPILER "i686-w64-mingw32-clang++")
SET(CMAKE_RC_COMPILER "i686-w64-mingw32-windres")
SET(CMAKE_RANLIB "i686-w64-mingw32-ranlib")
# Configure the behaviour of the find commands
SET(CMAKE_FIND_ROOT_PATH "/usr/i686-w64-mingw32")
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

View File

@@ -0,0 +1,13 @@
# Define the environment for cross-compiling with 32-bit MinGW-w64 GCC
SET(CMAKE_SYSTEM_NAME Windows) # Target system name
SET(CMAKE_SYSTEM_VERSION 1)
SET(CMAKE_C_COMPILER "i686-w64-mingw32-gcc")
SET(CMAKE_CXX_COMPILER "i686-w64-mingw32-g++")
SET(CMAKE_RC_COMPILER "i686-w64-mingw32-windres")
SET(CMAKE_RANLIB "i686-w64-mingw32-ranlib")
# Configure the behaviour of the find commands
SET(CMAKE_FIND_ROOT_PATH "/usr/i686-w64-mingw32")
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

View File

@@ -0,0 +1,17 @@
# Find EpollShim
# Once done, this will define
#
# EPOLLSHIM_FOUND - System has EpollShim
# EPOLLSHIM_INCLUDE_DIRS - The EpollShim include directories
# EPOLLSHIM_LIBRARIES - The libraries needed to use EpollShim
find_path(EPOLLSHIM_INCLUDE_DIRS NAMES sys/epoll.h sys/timerfd.h HINTS /usr/local/include/libepoll-shim)
find_library(EPOLLSHIM_LIBRARIES NAMES epoll-shim libepoll-shim HINTS /usr/local/lib)
if (EPOLLSHIM_INCLUDE_DIRS AND EPOLLSHIM_LIBRARIES)
set(EPOLLSHIM_FOUND TRUE)
endif (EPOLLSHIM_INCLUDE_DIRS AND EPOLLSHIM_LIBRARIES)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(EpollShim DEFAULT_MSG EPOLLSHIM_LIBRARIES EPOLLSHIM_INCLUDE_DIRS)
mark_as_advanced(EPOLLSHIM_INCLUDE_DIRS EPOLLSHIM_LIBRARIES)

View File

@@ -0,0 +1,18 @@
# Try to find OSMesa on a Unix system
#
# This will define:
#
# OSMESA_LIBRARIES - Link these to use OSMesa
# OSMESA_INCLUDE_DIR - Include directory for OSMesa
#
# Copyright (c) 2014 Brandon Schaefer <brandon.schaefer@canonical.com>
if (NOT WIN32)
find_package (PkgConfig)
pkg_check_modules (PKG_OSMESA QUIET osmesa)
set (OSMESA_INCLUDE_DIR ${PKG_OSMESA_INCLUDE_DIRS})
set (OSMESA_LIBRARIES ${PKG_OSMESA_LIBRARIES})
endif ()

View File

@@ -0,0 +1,13 @@
# Define the environment for cross-compiling with 64-bit MinGW-w64 Clang
SET(CMAKE_SYSTEM_NAME Windows) # Target system name
SET(CMAKE_SYSTEM_VERSION 1)
SET(CMAKE_C_COMPILER "x86_64-w64-mingw32-clang")
SET(CMAKE_CXX_COMPILER "x86_64-w64-mingw32-clang++")
SET(CMAKE_RC_COMPILER "x86_64-w64-mingw32-windres")
SET(CMAKE_RANLIB "x86_64-w64-mingw32-ranlib")
# Configure the behaviour of the find commands
SET(CMAKE_FIND_ROOT_PATH "/usr/x86_64-w64-mingw32")
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

View File

@@ -0,0 +1,13 @@
# Define the environment for cross-compiling with 64-bit MinGW-w64 GCC
SET(CMAKE_SYSTEM_NAME Windows) # Target system name
SET(CMAKE_SYSTEM_VERSION 1)
SET(CMAKE_C_COMPILER "x86_64-w64-mingw32-gcc")
SET(CMAKE_CXX_COMPILER "x86_64-w64-mingw32-g++")
SET(CMAKE_RC_COMPILER "x86_64-w64-mingw32-windres")
SET(CMAKE_RANLIB "x86_64-w64-mingw32-ranlib")
# Configure the behaviour of the find commands
SET(CMAKE_FIND_ROOT_PATH "/usr/x86_64-w64-mingw32")
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

View File

@@ -0,0 +1,179 @@
cmake_minimum_required(VERSION 3.4...3.20 FATAL_ERROR)
project(GLFW VERSION 3.4.0 LANGUAGES C)
set(CMAKE_LEGACY_CYGWIN_WIN32 OFF)
if (POLICY CMP0054)
cmake_policy(SET CMP0054 NEW)
endif()
if (POLICY CMP0069)
cmake_policy(SET CMP0069 NEW)
endif()
if (POLICY CMP0077)
cmake_policy(SET CMP0077 NEW)
endif()
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
set(GLFW_STANDALONE TRUE)
endif()
option(BUILD_SHARED_LIBS "Build shared libraries" OFF)
option(GLFW_BUILD_EXAMPLES "Build the GLFW example programs" ${GLFW_STANDALONE})
option(GLFW_BUILD_TESTS "Build the GLFW test programs" ${GLFW_STANDALONE})
option(GLFW_BUILD_DOCS "Build the GLFW documentation" ON)
option(GLFW_INSTALL "Generate installation target" ON)
include(GNUInstallDirs)
include(CMakeDependentOption)
if (GLFW_USE_OSMESA)
message(FATAL_ERROR "GLFW_USE_OSMESA has been removed; set the GLFW_PLATFORM init hint")
endif()
cmake_dependent_option(GLFW_BUILD_WIN32 "Build support for Win32" ON "WIN32" OFF)
cmake_dependent_option(GLFW_BUILD_COCOA "Build support for Cocoa" ON "APPLE" OFF)
cmake_dependent_option(GLFW_BUILD_X11 "Build support for X11" ON "UNIX;NOT APPLE" OFF)
cmake_dependent_option(GLFW_BUILD_WAYLAND "Build support for Wayland"
"${GLFW_USE_WAYLAND}" "UNIX;NOT APPLE" OFF)
cmake_dependent_option(GLFW_USE_HYBRID_HPG "Force use of high-performance GPU on hybrid systems" OFF
"WIN32" OFF)
cmake_dependent_option(USE_MSVC_RUNTIME_LIBRARY_DLL "Use MSVC runtime library DLL" ON
"MSVC" OFF)
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()
list(APPEND CMAKE_MODULE_PATH "${GLFW_SOURCE_DIR}/CMake/modules")
find_package(Threads REQUIRED)
if (GLFW_BUILD_DOCS)
set(DOXYGEN_SKIP_DOT TRUE)
find_package(Doxygen)
endif()
#--------------------------------------------------------------------
# Report backend selection
#--------------------------------------------------------------------
if (GLFW_BUILD_WIN32)
message(STATUS "Including Win32 support")
endif()
if (GLFW_BUILD_COCOA)
message(STATUS "Including Cocoa support")
endif()
if (GLFW_BUILD_WAYLAND)
message(STATUS "Including Wayland support")
endif()
if (GLFW_BUILD_X11)
message(STATUS "Including X11 support")
endif()
#--------------------------------------------------------------------
# Apply Microsoft C runtime library option
# This is here because it also applies to tests and examples
#--------------------------------------------------------------------
if (MSVC AND NOT USE_MSVC_RUNTIME_LIBRARY_DLL)
if (CMAKE_VERSION VERSION_LESS 3.15)
foreach (flag CMAKE_C_FLAGS
CMAKE_C_FLAGS_DEBUG
CMAKE_C_FLAGS_RELEASE
CMAKE_C_FLAGS_MINSIZEREL
CMAKE_C_FLAGS_RELWITHDEBINFO)
if (flag MATCHES "/MD")
string(REGEX REPLACE "/MD" "/MT" ${flag} "${${flag}}")
endif()
if (flag MATCHES "/MDd")
string(REGEX REPLACE "/MDd" "/MTd" ${flag} "${${flag}}")
endif()
endforeach()
else()
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
endif()
endif()
#--------------------------------------------------------------------
# Create generated files
#--------------------------------------------------------------------
include(CMakePackageConfigHelpers)
set(GLFW_CONFIG_PATH "${CMAKE_INSTALL_LIBDIR}/cmake/glfw3")
configure_package_config_file(CMake/glfw3Config.cmake.in
src/glfw3Config.cmake
INSTALL_DESTINATION "${GLFW_CONFIG_PATH}"
NO_CHECK_REQUIRED_COMPONENTS_MACRO)
write_basic_package_version_file(src/glfw3ConfigVersion.cmake
VERSION ${GLFW_VERSION}
COMPATIBILITY SameMajorVersion)
#--------------------------------------------------------------------
# Add subdirectories
#--------------------------------------------------------------------
add_subdirectory(src)
if (GLFW_BUILD_EXAMPLES)
add_subdirectory(examples)
endif()
if (GLFW_BUILD_TESTS)
add_subdirectory(tests)
endif()
if (DOXYGEN_FOUND AND GLFW_BUILD_DOCS)
add_subdirectory(docs)
endif()
#--------------------------------------------------------------------
# Install files other than the library
# The library is installed by src/CMakeLists.txt
#--------------------------------------------------------------------
if (GLFW_INSTALL)
install(DIRECTORY include/GLFW DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
FILES_MATCHING PATTERN glfw3.h PATTERN glfw3native.h)
install(FILES "${GLFW_BINARY_DIR}/src/glfw3Config.cmake"
"${GLFW_BINARY_DIR}/src/glfw3ConfigVersion.cmake"
DESTINATION "${GLFW_CONFIG_PATH}")
install(EXPORT glfwTargets FILE glfw3Targets.cmake
EXPORT_LINK_INTERFACE_LIBRARIES
DESTINATION "${GLFW_CONFIG_PATH}")
install(FILES "${GLFW_BINARY_DIR}/src/glfw3.pc"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
if (DOXYGEN_FOUND AND GLFW_BUILD_DOCS)
install(DIRECTORY "${GLFW_BINARY_DIR}/docs/html"
DESTINATION "${CMAKE_INSTALL_DOCDIR}")
endif()
# Only generate this target if no higher-level project already has
if (NOT TARGET uninstall)
configure_file(CMake/cmake_uninstall.cmake.in
cmake_uninstall.cmake IMMEDIATE @ONLY)
add_custom_target(uninstall
"${CMAKE_COMMAND}" -P
"${GLFW_BINARY_DIR}/cmake_uninstall.cmake")
set_target_properties(uninstall PROPERTIES FOLDER "GLFW3")
endif()
endif()

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,634 @@
/*************************************************************************
* GLFW 3.4 - www.glfw.org
* A library for OpenGL, window and input
*------------------------------------------------------------------------
* Copyright (c) 2002-2006 Marcus Geelnard
* Copyright (c) 2006-2018 Camilla Löwy <elmindreda@glfw.org>
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would
* be appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and must not
* be misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source
* distribution.
*
*************************************************************************/
#ifndef _glfw3_native_h_
#define _glfw3_native_h_
#ifdef __cplusplus
extern "C" {
#endif
/*************************************************************************
* Doxygen documentation
*************************************************************************/
/*! @file glfw3native.h
* @brief The header of the native access functions.
*
* This is the header file of the native access functions. See @ref native for
* more information.
*/
/*! @defgroup native Native access
* @brief Functions related to accessing native handles.
*
* **By using the native access functions you assert that you know what you're
* doing and how to fix problems caused by using them. If you don't, you
* shouldn't be using them.**
*
* Before the inclusion of @ref glfw3native.h, you may define zero or more
* window system API macro and zero or more context creation API macros.
*
* The chosen backends must match those the library was compiled for. Failure
* to do this will cause a link-time error.
*
* The available window API macros are:
* * `GLFW_EXPOSE_NATIVE_WIN32`
* * `GLFW_EXPOSE_NATIVE_COCOA`
* * `GLFW_EXPOSE_NATIVE_X11`
* * `GLFW_EXPOSE_NATIVE_WAYLAND`
*
* The available context API macros are:
* * `GLFW_EXPOSE_NATIVE_WGL`
* * `GLFW_EXPOSE_NATIVE_NSGL`
* * `GLFW_EXPOSE_NATIVE_GLX`
* * `GLFW_EXPOSE_NATIVE_EGL`
* * `GLFW_EXPOSE_NATIVE_OSMESA`
*
* These macros select which of the native access functions that are declared
* and which platform-specific headers to include. It is then up your (by
* definition platform-specific) code to handle which of these should be
* defined.
*
* If you do not want the platform-specific headers to be included, define
* `GLFW_NATIVE_INCLUDE_NONE` before including the @ref glfw3native.h header.
*
* @code
* #define GLFW_EXPOSE_NATIVE_WIN32
* #define GLFW_EXPOSE_NATIVE_WGL
* #define GLFW_NATIVE_INCLUDE_NONE
* #include <GLFW/glfw3native.h>
* @endcode
*/
/*************************************************************************
* System headers and types
*************************************************************************/
#if !defined(GLFW_NATIVE_INCLUDE_NONE)
#if defined(GLFW_EXPOSE_NATIVE_WIN32) || defined(GLFW_EXPOSE_NATIVE_WGL)
/* This is a workaround for the fact that glfw3.h needs to export APIENTRY (for
* example to allow applications to correctly declare a GL_KHR_debug callback)
* but windows.h assumes no one will define APIENTRY before it does
*/
#if defined(GLFW_APIENTRY_DEFINED)
#undef APIENTRY
#undef GLFW_APIENTRY_DEFINED
#endif
#include <windows.h>
#endif
#if defined(GLFW_EXPOSE_NATIVE_COCOA) || defined(GLFW_EXPOSE_NATIVE_NSGL)
#if defined(__OBJC__)
#import <Cocoa/Cocoa.h>
#else
#include <ApplicationServices/ApplicationServices.h>
#include <objc/objc.h>
#endif
#endif
#if defined(GLFW_EXPOSE_NATIVE_X11) || defined(GLFW_EXPOSE_NATIVE_GLX)
#include <X11/Xlib.h>
#include <X11/extensions/Xrandr.h>
#endif
#if defined(GLFW_EXPOSE_NATIVE_WAYLAND)
#include <wayland-client.h>
#endif
#if defined(GLFW_EXPOSE_NATIVE_WGL)
/* WGL is declared by windows.h */
#endif
#if defined(GLFW_EXPOSE_NATIVE_NSGL)
/* NSGL is declared by Cocoa.h */
#endif
#if defined(GLFW_EXPOSE_NATIVE_GLX)
/* This is a workaround for the fact that glfw3.h defines GLAPIENTRY because by
* default it also acts as an OpenGL header
* However, glx.h will include gl.h, which will define it unconditionally
*/
#if defined(GLFW_GLAPIENTRY_DEFINED)
#undef GLAPIENTRY
#undef GLFW_GLAPIENTRY_DEFINED
#endif
#include <GL/glx.h>
#endif
#if defined(GLFW_EXPOSE_NATIVE_EGL)
#include <EGL/egl.h>
#endif
#if defined(GLFW_EXPOSE_NATIVE_OSMESA)
/* This is a workaround for the fact that glfw3.h defines GLAPIENTRY because by
* default it also acts as an OpenGL header
* However, osmesa.h will include gl.h, which will define it unconditionally
*/
#if defined(GLFW_GLAPIENTRY_DEFINED)
#undef GLAPIENTRY
#undef GLFW_GLAPIENTRY_DEFINED
#endif
#include <GL/osmesa.h>
#endif
#endif /*GLFW_NATIVE_INCLUDE_NONE*/
/*************************************************************************
* Functions
*************************************************************************/
#if defined(GLFW_EXPOSE_NATIVE_WIN32)
/*! @brief Returns the adapter device name of the specified monitor.
*
* @return The UTF-8 encoded adapter device name (for example `\\.\DISPLAY1`)
* of the specified monitor, or `NULL` if an [error](@ref error_handling)
* occurred.
*
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
*
* @thread_safety This function may be called from any thread. Access is not
* synchronized.
*
* @since Added in version 3.1.
*
* @ingroup native
*/
GLFWAPI const char* glfwGetWin32Adapter(GLFWmonitor* monitor);
/*! @brief Returns the display device name of the specified monitor.
*
* @return The UTF-8 encoded display device name (for example
* `\\.\DISPLAY1\Monitor0`) of the specified monitor, or `NULL` if an
* [error](@ref error_handling) occurred.
*
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
*
* @thread_safety This function may be called from any thread. Access is not
* synchronized.
*
* @since Added in version 3.1.
*
* @ingroup native
*/
GLFWAPI const char* glfwGetWin32Monitor(GLFWmonitor* monitor);
/*! @brief Returns the `HWND` of the specified window.
*
* @return The `HWND` of the specified window, or `NULL` if an
* [error](@ref error_handling) occurred.
*
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
*
* @remark The `HDC` associated with the window can be queried with the
* [GetDC](https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getdc)
* function.
* @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
* synchronized.
*
* @since Added in version 3.0.
*
* @ingroup native
*/
GLFWAPI HWND glfwGetWin32Window(GLFWwindow* window);
#endif
#if defined(GLFW_EXPOSE_NATIVE_WGL)
/*! @brief Returns the `HGLRC` of the specified window.
*
* @return The `HGLRC` of the specified window, or `NULL` if an
* [error](@ref error_handling) occurred.
*
* @errors Possible errors include @ref GLFW_NO_WINDOW_CONTEXT and @ref
* GLFW_NOT_INITIALIZED.
*
* @remark The `HDC` associated with the window can be queried with the
* [GetDC](https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getdc)
* function.
* @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
* synchronized.
*
* @since Added in version 3.0.
*
* @ingroup native
*/
GLFWAPI HGLRC glfwGetWGLContext(GLFWwindow* window);
#endif
#if defined(GLFW_EXPOSE_NATIVE_COCOA)
/*! @brief Returns the `CGDirectDisplayID` of the specified monitor.
*
* @return The `CGDirectDisplayID` of the specified monitor, or
* `kCGNullDirectDisplay` if an [error](@ref error_handling) occurred.
*
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
*
* @thread_safety This function may be called from any thread. Access is not
* synchronized.
*
* @since Added in version 3.1.
*
* @ingroup native
*/
GLFWAPI CGDirectDisplayID glfwGetCocoaMonitor(GLFWmonitor* monitor);
/*! @brief Returns the `NSWindow` of the specified window.
*
* @return The `NSWindow` of the specified window, or `nil` if an
* [error](@ref error_handling) occurred.
*
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
*
* @thread_safety This function may be called from any thread. Access is not
* synchronized.
*
* @since Added in version 3.0.
*
* @ingroup native
*/
GLFWAPI id glfwGetCocoaWindow(GLFWwindow* window);
#endif
#if defined(GLFW_EXPOSE_NATIVE_NSGL)
/*! @brief Returns the `NSOpenGLContext` of the specified window.
*
* @return The `NSOpenGLContext` of the specified window, or `nil` if an
* [error](@ref error_handling) occurred.
*
* @errors Possible errors include @ref GLFW_NO_WINDOW_CONTEXT and @ref
* GLFW_NOT_INITIALIZED.
*
* @thread_safety This function may be called from any thread. Access is not
* synchronized.
*
* @since Added in version 3.0.
*
* @ingroup native
*/
GLFWAPI id glfwGetNSGLContext(GLFWwindow* window);
#endif
#if defined(GLFW_EXPOSE_NATIVE_X11)
/*! @brief Returns the `Display` used by GLFW.
*
* @return The `Display` used by GLFW, or `NULL` if an
* [error](@ref error_handling) occurred.
*
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
*
* @thread_safety This function may be called from any thread. Access is not
* synchronized.
*
* @since Added in version 3.0.
*
* @ingroup native
*/
GLFWAPI Display* glfwGetX11Display(void);
/*! @brief Returns the `RRCrtc` of the specified monitor.
*
* @return The `RRCrtc` of the specified monitor, or `None` if an
* [error](@ref error_handling) occurred.
*
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
*
* @thread_safety This function may be called from any thread. Access is not
* synchronized.
*
* @since Added in version 3.1.
*
* @ingroup native
*/
GLFWAPI RRCrtc glfwGetX11Adapter(GLFWmonitor* monitor);
/*! @brief Returns the `RROutput` of the specified monitor.
*
* @return The `RROutput` of the specified monitor, or `None` if an
* [error](@ref error_handling) occurred.
*
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
*
* @thread_safety This function may be called from any thread. Access is not
* synchronized.
*
* @since Added in version 3.1.
*
* @ingroup native
*/
GLFWAPI RROutput glfwGetX11Monitor(GLFWmonitor* monitor);
/*! @brief Returns the `Window` of the specified window.
*
* @return The `Window` of the specified window, or `None` if an
* [error](@ref error_handling) occurred.
*
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
*
* @thread_safety This function may be called from any thread. Access is not
* synchronized.
*
* @since Added in version 3.0.
*
* @ingroup native
*/
GLFWAPI Window glfwGetX11Window(GLFWwindow* window);
/*! @brief Sets the current primary selection to the specified string.
*
* @param[in] string A UTF-8 encoded string.
*
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
* GLFW_PLATFORM_ERROR.
*
* @pointer_lifetime The specified string is copied before this function
* returns.
*
* @thread_safety This function must only be called from the main thread.
*
* @sa @ref clipboard
* @sa glfwGetX11SelectionString
* @sa glfwSetClipboardString
*
* @since Added in version 3.3.
*
* @ingroup native
*/
GLFWAPI void glfwSetX11SelectionString(const char* string);
/*! @brief Returns the contents of the current primary selection as a string.
*
* If the selection is empty or if its contents cannot be converted, `NULL`
* is returned and a @ref GLFW_FORMAT_UNAVAILABLE error is generated.
*
* @return The contents of the selection as a UTF-8 encoded string, or `NULL`
* if an [error](@ref error_handling) occurred.
*
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
* GLFW_PLATFORM_ERROR.
*
* @pointer_lifetime The returned string is allocated and freed by GLFW. You
* should not free it yourself. It is valid until the next call to @ref
* glfwGetX11SelectionString or @ref glfwSetX11SelectionString, or until the
* library is terminated.
*
* @thread_safety This function must only be called from the main thread.
*
* @sa @ref clipboard
* @sa glfwSetX11SelectionString
* @sa glfwGetClipboardString
*
* @since Added in version 3.3.
*
* @ingroup native
*/
GLFWAPI const char* glfwGetX11SelectionString(void);
#endif
#if defined(GLFW_EXPOSE_NATIVE_GLX)
/*! @brief Returns the `GLXContext` of the specified window.
*
* @return The `GLXContext` of the specified window, or `NULL` if an
* [error](@ref error_handling) occurred.
*
* @errors Possible errors include @ref GLFW_NO_WINDOW_CONTEXT and @ref
* GLFW_NOT_INITIALIZED.
*
* @thread_safety This function may be called from any thread. Access is not
* synchronized.
*
* @since Added in version 3.0.
*
* @ingroup native
*/
GLFWAPI GLXContext glfwGetGLXContext(GLFWwindow* window);
/*! @brief Returns the `GLXWindow` of the specified window.
*
* @return The `GLXWindow` of the specified window, or `None` if an
* [error](@ref error_handling) occurred.
*
* @errors Possible errors include @ref GLFW_NO_WINDOW_CONTEXT and @ref
* GLFW_NOT_INITIALIZED.
*
* @thread_safety This function may be called from any thread. Access is not
* synchronized.
*
* @since Added in version 3.2.
*
* @ingroup native
*/
GLFWAPI GLXWindow glfwGetGLXWindow(GLFWwindow* window);
#endif
#if defined(GLFW_EXPOSE_NATIVE_WAYLAND)
/*! @brief Returns the `struct wl_display*` used by GLFW.
*
* @return The `struct wl_display*` used by GLFW, or `NULL` if an
* [error](@ref error_handling) occurred.
*
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
*
* @thread_safety This function may be called from any thread. Access is not
* synchronized.
*
* @since Added in version 3.2.
*
* @ingroup native
*/
GLFWAPI struct wl_display* glfwGetWaylandDisplay(void);
/*! @brief Returns the `struct wl_output*` of the specified monitor.
*
* @return The `struct wl_output*` of the specified monitor, or `NULL` if an
* [error](@ref error_handling) occurred.
*
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
*
* @thread_safety This function may be called from any thread. Access is not
* synchronized.
*
* @since Added in version 3.2.
*
* @ingroup native
*/
GLFWAPI struct wl_output* glfwGetWaylandMonitor(GLFWmonitor* monitor);
/*! @brief Returns the main `struct wl_surface*` of the specified window.
*
* @return The main `struct wl_surface*` of the specified window, or `NULL` if
* an [error](@ref error_handling) occurred.
*
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
*
* @thread_safety This function may be called from any thread. Access is not
* synchronized.
*
* @since Added in version 3.2.
*
* @ingroup native
*/
GLFWAPI struct wl_surface* glfwGetWaylandWindow(GLFWwindow* window);
#endif
#if defined(GLFW_EXPOSE_NATIVE_EGL)
/*! @brief Returns the `EGLDisplay` used by GLFW.
*
* @return The `EGLDisplay` used by GLFW, or `EGL_NO_DISPLAY` if an
* [error](@ref error_handling) occurred.
*
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
*
* @remark Because EGL is initialized on demand, this function will return
* `EGL_NO_DISPLAY` until the first context has been created via EGL.
*
* @thread_safety This function may be called from any thread. Access is not
* synchronized.
*
* @since Added in version 3.0.
*
* @ingroup native
*/
GLFWAPI EGLDisplay glfwGetEGLDisplay(void);
/*! @brief Returns the `EGLContext` of the specified window.
*
* @return The `EGLContext` of the specified window, or `EGL_NO_CONTEXT` if an
* [error](@ref error_handling) occurred.
*
* @errors Possible errors include @ref GLFW_NO_WINDOW_CONTEXT and @ref
* GLFW_NOT_INITIALIZED.
*
* @thread_safety This function may be called from any thread. Access is not
* synchronized.
*
* @since Added in version 3.0.
*
* @ingroup native
*/
GLFWAPI EGLContext glfwGetEGLContext(GLFWwindow* window);
/*! @brief Returns the `EGLSurface` of the specified window.
*
* @return The `EGLSurface` of the specified window, or `EGL_NO_SURFACE` if an
* [error](@ref error_handling) occurred.
*
* @errors Possible errors include @ref GLFW_NO_WINDOW_CONTEXT and @ref
* GLFW_NOT_INITIALIZED.
*
* @thread_safety This function may be called from any thread. Access is not
* synchronized.
*
* @since Added in version 3.0.
*
* @ingroup native
*/
GLFWAPI EGLSurface glfwGetEGLSurface(GLFWwindow* window);
#endif
#if defined(GLFW_EXPOSE_NATIVE_OSMESA)
/*! @brief Retrieves the color buffer associated with the specified window.
*
* @param[in] window The window whose color buffer to retrieve.
* @param[out] width Where to store the width of the color buffer, or `NULL`.
* @param[out] height Where to store the height of the color buffer, or `NULL`.
* @param[out] format Where to store the OSMesa pixel format of the color
* buffer, or `NULL`.
* @param[out] buffer Where to store the address of the color buffer, or
* `NULL`.
* @return `GLFW_TRUE` if successful, or `GLFW_FALSE` if an
* [error](@ref error_handling) occurred.
*
* @errors Possible errors include @ref GLFW_NO_WINDOW_CONTEXT and @ref
* GLFW_NOT_INITIALIZED.
*
* @thread_safety This function may be called from any thread. Access is not
* synchronized.
*
* @since Added in version 3.3.
*
* @ingroup native
*/
GLFWAPI int glfwGetOSMesaColorBuffer(GLFWwindow* window, int* width, int* height, int* format, void** buffer);
/*! @brief Retrieves the depth buffer associated with the specified window.
*
* @param[in] window The window whose depth buffer to retrieve.
* @param[out] width Where to store the width of the depth buffer, or `NULL`.
* @param[out] height Where to store the height of the depth buffer, or `NULL`.
* @param[out] bytesPerValue Where to store the number of bytes per depth
* buffer element, or `NULL`.
* @param[out] buffer Where to store the address of the depth buffer, or
* `NULL`.
* @return `GLFW_TRUE` if successful, or `GLFW_FALSE` if an
* [error](@ref error_handling) occurred.
*
* @errors Possible errors include @ref GLFW_NO_WINDOW_CONTEXT and @ref
* GLFW_NOT_INITIALIZED.
*
* @thread_safety This function may be called from any thread. Access is not
* synchronized.
*
* @since Added in version 3.3.
*
* @ingroup native
*/
GLFWAPI int glfwGetOSMesaDepthBuffer(GLFWwindow* window, int* width, int* height, int* bytesPerValue, void** buffer);
/*! @brief Returns the `OSMesaContext` of the specified window.
*
* @return The `OSMesaContext` of the specified window, or `NULL` if an
* [error](@ref error_handling) occurred.
*
* @errors Possible errors include @ref GLFW_NO_WINDOW_CONTEXT and @ref
* GLFW_NOT_INITIALIZED.
*
* @thread_safety This function may be called from any thread. Access is not
* synchronized.
*
* @since Added in version 3.3.
*
* @ingroup native
*/
GLFWAPI OSMesaContext glfwGetOSMesaContext(GLFWwindow* window);
#endif
#ifdef __cplusplus
}
#endif
#endif /* _glfw3_native_h_ */

View File

@@ -0,0 +1,400 @@
add_library(glfw ${GLFW_LIBRARY_TYPE}
"${GLFW_SOURCE_DIR}/include/GLFW/glfw3.h"
"${GLFW_SOURCE_DIR}/include/GLFW/glfw3native.h"
internal.h platform.h mappings.h
context.c init.c input.c monitor.c platform.c vulkan.c window.c
egl_context.c osmesa_context.c null_platform.h null_joystick.h
null_init.c null_monitor.c null_window.c null_joystick.c)
# The time, thread and module code is shared between all backends on a given OS,
# including the null backend, which still needs those bits to be functional
if (APPLE)
target_sources(glfw PRIVATE cocoa_time.h cocoa_time.c posix_thread.h
posix_module.c posix_thread.c)
elseif (WIN32)
target_sources(glfw PRIVATE win32_time.h win32_thread.h win32_module.c
win32_time.c win32_thread.c)
else()
target_sources(glfw PRIVATE posix_time.h posix_thread.h posix_module.c
posix_time.c posix_thread.c)
endif()
add_custom_target(update_mappings
COMMAND "${CMAKE_COMMAND}" -P "${GLFW_SOURCE_DIR}/CMake/GenerateMappings.cmake" mappings.h.in mappings.h
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
COMMENT "Updating gamepad mappings from upstream repository"
SOURCES mappings.h.in "${GLFW_SOURCE_DIR}/CMake/GenerateMappings.cmake"
VERBATIM)
set_target_properties(update_mappings PROPERTIES FOLDER "GLFW3")
if (GLFW_BUILD_COCOA)
target_compile_definitions(glfw PRIVATE _GLFW_COCOA)
target_sources(glfw PRIVATE cocoa_platform.h cocoa_joystick.h cocoa_init.m
cocoa_joystick.m cocoa_monitor.m cocoa_window.m
nsgl_context.m)
endif()
if (GLFW_BUILD_WIN32)
target_compile_definitions(glfw PRIVATE _GLFW_WIN32)
target_sources(glfw PRIVATE win32_platform.h win32_joystick.h win32_init.c
win32_joystick.c win32_monitor.c win32_window.c
wgl_context.c)
endif()
if (GLFW_BUILD_X11)
target_compile_definitions(glfw PRIVATE _GLFW_X11)
target_sources(glfw PRIVATE x11_platform.h xkb_unicode.h x11_init.c
x11_monitor.c x11_window.c xkb_unicode.c
glx_context.c)
endif()
if (GLFW_BUILD_WAYLAND)
target_compile_definitions(glfw PRIVATE _GLFW_WAYLAND)
target_sources(glfw PRIVATE wl_platform.h xkb_unicode.h wl_init.c
wl_monitor.c wl_window.c xkb_unicode.c)
endif()
if (GLFW_BUILD_X11 OR GLFW_BUILD_WAYLAND)
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
target_sources(glfw PRIVATE linux_joystick.h linux_joystick.c)
endif()
target_sources(glfw PRIVATE posix_poll.h posix_poll.c)
endif()
if (GLFW_BUILD_WAYLAND)
include(CheckIncludeFiles)
include(CheckFunctionExists)
check_function_exists(memfd_create HAVE_MEMFD_CREATE)
if (HAVE_MEMFD_CREATE)
target_compile_definitions(glfw PRIVATE HAVE_MEMFD_CREATE)
endif()
find_program(WAYLAND_SCANNER_EXECUTABLE NAMES wayland-scanner)
include(FindPkgConfig)
pkg_check_modules(WAYLAND_PROTOCOLS REQUIRED wayland-protocols>=1.15)
pkg_get_variable(WAYLAND_PROTOCOLS_BASE wayland-protocols pkgdatadir)
pkg_get_variable(WAYLAND_CLIENT_PKGDATADIR wayland-client pkgdatadir)
macro(wayland_generate protocol_file output_file)
add_custom_command(OUTPUT "${output_file}.h"
COMMAND "${WAYLAND_SCANNER_EXECUTABLE}" client-header "${protocol_file}" "${output_file}.h"
DEPENDS "${protocol_file}"
VERBATIM)
add_custom_command(OUTPUT "${output_file}-code.h"
COMMAND "${WAYLAND_SCANNER_EXECUTABLE}" private-code "${protocol_file}" "${output_file}-code.h"
DEPENDS "${protocol_file}"
VERBATIM)
target_sources(glfw PRIVATE "${output_file}.h" "${output_file}-code.h")
endmacro()
wayland_generate(
"${WAYLAND_CLIENT_PKGDATADIR}/wayland.xml"
"${GLFW_BINARY_DIR}/src/wayland-client-protocol")
wayland_generate(
"${WAYLAND_PROTOCOLS_BASE}/stable/xdg-shell/xdg-shell.xml"
"${GLFW_BINARY_DIR}/src/wayland-xdg-shell-client-protocol")
wayland_generate(
"${WAYLAND_PROTOCOLS_BASE}/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml"
"${GLFW_BINARY_DIR}/src/wayland-xdg-decoration-client-protocol")
wayland_generate(
"${WAYLAND_PROTOCOLS_BASE}/stable/viewporter/viewporter.xml"
"${GLFW_BINARY_DIR}/src/wayland-viewporter-client-protocol")
wayland_generate(
"${WAYLAND_PROTOCOLS_BASE}/unstable/relative-pointer/relative-pointer-unstable-v1.xml"
"${GLFW_BINARY_DIR}/src/wayland-relative-pointer-unstable-v1-client-protocol")
wayland_generate(
"${WAYLAND_PROTOCOLS_BASE}/unstable/pointer-constraints/pointer-constraints-unstable-v1.xml"
"${GLFW_BINARY_DIR}/src/wayland-pointer-constraints-unstable-v1-client-protocol")
wayland_generate(
"${WAYLAND_PROTOCOLS_BASE}/unstable/idle-inhibit/idle-inhibit-unstable-v1.xml"
"${GLFW_BINARY_DIR}/src/wayland-idle-inhibit-unstable-v1-client-protocol")
endif()
if (WIN32 AND GLFW_BUILD_SHARED_LIBRARY)
configure_file(glfw.rc.in glfw.rc @ONLY)
target_sources(glfw PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/glfw.rc")
endif()
if (UNIX AND GLFW_BUILD_SHARED_LIBRARY)
# On Unix-like systems, shared libraries can use the soname system.
set(GLFW_LIB_NAME glfw)
else()
set(GLFW_LIB_NAME glfw3)
endif()
set_target_properties(glfw PROPERTIES
OUTPUT_NAME ${GLFW_LIB_NAME}
VERSION ${GLFW_VERSION_MAJOR}.${GLFW_VERSION_MINOR}
SOVERSION ${GLFW_VERSION_MAJOR}
POSITION_INDEPENDENT_CODE ON
C_STANDARD 99
C_EXTENSIONS OFF
DEFINE_SYMBOL _GLFW_BUILD_DLL
FOLDER "GLFW3")
target_include_directories(glfw PUBLIC
"$<BUILD_INTERFACE:${GLFW_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>")
target_include_directories(glfw PRIVATE
"${GLFW_SOURCE_DIR}/src"
"${GLFW_BINARY_DIR}/src")
target_link_libraries(glfw PRIVATE Threads::Threads)
# Workaround for CMake not knowing about .m files before version 3.16
if (CMAKE_VERSION VERSION_LESS "3.16" AND APPLE)
set_source_files_properties(cocoa_init.m cocoa_joystick.m cocoa_monitor.m
cocoa_window.m nsgl_context.m PROPERTIES
LANGUAGE C)
endif()
if (GLFW_BUILD_WIN32)
list(APPEND glfw_PKG_LIBS "-lgdi32")
endif()
if (GLFW_BUILD_COCOA)
target_link_libraries(glfw PRIVATE "-framework Cocoa"
"-framework IOKit"
"-framework CoreFoundation")
set(glfw_PKG_DEPS "")
set(glfw_PKG_LIBS "-framework Cocoa -framework IOKit -framework CoreFoundation")
endif()
if (GLFW_BUILD_WAYLAND)
pkg_check_modules(Wayland REQUIRED
wayland-client>=0.2.7
wayland-cursor>=0.2.7
wayland-egl>=0.2.7
xkbcommon>=0.5.0)
target_include_directories(glfw PRIVATE ${Wayland_INCLUDE_DIRS})
if (NOT CMAKE_SYSTEM_NAME STREQUAL "Linux")
find_package(EpollShim)
if (EPOLLSHIM_FOUND)
target_include_directories(glfw PRIVATE ${EPOLLSHIM_INCLUDE_DIRS})
target_link_libraries(glfw PRIVATE ${EPOLLSHIM_LIBRARIES})
endif()
endif()
endif()
if (GLFW_BUILD_X11)
find_package(X11 REQUIRED)
target_include_directories(glfw PRIVATE "${X11_X11_INCLUDE_PATH}")
# Check for XRandR (modern resolution switching and gamma control)
if (NOT X11_Xrandr_INCLUDE_PATH)
message(FATAL_ERROR "RandR headers not found; install libxrandr development package")
endif()
target_include_directories(glfw PRIVATE "${X11_Xrandr_INCLUDE_PATH}")
# Check for Xinerama (legacy multi-monitor support)
if (NOT X11_Xinerama_INCLUDE_PATH)
message(FATAL_ERROR "Xinerama headers not found; install libxinerama development package")
endif()
target_include_directories(glfw PRIVATE "${X11_Xinerama_INCLUDE_PATH}")
# Check for Xkb (X keyboard extension)
if (NOT X11_Xkb_INCLUDE_PATH)
message(FATAL_ERROR "XKB headers not found; install X11 development package")
endif()
target_include_directories(glfw PRIVATE "${X11_Xkb_INCLUDE_PATH}")
# Check for Xcursor (cursor creation from RGBA images)
if (NOT X11_Xcursor_INCLUDE_PATH)
message(FATAL_ERROR "Xcursor headers not found; install libxcursor development package")
endif()
target_include_directories(glfw PRIVATE "${X11_Xcursor_INCLUDE_PATH}")
# Check for XInput (modern HID input)
if (NOT X11_Xi_INCLUDE_PATH)
message(FATAL_ERROR "XInput headers not found; install libxi development package")
endif()
target_include_directories(glfw PRIVATE "${X11_Xi_INCLUDE_PATH}")
# Check for X Shape (custom window input shape)
if (NOT X11_Xshape_INCLUDE_PATH)
message(FATAL_ERROR "X Shape headers not found; install libxext development package")
endif()
target_include_directories(glfw PRIVATE "${X11_Xshape_INCLUDE_PATH}")
endif()
if (UNIX AND NOT APPLE)
find_library(RT_LIBRARY rt)
mark_as_advanced(RT_LIBRARY)
if (RT_LIBRARY)
target_link_libraries(glfw PRIVATE "${RT_LIBRARY}")
list(APPEND glfw_PKG_LIBS "-lrt")
endif()
find_library(MATH_LIBRARY m)
mark_as_advanced(MATH_LIBRARY)
if (MATH_LIBRARY)
target_link_libraries(glfw PRIVATE "${MATH_LIBRARY}")
list(APPEND glfw_PKG_LIBS "-lm")
endif()
if (CMAKE_DL_LIBS)
target_link_libraries(glfw PRIVATE "${CMAKE_DL_LIBS}")
list(APPEND glfw_PKG_LIBS "-l${CMAKE_DL_LIBS}")
endif()
endif()
# Make GCC warn about declarations that VS 2010 and 2012 won't accept for all
# source files that VS will build (Clang ignores this because we set -std=c99)
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
set_source_files_properties(context.c init.c input.c monitor.c platform.c vulkan.c
window.c null_init.c null_joystick.c null_monitor.c
null_window.c win32_init.c win32_joystick.c win32_module.c
win32_monitor.c win32_time.c win32_thread.c win32_window.c
wgl_context.c egl_context.c osmesa_context.c PROPERTIES
COMPILE_FLAGS -Wdeclaration-after-statement)
endif()
if (WIN32)
if (GLFW_USE_HYBRID_HPG)
target_compile_definitions(glfw PRIVATE _GLFW_USE_HYBRID_HPG)
endif()
endif()
# Enable a reasonable set of warnings
# NOTE: The order matters here, Clang-CL matches both MSVC and Clang
if (MSVC)
target_compile_options(glfw PRIVATE "/W3")
elseif (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR
CMAKE_C_COMPILER_ID STREQUAL "Clang" OR
CMAKE_C_COMPILER_ID STREQUAL "AppleClang")
target_compile_options(glfw PRIVATE "-Wall")
endif()
if (GLFW_BUILD_WIN32)
target_compile_definitions(glfw PRIVATE UNICODE _UNICODE)
endif()
# HACK: When building on MinGW, WINVER and UNICODE need to be defined before
# the inclusion of stddef.h (by glfw3.h), which is itself included before
# 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.
if (MINGW)
target_compile_definitions(glfw PRIVATE WINVER=0x0501)
endif()
# Workaround for legacy MinGW not providing XInput and DirectInput
if (MINGW)
include(CheckIncludeFile)
check_include_file(dinput.h DINPUT_H_FOUND)
check_include_file(xinput.h XINPUT_H_FOUND)
if (NOT DINPUT_H_FOUND OR NOT XINPUT_H_FOUND)
target_include_directories(glfw PRIVATE "${GLFW_SOURCE_DIR}/deps/mingw")
endif()
endif()
# Workaround for the MS CRT deprecating parts of the standard library
if (MSVC OR CMAKE_C_SIMULATE_ID STREQUAL "MSVC")
target_compile_definitions(glfw PRIVATE _CRT_SECURE_NO_WARNINGS)
endif()
# Workaround for VS 2008 not shipping with stdint.h
if (MSVC90)
target_include_directories(glfw PUBLIC "${GLFW_SOURCE_DIR}/deps/vs2008")
endif()
# Check for the DirectX 9 SDK as it is not included with VS 2008
if (MSVC90)
include(CheckIncludeFile)
check_include_file(dinput.h DINPUT_H_FOUND)
if (NOT DINPUT_H_FOUND)
message(FATAL_ERROR "DirectX 9 headers not found; install DirectX 9 SDK")
endif()
endif()
# Workaround for -std=c99 on Linux disabling _DEFAULT_SOURCE (POSIX 2008 and more)
if (GLFW_BUILD_X11 OR GLFW_BUILD_WAYLAND)
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
target_compile_definitions(glfw PRIVATE _DEFAULT_SOURCE)
endif()
endif()
if (GLFW_BUILD_SHARED_LIBRARY)
if (WIN32)
if (MINGW)
# Remove the dependency on the shared version of libgcc
# NOTE: MinGW-w64 has the correct default but MinGW needs this
target_link_libraries(glfw PRIVATE "-static-libgcc")
# Remove the lib prefix on the DLL (but not the import library)
set_target_properties(glfw PROPERTIES PREFIX "")
# Add a suffix to the import library to avoid naming conflicts
set_target_properties(glfw PROPERTIES IMPORT_SUFFIX "dll.a")
else()
# Add a suffix to the import library to avoid naming conflicts
set_target_properties(glfw PROPERTIES IMPORT_SUFFIX "dll.lib")
endif()
target_compile_definitions(glfw INTERFACE GLFW_DLL)
endif()
if (MINGW)
# Enable link-time exploit mitigation features enabled by default on MSVC
include(CheckCCompilerFlag)
# Compatibility with data execution prevention (DEP)
set(CMAKE_REQUIRED_FLAGS "-Wl,--nxcompat")
check_c_compiler_flag("" _GLFW_HAS_DEP)
if (_GLFW_HAS_DEP)
target_link_libraries(glfw PRIVATE "-Wl,--nxcompat")
endif()
# Compatibility with address space layout randomization (ASLR)
set(CMAKE_REQUIRED_FLAGS "-Wl,--dynamicbase")
check_c_compiler_flag("" _GLFW_HAS_ASLR)
if (_GLFW_HAS_ASLR)
target_link_libraries(glfw PRIVATE "-Wl,--dynamicbase")
endif()
# Compatibility with 64-bit address space layout randomization (ASLR)
set(CMAKE_REQUIRED_FLAGS "-Wl,--high-entropy-va")
check_c_compiler_flag("" _GLFW_HAS_64ASLR)
if (_GLFW_HAS_64ASLR)
target_link_libraries(glfw PRIVATE "-Wl,--high-entropy-va")
endif()
# Clear flags again to avoid breaking later tests
set(CMAKE_REQUIRED_FLAGS)
endif()
if (UNIX)
# Hide symbols not explicitly tagged for export from the shared library
target_compile_options(glfw PRIVATE "-fvisibility=hidden")
endif()
endif()
foreach(arg ${glfw_PKG_DEPS})
string(APPEND deps " ${arg}")
endforeach()
foreach(arg ${glfw_PKG_LIBS})
string(APPEND libs " ${arg}")
endforeach()
set(GLFW_PKG_CONFIG_REQUIRES_PRIVATE "${deps}" CACHE INTERNAL
"GLFW pkg-config Requires.private")
set(GLFW_PKG_CONFIG_LIBS_PRIVATE "${libs}" CACHE INTERNAL
"GLFW pkg-config Libs.private")
configure_file("${GLFW_SOURCE_DIR}/CMake/glfw3.pc.in" glfw3.pc @ONLY)
if (GLFW_INSTALL)
install(TARGETS glfw
EXPORT glfwTargets
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")
endif()

View File

@@ -0,0 +1,692 @@
//========================================================================
// GLFW 3.4 macOS - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2009-2019 Camilla Löwy <elmindreda@glfw.org>
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would
// be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such, and must not
// be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source
// distribution.
//
//========================================================================
// It is fine to use C99 in this file because it will not be built with VS
//========================================================================
#include "internal.h"
#include <sys/param.h> // For MAXPATHLEN
// Needed for _NSGetProgname
#include <crt_externs.h>
// Change to our application bundle's resources directory, if present
//
static void changeToResourcesDirectory(void)
{
char resourcesPath[MAXPATHLEN];
CFBundleRef bundle = CFBundleGetMainBundle();
if (!bundle)
return;
CFURLRef resourcesURL = CFBundleCopyResourcesDirectoryURL(bundle);
CFStringRef last = CFURLCopyLastPathComponent(resourcesURL);
if (CFStringCompare(CFSTR("Resources"), last, 0) != kCFCompareEqualTo)
{
CFRelease(last);
CFRelease(resourcesURL);
return;
}
CFRelease(last);
if (!CFURLGetFileSystemRepresentation(resourcesURL,
true,
(UInt8*) resourcesPath,
MAXPATHLEN))
{
CFRelease(resourcesURL);
return;
}
CFRelease(resourcesURL);
chdir(resourcesPath);
}
// Set up the menu bar (manually)
// This is nasty, nasty stuff -- calls to undocumented semi-private APIs that
// could go away at any moment, lots of stuff that really should be
// localize(d|able), etc. Add a nib to save us this horror.
//
static void createMenuBar(void)
{
NSString* appName = nil;
NSDictionary* bundleInfo = [[NSBundle mainBundle] infoDictionary];
NSString* nameKeys[] =
{
@"CFBundleDisplayName",
@"CFBundleName",
@"CFBundleExecutable",
};
// Try to figure out what the calling application is called
for (size_t i = 0; i < sizeof(nameKeys) / sizeof(nameKeys[0]); i++)
{
id name = bundleInfo[nameKeys[i]];
if (name &&
[name isKindOfClass:[NSString class]] &&
![name isEqualToString:@""])
{
appName = name;
break;
}
}
if (!appName)
{
char** progname = _NSGetProgname();
if (progname && *progname)
appName = @(*progname);
else
appName = @"GLFW Application";
}
NSMenu* bar = [[NSMenu alloc] init];
[NSApp setMainMenu:bar];
NSMenuItem* appMenuItem =
[bar addItemWithTitle:@"" action:NULL keyEquivalent:@""];
NSMenu* appMenu = [[NSMenu alloc] init];
[appMenuItem setSubmenu:appMenu];
[appMenu addItemWithTitle:[NSString stringWithFormat:@"About %@", appName]
action:@selector(orderFrontStandardAboutPanel:)
keyEquivalent:@""];
[appMenu addItem:[NSMenuItem separatorItem]];
NSMenu* servicesMenu = [[NSMenu alloc] init];
[NSApp setServicesMenu:servicesMenu];
[[appMenu addItemWithTitle:@"Services"
action:NULL
keyEquivalent:@""] setSubmenu:servicesMenu];
[servicesMenu release];
[appMenu addItem:[NSMenuItem separatorItem]];
[appMenu addItemWithTitle:[NSString stringWithFormat:@"Hide %@", appName]
action:@selector(hide:)
keyEquivalent:@"h"];
[[appMenu addItemWithTitle:@"Hide Others"
action:@selector(hideOtherApplications:)
keyEquivalent:@"h"]
setKeyEquivalentModifierMask:NSEventModifierFlagOption | NSEventModifierFlagCommand];
[appMenu addItemWithTitle:@"Show All"
action:@selector(unhideAllApplications:)
keyEquivalent:@""];
[appMenu addItem:[NSMenuItem separatorItem]];
[appMenu addItemWithTitle:[NSString stringWithFormat:@"Quit %@", appName]
action:@selector(terminate:)
keyEquivalent:@"q"];
NSMenuItem* windowMenuItem =
[bar addItemWithTitle:@"" action:NULL keyEquivalent:@""];
[bar release];
NSMenu* windowMenu = [[NSMenu alloc] initWithTitle:@"Window"];
[NSApp setWindowsMenu:windowMenu];
[windowMenuItem setSubmenu:windowMenu];
[windowMenu addItemWithTitle:@"Minimize"
action:@selector(performMiniaturize:)
keyEquivalent:@"m"];
[windowMenu addItemWithTitle:@"Zoom"
action:@selector(performZoom:)
keyEquivalent:@""];
[windowMenu addItem:[NSMenuItem separatorItem]];
[windowMenu addItemWithTitle:@"Bring All to Front"
action:@selector(arrangeInFront:)
keyEquivalent:@""];
// TODO: Make this appear at the bottom of the menu (for consistency)
[windowMenu addItem:[NSMenuItem separatorItem]];
[[windowMenu addItemWithTitle:@"Enter Full Screen"
action:@selector(toggleFullScreen:)
keyEquivalent:@"f"]
setKeyEquivalentModifierMask:NSEventModifierFlagControl | NSEventModifierFlagCommand];
// Prior to Snow Leopard, we need to use this oddly-named semi-private API
// to get the application menu working properly.
SEL setAppleMenuSelector = NSSelectorFromString(@"setAppleMenu:");
[NSApp performSelector:setAppleMenuSelector withObject:appMenu];
}
// Create key code translation tables
//
static void createKeyTables(void)
{
memset(_glfw.ns.keycodes, -1, sizeof(_glfw.ns.keycodes));
memset(_glfw.ns.scancodes, -1, sizeof(_glfw.ns.scancodes));
_glfw.ns.keycodes[0x1D] = GLFW_KEY_0;
_glfw.ns.keycodes[0x12] = GLFW_KEY_1;
_glfw.ns.keycodes[0x13] = GLFW_KEY_2;
_glfw.ns.keycodes[0x14] = GLFW_KEY_3;
_glfw.ns.keycodes[0x15] = GLFW_KEY_4;
_glfw.ns.keycodes[0x17] = GLFW_KEY_5;
_glfw.ns.keycodes[0x16] = GLFW_KEY_6;
_glfw.ns.keycodes[0x1A] = GLFW_KEY_7;
_glfw.ns.keycodes[0x1C] = GLFW_KEY_8;
_glfw.ns.keycodes[0x19] = GLFW_KEY_9;
_glfw.ns.keycodes[0x00] = GLFW_KEY_A;
_glfw.ns.keycodes[0x0B] = GLFW_KEY_B;
_glfw.ns.keycodes[0x08] = GLFW_KEY_C;
_glfw.ns.keycodes[0x02] = GLFW_KEY_D;
_glfw.ns.keycodes[0x0E] = GLFW_KEY_E;
_glfw.ns.keycodes[0x03] = GLFW_KEY_F;
_glfw.ns.keycodes[0x05] = GLFW_KEY_G;
_glfw.ns.keycodes[0x04] = GLFW_KEY_H;
_glfw.ns.keycodes[0x22] = GLFW_KEY_I;
_glfw.ns.keycodes[0x26] = GLFW_KEY_J;
_glfw.ns.keycodes[0x28] = GLFW_KEY_K;
_glfw.ns.keycodes[0x25] = GLFW_KEY_L;
_glfw.ns.keycodes[0x2E] = GLFW_KEY_M;
_glfw.ns.keycodes[0x2D] = GLFW_KEY_N;
_glfw.ns.keycodes[0x1F] = GLFW_KEY_O;
_glfw.ns.keycodes[0x23] = GLFW_KEY_P;
_glfw.ns.keycodes[0x0C] = GLFW_KEY_Q;
_glfw.ns.keycodes[0x0F] = GLFW_KEY_R;
_glfw.ns.keycodes[0x01] = GLFW_KEY_S;
_glfw.ns.keycodes[0x11] = GLFW_KEY_T;
_glfw.ns.keycodes[0x20] = GLFW_KEY_U;
_glfw.ns.keycodes[0x09] = GLFW_KEY_V;
_glfw.ns.keycodes[0x0D] = GLFW_KEY_W;
_glfw.ns.keycodes[0x07] = GLFW_KEY_X;
_glfw.ns.keycodes[0x10] = GLFW_KEY_Y;
_glfw.ns.keycodes[0x06] = GLFW_KEY_Z;
_glfw.ns.keycodes[0x27] = GLFW_KEY_APOSTROPHE;
_glfw.ns.keycodes[0x2A] = GLFW_KEY_BACKSLASH;
_glfw.ns.keycodes[0x2B] = GLFW_KEY_COMMA;
_glfw.ns.keycodes[0x18] = GLFW_KEY_EQUAL;
_glfw.ns.keycodes[0x32] = GLFW_KEY_GRAVE_ACCENT;
_glfw.ns.keycodes[0x21] = GLFW_KEY_LEFT_BRACKET;
_glfw.ns.keycodes[0x1B] = GLFW_KEY_MINUS;
_glfw.ns.keycodes[0x2F] = GLFW_KEY_PERIOD;
_glfw.ns.keycodes[0x1E] = GLFW_KEY_RIGHT_BRACKET;
_glfw.ns.keycodes[0x29] = GLFW_KEY_SEMICOLON;
_glfw.ns.keycodes[0x2C] = GLFW_KEY_SLASH;
_glfw.ns.keycodes[0x0A] = GLFW_KEY_WORLD_1;
_glfw.ns.keycodes[0x33] = GLFW_KEY_BACKSPACE;
_glfw.ns.keycodes[0x39] = GLFW_KEY_CAPS_LOCK;
_glfw.ns.keycodes[0x75] = GLFW_KEY_DELETE;
_glfw.ns.keycodes[0x7D] = GLFW_KEY_DOWN;
_glfw.ns.keycodes[0x77] = GLFW_KEY_END;
_glfw.ns.keycodes[0x24] = GLFW_KEY_ENTER;
_glfw.ns.keycodes[0x35] = GLFW_KEY_ESCAPE;
_glfw.ns.keycodes[0x7A] = GLFW_KEY_F1;
_glfw.ns.keycodes[0x78] = GLFW_KEY_F2;
_glfw.ns.keycodes[0x63] = GLFW_KEY_F3;
_glfw.ns.keycodes[0x76] = GLFW_KEY_F4;
_glfw.ns.keycodes[0x60] = GLFW_KEY_F5;
_glfw.ns.keycodes[0x61] = GLFW_KEY_F6;
_glfw.ns.keycodes[0x62] = GLFW_KEY_F7;
_glfw.ns.keycodes[0x64] = GLFW_KEY_F8;
_glfw.ns.keycodes[0x65] = GLFW_KEY_F9;
_glfw.ns.keycodes[0x6D] = GLFW_KEY_F10;
_glfw.ns.keycodes[0x67] = GLFW_KEY_F11;
_glfw.ns.keycodes[0x6F] = GLFW_KEY_F12;
_glfw.ns.keycodes[0x69] = GLFW_KEY_PRINT_SCREEN;
_glfw.ns.keycodes[0x6B] = GLFW_KEY_F14;
_glfw.ns.keycodes[0x71] = GLFW_KEY_F15;
_glfw.ns.keycodes[0x6A] = GLFW_KEY_F16;
_glfw.ns.keycodes[0x40] = GLFW_KEY_F17;
_glfw.ns.keycodes[0x4F] = GLFW_KEY_F18;
_glfw.ns.keycodes[0x50] = GLFW_KEY_F19;
_glfw.ns.keycodes[0x5A] = GLFW_KEY_F20;
_glfw.ns.keycodes[0x73] = GLFW_KEY_HOME;
_glfw.ns.keycodes[0x72] = GLFW_KEY_INSERT;
_glfw.ns.keycodes[0x7B] = GLFW_KEY_LEFT;
_glfw.ns.keycodes[0x3A] = GLFW_KEY_LEFT_ALT;
_glfw.ns.keycodes[0x3B] = GLFW_KEY_LEFT_CONTROL;
_glfw.ns.keycodes[0x38] = GLFW_KEY_LEFT_SHIFT;
_glfw.ns.keycodes[0x37] = GLFW_KEY_LEFT_SUPER;
_glfw.ns.keycodes[0x6E] = GLFW_KEY_MENU;
_glfw.ns.keycodes[0x47] = GLFW_KEY_NUM_LOCK;
_glfw.ns.keycodes[0x79] = GLFW_KEY_PAGE_DOWN;
_glfw.ns.keycodes[0x74] = GLFW_KEY_PAGE_UP;
_glfw.ns.keycodes[0x7C] = GLFW_KEY_RIGHT;
_glfw.ns.keycodes[0x3D] = GLFW_KEY_RIGHT_ALT;
_glfw.ns.keycodes[0x3E] = GLFW_KEY_RIGHT_CONTROL;
_glfw.ns.keycodes[0x3C] = GLFW_KEY_RIGHT_SHIFT;
_glfw.ns.keycodes[0x36] = GLFW_KEY_RIGHT_SUPER;
_glfw.ns.keycodes[0x31] = GLFW_KEY_SPACE;
_glfw.ns.keycodes[0x30] = GLFW_KEY_TAB;
_glfw.ns.keycodes[0x7E] = GLFW_KEY_UP;
_glfw.ns.keycodes[0x52] = GLFW_KEY_KP_0;
_glfw.ns.keycodes[0x53] = GLFW_KEY_KP_1;
_glfw.ns.keycodes[0x54] = GLFW_KEY_KP_2;
_glfw.ns.keycodes[0x55] = GLFW_KEY_KP_3;
_glfw.ns.keycodes[0x56] = GLFW_KEY_KP_4;
_glfw.ns.keycodes[0x57] = GLFW_KEY_KP_5;
_glfw.ns.keycodes[0x58] = GLFW_KEY_KP_6;
_glfw.ns.keycodes[0x59] = GLFW_KEY_KP_7;
_glfw.ns.keycodes[0x5B] = GLFW_KEY_KP_8;
_glfw.ns.keycodes[0x5C] = GLFW_KEY_KP_9;
_glfw.ns.keycodes[0x45] = GLFW_KEY_KP_ADD;
_glfw.ns.keycodes[0x41] = GLFW_KEY_KP_DECIMAL;
_glfw.ns.keycodes[0x4B] = GLFW_KEY_KP_DIVIDE;
_glfw.ns.keycodes[0x4C] = GLFW_KEY_KP_ENTER;
_glfw.ns.keycodes[0x51] = GLFW_KEY_KP_EQUAL;
_glfw.ns.keycodes[0x43] = GLFW_KEY_KP_MULTIPLY;
_glfw.ns.keycodes[0x4E] = GLFW_KEY_KP_SUBTRACT;
for (int scancode = 0; scancode < 256; scancode++)
{
// Store the reverse translation for faster key name lookup
if (_glfw.ns.keycodes[scancode] >= 0)
_glfw.ns.scancodes[_glfw.ns.keycodes[scancode]] = scancode;
}
}
// Retrieve Unicode data for the current keyboard layout
//
static GLFWbool updateUnicodeData(void)
{
if (_glfw.ns.inputSource)
{
CFRelease(_glfw.ns.inputSource);
_glfw.ns.inputSource = NULL;
_glfw.ns.unicodeData = nil;
}
_glfw.ns.inputSource = TISCopyCurrentKeyboardLayoutInputSource();
if (!_glfw.ns.inputSource)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"Cocoa: Failed to retrieve keyboard layout input source");
return GLFW_FALSE;
}
_glfw.ns.unicodeData =
TISGetInputSourceProperty(_glfw.ns.inputSource,
kTISPropertyUnicodeKeyLayoutData);
if (!_glfw.ns.unicodeData)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"Cocoa: Failed to retrieve keyboard layout Unicode data");
return GLFW_FALSE;
}
return GLFW_TRUE;
}
// Load HIToolbox.framework and the TIS symbols we need from it
//
static GLFWbool initializeTIS(void)
{
// This works only because Cocoa has already loaded it properly
_glfw.ns.tis.bundle =
CFBundleGetBundleWithIdentifier(CFSTR("com.apple.HIToolbox"));
if (!_glfw.ns.tis.bundle)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"Cocoa: Failed to load HIToolbox.framework");
return GLFW_FALSE;
}
CFStringRef* kPropertyUnicodeKeyLayoutData =
CFBundleGetDataPointerForName(_glfw.ns.tis.bundle,
CFSTR("kTISPropertyUnicodeKeyLayoutData"));
_glfw.ns.tis.CopyCurrentKeyboardLayoutInputSource =
CFBundleGetFunctionPointerForName(_glfw.ns.tis.bundle,
CFSTR("TISCopyCurrentKeyboardLayoutInputSource"));
_glfw.ns.tis.GetInputSourceProperty =
CFBundleGetFunctionPointerForName(_glfw.ns.tis.bundle,
CFSTR("TISGetInputSourceProperty"));
_glfw.ns.tis.GetKbdType =
CFBundleGetFunctionPointerForName(_glfw.ns.tis.bundle,
CFSTR("LMGetKbdType"));
if (!kPropertyUnicodeKeyLayoutData ||
!TISCopyCurrentKeyboardLayoutInputSource ||
!TISGetInputSourceProperty ||
!LMGetKbdType)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"Cocoa: Failed to load TIS API symbols");
return GLFW_FALSE;
}
_glfw.ns.tis.kPropertyUnicodeKeyLayoutData =
*kPropertyUnicodeKeyLayoutData;
return updateUnicodeData();
}
@interface GLFWHelper : NSObject
@end
@implementation GLFWHelper
- (void)selectedKeyboardInputSourceChanged:(NSObject* )object
{
updateUnicodeData();
}
- (void)doNothing:(id)object
{
}
@end // GLFWHelper
@interface GLFWApplicationDelegate : NSObject <NSApplicationDelegate>
@end
@implementation GLFWApplicationDelegate
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender
{
for (_GLFWwindow* window = _glfw.windowListHead; window; window = window->next)
_glfwInputWindowCloseRequest(window);
return NSTerminateCancel;
}
- (void)applicationDidChangeScreenParameters:(NSNotification *) notification
{
for (_GLFWwindow* window = _glfw.windowListHead; window; window = window->next)
{
if (window->context.client != GLFW_NO_API)
[window->context.nsgl.object update];
}
_glfwPollMonitorsCocoa();
}
- (void)applicationWillFinishLaunching:(NSNotification *)notification
{
if (_glfw.hints.init.ns.menubar)
{
// Menu bar setup must go between sharedApplication and finishLaunching
// in order to properly emulate the behavior of NSApplicationMain
if ([[NSBundle mainBundle] pathForResource:@"MainMenu" ofType:@"nib"])
{
[[NSBundle mainBundle] loadNibNamed:@"MainMenu"
owner:NSApp
topLevelObjects:&_glfw.ns.nibObjects];
}
else
createMenuBar();
}
}
- (void)applicationDidFinishLaunching:(NSNotification *)notification
{
_glfwPostEmptyEventCocoa();
[NSApp stop:nil];
}
- (void)applicationDidHide:(NSNotification *)notification
{
for (int i = 0; i < _glfw.monitorCount; i++)
_glfwRestoreVideoModeCocoa(_glfw.monitors[i]);
}
@end // GLFWApplicationDelegate
//////////////////////////////////////////////////////////////////////////
////// GLFW internal API //////
//////////////////////////////////////////////////////////////////////////
void* _glfwLoadLocalVulkanLoaderCocoa(void)
{
CFBundleRef bundle = CFBundleGetMainBundle();
if (!bundle)
return NULL;
CFURLRef frameworksUrl = CFBundleCopyPrivateFrameworksURL(bundle);
if (!frameworksUrl)
return NULL;
CFURLRef loaderUrl = CFURLCreateCopyAppendingPathComponent(
kCFAllocatorDefault, frameworksUrl, CFSTR("libvulkan.1.dylib"), false);
if (!loaderUrl)
{
CFRelease(frameworksUrl);
return NULL;
}
char path[PATH_MAX];
void* handle = NULL;
if (CFURLGetFileSystemRepresentation(loaderUrl, true, (UInt8*) path, sizeof(path) - 1))
handle = _glfwPlatformLoadModule(path);
CFRelease(loaderUrl);
CFRelease(frameworksUrl);
return handle;
}
//////////////////////////////////////////////////////////////////////////
////// GLFW platform API //////
//////////////////////////////////////////////////////////////////////////
GLFWbool _glfwConnectCocoa(int platformID, _GLFWplatform* platform)
{
const _GLFWplatform cocoa =
{
GLFW_PLATFORM_COCOA,
_glfwInitCocoa,
_glfwTerminateCocoa,
_glfwGetCursorPosCocoa,
_glfwSetCursorPosCocoa,
_glfwSetCursorModeCocoa,
_glfwSetRawMouseMotionCocoa,
_glfwRawMouseMotionSupportedCocoa,
_glfwCreateCursorCocoa,
_glfwCreateStandardCursorCocoa,
_glfwDestroyCursorCocoa,
_glfwSetCursorCocoa,
_glfwGetScancodeNameCocoa,
_glfwGetKeyScancodeCocoa,
_glfwSetClipboardStringCocoa,
_glfwGetClipboardStringCocoa,
_glfwInitJoysticksCocoa,
_glfwTerminateJoysticksCocoa,
_glfwPollJoystickCocoa,
_glfwGetMappingNameCocoa,
_glfwUpdateGamepadGUIDCocoa,
_glfwFreeMonitorCocoa,
_glfwGetMonitorPosCocoa,
_glfwGetMonitorContentScaleCocoa,
_glfwGetMonitorWorkareaCocoa,
_glfwGetVideoModesCocoa,
_glfwGetVideoModeCocoa,
_glfwGetGammaRampCocoa,
_glfwSetGammaRampCocoa,
_glfwCreateWindowCocoa,
_glfwDestroyWindowCocoa,
_glfwSetWindowTitleCocoa,
_glfwSetWindowIconCocoa,
_glfwGetWindowPosCocoa,
_glfwSetWindowPosCocoa,
_glfwGetWindowSizeCocoa,
_glfwSetWindowSizeCocoa,
_glfwSetWindowSizeLimitsCocoa,
_glfwSetWindowAspectRatioCocoa,
_glfwGetFramebufferSizeCocoa,
_glfwGetWindowFrameSizeCocoa,
_glfwGetWindowContentScaleCocoa,
_glfwIconifyWindowCocoa,
_glfwRestoreWindowCocoa,
_glfwMaximizeWindowCocoa,
_glfwShowWindowCocoa,
_glfwHideWindowCocoa,
_glfwRequestWindowAttentionCocoa,
_glfwFocusWindowCocoa,
_glfwSetWindowMonitorCocoa,
_glfwWindowFocusedCocoa,
_glfwWindowIconifiedCocoa,
_glfwWindowVisibleCocoa,
_glfwWindowMaximizedCocoa,
_glfwWindowHoveredCocoa,
_glfwFramebufferTransparentCocoa,
_glfwGetWindowOpacityCocoa,
_glfwSetWindowResizableCocoa,
_glfwSetWindowDecoratedCocoa,
_glfwSetWindowFloatingCocoa,
_glfwSetWindowOpacityCocoa,
_glfwSetWindowMousePassthroughCocoa,
_glfwPollEventsCocoa,
_glfwWaitEventsCocoa,
_glfwWaitEventsTimeoutCocoa,
_glfwPostEmptyEventCocoa,
_glfwGetEGLPlatformCocoa,
_glfwGetEGLNativeDisplayCocoa,
_glfwGetEGLNativeWindowCocoa,
_glfwGetRequiredInstanceExtensionsCocoa,
_glfwGetPhysicalDevicePresentationSupportCocoa,
_glfwCreateWindowSurfaceCocoa,
};
*platform = cocoa;
return GLFW_TRUE;
}
int _glfwInitCocoa(void)
{
@autoreleasepool {
_glfw.ns.helper = [[GLFWHelper alloc] init];
[NSThread detachNewThreadSelector:@selector(doNothing:)
toTarget:_glfw.ns.helper
withObject:nil];
[NSApplication sharedApplication];
_glfw.ns.delegate = [[GLFWApplicationDelegate alloc] init];
if (_glfw.ns.delegate == nil)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"Cocoa: Failed to create application delegate");
return GLFW_FALSE;
}
[NSApp setDelegate:_glfw.ns.delegate];
NSEvent* (^block)(NSEvent*) = ^ NSEvent* (NSEvent* event)
{
if ([event modifierFlags] & NSEventModifierFlagCommand)
[[NSApp keyWindow] sendEvent:event];
return event;
};
_glfw.ns.keyUpMonitor =
[NSEvent addLocalMonitorForEventsMatchingMask:NSEventMaskKeyUp
handler:block];
if (_glfw.hints.init.ns.chdir)
changeToResourcesDirectory();
// Press and Hold prevents some keys from emitting repeated characters
NSDictionary* defaults = @{@"ApplePressAndHoldEnabled":@NO};
[[NSUserDefaults standardUserDefaults] registerDefaults:defaults];
[[NSNotificationCenter defaultCenter]
addObserver:_glfw.ns.helper
selector:@selector(selectedKeyboardInputSourceChanged:)
name:NSTextInputContextKeyboardSelectionDidChangeNotification
object:nil];
createKeyTables();
_glfw.ns.eventSource = CGEventSourceCreate(kCGEventSourceStateHIDSystemState);
if (!_glfw.ns.eventSource)
return GLFW_FALSE;
CGEventSourceSetLocalEventsSuppressionInterval(_glfw.ns.eventSource, 0.0);
if (!initializeTIS())
return GLFW_FALSE;
_glfwPollMonitorsCocoa();
if (![[NSRunningApplication currentApplication] isFinishedLaunching])
[NSApp run];
// In case we are unbundled, make us a proper UI application
if (_glfw.hints.init.ns.menubar)
[NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
return GLFW_TRUE;
} // autoreleasepool
}
void _glfwTerminateCocoa(void)
{
@autoreleasepool {
if (_glfw.ns.inputSource)
{
CFRelease(_glfw.ns.inputSource);
_glfw.ns.inputSource = NULL;
_glfw.ns.unicodeData = nil;
}
if (_glfw.ns.eventSource)
{
CFRelease(_glfw.ns.eventSource);
_glfw.ns.eventSource = NULL;
}
if (_glfw.ns.delegate)
{
[NSApp setDelegate:nil];
[_glfw.ns.delegate release];
_glfw.ns.delegate = nil;
}
if (_glfw.ns.helper)
{
[[NSNotificationCenter defaultCenter]
removeObserver:_glfw.ns.helper
name:NSTextInputContextKeyboardSelectionDidChangeNotification
object:nil];
[[NSNotificationCenter defaultCenter]
removeObserver:_glfw.ns.helper];
[_glfw.ns.helper release];
_glfw.ns.helper = nil;
}
if (_glfw.ns.keyUpMonitor)
[NSEvent removeMonitor:_glfw.ns.keyUpMonitor];
_glfw_free(_glfw.ns.clipboardString);
_glfwTerminateNSGL();
_glfwTerminateEGL();
_glfwTerminateOSMesa();
} // autoreleasepool
}

View File

@@ -0,0 +1,51 @@
//========================================================================
// GLFW 3.4 Cocoa - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would
// be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such, and must not
// be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source
// distribution.
//
//========================================================================
#include <IOKit/IOKitLib.h>
#include <IOKit/IOCFPlugIn.h>
#include <IOKit/hid/IOHIDKeys.h>
#define GLFW_COCOA_JOYSTICK_STATE _GLFWjoystickNS ns;
#define GLFW_COCOA_LIBRARY_JOYSTICK_STATE
#define GLFW_BUILD_COCOA_MAPPINGS
// Cocoa-specific per-joystick data
//
typedef struct _GLFWjoystickNS
{
IOHIDDeviceRef device;
CFMutableArrayRef axes;
CFMutableArrayRef buttons;
CFMutableArrayRef hats;
} _GLFWjoystickNS;
GLFWbool _glfwInitJoysticksCocoa(void);
void _glfwTerminateJoysticksCocoa(void);
GLFWbool _glfwPollJoystickCocoa(_GLFWjoystick* js, int mode);
const char* _glfwGetMappingNameCocoa(void);
void _glfwUpdateGamepadGUIDCocoa(char* guid);

View File

@@ -0,0 +1,478 @@
//========================================================================
// GLFW 3.4 Cocoa - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2009-2019 Camilla Löwy <elmindreda@glfw.org>
// Copyright (c) 2012 Torsten Walluhn <tw@mad-cad.net>
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would
// be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such, and must not
// be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source
// distribution.
//
//========================================================================
// It is fine to use C99 in this file because it will not be built with VS
//========================================================================
#include "internal.h"
#include <unistd.h>
#include <ctype.h>
#include <string.h>
#include <mach/mach.h>
#include <mach/mach_error.h>
#include <CoreFoundation/CoreFoundation.h>
#include <Kernel/IOKit/hidsystem/IOHIDUsageTables.h>
// Joystick element information
//
typedef struct _GLFWjoyelementNS
{
IOHIDElementRef native;
uint32_t usage;
int index;
long minimum;
long maximum;
} _GLFWjoyelementNS;
// Returns the value of the specified element of the specified joystick
//
static long getElementValue(_GLFWjoystick* js, _GLFWjoyelementNS* element)
{
IOHIDValueRef valueRef;
long value = 0;
if (js->ns.device)
{
if (IOHIDDeviceGetValue(js->ns.device,
element->native,
&valueRef) == kIOReturnSuccess)
{
value = IOHIDValueGetIntegerValue(valueRef);
}
}
return value;
}
// Comparison function for matching the SDL element order
//
static CFComparisonResult compareElements(const void* fp,
const void* sp,
void* user)
{
const _GLFWjoyelementNS* fe = fp;
const _GLFWjoyelementNS* se = sp;
if (fe->usage < se->usage)
return kCFCompareLessThan;
if (fe->usage > se->usage)
return kCFCompareGreaterThan;
if (fe->index < se->index)
return kCFCompareLessThan;
if (fe->index > se->index)
return kCFCompareGreaterThan;
return kCFCompareEqualTo;
}
// Removes the specified joystick
//
static void closeJoystick(_GLFWjoystick* js)
{
_glfwInputJoystick(js, GLFW_DISCONNECTED);
for (int i = 0; i < CFArrayGetCount(js->ns.axes); i++)
_glfw_free((void*) CFArrayGetValueAtIndex(js->ns.axes, i));
CFRelease(js->ns.axes);
for (int i = 0; i < CFArrayGetCount(js->ns.buttons); i++)
_glfw_free((void*) CFArrayGetValueAtIndex(js->ns.buttons, i));
CFRelease(js->ns.buttons);
for (int i = 0; i < CFArrayGetCount(js->ns.hats); i++)
_glfw_free((void*) CFArrayGetValueAtIndex(js->ns.hats, i));
CFRelease(js->ns.hats);
_glfwFreeJoystick(js);
}
// Callback for user-initiated joystick addition
//
static void matchCallback(void* context,
IOReturn result,
void* sender,
IOHIDDeviceRef device)
{
int jid;
char name[256];
char guid[33];
CFTypeRef property;
uint32_t vendor = 0, product = 0, version = 0;
_GLFWjoystick* js;
CFMutableArrayRef axes, buttons, hats;
for (jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++)
{
if (_glfw.joysticks[jid].ns.device == device)
return;
}
axes = CFArrayCreateMutable(NULL, 0, NULL);
buttons = CFArrayCreateMutable(NULL, 0, NULL);
hats = CFArrayCreateMutable(NULL, 0, NULL);
property = IOHIDDeviceGetProperty(device, CFSTR(kIOHIDProductKey));
if (property)
{
CFStringGetCString(property,
name,
sizeof(name),
kCFStringEncodingUTF8);
}
else
strncpy(name, "Unknown", sizeof(name));
property = IOHIDDeviceGetProperty(device, CFSTR(kIOHIDVendorIDKey));
if (property)
CFNumberGetValue(property, kCFNumberSInt32Type, &vendor);
property = IOHIDDeviceGetProperty(device, CFSTR(kIOHIDProductIDKey));
if (property)
CFNumberGetValue(property, kCFNumberSInt32Type, &product);
property = IOHIDDeviceGetProperty(device, CFSTR(kIOHIDVersionNumberKey));
if (property)
CFNumberGetValue(property, kCFNumberSInt32Type, &version);
// Generate a joystick GUID that matches the SDL 2.0.5+ one
if (vendor && product)
{
sprintf(guid, "03000000%02x%02x0000%02x%02x0000%02x%02x0000",
(uint8_t) vendor, (uint8_t) (vendor >> 8),
(uint8_t) product, (uint8_t) (product >> 8),
(uint8_t) version, (uint8_t) (version >> 8));
}
else
{
sprintf(guid, "05000000%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x00",
name[0], name[1], name[2], name[3],
name[4], name[5], name[6], name[7],
name[8], name[9], name[10]);
}
CFArrayRef elements =
IOHIDDeviceCopyMatchingElements(device, NULL, kIOHIDOptionsTypeNone);
for (CFIndex i = 0; i < CFArrayGetCount(elements); i++)
{
IOHIDElementRef native = (IOHIDElementRef)
CFArrayGetValueAtIndex(elements, i);
if (CFGetTypeID(native) != IOHIDElementGetTypeID())
continue;
const IOHIDElementType type = IOHIDElementGetType(native);
if ((type != kIOHIDElementTypeInput_Axis) &&
(type != kIOHIDElementTypeInput_Button) &&
(type != kIOHIDElementTypeInput_Misc))
{
continue;
}
CFMutableArrayRef target = NULL;
const uint32_t usage = IOHIDElementGetUsage(native);
const uint32_t page = IOHIDElementGetUsagePage(native);
if (page == kHIDPage_GenericDesktop)
{
switch (usage)
{
case kHIDUsage_GD_X:
case kHIDUsage_GD_Y:
case kHIDUsage_GD_Z:
case kHIDUsage_GD_Rx:
case kHIDUsage_GD_Ry:
case kHIDUsage_GD_Rz:
case kHIDUsage_GD_Slider:
case kHIDUsage_GD_Dial:
case kHIDUsage_GD_Wheel:
target = axes;
break;
case kHIDUsage_GD_Hatswitch:
target = hats;
break;
case kHIDUsage_GD_DPadUp:
case kHIDUsage_GD_DPadRight:
case kHIDUsage_GD_DPadDown:
case kHIDUsage_GD_DPadLeft:
case kHIDUsage_GD_SystemMainMenu:
case kHIDUsage_GD_Select:
case kHIDUsage_GD_Start:
target = buttons;
break;
}
}
else if (page == kHIDPage_Simulation)
{
switch (usage)
{
case kHIDUsage_Sim_Accelerator:
case kHIDUsage_Sim_Brake:
case kHIDUsage_Sim_Throttle:
case kHIDUsage_Sim_Rudder:
case kHIDUsage_Sim_Steering:
target = axes;
break;
}
}
else if (page == kHIDPage_Button || page == kHIDPage_Consumer)
target = buttons;
if (target)
{
_GLFWjoyelementNS* element = _glfw_calloc(1, sizeof(_GLFWjoyelementNS));
element->native = native;
element->usage = usage;
element->index = (int) CFArrayGetCount(target);
element->minimum = IOHIDElementGetLogicalMin(native);
element->maximum = IOHIDElementGetLogicalMax(native);
CFArrayAppendValue(target, element);
}
}
CFRelease(elements);
CFArraySortValues(axes, CFRangeMake(0, CFArrayGetCount(axes)),
compareElements, NULL);
CFArraySortValues(buttons, CFRangeMake(0, CFArrayGetCount(buttons)),
compareElements, NULL);
CFArraySortValues(hats, CFRangeMake(0, CFArrayGetCount(hats)),
compareElements, NULL);
js = _glfwAllocJoystick(name, guid,
(int) CFArrayGetCount(axes),
(int) CFArrayGetCount(buttons),
(int) CFArrayGetCount(hats));
js->ns.device = device;
js->ns.axes = axes;
js->ns.buttons = buttons;
js->ns.hats = hats;
_glfwInputJoystick(js, GLFW_CONNECTED);
}
// Callback for user-initiated joystick removal
//
static void removeCallback(void* context,
IOReturn result,
void* sender,
IOHIDDeviceRef device)
{
for (int jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++)
{
if (_glfw.joysticks[jid].connected && _glfw.joysticks[jid].ns.device == device)
{
closeJoystick(&_glfw.joysticks[jid]);
break;
}
}
}
//////////////////////////////////////////////////////////////////////////
////// GLFW platform API //////
//////////////////////////////////////////////////////////////////////////
GLFWbool _glfwInitJoysticksCocoa(void)
{
CFMutableArrayRef matching;
const long usages[] =
{
kHIDUsage_GD_Joystick,
kHIDUsage_GD_GamePad,
kHIDUsage_GD_MultiAxisController
};
_glfw.ns.hidManager = IOHIDManagerCreate(kCFAllocatorDefault,
kIOHIDOptionsTypeNone);
matching = CFArrayCreateMutable(kCFAllocatorDefault,
0,
&kCFTypeArrayCallBacks);
if (!matching)
{
_glfwInputError(GLFW_PLATFORM_ERROR, "Cocoa: Failed to create array");
return GLFW_FALSE;
}
for (size_t i = 0; i < sizeof(usages) / sizeof(long); i++)
{
const long page = kHIDPage_GenericDesktop;
CFMutableDictionaryRef dict =
CFDictionaryCreateMutable(kCFAllocatorDefault,
0,
&kCFTypeDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks);
if (!dict)
continue;
CFNumberRef pageRef = CFNumberCreate(kCFAllocatorDefault,
kCFNumberLongType,
&page);
CFNumberRef usageRef = CFNumberCreate(kCFAllocatorDefault,
kCFNumberLongType,
&usages[i]);
if (pageRef && usageRef)
{
CFDictionarySetValue(dict,
CFSTR(kIOHIDDeviceUsagePageKey),
pageRef);
CFDictionarySetValue(dict,
CFSTR(kIOHIDDeviceUsageKey),
usageRef);
CFArrayAppendValue(matching, dict);
}
if (pageRef)
CFRelease(pageRef);
if (usageRef)
CFRelease(usageRef);
CFRelease(dict);
}
IOHIDManagerSetDeviceMatchingMultiple(_glfw.ns.hidManager, matching);
CFRelease(matching);
IOHIDManagerRegisterDeviceMatchingCallback(_glfw.ns.hidManager,
&matchCallback, NULL);
IOHIDManagerRegisterDeviceRemovalCallback(_glfw.ns.hidManager,
&removeCallback, NULL);
IOHIDManagerScheduleWithRunLoop(_glfw.ns.hidManager,
CFRunLoopGetMain(),
kCFRunLoopDefaultMode);
IOHIDManagerOpen(_glfw.ns.hidManager, kIOHIDOptionsTypeNone);
// Execute the run loop once in order to register any initially-attached
// joysticks
CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, false);
return GLFW_TRUE;
}
void _glfwTerminateJoysticksCocoa(void)
{
for (int jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++)
{
if (_glfw.joysticks[jid].connected)
closeJoystick(&_glfw.joysticks[jid]);
}
if (_glfw.ns.hidManager)
{
CFRelease(_glfw.ns.hidManager);
_glfw.ns.hidManager = NULL;
}
}
GLFWbool _glfwPollJoystickCocoa(_GLFWjoystick* js, int mode)
{
if (mode & _GLFW_POLL_AXES)
{
for (CFIndex i = 0; i < CFArrayGetCount(js->ns.axes); i++)
{
_GLFWjoyelementNS* axis = (_GLFWjoyelementNS*)
CFArrayGetValueAtIndex(js->ns.axes, i);
const long raw = getElementValue(js, axis);
// Perform auto calibration
if (raw < axis->minimum)
axis->minimum = raw;
if (raw > axis->maximum)
axis->maximum = raw;
const long size = axis->maximum - axis->minimum;
if (size == 0)
_glfwInputJoystickAxis(js, (int) i, 0.f);
else
{
const float value = (2.f * (raw - axis->minimum) / size) - 1.f;
_glfwInputJoystickAxis(js, (int) i, value);
}
}
}
if (mode & _GLFW_POLL_BUTTONS)
{
for (CFIndex i = 0; i < CFArrayGetCount(js->ns.buttons); i++)
{
_GLFWjoyelementNS* button = (_GLFWjoyelementNS*)
CFArrayGetValueAtIndex(js->ns.buttons, i);
const char value = getElementValue(js, button) - button->minimum;
const int state = (value > 0) ? GLFW_PRESS : GLFW_RELEASE;
_glfwInputJoystickButton(js, (int) i, state);
}
for (CFIndex i = 0; i < CFArrayGetCount(js->ns.hats); i++)
{
const int states[9] =
{
GLFW_HAT_UP,
GLFW_HAT_RIGHT_UP,
GLFW_HAT_RIGHT,
GLFW_HAT_RIGHT_DOWN,
GLFW_HAT_DOWN,
GLFW_HAT_LEFT_DOWN,
GLFW_HAT_LEFT,
GLFW_HAT_LEFT_UP,
GLFW_HAT_CENTERED
};
_GLFWjoyelementNS* hat = (_GLFWjoyelementNS*)
CFArrayGetValueAtIndex(js->ns.hats, i);
long state = getElementValue(js, hat) - hat->minimum;
if (state < 0 || state > 8)
state = 8;
_glfwInputJoystickHat(js, (int) i, states[state]);
}
}
return js->connected;
}
const char* _glfwGetMappingNameCocoa(void)
{
return "Mac OS X";
}
void _glfwUpdateGamepadGUIDCocoa(char* guid)
{
if ((strncmp(guid + 4, "000000000000", 12) == 0) &&
(strncmp(guid + 20, "000000000000", 12) == 0))
{
char original[33];
strncpy(original, guid, sizeof(original) - 1);
sprintf(guid, "03000000%.4s0000%.4s000000000000",
original, original + 16);
}
}

View File

@@ -0,0 +1,627 @@
//========================================================================
// GLFW 3.4 macOS - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would
// be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such, and must not
// be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source
// distribution.
//
//========================================================================
// It is fine to use C99 in this file because it will not be built with VS
//========================================================================
#include "internal.h"
#include <stdlib.h>
#include <limits.h>
#include <math.h>
#include <IOKit/graphics/IOGraphicsLib.h>
#include <ApplicationServices/ApplicationServices.h>
// Get the name of the specified display, or NULL
//
static char* getMonitorName(CGDirectDisplayID displayID, NSScreen* screen)
{
// IOKit doesn't work on Apple Silicon anymore
// Luckily, 10.15 introduced -[NSScreen localizedName].
// Use it if available, and fall back to IOKit otherwise.
if (screen)
{
if ([screen respondsToSelector:@selector(localizedName)])
{
NSString* name = [screen valueForKey:@"localizedName"];
if (name)
return _glfw_strdup([name UTF8String]);
}
}
io_iterator_t it;
io_service_t service;
CFDictionaryRef info;
if (IOServiceGetMatchingServices(MACH_PORT_NULL,
IOServiceMatching("IODisplayConnect"),
&it) != 0)
{
// This may happen if a desktop Mac is running headless
return _glfw_strdup("Display");
}
while ((service = IOIteratorNext(it)) != 0)
{
info = IODisplayCreateInfoDictionary(service,
kIODisplayOnlyPreferredName);
CFNumberRef vendorIDRef =
CFDictionaryGetValue(info, CFSTR(kDisplayVendorID));
CFNumberRef productIDRef =
CFDictionaryGetValue(info, CFSTR(kDisplayProductID));
if (!vendorIDRef || !productIDRef)
{
CFRelease(info);
continue;
}
unsigned int vendorID, productID;
CFNumberGetValue(vendorIDRef, kCFNumberIntType, &vendorID);
CFNumberGetValue(productIDRef, kCFNumberIntType, &productID);
if (CGDisplayVendorNumber(displayID) == vendorID &&
CGDisplayModelNumber(displayID) == productID)
{
// Info dictionary is used and freed below
break;
}
CFRelease(info);
}
IOObjectRelease(it);
if (!service)
return _glfw_strdup("Display");
CFDictionaryRef names =
CFDictionaryGetValue(info, CFSTR(kDisplayProductName));
CFStringRef nameRef;
if (!names || !CFDictionaryGetValueIfPresent(names, CFSTR("en_US"),
(const void**) &nameRef))
{
// This may happen if a desktop Mac is running headless
CFRelease(info);
return _glfw_strdup("Display");
}
const CFIndex size =
CFStringGetMaximumSizeForEncoding(CFStringGetLength(nameRef),
kCFStringEncodingUTF8);
char* name = _glfw_calloc(size + 1, 1);
CFStringGetCString(nameRef, name, size, kCFStringEncodingUTF8);
CFRelease(info);
return name;
}
// Check whether the display mode should be included in enumeration
//
static GLFWbool modeIsGood(CGDisplayModeRef mode)
{
uint32_t flags = CGDisplayModeGetIOFlags(mode);
if (!(flags & kDisplayModeValidFlag) || !(flags & kDisplayModeSafeFlag))
return GLFW_FALSE;
if (flags & kDisplayModeInterlacedFlag)
return GLFW_FALSE;
if (flags & kDisplayModeStretchedFlag)
return GLFW_FALSE;
#if MAC_OS_X_VERSION_MAX_ALLOWED <= 101100
CFStringRef format = CGDisplayModeCopyPixelEncoding(mode);
if (CFStringCompare(format, CFSTR(IO16BitDirectPixels), 0) &&
CFStringCompare(format, CFSTR(IO32BitDirectPixels), 0))
{
CFRelease(format);
return GLFW_FALSE;
}
CFRelease(format);
#endif /* MAC_OS_X_VERSION_MAX_ALLOWED */
return GLFW_TRUE;
}
// Convert Core Graphics display mode to GLFW video mode
//
static GLFWvidmode vidmodeFromCGDisplayMode(CGDisplayModeRef mode,
double fallbackRefreshRate)
{
GLFWvidmode result;
result.width = (int) CGDisplayModeGetWidth(mode);
result.height = (int) CGDisplayModeGetHeight(mode);
result.refreshRate = (int) round(CGDisplayModeGetRefreshRate(mode));
if (result.refreshRate == 0)
result.refreshRate = (int) round(fallbackRefreshRate);
#if MAC_OS_X_VERSION_MAX_ALLOWED <= 101100
CFStringRef format = CGDisplayModeCopyPixelEncoding(mode);
if (CFStringCompare(format, CFSTR(IO16BitDirectPixels), 0) == 0)
{
result.redBits = 5;
result.greenBits = 5;
result.blueBits = 5;
}
else
#endif /* MAC_OS_X_VERSION_MAX_ALLOWED */
{
result.redBits = 8;
result.greenBits = 8;
result.blueBits = 8;
}
#if MAC_OS_X_VERSION_MAX_ALLOWED <= 101100
CFRelease(format);
#endif /* MAC_OS_X_VERSION_MAX_ALLOWED */
return result;
}
// Starts reservation for display fading
//
static CGDisplayFadeReservationToken beginFadeReservation(void)
{
CGDisplayFadeReservationToken token = kCGDisplayFadeReservationInvalidToken;
if (CGAcquireDisplayFadeReservation(5, &token) == kCGErrorSuccess)
{
CGDisplayFade(token, 0.3,
kCGDisplayBlendNormal,
kCGDisplayBlendSolidColor,
0.0, 0.0, 0.0,
TRUE);
}
return token;
}
// Ends reservation for display fading
//
static void endFadeReservation(CGDisplayFadeReservationToken token)
{
if (token != kCGDisplayFadeReservationInvalidToken)
{
CGDisplayFade(token, 0.5,
kCGDisplayBlendSolidColor,
kCGDisplayBlendNormal,
0.0, 0.0, 0.0,
FALSE);
CGReleaseDisplayFadeReservation(token);
}
}
// Returns the display refresh rate queried from the I/O registry
//
static double getFallbackRefreshRate(CGDirectDisplayID displayID)
{
double refreshRate = 60.0;
io_iterator_t it;
io_service_t service;
if (IOServiceGetMatchingServices(MACH_PORT_NULL,
IOServiceMatching("IOFramebuffer"),
&it) != 0)
{
return refreshRate;
}
while ((service = IOIteratorNext(it)) != 0)
{
const CFNumberRef indexRef =
IORegistryEntryCreateCFProperty(service,
CFSTR("IOFramebufferOpenGLIndex"),
kCFAllocatorDefault,
kNilOptions);
if (!indexRef)
continue;
uint32_t index = 0;
CFNumberGetValue(indexRef, kCFNumberIntType, &index);
CFRelease(indexRef);
if (CGOpenGLDisplayMaskToDisplayID(1 << index) != displayID)
continue;
const CFNumberRef clockRef =
IORegistryEntryCreateCFProperty(service,
CFSTR("IOFBCurrentPixelClock"),
kCFAllocatorDefault,
kNilOptions);
const CFNumberRef countRef =
IORegistryEntryCreateCFProperty(service,
CFSTR("IOFBCurrentPixelCount"),
kCFAllocatorDefault,
kNilOptions);
uint32_t clock = 0, count = 0;
if (clockRef)
{
CFNumberGetValue(clockRef, kCFNumberIntType, &clock);
CFRelease(clockRef);
}
if (countRef)
{
CFNumberGetValue(countRef, kCFNumberIntType, &count);
CFRelease(countRef);
}
if (clock > 0 && count > 0)
refreshRate = clock / (double) count;
break;
}
IOObjectRelease(it);
return refreshRate;
}
//////////////////////////////////////////////////////////////////////////
////// GLFW internal API //////
//////////////////////////////////////////////////////////////////////////
// Poll for changes in the set of connected monitors
//
void _glfwPollMonitorsCocoa(void)
{
uint32_t displayCount;
CGGetOnlineDisplayList(0, NULL, &displayCount);
CGDirectDisplayID* displays = _glfw_calloc(displayCount, sizeof(CGDirectDisplayID));
CGGetOnlineDisplayList(displayCount, displays, &displayCount);
for (int i = 0; i < _glfw.monitorCount; i++)
_glfw.monitors[i]->ns.screen = nil;
_GLFWmonitor** disconnected = NULL;
uint32_t disconnectedCount = _glfw.monitorCount;
if (disconnectedCount)
{
disconnected = _glfw_calloc(_glfw.monitorCount, sizeof(_GLFWmonitor*));
memcpy(disconnected,
_glfw.monitors,
_glfw.monitorCount * sizeof(_GLFWmonitor*));
}
for (uint32_t i = 0; i < displayCount; i++)
{
if (CGDisplayIsAsleep(displays[i]))
continue;
const uint32_t unitNumber = CGDisplayUnitNumber(displays[i]);
NSScreen* screen = nil;
for (screen in [NSScreen screens])
{
NSNumber* screenNumber = [screen deviceDescription][@"NSScreenNumber"];
// HACK: Compare unit numbers instead of display IDs to work around
// display replacement on machines with automatic graphics
// switching
if (CGDisplayUnitNumber([screenNumber unsignedIntValue]) == unitNumber)
break;
}
// HACK: Compare unit numbers instead of display IDs to work around
// display replacement on machines with automatic graphics
// switching
uint32_t j;
for (j = 0; j < disconnectedCount; j++)
{
if (disconnected[j] && disconnected[j]->ns.unitNumber == unitNumber)
{
disconnected[j]->ns.screen = screen;
disconnected[j] = NULL;
break;
}
}
if (j < disconnectedCount)
continue;
const CGSize size = CGDisplayScreenSize(displays[i]);
char* name = getMonitorName(displays[i], screen);
if (!name)
continue;
_GLFWmonitor* monitor = _glfwAllocMonitor(name, size.width, size.height);
monitor->ns.displayID = displays[i];
monitor->ns.unitNumber = unitNumber;
monitor->ns.screen = screen;
_glfw_free(name);
CGDisplayModeRef mode = CGDisplayCopyDisplayMode(displays[i]);
if (CGDisplayModeGetRefreshRate(mode) == 0.0)
monitor->ns.fallbackRefreshRate = getFallbackRefreshRate(displays[i]);
CGDisplayModeRelease(mode);
_glfwInputMonitor(monitor, GLFW_CONNECTED, _GLFW_INSERT_LAST);
}
for (uint32_t i = 0; i < disconnectedCount; i++)
{
if (disconnected[i])
_glfwInputMonitor(disconnected[i], GLFW_DISCONNECTED, 0);
}
_glfw_free(disconnected);
_glfw_free(displays);
}
// Change the current video mode
//
void _glfwSetVideoModeCocoa(_GLFWmonitor* monitor, const GLFWvidmode* desired)
{
GLFWvidmode current;
_glfwGetVideoModeCocoa(monitor, &current);
const GLFWvidmode* best = _glfwChooseVideoMode(monitor, desired);
if (_glfwCompareVideoModes(&current, best) == 0)
return;
CFArrayRef modes = CGDisplayCopyAllDisplayModes(monitor->ns.displayID, NULL);
const CFIndex count = CFArrayGetCount(modes);
CGDisplayModeRef native = NULL;
for (CFIndex i = 0; i < count; i++)
{
CGDisplayModeRef dm = (CGDisplayModeRef) CFArrayGetValueAtIndex(modes, i);
if (!modeIsGood(dm))
continue;
const GLFWvidmode mode =
vidmodeFromCGDisplayMode(dm, monitor->ns.fallbackRefreshRate);
if (_glfwCompareVideoModes(best, &mode) == 0)
{
native = dm;
break;
}
}
if (native)
{
if (monitor->ns.previousMode == NULL)
monitor->ns.previousMode = CGDisplayCopyDisplayMode(monitor->ns.displayID);
CGDisplayFadeReservationToken token = beginFadeReservation();
CGDisplaySetDisplayMode(monitor->ns.displayID, native, NULL);
endFadeReservation(token);
}
CFRelease(modes);
}
// Restore the previously saved (original) video mode
//
void _glfwRestoreVideoModeCocoa(_GLFWmonitor* monitor)
{
if (monitor->ns.previousMode)
{
CGDisplayFadeReservationToken token = beginFadeReservation();
CGDisplaySetDisplayMode(monitor->ns.displayID,
monitor->ns.previousMode, NULL);
endFadeReservation(token);
CGDisplayModeRelease(monitor->ns.previousMode);
monitor->ns.previousMode = NULL;
}
}
//////////////////////////////////////////////////////////////////////////
////// GLFW platform API //////
//////////////////////////////////////////////////////////////////////////
void _glfwFreeMonitorCocoa(_GLFWmonitor* monitor)
{
}
void _glfwGetMonitorPosCocoa(_GLFWmonitor* monitor, int* xpos, int* ypos)
{
@autoreleasepool {
const CGRect bounds = CGDisplayBounds(monitor->ns.displayID);
if (xpos)
*xpos = (int) bounds.origin.x;
if (ypos)
*ypos = (int) bounds.origin.y;
} // autoreleasepool
}
void _glfwGetMonitorContentScaleCocoa(_GLFWmonitor* monitor,
float* xscale, float* yscale)
{
@autoreleasepool {
if (!monitor->ns.screen)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"Cocoa: Cannot query content scale without screen");
}
const NSRect points = [monitor->ns.screen frame];
const NSRect pixels = [monitor->ns.screen convertRectToBacking:points];
if (xscale)
*xscale = (float) (pixels.size.width / points.size.width);
if (yscale)
*yscale = (float) (pixels.size.height / points.size.height);
} // autoreleasepool
}
void _glfwGetMonitorWorkareaCocoa(_GLFWmonitor* monitor,
int* xpos, int* ypos,
int* width, int* height)
{
@autoreleasepool {
if (!monitor->ns.screen)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"Cocoa: Cannot query workarea without screen");
}
const NSRect frameRect = [monitor->ns.screen visibleFrame];
if (xpos)
*xpos = frameRect.origin.x;
if (ypos)
*ypos = _glfwTransformYCocoa(frameRect.origin.y + frameRect.size.height - 1);
if (width)
*width = frameRect.size.width;
if (height)
*height = frameRect.size.height;
} // autoreleasepool
}
GLFWvidmode* _glfwGetVideoModesCocoa(_GLFWmonitor* monitor, int* count)
{
@autoreleasepool {
*count = 0;
CFArrayRef modes = CGDisplayCopyAllDisplayModes(monitor->ns.displayID, NULL);
const CFIndex found = CFArrayGetCount(modes);
GLFWvidmode* result = _glfw_calloc(found, sizeof(GLFWvidmode));
for (CFIndex i = 0; i < found; i++)
{
CGDisplayModeRef dm = (CGDisplayModeRef) CFArrayGetValueAtIndex(modes, i);
if (!modeIsGood(dm))
continue;
const GLFWvidmode mode =
vidmodeFromCGDisplayMode(dm, monitor->ns.fallbackRefreshRate);
CFIndex j;
for (j = 0; j < *count; j++)
{
if (_glfwCompareVideoModes(result + j, &mode) == 0)
break;
}
// Skip duplicate modes
if (j < *count)
continue;
(*count)++;
result[*count - 1] = mode;
}
CFRelease(modes);
return result;
} // autoreleasepool
}
void _glfwGetVideoModeCocoa(_GLFWmonitor* monitor, GLFWvidmode *mode)
{
@autoreleasepool {
CGDisplayModeRef native = CGDisplayCopyDisplayMode(monitor->ns.displayID);
*mode = vidmodeFromCGDisplayMode(native, monitor->ns.fallbackRefreshRate);
CGDisplayModeRelease(native);
} // autoreleasepool
}
GLFWbool _glfwGetGammaRampCocoa(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
{
@autoreleasepool {
uint32_t size = CGDisplayGammaTableCapacity(monitor->ns.displayID);
CGGammaValue* values = _glfw_calloc(size * 3, sizeof(CGGammaValue));
CGGetDisplayTransferByTable(monitor->ns.displayID,
size,
values,
values + size,
values + size * 2,
&size);
_glfwAllocGammaArrays(ramp, size);
for (uint32_t i = 0; i < size; i++)
{
ramp->red[i] = (unsigned short) (values[i] * 65535);
ramp->green[i] = (unsigned short) (values[i + size] * 65535);
ramp->blue[i] = (unsigned short) (values[i + size * 2] * 65535);
}
_glfw_free(values);
return GLFW_TRUE;
} // autoreleasepool
}
void _glfwSetGammaRampCocoa(_GLFWmonitor* monitor, const GLFWgammaramp* ramp)
{
@autoreleasepool {
CGGammaValue* values = _glfw_calloc(ramp->size * 3, sizeof(CGGammaValue));
for (unsigned int i = 0; i < ramp->size; i++)
{
values[i] = ramp->red[i] / 65535.f;
values[i + ramp->size] = ramp->green[i] / 65535.f;
values[i + ramp->size * 2] = ramp->blue[i] / 65535.f;
}
CGSetDisplayTransferByTable(monitor->ns.displayID,
ramp->size,
values,
values + ramp->size,
values + ramp->size * 2);
_glfw_free(values);
} // autoreleasepool
}
//////////////////////////////////////////////////////////////////////////
////// GLFW native API //////
//////////////////////////////////////////////////////////////////////////
GLFWAPI CGDirectDisplayID glfwGetCocoaMonitor(GLFWmonitor* handle)
{
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
_GLFW_REQUIRE_INIT_OR_RETURN(kCGNullDirectDisplay);
return monitor->ns.displayID;
}

View File

@@ -0,0 +1,302 @@
//========================================================================
// GLFW 3.4 macOS - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2009-2019 Camilla Löwy <elmindreda@glfw.org>
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would
// be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such, and must not
// be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source
// distribution.
//
//========================================================================
#include <stdint.h>
#include <Carbon/Carbon.h>
#include <IOKit/hid/IOHIDLib.h>
// NOTE: All of NSGL was deprecated in the 10.14 SDK
// This disables the pointless warnings for every symbol we use
#ifndef GL_SILENCE_DEPRECATION
#define GL_SILENCE_DEPRECATION
#endif
#if defined(__OBJC__)
#import <Cocoa/Cocoa.h>
#else
typedef void* id;
#endif
// NOTE: Many Cocoa enum values have been renamed and we need to build across
// SDK versions where one is unavailable or deprecated.
// We use the newer names in code and replace them with the older names if
// the base SDK does not provide the newer names.
#if MAC_OS_X_VERSION_MAX_ALLOWED < 101400
#define NSOpenGLContextParameterSwapInterval NSOpenGLCPSwapInterval
#define NSOpenGLContextParameterSurfaceOpacity NSOpenGLCPSurfaceOpacity
#endif
#if MAC_OS_X_VERSION_MAX_ALLOWED < 101200
#define NSBitmapFormatAlphaNonpremultiplied NSAlphaNonpremultipliedBitmapFormat
#define NSEventMaskAny NSAnyEventMask
#define NSEventMaskKeyUp NSKeyUpMask
#define NSEventModifierFlagCapsLock NSAlphaShiftKeyMask
#define NSEventModifierFlagCommand NSCommandKeyMask
#define NSEventModifierFlagControl NSControlKeyMask
#define NSEventModifierFlagDeviceIndependentFlagsMask NSDeviceIndependentModifierFlagsMask
#define NSEventModifierFlagOption NSAlternateKeyMask
#define NSEventModifierFlagShift NSShiftKeyMask
#define NSEventTypeApplicationDefined NSApplicationDefined
#define NSWindowStyleMaskBorderless NSBorderlessWindowMask
#define NSWindowStyleMaskClosable NSClosableWindowMask
#define NSWindowStyleMaskMiniaturizable NSMiniaturizableWindowMask
#define NSWindowStyleMaskResizable NSResizableWindowMask
#define NSWindowStyleMaskTitled NSTitledWindowMask
#endif
// NOTE: Many Cocoa dynamically linked constants have been renamed and we need
// to build across SDK versions where one is unavailable or deprecated.
// We use the newer names in code and replace them with the older names if
// the deployment target is older than the newer names.
#if MAC_OS_X_VERSION_MIN_REQUIRED < 101300
#define NSPasteboardTypeURL NSURLPboardType
#endif
typedef VkFlags VkMacOSSurfaceCreateFlagsMVK;
typedef VkFlags VkMetalSurfaceCreateFlagsEXT;
typedef struct VkMacOSSurfaceCreateInfoMVK
{
VkStructureType sType;
const void* pNext;
VkMacOSSurfaceCreateFlagsMVK flags;
const void* pView;
} VkMacOSSurfaceCreateInfoMVK;
typedef struct VkMetalSurfaceCreateInfoEXT
{
VkStructureType sType;
const void* pNext;
VkMetalSurfaceCreateFlagsEXT flags;
const void* pLayer;
} VkMetalSurfaceCreateInfoEXT;
typedef VkResult (APIENTRY *PFN_vkCreateMacOSSurfaceMVK)(VkInstance,const VkMacOSSurfaceCreateInfoMVK*,const VkAllocationCallbacks*,VkSurfaceKHR*);
typedef VkResult (APIENTRY *PFN_vkCreateMetalSurfaceEXT)(VkInstance,const VkMetalSurfaceCreateInfoEXT*,const VkAllocationCallbacks*,VkSurfaceKHR*);
#define GLFW_COCOA_WINDOW_STATE _GLFWwindowNS ns;
#define GLFW_COCOA_LIBRARY_WINDOW_STATE _GLFWlibraryNS ns;
#define GLFW_COCOA_MONITOR_STATE _GLFWmonitorNS ns;
#define GLFW_COCOA_CURSOR_STATE _GLFWcursorNS ns;
#define GLFW_NSGL_CONTEXT_STATE _GLFWcontextNSGL nsgl;
#define GLFW_NSGL_LIBRARY_CONTEXT_STATE _GLFWlibraryNSGL nsgl;
// HIToolbox.framework pointer typedefs
#define kTISPropertyUnicodeKeyLayoutData _glfw.ns.tis.kPropertyUnicodeKeyLayoutData
typedef TISInputSourceRef (*PFN_TISCopyCurrentKeyboardLayoutInputSource)(void);
#define TISCopyCurrentKeyboardLayoutInputSource _glfw.ns.tis.CopyCurrentKeyboardLayoutInputSource
typedef void* (*PFN_TISGetInputSourceProperty)(TISInputSourceRef,CFStringRef);
#define TISGetInputSourceProperty _glfw.ns.tis.GetInputSourceProperty
typedef UInt8 (*PFN_LMGetKbdType)(void);
#define LMGetKbdType _glfw.ns.tis.GetKbdType
// NSGL-specific per-context data
//
typedef struct _GLFWcontextNSGL
{
id pixelFormat;
id object;
} _GLFWcontextNSGL;
// NSGL-specific global data
//
typedef struct _GLFWlibraryNSGL
{
// dlopen handle for OpenGL.framework (for glfwGetProcAddress)
CFBundleRef framework;
} _GLFWlibraryNSGL;
// Cocoa-specific per-window data
//
typedef struct _GLFWwindowNS
{
id object;
id delegate;
id view;
id layer;
GLFWbool maximized;
GLFWbool occluded;
GLFWbool retina;
// Cached window properties to filter out duplicate events
int width, height;
int fbWidth, fbHeight;
float xscale, yscale;
// The total sum of the distances the cursor has been warped
// since the last cursor motion event was processed
// This is kept to counteract Cocoa doing the same internally
double cursorWarpDeltaX, cursorWarpDeltaY;
} _GLFWwindowNS;
// Cocoa-specific global data
//
typedef struct _GLFWlibraryNS
{
CGEventSourceRef eventSource;
id delegate;
GLFWbool cursorHidden;
TISInputSourceRef inputSource;
IOHIDManagerRef hidManager;
id unicodeData;
id helper;
id keyUpMonitor;
id nibObjects;
char keynames[GLFW_KEY_LAST + 1][17];
short int keycodes[256];
short int scancodes[GLFW_KEY_LAST + 1];
char* clipboardString;
CGPoint cascadePoint;
// Where to place the cursor when re-enabled
double restoreCursorPosX, restoreCursorPosY;
// The window whose disabled cursor mode is active
_GLFWwindow* disabledCursorWindow;
struct {
CFBundleRef bundle;
PFN_TISCopyCurrentKeyboardLayoutInputSource CopyCurrentKeyboardLayoutInputSource;
PFN_TISGetInputSourceProperty GetInputSourceProperty;
PFN_LMGetKbdType GetKbdType;
CFStringRef kPropertyUnicodeKeyLayoutData;
} tis;
} _GLFWlibraryNS;
// Cocoa-specific per-monitor data
//
typedef struct _GLFWmonitorNS
{
CGDirectDisplayID displayID;
CGDisplayModeRef previousMode;
uint32_t unitNumber;
id screen;
double fallbackRefreshRate;
} _GLFWmonitorNS;
// Cocoa-specific per-cursor data
//
typedef struct _GLFWcursorNS
{
id object;
} _GLFWcursorNS;
GLFWbool _glfwConnectCocoa(int platformID, _GLFWplatform* platform);
int _glfwInitCocoa(void);
void _glfwTerminateCocoa(void);
GLFWbool _glfwCreateWindowCocoa(_GLFWwindow* window, const _GLFWwndconfig* wndconfig, const _GLFWctxconfig* ctxconfig, const _GLFWfbconfig* fbconfig);
void _glfwDestroyWindowCocoa(_GLFWwindow* window);
void _glfwSetWindowTitleCocoa(_GLFWwindow* window, const char* title);
void _glfwSetWindowIconCocoa(_GLFWwindow* window, int count, const GLFWimage* images);
void _glfwGetWindowPosCocoa(_GLFWwindow* window, int* xpos, int* ypos);
void _glfwSetWindowPosCocoa(_GLFWwindow* window, int xpos, int ypos);
void _glfwGetWindowSizeCocoa(_GLFWwindow* window, int* width, int* height);
void _glfwSetWindowSizeCocoa(_GLFWwindow* window, int width, int height);
void _glfwSetWindowSizeLimitsCocoa(_GLFWwindow* window, int minwidth, int minheight, int maxwidth, int maxheight);
void _glfwSetWindowAspectRatioCocoa(_GLFWwindow* window, int numer, int denom);
void _glfwGetFramebufferSizeCocoa(_GLFWwindow* window, int* width, int* height);
void _glfwGetWindowFrameSizeCocoa(_GLFWwindow* window, int* left, int* top, int* right, int* bottom);
void _glfwGetWindowContentScaleCocoa(_GLFWwindow* window, float* xscale, float* yscale);
void _glfwIconifyWindowCocoa(_GLFWwindow* window);
void _glfwRestoreWindowCocoa(_GLFWwindow* window);
void _glfwMaximizeWindowCocoa(_GLFWwindow* window);
void _glfwShowWindowCocoa(_GLFWwindow* window);
void _glfwHideWindowCocoa(_GLFWwindow* window);
void _glfwRequestWindowAttentionCocoa(_GLFWwindow* window);
void _glfwFocusWindowCocoa(_GLFWwindow* window);
void _glfwSetWindowMonitorCocoa(_GLFWwindow* window, _GLFWmonitor* monitor, int xpos, int ypos, int width, int height, int refreshRate);
GLFWbool _glfwWindowFocusedCocoa(_GLFWwindow* window);
GLFWbool _glfwWindowIconifiedCocoa(_GLFWwindow* window);
GLFWbool _glfwWindowVisibleCocoa(_GLFWwindow* window);
GLFWbool _glfwWindowMaximizedCocoa(_GLFWwindow* window);
GLFWbool _glfwWindowHoveredCocoa(_GLFWwindow* window);
GLFWbool _glfwFramebufferTransparentCocoa(_GLFWwindow* window);
void _glfwSetWindowResizableCocoa(_GLFWwindow* window, GLFWbool enabled);
void _glfwSetWindowDecoratedCocoa(_GLFWwindow* window, GLFWbool enabled);
void _glfwSetWindowFloatingCocoa(_GLFWwindow* window, GLFWbool enabled);
float _glfwGetWindowOpacityCocoa(_GLFWwindow* window);
void _glfwSetWindowOpacityCocoa(_GLFWwindow* window, float opacity);
void _glfwSetWindowMousePassthroughCocoa(_GLFWwindow* window, GLFWbool enabled);
void _glfwSetRawMouseMotionCocoa(_GLFWwindow *window, GLFWbool enabled);
GLFWbool _glfwRawMouseMotionSupportedCocoa(void);
void _glfwPollEventsCocoa(void);
void _glfwWaitEventsCocoa(void);
void _glfwWaitEventsTimeoutCocoa(double timeout);
void _glfwPostEmptyEventCocoa(void);
void _glfwGetCursorPosCocoa(_GLFWwindow* window, double* xpos, double* ypos);
void _glfwSetCursorPosCocoa(_GLFWwindow* window, double xpos, double ypos);
void _glfwSetCursorModeCocoa(_GLFWwindow* window, int mode);
const char* _glfwGetScancodeNameCocoa(int scancode);
int _glfwGetKeyScancodeCocoa(int key);
GLFWbool _glfwCreateCursorCocoa(_GLFWcursor* cursor, const GLFWimage* image, int xhot, int yhot);
GLFWbool _glfwCreateStandardCursorCocoa(_GLFWcursor* cursor, int shape);
void _glfwDestroyCursorCocoa(_GLFWcursor* cursor);
void _glfwSetCursorCocoa(_GLFWwindow* window, _GLFWcursor* cursor);
void _glfwSetClipboardStringCocoa(const char* string);
const char* _glfwGetClipboardStringCocoa(void);
EGLenum _glfwGetEGLPlatformCocoa(EGLint** attribs);
EGLNativeDisplayType _glfwGetEGLNativeDisplayCocoa(void);
EGLNativeWindowType _glfwGetEGLNativeWindowCocoa(_GLFWwindow* window);
void _glfwGetRequiredInstanceExtensionsCocoa(char** extensions);
GLFWbool _glfwGetPhysicalDevicePresentationSupportCocoa(VkInstance instance, VkPhysicalDevice device, uint32_t queuefamily);
VkResult _glfwCreateWindowSurfaceCocoa(VkInstance instance, _GLFWwindow* window, const VkAllocationCallbacks* allocator, VkSurfaceKHR* surface);
void _glfwFreeMonitorCocoa(_GLFWmonitor* monitor);
void _glfwGetMonitorPosCocoa(_GLFWmonitor* monitor, int* xpos, int* ypos);
void _glfwGetMonitorContentScaleCocoa(_GLFWmonitor* monitor, float* xscale, float* yscale);
void _glfwGetMonitorWorkareaCocoa(_GLFWmonitor* monitor, int* xpos, int* ypos, int* width, int* height);
GLFWvidmode* _glfwGetVideoModesCocoa(_GLFWmonitor* monitor, int* count);
void _glfwGetVideoModeCocoa(_GLFWmonitor* monitor, GLFWvidmode* mode);
GLFWbool _glfwGetGammaRampCocoa(_GLFWmonitor* monitor, GLFWgammaramp* ramp);
void _glfwSetGammaRampCocoa(_GLFWmonitor* monitor, const GLFWgammaramp* ramp);
void _glfwPollMonitorsCocoa(void);
void _glfwSetVideoModeCocoa(_GLFWmonitor* monitor, const GLFWvidmode* desired);
void _glfwRestoreVideoModeCocoa(_GLFWmonitor* monitor);
float _glfwTransformYCocoa(float y);
void* _glfwLoadLocalVulkanLoaderCocoa(void);
GLFWbool _glfwInitNSGL(void);
void _glfwTerminateNSGL(void);
GLFWbool _glfwCreateContextNSGL(_GLFWwindow* window,
const _GLFWctxconfig* ctxconfig,
const _GLFWfbconfig* fbconfig);
void _glfwDestroyContextNSGL(_GLFWwindow* window);

View File

@@ -0,0 +1,55 @@
//========================================================================
// GLFW 3.4 macOS - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2009-2016 Camilla Löwy <elmindreda@glfw.org>
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would
// be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such, and must not
// be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source
// distribution.
//
//========================================================================
// It is fine to use C99 in this file because it will not be built with VS
//========================================================================
#include "internal.h"
#include <mach/mach_time.h>
//////////////////////////////////////////////////////////////////////////
////// GLFW platform API //////
//////////////////////////////////////////////////////////////////////////
void _glfwPlatformInitTimer(void)
{
mach_timebase_info_data_t info;
mach_timebase_info(&info);
_glfw.timer.ns.frequency = (info.denom * 1e9) / info.numer;
}
uint64_t _glfwPlatformGetTimerValue(void)
{
return mach_absolute_time();
}
uint64_t _glfwPlatformGetTimerFrequency(void)
{
return _glfw.timer.ns.frequency;
}

View File

@@ -0,0 +1,35 @@
//========================================================================
// GLFW 3.4 macOS - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2009-2021 Camilla Löwy <elmindreda@glfw.org>
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would
// be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such, and must not
// be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source
// distribution.
//
//========================================================================
#define GLFW_COCOA_LIBRARY_TIMER_STATE _GLFWtimerNS ns;
// Cocoa-specific global timer data
//
typedef struct _GLFWtimerNS
{
uint64_t frequency;
} _GLFWtimerNS;

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,765 @@
//========================================================================
// GLFW 3.4 - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2016 Camilla Löwy <elmindreda@glfw.org>
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would
// be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such, and must not
// be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source
// distribution.
//
//========================================================================
// Please use C89 style variable declarations in this file because VS 2010
//========================================================================
#include "internal.h"
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <stdio.h>
//////////////////////////////////////////////////////////////////////////
////// GLFW internal API //////
//////////////////////////////////////////////////////////////////////////
// Checks whether the desired context attributes are valid
//
// This function checks things like whether the specified client API version
// exists and whether all relevant options have supported and non-conflicting
// values
//
GLFWbool _glfwIsValidContextConfig(const _GLFWctxconfig* ctxconfig)
{
if (ctxconfig->source != GLFW_NATIVE_CONTEXT_API &&
ctxconfig->source != GLFW_EGL_CONTEXT_API &&
ctxconfig->source != GLFW_OSMESA_CONTEXT_API)
{
_glfwInputError(GLFW_INVALID_ENUM,
"Invalid context creation API 0x%08X",
ctxconfig->source);
return GLFW_FALSE;
}
if (ctxconfig->client != GLFW_NO_API &&
ctxconfig->client != GLFW_OPENGL_API &&
ctxconfig->client != GLFW_OPENGL_ES_API)
{
_glfwInputError(GLFW_INVALID_ENUM,
"Invalid client API 0x%08X",
ctxconfig->client);
return GLFW_FALSE;
}
if (ctxconfig->share)
{
if (ctxconfig->client == GLFW_NO_API ||
ctxconfig->share->context.client == GLFW_NO_API)
{
_glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL);
return GLFW_FALSE;
}
if (ctxconfig->source != ctxconfig->share->context.source)
{
_glfwInputError(GLFW_INVALID_ENUM,
"Context creation APIs do not match between contexts");
return GLFW_FALSE;
}
}
if (ctxconfig->client == GLFW_OPENGL_API)
{
if ((ctxconfig->major < 1 || ctxconfig->minor < 0) ||
(ctxconfig->major == 1 && ctxconfig->minor > 5) ||
(ctxconfig->major == 2 && ctxconfig->minor > 1) ||
(ctxconfig->major == 3 && ctxconfig->minor > 3))
{
// OpenGL 1.0 is the smallest valid version
// OpenGL 1.x series ended with version 1.5
// OpenGL 2.x series ended with version 2.1
// OpenGL 3.x series ended with version 3.3
// For now, let everything else through
_glfwInputError(GLFW_INVALID_VALUE,
"Invalid OpenGL version %i.%i",
ctxconfig->major, ctxconfig->minor);
return GLFW_FALSE;
}
if (ctxconfig->profile)
{
if (ctxconfig->profile != GLFW_OPENGL_CORE_PROFILE &&
ctxconfig->profile != GLFW_OPENGL_COMPAT_PROFILE)
{
_glfwInputError(GLFW_INVALID_ENUM,
"Invalid OpenGL profile 0x%08X",
ctxconfig->profile);
return GLFW_FALSE;
}
if (ctxconfig->major <= 2 ||
(ctxconfig->major == 3 && ctxconfig->minor < 2))
{
// Desktop OpenGL context profiles are only defined for version 3.2
// and above
_glfwInputError(GLFW_INVALID_VALUE,
"Context profiles are only defined for OpenGL version 3.2 and above");
return GLFW_FALSE;
}
}
if (ctxconfig->forward && ctxconfig->major <= 2)
{
// Forward-compatible contexts are only defined for OpenGL version 3.0 and above
_glfwInputError(GLFW_INVALID_VALUE,
"Forward-compatibility is only defined for OpenGL version 3.0 and above");
return GLFW_FALSE;
}
}
else if (ctxconfig->client == GLFW_OPENGL_ES_API)
{
if (ctxconfig->major < 1 || ctxconfig->minor < 0 ||
(ctxconfig->major == 1 && ctxconfig->minor > 1) ||
(ctxconfig->major == 2 && ctxconfig->minor > 0))
{
// OpenGL ES 1.0 is the smallest valid version
// OpenGL ES 1.x series ended with version 1.1
// OpenGL ES 2.x series ended with version 2.0
// For now, let everything else through
_glfwInputError(GLFW_INVALID_VALUE,
"Invalid OpenGL ES version %i.%i",
ctxconfig->major, ctxconfig->minor);
return GLFW_FALSE;
}
}
if (ctxconfig->robustness)
{
if (ctxconfig->robustness != GLFW_NO_RESET_NOTIFICATION &&
ctxconfig->robustness != GLFW_LOSE_CONTEXT_ON_RESET)
{
_glfwInputError(GLFW_INVALID_ENUM,
"Invalid context robustness mode 0x%08X",
ctxconfig->robustness);
return GLFW_FALSE;
}
}
if (ctxconfig->release)
{
if (ctxconfig->release != GLFW_RELEASE_BEHAVIOR_NONE &&
ctxconfig->release != GLFW_RELEASE_BEHAVIOR_FLUSH)
{
_glfwInputError(GLFW_INVALID_ENUM,
"Invalid context release behavior 0x%08X",
ctxconfig->release);
return GLFW_FALSE;
}
}
return GLFW_TRUE;
}
// Chooses the framebuffer config that best matches the desired one
//
const _GLFWfbconfig* _glfwChooseFBConfig(const _GLFWfbconfig* desired,
const _GLFWfbconfig* alternatives,
unsigned int count)
{
unsigned int i;
unsigned int missing, leastMissing = UINT_MAX;
unsigned int colorDiff, leastColorDiff = UINT_MAX;
unsigned int extraDiff, leastExtraDiff = UINT_MAX;
const _GLFWfbconfig* current;
const _GLFWfbconfig* closest = NULL;
for (i = 0; i < count; i++)
{
current = alternatives + i;
if (desired->stereo > 0 && current->stereo == 0)
{
// Stereo is a hard constraint
continue;
}
// Count number of missing buffers
{
missing = 0;
if (desired->alphaBits > 0 && current->alphaBits == 0)
missing++;
if (desired->depthBits > 0 && current->depthBits == 0)
missing++;
if (desired->stencilBits > 0 && current->stencilBits == 0)
missing++;
if (desired->auxBuffers > 0 &&
current->auxBuffers < desired->auxBuffers)
{
missing += desired->auxBuffers - current->auxBuffers;
}
if (desired->samples > 0 && current->samples == 0)
{
// Technically, several multisampling buffers could be
// involved, but that's a lower level implementation detail and
// not important to us here, so we count them as one
missing++;
}
if (desired->transparent != current->transparent)
missing++;
}
// These polynomials make many small channel size differences matter
// less than one large channel size difference
// Calculate color channel size difference value
{
colorDiff = 0;
if (desired->redBits != GLFW_DONT_CARE)
{
colorDiff += (desired->redBits - current->redBits) *
(desired->redBits - current->redBits);
}
if (desired->greenBits != GLFW_DONT_CARE)
{
colorDiff += (desired->greenBits - current->greenBits) *
(desired->greenBits - current->greenBits);
}
if (desired->blueBits != GLFW_DONT_CARE)
{
colorDiff += (desired->blueBits - current->blueBits) *
(desired->blueBits - current->blueBits);
}
}
// Calculate non-color channel size difference value
{
extraDiff = 0;
if (desired->alphaBits != GLFW_DONT_CARE)
{
extraDiff += (desired->alphaBits - current->alphaBits) *
(desired->alphaBits - current->alphaBits);
}
if (desired->depthBits != GLFW_DONT_CARE)
{
extraDiff += (desired->depthBits - current->depthBits) *
(desired->depthBits - current->depthBits);
}
if (desired->stencilBits != GLFW_DONT_CARE)
{
extraDiff += (desired->stencilBits - current->stencilBits) *
(desired->stencilBits - current->stencilBits);
}
if (desired->accumRedBits != GLFW_DONT_CARE)
{
extraDiff += (desired->accumRedBits - current->accumRedBits) *
(desired->accumRedBits - current->accumRedBits);
}
if (desired->accumGreenBits != GLFW_DONT_CARE)
{
extraDiff += (desired->accumGreenBits - current->accumGreenBits) *
(desired->accumGreenBits - current->accumGreenBits);
}
if (desired->accumBlueBits != GLFW_DONT_CARE)
{
extraDiff += (desired->accumBlueBits - current->accumBlueBits) *
(desired->accumBlueBits - current->accumBlueBits);
}
if (desired->accumAlphaBits != GLFW_DONT_CARE)
{
extraDiff += (desired->accumAlphaBits - current->accumAlphaBits) *
(desired->accumAlphaBits - current->accumAlphaBits);
}
if (desired->samples != GLFW_DONT_CARE)
{
extraDiff += (desired->samples - current->samples) *
(desired->samples - current->samples);
}
if (desired->sRGB && !current->sRGB)
extraDiff++;
}
// Figure out if the current one is better than the best one found so far
// Least number of missing buffers is the most important heuristic,
// then color buffer size match and lastly size match for other buffers
if (missing < leastMissing)
closest = current;
else if (missing == leastMissing)
{
if ((colorDiff < leastColorDiff) ||
(colorDiff == leastColorDiff && extraDiff < leastExtraDiff))
{
closest = current;
}
}
if (current == closest)
{
leastMissing = missing;
leastColorDiff = colorDiff;
leastExtraDiff = extraDiff;
}
}
return closest;
}
// Retrieves the attributes of the current context
//
GLFWbool _glfwRefreshContextAttribs(_GLFWwindow* window,
const _GLFWctxconfig* ctxconfig)
{
int i;
_GLFWwindow* previous;
const char* version;
const char* prefixes[] =
{
"OpenGL ES-CM ",
"OpenGL ES-CL ",
"OpenGL ES ",
NULL
};
window->context.source = ctxconfig->source;
window->context.client = GLFW_OPENGL_API;
previous = _glfwPlatformGetTls(&_glfw.contextSlot);
glfwMakeContextCurrent((GLFWwindow*) window);
window->context.GetIntegerv = (PFNGLGETINTEGERVPROC)
window->context.getProcAddress("glGetIntegerv");
window->context.GetString = (PFNGLGETSTRINGPROC)
window->context.getProcAddress("glGetString");
if (!window->context.GetIntegerv || !window->context.GetString)
{
_glfwInputError(GLFW_PLATFORM_ERROR, "Entry point retrieval is broken");
glfwMakeContextCurrent((GLFWwindow*) previous);
return GLFW_FALSE;
}
version = (const char*) window->context.GetString(GL_VERSION);
if (!version)
{
if (ctxconfig->client == GLFW_OPENGL_API)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"OpenGL version string retrieval is broken");
}
else
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"OpenGL ES version string retrieval is broken");
}
glfwMakeContextCurrent((GLFWwindow*) previous);
return GLFW_FALSE;
}
for (i = 0; prefixes[i]; i++)
{
const size_t length = strlen(prefixes[i]);
if (strncmp(version, prefixes[i], length) == 0)
{
version += length;
window->context.client = GLFW_OPENGL_ES_API;
break;
}
}
if (!sscanf(version, "%d.%d.%d",
&window->context.major,
&window->context.minor,
&window->context.revision))
{
if (window->context.client == GLFW_OPENGL_API)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"No version found in OpenGL version string");
}
else
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"No version found in OpenGL ES version string");
}
glfwMakeContextCurrent((GLFWwindow*) previous);
return GLFW_FALSE;
}
if (window->context.major < ctxconfig->major ||
(window->context.major == ctxconfig->major &&
window->context.minor < ctxconfig->minor))
{
// The desired OpenGL version is greater than the actual version
// This only happens if the machine lacks {GLX|WGL}_ARB_create_context
// /and/ the user has requested an OpenGL version greater than 1.0
// For API consistency, we emulate the behavior of the
// {GLX|WGL}_ARB_create_context extension and fail here
if (window->context.client == GLFW_OPENGL_API)
{
_glfwInputError(GLFW_VERSION_UNAVAILABLE,
"Requested OpenGL version %i.%i, got version %i.%i",
ctxconfig->major, ctxconfig->minor,
window->context.major, window->context.minor);
}
else
{
_glfwInputError(GLFW_VERSION_UNAVAILABLE,
"Requested OpenGL ES version %i.%i, got version %i.%i",
ctxconfig->major, ctxconfig->minor,
window->context.major, window->context.minor);
}
glfwMakeContextCurrent((GLFWwindow*) previous);
return GLFW_FALSE;
}
if (window->context.major >= 3)
{
// OpenGL 3.0+ uses a different function for extension string retrieval
// We cache it here instead of in glfwExtensionSupported mostly to alert
// users as early as possible that their build may be broken
window->context.GetStringi = (PFNGLGETSTRINGIPROC)
window->context.getProcAddress("glGetStringi");
if (!window->context.GetStringi)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"Entry point retrieval is broken");
glfwMakeContextCurrent((GLFWwindow*) previous);
return GLFW_FALSE;
}
}
if (window->context.client == GLFW_OPENGL_API)
{
// Read back context flags (OpenGL 3.0 and above)
if (window->context.major >= 3)
{
GLint flags;
window->context.GetIntegerv(GL_CONTEXT_FLAGS, &flags);
if (flags & GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT)
window->context.forward = GLFW_TRUE;
if (flags & GL_CONTEXT_FLAG_DEBUG_BIT)
window->context.debug = GLFW_TRUE;
else if (glfwExtensionSupported("GL_ARB_debug_output") &&
ctxconfig->debug)
{
// HACK: This is a workaround for older drivers (pre KHR_debug)
// not setting the debug bit in the context flags for
// debug contexts
window->context.debug = GLFW_TRUE;
}
if (flags & GL_CONTEXT_FLAG_NO_ERROR_BIT_KHR)
window->context.noerror = GLFW_TRUE;
}
// Read back OpenGL context profile (OpenGL 3.2 and above)
if (window->context.major >= 4 ||
(window->context.major == 3 && window->context.minor >= 2))
{
GLint mask;
window->context.GetIntegerv(GL_CONTEXT_PROFILE_MASK, &mask);
if (mask & GL_CONTEXT_COMPATIBILITY_PROFILE_BIT)
window->context.profile = GLFW_OPENGL_COMPAT_PROFILE;
else if (mask & GL_CONTEXT_CORE_PROFILE_BIT)
window->context.profile = GLFW_OPENGL_CORE_PROFILE;
else if (glfwExtensionSupported("GL_ARB_compatibility"))
{
// HACK: This is a workaround for the compatibility profile bit
// not being set in the context flags if an OpenGL 3.2+
// context was created without having requested a specific
// version
window->context.profile = GLFW_OPENGL_COMPAT_PROFILE;
}
}
// Read back robustness strategy
if (glfwExtensionSupported("GL_ARB_robustness"))
{
// NOTE: We avoid using the context flags for detection, as they are
// only present from 3.0 while the extension applies from 1.1
GLint strategy;
window->context.GetIntegerv(GL_RESET_NOTIFICATION_STRATEGY_ARB,
&strategy);
if (strategy == GL_LOSE_CONTEXT_ON_RESET_ARB)
window->context.robustness = GLFW_LOSE_CONTEXT_ON_RESET;
else if (strategy == GL_NO_RESET_NOTIFICATION_ARB)
window->context.robustness = GLFW_NO_RESET_NOTIFICATION;
}
}
else
{
// Read back robustness strategy
if (glfwExtensionSupported("GL_EXT_robustness"))
{
// NOTE: The values of these constants match those of the OpenGL ARB
// one, so we can reuse them here
GLint strategy;
window->context.GetIntegerv(GL_RESET_NOTIFICATION_STRATEGY_ARB,
&strategy);
if (strategy == GL_LOSE_CONTEXT_ON_RESET_ARB)
window->context.robustness = GLFW_LOSE_CONTEXT_ON_RESET;
else if (strategy == GL_NO_RESET_NOTIFICATION_ARB)
window->context.robustness = GLFW_NO_RESET_NOTIFICATION;
}
}
if (glfwExtensionSupported("GL_KHR_context_flush_control"))
{
GLint behavior;
window->context.GetIntegerv(GL_CONTEXT_RELEASE_BEHAVIOR, &behavior);
if (behavior == GL_NONE)
window->context.release = GLFW_RELEASE_BEHAVIOR_NONE;
else if (behavior == GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH)
window->context.release = GLFW_RELEASE_BEHAVIOR_FLUSH;
}
// Clearing the front buffer to black to avoid garbage pixels left over from
// previous uses of our bit of VRAM
{
PFNGLCLEARPROC glClear = (PFNGLCLEARPROC)
window->context.getProcAddress("glClear");
glClear(GL_COLOR_BUFFER_BIT);
if (window->doublebuffer)
window->context.swapBuffers(window);
}
glfwMakeContextCurrent((GLFWwindow*) previous);
return GLFW_TRUE;
}
// Searches an extension string for the specified extension
//
GLFWbool _glfwStringInExtensionString(const char* string, const char* extensions)
{
const char* start = extensions;
for (;;)
{
const char* where;
const char* terminator;
where = strstr(start, string);
if (!where)
return GLFW_FALSE;
terminator = where + strlen(string);
if (where == start || *(where - 1) == ' ')
{
if (*terminator == ' ' || *terminator == '\0')
break;
}
start = terminator;
}
return GLFW_TRUE;
}
//////////////////////////////////////////////////////////////////////////
////// GLFW public API //////
//////////////////////////////////////////////////////////////////////////
GLFWAPI void glfwMakeContextCurrent(GLFWwindow* handle)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
_GLFWwindow* previous;
_GLFW_REQUIRE_INIT();
previous = _glfwPlatformGetTls(&_glfw.contextSlot);
if (window && window->context.client == GLFW_NO_API)
{
_glfwInputError(GLFW_NO_WINDOW_CONTEXT,
"Cannot make current with a window that has no OpenGL or OpenGL ES context");
return;
}
if (previous)
{
if (!window || window->context.source != previous->context.source)
previous->context.makeCurrent(NULL);
}
if (window)
window->context.makeCurrent(window);
}
GLFWAPI GLFWwindow* glfwGetCurrentContext(void)
{
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
return _glfwPlatformGetTls(&_glfw.contextSlot);
}
GLFWAPI void glfwSwapBuffers(GLFWwindow* handle)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL);
_GLFW_REQUIRE_INIT();
if (window->context.client == GLFW_NO_API)
{
_glfwInputError(GLFW_NO_WINDOW_CONTEXT,
"Cannot swap buffers of a window that has no OpenGL or OpenGL ES context");
return;
}
window->context.swapBuffers(window);
}
GLFWAPI void glfwSwapInterval(int interval)
{
_GLFWwindow* window;
_GLFW_REQUIRE_INIT();
window = _glfwPlatformGetTls(&_glfw.contextSlot);
if (!window)
{
_glfwInputError(GLFW_NO_CURRENT_CONTEXT,
"Cannot set swap interval without a current OpenGL or OpenGL ES context");
return;
}
window->context.swapInterval(interval);
}
GLFWAPI int glfwExtensionSupported(const char* extension)
{
_GLFWwindow* window;
assert(extension != NULL);
_GLFW_REQUIRE_INIT_OR_RETURN(GLFW_FALSE);
window = _glfwPlatformGetTls(&_glfw.contextSlot);
if (!window)
{
_glfwInputError(GLFW_NO_CURRENT_CONTEXT,
"Cannot query extension without a current OpenGL or OpenGL ES context");
return GLFW_FALSE;
}
if (*extension == '\0')
{
_glfwInputError(GLFW_INVALID_VALUE, "Extension name cannot be an empty string");
return GLFW_FALSE;
}
if (window->context.major >= 3)
{
int i;
GLint count;
// Check if extension is in the modern OpenGL extensions string list
window->context.GetIntegerv(GL_NUM_EXTENSIONS, &count);
for (i = 0; i < count; i++)
{
const char* en = (const char*)
window->context.GetStringi(GL_EXTENSIONS, i);
if (!en)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"Extension string retrieval is broken");
return GLFW_FALSE;
}
if (strcmp(en, extension) == 0)
return GLFW_TRUE;
}
}
else
{
// Check if extension is in the old style OpenGL extensions string
const char* extensions = (const char*)
window->context.GetString(GL_EXTENSIONS);
if (!extensions)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"Extension string retrieval is broken");
return GLFW_FALSE;
}
if (_glfwStringInExtensionString(extension, extensions))
return GLFW_TRUE;
}
// Check if extension is in the platform-specific string
return window->context.extensionSupported(extension);
}
GLFWAPI GLFWglproc glfwGetProcAddress(const char* procname)
{
_GLFWwindow* window;
assert(procname != NULL);
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
window = _glfwPlatformGetTls(&_glfw.contextSlot);
if (!window)
{
_glfwInputError(GLFW_NO_CURRENT_CONTEXT,
"Cannot query entry point without a current OpenGL or OpenGL ES context");
return NULL;
}
return window->context.getProcAddress(procname);
}

View File

@@ -0,0 +1,884 @@
//========================================================================
// GLFW 3.4 EGL - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would
// be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such, and must not
// be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source
// distribution.
//
//========================================================================
// Please use C89 style variable declarations in this file because VS 2010
//========================================================================
#include "internal.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
// Return a description of the specified EGL error
//
static const char* getEGLErrorString(EGLint error)
{
switch (error)
{
case EGL_SUCCESS:
return "Success";
case EGL_NOT_INITIALIZED:
return "EGL is not or could not be initialized";
case EGL_BAD_ACCESS:
return "EGL cannot access a requested resource";
case EGL_BAD_ALLOC:
return "EGL failed to allocate resources for the requested operation";
case EGL_BAD_ATTRIBUTE:
return "An unrecognized attribute or attribute value was passed in the attribute list";
case EGL_BAD_CONTEXT:
return "An EGLContext argument does not name a valid EGL rendering context";
case EGL_BAD_CONFIG:
return "An EGLConfig argument does not name a valid EGL frame buffer configuration";
case EGL_BAD_CURRENT_SURFACE:
return "The current surface of the calling thread is a window, pixel buffer or pixmap that is no longer valid";
case EGL_BAD_DISPLAY:
return "An EGLDisplay argument does not name a valid EGL display connection";
case EGL_BAD_SURFACE:
return "An EGLSurface argument does not name a valid surface configured for GL rendering";
case EGL_BAD_MATCH:
return "Arguments are inconsistent";
case EGL_BAD_PARAMETER:
return "One or more argument values are invalid";
case EGL_BAD_NATIVE_PIXMAP:
return "A NativePixmapType argument does not refer to a valid native pixmap";
case EGL_BAD_NATIVE_WINDOW:
return "A NativeWindowType argument does not refer to a valid native window";
case EGL_CONTEXT_LOST:
return "The application must destroy all contexts and reinitialise";
default:
return "ERROR: UNKNOWN EGL ERROR";
}
}
// Returns the specified attribute of the specified EGLConfig
//
static int getEGLConfigAttrib(EGLConfig config, int attrib)
{
int value;
eglGetConfigAttrib(_glfw.egl.display, config, attrib, &value);
return value;
}
// Return the EGLConfig most closely matching the specified hints
//
static GLFWbool chooseEGLConfig(const _GLFWctxconfig* ctxconfig,
const _GLFWfbconfig* desired,
EGLConfig* result)
{
EGLConfig* nativeConfigs;
_GLFWfbconfig* usableConfigs;
const _GLFWfbconfig* closest;
int i, nativeCount, usableCount;
eglGetConfigs(_glfw.egl.display, NULL, 0, &nativeCount);
if (!nativeCount)
{
_glfwInputError(GLFW_API_UNAVAILABLE, "EGL: No EGLConfigs returned");
return GLFW_FALSE;
}
nativeConfigs = _glfw_calloc(nativeCount, sizeof(EGLConfig));
eglGetConfigs(_glfw.egl.display, nativeConfigs, nativeCount, &nativeCount);
usableConfigs = _glfw_calloc(nativeCount, sizeof(_GLFWfbconfig));
usableCount = 0;
for (i = 0; i < nativeCount; i++)
{
const EGLConfig n = nativeConfigs[i];
_GLFWfbconfig* u = usableConfigs + usableCount;
// Only consider RGB(A) EGLConfigs
if (getEGLConfigAttrib(n, EGL_COLOR_BUFFER_TYPE) != EGL_RGB_BUFFER)
continue;
// Only consider window EGLConfigs
if (!(getEGLConfigAttrib(n, EGL_SURFACE_TYPE) & EGL_WINDOW_BIT))
continue;
#if defined(_GLFW_X11)
if (_glfw.platform.platformID == GLFW_PLATFORM_X11)
{
XVisualInfo vi = {0};
// Only consider EGLConfigs with associated Visuals
vi.visualid = getEGLConfigAttrib(n, EGL_NATIVE_VISUAL_ID);
if (!vi.visualid)
continue;
if (desired->transparent)
{
int count;
XVisualInfo* vis =
XGetVisualInfo(_glfw.x11.display, VisualIDMask, &vi, &count);
if (vis)
{
u->transparent = _glfwIsVisualTransparentX11(vis[0].visual);
XFree(vis);
}
}
}
#endif // _GLFW_X11
if (ctxconfig->client == GLFW_OPENGL_ES_API)
{
if (ctxconfig->major == 1)
{
if (!(getEGLConfigAttrib(n, EGL_RENDERABLE_TYPE) & EGL_OPENGL_ES_BIT))
continue;
}
else
{
if (!(getEGLConfigAttrib(n, EGL_RENDERABLE_TYPE) & EGL_OPENGL_ES2_BIT))
continue;
}
}
else if (ctxconfig->client == GLFW_OPENGL_API)
{
if (!(getEGLConfigAttrib(n, EGL_RENDERABLE_TYPE) & EGL_OPENGL_BIT))
continue;
}
u->redBits = getEGLConfigAttrib(n, EGL_RED_SIZE);
u->greenBits = getEGLConfigAttrib(n, EGL_GREEN_SIZE);
u->blueBits = getEGLConfigAttrib(n, EGL_BLUE_SIZE);
u->alphaBits = getEGLConfigAttrib(n, EGL_ALPHA_SIZE);
u->depthBits = getEGLConfigAttrib(n, EGL_DEPTH_SIZE);
u->stencilBits = getEGLConfigAttrib(n, EGL_STENCIL_SIZE);
#if defined(_GLFW_WAYLAND)
if (_glfw.platform.platformID == GLFW_PLATFORM_WAYLAND)
{
// NOTE: The wl_surface opaque region is no guarantee that its buffer
// is presented as opaque, if it also has an alpha channel
// HACK: If EGL_EXT_present_opaque is unavailable, ignore any config
// with an alpha channel to ensure the buffer is opaque
if (!_glfw.egl.EXT_present_opaque)
{
if (!desired->transparent && u->alphaBits > 0)
continue;
}
}
#endif // _GLFW_WAYLAND
u->samples = getEGLConfigAttrib(n, EGL_SAMPLES);
u->doublebuffer = desired->doublebuffer;
u->handle = (uintptr_t) n;
usableCount++;
}
closest = _glfwChooseFBConfig(desired, usableConfigs, usableCount);
if (closest)
*result = (EGLConfig) closest->handle;
_glfw_free(nativeConfigs);
_glfw_free(usableConfigs);
return closest != NULL;
}
static void makeContextCurrentEGL(_GLFWwindow* window)
{
if (window)
{
if (!eglMakeCurrent(_glfw.egl.display,
window->context.egl.surface,
window->context.egl.surface,
window->context.egl.handle))
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"EGL: Failed to make context current: %s",
getEGLErrorString(eglGetError()));
return;
}
}
else
{
if (!eglMakeCurrent(_glfw.egl.display,
EGL_NO_SURFACE,
EGL_NO_SURFACE,
EGL_NO_CONTEXT))
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"EGL: Failed to clear current context: %s",
getEGLErrorString(eglGetError()));
return;
}
}
_glfwPlatformSetTls(&_glfw.contextSlot, window);
}
static void swapBuffersEGL(_GLFWwindow* window)
{
if (window != _glfwPlatformGetTls(&_glfw.contextSlot))
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"EGL: The context must be current on the calling thread when swapping buffers");
return;
}
#if defined(_GLFW_WAYLAND)
if (_glfw.platform.platformID == GLFW_PLATFORM_WAYLAND)
{
// NOTE: Swapping buffers on a hidden window on Wayland makes it visible
if (!window->wl.visible)
return;
}
#endif
eglSwapBuffers(_glfw.egl.display, window->context.egl.surface);
}
static void swapIntervalEGL(int interval)
{
eglSwapInterval(_glfw.egl.display, interval);
}
static int extensionSupportedEGL(const char* extension)
{
const char* extensions = eglQueryString(_glfw.egl.display, EGL_EXTENSIONS);
if (extensions)
{
if (_glfwStringInExtensionString(extension, extensions))
return GLFW_TRUE;
}
return GLFW_FALSE;
}
static GLFWglproc getProcAddressEGL(const char* procname)
{
_GLFWwindow* window = _glfwPlatformGetTls(&_glfw.contextSlot);
if (window->context.egl.client)
{
GLFWglproc proc = (GLFWglproc)
_glfwPlatformGetModuleSymbol(window->context.egl.client, procname);
if (proc)
return proc;
}
return eglGetProcAddress(procname);
}
static void destroyContextEGL(_GLFWwindow* window)
{
// NOTE: Do not unload libGL.so.1 while the X11 display is still open,
// as it will make XCloseDisplay segfault
if (_glfw.platform.platformID != GLFW_PLATFORM_X11 ||
window->context.client != GLFW_OPENGL_API)
{
if (window->context.egl.client)
{
_glfwPlatformFreeModule(window->context.egl.client);
window->context.egl.client = NULL;
}
}
if (window->context.egl.surface)
{
eglDestroySurface(_glfw.egl.display, window->context.egl.surface);
window->context.egl.surface = EGL_NO_SURFACE;
}
if (window->context.egl.handle)
{
eglDestroyContext(_glfw.egl.display, window->context.egl.handle);
window->context.egl.handle = EGL_NO_CONTEXT;
}
}
//////////////////////////////////////////////////////////////////////////
////// GLFW internal API //////
//////////////////////////////////////////////////////////////////////////
// Initialize EGL
//
GLFWbool _glfwInitEGL(void)
{
int i;
EGLint* attribs = NULL;
const char* extensions;
const char* sonames[] =
{
#if defined(_GLFW_EGL_LIBRARY)
_GLFW_EGL_LIBRARY,
#elif defined(_GLFW_WIN32)
"libEGL.dll",
"EGL.dll",
#elif defined(_GLFW_COCOA)
"libEGL.dylib",
#elif defined(__CYGWIN__)
"libEGL-1.so",
#elif defined(__OpenBSD__) || defined(__NetBSD__)
"libEGL.so",
#else
"libEGL.so.1",
#endif
NULL
};
if (_glfw.egl.handle)
return GLFW_TRUE;
for (i = 0; sonames[i]; i++)
{
_glfw.egl.handle = _glfwPlatformLoadModule(sonames[i]);
if (_glfw.egl.handle)
break;
}
if (!_glfw.egl.handle)
{
_glfwInputError(GLFW_API_UNAVAILABLE, "EGL: Library not found");
return GLFW_FALSE;
}
_glfw.egl.prefix = (strncmp(sonames[i], "lib", 3) == 0);
_glfw.egl.GetConfigAttrib = (PFN_eglGetConfigAttrib)
_glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglGetConfigAttrib");
_glfw.egl.GetConfigs = (PFN_eglGetConfigs)
_glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglGetConfigs");
_glfw.egl.GetDisplay = (PFN_eglGetDisplay)
_glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglGetDisplay");
_glfw.egl.GetError = (PFN_eglGetError)
_glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglGetError");
_glfw.egl.Initialize = (PFN_eglInitialize)
_glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglInitialize");
_glfw.egl.Terminate = (PFN_eglTerminate)
_glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglTerminate");
_glfw.egl.BindAPI = (PFN_eglBindAPI)
_glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglBindAPI");
_glfw.egl.CreateContext = (PFN_eglCreateContext)
_glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglCreateContext");
_glfw.egl.DestroySurface = (PFN_eglDestroySurface)
_glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglDestroySurface");
_glfw.egl.DestroyContext = (PFN_eglDestroyContext)
_glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglDestroyContext");
_glfw.egl.CreateWindowSurface = (PFN_eglCreateWindowSurface)
_glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglCreateWindowSurface");
_glfw.egl.MakeCurrent = (PFN_eglMakeCurrent)
_glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglMakeCurrent");
_glfw.egl.SwapBuffers = (PFN_eglSwapBuffers)
_glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglSwapBuffers");
_glfw.egl.SwapInterval = (PFN_eglSwapInterval)
_glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglSwapInterval");
_glfw.egl.QueryString = (PFN_eglQueryString)
_glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglQueryString");
_glfw.egl.GetProcAddress = (PFN_eglGetProcAddress)
_glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglGetProcAddress");
if (!_glfw.egl.GetConfigAttrib ||
!_glfw.egl.GetConfigs ||
!_glfw.egl.GetDisplay ||
!_glfw.egl.GetError ||
!_glfw.egl.Initialize ||
!_glfw.egl.Terminate ||
!_glfw.egl.BindAPI ||
!_glfw.egl.CreateContext ||
!_glfw.egl.DestroySurface ||
!_glfw.egl.DestroyContext ||
!_glfw.egl.CreateWindowSurface ||
!_glfw.egl.MakeCurrent ||
!_glfw.egl.SwapBuffers ||
!_glfw.egl.SwapInterval ||
!_glfw.egl.QueryString ||
!_glfw.egl.GetProcAddress)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"EGL: Failed to load required entry points");
_glfwTerminateEGL();
return GLFW_FALSE;
}
extensions = eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS);
if (extensions && eglGetError() == EGL_SUCCESS)
_glfw.egl.EXT_client_extensions = GLFW_TRUE;
if (_glfw.egl.EXT_client_extensions)
{
_glfw.egl.EXT_platform_base =
_glfwStringInExtensionString("EGL_EXT_platform_base", extensions);
_glfw.egl.EXT_platform_x11 =
_glfwStringInExtensionString("EGL_EXT_platform_x11", extensions);
_glfw.egl.EXT_platform_wayland =
_glfwStringInExtensionString("EGL_EXT_platform_wayland", extensions);
_glfw.egl.ANGLE_platform_angle =
_glfwStringInExtensionString("EGL_ANGLE_platform_angle", extensions);
_glfw.egl.ANGLE_platform_angle_opengl =
_glfwStringInExtensionString("EGL_ANGLE_platform_angle_opengl", extensions);
_glfw.egl.ANGLE_platform_angle_d3d =
_glfwStringInExtensionString("EGL_ANGLE_platform_angle_d3d", extensions);
_glfw.egl.ANGLE_platform_angle_vulkan =
_glfwStringInExtensionString("EGL_ANGLE_platform_angle_vulkan", extensions);
_glfw.egl.ANGLE_platform_angle_metal =
_glfwStringInExtensionString("EGL_ANGLE_platform_angle_metal", extensions);
}
if (_glfw.egl.EXT_platform_base)
{
_glfw.egl.GetPlatformDisplayEXT = (PFNEGLGETPLATFORMDISPLAYEXTPROC)
eglGetProcAddress("eglGetPlatformDisplayEXT");
_glfw.egl.CreatePlatformWindowSurfaceEXT = (PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC)
eglGetProcAddress("eglCreatePlatformWindowSurfaceEXT");
}
_glfw.egl.platform = _glfw.platform.getEGLPlatform(&attribs);
if (_glfw.egl.platform)
{
_glfw.egl.display =
eglGetPlatformDisplayEXT(_glfw.egl.platform,
_glfw.platform.getEGLNativeDisplay(),
attribs);
}
else
_glfw.egl.display = eglGetDisplay(_glfw.platform.getEGLNativeDisplay());
_glfw_free(attribs);
if (_glfw.egl.display == EGL_NO_DISPLAY)
{
_glfwInputError(GLFW_API_UNAVAILABLE,
"EGL: Failed to get EGL display: %s",
getEGLErrorString(eglGetError()));
_glfwTerminateEGL();
return GLFW_FALSE;
}
if (!eglInitialize(_glfw.egl.display, &_glfw.egl.major, &_glfw.egl.minor))
{
_glfwInputError(GLFW_API_UNAVAILABLE,
"EGL: Failed to initialize EGL: %s",
getEGLErrorString(eglGetError()));
_glfwTerminateEGL();
return GLFW_FALSE;
}
_glfw.egl.KHR_create_context =
extensionSupportedEGL("EGL_KHR_create_context");
_glfw.egl.KHR_create_context_no_error =
extensionSupportedEGL("EGL_KHR_create_context_no_error");
_glfw.egl.KHR_gl_colorspace =
extensionSupportedEGL("EGL_KHR_gl_colorspace");
_glfw.egl.KHR_get_all_proc_addresses =
extensionSupportedEGL("EGL_KHR_get_all_proc_addresses");
_glfw.egl.KHR_context_flush_control =
extensionSupportedEGL("EGL_KHR_context_flush_control");
_glfw.egl.EXT_present_opaque =
extensionSupportedEGL("EGL_EXT_present_opaque");
return GLFW_TRUE;
}
// Terminate EGL
//
void _glfwTerminateEGL(void)
{
if (_glfw.egl.display)
{
eglTerminate(_glfw.egl.display);
_glfw.egl.display = EGL_NO_DISPLAY;
}
if (_glfw.egl.handle)
{
_glfwPlatformFreeModule(_glfw.egl.handle);
_glfw.egl.handle = NULL;
}
}
#define SET_ATTRIB(a, v) \
{ \
assert(((size_t) index + 1) < sizeof(attribs) / sizeof(attribs[0])); \
attribs[index++] = a; \
attribs[index++] = v; \
}
// Create the OpenGL or OpenGL ES context
//
GLFWbool _glfwCreateContextEGL(_GLFWwindow* window,
const _GLFWctxconfig* ctxconfig,
const _GLFWfbconfig* fbconfig)
{
EGLint attribs[40];
EGLConfig config;
EGLContext share = NULL;
EGLNativeWindowType native;
int index = 0;
if (!_glfw.egl.display)
{
_glfwInputError(GLFW_API_UNAVAILABLE, "EGL: API not available");
return GLFW_FALSE;
}
if (ctxconfig->share)
share = ctxconfig->share->context.egl.handle;
if (!chooseEGLConfig(ctxconfig, fbconfig, &config))
{
_glfwInputError(GLFW_FORMAT_UNAVAILABLE,
"EGL: Failed to find a suitable EGLConfig");
return GLFW_FALSE;
}
if (ctxconfig->client == GLFW_OPENGL_ES_API)
{
if (!eglBindAPI(EGL_OPENGL_ES_API))
{
_glfwInputError(GLFW_API_UNAVAILABLE,
"EGL: Failed to bind OpenGL ES: %s",
getEGLErrorString(eglGetError()));
return GLFW_FALSE;
}
}
else
{
if (!eglBindAPI(EGL_OPENGL_API))
{
_glfwInputError(GLFW_API_UNAVAILABLE,
"EGL: Failed to bind OpenGL: %s",
getEGLErrorString(eglGetError()));
return GLFW_FALSE;
}
}
if (_glfw.egl.KHR_create_context)
{
int mask = 0, flags = 0;
if (ctxconfig->client == GLFW_OPENGL_API)
{
if (ctxconfig->forward)
flags |= EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR;
if (ctxconfig->profile == GLFW_OPENGL_CORE_PROFILE)
mask |= EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR;
else if (ctxconfig->profile == GLFW_OPENGL_COMPAT_PROFILE)
mask |= EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR;
}
if (ctxconfig->debug)
flags |= EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR;
if (ctxconfig->robustness)
{
if (ctxconfig->robustness == GLFW_NO_RESET_NOTIFICATION)
{
SET_ATTRIB(EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR,
EGL_NO_RESET_NOTIFICATION_KHR);
}
else if (ctxconfig->robustness == GLFW_LOSE_CONTEXT_ON_RESET)
{
SET_ATTRIB(EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR,
EGL_LOSE_CONTEXT_ON_RESET_KHR);
}
flags |= EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR;
}
if (ctxconfig->noerror)
{
if (_glfw.egl.KHR_create_context_no_error)
SET_ATTRIB(EGL_CONTEXT_OPENGL_NO_ERROR_KHR, GLFW_TRUE);
}
if (ctxconfig->major != 1 || ctxconfig->minor != 0)
{
SET_ATTRIB(EGL_CONTEXT_MAJOR_VERSION_KHR, ctxconfig->major);
SET_ATTRIB(EGL_CONTEXT_MINOR_VERSION_KHR, ctxconfig->minor);
}
if (mask)
SET_ATTRIB(EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR, mask);
if (flags)
SET_ATTRIB(EGL_CONTEXT_FLAGS_KHR, flags);
}
else
{
if (ctxconfig->client == GLFW_OPENGL_ES_API)
SET_ATTRIB(EGL_CONTEXT_CLIENT_VERSION, ctxconfig->major);
}
if (_glfw.egl.KHR_context_flush_control)
{
if (ctxconfig->release == GLFW_RELEASE_BEHAVIOR_NONE)
{
SET_ATTRIB(EGL_CONTEXT_RELEASE_BEHAVIOR_KHR,
EGL_CONTEXT_RELEASE_BEHAVIOR_NONE_KHR);
}
else if (ctxconfig->release == GLFW_RELEASE_BEHAVIOR_FLUSH)
{
SET_ATTRIB(EGL_CONTEXT_RELEASE_BEHAVIOR_KHR,
EGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_KHR);
}
}
SET_ATTRIB(EGL_NONE, EGL_NONE);
window->context.egl.handle = eglCreateContext(_glfw.egl.display,
config, share, attribs);
if (window->context.egl.handle == EGL_NO_CONTEXT)
{
_glfwInputError(GLFW_VERSION_UNAVAILABLE,
"EGL: Failed to create context: %s",
getEGLErrorString(eglGetError()));
return GLFW_FALSE;
}
// Set up attributes for surface creation
index = 0;
if (fbconfig->sRGB)
{
if (_glfw.egl.KHR_gl_colorspace)
SET_ATTRIB(EGL_GL_COLORSPACE_KHR, EGL_GL_COLORSPACE_SRGB_KHR);
}
if (!fbconfig->doublebuffer)
SET_ATTRIB(EGL_RENDER_BUFFER, EGL_SINGLE_BUFFER);
if (_glfw.egl.EXT_present_opaque)
SET_ATTRIB(EGL_PRESENT_OPAQUE_EXT, !fbconfig->transparent);
SET_ATTRIB(EGL_NONE, EGL_NONE);
native = _glfw.platform.getEGLNativeWindow(window);
// HACK: ANGLE does not implement eglCreatePlatformWindowSurfaceEXT
// despite reporting EGL_EXT_platform_base
if (_glfw.egl.platform && _glfw.egl.platform != EGL_PLATFORM_ANGLE_ANGLE)
{
window->context.egl.surface =
eglCreatePlatformWindowSurfaceEXT(_glfw.egl.display, config, native, attribs);
}
else
{
window->context.egl.surface =
eglCreateWindowSurface(_glfw.egl.display, config, native, attribs);
}
if (window->context.egl.surface == EGL_NO_SURFACE)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"EGL: Failed to create window surface: %s",
getEGLErrorString(eglGetError()));
return GLFW_FALSE;
}
window->context.egl.config = config;
// Load the appropriate client library
if (!_glfw.egl.KHR_get_all_proc_addresses)
{
int i;
const char** sonames;
const char* es1sonames[] =
{
#if defined(_GLFW_GLESV1_LIBRARY)
_GLFW_GLESV1_LIBRARY,
#elif defined(_GLFW_WIN32)
"GLESv1_CM.dll",
"libGLES_CM.dll",
#elif defined(_GLFW_COCOA)
"libGLESv1_CM.dylib",
#elif defined(__OpenBSD__) || defined(__NetBSD__)
"libGLESv1_CM.so",
#else
"libGLESv1_CM.so.1",
"libGLES_CM.so.1",
#endif
NULL
};
const char* es2sonames[] =
{
#if defined(_GLFW_GLESV2_LIBRARY)
_GLFW_GLESV2_LIBRARY,
#elif defined(_GLFW_WIN32)
"GLESv2.dll",
"libGLESv2.dll",
#elif defined(_GLFW_COCOA)
"libGLESv2.dylib",
#elif defined(__CYGWIN__)
"libGLESv2-2.so",
#elif defined(__OpenBSD__) || defined(__NetBSD__)
"libGLESv2.so",
#else
"libGLESv2.so.2",
#endif
NULL
};
const char* glsonames[] =
{
#if defined(_GLFW_OPENGL_LIBRARY)
_GLFW_OPENGL_LIBRARY,
#elif defined(_GLFW_WIN32)
#elif defined(_GLFW_COCOA)
#elif defined(__OpenBSD__) || defined(__NetBSD__)
"libGL.so",
#else
"libOpenGL.so.0",
"libGL.so.1",
#endif
NULL
};
if (ctxconfig->client == GLFW_OPENGL_ES_API)
{
if (ctxconfig->major == 1)
sonames = es1sonames;
else
sonames = es2sonames;
}
else
sonames = glsonames;
for (i = 0; sonames[i]; i++)
{
// HACK: Match presence of lib prefix to increase chance of finding
// a matching pair in the jungle that is Win32 EGL/GLES
if (_glfw.egl.prefix != (strncmp(sonames[i], "lib", 3) == 0))
continue;
window->context.egl.client = _glfwPlatformLoadModule(sonames[i]);
if (window->context.egl.client)
break;
}
if (!window->context.egl.client)
{
_glfwInputError(GLFW_API_UNAVAILABLE,
"EGL: Failed to load client library");
return GLFW_FALSE;
}
}
window->context.makeCurrent = makeContextCurrentEGL;
window->context.swapBuffers = swapBuffersEGL;
window->context.swapInterval = swapIntervalEGL;
window->context.extensionSupported = extensionSupportedEGL;
window->context.getProcAddress = getProcAddressEGL;
window->context.destroy = destroyContextEGL;
return GLFW_TRUE;
}
#undef SET_ATTRIB
// Returns the Visual and depth of the chosen EGLConfig
//
#if defined(_GLFW_X11)
GLFWbool _glfwChooseVisualEGL(const _GLFWwndconfig* wndconfig,
const _GLFWctxconfig* ctxconfig,
const _GLFWfbconfig* fbconfig,
Visual** visual, int* depth)
{
XVisualInfo* result;
XVisualInfo desired;
EGLConfig native;
EGLint visualID = 0, count = 0;
const long vimask = VisualScreenMask | VisualIDMask;
if (!chooseEGLConfig(ctxconfig, fbconfig, &native))
{
_glfwInputError(GLFW_FORMAT_UNAVAILABLE,
"EGL: Failed to find a suitable EGLConfig");
return GLFW_FALSE;
}
eglGetConfigAttrib(_glfw.egl.display, native,
EGL_NATIVE_VISUAL_ID, &visualID);
desired.screen = _glfw.x11.screen;
desired.visualid = visualID;
result = XGetVisualInfo(_glfw.x11.display, vimask, &desired, &count);
if (!result)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"EGL: Failed to retrieve Visual for EGLConfig");
return GLFW_FALSE;
}
*visual = result->visual;
*depth = result->depth;
XFree(result);
return GLFW_TRUE;
}
#endif // _GLFW_X11
//////////////////////////////////////////////////////////////////////////
////// GLFW native API //////
//////////////////////////////////////////////////////////////////////////
GLFWAPI EGLDisplay glfwGetEGLDisplay(void)
{
_GLFW_REQUIRE_INIT_OR_RETURN(EGL_NO_DISPLAY);
return _glfw.egl.display;
}
GLFWAPI EGLContext glfwGetEGLContext(GLFWwindow* handle)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
_GLFW_REQUIRE_INIT_OR_RETURN(EGL_NO_CONTEXT);
if (window->context.source != GLFW_EGL_CONTEXT_API)
{
_glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL);
return EGL_NO_CONTEXT;
}
return window->context.egl.handle;
}
GLFWAPI EGLSurface glfwGetEGLSurface(GLFWwindow* handle)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
_GLFW_REQUIRE_INIT_OR_RETURN(EGL_NO_SURFACE);
if (window->context.source != GLFW_EGL_CONTEXT_API)
{
_glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL);
return EGL_NO_SURFACE;
}
return window->context.egl.surface;
}

View File

@@ -0,0 +1,30 @@
#include <winver.h>
VS_VERSION_INFO VERSIONINFO
FILEVERSION @GLFW_VERSION_MAJOR@,@GLFW_VERSION_MINOR@,@GLFW_VERSION_PATCH@,0
PRODUCTVERSION @GLFW_VERSION_MAJOR@,@GLFW_VERSION_MINOR@,@GLFW_VERSION_PATCH@,0
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
FILEFLAGS 0
FILEOS VOS_NT_WINDOWS32
FILETYPE VFT_DLL
FILESUBTYPE 0
{
BLOCK "StringFileInfo"
{
BLOCK "040904B0"
{
VALUE "CompanyName", "GLFW"
VALUE "FileDescription", "GLFW @GLFW_VERSION@ DLL"
VALUE "FileVersion", "@GLFW_VERSION@"
VALUE "OriginalFilename", "glfw3.dll"
VALUE "ProductName", "GLFW"
VALUE "ProductVersion", "@GLFW_VERSION@"
}
}
BLOCK "VarFileInfo"
{
VALUE "Translation", 0x409, 1200
}
}

View File

@@ -0,0 +1,716 @@
//========================================================================
// GLFW 3.4 GLX - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would
// be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such, and must not
// be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source
// distribution.
//
//========================================================================
// It is fine to use C99 in this file because it will not be built with VS
//========================================================================
#include "internal.h"
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#ifndef GLXBadProfileARB
#define GLXBadProfileARB 13
#endif
// Returns the specified attribute of the specified GLXFBConfig
//
static int getGLXFBConfigAttrib(GLXFBConfig fbconfig, int attrib)
{
int value;
glXGetFBConfigAttrib(_glfw.x11.display, fbconfig, attrib, &value);
return value;
}
// Return the GLXFBConfig most closely matching the specified hints
//
static GLFWbool chooseGLXFBConfig(const _GLFWfbconfig* desired,
GLXFBConfig* result)
{
GLXFBConfig* nativeConfigs;
_GLFWfbconfig* usableConfigs;
const _GLFWfbconfig* closest;
int nativeCount, usableCount;
const char* vendor;
GLFWbool trustWindowBit = GLFW_TRUE;
// HACK: This is a (hopefully temporary) workaround for Chromium
// (VirtualBox GL) not setting the window bit on any GLXFBConfigs
vendor = glXGetClientString(_glfw.x11.display, GLX_VENDOR);
if (vendor && strcmp(vendor, "Chromium") == 0)
trustWindowBit = GLFW_FALSE;
nativeConfigs =
glXGetFBConfigs(_glfw.x11.display, _glfw.x11.screen, &nativeCount);
if (!nativeConfigs || !nativeCount)
{
_glfwInputError(GLFW_API_UNAVAILABLE, "GLX: No GLXFBConfigs returned");
return GLFW_FALSE;
}
usableConfigs = _glfw_calloc(nativeCount, sizeof(_GLFWfbconfig));
usableCount = 0;
for (int i = 0; i < nativeCount; i++)
{
const GLXFBConfig n = nativeConfigs[i];
_GLFWfbconfig* u = usableConfigs + usableCount;
// Only consider RGBA GLXFBConfigs
if (!(getGLXFBConfigAttrib(n, GLX_RENDER_TYPE) & GLX_RGBA_BIT))
continue;
// Only consider window GLXFBConfigs
if (!(getGLXFBConfigAttrib(n, GLX_DRAWABLE_TYPE) & GLX_WINDOW_BIT))
{
if (trustWindowBit)
continue;
}
if (getGLXFBConfigAttrib(n, GLX_DOUBLEBUFFER) != desired->doublebuffer)
continue;
if (desired->transparent)
{
XVisualInfo* vi = glXGetVisualFromFBConfig(_glfw.x11.display, n);
if (vi)
{
u->transparent = _glfwIsVisualTransparentX11(vi->visual);
XFree(vi);
}
}
u->redBits = getGLXFBConfigAttrib(n, GLX_RED_SIZE);
u->greenBits = getGLXFBConfigAttrib(n, GLX_GREEN_SIZE);
u->blueBits = getGLXFBConfigAttrib(n, GLX_BLUE_SIZE);
u->alphaBits = getGLXFBConfigAttrib(n, GLX_ALPHA_SIZE);
u->depthBits = getGLXFBConfigAttrib(n, GLX_DEPTH_SIZE);
u->stencilBits = getGLXFBConfigAttrib(n, GLX_STENCIL_SIZE);
u->accumRedBits = getGLXFBConfigAttrib(n, GLX_ACCUM_RED_SIZE);
u->accumGreenBits = getGLXFBConfigAttrib(n, GLX_ACCUM_GREEN_SIZE);
u->accumBlueBits = getGLXFBConfigAttrib(n, GLX_ACCUM_BLUE_SIZE);
u->accumAlphaBits = getGLXFBConfigAttrib(n, GLX_ACCUM_ALPHA_SIZE);
u->auxBuffers = getGLXFBConfigAttrib(n, GLX_AUX_BUFFERS);
if (getGLXFBConfigAttrib(n, GLX_STEREO))
u->stereo = GLFW_TRUE;
if (_glfw.glx.ARB_multisample)
u->samples = getGLXFBConfigAttrib(n, GLX_SAMPLES);
if (_glfw.glx.ARB_framebuffer_sRGB || _glfw.glx.EXT_framebuffer_sRGB)
u->sRGB = getGLXFBConfigAttrib(n, GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB);
u->handle = (uintptr_t) n;
usableCount++;
}
closest = _glfwChooseFBConfig(desired, usableConfigs, usableCount);
if (closest)
*result = (GLXFBConfig) closest->handle;
XFree(nativeConfigs);
_glfw_free(usableConfigs);
return closest != NULL;
}
// Create the OpenGL context using legacy API
//
static GLXContext createLegacyContextGLX(_GLFWwindow* window,
GLXFBConfig fbconfig,
GLXContext share)
{
return glXCreateNewContext(_glfw.x11.display,
fbconfig,
GLX_RGBA_TYPE,
share,
True);
}
static void makeContextCurrentGLX(_GLFWwindow* window)
{
if (window)
{
if (!glXMakeCurrent(_glfw.x11.display,
window->context.glx.window,
window->context.glx.handle))
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"GLX: Failed to make context current");
return;
}
}
else
{
if (!glXMakeCurrent(_glfw.x11.display, None, NULL))
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"GLX: Failed to clear current context");
return;
}
}
_glfwPlatformSetTls(&_glfw.contextSlot, window);
}
static void swapBuffersGLX(_GLFWwindow* window)
{
glXSwapBuffers(_glfw.x11.display, window->context.glx.window);
}
static void swapIntervalGLX(int interval)
{
_GLFWwindow* window = _glfwPlatformGetTls(&_glfw.contextSlot);
if (_glfw.glx.EXT_swap_control)
{
_glfw.glx.SwapIntervalEXT(_glfw.x11.display,
window->context.glx.window,
interval);
}
else if (_glfw.glx.MESA_swap_control)
_glfw.glx.SwapIntervalMESA(interval);
else if (_glfw.glx.SGI_swap_control)
{
if (interval > 0)
_glfw.glx.SwapIntervalSGI(interval);
}
}
static int extensionSupportedGLX(const char* extension)
{
const char* extensions =
glXQueryExtensionsString(_glfw.x11.display, _glfw.x11.screen);
if (extensions)
{
if (_glfwStringInExtensionString(extension, extensions))
return GLFW_TRUE;
}
return GLFW_FALSE;
}
static GLFWglproc getProcAddressGLX(const char* procname)
{
if (_glfw.glx.GetProcAddress)
return _glfw.glx.GetProcAddress((const GLubyte*) procname);
else if (_glfw.glx.GetProcAddressARB)
return _glfw.glx.GetProcAddressARB((const GLubyte*) procname);
else
{
// NOTE: glvnd provides GLX 1.4, so this can only happen with libGL
return _glfwPlatformGetModuleSymbol(_glfw.glx.handle, procname);
}
}
static void destroyContextGLX(_GLFWwindow* window)
{
if (window->context.glx.window)
{
glXDestroyWindow(_glfw.x11.display, window->context.glx.window);
window->context.glx.window = None;
}
if (window->context.glx.handle)
{
glXDestroyContext(_glfw.x11.display, window->context.glx.handle);
window->context.glx.handle = NULL;
}
}
//////////////////////////////////////////////////////////////////////////
////// GLFW internal API //////
//////////////////////////////////////////////////////////////////////////
// Initialize GLX
//
GLFWbool _glfwInitGLX(void)
{
const char* sonames[] =
{
#if defined(_GLFW_GLX_LIBRARY)
_GLFW_GLX_LIBRARY,
#elif defined(__CYGWIN__)
"libGL-1.so",
#elif defined(__OpenBSD__) || defined(__NetBSD__)
"libGL.so",
#else
"libGLX.so.0",
"libGL.so.1",
"libGL.so",
#endif
NULL
};
if (_glfw.glx.handle)
return GLFW_TRUE;
for (int i = 0; sonames[i]; i++)
{
_glfw.glx.handle = _glfwPlatformLoadModule(sonames[i]);
if (_glfw.glx.handle)
break;
}
if (!_glfw.glx.handle)
{
_glfwInputError(GLFW_API_UNAVAILABLE, "GLX: Failed to load GLX");
return GLFW_FALSE;
}
_glfw.glx.GetFBConfigs = (PFNGLXGETFBCONFIGSPROC)
_glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXGetFBConfigs");
_glfw.glx.GetFBConfigAttrib = (PFNGLXGETFBCONFIGATTRIBPROC)
_glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXGetFBConfigAttrib");
_glfw.glx.GetClientString = (PFNGLXGETCLIENTSTRINGPROC)
_glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXGetClientString");
_glfw.glx.QueryExtension = (PFNGLXQUERYEXTENSIONPROC)
_glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXQueryExtension");
_glfw.glx.QueryVersion = (PFNGLXQUERYVERSIONPROC)
_glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXQueryVersion");
_glfw.glx.DestroyContext = (PFNGLXDESTROYCONTEXTPROC)
_glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXDestroyContext");
_glfw.glx.MakeCurrent = (PFNGLXMAKECURRENTPROC)
_glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXMakeCurrent");
_glfw.glx.SwapBuffers = (PFNGLXSWAPBUFFERSPROC)
_glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXSwapBuffers");
_glfw.glx.QueryExtensionsString = (PFNGLXQUERYEXTENSIONSSTRINGPROC)
_glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXQueryExtensionsString");
_glfw.glx.CreateNewContext = (PFNGLXCREATENEWCONTEXTPROC)
_glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXCreateNewContext");
_glfw.glx.CreateWindow = (PFNGLXCREATEWINDOWPROC)
_glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXCreateWindow");
_glfw.glx.DestroyWindow = (PFNGLXDESTROYWINDOWPROC)
_glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXDestroyWindow");
_glfw.glx.GetVisualFromFBConfig = (PFNGLXGETVISUALFROMFBCONFIGPROC)
_glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXGetVisualFromFBConfig");
if (!_glfw.glx.GetFBConfigs ||
!_glfw.glx.GetFBConfigAttrib ||
!_glfw.glx.GetClientString ||
!_glfw.glx.QueryExtension ||
!_glfw.glx.QueryVersion ||
!_glfw.glx.DestroyContext ||
!_glfw.glx.MakeCurrent ||
!_glfw.glx.SwapBuffers ||
!_glfw.glx.QueryExtensionsString ||
!_glfw.glx.CreateNewContext ||
!_glfw.glx.CreateWindow ||
!_glfw.glx.DestroyWindow ||
!_glfw.glx.GetVisualFromFBConfig)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"GLX: Failed to load required entry points");
return GLFW_FALSE;
}
// NOTE: Unlike GLX 1.3 entry points these are not required to be present
_glfw.glx.GetProcAddress = (PFNGLXGETPROCADDRESSPROC)
_glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXGetProcAddress");
_glfw.glx.GetProcAddressARB = (PFNGLXGETPROCADDRESSPROC)
_glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXGetProcAddressARB");
if (!glXQueryExtension(_glfw.x11.display,
&_glfw.glx.errorBase,
&_glfw.glx.eventBase))
{
_glfwInputError(GLFW_API_UNAVAILABLE, "GLX: GLX extension not found");
return GLFW_FALSE;
}
if (!glXQueryVersion(_glfw.x11.display, &_glfw.glx.major, &_glfw.glx.minor))
{
_glfwInputError(GLFW_API_UNAVAILABLE,
"GLX: Failed to query GLX version");
return GLFW_FALSE;
}
if (_glfw.glx.major == 1 && _glfw.glx.minor < 3)
{
_glfwInputError(GLFW_API_UNAVAILABLE,
"GLX: GLX version 1.3 is required");
return GLFW_FALSE;
}
if (extensionSupportedGLX("GLX_EXT_swap_control"))
{
_glfw.glx.SwapIntervalEXT = (PFNGLXSWAPINTERVALEXTPROC)
getProcAddressGLX("glXSwapIntervalEXT");
if (_glfw.glx.SwapIntervalEXT)
_glfw.glx.EXT_swap_control = GLFW_TRUE;
}
if (extensionSupportedGLX("GLX_SGI_swap_control"))
{
_glfw.glx.SwapIntervalSGI = (PFNGLXSWAPINTERVALSGIPROC)
getProcAddressGLX("glXSwapIntervalSGI");
if (_glfw.glx.SwapIntervalSGI)
_glfw.glx.SGI_swap_control = GLFW_TRUE;
}
if (extensionSupportedGLX("GLX_MESA_swap_control"))
{
_glfw.glx.SwapIntervalMESA = (PFNGLXSWAPINTERVALMESAPROC)
getProcAddressGLX("glXSwapIntervalMESA");
if (_glfw.glx.SwapIntervalMESA)
_glfw.glx.MESA_swap_control = GLFW_TRUE;
}
if (extensionSupportedGLX("GLX_ARB_multisample"))
_glfw.glx.ARB_multisample = GLFW_TRUE;
if (extensionSupportedGLX("GLX_ARB_framebuffer_sRGB"))
_glfw.glx.ARB_framebuffer_sRGB = GLFW_TRUE;
if (extensionSupportedGLX("GLX_EXT_framebuffer_sRGB"))
_glfw.glx.EXT_framebuffer_sRGB = GLFW_TRUE;
if (extensionSupportedGLX("GLX_ARB_create_context"))
{
_glfw.glx.CreateContextAttribsARB = (PFNGLXCREATECONTEXTATTRIBSARBPROC)
getProcAddressGLX("glXCreateContextAttribsARB");
if (_glfw.glx.CreateContextAttribsARB)
_glfw.glx.ARB_create_context = GLFW_TRUE;
}
if (extensionSupportedGLX("GLX_ARB_create_context_robustness"))
_glfw.glx.ARB_create_context_robustness = GLFW_TRUE;
if (extensionSupportedGLX("GLX_ARB_create_context_profile"))
_glfw.glx.ARB_create_context_profile = GLFW_TRUE;
if (extensionSupportedGLX("GLX_EXT_create_context_es2_profile"))
_glfw.glx.EXT_create_context_es2_profile = GLFW_TRUE;
if (extensionSupportedGLX("GLX_ARB_create_context_no_error"))
_glfw.glx.ARB_create_context_no_error = GLFW_TRUE;
if (extensionSupportedGLX("GLX_ARB_context_flush_control"))
_glfw.glx.ARB_context_flush_control = GLFW_TRUE;
return GLFW_TRUE;
}
// Terminate GLX
//
void _glfwTerminateGLX(void)
{
// NOTE: This function must not call any X11 functions, as it is called
// after XCloseDisplay (see _glfwTerminateX11 for details)
if (_glfw.glx.handle)
{
_glfwPlatformFreeModule(_glfw.glx.handle);
_glfw.glx.handle = NULL;
}
}
#define SET_ATTRIB(a, v) \
{ \
assert(((size_t) index + 1) < sizeof(attribs) / sizeof(attribs[0])); \
attribs[index++] = a; \
attribs[index++] = v; \
}
// Create the OpenGL or OpenGL ES context
//
GLFWbool _glfwCreateContextGLX(_GLFWwindow* window,
const _GLFWctxconfig* ctxconfig,
const _GLFWfbconfig* fbconfig)
{
int attribs[40];
GLXFBConfig native = NULL;
GLXContext share = NULL;
if (ctxconfig->share)
share = ctxconfig->share->context.glx.handle;
if (!chooseGLXFBConfig(fbconfig, &native))
{
_glfwInputError(GLFW_FORMAT_UNAVAILABLE,
"GLX: Failed to find a suitable GLXFBConfig");
return GLFW_FALSE;
}
if (ctxconfig->client == GLFW_OPENGL_ES_API)
{
if (!_glfw.glx.ARB_create_context ||
!_glfw.glx.ARB_create_context_profile ||
!_glfw.glx.EXT_create_context_es2_profile)
{
_glfwInputError(GLFW_API_UNAVAILABLE,
"GLX: OpenGL ES requested but GLX_EXT_create_context_es2_profile is unavailable");
return GLFW_FALSE;
}
}
if (ctxconfig->forward)
{
if (!_glfw.glx.ARB_create_context)
{
_glfwInputError(GLFW_VERSION_UNAVAILABLE,
"GLX: Forward compatibility requested but GLX_ARB_create_context_profile is unavailable");
return GLFW_FALSE;
}
}
if (ctxconfig->profile)
{
if (!_glfw.glx.ARB_create_context ||
!_glfw.glx.ARB_create_context_profile)
{
_glfwInputError(GLFW_VERSION_UNAVAILABLE,
"GLX: An OpenGL profile requested but GLX_ARB_create_context_profile is unavailable");
return GLFW_FALSE;
}
}
_glfwGrabErrorHandlerX11();
if (_glfw.glx.ARB_create_context)
{
int index = 0, mask = 0, flags = 0;
if (ctxconfig->client == GLFW_OPENGL_API)
{
if (ctxconfig->forward)
flags |= GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB;
if (ctxconfig->profile == GLFW_OPENGL_CORE_PROFILE)
mask |= GLX_CONTEXT_CORE_PROFILE_BIT_ARB;
else if (ctxconfig->profile == GLFW_OPENGL_COMPAT_PROFILE)
mask |= GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB;
}
else
mask |= GLX_CONTEXT_ES2_PROFILE_BIT_EXT;
if (ctxconfig->debug)
flags |= GLX_CONTEXT_DEBUG_BIT_ARB;
if (ctxconfig->robustness)
{
if (_glfw.glx.ARB_create_context_robustness)
{
if (ctxconfig->robustness == GLFW_NO_RESET_NOTIFICATION)
{
SET_ATTRIB(GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB,
GLX_NO_RESET_NOTIFICATION_ARB);
}
else if (ctxconfig->robustness == GLFW_LOSE_CONTEXT_ON_RESET)
{
SET_ATTRIB(GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB,
GLX_LOSE_CONTEXT_ON_RESET_ARB);
}
flags |= GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB;
}
}
if (ctxconfig->release)
{
if (_glfw.glx.ARB_context_flush_control)
{
if (ctxconfig->release == GLFW_RELEASE_BEHAVIOR_NONE)
{
SET_ATTRIB(GLX_CONTEXT_RELEASE_BEHAVIOR_ARB,
GLX_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB);
}
else if (ctxconfig->release == GLFW_RELEASE_BEHAVIOR_FLUSH)
{
SET_ATTRIB(GLX_CONTEXT_RELEASE_BEHAVIOR_ARB,
GLX_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB);
}
}
}
if (ctxconfig->noerror)
{
if (_glfw.glx.ARB_create_context_no_error)
SET_ATTRIB(GLX_CONTEXT_OPENGL_NO_ERROR_ARB, GLFW_TRUE);
}
// NOTE: Only request an explicitly versioned context when necessary, as
// explicitly requesting version 1.0 does not always return the
// highest version supported by the driver
if (ctxconfig->major != 1 || ctxconfig->minor != 0)
{
SET_ATTRIB(GLX_CONTEXT_MAJOR_VERSION_ARB, ctxconfig->major);
SET_ATTRIB(GLX_CONTEXT_MINOR_VERSION_ARB, ctxconfig->minor);
}
if (mask)
SET_ATTRIB(GLX_CONTEXT_PROFILE_MASK_ARB, mask);
if (flags)
SET_ATTRIB(GLX_CONTEXT_FLAGS_ARB, flags);
SET_ATTRIB(None, None);
window->context.glx.handle =
_glfw.glx.CreateContextAttribsARB(_glfw.x11.display,
native,
share,
True,
attribs);
// HACK: This is a fallback for broken versions of the Mesa
// implementation of GLX_ARB_create_context_profile that fail
// default 1.0 context creation with a GLXBadProfileARB error in
// violation of the extension spec
if (!window->context.glx.handle)
{
if (_glfw.x11.errorCode == _glfw.glx.errorBase + GLXBadProfileARB &&
ctxconfig->client == GLFW_OPENGL_API &&
ctxconfig->profile == GLFW_OPENGL_ANY_PROFILE &&
ctxconfig->forward == GLFW_FALSE)
{
window->context.glx.handle =
createLegacyContextGLX(window, native, share);
}
}
}
else
{
window->context.glx.handle =
createLegacyContextGLX(window, native, share);
}
_glfwReleaseErrorHandlerX11();
if (!window->context.glx.handle)
{
_glfwInputErrorX11(GLFW_VERSION_UNAVAILABLE, "GLX: Failed to create context");
return GLFW_FALSE;
}
window->context.glx.window =
glXCreateWindow(_glfw.x11.display, native, window->x11.handle, NULL);
if (!window->context.glx.window)
{
_glfwInputError(GLFW_PLATFORM_ERROR, "GLX: Failed to create window");
return GLFW_FALSE;
}
window->context.makeCurrent = makeContextCurrentGLX;
window->context.swapBuffers = swapBuffersGLX;
window->context.swapInterval = swapIntervalGLX;
window->context.extensionSupported = extensionSupportedGLX;
window->context.getProcAddress = getProcAddressGLX;
window->context.destroy = destroyContextGLX;
return GLFW_TRUE;
}
#undef SET_ATTRIB
// Returns the Visual and depth of the chosen GLXFBConfig
//
GLFWbool _glfwChooseVisualGLX(const _GLFWwndconfig* wndconfig,
const _GLFWctxconfig* ctxconfig,
const _GLFWfbconfig* fbconfig,
Visual** visual, int* depth)
{
GLXFBConfig native;
XVisualInfo* result;
if (!chooseGLXFBConfig(fbconfig, &native))
{
_glfwInputError(GLFW_FORMAT_UNAVAILABLE,
"GLX: Failed to find a suitable GLXFBConfig");
return GLFW_FALSE;
}
result = glXGetVisualFromFBConfig(_glfw.x11.display, native);
if (!result)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"GLX: Failed to retrieve Visual for GLXFBConfig");
return GLFW_FALSE;
}
*visual = result->visual;
*depth = result->depth;
XFree(result);
return GLFW_TRUE;
}
//////////////////////////////////////////////////////////////////////////
////// GLFW native API //////
//////////////////////////////////////////////////////////////////////////
GLFWAPI GLXContext glfwGetGLXContext(GLFWwindow* handle)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
if (_glfw.platform.platformID != GLFW_PLATFORM_X11)
{
_glfwInputError(GLFW_PLATFORM_UNAVAILABLE, "GLX: Platform not initialized");
return NULL;
}
if (window->context.source != GLFW_NATIVE_CONTEXT_API)
{
_glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL);
return NULL;
}
return window->context.glx.handle;
}
GLFWAPI GLXWindow glfwGetGLXWindow(GLFWwindow* handle)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
_GLFW_REQUIRE_INIT_OR_RETURN(None);
if (_glfw.platform.platformID != GLFW_PLATFORM_X11)
{
_glfwInputError(GLFW_PLATFORM_UNAVAILABLE, "GLX: Platform not initialized");
return None;
}
if (window->context.source != GLFW_NATIVE_CONTEXT_API)
{
_glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL);
return None;
}
return window->context.glx.window;
}

545
thirdparty/imgui_suite/glfw/src/init.c vendored Normal file
View File

@@ -0,0 +1,545 @@
//========================================================================
// GLFW 3.4 - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2018 Camilla Löwy <elmindreda@glfw.org>
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would
// be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such, and must not
// be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source
// distribution.
//
//========================================================================
// Please use C89 style variable declarations in this file because VS 2010
//========================================================================
#include "internal.h"
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <assert.h>
// NOTE: The global variables below comprise all mutable global data in GLFW
// Any other mutable global variable is a bug
// This contains all mutable state shared between compilation units of GLFW
//
_GLFWlibrary _glfw = { GLFW_FALSE };
// These are outside of _glfw so they can be used before initialization and
// after termination without special handling when _glfw is cleared to zero
//
static _GLFWerror _glfwMainThreadError;
static GLFWerrorfun _glfwErrorCallback;
static GLFWallocator _glfwInitAllocator;
static _GLFWinitconfig _glfwInitHints =
{
GLFW_TRUE, // hat buttons
GLFW_ANGLE_PLATFORM_TYPE_NONE, // ANGLE backend
GLFW_ANY_PLATFORM, // preferred platform
NULL, // vkGetInstanceProcAddr function
{
GLFW_TRUE, // macOS menu bar
GLFW_TRUE // macOS bundle chdir
},
{
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
//
static void terminate(void)
{
int i;
memset(&_glfw.callbacks, 0, sizeof(_glfw.callbacks));
while (_glfw.windowListHead)
glfwDestroyWindow((GLFWwindow*) _glfw.windowListHead);
while (_glfw.cursorListHead)
glfwDestroyCursor((GLFWcursor*) _glfw.cursorListHead);
for (i = 0; i < _glfw.monitorCount; i++)
{
_GLFWmonitor* monitor = _glfw.monitors[i];
if (monitor->originalRamp.size)
_glfw.platform.setGammaRamp(monitor, &monitor->originalRamp);
_glfwFreeMonitor(monitor);
}
_glfw_free(_glfw.monitors);
_glfw.monitors = NULL;
_glfw.monitorCount = 0;
_glfw_free(_glfw.mappings);
_glfw.mappings = NULL;
_glfw.mappingCount = 0;
_glfwTerminateVulkan();
_glfw.platform.terminateJoysticks();
_glfw.platform.terminate();
_glfw.initialized = GLFW_FALSE;
while (_glfw.errorListHead)
{
_GLFWerror* error = _glfw.errorListHead;
_glfw.errorListHead = error->next;
_glfw_free(error);
}
_glfwPlatformDestroyTls(&_glfw.contextSlot);
_glfwPlatformDestroyTls(&_glfw.errorSlot);
_glfwPlatformDestroyMutex(&_glfw.errorLock);
memset(&_glfw, 0, sizeof(_glfw));
}
//////////////////////////////////////////////////////////////////////////
////// GLFW internal API //////
//////////////////////////////////////////////////////////////////////////
// Encode a Unicode code point to a UTF-8 stream
// Based on cutef8 by Jeff Bezanson (Public Domain)
//
size_t _glfwEncodeUTF8(char* s, uint32_t codepoint)
{
size_t count = 0;
if (codepoint < 0x80)
s[count++] = (char) codepoint;
else if (codepoint < 0x800)
{
s[count++] = (codepoint >> 6) | 0xc0;
s[count++] = (codepoint & 0x3f) | 0x80;
}
else if (codepoint < 0x10000)
{
s[count++] = (codepoint >> 12) | 0xe0;
s[count++] = ((codepoint >> 6) & 0x3f) | 0x80;
s[count++] = (codepoint & 0x3f) | 0x80;
}
else if (codepoint < 0x110000)
{
s[count++] = (codepoint >> 18) | 0xf0;
s[count++] = ((codepoint >> 12) & 0x3f) | 0x80;
s[count++] = ((codepoint >> 6) & 0x3f) | 0x80;
s[count++] = (codepoint & 0x3f) | 0x80;
}
return count;
}
// Splits and translates a text/uri-list into separate file paths
// NOTE: This function destroys the provided string
//
char** _glfwParseUriList(char* text, int* count)
{
const char* prefix = "file://";
char** paths = NULL;
char* line;
*count = 0;
while ((line = strtok(text, "\r\n")))
{
char* path;
text = NULL;
if (line[0] == '#')
continue;
if (strncmp(line, prefix, strlen(prefix)) == 0)
{
line += strlen(prefix);
// TODO: Validate hostname
while (*line != '/')
line++;
}
(*count)++;
path = _glfw_calloc(strlen(line) + 1, 1);
paths = _glfw_realloc(paths, *count * sizeof(char*));
paths[*count - 1] = path;
while (*line)
{
if (line[0] == '%' && line[1] && line[2])
{
const char digits[3] = { line[1], line[2], '\0' };
*path = (char) strtol(digits, NULL, 16);
line += 2;
}
else
*path = *line;
path++;
line++;
}
}
return paths;
}
char* _glfw_strdup(const char* source)
{
const size_t length = strlen(source);
char* result = _glfw_calloc(length + 1, 1);
strcpy(result, source);
return result;
}
int _glfw_min(int a, int b)
{
return a < b ? a : b;
}
int _glfw_max(int a, int b)
{
return a > b ? a : b;
}
float _glfw_fminf(float a, float b)
{
if (a != a)
return b;
else if (b != b)
return a;
else if (a < b)
return a;
else
return b;
}
float _glfw_fmaxf(float a, float b)
{
if (a != a)
return b;
else if (b != b)
return a;
else if (a > b)
return a;
else
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 //////
//////////////////////////////////////////////////////////////////////////
// Notifies shared code of an error
//
void _glfwInputError(int code, const char* format, ...)
{
_GLFWerror* error;
char description[_GLFW_MESSAGE_SIZE];
if (format)
{
va_list vl;
va_start(vl, format);
vsnprintf(description, sizeof(description), format, vl);
va_end(vl);
description[sizeof(description) - 1] = '\0';
}
else
{
if (code == GLFW_NOT_INITIALIZED)
strcpy(description, "The GLFW library is not initialized");
else if (code == GLFW_NO_CURRENT_CONTEXT)
strcpy(description, "There is no current context");
else if (code == GLFW_INVALID_ENUM)
strcpy(description, "Invalid argument for enum parameter");
else if (code == GLFW_INVALID_VALUE)
strcpy(description, "Invalid value for parameter");
else if (code == GLFW_OUT_OF_MEMORY)
strcpy(description, "Out of memory");
else if (code == GLFW_API_UNAVAILABLE)
strcpy(description, "The requested API is unavailable");
else if (code == GLFW_VERSION_UNAVAILABLE)
strcpy(description, "The requested API version is unavailable");
else if (code == GLFW_PLATFORM_ERROR)
strcpy(description, "A platform-specific error occurred");
else if (code == GLFW_FORMAT_UNAVAILABLE)
strcpy(description, "The requested format is unavailable");
else if (code == GLFW_NO_WINDOW_CONTEXT)
strcpy(description, "The specified window has no context");
else if (code == GLFW_CURSOR_UNAVAILABLE)
strcpy(description, "The specified cursor shape is unavailable");
else if (code == GLFW_FEATURE_UNAVAILABLE)
strcpy(description, "The requested feature cannot be implemented for this platform");
else if (code == GLFW_FEATURE_UNIMPLEMENTED)
strcpy(description, "The requested feature has not yet been implemented for this platform");
else if (code == GLFW_PLATFORM_UNAVAILABLE)
strcpy(description, "The requested platform is unavailable");
else
strcpy(description, "ERROR: UNKNOWN GLFW ERROR");
}
if (_glfw.initialized)
{
error = _glfwPlatformGetTls(&_glfw.errorSlot);
if (!error)
{
error = _glfw_calloc(1, sizeof(_GLFWerror));
_glfwPlatformSetTls(&_glfw.errorSlot, error);
_glfwPlatformLockMutex(&_glfw.errorLock);
error->next = _glfw.errorListHead;
_glfw.errorListHead = error;
_glfwPlatformUnlockMutex(&_glfw.errorLock);
}
}
else
error = &_glfwMainThreadError;
error->code = code;
strcpy(error->description, description);
if (_glfwErrorCallback)
_glfwErrorCallback(code, description);
}
//////////////////////////////////////////////////////////////////////////
////// GLFW public API //////
//////////////////////////////////////////////////////////////////////////
GLFWAPI int glfwInit(void)
{
if (_glfw.initialized)
return GLFW_TRUE;
memset(&_glfw, 0, sizeof(_glfw));
_glfw.hints.init = _glfwInitHints;
_glfw.allocator = _glfwInitAllocator;
if (!_glfw.allocator.allocate)
{
_glfw.allocator.allocate = defaultAllocate;
_glfw.allocator.reallocate = defaultReallocate;
_glfw.allocator.deallocate = defaultDeallocate;
}
if (!_glfwSelectPlatform(_glfw.hints.init.platformID, &_glfw.platform))
return GLFW_FALSE;
if (!_glfw.platform.init())
{
terminate();
return GLFW_FALSE;
}
if (!_glfwPlatformCreateMutex(&_glfw.errorLock) ||
!_glfwPlatformCreateTls(&_glfw.errorSlot) ||
!_glfwPlatformCreateTls(&_glfw.contextSlot))
{
terminate();
return GLFW_FALSE;
}
_glfwPlatformSetTls(&_glfw.errorSlot, &_glfwMainThreadError);
_glfwInitGamepadMappings();
_glfwPlatformInitTimer();
_glfw.timer.offset = _glfwPlatformGetTimerValue();
_glfw.initialized = GLFW_TRUE;
glfwDefaultWindowHints();
return GLFW_TRUE;
}
GLFWAPI void glfwTerminate(void)
{
if (!_glfw.initialized)
return;
terminate();
}
GLFWAPI void glfwInitHint(int hint, int value)
{
switch (hint)
{
case GLFW_JOYSTICK_HAT_BUTTONS:
_glfwInitHints.hatButtons = value;
return;
case GLFW_ANGLE_PLATFORM_TYPE:
_glfwInitHints.angleType = value;
return;
case GLFW_PLATFORM:
_glfwInitHints.platformID = value;
return;
case GLFW_COCOA_CHDIR_RESOURCES:
_glfwInitHints.ns.chdir = value;
return;
case GLFW_COCOA_MENUBAR:
_glfwInitHints.ns.menubar = value;
return;
case GLFW_X11_XCB_VULKAN_SURFACE:
_glfwInitHints.x11.xcbVulkanSurface = value;
return;
}
_glfwInputError(GLFW_INVALID_ENUM,
"Invalid init hint 0x%08X", hint);
}
GLFWAPI void glfwInitAllocator(const GLFWallocator* allocator)
{
if (allocator)
{
if (allocator->allocate && allocator->reallocate && allocator->deallocate)
_glfwInitAllocator = *allocator;
else
_glfwInputError(GLFW_INVALID_VALUE, "Missing function in allocator");
}
else
memset(&_glfwInitAllocator, 0, sizeof(GLFWallocator));
}
GLFWAPI void glfwInitVulkanLoader(PFN_vkGetInstanceProcAddr loader)
{
_glfwInitHints.vulkanLoader = loader;
}
GLFWAPI void glfwGetVersion(int* major, int* minor, int* rev)
{
if (major != NULL)
*major = GLFW_VERSION_MAJOR;
if (minor != NULL)
*minor = GLFW_VERSION_MINOR;
if (rev != NULL)
*rev = GLFW_VERSION_REVISION;
}
GLFWAPI int glfwGetError(const char** description)
{
_GLFWerror* error;
int code = GLFW_NO_ERROR;
if (description)
*description = NULL;
if (_glfw.initialized)
error = _glfwPlatformGetTls(&_glfw.errorSlot);
else
error = &_glfwMainThreadError;
if (error)
{
code = error->code;
error->code = GLFW_NO_ERROR;
if (description && code)
*description = error->description;
}
return code;
}
GLFWAPI GLFWerrorfun glfwSetErrorCallback(GLFWerrorfun cbfun)
{
_GLFW_SWAP(GLFWerrorfun, _glfwErrorCallback, cbfun);
return cbfun;
}

1504
thirdparty/imgui_suite/glfw/src/input.c vendored Normal file

File diff suppressed because it is too large Load Diff

1016
thirdparty/imgui_suite/glfw/src/internal.h vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,431 @@
//========================================================================
// GLFW 3.4 Linux - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would
// be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such, and must not
// be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source
// distribution.
//
//========================================================================
// It is fine to use C99 in this file because it will not be built with VS
//========================================================================
#include "internal.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/inotify.h>
#include <fcntl.h>
#include <errno.h>
#include <dirent.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#ifndef SYN_DROPPED // < v2.6.39 kernel headers
// Workaround for CentOS-6, which is supported till 2020-11-30, but still on v2.6.32
#define SYN_DROPPED 3
#endif
// Apply an EV_KEY event to the specified joystick
//
static void handleKeyEvent(_GLFWjoystick* js, int code, int value)
{
_glfwInputJoystickButton(js,
js->linjs.keyMap[code - BTN_MISC],
value ? GLFW_PRESS : GLFW_RELEASE);
}
// Apply an EV_ABS event to the specified joystick
//
static void handleAbsEvent(_GLFWjoystick* js, int code, int value)
{
const int index = js->linjs.absMap[code];
if (code >= ABS_HAT0X && code <= ABS_HAT3Y)
{
static const char stateMap[3][3] =
{
{ GLFW_HAT_CENTERED, GLFW_HAT_UP, GLFW_HAT_DOWN },
{ GLFW_HAT_LEFT, GLFW_HAT_LEFT_UP, GLFW_HAT_LEFT_DOWN },
{ GLFW_HAT_RIGHT, GLFW_HAT_RIGHT_UP, GLFW_HAT_RIGHT_DOWN },
};
const int hat = (code - ABS_HAT0X) / 2;
const int axis = (code - ABS_HAT0X) % 2;
int* state = js->linjs.hats[hat];
// NOTE: Looking at several input drivers, it seems all hat events use
// -1 for left / up, 0 for centered and 1 for right / down
if (value == 0)
state[axis] = 0;
else if (value < 0)
state[axis] = 1;
else if (value > 0)
state[axis] = 2;
_glfwInputJoystickHat(js, index, stateMap[state[0]][state[1]]);
}
else
{
const struct input_absinfo* info = &js->linjs.absInfo[code];
float normalized = value;
const int range = info->maximum - info->minimum;
if (range)
{
// Normalize to 0.0 -> 1.0
normalized = (normalized - info->minimum) / range;
// Normalize to -1.0 -> 1.0
normalized = normalized * 2.0f - 1.0f;
}
_glfwInputJoystickAxis(js, index, normalized);
}
}
// Poll state of absolute axes
//
static void pollAbsState(_GLFWjoystick* js)
{
for (int code = 0; code < ABS_CNT; code++)
{
if (js->linjs.absMap[code] < 0)
continue;
struct input_absinfo* info = &js->linjs.absInfo[code];
if (ioctl(js->linjs.fd, EVIOCGABS(code), info) < 0)
continue;
handleAbsEvent(js, code, info->value);
}
}
#define isBitSet(bit, arr) (arr[(bit) / 8] & (1 << ((bit) % 8)))
// Attempt to open the specified joystick device
//
static GLFWbool openJoystickDevice(const char* path)
{
for (int jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++)
{
if (!_glfw.joysticks[jid].connected)
continue;
if (strcmp(_glfw.joysticks[jid].linjs.path, path) == 0)
return GLFW_FALSE;
}
_GLFWjoystickLinux linjs = {0};
linjs.fd = open(path, O_RDONLY | O_NONBLOCK);
if (linjs.fd == -1)
return GLFW_FALSE;
char evBits[(EV_CNT + 7) / 8] = {0};
char keyBits[(KEY_CNT + 7) / 8] = {0};
char absBits[(ABS_CNT + 7) / 8] = {0};
struct input_id id;
if (ioctl(linjs.fd, EVIOCGBIT(0, sizeof(evBits)), evBits) < 0 ||
ioctl(linjs.fd, EVIOCGBIT(EV_KEY, sizeof(keyBits)), keyBits) < 0 ||
ioctl(linjs.fd, EVIOCGBIT(EV_ABS, sizeof(absBits)), absBits) < 0 ||
ioctl(linjs.fd, EVIOCGID, &id) < 0)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"Linux: Failed to query input device: %s",
strerror(errno));
close(linjs.fd);
return GLFW_FALSE;
}
// Ensure this device supports the events expected of a joystick
if (!isBitSet(EV_ABS, evBits))
{
close(linjs.fd);
return GLFW_FALSE;
}
char name[256] = "";
if (ioctl(linjs.fd, EVIOCGNAME(sizeof(name)), name) < 0)
strncpy(name, "Unknown", sizeof(name));
char guid[33] = "";
// Generate a joystick GUID that matches the SDL 2.0.5+ one
if (id.vendor && id.product && id.version)
{
sprintf(guid, "%02x%02x0000%02x%02x0000%02x%02x0000%02x%02x0000",
id.bustype & 0xff, id.bustype >> 8,
id.vendor & 0xff, id.vendor >> 8,
id.product & 0xff, id.product >> 8,
id.version & 0xff, id.version >> 8);
}
else
{
sprintf(guid, "%02x%02x0000%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x00",
id.bustype & 0xff, id.bustype >> 8,
name[0], name[1], name[2], name[3],
name[4], name[5], name[6], name[7],
name[8], name[9], name[10]);
}
int axisCount = 0, buttonCount = 0, hatCount = 0;
for (int code = BTN_MISC; code < KEY_CNT; code++)
{
if (!isBitSet(code, keyBits))
continue;
linjs.keyMap[code - BTN_MISC] = buttonCount;
buttonCount++;
}
for (int code = 0; code < ABS_CNT; code++)
{
linjs.absMap[code] = -1;
if (!isBitSet(code, absBits))
continue;
if (code >= ABS_HAT0X && code <= ABS_HAT3Y)
{
linjs.absMap[code] = hatCount;
hatCount++;
// Skip the Y axis
code++;
}
else
{
if (ioctl(linjs.fd, EVIOCGABS(code), &linjs.absInfo[code]) < 0)
continue;
linjs.absMap[code] = axisCount;
axisCount++;
}
}
_GLFWjoystick* js =
_glfwAllocJoystick(name, guid, axisCount, buttonCount, hatCount);
if (!js)
{
close(linjs.fd);
return GLFW_FALSE;
}
strncpy(linjs.path, path, sizeof(linjs.path) - 1);
memcpy(&js->linjs, &linjs, sizeof(linjs));
pollAbsState(js);
_glfwInputJoystick(js, GLFW_CONNECTED);
return GLFW_TRUE;
}
#undef isBitSet
// Frees all resources associated with the specified joystick
//
static void closeJoystick(_GLFWjoystick* js)
{
_glfwInputJoystick(js, GLFW_DISCONNECTED);
close(js->linjs.fd);
_glfwFreeJoystick(js);
}
// Lexically compare joysticks by name; used by qsort
//
static int compareJoysticks(const void* fp, const void* sp)
{
const _GLFWjoystick* fj = fp;
const _GLFWjoystick* sj = sp;
return strcmp(fj->linjs.path, sj->linjs.path);
}
//////////////////////////////////////////////////////////////////////////
////// GLFW internal API //////
//////////////////////////////////////////////////////////////////////////
void _glfwDetectJoystickConnectionLinux(void)
{
if (_glfw.linjs.inotify <= 0)
return;
ssize_t offset = 0;
char buffer[16384];
const ssize_t size = read(_glfw.linjs.inotify, buffer, sizeof(buffer));
while (size > offset)
{
regmatch_t match;
const struct inotify_event* e = (struct inotify_event*) (buffer + offset);
offset += sizeof(struct inotify_event) + e->len;
if (regexec(&_glfw.linjs.regex, e->name, 1, &match, 0) != 0)
continue;
char path[PATH_MAX];
snprintf(path, sizeof(path), "/dev/input/%s", e->name);
if (e->mask & (IN_CREATE | IN_ATTRIB))
openJoystickDevice(path);
else if (e->mask & IN_DELETE)
{
for (int jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++)
{
if (strcmp(_glfw.joysticks[jid].linjs.path, path) == 0)
{
closeJoystick(_glfw.joysticks + jid);
break;
}
}
}
}
}
//////////////////////////////////////////////////////////////////////////
////// GLFW platform API //////
//////////////////////////////////////////////////////////////////////////
GLFWbool _glfwInitJoysticksLinux(void)
{
const char* dirname = "/dev/input";
_glfw.linjs.inotify = inotify_init1(IN_NONBLOCK | IN_CLOEXEC);
if (_glfw.linjs.inotify > 0)
{
// HACK: Register for IN_ATTRIB to get notified when udev is done
// This works well in practice but the true way is libudev
_glfw.linjs.watch = inotify_add_watch(_glfw.linjs.inotify,
dirname,
IN_CREATE | IN_ATTRIB | IN_DELETE);
}
// Continue without device connection notifications if inotify fails
if (regcomp(&_glfw.linjs.regex, "^event[0-9]\\+$", 0) != 0)
{
_glfwInputError(GLFW_PLATFORM_ERROR, "Linux: Failed to compile regex");
return GLFW_FALSE;
}
int count = 0;
DIR* dir = opendir(dirname);
if (dir)
{
struct dirent* entry;
while ((entry = readdir(dir)))
{
regmatch_t match;
if (regexec(&_glfw.linjs.regex, entry->d_name, 1, &match, 0) != 0)
continue;
char path[PATH_MAX];
snprintf(path, sizeof(path), "%s/%s", dirname, entry->d_name);
if (openJoystickDevice(path))
count++;
}
closedir(dir);
}
// Continue with no joysticks if enumeration fails
qsort(_glfw.joysticks, count, sizeof(_GLFWjoystick), compareJoysticks);
return GLFW_TRUE;
}
void _glfwTerminateJoysticksLinux(void)
{
for (int jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++)
{
_GLFWjoystick* js = _glfw.joysticks + jid;
if (js->connected)
closeJoystick(js);
}
if (_glfw.linjs.inotify > 0)
{
if (_glfw.linjs.watch > 0)
inotify_rm_watch(_glfw.linjs.inotify, _glfw.linjs.watch);
close(_glfw.linjs.inotify);
regfree(&_glfw.linjs.regex);
}
}
GLFWbool _glfwPollJoystickLinux(_GLFWjoystick* js, int mode)
{
// Read all queued events (non-blocking)
for (;;)
{
struct input_event e;
errno = 0;
if (read(js->linjs.fd, &e, sizeof(e)) < 0)
{
// Reset the joystick slot if the device was disconnected
if (errno == ENODEV)
closeJoystick(js);
break;
}
if (e.type == EV_SYN)
{
if (e.code == SYN_DROPPED)
_glfw.linjs.dropped = GLFW_TRUE;
else if (e.code == SYN_REPORT)
{
_glfw.linjs.dropped = GLFW_FALSE;
pollAbsState(js);
}
}
if (_glfw.linjs.dropped)
continue;
if (e.type == EV_KEY)
handleKeyEvent(js, e.code, e.value);
else if (e.type == EV_ABS)
handleAbsEvent(js, e.code, e.value);
}
return js->connected;
}
const char* _glfwGetMappingNameLinux(void)
{
return "Linux";
}
void _glfwUpdateGamepadGUIDLinux(char* guid)
{
}

View File

@@ -0,0 +1,65 @@
//========================================================================
// GLFW 3.4 Linux - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2014 Jonas Ådahl <jadahl@gmail.com>
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would
// be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such, and must not
// be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source
// distribution.
//
//========================================================================
#include <linux/input.h>
#include <linux/limits.h>
#include <regex.h>
#define GLFW_LINUX_JOYSTICK_STATE _GLFWjoystickLinux linjs;
#define GLFW_LINUX_LIBRARY_JOYSTICK_STATE _GLFWlibraryLinux linjs;
#define GLFW_BUILD_LINUX_MAPPINGS
// Linux-specific joystick data
//
typedef struct _GLFWjoystickLinux
{
int fd;
char path[PATH_MAX];
int keyMap[KEY_CNT - BTN_MISC];
int absMap[ABS_CNT];
struct input_absinfo absInfo[ABS_CNT];
int hats[4][2];
} _GLFWjoystickLinux;
// Linux-specific joystick API data
//
typedef struct _GLFWlibraryLinux
{
int inotify;
int watch;
regex_t regex;
GLFWbool dropped;
} _GLFWlibraryLinux;
void _glfwDetectJoystickConnectionLinux(void);
GLFWbool _glfwInitJoysticksLinux(void);
void _glfwTerminateJoysticksLinux(void);
GLFWbool _glfwPollJoystickLinux(_GLFWjoystick* js, int mode);
const char* _glfwGetMappingNameLinux(void);
void _glfwUpdateGamepadGUIDLinux(char* guid);

1009
thirdparty/imgui_suite/glfw/src/mappings.h vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,82 @@
//========================================================================
// GLFW 3.4 - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2006-2018 Camilla Löwy <elmindreda@glfw.org>
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would
// be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such, and must not
// be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source
// distribution.
//
//========================================================================
// As mappings.h.in, this file is used by CMake to produce the mappings.h
// header file. If you are adding a GLFW specific gamepad mapping, this is
// where to put it.
//========================================================================
// As mappings.h, this provides all pre-defined gamepad mappings, including
// all available in SDL_GameControllerDB. Do not edit this file. Any gamepad
// mappings not specific to GLFW should be submitted to SDL_GameControllerDB.
// This file can be re-generated from mappings.h.in and the upstream
// gamecontrollerdb.txt with the 'update_mappings' CMake target.
//========================================================================
// All gamepad mappings not labeled GLFW are copied from the
// SDL_GameControllerDB project under the following license:
//
// Simple DirectMedia Layer
// Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.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.
const char* _glfwDefaultMappings[] =
{
#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,",
"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,",
"78696e70757404000000000000000000,XInput Flight 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,",
"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,",
"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,",
#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
};

View File

@@ -0,0 +1,548 @@
//========================================================================
// GLFW 3.4 - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would
// be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such, and must not
// be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source
// distribution.
//
//========================================================================
// Please use C89 style variable declarations in this file because VS 2010
//========================================================================
#include "internal.h"
#include <assert.h>
#include <math.h>
#include <float.h>
#include <string.h>
#include <stdlib.h>
#include <limits.h>
// Lexically compare video modes, used by qsort
//
static int compareVideoModes(const void* fp, const void* sp)
{
const GLFWvidmode* fm = fp;
const GLFWvidmode* sm = sp;
const int fbpp = fm->redBits + fm->greenBits + fm->blueBits;
const int sbpp = sm->redBits + sm->greenBits + sm->blueBits;
const int farea = fm->width * fm->height;
const int sarea = sm->width * sm->height;
// First sort on color bits per pixel
if (fbpp != sbpp)
return fbpp - sbpp;
// Then sort on screen area
if (farea != sarea)
return farea - sarea;
// Then sort on width
if (fm->width != sm->width)
return fm->width - sm->width;
// Lastly sort on refresh rate
return fm->refreshRate - sm->refreshRate;
}
// Retrieves the available modes for the specified monitor
//
static GLFWbool refreshVideoModes(_GLFWmonitor* monitor)
{
int modeCount;
GLFWvidmode* modes;
if (monitor->modes)
return GLFW_TRUE;
modes = _glfw.platform.getVideoModes(monitor, &modeCount);
if (!modes)
return GLFW_FALSE;
qsort(modes, modeCount, sizeof(GLFWvidmode), compareVideoModes);
_glfw_free(monitor->modes);
monitor->modes = modes;
monitor->modeCount = modeCount;
return GLFW_TRUE;
}
//////////////////////////////////////////////////////////////////////////
////// GLFW event API //////
//////////////////////////////////////////////////////////////////////////
// Notifies shared code of a monitor connection or disconnection
//
void _glfwInputMonitor(_GLFWmonitor* monitor, int action, int placement)
{
assert(monitor != NULL);
assert(action == GLFW_CONNECTED || action == GLFW_DISCONNECTED);
assert(placement == _GLFW_INSERT_FIRST || placement == _GLFW_INSERT_LAST);
if (action == GLFW_CONNECTED)
{
_glfw.monitorCount++;
_glfw.monitors =
_glfw_realloc(_glfw.monitors,
sizeof(_GLFWmonitor*) * _glfw.monitorCount);
if (placement == _GLFW_INSERT_FIRST)
{
memmove(_glfw.monitors + 1,
_glfw.monitors,
((size_t) _glfw.monitorCount - 1) * sizeof(_GLFWmonitor*));
_glfw.monitors[0] = monitor;
}
else
_glfw.monitors[_glfw.monitorCount - 1] = monitor;
}
else if (action == GLFW_DISCONNECTED)
{
int i;
_GLFWwindow* window;
for (window = _glfw.windowListHead; window; window = window->next)
{
if (window->monitor == monitor)
{
int width, height, xoff, yoff;
_glfw.platform.getWindowSize(window, &width, &height);
_glfw.platform.setWindowMonitor(window, NULL, 0, 0, width, height, 0);
_glfw.platform.getWindowFrameSize(window, &xoff, &yoff, NULL, NULL);
_glfw.platform.setWindowPos(window, xoff, yoff);
}
}
for (i = 0; i < _glfw.monitorCount; i++)
{
if (_glfw.monitors[i] == monitor)
{
_glfw.monitorCount--;
memmove(_glfw.monitors + i,
_glfw.monitors + i + 1,
((size_t) _glfw.monitorCount - i) * sizeof(_GLFWmonitor*));
break;
}
}
}
if (_glfw.callbacks.monitor)
_glfw.callbacks.monitor((GLFWmonitor*) monitor, action);
if (action == GLFW_DISCONNECTED)
_glfwFreeMonitor(monitor);
}
// Notifies shared code that a full screen window has acquired or released
// a monitor
//
void _glfwInputMonitorWindow(_GLFWmonitor* monitor, _GLFWwindow* window)
{
assert(monitor != NULL);
monitor->window = window;
}
//////////////////////////////////////////////////////////////////////////
////// GLFW internal API //////
//////////////////////////////////////////////////////////////////////////
// Allocates and returns a monitor object with the specified name and dimensions
//
_GLFWmonitor* _glfwAllocMonitor(const char* name, int widthMM, int heightMM)
{
_GLFWmonitor* monitor = _glfw_calloc(1, sizeof(_GLFWmonitor));
monitor->widthMM = widthMM;
monitor->heightMM = heightMM;
strncpy(monitor->name, name, sizeof(monitor->name) - 1);
return monitor;
}
// Frees a monitor object and any data associated with it
//
void _glfwFreeMonitor(_GLFWmonitor* monitor)
{
if (monitor == NULL)
return;
_glfw.platform.freeMonitor(monitor);
_glfwFreeGammaArrays(&monitor->originalRamp);
_glfwFreeGammaArrays(&monitor->currentRamp);
_glfw_free(monitor->modes);
_glfw_free(monitor);
}
// Allocates red, green and blue value arrays of the specified size
//
void _glfwAllocGammaArrays(GLFWgammaramp* ramp, unsigned int size)
{
ramp->red = _glfw_calloc(size, sizeof(unsigned short));
ramp->green = _glfw_calloc(size, sizeof(unsigned short));
ramp->blue = _glfw_calloc(size, sizeof(unsigned short));
ramp->size = size;
}
// Frees the red, green and blue value arrays and clears the struct
//
void _glfwFreeGammaArrays(GLFWgammaramp* ramp)
{
_glfw_free(ramp->red);
_glfw_free(ramp->green);
_glfw_free(ramp->blue);
memset(ramp, 0, sizeof(GLFWgammaramp));
}
// Chooses the video mode most closely matching the desired one
//
const GLFWvidmode* _glfwChooseVideoMode(_GLFWmonitor* monitor,
const GLFWvidmode* desired)
{
int i;
unsigned int sizeDiff, leastSizeDiff = UINT_MAX;
unsigned int rateDiff, leastRateDiff = UINT_MAX;
unsigned int colorDiff, leastColorDiff = UINT_MAX;
const GLFWvidmode* current;
const GLFWvidmode* closest = NULL;
if (!refreshVideoModes(monitor))
return NULL;
for (i = 0; i < monitor->modeCount; i++)
{
current = monitor->modes + i;
colorDiff = 0;
if (desired->redBits != GLFW_DONT_CARE)
colorDiff += abs(current->redBits - desired->redBits);
if (desired->greenBits != GLFW_DONT_CARE)
colorDiff += abs(current->greenBits - desired->greenBits);
if (desired->blueBits != GLFW_DONT_CARE)
colorDiff += abs(current->blueBits - desired->blueBits);
sizeDiff = abs((current->width - desired->width) *
(current->width - desired->width) +
(current->height - desired->height) *
(current->height - desired->height));
if (desired->refreshRate != GLFW_DONT_CARE)
rateDiff = abs(current->refreshRate - desired->refreshRate);
else
rateDiff = UINT_MAX - current->refreshRate;
if ((colorDiff < leastColorDiff) ||
(colorDiff == leastColorDiff && sizeDiff < leastSizeDiff) ||
(colorDiff == leastColorDiff && sizeDiff == leastSizeDiff && rateDiff < leastRateDiff))
{
closest = current;
leastSizeDiff = sizeDiff;
leastRateDiff = rateDiff;
leastColorDiff = colorDiff;
}
}
return closest;
}
// Performs lexical comparison between two @ref GLFWvidmode structures
//
int _glfwCompareVideoModes(const GLFWvidmode* fm, const GLFWvidmode* sm)
{
return compareVideoModes(fm, sm);
}
// Splits a color depth into red, green and blue bit depths
//
void _glfwSplitBPP(int bpp, int* red, int* green, int* blue)
{
int delta;
// We assume that by 32 the user really meant 24
if (bpp == 32)
bpp = 24;
// Convert "bits per pixel" to red, green & blue sizes
*red = *green = *blue = bpp / 3;
delta = bpp - (*red * 3);
if (delta >= 1)
*green = *green + 1;
if (delta == 2)
*red = *red + 1;
}
//////////////////////////////////////////////////////////////////////////
////// GLFW public API //////
//////////////////////////////////////////////////////////////////////////
GLFWAPI GLFWmonitor** glfwGetMonitors(int* count)
{
assert(count != NULL);
*count = 0;
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
*count = _glfw.monitorCount;
return (GLFWmonitor**) _glfw.monitors;
}
GLFWAPI GLFWmonitor* glfwGetPrimaryMonitor(void)
{
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
if (!_glfw.monitorCount)
return NULL;
return (GLFWmonitor*) _glfw.monitors[0];
}
GLFWAPI void glfwGetMonitorPos(GLFWmonitor* handle, int* xpos, int* ypos)
{
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
assert(monitor != NULL);
if (xpos)
*xpos = 0;
if (ypos)
*ypos = 0;
_GLFW_REQUIRE_INIT();
_glfw.platform.getMonitorPos(monitor, xpos, ypos);
}
GLFWAPI void glfwGetMonitorWorkarea(GLFWmonitor* handle,
int* xpos, int* ypos,
int* width, int* height)
{
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
assert(monitor != NULL);
if (xpos)
*xpos = 0;
if (ypos)
*ypos = 0;
if (width)
*width = 0;
if (height)
*height = 0;
_GLFW_REQUIRE_INIT();
_glfw.platform.getMonitorWorkarea(monitor, xpos, ypos, width, height);
}
GLFWAPI void glfwGetMonitorPhysicalSize(GLFWmonitor* handle, int* widthMM, int* heightMM)
{
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
assert(monitor != NULL);
if (widthMM)
*widthMM = 0;
if (heightMM)
*heightMM = 0;
_GLFW_REQUIRE_INIT();
if (widthMM)
*widthMM = monitor->widthMM;
if (heightMM)
*heightMM = monitor->heightMM;
}
GLFWAPI void glfwGetMonitorContentScale(GLFWmonitor* handle,
float* xscale, float* yscale)
{
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
assert(monitor != NULL);
if (xscale)
*xscale = 0.f;
if (yscale)
*yscale = 0.f;
_GLFW_REQUIRE_INIT();
_glfw.platform.getMonitorContentScale(monitor, xscale, yscale);
}
GLFWAPI const char* glfwGetMonitorName(GLFWmonitor* handle)
{
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
assert(monitor != NULL);
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
return monitor->name;
}
GLFWAPI void glfwSetMonitorUserPointer(GLFWmonitor* handle, void* pointer)
{
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
assert(monitor != NULL);
_GLFW_REQUIRE_INIT();
monitor->userPointer = pointer;
}
GLFWAPI void* glfwGetMonitorUserPointer(GLFWmonitor* handle)
{
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
assert(monitor != NULL);
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
return monitor->userPointer;
}
GLFWAPI GLFWmonitorfun glfwSetMonitorCallback(GLFWmonitorfun cbfun)
{
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
_GLFW_SWAP(GLFWmonitorfun, _glfw.callbacks.monitor, cbfun);
return cbfun;
}
GLFWAPI const GLFWvidmode* glfwGetVideoModes(GLFWmonitor* handle, int* count)
{
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
assert(monitor != NULL);
assert(count != NULL);
*count = 0;
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
if (!refreshVideoModes(monitor))
return NULL;
*count = monitor->modeCount;
return monitor->modes;
}
GLFWAPI const GLFWvidmode* glfwGetVideoMode(GLFWmonitor* handle)
{
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
assert(monitor != NULL);
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
_glfw.platform.getVideoMode(monitor, &monitor->currentMode);
return &monitor->currentMode;
}
GLFWAPI void glfwSetGamma(GLFWmonitor* handle, float gamma)
{
unsigned int i;
unsigned short* values;
GLFWgammaramp ramp;
const GLFWgammaramp* original;
assert(handle != NULL);
assert(gamma > 0.f);
assert(gamma <= FLT_MAX);
_GLFW_REQUIRE_INIT();
if (gamma != gamma || gamma <= 0.f || gamma > FLT_MAX)
{
_glfwInputError(GLFW_INVALID_VALUE, "Invalid gamma value %f", gamma);
return;
}
original = glfwGetGammaRamp(handle);
if (!original)
return;
values = _glfw_calloc(original->size, sizeof(unsigned short));
for (i = 0; i < original->size; i++)
{
float value;
// Calculate intensity
value = i / (float) (original->size - 1);
// Apply gamma curve
value = powf(value, 1.f / gamma) * 65535.f + 0.5f;
// Clamp to value range
value = _glfw_fminf(value, 65535.f);
values[i] = (unsigned short) value;
}
ramp.red = values;
ramp.green = values;
ramp.blue = values;
ramp.size = original->size;
glfwSetGammaRamp(handle, &ramp);
_glfw_free(values);
}
GLFWAPI const GLFWgammaramp* glfwGetGammaRamp(GLFWmonitor* handle)
{
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
assert(monitor != NULL);
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
_glfwFreeGammaArrays(&monitor->currentRamp);
if (!_glfw.platform.getGammaRamp(monitor, &monitor->currentRamp))
return NULL;
return &monitor->currentRamp;
}
GLFWAPI void glfwSetGammaRamp(GLFWmonitor* handle, const GLFWgammaramp* ramp)
{
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
assert(monitor != NULL);
assert(ramp != NULL);
assert(ramp->size > 0);
assert(ramp->red != NULL);
assert(ramp->green != NULL);
assert(ramp->blue != NULL);
_GLFW_REQUIRE_INIT();
if (ramp->size <= 0)
{
_glfwInputError(GLFW_INVALID_VALUE,
"Invalid gamma ramp size %i",
ramp->size);
return;
}
if (!monitor->originalRamp.size)
{
if (!_glfw.platform.getGammaRamp(monitor, &monitor->originalRamp))
return;
}
_glfw.platform.setGammaRamp(monitor, ramp);
}

View File

@@ -0,0 +1,376 @@
//========================================================================
// GLFW 3.4 macOS - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2009-2019 Camilla Löwy <elmindreda@glfw.org>
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would
// be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such, and must not
// be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source
// distribution.
//
//========================================================================
// It is fine to use C99 in this file because it will not be built with VS
//========================================================================
#include "internal.h"
#include <unistd.h>
#include <math.h>
static void makeContextCurrentNSGL(_GLFWwindow* window)
{
@autoreleasepool {
if (window)
[window->context.nsgl.object makeCurrentContext];
else
[NSOpenGLContext clearCurrentContext];
_glfwPlatformSetTls(&_glfw.contextSlot, window);
} // autoreleasepool
}
static void swapBuffersNSGL(_GLFWwindow* window)
{
@autoreleasepool {
// HACK: Simulate vsync with usleep as NSGL swap interval does not apply to
// windows with a non-visible occlusion state
if (window->ns.occluded)
{
int interval = 0;
[window->context.nsgl.object getValues:&interval
forParameter:NSOpenGLContextParameterSwapInterval];
if (interval > 0)
{
const double framerate = 60.0;
const uint64_t frequency = _glfwPlatformGetTimerFrequency();
const uint64_t value = _glfwPlatformGetTimerValue();
const double elapsed = value / (double) frequency;
const double period = 1.0 / framerate;
const double delay = period - fmod(elapsed, period);
usleep(floorl(delay * 1e6));
}
}
[window->context.nsgl.object flushBuffer];
} // autoreleasepool
}
static void swapIntervalNSGL(int interval)
{
@autoreleasepool {
_GLFWwindow* window = _glfwPlatformGetTls(&_glfw.contextSlot);
if (window)
{
[window->context.nsgl.object setValues:&interval
forParameter:NSOpenGLContextParameterSwapInterval];
}
} // autoreleasepool
}
static int extensionSupportedNSGL(const char* extension)
{
// There are no NSGL extensions
return GLFW_FALSE;
}
static GLFWglproc getProcAddressNSGL(const char* procname)
{
CFStringRef symbolName = CFStringCreateWithCString(kCFAllocatorDefault,
procname,
kCFStringEncodingASCII);
GLFWglproc symbol = CFBundleGetFunctionPointerForName(_glfw.nsgl.framework,
symbolName);
CFRelease(symbolName);
return symbol;
}
static void destroyContextNSGL(_GLFWwindow* window)
{
@autoreleasepool {
[window->context.nsgl.pixelFormat release];
window->context.nsgl.pixelFormat = nil;
[window->context.nsgl.object release];
window->context.nsgl.object = nil;
} // autoreleasepool
}
//////////////////////////////////////////////////////////////////////////
////// GLFW internal API //////
//////////////////////////////////////////////////////////////////////////
// Initialize OpenGL support
//
GLFWbool _glfwInitNSGL(void)
{
if (_glfw.nsgl.framework)
return GLFW_TRUE;
_glfw.nsgl.framework =
CFBundleGetBundleWithIdentifier(CFSTR("com.apple.opengl"));
if (_glfw.nsgl.framework == NULL)
{
_glfwInputError(GLFW_API_UNAVAILABLE,
"NSGL: Failed to locate OpenGL framework");
return GLFW_FALSE;
}
return GLFW_TRUE;
}
// Terminate OpenGL support
//
void _glfwTerminateNSGL(void)
{
}
// Create the OpenGL context
//
GLFWbool _glfwCreateContextNSGL(_GLFWwindow* window,
const _GLFWctxconfig* ctxconfig,
const _GLFWfbconfig* fbconfig)
{
if (ctxconfig->client == GLFW_OPENGL_ES_API)
{
_glfwInputError(GLFW_API_UNAVAILABLE,
"NSGL: OpenGL ES is not available on macOS");
return GLFW_FALSE;
}
if (ctxconfig->major > 2)
{
if (ctxconfig->major == 3 && ctxconfig->minor < 2)
{
_glfwInputError(GLFW_VERSION_UNAVAILABLE,
"NSGL: The targeted version of macOS does not support OpenGL 3.0 or 3.1 but may support 3.2 and above");
return GLFW_FALSE;
}
}
// Context robustness modes (GL_KHR_robustness) are not yet supported by
// macOS but are not a hard constraint, so ignore and continue
// Context release behaviors (GL_KHR_context_flush_control) are not yet
// supported by macOS but are not a hard constraint, so ignore and continue
// Debug contexts (GL_KHR_debug) are not yet supported by macOS but are not
// a hard constraint, so ignore and continue
// No-error contexts (GL_KHR_no_error) are not yet supported by macOS but
// are not a hard constraint, so ignore and continue
#define ADD_ATTRIB(a) \
{ \
assert((size_t) index < sizeof(attribs) / sizeof(attribs[0])); \
attribs[index++] = a; \
}
#define SET_ATTRIB(a, v) { ADD_ATTRIB(a); ADD_ATTRIB(v); }
NSOpenGLPixelFormatAttribute attribs[40];
int index = 0;
ADD_ATTRIB(NSOpenGLPFAAccelerated);
ADD_ATTRIB(NSOpenGLPFAClosestPolicy);
if (ctxconfig->nsgl.offline)
{
ADD_ATTRIB(NSOpenGLPFAAllowOfflineRenderers);
// NOTE: This replaces the NSSupportsAutomaticGraphicsSwitching key in
// Info.plist for unbundled applications
// HACK: This assumes that NSOpenGLPixelFormat will remain
// a straightforward wrapper of its CGL counterpart
ADD_ATTRIB(kCGLPFASupportsAutomaticGraphicsSwitching);
}
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101000
if (ctxconfig->major >= 4)
{
SET_ATTRIB(NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion4_1Core);
}
else
#endif /*MAC_OS_X_VERSION_MAX_ALLOWED*/
if (ctxconfig->major >= 3)
{
SET_ATTRIB(NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion3_2Core);
}
if (ctxconfig->major <= 2)
{
if (fbconfig->auxBuffers != GLFW_DONT_CARE)
SET_ATTRIB(NSOpenGLPFAAuxBuffers, fbconfig->auxBuffers);
if (fbconfig->accumRedBits != GLFW_DONT_CARE &&
fbconfig->accumGreenBits != GLFW_DONT_CARE &&
fbconfig->accumBlueBits != GLFW_DONT_CARE &&
fbconfig->accumAlphaBits != GLFW_DONT_CARE)
{
const int accumBits = fbconfig->accumRedBits +
fbconfig->accumGreenBits +
fbconfig->accumBlueBits +
fbconfig->accumAlphaBits;
SET_ATTRIB(NSOpenGLPFAAccumSize, accumBits);
}
}
if (fbconfig->redBits != GLFW_DONT_CARE &&
fbconfig->greenBits != GLFW_DONT_CARE &&
fbconfig->blueBits != GLFW_DONT_CARE)
{
int colorBits = fbconfig->redBits +
fbconfig->greenBits +
fbconfig->blueBits;
// macOS needs non-zero color size, so set reasonable values
if (colorBits == 0)
colorBits = 24;
else if (colorBits < 15)
colorBits = 15;
SET_ATTRIB(NSOpenGLPFAColorSize, colorBits);
}
if (fbconfig->alphaBits != GLFW_DONT_CARE)
SET_ATTRIB(NSOpenGLPFAAlphaSize, fbconfig->alphaBits);
if (fbconfig->depthBits != GLFW_DONT_CARE)
SET_ATTRIB(NSOpenGLPFADepthSize, fbconfig->depthBits);
if (fbconfig->stencilBits != GLFW_DONT_CARE)
SET_ATTRIB(NSOpenGLPFAStencilSize, fbconfig->stencilBits);
if (fbconfig->stereo)
{
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101200
_glfwInputError(GLFW_FORMAT_UNAVAILABLE,
"NSGL: Stereo rendering is deprecated");
return GLFW_FALSE;
#else
ADD_ATTRIB(NSOpenGLPFAStereo);
#endif
}
if (fbconfig->doublebuffer)
ADD_ATTRIB(NSOpenGLPFADoubleBuffer);
if (fbconfig->samples != GLFW_DONT_CARE)
{
if (fbconfig->samples == 0)
{
SET_ATTRIB(NSOpenGLPFASampleBuffers, 0);
}
else
{
SET_ATTRIB(NSOpenGLPFASampleBuffers, 1);
SET_ATTRIB(NSOpenGLPFASamples, fbconfig->samples);
}
}
// NOTE: All NSOpenGLPixelFormats on the relevant cards support sRGB
// framebuffer, so there's no need (and no way) to request it
ADD_ATTRIB(0);
#undef ADD_ATTRIB
#undef SET_ATTRIB
window->context.nsgl.pixelFormat =
[[NSOpenGLPixelFormat alloc] initWithAttributes:attribs];
if (window->context.nsgl.pixelFormat == nil)
{
_glfwInputError(GLFW_FORMAT_UNAVAILABLE,
"NSGL: Failed to find a suitable pixel format");
return GLFW_FALSE;
}
NSOpenGLContext* share = nil;
if (ctxconfig->share)
share = ctxconfig->share->context.nsgl.object;
window->context.nsgl.object =
[[NSOpenGLContext alloc] initWithFormat:window->context.nsgl.pixelFormat
shareContext:share];
if (window->context.nsgl.object == nil)
{
_glfwInputError(GLFW_VERSION_UNAVAILABLE,
"NSGL: Failed to create OpenGL context");
return GLFW_FALSE;
}
if (fbconfig->transparent)
{
GLint opaque = 0;
[window->context.nsgl.object setValues:&opaque
forParameter:NSOpenGLContextParameterSurfaceOpacity];
}
[window->ns.view setWantsBestResolutionOpenGLSurface:window->ns.retina];
[window->context.nsgl.object setView:window->ns.view];
window->context.makeCurrent = makeContextCurrentNSGL;
window->context.swapBuffers = swapBuffersNSGL;
window->context.swapInterval = swapIntervalNSGL;
window->context.extensionSupported = extensionSupportedNSGL;
window->context.getProcAddress = getProcAddressNSGL;
window->context.destroy = destroyContextNSGL;
return GLFW_TRUE;
}
//////////////////////////////////////////////////////////////////////////
////// GLFW native API //////
//////////////////////////////////////////////////////////////////////////
GLFWAPI id glfwGetNSGLContext(GLFWwindow* handle)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
_GLFW_REQUIRE_INIT_OR_RETURN(nil);
if (_glfw.platform.platformID != GLFW_PLATFORM_COCOA)
{
_glfwInputError(GLFW_PLATFORM_UNAVAILABLE,
"NSGL: Platform not initialized");
return nil;
}
if (window->context.source != GLFW_NATIVE_CONTEXT_API)
{
_glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL);
return nil;
}
return window->context.nsgl.object;
}

View File

@@ -0,0 +1,133 @@
//========================================================================
// GLFW 3.4 - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2016 Google Inc.
// Copyright (c) 2016-2017 Camilla Löwy <elmindreda@glfw.org>
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would
// be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such, and must not
// be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source
// distribution.
//
//========================================================================
// It is fine to use C99 in this file because it will not be built with VS
//========================================================================
#include "internal.h"
#include <stdlib.h>
//////////////////////////////////////////////////////////////////////////
////// GLFW platform API //////
//////////////////////////////////////////////////////////////////////////
GLFWbool _glfwConnectNull(int platformID, _GLFWplatform* platform)
{
const _GLFWplatform null =
{
GLFW_PLATFORM_NULL,
_glfwInitNull,
_glfwTerminateNull,
_glfwGetCursorPosNull,
_glfwSetCursorPosNull,
_glfwSetCursorModeNull,
_glfwSetRawMouseMotionNull,
_glfwRawMouseMotionSupportedNull,
_glfwCreateCursorNull,
_glfwCreateStandardCursorNull,
_glfwDestroyCursorNull,
_glfwSetCursorNull,
_glfwGetScancodeNameNull,
_glfwGetKeyScancodeNull,
_glfwSetClipboardStringNull,
_glfwGetClipboardStringNull,
_glfwInitJoysticksNull,
_glfwTerminateJoysticksNull,
_glfwPollJoystickNull,
_glfwGetMappingNameNull,
_glfwUpdateGamepadGUIDNull,
_glfwFreeMonitorNull,
_glfwGetMonitorPosNull,
_glfwGetMonitorContentScaleNull,
_glfwGetMonitorWorkareaNull,
_glfwGetVideoModesNull,
_glfwGetVideoModeNull,
_glfwGetGammaRampNull,
_glfwSetGammaRampNull,
_glfwCreateWindowNull,
_glfwDestroyWindowNull,
_glfwSetWindowTitleNull,
_glfwSetWindowIconNull,
_glfwGetWindowPosNull,
_glfwSetWindowPosNull,
_glfwGetWindowSizeNull,
_glfwSetWindowSizeNull,
_glfwSetWindowSizeLimitsNull,
_glfwSetWindowAspectRatioNull,
_glfwGetFramebufferSizeNull,
_glfwGetWindowFrameSizeNull,
_glfwGetWindowContentScaleNull,
_glfwIconifyWindowNull,
_glfwRestoreWindowNull,
_glfwMaximizeWindowNull,
_glfwShowWindowNull,
_glfwHideWindowNull,
_glfwRequestWindowAttentionNull,
_glfwFocusWindowNull,
_glfwSetWindowMonitorNull,
_glfwWindowFocusedNull,
_glfwWindowIconifiedNull,
_glfwWindowVisibleNull,
_glfwWindowMaximizedNull,
_glfwWindowHoveredNull,
_glfwFramebufferTransparentNull,
_glfwGetWindowOpacityNull,
_glfwSetWindowResizableNull,
_glfwSetWindowDecoratedNull,
_glfwSetWindowFloatingNull,
_glfwSetWindowOpacityNull,
_glfwSetWindowMousePassthroughNull,
_glfwPollEventsNull,
_glfwWaitEventsNull,
_glfwWaitEventsTimeoutNull,
_glfwPostEmptyEventNull,
_glfwGetEGLPlatformNull,
_glfwGetEGLNativeDisplayNull,
_glfwGetEGLNativeWindowNull,
_glfwGetRequiredInstanceExtensionsNull,
_glfwGetPhysicalDevicePresentationSupportNull,
_glfwCreateWindowSurfaceNull,
};
*platform = null;
return GLFW_TRUE;
}
int _glfwInitNull(void)
{
_glfwPollMonitorsNull();
return GLFW_TRUE;
}
void _glfwTerminateNull(void)
{
free(_glfw.null.clipboardString);
_glfwTerminateOSMesa();
_glfwTerminateEGL();
}

View File

@@ -0,0 +1,58 @@
//========================================================================
// GLFW 3.4 - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2016-2017 Camilla Löwy <elmindreda@glfw.org>
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would
// be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such, and must not
// be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source
// distribution.
//
//========================================================================
// It is fine to use C99 in this file because it will not be built with VS
//========================================================================
#include "internal.h"
//////////////////////////////////////////////////////////////////////////
////// GLFW platform API //////
//////////////////////////////////////////////////////////////////////////
GLFWbool _glfwInitJoysticksNull(void)
{
return GLFW_TRUE;
}
void _glfwTerminateJoysticksNull(void)
{
}
GLFWbool _glfwPollJoystickNull(_GLFWjoystick* js, int mode)
{
return GLFW_FALSE;
}
const char* _glfwGetMappingNameNull(void)
{
return "";
}
void _glfwUpdateGamepadGUIDNull(char* guid)
{
}

View File

@@ -0,0 +1,32 @@
//========================================================================
// GLFW 3.4 - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would
// be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such, and must not
// be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source
// distribution.
//
//========================================================================
GLFWbool _glfwInitJoysticksNull(void);
void _glfwTerminateJoysticksNull(void);
GLFWbool _glfwPollJoystickNull(_GLFWjoystick* js, int mode);
const char* _glfwGetMappingNameNull(void);
void _glfwUpdateGamepadGUIDNull(char* guid);

View File

@@ -0,0 +1,161 @@
//========================================================================
// GLFW 3.4 - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2016 Google Inc.
// Copyright (c) 2016-2019 Camilla Löwy <elmindreda@glfw.org>
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would
// be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such, and must not
// be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source
// distribution.
//
//========================================================================
// It is fine to use C99 in this file because it will not be built with VS
//========================================================================
#include "internal.h"
#include <stdlib.h>
#include <string.h>
#include <math.h>
// The the sole (fake) video mode of our (sole) fake monitor
//
static GLFWvidmode getVideoMode(void)
{
GLFWvidmode mode;
mode.width = 1920;
mode.height = 1080;
mode.redBits = 8;
mode.greenBits = 8;
mode.blueBits = 8;
mode.refreshRate = 60;
return mode;
}
//////////////////////////////////////////////////////////////////////////
////// GLFW internal API //////
//////////////////////////////////////////////////////////////////////////
void _glfwPollMonitorsNull(void)
{
const float dpi = 141.f;
const GLFWvidmode mode = getVideoMode();
_GLFWmonitor* monitor = _glfwAllocMonitor("Null SuperNoop 0",
(int) (mode.width * 25.4f / dpi),
(int) (mode.height * 25.4f / dpi));
_glfwInputMonitor(monitor, GLFW_CONNECTED, _GLFW_INSERT_FIRST);
}
//////////////////////////////////////////////////////////////////////////
////// GLFW platform API //////
//////////////////////////////////////////////////////////////////////////
void _glfwFreeMonitorNull(_GLFWmonitor* monitor)
{
_glfwFreeGammaArrays(&monitor->null.ramp);
}
void _glfwGetMonitorPosNull(_GLFWmonitor* monitor, int* xpos, int* ypos)
{
if (xpos)
*xpos = 0;
if (ypos)
*ypos = 0;
}
void _glfwGetMonitorContentScaleNull(_GLFWmonitor* monitor,
float* xscale, float* yscale)
{
if (xscale)
*xscale = 1.f;
if (yscale)
*yscale = 1.f;
}
void _glfwGetMonitorWorkareaNull(_GLFWmonitor* monitor,
int* xpos, int* ypos,
int* width, int* height)
{
const GLFWvidmode mode = getVideoMode();
if (xpos)
*xpos = 0;
if (ypos)
*ypos = 10;
if (width)
*width = mode.width;
if (height)
*height = mode.height - 10;
}
GLFWvidmode* _glfwGetVideoModesNull(_GLFWmonitor* monitor, int* found)
{
GLFWvidmode* mode = _glfw_calloc(1, sizeof(GLFWvidmode));
*mode = getVideoMode();
*found = 1;
return mode;
}
void _glfwGetVideoModeNull(_GLFWmonitor* monitor, GLFWvidmode* mode)
{
*mode = getVideoMode();
}
GLFWbool _glfwGetGammaRampNull(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
{
if (!monitor->null.ramp.size)
{
unsigned int i;
_glfwAllocGammaArrays(&monitor->null.ramp, 256);
for (i = 0; i < monitor->null.ramp.size; i++)
{
const float gamma = 2.2f;
float value;
value = i / (float) (monitor->null.ramp.size - 1);
value = powf(value, 1.f / gamma) * 65535.f + 0.5f;
value = _glfw_fminf(value, 65535.f);
monitor->null.ramp.red[i] = (unsigned short) value;
monitor->null.ramp.green[i] = (unsigned short) value;
monitor->null.ramp.blue[i] = (unsigned short) value;
}
}
_glfwAllocGammaArrays(ramp, monitor->null.ramp.size);
memcpy(ramp->red, monitor->null.ramp.red, sizeof(short) * ramp->size);
memcpy(ramp->green, monitor->null.ramp.green, sizeof(short) * ramp->size);
memcpy(ramp->blue, monitor->null.ramp.blue, sizeof(short) * ramp->size);
return GLFW_TRUE;
}
void _glfwSetGammaRampNull(_GLFWmonitor* monitor, const GLFWgammaramp* ramp)
{
if (monitor->null.ramp.size != ramp->size)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"Null: Gamma ramp size must match current ramp size");
return;
}
memcpy(monitor->null.ramp.red, ramp->red, sizeof(short) * ramp->size);
memcpy(monitor->null.ramp.green, ramp->green, sizeof(short) * ramp->size);
memcpy(monitor->null.ramp.blue, ramp->blue, sizeof(short) * ramp->size);
}

View File

@@ -0,0 +1,149 @@
//========================================================================
// GLFW 3.4 - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2016 Google Inc.
// Copyright (c) 2016-2017 Camilla Löwy <elmindreda@glfw.org>
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would
// be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such, and must not
// be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source
// distribution.
//
//========================================================================
#define GLFW_NULL_WINDOW_STATE _GLFWwindowNull null;
#define GLFW_NULL_LIBRARY_WINDOW_STATE _GLFWlibraryNull null;
#define GLFW_NULL_MONITOR_STATE _GLFWmonitorNull null;
#define GLFW_NULL_CONTEXT_STATE
#define GLFW_NULL_CURSOR_STATE
#define GLFW_NULL_LIBRARY_CONTEXT_STATE
// Null-specific per-window data
//
typedef struct _GLFWwindowNull
{
int xpos;
int ypos;
int width;
int height;
char* title;
GLFWbool visible;
GLFWbool iconified;
GLFWbool maximized;
GLFWbool resizable;
GLFWbool decorated;
GLFWbool floating;
GLFWbool transparent;
float opacity;
} _GLFWwindowNull;
// Null-specific per-monitor data
//
typedef struct _GLFWmonitorNull
{
GLFWgammaramp ramp;
} _GLFWmonitorNull;
// Null-specific global data
//
typedef struct _GLFWlibraryNull
{
int xcursor;
int ycursor;
char* clipboardString;
_GLFWwindow* focusedWindow;
} _GLFWlibraryNull;
void _glfwPollMonitorsNull(void);
GLFWbool _glfwConnectNull(int platformID, _GLFWplatform* platform);
int _glfwInitNull(void);
void _glfwTerminateNull(void);
void _glfwFreeMonitorNull(_GLFWmonitor* monitor);
void _glfwGetMonitorPosNull(_GLFWmonitor* monitor, int* xpos, int* ypos);
void _glfwGetMonitorContentScaleNull(_GLFWmonitor* monitor, float* xscale, float* yscale);
void _glfwGetMonitorWorkareaNull(_GLFWmonitor* monitor, int* xpos, int* ypos, int* width, int* height);
GLFWvidmode* _glfwGetVideoModesNull(_GLFWmonitor* monitor, int* found);
void _glfwGetVideoModeNull(_GLFWmonitor* monitor, GLFWvidmode* mode);
GLFWbool _glfwGetGammaRampNull(_GLFWmonitor* monitor, GLFWgammaramp* ramp);
void _glfwSetGammaRampNull(_GLFWmonitor* monitor, const GLFWgammaramp* ramp);
GLFWbool _glfwCreateWindowNull(_GLFWwindow* window, const _GLFWwndconfig* wndconfig, const _GLFWctxconfig* ctxconfig, const _GLFWfbconfig* fbconfig);
void _glfwDestroyWindowNull(_GLFWwindow* window);
void _glfwSetWindowTitleNull(_GLFWwindow* window, const char* title);
void _glfwSetWindowIconNull(_GLFWwindow* window, int count, const GLFWimage* images);
void _glfwSetWindowMonitorNull(_GLFWwindow* window, _GLFWmonitor* monitor, int xpos, int ypos, int width, int height, int refreshRate);
void _glfwGetWindowPosNull(_GLFWwindow* window, int* xpos, int* ypos);
void _glfwSetWindowPosNull(_GLFWwindow* window, int xpos, int ypos);
void _glfwGetWindowSizeNull(_GLFWwindow* window, int* width, int* height);
void _glfwSetWindowSizeNull(_GLFWwindow* window, int width, int height);
void _glfwSetWindowSizeLimitsNull(_GLFWwindow* window, int minwidth, int minheight, int maxwidth, int maxheight);
void _glfwSetWindowAspectRatioNull(_GLFWwindow* window, int n, int d);
void _glfwGetFramebufferSizeNull(_GLFWwindow* window, int* width, int* height);
void _glfwGetWindowFrameSizeNull(_GLFWwindow* window, int* left, int* top, int* right, int* bottom);
void _glfwGetWindowContentScaleNull(_GLFWwindow* window, float* xscale, float* yscale);
void _glfwIconifyWindowNull(_GLFWwindow* window);
void _glfwRestoreWindowNull(_GLFWwindow* window);
void _glfwMaximizeWindowNull(_GLFWwindow* window);
GLFWbool _glfwWindowMaximizedNull(_GLFWwindow* window);
GLFWbool _glfwWindowHoveredNull(_GLFWwindow* window);
GLFWbool _glfwFramebufferTransparentNull(_GLFWwindow* window);
void _glfwSetWindowResizableNull(_GLFWwindow* window, GLFWbool enabled);
void _glfwSetWindowDecoratedNull(_GLFWwindow* window, GLFWbool enabled);
void _glfwSetWindowFloatingNull(_GLFWwindow* window, GLFWbool enabled);
void _glfwSetWindowMousePassthroughNull(_GLFWwindow* window, GLFWbool enabled);
float _glfwGetWindowOpacityNull(_GLFWwindow* window);
void _glfwSetWindowOpacityNull(_GLFWwindow* window, float opacity);
void _glfwSetRawMouseMotionNull(_GLFWwindow *window, GLFWbool enabled);
GLFWbool _glfwRawMouseMotionSupportedNull(void);
void _glfwShowWindowNull(_GLFWwindow* window);
void _glfwRequestWindowAttentionNull(_GLFWwindow* window);
void _glfwRequestWindowAttentionNull(_GLFWwindow* window);
void _glfwHideWindowNull(_GLFWwindow* window);
void _glfwFocusWindowNull(_GLFWwindow* window);
GLFWbool _glfwWindowFocusedNull(_GLFWwindow* window);
GLFWbool _glfwWindowIconifiedNull(_GLFWwindow* window);
GLFWbool _glfwWindowVisibleNull(_GLFWwindow* window);
void _glfwPollEventsNull(void);
void _glfwWaitEventsNull(void);
void _glfwWaitEventsTimeoutNull(double timeout);
void _glfwPostEmptyEventNull(void);
void _glfwGetCursorPosNull(_GLFWwindow* window, double* xpos, double* ypos);
void _glfwSetCursorPosNull(_GLFWwindow* window, double x, double y);
void _glfwSetCursorModeNull(_GLFWwindow* window, int mode);
GLFWbool _glfwCreateCursorNull(_GLFWcursor* cursor, const GLFWimage* image, int xhot, int yhot);
GLFWbool _glfwCreateStandardCursorNull(_GLFWcursor* cursor, int shape);
void _glfwDestroyCursorNull(_GLFWcursor* cursor);
void _glfwSetCursorNull(_GLFWwindow* window, _GLFWcursor* cursor);
void _glfwSetClipboardStringNull(const char* string);
const char* _glfwGetClipboardStringNull(void);
const char* _glfwGetScancodeNameNull(int scancode);
int _glfwGetKeyScancodeNull(int key);
EGLenum _glfwGetEGLPlatformNull(EGLint** attribs);
EGLNativeDisplayType _glfwGetEGLNativeDisplayNull(void);
EGLNativeWindowType _glfwGetEGLNativeWindowNull(_GLFWwindow* window);
void _glfwGetRequiredInstanceExtensionsNull(char** extensions);
GLFWbool _glfwGetPhysicalDevicePresentationSupportNull(VkInstance instance, VkPhysicalDevice device, uint32_t queuefamily);
VkResult _glfwCreateWindowSurfaceNull(VkInstance instance, _GLFWwindow* window, const VkAllocationCallbacks* allocator, VkSurfaceKHR* surface);
void _glfwPollMonitorsNull(void);

View File

@@ -0,0 +1,724 @@
//========================================================================
// GLFW 3.4 - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2016 Google Inc.
// Copyright (c) 2016-2019 Camilla Löwy <elmindreda@glfw.org>
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would
// be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such, and must not
// be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source
// distribution.
//
//========================================================================
// It is fine to use C99 in this file because it will not be built with VS
//========================================================================
#include "internal.h"
#include <stdlib.h>
#ifdef __GNUC__
#pragma GCC diagnostic ignored "-Wsign-compare"
#endif
static void applySizeLimits(_GLFWwindow* window, int* width, int* height)
{
if (window->numer != GLFW_DONT_CARE && window->denom != GLFW_DONT_CARE)
{
const float ratio = (float) window->numer / (float) window->denom;
*height = (int) (*width / ratio);
}
if (window->minwidth != GLFW_DONT_CARE)
*width = _glfw_max(*width, window->minwidth);
else if (window->maxwidth != GLFW_DONT_CARE)
*width = _glfw_min(*width, window->maxwidth);
if (window->minheight != GLFW_DONT_CARE)
*height = _glfw_min(*height, window->minheight);
else if (window->maxheight != GLFW_DONT_CARE)
*height = _glfw_max(*height, window->maxheight);
}
static void fitToMonitor(_GLFWwindow* window)
{
GLFWvidmode mode;
_glfwGetVideoModeNull(window->monitor, &mode);
_glfwGetMonitorPosNull(window->monitor,
&window->null.xpos,
&window->null.ypos);
window->null.width = mode.width;
window->null.height = mode.height;
}
static void acquireMonitor(_GLFWwindow* window)
{
_glfwInputMonitorWindow(window->monitor, window);
}
static void releaseMonitor(_GLFWwindow* window)
{
if (window->monitor->window != window)
return;
_glfwInputMonitorWindow(window->monitor, NULL);
}
static int createNativeWindow(_GLFWwindow* window,
const _GLFWwndconfig* wndconfig,
const _GLFWfbconfig* fbconfig)
{
if (window->monitor)
fitToMonitor(window);
else
{
if (wndconfig->xpos == GLFW_ANY_POSITION && wndconfig->ypos == GLFW_ANY_POSITION)
{
window->null.xpos = 17;
window->null.ypos = 17;
}
else
{
window->null.xpos = wndconfig->xpos;
window->null.ypos = wndconfig->ypos;
}
window->null.width = wndconfig->width;
window->null.height = wndconfig->height;
}
window->null.visible = wndconfig->visible;
window->null.decorated = wndconfig->decorated;
window->null.maximized = wndconfig->maximized;
window->null.floating = wndconfig->floating;
window->null.transparent = fbconfig->transparent;
window->null.opacity = 1.f;
return GLFW_TRUE;
}
//////////////////////////////////////////////////////////////////////////
////// GLFW platform API //////
//////////////////////////////////////////////////////////////////////////
GLFWbool _glfwCreateWindowNull(_GLFWwindow* window,
const _GLFWwndconfig* wndconfig,
const _GLFWctxconfig* ctxconfig,
const _GLFWfbconfig* fbconfig)
{
if (!createNativeWindow(window, wndconfig, fbconfig))
return GLFW_FALSE;
if (ctxconfig->client != GLFW_NO_API)
{
if (ctxconfig->source == GLFW_NATIVE_CONTEXT_API ||
ctxconfig->source == GLFW_OSMESA_CONTEXT_API)
{
if (!_glfwInitOSMesa())
return GLFW_FALSE;
if (!_glfwCreateContextOSMesa(window, ctxconfig, fbconfig))
return GLFW_FALSE;
}
else if (ctxconfig->source == GLFW_EGL_CONTEXT_API)
{
if (!_glfwInitEGL())
return GLFW_FALSE;
if (!_glfwCreateContextEGL(window, ctxconfig, fbconfig))
return GLFW_FALSE;
}
if (!_glfwRefreshContextAttribs(window, ctxconfig))
return GLFW_FALSE;
}
if (wndconfig->mousePassthrough)
_glfwSetWindowMousePassthroughNull(window, GLFW_TRUE);
if (window->monitor)
{
_glfwShowWindowNull(window);
_glfwFocusWindowNull(window);
acquireMonitor(window);
if (wndconfig->centerCursor)
_glfwCenterCursorInContentArea(window);
}
else
{
if (wndconfig->visible)
{
_glfwShowWindowNull(window);
if (wndconfig->focused)
_glfwFocusWindowNull(window);
}
}
return GLFW_TRUE;
}
void _glfwDestroyWindowNull(_GLFWwindow* window)
{
if (window->monitor)
releaseMonitor(window);
if (_glfw.null.focusedWindow == window)
_glfw.null.focusedWindow = NULL;
if (window->context.destroy)
window->context.destroy(window);
}
void _glfwSetWindowTitleNull(_GLFWwindow* window, const char* title)
{
}
void _glfwSetWindowIconNull(_GLFWwindow* window, int count, const GLFWimage* images)
{
}
void _glfwSetWindowMonitorNull(_GLFWwindow* window,
_GLFWmonitor* monitor,
int xpos, int ypos,
int width, int height,
int refreshRate)
{
if (window->monitor == monitor)
{
if (!monitor)
{
_glfwSetWindowPosNull(window, xpos, ypos);
_glfwSetWindowSizeNull(window, width, height);
}
return;
}
if (window->monitor)
releaseMonitor(window);
_glfwInputWindowMonitor(window, monitor);
if (window->monitor)
{
window->null.visible = GLFW_TRUE;
acquireMonitor(window);
fitToMonitor(window);
}
else
{
_glfwSetWindowPosNull(window, xpos, ypos);
_glfwSetWindowSizeNull(window, width, height);
}
}
void _glfwGetWindowPosNull(_GLFWwindow* window, int* xpos, int* ypos)
{
if (xpos)
*xpos = window->null.xpos;
if (ypos)
*ypos = window->null.ypos;
}
void _glfwSetWindowPosNull(_GLFWwindow* window, int xpos, int ypos)
{
if (window->monitor)
return;
if (window->null.xpos != xpos || window->null.ypos != ypos)
{
window->null.xpos = xpos;
window->null.ypos = ypos;
_glfwInputWindowPos(window, xpos, ypos);
}
}
void _glfwGetWindowSizeNull(_GLFWwindow* window, int* width, int* height)
{
if (width)
*width = window->null.width;
if (height)
*height = window->null.height;
}
void _glfwSetWindowSizeNull(_GLFWwindow* window, int width, int height)
{
if (window->monitor)
return;
if (window->null.width != width || window->null.height != height)
{
window->null.width = width;
window->null.height = height;
_glfwInputWindowSize(window, width, height);
_glfwInputFramebufferSize(window, width, height);
}
}
void _glfwSetWindowSizeLimitsNull(_GLFWwindow* window,
int minwidth, int minheight,
int maxwidth, int maxheight)
{
int width = window->null.width;
int height = window->null.height;
applySizeLimits(window, &width, &height);
_glfwSetWindowSizeNull(window, width, height);
}
void _glfwSetWindowAspectRatioNull(_GLFWwindow* window, int n, int d)
{
int width = window->null.width;
int height = window->null.height;
applySizeLimits(window, &width, &height);
_glfwSetWindowSizeNull(window, width, height);
}
void _glfwGetFramebufferSizeNull(_GLFWwindow* window, int* width, int* height)
{
if (width)
*width = window->null.width;
if (height)
*height = window->null.height;
}
void _glfwGetWindowFrameSizeNull(_GLFWwindow* window,
int* left, int* top,
int* right, int* bottom)
{
if (window->null.decorated && !window->monitor)
{
if (left)
*left = 1;
if (top)
*top = 10;
if (right)
*right = 1;
if (bottom)
*bottom = 1;
}
else
{
if (left)
*left = 0;
if (top)
*top = 0;
if (right)
*right = 0;
if (bottom)
*bottom = 0;
}
}
void _glfwGetWindowContentScaleNull(_GLFWwindow* window, float* xscale, float* yscale)
{
if (xscale)
*xscale = 1.f;
if (yscale)
*yscale = 1.f;
}
void _glfwIconifyWindowNull(_GLFWwindow* window)
{
if (_glfw.null.focusedWindow == window)
{
_glfw.null.focusedWindow = NULL;
_glfwInputWindowFocus(window, GLFW_FALSE);
}
if (!window->null.iconified)
{
window->null.iconified = GLFW_TRUE;
_glfwInputWindowIconify(window, GLFW_TRUE);
if (window->monitor)
releaseMonitor(window);
}
}
void _glfwRestoreWindowNull(_GLFWwindow* window)
{
if (window->null.iconified)
{
window->null.iconified = GLFW_FALSE;
_glfwInputWindowIconify(window, GLFW_FALSE);
if (window->monitor)
acquireMonitor(window);
}
else if (window->null.maximized)
{
window->null.maximized = GLFW_FALSE;
_glfwInputWindowMaximize(window, GLFW_FALSE);
}
}
void _glfwMaximizeWindowNull(_GLFWwindow* window)
{
if (!window->null.maximized)
{
window->null.maximized = GLFW_TRUE;
_glfwInputWindowMaximize(window, GLFW_TRUE);
}
}
GLFWbool _glfwWindowMaximizedNull(_GLFWwindow* window)
{
return window->null.maximized;
}
GLFWbool _glfwWindowHoveredNull(_GLFWwindow* window)
{
return _glfw.null.xcursor >= window->null.xpos &&
_glfw.null.ycursor >= window->null.ypos &&
_glfw.null.xcursor <= window->null.xpos + window->null.width - 1 &&
_glfw.null.ycursor <= window->null.ypos + window->null.height - 1;
}
GLFWbool _glfwFramebufferTransparentNull(_GLFWwindow* window)
{
return window->null.transparent;
}
void _glfwSetWindowResizableNull(_GLFWwindow* window, GLFWbool enabled)
{
window->null.resizable = enabled;
}
void _glfwSetWindowDecoratedNull(_GLFWwindow* window, GLFWbool enabled)
{
window->null.decorated = enabled;
}
void _glfwSetWindowFloatingNull(_GLFWwindow* window, GLFWbool enabled)
{
window->null.floating = enabled;
}
void _glfwSetWindowMousePassthroughNull(_GLFWwindow* window, GLFWbool enabled)
{
}
float _glfwGetWindowOpacityNull(_GLFWwindow* window)
{
return window->null.opacity;
}
void _glfwSetWindowOpacityNull(_GLFWwindow* window, float opacity)
{
window->null.opacity = opacity;
}
void _glfwSetRawMouseMotionNull(_GLFWwindow *window, GLFWbool enabled)
{
}
GLFWbool _glfwRawMouseMotionSupportedNull(void)
{
return GLFW_TRUE;
}
void _glfwShowWindowNull(_GLFWwindow* window)
{
window->null.visible = GLFW_TRUE;
}
void _glfwRequestWindowAttentionNull(_GLFWwindow* window)
{
}
void _glfwHideWindowNull(_GLFWwindow* window)
{
if (_glfw.null.focusedWindow == window)
{
_glfw.null.focusedWindow = NULL;
_glfwInputWindowFocus(window, GLFW_FALSE);
}
window->null.visible = GLFW_FALSE;
}
void _glfwFocusWindowNull(_GLFWwindow* window)
{
_GLFWwindow* previous;
if (_glfw.null.focusedWindow == window)
return;
if (!window->null.visible)
return;
previous = _glfw.null.focusedWindow;
_glfw.null.focusedWindow = window;
if (previous)
{
_glfwInputWindowFocus(previous, GLFW_FALSE);
if (previous->monitor && previous->autoIconify)
_glfwIconifyWindowNull(previous);
}
_glfwInputWindowFocus(window, GLFW_TRUE);
}
GLFWbool _glfwWindowFocusedNull(_GLFWwindow* window)
{
return _glfw.null.focusedWindow == window;
}
GLFWbool _glfwWindowIconifiedNull(_GLFWwindow* window)
{
return window->null.iconified;
}
GLFWbool _glfwWindowVisibleNull(_GLFWwindow* window)
{
return window->null.visible;
}
void _glfwPollEventsNull(void)
{
}
void _glfwWaitEventsNull(void)
{
}
void _glfwWaitEventsTimeoutNull(double timeout)
{
}
void _glfwPostEmptyEventNull(void)
{
}
void _glfwGetCursorPosNull(_GLFWwindow* window, double* xpos, double* ypos)
{
if (xpos)
*xpos = _glfw.null.xcursor - window->null.xpos;
if (ypos)
*ypos = _glfw.null.ycursor - window->null.ypos;
}
void _glfwSetCursorPosNull(_GLFWwindow* window, double x, double y)
{
_glfw.null.xcursor = window->null.xpos + (int) x;
_glfw.null.ycursor = window->null.ypos + (int) y;
}
void _glfwSetCursorModeNull(_GLFWwindow* window, int mode)
{
}
GLFWbool _glfwCreateCursorNull(_GLFWcursor* cursor,
const GLFWimage* image,
int xhot, int yhot)
{
return GLFW_TRUE;
}
GLFWbool _glfwCreateStandardCursorNull(_GLFWcursor* cursor, int shape)
{
return GLFW_TRUE;
}
void _glfwDestroyCursorNull(_GLFWcursor* cursor)
{
}
void _glfwSetCursorNull(_GLFWwindow* window, _GLFWcursor* cursor)
{
}
void _glfwSetClipboardStringNull(const char* string)
{
char* copy = _glfw_strdup(string);
_glfw_free(_glfw.null.clipboardString);
_glfw.null.clipboardString = copy;
}
const char* _glfwGetClipboardStringNull(void)
{
return _glfw.null.clipboardString;
}
EGLenum _glfwGetEGLPlatformNull(EGLint** attribs)
{
return 0;
}
EGLNativeDisplayType _glfwGetEGLNativeDisplayNull(void)
{
return 0;
}
EGLNativeWindowType _glfwGetEGLNativeWindowNull(_GLFWwindow* window)
{
return 0;
}
const char* _glfwGetScancodeNameNull(int scancode)
{
if (scancode < GLFW_KEY_SPACE || scancode > GLFW_KEY_LAST)
{
_glfwInputError(GLFW_INVALID_VALUE, "Invalid scancode %i", scancode);
return NULL;
}
switch (scancode)
{
case GLFW_KEY_APOSTROPHE:
return "'";
case GLFW_KEY_COMMA:
return ",";
case GLFW_KEY_MINUS:
case GLFW_KEY_KP_SUBTRACT:
return "-";
case GLFW_KEY_PERIOD:
case GLFW_KEY_KP_DECIMAL:
return ".";
case GLFW_KEY_SLASH:
case GLFW_KEY_KP_DIVIDE:
return "/";
case GLFW_KEY_SEMICOLON:
return ";";
case GLFW_KEY_EQUAL:
case GLFW_KEY_KP_EQUAL:
return "=";
case GLFW_KEY_LEFT_BRACKET:
return "[";
case GLFW_KEY_RIGHT_BRACKET:
return "]";
case GLFW_KEY_KP_MULTIPLY:
return "*";
case GLFW_KEY_KP_ADD:
return "+";
case GLFW_KEY_BACKSLASH:
case GLFW_KEY_WORLD_1:
case GLFW_KEY_WORLD_2:
return "\\";
case GLFW_KEY_0:
case GLFW_KEY_KP_0:
return "0";
case GLFW_KEY_1:
case GLFW_KEY_KP_1:
return "1";
case GLFW_KEY_2:
case GLFW_KEY_KP_2:
return "2";
case GLFW_KEY_3:
case GLFW_KEY_KP_3:
return "3";
case GLFW_KEY_4:
case GLFW_KEY_KP_4:
return "4";
case GLFW_KEY_5:
case GLFW_KEY_KP_5:
return "5";
case GLFW_KEY_6:
case GLFW_KEY_KP_6:
return "6";
case GLFW_KEY_7:
case GLFW_KEY_KP_7:
return "7";
case GLFW_KEY_8:
case GLFW_KEY_KP_8:
return "8";
case GLFW_KEY_9:
case GLFW_KEY_KP_9:
return "9";
case GLFW_KEY_A:
return "a";
case GLFW_KEY_B:
return "b";
case GLFW_KEY_C:
return "c";
case GLFW_KEY_D:
return "d";
case GLFW_KEY_E:
return "e";
case GLFW_KEY_F:
return "f";
case GLFW_KEY_G:
return "g";
case GLFW_KEY_H:
return "h";
case GLFW_KEY_I:
return "i";
case GLFW_KEY_J:
return "j";
case GLFW_KEY_K:
return "k";
case GLFW_KEY_L:
return "l";
case GLFW_KEY_M:
return "m";
case GLFW_KEY_N:
return "n";
case GLFW_KEY_O:
return "o";
case GLFW_KEY_P:
return "p";
case GLFW_KEY_Q:
return "q";
case GLFW_KEY_R:
return "r";
case GLFW_KEY_S:
return "s";
case GLFW_KEY_T:
return "t";
case GLFW_KEY_U:
return "u";
case GLFW_KEY_V:
return "v";
case GLFW_KEY_W:
return "w";
case GLFW_KEY_X:
return "x";
case GLFW_KEY_Y:
return "y";
case GLFW_KEY_Z:
return "z";
}
return NULL;
}
int _glfwGetKeyScancodeNull(int key)
{
return key;
}
void _glfwGetRequiredInstanceExtensionsNull(char** extensions)
{
}
GLFWbool _glfwGetPhysicalDevicePresentationSupportNull(VkInstance instance,
VkPhysicalDevice device,
uint32_t queuefamily)
{
return GLFW_FALSE;
}
VkResult _glfwCreateWindowSurfaceNull(VkInstance instance,
_GLFWwindow* window,
const VkAllocationCallbacks* allocator,
VkSurfaceKHR* surface)
{
// This seems like the most appropriate error to return here
return VK_ERROR_EXTENSION_NOT_PRESENT;
}

View File

@@ -0,0 +1,386 @@
//========================================================================
// GLFW 3.4 OSMesa - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2016 Google Inc.
// Copyright (c) 2016-2017 Camilla Löwy <elmindreda@glfw.org>
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would
// be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such, and must not
// be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source
// distribution.
//
//========================================================================
// Please use C89 style variable declarations in this file because VS 2010
//========================================================================
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include "internal.h"
static void makeContextCurrentOSMesa(_GLFWwindow* window)
{
if (window)
{
int width, height;
_glfw.platform.getFramebufferSize(window, &width, &height);
// Check to see if we need to allocate a new buffer
if ((window->context.osmesa.buffer == NULL) ||
(width != window->context.osmesa.width) ||
(height != window->context.osmesa.height))
{
_glfw_free(window->context.osmesa.buffer);
// Allocate the new buffer (width * height * 8-bit RGBA)
window->context.osmesa.buffer = _glfw_calloc(4, (size_t) width * height);
window->context.osmesa.width = width;
window->context.osmesa.height = height;
}
if (!OSMesaMakeCurrent(window->context.osmesa.handle,
window->context.osmesa.buffer,
GL_UNSIGNED_BYTE,
width, height))
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"OSMesa: Failed to make context current");
return;
}
}
_glfwPlatformSetTls(&_glfw.contextSlot, window);
}
static GLFWglproc getProcAddressOSMesa(const char* procname)
{
return (GLFWglproc) OSMesaGetProcAddress(procname);
}
static void destroyContextOSMesa(_GLFWwindow* window)
{
if (window->context.osmesa.handle)
{
OSMesaDestroyContext(window->context.osmesa.handle);
window->context.osmesa.handle = NULL;
}
if (window->context.osmesa.buffer)
{
_glfw_free(window->context.osmesa.buffer);
window->context.osmesa.width = 0;
window->context.osmesa.height = 0;
}
}
static void swapBuffersOSMesa(_GLFWwindow* window)
{
// No double buffering on OSMesa
}
static void swapIntervalOSMesa(int interval)
{
// No swap interval on OSMesa
}
static int extensionSupportedOSMesa(const char* extension)
{
// OSMesa does not have extensions
return GLFW_FALSE;
}
//////////////////////////////////////////////////////////////////////////
////// GLFW internal API //////
//////////////////////////////////////////////////////////////////////////
GLFWbool _glfwInitOSMesa(void)
{
int i;
const char* sonames[] =
{
#if defined(_GLFW_OSMESA_LIBRARY)
_GLFW_OSMESA_LIBRARY,
#elif defined(_WIN32)
"libOSMesa.dll",
"OSMesa.dll",
#elif defined(__APPLE__)
"libOSMesa.8.dylib",
#elif defined(__CYGWIN__)
"libOSMesa-8.so",
#elif defined(__OpenBSD__) || defined(__NetBSD__)
"libOSMesa.so",
#else
"libOSMesa.so.8",
"libOSMesa.so.6",
#endif
NULL
};
if (_glfw.osmesa.handle)
return GLFW_TRUE;
for (i = 0; sonames[i]; i++)
{
_glfw.osmesa.handle = _glfwPlatformLoadModule(sonames[i]);
if (_glfw.osmesa.handle)
break;
}
if (!_glfw.osmesa.handle)
{
_glfwInputError(GLFW_API_UNAVAILABLE, "OSMesa: Library not found");
return GLFW_FALSE;
}
_glfw.osmesa.CreateContextExt = (PFN_OSMesaCreateContextExt)
_glfwPlatformGetModuleSymbol(_glfw.osmesa.handle, "OSMesaCreateContextExt");
_glfw.osmesa.CreateContextAttribs = (PFN_OSMesaCreateContextAttribs)
_glfwPlatformGetModuleSymbol(_glfw.osmesa.handle, "OSMesaCreateContextAttribs");
_glfw.osmesa.DestroyContext = (PFN_OSMesaDestroyContext)
_glfwPlatformGetModuleSymbol(_glfw.osmesa.handle, "OSMesaDestroyContext");
_glfw.osmesa.MakeCurrent = (PFN_OSMesaMakeCurrent)
_glfwPlatformGetModuleSymbol(_glfw.osmesa.handle, "OSMesaMakeCurrent");
_glfw.osmesa.GetColorBuffer = (PFN_OSMesaGetColorBuffer)
_glfwPlatformGetModuleSymbol(_glfw.osmesa.handle, "OSMesaGetColorBuffer");
_glfw.osmesa.GetDepthBuffer = (PFN_OSMesaGetDepthBuffer)
_glfwPlatformGetModuleSymbol(_glfw.osmesa.handle, "OSMesaGetDepthBuffer");
_glfw.osmesa.GetProcAddress = (PFN_OSMesaGetProcAddress)
_glfwPlatformGetModuleSymbol(_glfw.osmesa.handle, "OSMesaGetProcAddress");
if (!_glfw.osmesa.CreateContextExt ||
!_glfw.osmesa.DestroyContext ||
!_glfw.osmesa.MakeCurrent ||
!_glfw.osmesa.GetColorBuffer ||
!_glfw.osmesa.GetDepthBuffer ||
!_glfw.osmesa.GetProcAddress)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"OSMesa: Failed to load required entry points");
_glfwTerminateOSMesa();
return GLFW_FALSE;
}
return GLFW_TRUE;
}
void _glfwTerminateOSMesa(void)
{
if (_glfw.osmesa.handle)
{
_glfwPlatformFreeModule(_glfw.osmesa.handle);
_glfw.osmesa.handle = NULL;
}
}
#define SET_ATTRIB(a, v) \
{ \
assert(((size_t) index + 1) < sizeof(attribs) / sizeof(attribs[0])); \
attribs[index++] = a; \
attribs[index++] = v; \
}
GLFWbool _glfwCreateContextOSMesa(_GLFWwindow* window,
const _GLFWctxconfig* ctxconfig,
const _GLFWfbconfig* fbconfig)
{
OSMesaContext share = NULL;
const int accumBits = fbconfig->accumRedBits +
fbconfig->accumGreenBits +
fbconfig->accumBlueBits +
fbconfig->accumAlphaBits;
if (ctxconfig->client == GLFW_OPENGL_ES_API)
{
_glfwInputError(GLFW_API_UNAVAILABLE,
"OSMesa: OpenGL ES is not available on OSMesa");
return GLFW_FALSE;
}
if (ctxconfig->share)
share = ctxconfig->share->context.osmesa.handle;
if (OSMesaCreateContextAttribs)
{
int index = 0, attribs[40];
SET_ATTRIB(OSMESA_FORMAT, OSMESA_RGBA);
SET_ATTRIB(OSMESA_DEPTH_BITS, fbconfig->depthBits);
SET_ATTRIB(OSMESA_STENCIL_BITS, fbconfig->stencilBits);
SET_ATTRIB(OSMESA_ACCUM_BITS, accumBits);
if (ctxconfig->profile == GLFW_OPENGL_CORE_PROFILE)
{
SET_ATTRIB(OSMESA_PROFILE, OSMESA_CORE_PROFILE);
}
else if (ctxconfig->profile == GLFW_OPENGL_COMPAT_PROFILE)
{
SET_ATTRIB(OSMESA_PROFILE, OSMESA_COMPAT_PROFILE);
}
if (ctxconfig->major != 1 || ctxconfig->minor != 0)
{
SET_ATTRIB(OSMESA_CONTEXT_MAJOR_VERSION, ctxconfig->major);
SET_ATTRIB(OSMESA_CONTEXT_MINOR_VERSION, ctxconfig->minor);
}
if (ctxconfig->forward)
{
_glfwInputError(GLFW_VERSION_UNAVAILABLE,
"OSMesa: Forward-compatible contexts not supported");
return GLFW_FALSE;
}
SET_ATTRIB(0, 0);
window->context.osmesa.handle =
OSMesaCreateContextAttribs(attribs, share);
}
else
{
if (ctxconfig->profile)
{
_glfwInputError(GLFW_VERSION_UNAVAILABLE,
"OSMesa: OpenGL profiles unavailable");
return GLFW_FALSE;
}
window->context.osmesa.handle =
OSMesaCreateContextExt(OSMESA_RGBA,
fbconfig->depthBits,
fbconfig->stencilBits,
accumBits,
share);
}
if (window->context.osmesa.handle == NULL)
{
_glfwInputError(GLFW_VERSION_UNAVAILABLE,
"OSMesa: Failed to create context");
return GLFW_FALSE;
}
window->context.makeCurrent = makeContextCurrentOSMesa;
window->context.swapBuffers = swapBuffersOSMesa;
window->context.swapInterval = swapIntervalOSMesa;
window->context.extensionSupported = extensionSupportedOSMesa;
window->context.getProcAddress = getProcAddressOSMesa;
window->context.destroy = destroyContextOSMesa;
return GLFW_TRUE;
}
#undef SET_ATTRIB
//////////////////////////////////////////////////////////////////////////
////// GLFW native API //////
//////////////////////////////////////////////////////////////////////////
GLFWAPI int glfwGetOSMesaColorBuffer(GLFWwindow* handle, int* width,
int* height, int* format, void** buffer)
{
void* mesaBuffer;
GLint mesaWidth, mesaHeight, mesaFormat;
_GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL);
_GLFW_REQUIRE_INIT_OR_RETURN(GLFW_FALSE);
if (window->context.source != GLFW_OSMESA_CONTEXT_API)
{
_glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL);
return GLFW_FALSE;
}
if (!OSMesaGetColorBuffer(window->context.osmesa.handle,
&mesaWidth, &mesaHeight,
&mesaFormat, &mesaBuffer))
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"OSMesa: Failed to retrieve color buffer");
return GLFW_FALSE;
}
if (width)
*width = mesaWidth;
if (height)
*height = mesaHeight;
if (format)
*format = mesaFormat;
if (buffer)
*buffer = mesaBuffer;
return GLFW_TRUE;
}
GLFWAPI int glfwGetOSMesaDepthBuffer(GLFWwindow* handle,
int* width, int* height,
int* bytesPerValue,
void** buffer)
{
void* mesaBuffer;
GLint mesaWidth, mesaHeight, mesaBytes;
_GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL);
_GLFW_REQUIRE_INIT_OR_RETURN(GLFW_FALSE);
if (window->context.source != GLFW_OSMESA_CONTEXT_API)
{
_glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL);
return GLFW_FALSE;
}
if (!OSMesaGetDepthBuffer(window->context.osmesa.handle,
&mesaWidth, &mesaHeight,
&mesaBytes, &mesaBuffer))
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"OSMesa: Failed to retrieve depth buffer");
return GLFW_FALSE;
}
if (width)
*width = mesaWidth;
if (height)
*height = mesaHeight;
if (bytesPerValue)
*bytesPerValue = mesaBytes;
if (buffer)
*buffer = mesaBuffer;
return GLFW_TRUE;
}
GLFWAPI OSMesaContext glfwGetOSMesaContext(GLFWwindow* handle)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
if (window->context.source != GLFW_OSMESA_CONTEXT_API)
{
_glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL);
return NULL;
}
return window->context.osmesa.handle;
}

View File

@@ -0,0 +1,189 @@
//========================================================================
// GLFW 3.4 - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2018 Camilla Löwy <elmindreda@glfw.org>
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would
// be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such, and must not
// be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source
// distribution.
//
//========================================================================
// Please use C89 style variable declarations in this file because VS 2010
//========================================================================
#include "internal.h"
//////////////////////////////////////////////////////////////////////////
////// GLFW internal API //////
//////////////////////////////////////////////////////////////////////////
static const struct
{
int ID;
GLFWbool (*connect)(int,_GLFWplatform*);
} supportedPlatforms[] =
{
#if defined(_GLFW_WIN32)
{ GLFW_PLATFORM_WIN32, _glfwConnectWin32 },
#endif
#if defined(_GLFW_COCOA)
{ GLFW_PLATFORM_COCOA, _glfwConnectCocoa },
#endif
#if defined(_GLFW_X11)
{ GLFW_PLATFORM_X11, _glfwConnectX11 },
#endif
#if defined(_GLFW_WAYLAND)
{ GLFW_PLATFORM_WAYLAND, _glfwConnectWayland },
#endif
};
GLFWbool _glfwSelectPlatform(int desiredID, _GLFWplatform* platform)
{
const size_t count = sizeof(supportedPlatforms) / sizeof(supportedPlatforms[0]);
size_t i;
if (desiredID != GLFW_ANY_PLATFORM &&
desiredID != GLFW_PLATFORM_WIN32 &&
desiredID != GLFW_PLATFORM_COCOA &&
desiredID != GLFW_PLATFORM_WAYLAND &&
desiredID != GLFW_PLATFORM_X11 &&
desiredID != GLFW_PLATFORM_NULL)
{
_glfwInputError(GLFW_INVALID_ENUM, "Invalid platform ID 0x%08X", desiredID);
return GLFW_FALSE;
}
// Only allow the Null platform if specifically requested
if (desiredID == GLFW_PLATFORM_NULL)
return _glfwConnectNull(desiredID, platform);
else if (count == 0)
{
_glfwInputError(GLFW_PLATFORM_UNAVAILABLE, "This binary only supports the Null platform");
return GLFW_FALSE;
}
if (desiredID == GLFW_ANY_PLATFORM)
{
// If there is exactly one platform available for auto-selection, let it emit the
// error on failure as the platform-specific error description may be more helpful
if (count == 1)
return supportedPlatforms[0].connect(supportedPlatforms[0].ID, platform);
for (i = 0; i < count; i++)
{
if (supportedPlatforms[i].connect(desiredID, platform))
return GLFW_TRUE;
}
_glfwInputError(GLFW_PLATFORM_UNAVAILABLE, "Failed to detect any supported platform");
}
else
{
for (i = 0; i < count; i++)
{
if (supportedPlatforms[i].ID == desiredID)
return supportedPlatforms[i].connect(desiredID, platform);
}
_glfwInputError(GLFW_PLATFORM_UNAVAILABLE, "The requested platform is not supported");
}
return GLFW_FALSE;
}
//////////////////////////////////////////////////////////////////////////
////// GLFW public API //////
//////////////////////////////////////////////////////////////////////////
GLFWAPI int glfwGetPlatform(void)
{
_GLFW_REQUIRE_INIT_OR_RETURN(0);
return _glfw.platform.platformID;
}
GLFWAPI int glfwPlatformSupported(int platformID)
{
const size_t count = sizeof(supportedPlatforms) / sizeof(supportedPlatforms[0]);
size_t i;
if (platformID != GLFW_PLATFORM_WIN32 &&
platformID != GLFW_PLATFORM_COCOA &&
platformID != GLFW_PLATFORM_WAYLAND &&
platformID != GLFW_PLATFORM_X11 &&
platformID != GLFW_PLATFORM_NULL)
{
_glfwInputError(GLFW_INVALID_ENUM, "Invalid platform ID 0x%08X", platformID);
return GLFW_FALSE;
}
if (platformID == GLFW_PLATFORM_NULL)
return GLFW_TRUE;
for (i = 0; i < count; i++)
{
if (platformID == supportedPlatforms[i].ID)
return GLFW_TRUE;
}
return GLFW_FALSE;
}
GLFWAPI const char* glfwGetVersionString(void)
{
return _GLFW_VERSION_NUMBER
#if defined(_GLFW_WIN32)
" Win32 WGL"
#endif
#if defined(_GLFW_COCOA)
" Cocoa NSGL"
#endif
#if defined(_GLFW_WAYLAND)
" Wayland"
#endif
#if defined(_GLFW_X11)
" X11 GLX"
#endif
" Null"
" EGL"
" OSMesa"
#if defined(__MINGW64_VERSION_MAJOR)
" MinGW-w64"
#elif defined(__MINGW32__)
" MinGW"
#elif defined(_MSC_VER)
" VisualC"
#endif
#if defined(_GLFW_USE_HYBRID_HPG) || defined(_GLFW_USE_OPTIMUS_HPG)
" hybrid-GPU"
#endif
#if defined(_POSIX_MONOTONIC_CLOCK)
" monotonic"
#endif
#if defined(_GLFW_BUILD_DLL)
#if defined(_WIN32)
" DLL"
#elif defined(__APPLE__)
" dynamic"
#else
" shared"
#endif
#endif
;
}

View File

@@ -0,0 +1,163 @@
//========================================================================
// GLFW 3.4 - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2018 Camilla Löwy <elmindreda@glfw.org>
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would
// be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such, and must not
// be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source
// distribution.
//
//========================================================================
#include "null_platform.h"
#if defined(_GLFW_WIN32)
#include "win32_platform.h"
#else
#define GLFW_WIN32_WINDOW_STATE
#define GLFW_WIN32_MONITOR_STATE
#define GLFW_WIN32_CURSOR_STATE
#define GLFW_WIN32_LIBRARY_WINDOW_STATE
#define GLFW_WGL_CONTEXT_STATE
#define GLFW_WGL_LIBRARY_CONTEXT_STATE
#endif
#if defined(_GLFW_COCOA)
#include "cocoa_platform.h"
#else
#define GLFW_COCOA_WINDOW_STATE
#define GLFW_COCOA_MONITOR_STATE
#define GLFW_COCOA_CURSOR_STATE
#define GLFW_COCOA_LIBRARY_WINDOW_STATE
#define GLFW_NSGL_CONTEXT_STATE
#define GLFW_NSGL_LIBRARY_CONTEXT_STATE
#endif
#if defined(_GLFW_WAYLAND)
#include "wl_platform.h"
#else
#define GLFW_WAYLAND_WINDOW_STATE
#define GLFW_WAYLAND_MONITOR_STATE
#define GLFW_WAYLAND_CURSOR_STATE
#define GLFW_WAYLAND_LIBRARY_WINDOW_STATE
#endif
#if defined(_GLFW_X11)
#include "x11_platform.h"
#else
#define GLFW_X11_WINDOW_STATE
#define GLFW_X11_MONITOR_STATE
#define GLFW_X11_CURSOR_STATE
#define GLFW_X11_LIBRARY_WINDOW_STATE
#define GLFW_GLX_CONTEXT_STATE
#define GLFW_GLX_LIBRARY_CONTEXT_STATE
#endif
#include "null_joystick.h"
#if defined(_GLFW_WIN32)
#include "win32_joystick.h"
#else
#define GLFW_WIN32_JOYSTICK_STATE
#define GLFW_WIN32_LIBRARY_JOYSTICK_STATE
#endif
#if defined(_GLFW_COCOA)
#include "cocoa_joystick.h"
#else
#define GLFW_COCOA_JOYSTICK_STATE
#define GLFW_COCOA_LIBRARY_JOYSTICK_STATE
#endif
#if (defined(_GLFW_X11) || defined(_GLFW_WAYLAND)) && defined(__linux__)
#include "linux_joystick.h"
#else
#define GLFW_LINUX_JOYSTICK_STATE
#define GLFW_LINUX_LIBRARY_JOYSTICK_STATE
#endif
#define GLFW_PLATFORM_WINDOW_STATE \
GLFW_WIN32_WINDOW_STATE \
GLFW_COCOA_WINDOW_STATE \
GLFW_WAYLAND_WINDOW_STATE \
GLFW_X11_WINDOW_STATE \
GLFW_NULL_WINDOW_STATE \
#define GLFW_PLATFORM_MONITOR_STATE \
GLFW_WIN32_MONITOR_STATE \
GLFW_COCOA_MONITOR_STATE \
GLFW_WAYLAND_MONITOR_STATE \
GLFW_X11_MONITOR_STATE \
GLFW_NULL_MONITOR_STATE \
#define GLFW_PLATFORM_CURSOR_STATE \
GLFW_WIN32_CURSOR_STATE \
GLFW_COCOA_CURSOR_STATE \
GLFW_WAYLAND_CURSOR_STATE \
GLFW_X11_CURSOR_STATE \
GLFW_NULL_CURSOR_STATE \
#define GLFW_PLATFORM_JOYSTICK_STATE \
GLFW_WIN32_JOYSTICK_STATE \
GLFW_COCOA_JOYSTICK_STATE \
GLFW_LINUX_JOYSTICK_STATE
#define GLFW_PLATFORM_LIBRARY_WINDOW_STATE \
GLFW_WIN32_LIBRARY_WINDOW_STATE \
GLFW_COCOA_LIBRARY_WINDOW_STATE \
GLFW_WAYLAND_LIBRARY_WINDOW_STATE \
GLFW_X11_LIBRARY_WINDOW_STATE \
GLFW_NULL_LIBRARY_WINDOW_STATE \
#define GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE \
GLFW_WIN32_LIBRARY_JOYSTICK_STATE \
GLFW_COCOA_LIBRARY_JOYSTICK_STATE \
GLFW_LINUX_LIBRARY_JOYSTICK_STATE
#define GLFW_PLATFORM_CONTEXT_STATE \
GLFW_WGL_CONTEXT_STATE \
GLFW_NSGL_CONTEXT_STATE \
GLFW_GLX_CONTEXT_STATE
#define GLFW_PLATFORM_LIBRARY_CONTEXT_STATE \
GLFW_WGL_LIBRARY_CONTEXT_STATE \
GLFW_NSGL_LIBRARY_CONTEXT_STATE \
GLFW_GLX_LIBRARY_CONTEXT_STATE
#if defined(_WIN32)
#include "win32_thread.h"
#define GLFW_PLATFORM_TLS_STATE GLFW_WIN32_TLS_STATE
#define GLFW_PLATFORM_MUTEX_STATE GLFW_WIN32_MUTEX_STATE
#else
#include "posix_thread.h"
#define GLFW_PLATFORM_TLS_STATE GLFW_POSIX_TLS_STATE
#define GLFW_PLATFORM_MUTEX_STATE GLFW_POSIX_MUTEX_STATE
#endif
#if defined(_WIN32)
#include "win32_time.h"
#define GLFW_PLATFORM_LIBRARY_TIMER_STATE GLFW_WIN32_LIBRARY_TIMER_STATE
#elif defined(__APPLE__)
#include "cocoa_time.h"
#define GLFW_PLATFORM_LIBRARY_TIMER_STATE GLFW_COCOA_LIBRARY_TIMER_STATE
#else
#include "posix_time.h"
#define GLFW_PLATFORM_LIBRARY_TIMER_STATE GLFW_POSIX_LIBRARY_TIMER_STATE
#endif

View File

@@ -0,0 +1,53 @@
//========================================================================
// GLFW 3.4 POSIX - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2021 Camilla Löwy <elmindreda@glfw.org>
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would
// be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such, and must not
// be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source
// distribution.
//
//========================================================================
// It is fine to use C99 in this file because it will not be built with VS
//========================================================================
#include "internal.h"
#include <dlfcn.h>
#pragma GCC diagnostic ignored "-Wpedantic"
//////////////////////////////////////////////////////////////////////////
////// GLFW platform API //////
//////////////////////////////////////////////////////////////////////////
void* _glfwPlatformLoadModule(const char* path)
{
return dlopen(path, RTLD_LAZY | RTLD_LOCAL);
}
void _glfwPlatformFreeModule(void* module)
{
dlclose(module);
}
GLFWproc _glfwPlatformGetModuleSymbol(void* module, const char* name)
{
return dlsym(module, name);
}

View File

@@ -0,0 +1,81 @@
//========================================================================
// GLFW 3.4 POSIX - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2022 Camilla Löwy <elmindreda@glfw.org>
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would
// be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such, and must not
// be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source
// distribution.
//
//========================================================================
// It is fine to use C99 in this file because it will not be built with VS
//========================================================================
#define _GNU_SOURCE
#include "internal.h"
#include <signal.h>
#include <time.h>
#include <errno.h>
GLFWbool _glfwPollPOSIX(struct pollfd* fds, nfds_t count, double* timeout)
{
for (;;)
{
if (timeout)
{
const uint64_t base = _glfwPlatformGetTimerValue();
#if defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__CYGWIN__)
const time_t seconds = (time_t) *timeout;
const long nanoseconds = (long) ((*timeout - seconds) * 1e9);
const struct timespec ts = { seconds, nanoseconds };
const int result = ppoll(fds, count, &ts, NULL);
#elif defined(__NetBSD__)
const time_t seconds = (time_t) *timeout;
const long nanoseconds = (long) ((*timeout - seconds) * 1e9);
const struct timespec ts = { seconds, nanoseconds };
const int result = pollts(fds, count, &ts, NULL);
#else
const int milliseconds = (int) (*timeout * 1e3);
const int result = poll(fds, count, milliseconds);
#endif
const int error = errno; // clock_gettime may overwrite our error
*timeout -= (_glfwPlatformGetTimerValue() - base) /
(double) _glfwPlatformGetTimerFrequency();
if (result > 0)
return GLFW_TRUE;
else if (result == -1 && error != EINTR && error != EAGAIN)
return GLFW_FALSE;
else if (*timeout <= 0.0)
return GLFW_FALSE;
}
else
{
const int result = poll(fds, count, -1);
if (result > 0)
return GLFW_TRUE;
else if (result == -1 && errno != EINTR && errno != EAGAIN)
return GLFW_FALSE;
}
}
}

View File

@@ -0,0 +1,32 @@
//========================================================================
// GLFW 3.4 POSIX - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2022 Camilla Löwy <elmindreda@glfw.org>
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would
// be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such, and must not
// be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source
// distribution.
//
//========================================================================
// It is fine to use C99 in this file because it will not be built with VS
//========================================================================
#include <poll.h>
GLFWbool _glfwPollPOSIX(struct pollfd* fds, nfds_t count, double* timeout);

View File

@@ -0,0 +1,105 @@
//========================================================================
// GLFW 3.4 POSIX - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would
// be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such, and must not
// be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source
// distribution.
//
//========================================================================
// It is fine to use C99 in this file because it will not be built with VS
//========================================================================
#include "internal.h"
#include <assert.h>
#include <string.h>
//////////////////////////////////////////////////////////////////////////
////// GLFW platform API //////
//////////////////////////////////////////////////////////////////////////
GLFWbool _glfwPlatformCreateTls(_GLFWtls* tls)
{
assert(tls->posix.allocated == GLFW_FALSE);
if (pthread_key_create(&tls->posix.key, NULL) != 0)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"POSIX: Failed to create context TLS");
return GLFW_FALSE;
}
tls->posix.allocated = GLFW_TRUE;
return GLFW_TRUE;
}
void _glfwPlatformDestroyTls(_GLFWtls* tls)
{
if (tls->posix.allocated)
pthread_key_delete(tls->posix.key);
memset(tls, 0, sizeof(_GLFWtls));
}
void* _glfwPlatformGetTls(_GLFWtls* tls)
{
assert(tls->posix.allocated == GLFW_TRUE);
return pthread_getspecific(tls->posix.key);
}
void _glfwPlatformSetTls(_GLFWtls* tls, void* value)
{
assert(tls->posix.allocated == GLFW_TRUE);
pthread_setspecific(tls->posix.key, value);
}
GLFWbool _glfwPlatformCreateMutex(_GLFWmutex* mutex)
{
assert(mutex->posix.allocated == GLFW_FALSE);
if (pthread_mutex_init(&mutex->posix.handle, NULL) != 0)
{
_glfwInputError(GLFW_PLATFORM_ERROR, "POSIX: Failed to create mutex");
return GLFW_FALSE;
}
return mutex->posix.allocated = GLFW_TRUE;
}
void _glfwPlatformDestroyMutex(_GLFWmutex* mutex)
{
if (mutex->posix.allocated)
pthread_mutex_destroy(&mutex->posix.handle);
memset(mutex, 0, sizeof(_GLFWmutex));
}
void _glfwPlatformLockMutex(_GLFWmutex* mutex)
{
assert(mutex->posix.allocated == GLFW_TRUE);
pthread_mutex_lock(&mutex->posix.handle);
}
void _glfwPlatformUnlockMutex(_GLFWmutex* mutex)
{
assert(mutex->posix.allocated == GLFW_TRUE);
pthread_mutex_unlock(&mutex->posix.handle);
}

View File

@@ -0,0 +1,49 @@
//========================================================================
// GLFW 3.4 POSIX - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would
// be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such, and must not
// be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source
// distribution.
//
//========================================================================
#include <pthread.h>
#define GLFW_POSIX_TLS_STATE _GLFWtlsPOSIX posix;
#define GLFW_POSIX_MUTEX_STATE _GLFWmutexPOSIX posix;
// POSIX-specific thread local storage data
//
typedef struct _GLFWtlsPOSIX
{
GLFWbool allocated;
pthread_key_t key;
} _GLFWtlsPOSIX;
// POSIX-specific mutex data
//
typedef struct _GLFWmutexPOSIX
{
GLFWbool allocated;
pthread_mutex_t handle;
} _GLFWmutexPOSIX;

View File

@@ -0,0 +1,63 @@
//========================================================================
// GLFW 3.4 POSIX - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would
// be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such, and must not
// be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source
// distribution.
//
//========================================================================
// It is fine to use C99 in this file because it will not be built with VS
//========================================================================
#include "internal.h"
#include <unistd.h>
#include <sys/time.h>
//////////////////////////////////////////////////////////////////////////
////// GLFW platform API //////
//////////////////////////////////////////////////////////////////////////
void _glfwPlatformInitTimer(void)
{
_glfw.timer.posix.clock = CLOCK_REALTIME;
_glfw.timer.posix.frequency = 1000000000;
#if defined(_POSIX_MONOTONIC_CLOCK)
struct timespec ts;
if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0)
_glfw.timer.posix.clock = CLOCK_MONOTONIC;
#endif
}
uint64_t _glfwPlatformGetTimerValue(void)
{
struct timespec ts;
clock_gettime(_glfw.timer.posix.clock, &ts);
return (uint64_t) ts.tv_sec * _glfw.timer.posix.frequency + (uint64_t) ts.tv_nsec;
}
uint64_t _glfwPlatformGetTimerFrequency(void)
{
return _glfw.timer.posix.frequency;
}

View File

@@ -0,0 +1,41 @@
//========================================================================
// GLFW 3.4 POSIX - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would
// be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such, and must not
// be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source
// distribution.
//
//========================================================================
#define GLFW_POSIX_LIBRARY_TIMER_STATE _GLFWtimerPOSIX posix;
#include <stdint.h>
#include <time.h>
// POSIX-specific global timer data
//
typedef struct _GLFWtimerPOSIX
{
clockid_t clock;
uint64_t frequency;
} _GLFWtimerPOSIX;

330
thirdparty/imgui_suite/glfw/src/vulkan.c vendored Normal file
View File

@@ -0,0 +1,330 @@
//========================================================================
// GLFW 3.4 - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2018 Camilla Löwy <elmindreda@glfw.org>
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would
// be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such, and must not
// be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source
// distribution.
//
//========================================================================
// Please use C89 style variable declarations in this file because VS 2010
//========================================================================
#include "internal.h"
#include <assert.h>
#include <string.h>
#include <stdlib.h>
#define _GLFW_FIND_LOADER 1
#define _GLFW_REQUIRE_LOADER 2
//////////////////////////////////////////////////////////////////////////
////// GLFW internal API //////
//////////////////////////////////////////////////////////////////////////
GLFWbool _glfwInitVulkan(int mode)
{
VkResult err;
VkExtensionProperties* ep;
PFN_vkEnumerateInstanceExtensionProperties vkEnumerateInstanceExtensionProperties;
uint32_t i, count;
if (_glfw.vk.available)
return GLFW_TRUE;
if (_glfw.hints.init.vulkanLoader)
_glfw.vk.GetInstanceProcAddr = _glfw.hints.init.vulkanLoader;
else
{
#if defined(_GLFW_VULKAN_LIBRARY)
_glfw.vk.handle = _glfwPlatformLoadModule(_GLFW_VULKAN_LIBRARY);
#elif defined(_GLFW_WIN32)
_glfw.vk.handle = _glfwPlatformLoadModule("vulkan-1.dll");
#elif defined(_GLFW_COCOA)
_glfw.vk.handle = _glfwPlatformLoadModule("libvulkan.1.dylib");
if (!_glfw.vk.handle)
_glfw.vk.handle = _glfwLoadLocalVulkanLoaderCocoa();
#elif defined(__OpenBSD__) || defined(__NetBSD__)
_glfw.vk.handle = _glfwPlatformLoadModule("libvulkan.so");
#else
_glfw.vk.handle = _glfwPlatformLoadModule("libvulkan.so.1");
#endif
if (!_glfw.vk.handle)
{
if (mode == _GLFW_REQUIRE_LOADER)
_glfwInputError(GLFW_API_UNAVAILABLE, "Vulkan: Loader not found");
return GLFW_FALSE;
}
_glfw.vk.GetInstanceProcAddr = (PFN_vkGetInstanceProcAddr)
_glfwPlatformGetModuleSymbol(_glfw.vk.handle, "vkGetInstanceProcAddr");
if (!_glfw.vk.GetInstanceProcAddr)
{
_glfwInputError(GLFW_API_UNAVAILABLE,
"Vulkan: Loader does not export vkGetInstanceProcAddr");
_glfwTerminateVulkan();
return GLFW_FALSE;
}
}
vkEnumerateInstanceExtensionProperties = (PFN_vkEnumerateInstanceExtensionProperties)
vkGetInstanceProcAddr(NULL, "vkEnumerateInstanceExtensionProperties");
if (!vkEnumerateInstanceExtensionProperties)
{
_glfwInputError(GLFW_API_UNAVAILABLE,
"Vulkan: Failed to retrieve vkEnumerateInstanceExtensionProperties");
_glfwTerminateVulkan();
return GLFW_FALSE;
}
err = vkEnumerateInstanceExtensionProperties(NULL, &count, NULL);
if (err)
{
// NOTE: This happens on systems with a loader but without any Vulkan ICD
if (mode == _GLFW_REQUIRE_LOADER)
{
_glfwInputError(GLFW_API_UNAVAILABLE,
"Vulkan: Failed to query instance extension count: %s",
_glfwGetVulkanResultString(err));
}
_glfwTerminateVulkan();
return GLFW_FALSE;
}
ep = _glfw_calloc(count, sizeof(VkExtensionProperties));
err = vkEnumerateInstanceExtensionProperties(NULL, &count, ep);
if (err)
{
_glfwInputError(GLFW_API_UNAVAILABLE,
"Vulkan: Failed to query instance extensions: %s",
_glfwGetVulkanResultString(err));
_glfw_free(ep);
_glfwTerminateVulkan();
return GLFW_FALSE;
}
for (i = 0; i < count; i++)
{
if (strcmp(ep[i].extensionName, "VK_KHR_surface") == 0)
_glfw.vk.KHR_surface = GLFW_TRUE;
else if (strcmp(ep[i].extensionName, "VK_KHR_win32_surface") == 0)
_glfw.vk.KHR_win32_surface = GLFW_TRUE;
else if (strcmp(ep[i].extensionName, "VK_MVK_macos_surface") == 0)
_glfw.vk.MVK_macos_surface = GLFW_TRUE;
else if (strcmp(ep[i].extensionName, "VK_EXT_metal_surface") == 0)
_glfw.vk.EXT_metal_surface = GLFW_TRUE;
else if (strcmp(ep[i].extensionName, "VK_KHR_xlib_surface") == 0)
_glfw.vk.KHR_xlib_surface = GLFW_TRUE;
else if (strcmp(ep[i].extensionName, "VK_KHR_xcb_surface") == 0)
_glfw.vk.KHR_xcb_surface = GLFW_TRUE;
else if (strcmp(ep[i].extensionName, "VK_KHR_wayland_surface") == 0)
_glfw.vk.KHR_wayland_surface = GLFW_TRUE;
}
_glfw_free(ep);
_glfw.vk.available = GLFW_TRUE;
_glfw.platform.getRequiredInstanceExtensions(_glfw.vk.extensions);
return GLFW_TRUE;
}
void _glfwTerminateVulkan(void)
{
if (_glfw.vk.handle)
_glfwPlatformFreeModule(_glfw.vk.handle);
}
const char* _glfwGetVulkanResultString(VkResult result)
{
switch (result)
{
case VK_SUCCESS:
return "Success";
case VK_NOT_READY:
return "A fence or query has not yet completed";
case VK_TIMEOUT:
return "A wait operation has not completed in the specified time";
case VK_EVENT_SET:
return "An event is signaled";
case VK_EVENT_RESET:
return "An event is unsignaled";
case VK_INCOMPLETE:
return "A return array was too small for the result";
case VK_ERROR_OUT_OF_HOST_MEMORY:
return "A host memory allocation has failed";
case VK_ERROR_OUT_OF_DEVICE_MEMORY:
return "A device memory allocation has failed";
case VK_ERROR_INITIALIZATION_FAILED:
return "Initialization of an object could not be completed for implementation-specific reasons";
case VK_ERROR_DEVICE_LOST:
return "The logical or physical device has been lost";
case VK_ERROR_MEMORY_MAP_FAILED:
return "Mapping of a memory object has failed";
case VK_ERROR_LAYER_NOT_PRESENT:
return "A requested layer is not present or could not be loaded";
case VK_ERROR_EXTENSION_NOT_PRESENT:
return "A requested extension is not supported";
case VK_ERROR_FEATURE_NOT_PRESENT:
return "A requested feature is not supported";
case VK_ERROR_INCOMPATIBLE_DRIVER:
return "The requested version of Vulkan is not supported by the driver or is otherwise incompatible";
case VK_ERROR_TOO_MANY_OBJECTS:
return "Too many objects of the type have already been created";
case VK_ERROR_FORMAT_NOT_SUPPORTED:
return "A requested format is not supported on this device";
case VK_ERROR_SURFACE_LOST_KHR:
return "A surface is no longer available";
case VK_SUBOPTIMAL_KHR:
return "A swapchain no longer matches the surface properties exactly, but can still be used";
case VK_ERROR_OUT_OF_DATE_KHR:
return "A surface has changed in such a way that it is no longer compatible with the swapchain";
case VK_ERROR_INCOMPATIBLE_DISPLAY_KHR:
return "The display used by a swapchain does not use the same presentable image layout";
case VK_ERROR_NATIVE_WINDOW_IN_USE_KHR:
return "The requested window is already connected to a VkSurfaceKHR, or to some other non-Vulkan API";
case VK_ERROR_VALIDATION_FAILED_EXT:
return "A validation layer found an error";
default:
return "ERROR: UNKNOWN VULKAN ERROR";
}
}
//////////////////////////////////////////////////////////////////////////
////// GLFW public API //////
//////////////////////////////////////////////////////////////////////////
GLFWAPI int glfwVulkanSupported(void)
{
_GLFW_REQUIRE_INIT_OR_RETURN(GLFW_FALSE);
return _glfwInitVulkan(_GLFW_FIND_LOADER);
}
GLFWAPI const char** glfwGetRequiredInstanceExtensions(uint32_t* count)
{
assert(count != NULL);
*count = 0;
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
if (!_glfwInitVulkan(_GLFW_REQUIRE_LOADER))
return NULL;
if (!_glfw.vk.extensions[0])
return NULL;
*count = 2;
return (const char**) _glfw.vk.extensions;
}
GLFWAPI GLFWvkproc glfwGetInstanceProcAddress(VkInstance instance,
const char* procname)
{
GLFWvkproc proc;
assert(procname != NULL);
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
if (!_glfwInitVulkan(_GLFW_REQUIRE_LOADER))
return NULL;
// NOTE: Vulkan 1.0 and 1.1 vkGetInstanceProcAddr cannot return itself
if (strcmp(procname, "vkGetInstanceProcAddr") == 0)
return (GLFWvkproc) vkGetInstanceProcAddr;
proc = (GLFWvkproc) vkGetInstanceProcAddr(instance, procname);
if (!proc)
{
if (_glfw.vk.handle)
proc = (GLFWvkproc) _glfwPlatformGetModuleSymbol(_glfw.vk.handle, procname);
}
return proc;
}
GLFWAPI int glfwGetPhysicalDevicePresentationSupport(VkInstance instance,
VkPhysicalDevice device,
uint32_t queuefamily)
{
assert(instance != VK_NULL_HANDLE);
assert(device != VK_NULL_HANDLE);
_GLFW_REQUIRE_INIT_OR_RETURN(GLFW_FALSE);
if (!_glfwInitVulkan(_GLFW_REQUIRE_LOADER))
return GLFW_FALSE;
if (!_glfw.vk.extensions[0])
{
_glfwInputError(GLFW_API_UNAVAILABLE,
"Vulkan: Window surface creation extensions not found");
return GLFW_FALSE;
}
return _glfw.platform.getPhysicalDevicePresentationSupport(instance,
device,
queuefamily);
}
GLFWAPI VkResult glfwCreateWindowSurface(VkInstance instance,
GLFWwindow* handle,
const VkAllocationCallbacks* allocator,
VkSurfaceKHR* surface)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
assert(instance != VK_NULL_HANDLE);
assert(window != NULL);
assert(surface != NULL);
*surface = VK_NULL_HANDLE;
_GLFW_REQUIRE_INIT_OR_RETURN(VK_ERROR_INITIALIZATION_FAILED);
if (!_glfwInitVulkan(_GLFW_REQUIRE_LOADER))
return VK_ERROR_INITIALIZATION_FAILED;
if (!_glfw.vk.extensions[0])
{
_glfwInputError(GLFW_API_UNAVAILABLE,
"Vulkan: Window surface creation extensions not found");
return VK_ERROR_EXTENSION_NOT_PRESENT;
}
if (window->context.client != GLFW_NO_API)
{
_glfwInputError(GLFW_INVALID_VALUE,
"Vulkan: Window surface creation requires the window to have the client API set to GLFW_NO_API");
return VK_ERROR_NATIVE_WINDOW_IN_USE_KHR;
}
return _glfw.platform.createWindowSurface(instance, window, allocator, surface);
}

View File

@@ -0,0 +1,778 @@
//========================================================================
// GLFW 3.4 WGL - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would
// be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such, and must not
// be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source
// distribution.
//
//========================================================================
// Please use C89 style variable declarations in this file because VS 2010
//========================================================================
#include "internal.h"
#include <stdlib.h>
#include <assert.h>
// Return the value corresponding to the specified attribute
//
static int findPixelFormatAttribValueWGL(const int* attribs,
int attribCount,
const int* values,
int attrib)
{
int i;
for (i = 0; i < attribCount; i++)
{
if (attribs[i] == attrib)
return values[i];
}
_glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
"WGL: Unknown pixel format attribute requested");
return 0;
}
#define ADD_ATTRIB(a) \
{ \
assert((size_t) attribCount < sizeof(attribs) / sizeof(attribs[0])); \
attribs[attribCount++] = a; \
}
#define FIND_ATTRIB_VALUE(a) \
findPixelFormatAttribValueWGL(attribs, attribCount, values, a)
// Return a list of available and usable framebuffer configs
//
static int choosePixelFormatWGL(_GLFWwindow* window,
const _GLFWctxconfig* ctxconfig,
const _GLFWfbconfig* fbconfig)
{
_GLFWfbconfig* usableConfigs;
const _GLFWfbconfig* closest;
int i, pixelFormat, nativeCount, usableCount = 0, attribCount = 0;
int attribs[40];
int values[sizeof(attribs) / sizeof(attribs[0])];
nativeCount = DescribePixelFormat(window->context.wgl.dc,
1,
sizeof(PIXELFORMATDESCRIPTOR),
NULL);
if (_glfw.wgl.ARB_pixel_format)
{
ADD_ATTRIB(WGL_SUPPORT_OPENGL_ARB);
ADD_ATTRIB(WGL_DRAW_TO_WINDOW_ARB);
ADD_ATTRIB(WGL_PIXEL_TYPE_ARB);
ADD_ATTRIB(WGL_ACCELERATION_ARB);
ADD_ATTRIB(WGL_RED_BITS_ARB);
ADD_ATTRIB(WGL_RED_SHIFT_ARB);
ADD_ATTRIB(WGL_GREEN_BITS_ARB);
ADD_ATTRIB(WGL_GREEN_SHIFT_ARB);
ADD_ATTRIB(WGL_BLUE_BITS_ARB);
ADD_ATTRIB(WGL_BLUE_SHIFT_ARB);
ADD_ATTRIB(WGL_ALPHA_BITS_ARB);
ADD_ATTRIB(WGL_ALPHA_SHIFT_ARB);
ADD_ATTRIB(WGL_DEPTH_BITS_ARB);
ADD_ATTRIB(WGL_STENCIL_BITS_ARB);
ADD_ATTRIB(WGL_ACCUM_BITS_ARB);
ADD_ATTRIB(WGL_ACCUM_RED_BITS_ARB);
ADD_ATTRIB(WGL_ACCUM_GREEN_BITS_ARB);
ADD_ATTRIB(WGL_ACCUM_BLUE_BITS_ARB);
ADD_ATTRIB(WGL_ACCUM_ALPHA_BITS_ARB);
ADD_ATTRIB(WGL_AUX_BUFFERS_ARB);
ADD_ATTRIB(WGL_STEREO_ARB);
ADD_ATTRIB(WGL_DOUBLE_BUFFER_ARB);
if (_glfw.wgl.ARB_multisample)
ADD_ATTRIB(WGL_SAMPLES_ARB);
if (ctxconfig->client == GLFW_OPENGL_API)
{
if (_glfw.wgl.ARB_framebuffer_sRGB || _glfw.wgl.EXT_framebuffer_sRGB)
ADD_ATTRIB(WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB);
}
else
{
if (_glfw.wgl.EXT_colorspace)
ADD_ATTRIB(WGL_COLORSPACE_EXT);
}
}
usableConfigs = _glfw_calloc(nativeCount, sizeof(_GLFWfbconfig));
for (i = 0; i < nativeCount; i++)
{
_GLFWfbconfig* u = usableConfigs + usableCount;
pixelFormat = i + 1;
if (_glfw.wgl.ARB_pixel_format)
{
// Get pixel format attributes through "modern" extension
if (!wglGetPixelFormatAttribivARB(window->context.wgl.dc,
pixelFormat, 0,
attribCount,
attribs, values))
{
_glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
"WGL: Failed to retrieve pixel format attributes");
_glfw_free(usableConfigs);
return 0;
}
if (!FIND_ATTRIB_VALUE(WGL_SUPPORT_OPENGL_ARB) ||
!FIND_ATTRIB_VALUE(WGL_DRAW_TO_WINDOW_ARB))
{
continue;
}
if (FIND_ATTRIB_VALUE(WGL_PIXEL_TYPE_ARB) != WGL_TYPE_RGBA_ARB)
continue;
if (FIND_ATTRIB_VALUE(WGL_ACCELERATION_ARB) == WGL_NO_ACCELERATION_ARB)
continue;
if (FIND_ATTRIB_VALUE(WGL_DOUBLE_BUFFER_ARB) != fbconfig->doublebuffer)
continue;
u->redBits = FIND_ATTRIB_VALUE(WGL_RED_BITS_ARB);
u->greenBits = FIND_ATTRIB_VALUE(WGL_GREEN_BITS_ARB);
u->blueBits = FIND_ATTRIB_VALUE(WGL_BLUE_BITS_ARB);
u->alphaBits = FIND_ATTRIB_VALUE(WGL_ALPHA_BITS_ARB);
u->depthBits = FIND_ATTRIB_VALUE(WGL_DEPTH_BITS_ARB);
u->stencilBits = FIND_ATTRIB_VALUE(WGL_STENCIL_BITS_ARB);
u->accumRedBits = FIND_ATTRIB_VALUE(WGL_ACCUM_RED_BITS_ARB);
u->accumGreenBits = FIND_ATTRIB_VALUE(WGL_ACCUM_GREEN_BITS_ARB);
u->accumBlueBits = FIND_ATTRIB_VALUE(WGL_ACCUM_BLUE_BITS_ARB);
u->accumAlphaBits = FIND_ATTRIB_VALUE(WGL_ACCUM_ALPHA_BITS_ARB);
u->auxBuffers = FIND_ATTRIB_VALUE(WGL_AUX_BUFFERS_ARB);
if (FIND_ATTRIB_VALUE(WGL_STEREO_ARB))
u->stereo = GLFW_TRUE;
if (_glfw.wgl.ARB_multisample)
u->samples = FIND_ATTRIB_VALUE(WGL_SAMPLES_ARB);
if (ctxconfig->client == GLFW_OPENGL_API)
{
if (_glfw.wgl.ARB_framebuffer_sRGB ||
_glfw.wgl.EXT_framebuffer_sRGB)
{
if (FIND_ATTRIB_VALUE(WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB))
u->sRGB = GLFW_TRUE;
}
}
else
{
if (_glfw.wgl.EXT_colorspace)
{
if (FIND_ATTRIB_VALUE(WGL_COLORSPACE_EXT) == WGL_COLORSPACE_SRGB_EXT)
u->sRGB = GLFW_TRUE;
}
}
}
else
{
// Get pixel format attributes through legacy PFDs
PIXELFORMATDESCRIPTOR pfd;
if (!DescribePixelFormat(window->context.wgl.dc,
pixelFormat,
sizeof(PIXELFORMATDESCRIPTOR),
&pfd))
{
_glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
"WGL: Failed to describe pixel format");
_glfw_free(usableConfigs);
return 0;
}
if (!(pfd.dwFlags & PFD_DRAW_TO_WINDOW) ||
!(pfd.dwFlags & PFD_SUPPORT_OPENGL))
{
continue;
}
if (!(pfd.dwFlags & PFD_GENERIC_ACCELERATED) &&
(pfd.dwFlags & PFD_GENERIC_FORMAT))
{
continue;
}
if (pfd.iPixelType != PFD_TYPE_RGBA)
continue;
if (!!(pfd.dwFlags & PFD_DOUBLEBUFFER) != fbconfig->doublebuffer)
continue;
u->redBits = pfd.cRedBits;
u->greenBits = pfd.cGreenBits;
u->blueBits = pfd.cBlueBits;
u->alphaBits = pfd.cAlphaBits;
u->depthBits = pfd.cDepthBits;
u->stencilBits = pfd.cStencilBits;
u->accumRedBits = pfd.cAccumRedBits;
u->accumGreenBits = pfd.cAccumGreenBits;
u->accumBlueBits = pfd.cAccumBlueBits;
u->accumAlphaBits = pfd.cAccumAlphaBits;
u->auxBuffers = pfd.cAuxBuffers;
if (pfd.dwFlags & PFD_STEREO)
u->stereo = GLFW_TRUE;
}
u->handle = pixelFormat;
usableCount++;
}
if (!usableCount)
{
_glfwInputError(GLFW_API_UNAVAILABLE,
"WGL: The driver does not appear to support OpenGL");
_glfw_free(usableConfigs);
return 0;
}
closest = _glfwChooseFBConfig(fbconfig, usableConfigs, usableCount);
if (!closest)
{
_glfwInputError(GLFW_FORMAT_UNAVAILABLE,
"WGL: Failed to find a suitable pixel format");
_glfw_free(usableConfigs);
return 0;
}
pixelFormat = (int) closest->handle;
_glfw_free(usableConfigs);
return pixelFormat;
}
#undef ADD_ATTRIB
#undef FIND_ATTRIB_VALUE
static void makeContextCurrentWGL(_GLFWwindow* window)
{
if (window)
{
if (wglMakeCurrent(window->context.wgl.dc, window->context.wgl.handle))
_glfwPlatformSetTls(&_glfw.contextSlot, window);
else
{
_glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
"WGL: Failed to make context current");
_glfwPlatformSetTls(&_glfw.contextSlot, NULL);
}
}
else
{
if (!wglMakeCurrent(NULL, NULL))
{
_glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
"WGL: Failed to clear current context");
}
_glfwPlatformSetTls(&_glfw.contextSlot, NULL);
}
}
static void swapBuffersWGL(_GLFWwindow* window)
{
if (!window->monitor)
{
// HACK: Use DwmFlush when desktop composition is enabled on Windows Vista and 7
if (!IsWindows8OrGreater() && IsWindowsVistaOrGreater())
{
BOOL enabled = FALSE;
if (SUCCEEDED(DwmIsCompositionEnabled(&enabled)) && enabled)
{
int count = abs(window->context.wgl.interval);
while (count--)
DwmFlush();
}
}
}
SwapBuffers(window->context.wgl.dc);
}
static void swapIntervalWGL(int interval)
{
_GLFWwindow* window = _glfwPlatformGetTls(&_glfw.contextSlot);
window->context.wgl.interval = interval;
if (!window->monitor)
{
// HACK: Disable WGL swap interval when desktop composition is enabled on Windows
// Vista and 7 to avoid interfering with DWM vsync
if (!IsWindows8OrGreater() && IsWindowsVistaOrGreater())
{
BOOL enabled = FALSE;
if (SUCCEEDED(DwmIsCompositionEnabled(&enabled)) && enabled)
interval = 0;
}
}
if (_glfw.wgl.EXT_swap_control)
wglSwapIntervalEXT(interval);
}
static int extensionSupportedWGL(const char* extension)
{
const char* extensions = NULL;
if (_glfw.wgl.GetExtensionsStringARB)
extensions = wglGetExtensionsStringARB(wglGetCurrentDC());
else if (_glfw.wgl.GetExtensionsStringEXT)
extensions = wglGetExtensionsStringEXT();
if (!extensions)
return GLFW_FALSE;
return _glfwStringInExtensionString(extension, extensions);
}
static GLFWglproc getProcAddressWGL(const char* procname)
{
const GLFWglproc proc = (GLFWglproc) wglGetProcAddress(procname);
if (proc)
return proc;
return (GLFWglproc) _glfwPlatformGetModuleSymbol(_glfw.wgl.instance, procname);
}
static void destroyContextWGL(_GLFWwindow* window)
{
if (window->context.wgl.handle)
{
wglDeleteContext(window->context.wgl.handle);
window->context.wgl.handle = NULL;
}
}
// Initialize WGL
//
GLFWbool _glfwInitWGL(void)
{
PIXELFORMATDESCRIPTOR pfd;
HGLRC prc, rc;
HDC pdc, dc;
if (_glfw.wgl.instance)
return GLFW_TRUE;
_glfw.wgl.instance = _glfwPlatformLoadModule("opengl32.dll");
if (!_glfw.wgl.instance)
{
_glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
"WGL: Failed to load opengl32.dll");
return GLFW_FALSE;
}
_glfw.wgl.CreateContext = (PFN_wglCreateContext)
_glfwPlatformGetModuleSymbol(_glfw.wgl.instance, "wglCreateContext");
_glfw.wgl.DeleteContext = (PFN_wglDeleteContext)
_glfwPlatformGetModuleSymbol(_glfw.wgl.instance, "wglDeleteContext");
_glfw.wgl.GetProcAddress = (PFN_wglGetProcAddress)
_glfwPlatformGetModuleSymbol(_glfw.wgl.instance, "wglGetProcAddress");
_glfw.wgl.GetCurrentDC = (PFN_wglGetCurrentDC)
_glfwPlatformGetModuleSymbol(_glfw.wgl.instance, "wglGetCurrentDC");
_glfw.wgl.GetCurrentContext = (PFN_wglGetCurrentContext)
_glfwPlatformGetModuleSymbol(_glfw.wgl.instance, "wglGetCurrentContext");
_glfw.wgl.MakeCurrent = (PFN_wglMakeCurrent)
_glfwPlatformGetModuleSymbol(_glfw.wgl.instance, "wglMakeCurrent");
_glfw.wgl.ShareLists = (PFN_wglShareLists)
_glfwPlatformGetModuleSymbol(_glfw.wgl.instance, "wglShareLists");
// NOTE: A dummy context has to be created for opengl32.dll to load the
// OpenGL ICD, from which we can then query WGL extensions
// NOTE: This code will accept the Microsoft GDI ICD; accelerated context
// creation failure occurs during manual pixel format enumeration
dc = GetDC(_glfw.win32.helperWindowHandle);
ZeroMemory(&pfd, sizeof(pfd));
pfd.nSize = sizeof(pfd);
pfd.nVersion = 1;
pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
pfd.iPixelType = PFD_TYPE_RGBA;
pfd.cColorBits = 24;
if (!SetPixelFormat(dc, ChoosePixelFormat(dc, &pfd), &pfd))
{
_glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
"WGL: Failed to set pixel format for dummy context");
return GLFW_FALSE;
}
rc = wglCreateContext(dc);
if (!rc)
{
_glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
"WGL: Failed to create dummy context");
return GLFW_FALSE;
}
pdc = wglGetCurrentDC();
prc = wglGetCurrentContext();
if (!wglMakeCurrent(dc, rc))
{
_glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
"WGL: Failed to make dummy context current");
wglMakeCurrent(pdc, prc);
wglDeleteContext(rc);
return GLFW_FALSE;
}
// NOTE: Functions must be loaded first as they're needed to retrieve the
// extension string that tells us whether the functions are supported
_glfw.wgl.GetExtensionsStringEXT = (PFNWGLGETEXTENSIONSSTRINGEXTPROC)
wglGetProcAddress("wglGetExtensionsStringEXT");
_glfw.wgl.GetExtensionsStringARB = (PFNWGLGETEXTENSIONSSTRINGARBPROC)
wglGetProcAddress("wglGetExtensionsStringARB");
_glfw.wgl.CreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC)
wglGetProcAddress("wglCreateContextAttribsARB");
_glfw.wgl.SwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC)
wglGetProcAddress("wglSwapIntervalEXT");
_glfw.wgl.GetPixelFormatAttribivARB = (PFNWGLGETPIXELFORMATATTRIBIVARBPROC)
wglGetProcAddress("wglGetPixelFormatAttribivARB");
// NOTE: WGL_ARB_extensions_string and WGL_EXT_extensions_string are not
// checked below as we are already using them
_glfw.wgl.ARB_multisample =
extensionSupportedWGL("WGL_ARB_multisample");
_glfw.wgl.ARB_framebuffer_sRGB =
extensionSupportedWGL("WGL_ARB_framebuffer_sRGB");
_glfw.wgl.EXT_framebuffer_sRGB =
extensionSupportedWGL("WGL_EXT_framebuffer_sRGB");
_glfw.wgl.ARB_create_context =
extensionSupportedWGL("WGL_ARB_create_context");
_glfw.wgl.ARB_create_context_profile =
extensionSupportedWGL("WGL_ARB_create_context_profile");
_glfw.wgl.EXT_create_context_es2_profile =
extensionSupportedWGL("WGL_EXT_create_context_es2_profile");
_glfw.wgl.ARB_create_context_robustness =
extensionSupportedWGL("WGL_ARB_create_context_robustness");
_glfw.wgl.ARB_create_context_no_error =
extensionSupportedWGL("WGL_ARB_create_context_no_error");
_glfw.wgl.EXT_swap_control =
extensionSupportedWGL("WGL_EXT_swap_control");
_glfw.wgl.EXT_colorspace =
extensionSupportedWGL("WGL_EXT_colorspace");
_glfw.wgl.ARB_pixel_format =
extensionSupportedWGL("WGL_ARB_pixel_format");
_glfw.wgl.ARB_context_flush_control =
extensionSupportedWGL("WGL_ARB_context_flush_control");
wglMakeCurrent(pdc, prc);
wglDeleteContext(rc);
return GLFW_TRUE;
}
// Terminate WGL
//
void _glfwTerminateWGL(void)
{
if (_glfw.wgl.instance)
_glfwPlatformFreeModule(_glfw.wgl.instance);
}
#define SET_ATTRIB(a, v) \
{ \
assert(((size_t) index + 1) < sizeof(attribs) / sizeof(attribs[0])); \
attribs[index++] = a; \
attribs[index++] = v; \
}
// Create the OpenGL or OpenGL ES context
//
GLFWbool _glfwCreateContextWGL(_GLFWwindow* window,
const _GLFWctxconfig* ctxconfig,
const _GLFWfbconfig* fbconfig)
{
int attribs[40];
int pixelFormat;
PIXELFORMATDESCRIPTOR pfd;
HGLRC share = NULL;
if (ctxconfig->share)
share = ctxconfig->share->context.wgl.handle;
window->context.wgl.dc = GetDC(window->win32.handle);
if (!window->context.wgl.dc)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"WGL: Failed to retrieve DC for window");
return GLFW_FALSE;
}
pixelFormat = choosePixelFormatWGL(window, ctxconfig, fbconfig);
if (!pixelFormat)
return GLFW_FALSE;
if (!DescribePixelFormat(window->context.wgl.dc,
pixelFormat, sizeof(pfd), &pfd))
{
_glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
"WGL: Failed to retrieve PFD for selected pixel format");
return GLFW_FALSE;
}
if (!SetPixelFormat(window->context.wgl.dc, pixelFormat, &pfd))
{
_glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
"WGL: Failed to set selected pixel format");
return GLFW_FALSE;
}
if (ctxconfig->client == GLFW_OPENGL_API)
{
if (ctxconfig->forward)
{
if (!_glfw.wgl.ARB_create_context)
{
_glfwInputError(GLFW_VERSION_UNAVAILABLE,
"WGL: A forward compatible OpenGL context requested but WGL_ARB_create_context is unavailable");
return GLFW_FALSE;
}
}
if (ctxconfig->profile)
{
if (!_glfw.wgl.ARB_create_context_profile)
{
_glfwInputError(GLFW_VERSION_UNAVAILABLE,
"WGL: OpenGL profile requested but WGL_ARB_create_context_profile is unavailable");
return GLFW_FALSE;
}
}
}
else
{
if (!_glfw.wgl.ARB_create_context ||
!_glfw.wgl.ARB_create_context_profile ||
!_glfw.wgl.EXT_create_context_es2_profile)
{
_glfwInputError(GLFW_API_UNAVAILABLE,
"WGL: OpenGL ES requested but WGL_ARB_create_context_es2_profile is unavailable");
return GLFW_FALSE;
}
}
if (_glfw.wgl.ARB_create_context)
{
int index = 0, mask = 0, flags = 0;
if (ctxconfig->client == GLFW_OPENGL_API)
{
if (ctxconfig->forward)
flags |= WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB;
if (ctxconfig->profile == GLFW_OPENGL_CORE_PROFILE)
mask |= WGL_CONTEXT_CORE_PROFILE_BIT_ARB;
else if (ctxconfig->profile == GLFW_OPENGL_COMPAT_PROFILE)
mask |= WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB;
}
else
mask |= WGL_CONTEXT_ES2_PROFILE_BIT_EXT;
if (ctxconfig->debug)
flags |= WGL_CONTEXT_DEBUG_BIT_ARB;
if (ctxconfig->robustness)
{
if (_glfw.wgl.ARB_create_context_robustness)
{
if (ctxconfig->robustness == GLFW_NO_RESET_NOTIFICATION)
{
SET_ATTRIB(WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB,
WGL_NO_RESET_NOTIFICATION_ARB);
}
else if (ctxconfig->robustness == GLFW_LOSE_CONTEXT_ON_RESET)
{
SET_ATTRIB(WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB,
WGL_LOSE_CONTEXT_ON_RESET_ARB);
}
flags |= WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB;
}
}
if (ctxconfig->release)
{
if (_glfw.wgl.ARB_context_flush_control)
{
if (ctxconfig->release == GLFW_RELEASE_BEHAVIOR_NONE)
{
SET_ATTRIB(WGL_CONTEXT_RELEASE_BEHAVIOR_ARB,
WGL_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB);
}
else if (ctxconfig->release == GLFW_RELEASE_BEHAVIOR_FLUSH)
{
SET_ATTRIB(WGL_CONTEXT_RELEASE_BEHAVIOR_ARB,
WGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB);
}
}
}
if (ctxconfig->noerror)
{
if (_glfw.wgl.ARB_create_context_no_error)
SET_ATTRIB(WGL_CONTEXT_OPENGL_NO_ERROR_ARB, GLFW_TRUE);
}
// NOTE: Only request an explicitly versioned context when necessary, as
// explicitly requesting version 1.0 does not always return the
// highest version supported by the driver
if (ctxconfig->major != 1 || ctxconfig->minor != 0)
{
SET_ATTRIB(WGL_CONTEXT_MAJOR_VERSION_ARB, ctxconfig->major);
SET_ATTRIB(WGL_CONTEXT_MINOR_VERSION_ARB, ctxconfig->minor);
}
if (flags)
SET_ATTRIB(WGL_CONTEXT_FLAGS_ARB, flags);
if (mask)
SET_ATTRIB(WGL_CONTEXT_PROFILE_MASK_ARB, mask);
SET_ATTRIB(0, 0);
window->context.wgl.handle =
wglCreateContextAttribsARB(window->context.wgl.dc, share, attribs);
if (!window->context.wgl.handle)
{
const DWORD error = GetLastError();
if (error == (0xc0070000 | ERROR_INVALID_VERSION_ARB))
{
if (ctxconfig->client == GLFW_OPENGL_API)
{
_glfwInputError(GLFW_VERSION_UNAVAILABLE,
"WGL: Driver does not support OpenGL version %i.%i",
ctxconfig->major,
ctxconfig->minor);
}
else
{
_glfwInputError(GLFW_VERSION_UNAVAILABLE,
"WGL: Driver does not support OpenGL ES version %i.%i",
ctxconfig->major,
ctxconfig->minor);
}
}
else if (error == (0xc0070000 | ERROR_INVALID_PROFILE_ARB))
{
_glfwInputError(GLFW_VERSION_UNAVAILABLE,
"WGL: Driver does not support the requested OpenGL profile");
}
else if (error == (0xc0070000 | ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB))
{
_glfwInputError(GLFW_INVALID_VALUE,
"WGL: The share context is not compatible with the requested context");
}
else
{
if (ctxconfig->client == GLFW_OPENGL_API)
{
_glfwInputError(GLFW_VERSION_UNAVAILABLE,
"WGL: Failed to create OpenGL context");
}
else
{
_glfwInputError(GLFW_VERSION_UNAVAILABLE,
"WGL: Failed to create OpenGL ES context");
}
}
return GLFW_FALSE;
}
}
else
{
window->context.wgl.handle = wglCreateContext(window->context.wgl.dc);
if (!window->context.wgl.handle)
{
_glfwInputErrorWin32(GLFW_VERSION_UNAVAILABLE,
"WGL: Failed to create OpenGL context");
return GLFW_FALSE;
}
if (share)
{
if (!wglShareLists(share, window->context.wgl.handle))
{
_glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
"WGL: Failed to enable sharing with specified OpenGL context");
return GLFW_FALSE;
}
}
}
window->context.makeCurrent = makeContextCurrentWGL;
window->context.swapBuffers = swapBuffersWGL;
window->context.swapInterval = swapIntervalWGL;
window->context.extensionSupported = extensionSupportedWGL;
window->context.getProcAddress = getProcAddressWGL;
window->context.destroy = destroyContextWGL;
return GLFW_TRUE;
}
#undef SET_ATTRIB
GLFWAPI HGLRC glfwGetWGLContext(GLFWwindow* handle)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
if (_glfw.platform.platformID != GLFW_PLATFORM_WIN32)
{
_glfwInputError(GLFW_PLATFORM_UNAVAILABLE,
"WGL: Platform not initialized");
return NULL;
}
if (window->context.source != GLFW_NATIVE_CONTEXT_API)
{
_glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL);
return NULL;
}
return window->context.wgl.handle;
}

View File

@@ -0,0 +1,727 @@
//========================================================================
// GLFW 3.4 Win32 - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would
// be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such, and must not
// be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source
// distribution.
//
//========================================================================
// Please use C89 style variable declarations in this file because VS 2010
//========================================================================
#include "internal.h"
#include <stdlib.h>
static const GUID _glfw_GUID_DEVINTERFACE_HID =
{0x4d1e55b2,0xf16f,0x11cf,{0x88,0xcb,0x00,0x11,0x11,0x00,0x00,0x30}};
#define GUID_DEVINTERFACE_HID _glfw_GUID_DEVINTERFACE_HID
#if defined(_GLFW_USE_HYBRID_HPG) || defined(_GLFW_USE_OPTIMUS_HPG)
#if defined(_GLFW_BUILD_DLL)
#pragma message("These symbols must be exported by the executable and have no effect in a DLL")
#endif
// Executables (but not DLLs) exporting this symbol with this value will be
// automatically directed to the high-performance GPU on Nvidia Optimus systems
// with up-to-date drivers
//
__declspec(dllexport) DWORD NvOptimusEnablement = 1;
// Executables (but not DLLs) exporting this symbol with this value will be
// automatically directed to the high-performance GPU on AMD PowerXpress systems
// with up-to-date drivers
//
__declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1;
#endif // _GLFW_USE_HYBRID_HPG
#if defined(_GLFW_BUILD_DLL)
// GLFW DLL entry point
//
BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID reserved)
{
return TRUE;
}
#endif // _GLFW_BUILD_DLL
// Load necessary libraries (DLLs)
//
static GLFWbool loadLibraries(void)
{
if (!GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS |
GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
(const WCHAR*) &_glfw,
(HMODULE*) &_glfw.win32.instance))
{
_glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
"Win32: Failed to retrieve own module handle");
return GLFW_FALSE;
}
_glfw.win32.user32.instance = _glfwPlatformLoadModule("user32.dll");
if (!_glfw.win32.user32.instance)
{
_glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
"Win32: Failed to load user32.dll");
return GLFW_FALSE;
}
_glfw.win32.user32.SetProcessDPIAware_ = (PFN_SetProcessDPIAware)
_glfwPlatformGetModuleSymbol(_glfw.win32.user32.instance, "SetProcessDPIAware");
_glfw.win32.user32.ChangeWindowMessageFilterEx_ = (PFN_ChangeWindowMessageFilterEx)
_glfwPlatformGetModuleSymbol(_glfw.win32.user32.instance, "ChangeWindowMessageFilterEx");
_glfw.win32.user32.EnableNonClientDpiScaling_ = (PFN_EnableNonClientDpiScaling)
_glfwPlatformGetModuleSymbol(_glfw.win32.user32.instance, "EnableNonClientDpiScaling");
_glfw.win32.user32.SetProcessDpiAwarenessContext_ = (PFN_SetProcessDpiAwarenessContext)
_glfwPlatformGetModuleSymbol(_glfw.win32.user32.instance, "SetProcessDpiAwarenessContext");
_glfw.win32.user32.GetDpiForWindow_ = (PFN_GetDpiForWindow)
_glfwPlatformGetModuleSymbol(_glfw.win32.user32.instance, "GetDpiForWindow");
_glfw.win32.user32.AdjustWindowRectExForDpi_ = (PFN_AdjustWindowRectExForDpi)
_glfwPlatformGetModuleSymbol(_glfw.win32.user32.instance, "AdjustWindowRectExForDpi");
_glfw.win32.user32.GetSystemMetricsForDpi_ = (PFN_GetSystemMetricsForDpi)
_glfwPlatformGetModuleSymbol(_glfw.win32.user32.instance, "GetSystemMetricsForDpi");
_glfw.win32.dinput8.instance = _glfwPlatformLoadModule("dinput8.dll");
if (_glfw.win32.dinput8.instance)
{
_glfw.win32.dinput8.Create = (PFN_DirectInput8Create)
_glfwPlatformGetModuleSymbol(_glfw.win32.dinput8.instance, "DirectInput8Create");
}
{
int i;
const char* names[] =
{
"xinput1_4.dll",
"xinput1_3.dll",
"xinput9_1_0.dll",
"xinput1_2.dll",
"xinput1_1.dll",
NULL
};
for (i = 0; names[i]; i++)
{
_glfw.win32.xinput.instance = _glfwPlatformLoadModule(names[i]);
if (_glfw.win32.xinput.instance)
{
_glfw.win32.xinput.GetCapabilities = (PFN_XInputGetCapabilities)
_glfwPlatformGetModuleSymbol(_glfw.win32.xinput.instance, "XInputGetCapabilities");
_glfw.win32.xinput.GetState = (PFN_XInputGetState)
_glfwPlatformGetModuleSymbol(_glfw.win32.xinput.instance, "XInputGetState");
break;
}
}
}
_glfw.win32.dwmapi.instance = _glfwPlatformLoadModule("dwmapi.dll");
if (_glfw.win32.dwmapi.instance)
{
_glfw.win32.dwmapi.IsCompositionEnabled = (PFN_DwmIsCompositionEnabled)
_glfwPlatformGetModuleSymbol(_glfw.win32.dwmapi.instance, "DwmIsCompositionEnabled");
_glfw.win32.dwmapi.Flush = (PFN_DwmFlush)
_glfwPlatformGetModuleSymbol(_glfw.win32.dwmapi.instance, "DwmFlush");
_glfw.win32.dwmapi.EnableBlurBehindWindow = (PFN_DwmEnableBlurBehindWindow)
_glfwPlatformGetModuleSymbol(_glfw.win32.dwmapi.instance, "DwmEnableBlurBehindWindow");
_glfw.win32.dwmapi.GetColorizationColor = (PFN_DwmGetColorizationColor)
_glfwPlatformGetModuleSymbol(_glfw.win32.dwmapi.instance, "DwmGetColorizationColor");
}
_glfw.win32.shcore.instance = _glfwPlatformLoadModule("shcore.dll");
if (_glfw.win32.shcore.instance)
{
_glfw.win32.shcore.SetProcessDpiAwareness_ = (PFN_SetProcessDpiAwareness)
_glfwPlatformGetModuleSymbol(_glfw.win32.shcore.instance, "SetProcessDpiAwareness");
_glfw.win32.shcore.GetDpiForMonitor_ = (PFN_GetDpiForMonitor)
_glfwPlatformGetModuleSymbol(_glfw.win32.shcore.instance, "GetDpiForMonitor");
}
_glfw.win32.ntdll.instance = _glfwPlatformLoadModule("ntdll.dll");
if (_glfw.win32.ntdll.instance)
{
_glfw.win32.ntdll.RtlVerifyVersionInfo_ = (PFN_RtlVerifyVersionInfo)
_glfwPlatformGetModuleSymbol(_glfw.win32.ntdll.instance, "RtlVerifyVersionInfo");
}
return GLFW_TRUE;
}
// Unload used libraries (DLLs)
//
static void freeLibraries(void)
{
if (_glfw.win32.xinput.instance)
_glfwPlatformFreeModule(_glfw.win32.xinput.instance);
if (_glfw.win32.dinput8.instance)
_glfwPlatformFreeModule(_glfw.win32.dinput8.instance);
if (_glfw.win32.user32.instance)
_glfwPlatformFreeModule(_glfw.win32.user32.instance);
if (_glfw.win32.dwmapi.instance)
_glfwPlatformFreeModule(_glfw.win32.dwmapi.instance);
if (_glfw.win32.shcore.instance)
_glfwPlatformFreeModule(_glfw.win32.shcore.instance);
if (_glfw.win32.ntdll.instance)
_glfwPlatformFreeModule(_glfw.win32.ntdll.instance);
}
// Create key code translation tables
//
static void createKeyTables(void)
{
int scancode;
memset(_glfw.win32.keycodes, -1, sizeof(_glfw.win32.keycodes));
memset(_glfw.win32.scancodes, -1, sizeof(_glfw.win32.scancodes));
_glfw.win32.keycodes[0x00B] = GLFW_KEY_0;
_glfw.win32.keycodes[0x002] = GLFW_KEY_1;
_glfw.win32.keycodes[0x003] = GLFW_KEY_2;
_glfw.win32.keycodes[0x004] = GLFW_KEY_3;
_glfw.win32.keycodes[0x005] = GLFW_KEY_4;
_glfw.win32.keycodes[0x006] = GLFW_KEY_5;
_glfw.win32.keycodes[0x007] = GLFW_KEY_6;
_glfw.win32.keycodes[0x008] = GLFW_KEY_7;
_glfw.win32.keycodes[0x009] = GLFW_KEY_8;
_glfw.win32.keycodes[0x00A] = GLFW_KEY_9;
_glfw.win32.keycodes[0x01E] = GLFW_KEY_A;
_glfw.win32.keycodes[0x030] = GLFW_KEY_B;
_glfw.win32.keycodes[0x02E] = GLFW_KEY_C;
_glfw.win32.keycodes[0x020] = GLFW_KEY_D;
_glfw.win32.keycodes[0x012] = GLFW_KEY_E;
_glfw.win32.keycodes[0x021] = GLFW_KEY_F;
_glfw.win32.keycodes[0x022] = GLFW_KEY_G;
_glfw.win32.keycodes[0x023] = GLFW_KEY_H;
_glfw.win32.keycodes[0x017] = GLFW_KEY_I;
_glfw.win32.keycodes[0x024] = GLFW_KEY_J;
_glfw.win32.keycodes[0x025] = GLFW_KEY_K;
_glfw.win32.keycodes[0x026] = GLFW_KEY_L;
_glfw.win32.keycodes[0x032] = GLFW_KEY_M;
_glfw.win32.keycodes[0x031] = GLFW_KEY_N;
_glfw.win32.keycodes[0x018] = GLFW_KEY_O;
_glfw.win32.keycodes[0x019] = GLFW_KEY_P;
_glfw.win32.keycodes[0x010] = GLFW_KEY_Q;
_glfw.win32.keycodes[0x013] = GLFW_KEY_R;
_glfw.win32.keycodes[0x01F] = GLFW_KEY_S;
_glfw.win32.keycodes[0x014] = GLFW_KEY_T;
_glfw.win32.keycodes[0x016] = GLFW_KEY_U;
_glfw.win32.keycodes[0x02F] = GLFW_KEY_V;
_glfw.win32.keycodes[0x011] = GLFW_KEY_W;
_glfw.win32.keycodes[0x02D] = GLFW_KEY_X;
_glfw.win32.keycodes[0x015] = GLFW_KEY_Y;
_glfw.win32.keycodes[0x02C] = GLFW_KEY_Z;
_glfw.win32.keycodes[0x028] = GLFW_KEY_APOSTROPHE;
_glfw.win32.keycodes[0x02B] = GLFW_KEY_BACKSLASH;
_glfw.win32.keycodes[0x033] = GLFW_KEY_COMMA;
_glfw.win32.keycodes[0x00D] = GLFW_KEY_EQUAL;
_glfw.win32.keycodes[0x029] = GLFW_KEY_GRAVE_ACCENT;
_glfw.win32.keycodes[0x01A] = GLFW_KEY_LEFT_BRACKET;
_glfw.win32.keycodes[0x00C] = GLFW_KEY_MINUS;
_glfw.win32.keycodes[0x034] = GLFW_KEY_PERIOD;
_glfw.win32.keycodes[0x01B] = GLFW_KEY_RIGHT_BRACKET;
_glfw.win32.keycodes[0x027] = GLFW_KEY_SEMICOLON;
_glfw.win32.keycodes[0x035] = GLFW_KEY_SLASH;
_glfw.win32.keycodes[0x056] = GLFW_KEY_WORLD_2;
_glfw.win32.keycodes[0x00E] = GLFW_KEY_BACKSPACE;
_glfw.win32.keycodes[0x153] = GLFW_KEY_DELETE;
_glfw.win32.keycodes[0x14F] = GLFW_KEY_END;
_glfw.win32.keycodes[0x01C] = GLFW_KEY_ENTER;
_glfw.win32.keycodes[0x001] = GLFW_KEY_ESCAPE;
_glfw.win32.keycodes[0x147] = GLFW_KEY_HOME;
_glfw.win32.keycodes[0x152] = GLFW_KEY_INSERT;
_glfw.win32.keycodes[0x15D] = GLFW_KEY_MENU;
_glfw.win32.keycodes[0x151] = GLFW_KEY_PAGE_DOWN;
_glfw.win32.keycodes[0x149] = GLFW_KEY_PAGE_UP;
_glfw.win32.keycodes[0x045] = GLFW_KEY_PAUSE;
_glfw.win32.keycodes[0x039] = GLFW_KEY_SPACE;
_glfw.win32.keycodes[0x00F] = GLFW_KEY_TAB;
_glfw.win32.keycodes[0x03A] = GLFW_KEY_CAPS_LOCK;
_glfw.win32.keycodes[0x145] = GLFW_KEY_NUM_LOCK;
_glfw.win32.keycodes[0x046] = GLFW_KEY_SCROLL_LOCK;
_glfw.win32.keycodes[0x03B] = GLFW_KEY_F1;
_glfw.win32.keycodes[0x03C] = GLFW_KEY_F2;
_glfw.win32.keycodes[0x03D] = GLFW_KEY_F3;
_glfw.win32.keycodes[0x03E] = GLFW_KEY_F4;
_glfw.win32.keycodes[0x03F] = GLFW_KEY_F5;
_glfw.win32.keycodes[0x040] = GLFW_KEY_F6;
_glfw.win32.keycodes[0x041] = GLFW_KEY_F7;
_glfw.win32.keycodes[0x042] = GLFW_KEY_F8;
_glfw.win32.keycodes[0x043] = GLFW_KEY_F9;
_glfw.win32.keycodes[0x044] = GLFW_KEY_F10;
_glfw.win32.keycodes[0x057] = GLFW_KEY_F11;
_glfw.win32.keycodes[0x058] = GLFW_KEY_F12;
_glfw.win32.keycodes[0x064] = GLFW_KEY_F13;
_glfw.win32.keycodes[0x065] = GLFW_KEY_F14;
_glfw.win32.keycodes[0x066] = GLFW_KEY_F15;
_glfw.win32.keycodes[0x067] = GLFW_KEY_F16;
_glfw.win32.keycodes[0x068] = GLFW_KEY_F17;
_glfw.win32.keycodes[0x069] = GLFW_KEY_F18;
_glfw.win32.keycodes[0x06A] = GLFW_KEY_F19;
_glfw.win32.keycodes[0x06B] = GLFW_KEY_F20;
_glfw.win32.keycodes[0x06C] = GLFW_KEY_F21;
_glfw.win32.keycodes[0x06D] = GLFW_KEY_F22;
_glfw.win32.keycodes[0x06E] = GLFW_KEY_F23;
_glfw.win32.keycodes[0x076] = GLFW_KEY_F24;
_glfw.win32.keycodes[0x038] = GLFW_KEY_LEFT_ALT;
_glfw.win32.keycodes[0x01D] = GLFW_KEY_LEFT_CONTROL;
_glfw.win32.keycodes[0x02A] = GLFW_KEY_LEFT_SHIFT;
_glfw.win32.keycodes[0x15B] = GLFW_KEY_LEFT_SUPER;
_glfw.win32.keycodes[0x137] = GLFW_KEY_PRINT_SCREEN;
_glfw.win32.keycodes[0x138] = GLFW_KEY_RIGHT_ALT;
_glfw.win32.keycodes[0x11D] = GLFW_KEY_RIGHT_CONTROL;
_glfw.win32.keycodes[0x036] = GLFW_KEY_RIGHT_SHIFT;
_glfw.win32.keycodes[0x15C] = GLFW_KEY_RIGHT_SUPER;
_glfw.win32.keycodes[0x150] = GLFW_KEY_DOWN;
_glfw.win32.keycodes[0x14B] = GLFW_KEY_LEFT;
_glfw.win32.keycodes[0x14D] = GLFW_KEY_RIGHT;
_glfw.win32.keycodes[0x148] = GLFW_KEY_UP;
_glfw.win32.keycodes[0x052] = GLFW_KEY_KP_0;
_glfw.win32.keycodes[0x04F] = GLFW_KEY_KP_1;
_glfw.win32.keycodes[0x050] = GLFW_KEY_KP_2;
_glfw.win32.keycodes[0x051] = GLFW_KEY_KP_3;
_glfw.win32.keycodes[0x04B] = GLFW_KEY_KP_4;
_glfw.win32.keycodes[0x04C] = GLFW_KEY_KP_5;
_glfw.win32.keycodes[0x04D] = GLFW_KEY_KP_6;
_glfw.win32.keycodes[0x047] = GLFW_KEY_KP_7;
_glfw.win32.keycodes[0x048] = GLFW_KEY_KP_8;
_glfw.win32.keycodes[0x049] = GLFW_KEY_KP_9;
_glfw.win32.keycodes[0x04E] = GLFW_KEY_KP_ADD;
_glfw.win32.keycodes[0x053] = GLFW_KEY_KP_DECIMAL;
_glfw.win32.keycodes[0x135] = GLFW_KEY_KP_DIVIDE;
_glfw.win32.keycodes[0x11C] = GLFW_KEY_KP_ENTER;
_glfw.win32.keycodes[0x059] = GLFW_KEY_KP_EQUAL;
_glfw.win32.keycodes[0x037] = GLFW_KEY_KP_MULTIPLY;
_glfw.win32.keycodes[0x04A] = GLFW_KEY_KP_SUBTRACT;
for (scancode = 0; scancode < 512; scancode++)
{
if (_glfw.win32.keycodes[scancode] > 0)
_glfw.win32.scancodes[_glfw.win32.keycodes[scancode]] = scancode;
}
}
// Window procedure for the hidden helper window
//
static LRESULT CALLBACK helperWindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg)
{
case WM_DISPLAYCHANGE:
_glfwPollMonitorsWin32();
break;
case WM_DEVICECHANGE:
{
if (!_glfw.joysticksInitialized)
break;
if (wParam == DBT_DEVICEARRIVAL)
{
DEV_BROADCAST_HDR* dbh = (DEV_BROADCAST_HDR*) lParam;
if (dbh && dbh->dbch_devicetype == DBT_DEVTYP_DEVICEINTERFACE)
_glfwDetectJoystickConnectionWin32();
}
else if (wParam == DBT_DEVICEREMOVECOMPLETE)
{
DEV_BROADCAST_HDR* dbh = (DEV_BROADCAST_HDR*) lParam;
if (dbh && dbh->dbch_devicetype == DBT_DEVTYP_DEVICEINTERFACE)
_glfwDetectJoystickDisconnectionWin32();
}
break;
}
}
return DefWindowProcW(hWnd, uMsg, wParam, lParam);
}
// Creates a dummy window for behind-the-scenes work
//
static GLFWbool createHelperWindow(void)
{
MSG msg;
WNDCLASSEXW wc = { sizeof(wc) };
wc.style = CS_OWNDC;
wc.lpfnWndProc = (WNDPROC) helperWindowProc;
wc.hInstance = _glfw.win32.instance;
wc.lpszClassName = L"GLFW3 Helper";
_glfw.win32.helperWindowClass = RegisterClassExW(&wc);
if (!_glfw.win32.helperWindowClass)
{
_glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
"WIn32: Failed to register helper window class");
return GLFW_FALSE;
}
_glfw.win32.helperWindowHandle =
CreateWindowExW(WS_EX_OVERLAPPEDWINDOW,
MAKEINTATOM(_glfw.win32.helperWindowClass),
L"GLFW message window",
WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
0, 0, 1, 1,
NULL, NULL,
_glfw.win32.instance,
NULL);
if (!_glfw.win32.helperWindowHandle)
{
_glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
"Win32: Failed to create helper window");
return GLFW_FALSE;
}
// HACK: The command to the first ShowWindow call is ignored if the parent
// process passed along a STARTUPINFO, so clear that with a no-op call
ShowWindow(_glfw.win32.helperWindowHandle, SW_HIDE);
// Register for HID device notifications
{
DEV_BROADCAST_DEVICEINTERFACE_W dbi;
ZeroMemory(&dbi, sizeof(dbi));
dbi.dbcc_size = sizeof(dbi);
dbi.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE;
dbi.dbcc_classguid = GUID_DEVINTERFACE_HID;
_glfw.win32.deviceNotificationHandle =
RegisterDeviceNotificationW(_glfw.win32.helperWindowHandle,
(DEV_BROADCAST_HDR*) &dbi,
DEVICE_NOTIFY_WINDOW_HANDLE);
}
while (PeekMessageW(&msg, _glfw.win32.helperWindowHandle, 0, 0, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessageW(&msg);
}
return GLFW_TRUE;
}
//////////////////////////////////////////////////////////////////////////
////// GLFW internal API //////
//////////////////////////////////////////////////////////////////////////
// Returns a wide string version of the specified UTF-8 string
//
WCHAR* _glfwCreateWideStringFromUTF8Win32(const char* source)
{
WCHAR* target;
int count;
count = MultiByteToWideChar(CP_UTF8, 0, source, -1, NULL, 0);
if (!count)
{
_glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
"Win32: Failed to convert string from UTF-8");
return NULL;
}
target = _glfw_calloc(count, sizeof(WCHAR));
if (!MultiByteToWideChar(CP_UTF8, 0, source, -1, target, count))
{
_glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
"Win32: Failed to convert string from UTF-8");
_glfw_free(target);
return NULL;
}
return target;
}
// Returns a UTF-8 string version of the specified wide string
//
char* _glfwCreateUTF8FromWideStringWin32(const WCHAR* source)
{
char* target;
int size;
size = WideCharToMultiByte(CP_UTF8, 0, source, -1, NULL, 0, NULL, NULL);
if (!size)
{
_glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
"Win32: Failed to convert string to UTF-8");
return NULL;
}
target = _glfw_calloc(size, 1);
if (!WideCharToMultiByte(CP_UTF8, 0, source, -1, target, size, NULL, NULL))
{
_glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
"Win32: Failed to convert string to UTF-8");
_glfw_free(target);
return NULL;
}
return target;
}
// Reports the specified error, appending information about the last Win32 error
//
void _glfwInputErrorWin32(int error, const char* description)
{
WCHAR buffer[_GLFW_MESSAGE_SIZE] = L"";
char message[_GLFW_MESSAGE_SIZE] = "";
FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS |
FORMAT_MESSAGE_MAX_WIDTH_MASK,
NULL,
GetLastError() & 0xffff,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
buffer,
sizeof(buffer) / sizeof(WCHAR),
NULL);
WideCharToMultiByte(CP_UTF8, 0, buffer, -1, message, sizeof(message), NULL, NULL);
_glfwInputError(error, "%s: %s", description, message);
}
// Updates key names according to the current keyboard layout
//
void _glfwUpdateKeyNamesWin32(void)
{
int key;
BYTE state[256] = {0};
memset(_glfw.win32.keynames, 0, sizeof(_glfw.win32.keynames));
for (key = GLFW_KEY_SPACE; key <= GLFW_KEY_LAST; key++)
{
UINT vk;
int scancode, length;
WCHAR chars[16];
scancode = _glfw.win32.scancodes[key];
if (scancode == -1)
continue;
if (key >= GLFW_KEY_KP_0 && key <= GLFW_KEY_KP_ADD)
{
const UINT vks[] = {
VK_NUMPAD0, VK_NUMPAD1, VK_NUMPAD2, VK_NUMPAD3,
VK_NUMPAD4, VK_NUMPAD5, VK_NUMPAD6, VK_NUMPAD7,
VK_NUMPAD8, VK_NUMPAD9, VK_DECIMAL, VK_DIVIDE,
VK_MULTIPLY, VK_SUBTRACT, VK_ADD
};
vk = vks[key - GLFW_KEY_KP_0];
}
else
vk = MapVirtualKeyW(scancode, MAPVK_VSC_TO_VK);
length = ToUnicode(vk, scancode, state,
chars, sizeof(chars) / sizeof(WCHAR),
0);
if (length == -1)
{
// This is a dead key, so we need a second simulated key press
// to make it output its own character (usually a diacritic)
length = ToUnicode(vk, scancode, state,
chars, sizeof(chars) / sizeof(WCHAR),
0);
}
if (length < 1)
continue;
WideCharToMultiByte(CP_UTF8, 0, chars, 1,
_glfw.win32.keynames[key],
sizeof(_glfw.win32.keynames[key]),
NULL, NULL);
}
}
// Replacement for IsWindowsVersionOrGreater, as we cannot rely on the
// application having a correct embedded manifest
//
BOOL _glfwIsWindowsVersionOrGreaterWin32(WORD major, WORD minor, WORD sp)
{
OSVERSIONINFOEXW osvi = { sizeof(osvi), major, minor, 0, 0, {0}, sp };
DWORD mask = VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR;
ULONGLONG cond = VerSetConditionMask(0, VER_MAJORVERSION, VER_GREATER_EQUAL);
cond = VerSetConditionMask(cond, VER_MINORVERSION, VER_GREATER_EQUAL);
cond = VerSetConditionMask(cond, VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL);
// HACK: Use RtlVerifyVersionInfo instead of VerifyVersionInfoW as the
// latter lies unless the user knew to embed a non-default manifest
// announcing support for Windows 10 via supportedOS GUID
return RtlVerifyVersionInfo(&osvi, mask, cond) == 0;
}
// Checks whether we are on at least the specified build of Windows 10
//
BOOL _glfwIsWindows10BuildOrGreaterWin32(WORD build)
{
OSVERSIONINFOEXW osvi = { sizeof(osvi), 10, 0, build };
DWORD mask = VER_MAJORVERSION | VER_MINORVERSION | VER_BUILDNUMBER;
ULONGLONG cond = VerSetConditionMask(0, VER_MAJORVERSION, VER_GREATER_EQUAL);
cond = VerSetConditionMask(cond, VER_MINORVERSION, VER_GREATER_EQUAL);
cond = VerSetConditionMask(cond, VER_BUILDNUMBER, VER_GREATER_EQUAL);
// HACK: Use RtlVerifyVersionInfo instead of VerifyVersionInfoW as the
// latter lies unless the user knew to embed a non-default manifest
// announcing support for Windows 10 via supportedOS GUID
return RtlVerifyVersionInfo(&osvi, mask, cond) == 0;
}
GLFWbool _glfwConnectWin32(int platformID, _GLFWplatform* platform)
{
const _GLFWplatform win32 =
{
GLFW_PLATFORM_WIN32,
_glfwInitWin32,
_glfwTerminateWin32,
_glfwGetCursorPosWin32,
_glfwSetCursorPosWin32,
_glfwSetCursorModeWin32,
_glfwSetRawMouseMotionWin32,
_glfwRawMouseMotionSupportedWin32,
_glfwCreateCursorWin32,
_glfwCreateStandardCursorWin32,
_glfwDestroyCursorWin32,
_glfwSetCursorWin32,
_glfwGetScancodeNameWin32,
_glfwGetKeyScancodeWin32,
_glfwSetClipboardStringWin32,
_glfwGetClipboardStringWin32,
_glfwInitJoysticksWin32,
_glfwTerminateJoysticksWin32,
_glfwPollJoystickWin32,
_glfwGetMappingNameWin32,
_glfwUpdateGamepadGUIDWin32,
_glfwFreeMonitorWin32,
_glfwGetMonitorPosWin32,
_glfwGetMonitorContentScaleWin32,
_glfwGetMonitorWorkareaWin32,
_glfwGetVideoModesWin32,
_glfwGetVideoModeWin32,
_glfwGetGammaRampWin32,
_glfwSetGammaRampWin32,
_glfwCreateWindowWin32,
_glfwDestroyWindowWin32,
_glfwSetWindowTitleWin32,
_glfwSetWindowIconWin32,
_glfwGetWindowPosWin32,
_glfwSetWindowPosWin32,
_glfwGetWindowSizeWin32,
_glfwSetWindowSizeWin32,
_glfwSetWindowSizeLimitsWin32,
_glfwSetWindowAspectRatioWin32,
_glfwGetFramebufferSizeWin32,
_glfwGetWindowFrameSizeWin32,
_glfwGetWindowContentScaleWin32,
_glfwIconifyWindowWin32,
_glfwRestoreWindowWin32,
_glfwMaximizeWindowWin32,
_glfwShowWindowWin32,
_glfwHideWindowWin32,
_glfwRequestWindowAttentionWin32,
_glfwFocusWindowWin32,
_glfwSetWindowMonitorWin32,
_glfwWindowFocusedWin32,
_glfwWindowIconifiedWin32,
_glfwWindowVisibleWin32,
_glfwWindowMaximizedWin32,
_glfwWindowHoveredWin32,
_glfwFramebufferTransparentWin32,
_glfwGetWindowOpacityWin32,
_glfwSetWindowResizableWin32,
_glfwSetWindowDecoratedWin32,
_glfwSetWindowFloatingWin32,
_glfwSetWindowOpacityWin32,
_glfwSetWindowMousePassthroughWin32,
_glfwPollEventsWin32,
_glfwWaitEventsWin32,
_glfwWaitEventsTimeoutWin32,
_glfwPostEmptyEventWin32,
_glfwGetEGLPlatformWin32,
_glfwGetEGLNativeDisplayWin32,
_glfwGetEGLNativeWindowWin32,
_glfwGetRequiredInstanceExtensionsWin32,
_glfwGetPhysicalDevicePresentationSupportWin32,
_glfwCreateWindowSurfaceWin32,
};
*platform = win32;
return GLFW_TRUE;
}
int _glfwInitWin32(void)
{
if (!loadLibraries())
return GLFW_FALSE;
createKeyTables();
_glfwUpdateKeyNamesWin32();
if (_glfwIsWindows10Version1703OrGreaterWin32())
SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2);
else if (IsWindows8Point1OrGreater())
SetProcessDpiAwareness(PROCESS_PER_MONITOR_DPI_AWARE);
else if (IsWindowsVistaOrGreater())
SetProcessDPIAware();
if (!createHelperWindow())
return GLFW_FALSE;
_glfwPollMonitorsWin32();
return GLFW_TRUE;
}
void _glfwTerminateWin32(void)
{
if (_glfw.win32.deviceNotificationHandle)
UnregisterDeviceNotification(_glfw.win32.deviceNotificationHandle);
if (_glfw.win32.helperWindowHandle)
DestroyWindow(_glfw.win32.helperWindowHandle);
if (_glfw.win32.helperWindowClass)
UnregisterClassW(MAKEINTATOM(_glfw.win32.helperWindowClass), _glfw.win32.instance);
if (_glfw.win32.mainWindowClass)
UnregisterClassW(MAKEINTATOM(_glfw.win32.mainWindowClass), _glfw.win32.instance);
_glfw_free(_glfw.win32.clipboardString);
_glfw_free(_glfw.win32.rawInput);
_glfwTerminateWGL();
_glfwTerminateEGL();
_glfwTerminateOSMesa();
freeLibraries();
}

View File

@@ -0,0 +1,758 @@
//========================================================================
// GLFW 3.4 Win32 - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would
// be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such, and must not
// be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source
// distribution.
//
//========================================================================
// Please use C89 style variable declarations in this file because VS 2010
//========================================================================
#include "internal.h"
#include <stdio.h>
#include <math.h>
#define _GLFW_TYPE_AXIS 0
#define _GLFW_TYPE_SLIDER 1
#define _GLFW_TYPE_BUTTON 2
#define _GLFW_TYPE_POV 3
// Data produced with DirectInput device object enumeration
//
typedef struct _GLFWobjenumWin32
{
IDirectInputDevice8W* device;
_GLFWjoyobjectWin32* objects;
int objectCount;
int axisCount;
int sliderCount;
int buttonCount;
int povCount;
} _GLFWobjenumWin32;
// Define local copies of the necessary GUIDs
//
static const GUID _glfw_IID_IDirectInput8W =
{0xbf798031,0x483a,0x4da2,{0xaa,0x99,0x5d,0x64,0xed,0x36,0x97,0x00}};
static const GUID _glfw_GUID_XAxis =
{0xa36d02e0,0xc9f3,0x11cf,{0xbf,0xc7,0x44,0x45,0x53,0x54,0x00,0x00}};
static const GUID _glfw_GUID_YAxis =
{0xa36d02e1,0xc9f3,0x11cf,{0xbf,0xc7,0x44,0x45,0x53,0x54,0x00,0x00}};
static const GUID _glfw_GUID_ZAxis =
{0xa36d02e2,0xc9f3,0x11cf,{0xbf,0xc7,0x44,0x45,0x53,0x54,0x00,0x00}};
static const GUID _glfw_GUID_RxAxis =
{0xa36d02f4,0xc9f3,0x11cf,{0xbf,0xc7,0x44,0x45,0x53,0x54,0x00,0x00}};
static const GUID _glfw_GUID_RyAxis =
{0xa36d02f5,0xc9f3,0x11cf,{0xbf,0xc7,0x44,0x45,0x53,0x54,0x00,0x00}};
static const GUID _glfw_GUID_RzAxis =
{0xa36d02e3,0xc9f3,0x11cf,{0xbf,0xc7,0x44,0x45,0x53,0x54,0x00,0x00}};
static const GUID _glfw_GUID_Slider =
{0xa36d02e4,0xc9f3,0x11cf,{0xbf,0xc7,0x44,0x45,0x53,0x54,0x00,0x00}};
static const GUID _glfw_GUID_POV =
{0xa36d02f2,0xc9f3,0x11cf,{0xbf,0xc7,0x44,0x45,0x53,0x54,0x00,0x00}};
#define IID_IDirectInput8W _glfw_IID_IDirectInput8W
#define GUID_XAxis _glfw_GUID_XAxis
#define GUID_YAxis _glfw_GUID_YAxis
#define GUID_ZAxis _glfw_GUID_ZAxis
#define GUID_RxAxis _glfw_GUID_RxAxis
#define GUID_RyAxis _glfw_GUID_RyAxis
#define GUID_RzAxis _glfw_GUID_RzAxis
#define GUID_Slider _glfw_GUID_Slider
#define GUID_POV _glfw_GUID_POV
// Object data array for our clone of c_dfDIJoystick
// Generated with https://github.com/elmindreda/c_dfDIJoystick2
//
static DIOBJECTDATAFORMAT _glfwObjectDataFormats[] =
{
{ &GUID_XAxis,DIJOFS_X,DIDFT_AXIS|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,DIDOI_ASPECTPOSITION },
{ &GUID_YAxis,DIJOFS_Y,DIDFT_AXIS|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,DIDOI_ASPECTPOSITION },
{ &GUID_ZAxis,DIJOFS_Z,DIDFT_AXIS|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,DIDOI_ASPECTPOSITION },
{ &GUID_RxAxis,DIJOFS_RX,DIDFT_AXIS|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,DIDOI_ASPECTPOSITION },
{ &GUID_RyAxis,DIJOFS_RY,DIDFT_AXIS|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,DIDOI_ASPECTPOSITION },
{ &GUID_RzAxis,DIJOFS_RZ,DIDFT_AXIS|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,DIDOI_ASPECTPOSITION },
{ &GUID_Slider,DIJOFS_SLIDER(0),DIDFT_AXIS|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,DIDOI_ASPECTPOSITION },
{ &GUID_Slider,DIJOFS_SLIDER(1),DIDFT_AXIS|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,DIDOI_ASPECTPOSITION },
{ &GUID_POV,DIJOFS_POV(0),DIDFT_POV|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
{ &GUID_POV,DIJOFS_POV(1),DIDFT_POV|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
{ &GUID_POV,DIJOFS_POV(2),DIDFT_POV|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
{ &GUID_POV,DIJOFS_POV(3),DIDFT_POV|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
{ NULL,DIJOFS_BUTTON(0),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
{ NULL,DIJOFS_BUTTON(1),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
{ NULL,DIJOFS_BUTTON(2),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
{ NULL,DIJOFS_BUTTON(3),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
{ NULL,DIJOFS_BUTTON(4),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
{ NULL,DIJOFS_BUTTON(5),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
{ NULL,DIJOFS_BUTTON(6),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
{ NULL,DIJOFS_BUTTON(7),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
{ NULL,DIJOFS_BUTTON(8),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
{ NULL,DIJOFS_BUTTON(9),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
{ NULL,DIJOFS_BUTTON(10),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
{ NULL,DIJOFS_BUTTON(11),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
{ NULL,DIJOFS_BUTTON(12),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
{ NULL,DIJOFS_BUTTON(13),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
{ NULL,DIJOFS_BUTTON(14),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
{ NULL,DIJOFS_BUTTON(15),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
{ NULL,DIJOFS_BUTTON(16),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
{ NULL,DIJOFS_BUTTON(17),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
{ NULL,DIJOFS_BUTTON(18),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
{ NULL,DIJOFS_BUTTON(19),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
{ NULL,DIJOFS_BUTTON(20),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
{ NULL,DIJOFS_BUTTON(21),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
{ NULL,DIJOFS_BUTTON(22),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
{ NULL,DIJOFS_BUTTON(23),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
{ NULL,DIJOFS_BUTTON(24),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
{ NULL,DIJOFS_BUTTON(25),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
{ NULL,DIJOFS_BUTTON(26),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
{ NULL,DIJOFS_BUTTON(27),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
{ NULL,DIJOFS_BUTTON(28),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
{ NULL,DIJOFS_BUTTON(29),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
{ NULL,DIJOFS_BUTTON(30),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
{ NULL,DIJOFS_BUTTON(31),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
};
// Our clone of c_dfDIJoystick
//
static const DIDATAFORMAT _glfwDataFormat =
{
sizeof(DIDATAFORMAT),
sizeof(DIOBJECTDATAFORMAT),
DIDFT_ABSAXIS,
sizeof(DIJOYSTATE),
sizeof(_glfwObjectDataFormats) / sizeof(DIOBJECTDATAFORMAT),
_glfwObjectDataFormats
};
// Returns a description fitting the specified XInput capabilities
//
static const char* getDeviceDescription(const XINPUT_CAPABILITIES* xic)
{
switch (xic->SubType)
{
case XINPUT_DEVSUBTYPE_WHEEL:
return "XInput Wheel";
case XINPUT_DEVSUBTYPE_ARCADE_STICK:
return "XInput Arcade Stick";
case XINPUT_DEVSUBTYPE_FLIGHT_STICK:
return "XInput Flight Stick";
case XINPUT_DEVSUBTYPE_DANCE_PAD:
return "XInput Dance Pad";
case XINPUT_DEVSUBTYPE_GUITAR:
return "XInput Guitar";
case XINPUT_DEVSUBTYPE_DRUM_KIT:
return "XInput Drum Kit";
case XINPUT_DEVSUBTYPE_GAMEPAD:
{
if (xic->Flags & XINPUT_CAPS_WIRELESS)
return "Wireless Xbox Controller";
else
return "Xbox Controller";
}
}
return "Unknown XInput Device";
}
// Lexically compare device objects
//
static int compareJoystickObjects(const void* first, const void* second)
{
const _GLFWjoyobjectWin32* fo = first;
const _GLFWjoyobjectWin32* so = second;
if (fo->type != so->type)
return fo->type - so->type;
return fo->offset - so->offset;
}
// Checks whether the specified device supports XInput
// Technique from FDInputJoystickManager::IsXInputDeviceFast in ZDoom
//
static GLFWbool supportsXInput(const GUID* guid)
{
UINT i, count = 0;
RAWINPUTDEVICELIST* ridl;
GLFWbool result = GLFW_FALSE;
if (GetRawInputDeviceList(NULL, &count, sizeof(RAWINPUTDEVICELIST)) != 0)
return GLFW_FALSE;
ridl = _glfw_calloc(count, sizeof(RAWINPUTDEVICELIST));
if (GetRawInputDeviceList(ridl, &count, sizeof(RAWINPUTDEVICELIST)) == (UINT) -1)
{
_glfw_free(ridl);
return GLFW_FALSE;
}
for (i = 0; i < count; i++)
{
RID_DEVICE_INFO rdi;
char name[256];
UINT size;
if (ridl[i].dwType != RIM_TYPEHID)
continue;
ZeroMemory(&rdi, sizeof(rdi));
rdi.cbSize = sizeof(rdi);
size = sizeof(rdi);
if ((INT) GetRawInputDeviceInfoA(ridl[i].hDevice,
RIDI_DEVICEINFO,
&rdi, &size) == -1)
{
continue;
}
if (MAKELONG(rdi.hid.dwVendorId, rdi.hid.dwProductId) != (LONG) guid->Data1)
continue;
memset(name, 0, sizeof(name));
size = sizeof(name);
if ((INT) GetRawInputDeviceInfoA(ridl[i].hDevice,
RIDI_DEVICENAME,
name, &size) == -1)
{
break;
}
name[sizeof(name) - 1] = '\0';
if (strstr(name, "IG_"))
{
result = GLFW_TRUE;
break;
}
}
_glfw_free(ridl);
return result;
}
// Frees all resources associated with the specified joystick
//
static void closeJoystick(_GLFWjoystick* js)
{
_glfwInputJoystick(js, GLFW_DISCONNECTED);
if (js->win32.device)
{
IDirectInputDevice8_Unacquire(js->win32.device);
IDirectInputDevice8_Release(js->win32.device);
}
_glfw_free(js->win32.objects);
_glfwFreeJoystick(js);
}
// DirectInput device object enumeration callback
// Insights gleaned from SDL
//
static BOOL CALLBACK deviceObjectCallback(const DIDEVICEOBJECTINSTANCEW* doi,
void* user)
{
_GLFWobjenumWin32* data = user;
_GLFWjoyobjectWin32* object = data->objects + data->objectCount;
if (DIDFT_GETTYPE(doi->dwType) & DIDFT_AXIS)
{
DIPROPRANGE dipr;
if (memcmp(&doi->guidType, &GUID_Slider, sizeof(GUID)) == 0)
object->offset = DIJOFS_SLIDER(data->sliderCount);
else if (memcmp(&doi->guidType, &GUID_XAxis, sizeof(GUID)) == 0)
object->offset = DIJOFS_X;
else if (memcmp(&doi->guidType, &GUID_YAxis, sizeof(GUID)) == 0)
object->offset = DIJOFS_Y;
else if (memcmp(&doi->guidType, &GUID_ZAxis, sizeof(GUID)) == 0)
object->offset = DIJOFS_Z;
else if (memcmp(&doi->guidType, &GUID_RxAxis, sizeof(GUID)) == 0)
object->offset = DIJOFS_RX;
else if (memcmp(&doi->guidType, &GUID_RyAxis, sizeof(GUID)) == 0)
object->offset = DIJOFS_RY;
else if (memcmp(&doi->guidType, &GUID_RzAxis, sizeof(GUID)) == 0)
object->offset = DIJOFS_RZ;
else
return DIENUM_CONTINUE;
ZeroMemory(&dipr, sizeof(dipr));
dipr.diph.dwSize = sizeof(dipr);
dipr.diph.dwHeaderSize = sizeof(dipr.diph);
dipr.diph.dwObj = doi->dwType;
dipr.diph.dwHow = DIPH_BYID;
dipr.lMin = -32768;
dipr.lMax = 32767;
if (FAILED(IDirectInputDevice8_SetProperty(data->device,
DIPROP_RANGE,
&dipr.diph)))
{
return DIENUM_CONTINUE;
}
if (memcmp(&doi->guidType, &GUID_Slider, sizeof(GUID)) == 0)
{
object->type = _GLFW_TYPE_SLIDER;
data->sliderCount++;
}
else
{
object->type = _GLFW_TYPE_AXIS;
data->axisCount++;
}
}
else if (DIDFT_GETTYPE(doi->dwType) & DIDFT_BUTTON)
{
object->offset = DIJOFS_BUTTON(data->buttonCount);
object->type = _GLFW_TYPE_BUTTON;
data->buttonCount++;
}
else if (DIDFT_GETTYPE(doi->dwType) & DIDFT_POV)
{
object->offset = DIJOFS_POV(data->povCount);
object->type = _GLFW_TYPE_POV;
data->povCount++;
}
data->objectCount++;
return DIENUM_CONTINUE;
}
// DirectInput device enumeration callback
//
static BOOL CALLBACK deviceCallback(const DIDEVICEINSTANCE* di, void* user)
{
int jid = 0;
DIDEVCAPS dc;
DIPROPDWORD dipd;
IDirectInputDevice8* device;
_GLFWobjenumWin32 data;
_GLFWjoystick* js;
char guid[33];
char name[256];
for (jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++)
{
js = _glfw.joysticks + jid;
if (js->connected)
{
if (memcmp(&js->win32.guid, &di->guidInstance, sizeof(GUID)) == 0)
return DIENUM_CONTINUE;
}
}
if (supportsXInput(&di->guidProduct))
return DIENUM_CONTINUE;
if (FAILED(IDirectInput8_CreateDevice(_glfw.win32.dinput8.api,
&di->guidInstance,
&device,
NULL)))
{
_glfwInputError(GLFW_PLATFORM_ERROR, "Win32: Failed to create device");
return DIENUM_CONTINUE;
}
if (FAILED(IDirectInputDevice8_SetDataFormat(device, &_glfwDataFormat)))
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"Win32: Failed to set device data format");
IDirectInputDevice8_Release(device);
return DIENUM_CONTINUE;
}
ZeroMemory(&dc, sizeof(dc));
dc.dwSize = sizeof(dc);
if (FAILED(IDirectInputDevice8_GetCapabilities(device, &dc)))
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"Win32: Failed to query device capabilities");
IDirectInputDevice8_Release(device);
return DIENUM_CONTINUE;
}
ZeroMemory(&dipd, sizeof(dipd));
dipd.diph.dwSize = sizeof(dipd);
dipd.diph.dwHeaderSize = sizeof(dipd.diph);
dipd.diph.dwHow = DIPH_DEVICE;
dipd.dwData = DIPROPAXISMODE_ABS;
if (FAILED(IDirectInputDevice8_SetProperty(device,
DIPROP_AXISMODE,
&dipd.diph)))
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"Win32: Failed to set device axis mode");
IDirectInputDevice8_Release(device);
return DIENUM_CONTINUE;
}
memset(&data, 0, sizeof(data));
data.device = device;
data.objects = _glfw_calloc(dc.dwAxes + (size_t) dc.dwButtons + dc.dwPOVs,
sizeof(_GLFWjoyobjectWin32));
if (FAILED(IDirectInputDevice8_EnumObjects(device,
deviceObjectCallback,
&data,
DIDFT_AXIS | DIDFT_BUTTON | DIDFT_POV)))
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"Win32: Failed to enumerate device objects");
IDirectInputDevice8_Release(device);
_glfw_free(data.objects);
return DIENUM_CONTINUE;
}
qsort(data.objects, data.objectCount,
sizeof(_GLFWjoyobjectWin32),
compareJoystickObjects);
if (!WideCharToMultiByte(CP_UTF8, 0,
di->tszInstanceName, -1,
name, sizeof(name),
NULL, NULL))
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"Win32: Failed to convert joystick name to UTF-8");
IDirectInputDevice8_Release(device);
_glfw_free(data.objects);
return DIENUM_STOP;
}
// Generate a joystick GUID that matches the SDL 2.0.5+ one
if (memcmp(&di->guidProduct.Data4[2], "PIDVID", 6) == 0)
{
sprintf(guid, "03000000%02x%02x0000%02x%02x000000000000",
(uint8_t) di->guidProduct.Data1,
(uint8_t) (di->guidProduct.Data1 >> 8),
(uint8_t) (di->guidProduct.Data1 >> 16),
(uint8_t) (di->guidProduct.Data1 >> 24));
}
else
{
sprintf(guid, "05000000%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x00",
name[0], name[1], name[2], name[3],
name[4], name[5], name[6], name[7],
name[8], name[9], name[10]);
}
js = _glfwAllocJoystick(name, guid,
data.axisCount + data.sliderCount,
data.buttonCount,
data.povCount);
if (!js)
{
IDirectInputDevice8_Release(device);
_glfw_free(data.objects);
return DIENUM_STOP;
}
js->win32.device = device;
js->win32.guid = di->guidInstance;
js->win32.objects = data.objects;
js->win32.objectCount = data.objectCount;
_glfwInputJoystick(js, GLFW_CONNECTED);
return DIENUM_CONTINUE;
}
//////////////////////////////////////////////////////////////////////////
////// GLFW internal API //////
//////////////////////////////////////////////////////////////////////////
// Checks for new joysticks after DBT_DEVICEARRIVAL
//
void _glfwDetectJoystickConnectionWin32(void)
{
if (_glfw.win32.xinput.instance)
{
DWORD index;
for (index = 0; index < XUSER_MAX_COUNT; index++)
{
int jid;
char guid[33];
XINPUT_CAPABILITIES xic;
_GLFWjoystick* js;
for (jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++)
{
if (_glfw.joysticks[jid].connected &&
_glfw.joysticks[jid].win32.device == NULL &&
_glfw.joysticks[jid].win32.index == index)
{
break;
}
}
if (jid <= GLFW_JOYSTICK_LAST)
continue;
if (XInputGetCapabilities(index, 0, &xic) != ERROR_SUCCESS)
continue;
// Generate a joystick GUID that matches the SDL 2.0.5+ one
sprintf(guid, "78696e707574%02x000000000000000000",
xic.SubType & 0xff);
js = _glfwAllocJoystick(getDeviceDescription(&xic), guid, 6, 10, 1);
if (!js)
continue;
js->win32.index = index;
_glfwInputJoystick(js, GLFW_CONNECTED);
}
}
if (_glfw.win32.dinput8.api)
{
if (FAILED(IDirectInput8_EnumDevices(_glfw.win32.dinput8.api,
DI8DEVCLASS_GAMECTRL,
deviceCallback,
NULL,
DIEDFL_ALLDEVICES)))
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"Failed to enumerate DirectInput8 devices");
return;
}
}
}
// Checks for joystick disconnection after DBT_DEVICEREMOVECOMPLETE
//
void _glfwDetectJoystickDisconnectionWin32(void)
{
int jid;
for (jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++)
{
_GLFWjoystick* js = _glfw.joysticks + jid;
if (js->connected)
_glfwPollJoystickWin32(js, _GLFW_POLL_PRESENCE);
}
}
//////////////////////////////////////////////////////////////////////////
////// GLFW platform API //////
//////////////////////////////////////////////////////////////////////////
GLFWbool _glfwInitJoysticksWin32(void)
{
if (_glfw.win32.dinput8.instance)
{
if (FAILED(DirectInput8Create(_glfw.win32.instance,
DIRECTINPUT_VERSION,
&IID_IDirectInput8W,
(void**) &_glfw.win32.dinput8.api,
NULL)))
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"Win32: Failed to create interface");
return GLFW_FALSE;
}
}
_glfwDetectJoystickConnectionWin32();
return GLFW_TRUE;
}
void _glfwTerminateJoysticksWin32(void)
{
int jid;
for (jid = GLFW_JOYSTICK_1; jid <= GLFW_JOYSTICK_LAST; jid++)
closeJoystick(_glfw.joysticks + jid);
if (_glfw.win32.dinput8.api)
IDirectInput8_Release(_glfw.win32.dinput8.api);
}
GLFWbool _glfwPollJoystickWin32(_GLFWjoystick* js, int mode)
{
if (js->win32.device)
{
int i, ai = 0, bi = 0, pi = 0;
HRESULT result;
DIJOYSTATE state = {0};
IDirectInputDevice8_Poll(js->win32.device);
result = IDirectInputDevice8_GetDeviceState(js->win32.device,
sizeof(state),
&state);
if (result == DIERR_NOTACQUIRED || result == DIERR_INPUTLOST)
{
IDirectInputDevice8_Acquire(js->win32.device);
IDirectInputDevice8_Poll(js->win32.device);
result = IDirectInputDevice8_GetDeviceState(js->win32.device,
sizeof(state),
&state);
}
if (FAILED(result))
{
closeJoystick(js);
return GLFW_FALSE;
}
if (mode == _GLFW_POLL_PRESENCE)
return GLFW_TRUE;
for (i = 0; i < js->win32.objectCount; i++)
{
const void* data = (char*) &state + js->win32.objects[i].offset;
switch (js->win32.objects[i].type)
{
case _GLFW_TYPE_AXIS:
case _GLFW_TYPE_SLIDER:
{
const float value = (*((LONG*) data) + 0.5f) / 32767.5f;
_glfwInputJoystickAxis(js, ai, value);
ai++;
break;
}
case _GLFW_TYPE_BUTTON:
{
const char value = (*((BYTE*) data) & 0x80) != 0;
_glfwInputJoystickButton(js, bi, value);
bi++;
break;
}
case _GLFW_TYPE_POV:
{
const int states[9] =
{
GLFW_HAT_UP,
GLFW_HAT_RIGHT_UP,
GLFW_HAT_RIGHT,
GLFW_HAT_RIGHT_DOWN,
GLFW_HAT_DOWN,
GLFW_HAT_LEFT_DOWN,
GLFW_HAT_LEFT,
GLFW_HAT_LEFT_UP,
GLFW_HAT_CENTERED
};
// Screams of horror are appropriate at this point
int stateIndex = LOWORD(*(DWORD*) data) / (45 * DI_DEGREES);
if (stateIndex < 0 || stateIndex > 8)
stateIndex = 8;
_glfwInputJoystickHat(js, pi, states[stateIndex]);
pi++;
break;
}
}
}
}
else
{
int i, dpad = 0;
DWORD result;
XINPUT_STATE xis;
const WORD buttons[10] =
{
XINPUT_GAMEPAD_A,
XINPUT_GAMEPAD_B,
XINPUT_GAMEPAD_X,
XINPUT_GAMEPAD_Y,
XINPUT_GAMEPAD_LEFT_SHOULDER,
XINPUT_GAMEPAD_RIGHT_SHOULDER,
XINPUT_GAMEPAD_BACK,
XINPUT_GAMEPAD_START,
XINPUT_GAMEPAD_LEFT_THUMB,
XINPUT_GAMEPAD_RIGHT_THUMB
};
result = XInputGetState(js->win32.index, &xis);
if (result != ERROR_SUCCESS)
{
if (result == ERROR_DEVICE_NOT_CONNECTED)
closeJoystick(js);
return GLFW_FALSE;
}
if (mode == _GLFW_POLL_PRESENCE)
return GLFW_TRUE;
_glfwInputJoystickAxis(js, 0, (xis.Gamepad.sThumbLX + 0.5f) / 32767.5f);
_glfwInputJoystickAxis(js, 1, -(xis.Gamepad.sThumbLY + 0.5f) / 32767.5f);
_glfwInputJoystickAxis(js, 2, (xis.Gamepad.sThumbRX + 0.5f) / 32767.5f);
_glfwInputJoystickAxis(js, 3, -(xis.Gamepad.sThumbRY + 0.5f) / 32767.5f);
_glfwInputJoystickAxis(js, 4, xis.Gamepad.bLeftTrigger / 127.5f - 1.f);
_glfwInputJoystickAxis(js, 5, xis.Gamepad.bRightTrigger / 127.5f - 1.f);
for (i = 0; i < 10; i++)
{
const char value = (xis.Gamepad.wButtons & buttons[i]) ? 1 : 0;
_glfwInputJoystickButton(js, i, value);
}
if (xis.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_UP)
dpad |= GLFW_HAT_UP;
if (xis.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_RIGHT)
dpad |= GLFW_HAT_RIGHT;
if (xis.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_DOWN)
dpad |= GLFW_HAT_DOWN;
if (xis.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_LEFT)
dpad |= GLFW_HAT_LEFT;
_glfwInputJoystickHat(js, 0, dpad);
}
return GLFW_TRUE;
}
const char* _glfwGetMappingNameWin32(void)
{
return "Windows";
}
void _glfwUpdateGamepadGUIDWin32(char* guid)
{
if (strcmp(guid + 20, "504944564944") == 0)
{
char original[33];
strncpy(original, guid, sizeof(original) - 1);
sprintf(guid, "03000000%.4s0000%.4s000000000000",
original, original + 4);
}
}

View File

@@ -0,0 +1,53 @@
//========================================================================
// GLFW 3.4 Win32 - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would
// be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such, and must not
// be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source
// distribution.
//
//========================================================================
#define GLFW_WIN32_JOYSTICK_STATE _GLFWjoystickWin32 win32;
#define GLFW_WIN32_LIBRARY_JOYSTICK_STATE
#define GLFW_BUILD_WIN32_MAPPINGS
// Joystick element (axis, button or slider)
//
typedef struct _GLFWjoyobjectWin32
{
int offset;
int type;
} _GLFWjoyobjectWin32;
// Win32-specific per-joystick data
//
typedef struct _GLFWjoystickWin32
{
_GLFWjoyobjectWin32* objects;
int objectCount;
IDirectInputDevice8W* device;
DWORD index;
GUID guid;
} _GLFWjoystickWin32;
void _glfwDetectJoystickConnectionWin32(void);
void _glfwDetectJoystickDisconnectionWin32(void);

Some files were not shown because too many files have changed in this diff Show More